Merge pull request #113 from nwg-piotr/touch

Don't launch if the window has been scrolled
This commit is contained in:
Piotr Miller
2024-02-06 03:38:09 +01:00
committed by GitHub
2 changed files with 23 additions and 2 deletions

13
main.go
View File

@@ -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 {

View File

@@ -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