diff --git a/main.go b/main.go index 05c7d9d..97fa488 100644 --- a/main.go +++ b/main.go @@ -32,6 +32,7 @@ var ( preferredApps map[string]interface{} exclusions []string hyprlandMonitors []monitor + beenScrolled bool ) var categoryNames = [...]string{ @@ -518,6 +519,18 @@ func main() { resultWindow.SetEvents(int(gdk.ALL_EVENTS_MASK)) resultWindow.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) + // On touch screen we don't want the button-release-event to launch the app if the user just wanted to scroll the + // window. Let's forbid doing so if the content has been scrolled. We will reset the value on button-press-event. + // Resolves https://github.com/nwg-piotr/nwg-drawer/issues/110 + vAdj := resultWindow.GetVAdjustment() + vAdj.Connect("value-changed", func() { + beenScrolled = true + }) + hAdj := resultWindow.GetHAdjustment() + hAdj.Connect("value-changed", func() { + beenScrolled = true + }) + resultWindow.Connect("button-release-event", func(_ *gtk.ScrolledWindow, event *gdk.Event) bool { btnEvent := gdk.EventButtonNewFromEvent(event) if btnEvent.Button() == 3 { diff --git a/uicomponents.go b/uicomponents.go index 6997570..d5254ab 100644 --- a/uicomponents.go +++ b/uicomponents.go @@ -264,11 +264,19 @@ func flowBoxButton(entry desktopEntry) *gtk.Button { r := substring(desc, 0, 117) desc = fmt.Sprintf("%s…", string(r)) } + + button.Connect("button-press-event", func() { + // if not scrolled from now on, we will allow launching apps on button-release-event + beenScrolled = false + }) + button.Connect("button-release-event", func(btn *gtk.Button, e *gdk.Event) bool { btnEvent := gdk.EventButtonNewFromEvent(e) if btnEvent.Button() == 1 { - launch(exec, terminal) - return true + if !beenScrolled { + launch(exec, terminal) + return true + } } else if btnEvent.Button() == 3 { pinItem(ID) return true