From 5004aac259b2b5c27a2e5ad38e9bb72d3bf85422 Mon Sep 17 00:00:00 2001 From: Atterpac <89053530+atterpac@users.noreply.github.com> Date: Thu, 5 Sep 2024 15:10:05 -0700 Subject: [PATCH] [V3] Refactor linux ignore mouse events (#3721) refactor linux ignore mouse events changelog.md --- mkdocs-website/docs/en/changelog.md | 1 + v3/pkg/application/linux_cgo.go | 8 ++++++++ v3/pkg/application/webview_window_linux.go | 13 +++---------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/mkdocs-website/docs/en/changelog.md b/mkdocs-website/docs/en/changelog.md index c380987a5af..0518eafca97 100644 --- a/mkdocs-website/docs/en/changelog.md +++ b/mkdocs-website/docs/en/changelog.md @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Services have been expanded to provide plugin functionality. By [atterpac](https://github.com/atterpac) and [leaanthony](https://github.com/leaanthony) in [#3570](https://github.com/wailsapp/wails/pull/3570) ### Fixed +- [linux] Fixed linux compile error introduced by IgnoreMouseEvents addition by [atterpac](https://github.com/atterpac) in [#3721](https://github.com/wailsapp/wails/pull/3721) - [windows] Fixed syso icon file generation bug by [atterpac](https://github.com/atterpac) in [#3675](https://github.com/wailsapp/wails/pull/3675) - [linux] Fix to run natively in wayland incorporated from [#1811](https://github.com/wailsapp/wails/pull/1811) in [#3614](https://github.com/wailsapp/wails/pull/3614) by [@stendler](https://github.com/stendler) - [windows] Fixed system tray startup panic in [#3693](https://github.com/wailsapp/wails/issues/3693) by [@DeltaLaboratory](https://github.com/DeltaLaboratory) diff --git a/v3/pkg/application/linux_cgo.go b/v3/pkg/application/linux_cgo.go index f55daa71117..29e3f75fdcf 100644 --- a/v3/pkg/application/linux_cgo.go +++ b/v3/pkg/application/linux_cgo.go @@ -1373,6 +1373,14 @@ func (w *linuxWebviewWindow) position() (int, int) { return int(x), int(y) } +func (w *linuxWebviewWindow) ignoreMouse(ignore bool) { + if ignore { + C.gtk_widget_set_events((*C.GtkWidget)(unsafe.Pointer(w.window)), C.GDK_ENTER_NOTIFY_MASK|C.GDK_LEAVE_NOTIFY_MASK) + } else { + C.gtk_widget_set_events((*C.GtkWidget)(unsafe.Pointer(w.window)), C.GDK_ALL_EVENTS_MASK) + } +} + // FIXME Change this to reflect mouse button! // //export onButtonEvent diff --git a/v3/pkg/application/webview_window_linux.go b/v3/pkg/application/webview_window_linux.go index cb7c7744fa0..22ede469603 100644 --- a/v3/pkg/application/webview_window_linux.go +++ b/v3/pkg/application/webview_window_linux.go @@ -2,8 +2,7 @@ package application -import "C" -import ( +import ( "fmt" "time" @@ -282,7 +281,7 @@ func (w *linuxWebviewWindow) run() { } // Ignore mouse events if requested - w.setIgnoreMouseEvents(options.IgnoreMouseEvents) + w.setIgnoreMouseEvents(w.parent.options.IgnoreMouseEvents) startURL, err := assetserver.GetStartURL(w.parent.options.URL) if err != nil { @@ -375,11 +374,5 @@ func (w *linuxWebviewWindow) isIgnoreMouseEvents() bool { } func (w *linuxWebviewWindow) setIgnoreMouseEvents(ignore bool) { - w.ignoreMouseEvents = ignore - - if ignore { - C.gtk_widget_set_events((*C.GtkWidget)(unsafe.Pointer(w.window)), C.GDK_ENTER_NOTIFY_MASK|C.GDK_LEAVE_NOTIFY_MASK) - } else { - C.gtk_widget_set_events((*C.GtkWidget)(unsafe.Pointer(w.window)), C.GDK_ALL_EVENTS_MASK) - } + w.ignoreMouse(w.ignoreMouseEvents) }