Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
nwg-piotr committed Feb 6, 2024
2 parents b056b4c + 42b55d4 commit 71ce3b5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
13 changes: 13 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var (
preferredApps map[string]interface{}
exclusions []string
hyprlandMonitors []monitor
beenScrolled bool
)

var categoryNames = [...]string{
Expand Down Expand Up @@ -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 {
Expand Down
12 changes: 10 additions & 2 deletions uicomponents.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 71ce3b5

Please sign in to comment.