Skip to content

Commit

Permalink
[V3] Refactor linux ignore mouse events (#3721)
Browse files Browse the repository at this point in the history
refactor linux ignore mouse events

changelog.md
  • Loading branch information
atterpac authored Sep 5, 2024
1 parent 2460b57 commit 5004aac
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions mkdocs-website/docs/en/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions v3/pkg/application/linux_cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 3 additions & 10 deletions v3/pkg/application/webview_window_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

package application

import "C"
import (
import (
"fmt"
"time"

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}

0 comments on commit 5004aac

Please sign in to comment.