nwg-piotr / nwg-drawer

Application drawer for wlroots-based Wayland compositors
MIT License
250 stars 27 forks source link

Touch swiping results in a mouse click at the end of the action #36

Closed lheimbs closed 2 years ago

lheimbs commented 2 years ago

Describe the bug

When swiping up/down on a touchscreen enabled device the drawer does scroll down while the scrolling action is in progress but immediately exits upon lifting the finger from the touchscreen. Essentially, at the point where the pointer is at the end of the touch action a mouse click is done, which either opens the app the pointer is on or quits the drawer.

To Repoduce

Steps to reproduce the behavior:

Expected behavior

A swiping action should not result in a mouse click. I realize this might be difficult to reproduce without a touch device so i'd happily help to debug this if you are interested in making this work on a touchscreen.

Incidentally, the nwggrid works as expected

Desktop (please complete the following information):

Additional context

$ nwg-drawer -d    
INFO[0000] term: xterm-kitty                            
INFO[0000] lang: en_US                                  
INFO[0000] Config dir: /home/user/.config/nwg-drawer   
INFO[0000] Found 0 pinned items                         
INFO[0000] Found 89 desktop files                       
INFO[0000] Skipped 0 duplicates; 23 .desktop entries hidden by "NoDisplay=true" 
INFO[0000] /home/user/.config/nwg-drawer/preferred-apps.json file not found 
INFO[0000] /home/user/.config/nwg-drawer/excluded-dirs file not found 
INFO[0000] Using style from /home/user/.config/nwg-drawer/drawer.css 
WARN[0000] Undefined icon for XDvi                      
WARN[0000] /home/user/.config/user-dirs.dirs file not found, using defaults 

** (nwg-drawer:148169): WARNING **: 23:04:00.285: gtk-layer-shell v0.6.0 may not work on GTK v3.24.31. If you experience crashes, check https://github.com/wmww/gtk-layer-shell/blob/master/compatibility.md
INFO[0000] UI created in 423 ms. Thank you for your patience. 
ERRO[0000] ERROR%!(EXTRA syscall.Errno=no such file or directory) 
nwg-piotr commented 2 years ago

Well, I connected the widow to button-release-event for it to close when clicked outside any icon.

https://github.com/nwg-piotr/nwg-drawer/blob/94c94b8b1e125c00c386d52c738b01dded7d4529/main.go#L420

A swiping action should not result in a mouse click.

This is beyond my control.

It seems GTK fires the button-release-event event on the end of swipe gestures... Probably some workaround is possible, but without a touch screen on my end it's going to take ages.

lheimbs commented 2 years ago

Hi Piotr, Thanks for the reply. I'll try to get into this myself but it might take a while since I'm neither experienced with go nor gtk.

The dock/drawer/etc. are great programs btw. and really suit people like me who have a touchscreen device and don't want to use an entire DE like gnome/kde

nwg-piotr commented 2 years ago

Thank you, it's great to hear.

I'm currently working hard on integration of all this stuff with a common management app, and some presets to choose from. It's going to be included into the next ArchLabs Linux iso. When I'm on the beta stage of this work, I'll try to get my old netbook back to life, and take a look at the issue. It's got touch screen, unfortunately broken. :/

nightly-brew commented 2 years ago

A similar issue affects scrolling by grabbing the scrollbar with the mouse: when I release the bar, the drawer closes. Even though the aformentioned issue is related to how gtk handles touch swiping, I think the button-release-event part could benefit from a little rework.

nwg-piotr commented 2 years ago

If you just want to close the window, without touching the keyboard, it's convenient to be able to just click outside icons.

resultWindow.Connect("button-release-event", func(sw *gtk.ScrolledWindow, e *gdk.Event) bool {
        btnEvent := gdk.EventButtonNewFromEvent(e)
        if btnEvent.Button() == 1 || btnEvent.Button() == 3 {
            if !*resident {
                gtk.MainQuit()
            } else {
                restoreStateAndHide()
            }
            return true
        }
        return false
    })

For this not to happen on drag end, we could restrict the action to just the right mouse button. What do you think?

nwg-piotr commented 2 years ago

Should be "RMB" above. :) @lheimbs, could you build from the issue36 branch and tell me if it helps?

lheimbs commented 2 years ago

I just tried it and works nicely both while touch swiping and grabbing the scrollbar with the mouse. Thanks!

nwg-piotr commented 2 years ago

Very well. I need to wait some time before releasing, as there were too many releases lately. :) Thanks for testing!

nightly-brew commented 2 years ago

Sounds great! You might want to advertise this feature in the README though, so users aren't surprised to see the drawer disappear.

nwg-piotr commented 2 years ago

Yes, I will. This will be mentioned in release notes, though, but who reads them?