Skip to content

Commit

Permalink
check if window scrolled #110
Browse files Browse the repository at this point in the history
  • Loading branch information
nwg-piotr committed Feb 6, 2024
1 parent 631b651 commit 6b39eba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
10 changes: 10 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,15 @@ func main() {
resultWindow.SetEvents(int(gdk.ALL_EVENTS_MASK))
resultWindow.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)

vAdj := resultWindow.GetVAdjustment()
vAdj.Connect("value-changed", func() {
beenScrolled = true
})
hAdj := resultWindow.GetVAdjustment()
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
11 changes: 9 additions & 2 deletions uicomponents.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,18 @@ func flowBoxButton(entry desktopEntry) *gtk.Button {
r := substring(desc, 0, 117)
desc = fmt.Sprintf("%s…", string(r))
}

button.Connect("button-press-event", func() {
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 6b39eba

Please sign in to comment.