marklieberman / foxygestures

Mouse gestures for Firefox
GNU General Public License v3.0
188 stars 19 forks source link

On Linux, gestures can apply to the wrong window under some window managers #268

Open siebenmann opened 6 years ago

siebenmann commented 6 years ago

If you use a window manager that allows for unusual window focus policies (as I do), it's possible to wind up with the window manager focus being on one Firefox window but your mouse being in another one. If you draw gestures in this situation, such as 'close tab', the mouse trails will appear in the window under your mouse but the gesture action will be applied to the window with focus.

Looking at the code, I suspect that this is happening because action functions like closeTabTransition assume that what the browser reports as the current window and tab are the window and tab that gestures have been drawn in. I don't know if it would be simple to fix this by taking the tab ID from the data passed in to the action functions, which I believe ultimately comes from the tab itself.

Even in my window manager (fvwm) and with my focus policy (what fvwm calls 'SloppyFocus', where focus is normally in the window the mouse was in last), reproducing this is not easy. It may happen more readily in X window managers which completely decouple focus policy from mouse position (eg, you move the focus around purely with keyboard commands).

marklieberman commented 6 years ago

I don't have a lot of experience with desktop Linux. Can you recommend an easy to setup distro I can use for testing in a VM?

siebenmann commented 6 years ago

It's going to take me some time to put together a good 'how to reproduce this from a standing start' guide. Because you need an uncommon window manager and window manager setup, it's unfortunately not simple (and perhaps not possible) to reproduce this on normal Linux desktops, as far as I know.

(You can switch the keyboard focus to a window other than the one under the mouse in many desktops, but the moment you start a mouse gesture by holding the mouse button down, common desktops will put the keyboard focus back on the window under the mouse, and so things work right.)

jwcacces commented 1 year ago

I'm having the same experience on macOS Monterey (12.5.1). When making gestures on a non-focused windows, the focused window, not the gestured window, gets the action.

This usually results in me closing a tab in the wrong window.

https://user-images.githubusercontent.com/7291077/194586916-208b1e67-3e74-4291-a349-79cae0c60741.mov