Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alt-Drag triggers Alt menu in Firefox and Wine apps #9

Open
rprichard opened this issue Apr 6, 2017 · 4 comments
Open

Alt-Drag triggers Alt menu in Firefox and Wine apps #9

rprichard opened this issue Apr 6, 2017 · 4 comments
Labels
enhancement The report requests an enhancement beyond the intended behaviour.

Comments

@rprichard
Copy link

rprichard commented Apr 6, 2017

When I use Alt-mouse to move/resize a window with Blackbox, the menu activates in certain applications. For example, with Firefox, the menu is normally invisible. Pressing Alt shows the menu and transfers keyboard focus to it. The problem also affects Wine (e.g. Notepad), because Alt transfers focus to the menu in Windows.

Ideally, pressing Alt would not activate the menu.

Somehow, xfwm4 avoids this problem, but I'm not sure how. Maybe it's got something to do with window focus. The Alt-Tab switching in bbkeys also avoids the problem.

(Aside: The problem is much worse in Windows. The solution that altdrag uses is to generate a fake Ctrl keypress (e.g. AltDown -> dragging -> CtrlDown -> CtrlUp -> AltUp), but I didn't see any Ctrl keypresses with xev.

Edit: I'm using commit 8c9e2af, Blackbox 0.72.

@rprichard
Copy link
Author

Another Firefox observation: I clicked on the initial default Google search box to display a blinking caret. With xfwm4, when I use Alt-drag to move/resize Firefox, its window remains focused according to its title bar, but the caret stops blinking. With blackbox, the caret remains blinking.

@rprichard
Copy link
Author

I tested by Alt-moving an xev event dumping window, and it looks like xfwm4 "defocuses" a window while it's being moved/resized. I'm guessing that loss of focus is what's preventing the menubar from activating with Firefox.

blackbox:

[2017-04-06 15:38:45.212483] KeyPress event, serial 38, synthetic NO, window 0xc00001,
[2017-04-06 15:38:45.212562]     root 0x4fc, subw 0x0, time 50764597, (294,350), root:(4054,681),
[2017-04-06 15:38:45.212631]     state 0x0, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
[2017-04-06 15:38:45.212701]     XLookupString gives 0 bytes:
[2017-04-06 15:38:45.212745]     XmbLookupString gives 0 bytes:
[2017-04-06 15:38:45.212793]     XFilterEvent returns: False
[2017-04-06 15:38:45.707345]
[2017-04-06 15:38:45.707424] LeaveNotify event, serial 38, synthetic NO, window 0xc00001,
[2017-04-06 15:38:45.707465]     root 0x4fc, subw 0x0, time 50765092, (294,350), root:(4054,681),
[2017-04-06 15:38:45.707525]     mode NotifyGrab, detail NotifyAncestor, same_screen YES,
[2017-04-06 15:38:45.707598]     focus YES, state 264
[2017-04-06 15:38:48.651466]
[2017-04-06 15:38:48.651567] EnterNotify event, serial 38, synthetic NO, window 0xc00001,
[2017-04-06 15:38:48.651643]     root 0x4fc, subw 0x0, time 50768036, (294,350), root:(4067,686),
[2017-04-06 15:38:48.651714]     mode NotifyUngrab, detail NotifyAncestor, same_screen YES,
[2017-04-06 15:38:48.651778]     focus YES, state 8
[2017-04-06 15:38:48.651837]
[2017-04-06 15:38:48.651897] KeymapNotify event, serial 38, synthetic NO, window 0x0,
[2017-04-06 15:38:48.651958]     keys:  4294967292 0   0   0   0   0   0   0   1   0   0   0   0   0   0   0
[2017-04-06 15:38:48.652019]            0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
[2017-04-06 15:38:48.652081]
[2017-04-06 15:38:48.652131] ConfigureNotify event, serial 38, synthetic YES, window 0xc00001,
[2017-04-06 15:38:48.652185]     event 0xc00001, window 0xc00001, (3773,336), width 669, height 626,
[2017-04-06 15:38:48.652236]     border_width 2, above 0x4a0018d, override NO
[2017-04-06 15:38:49.874441]
[2017-04-06 15:38:49.874548] KeyRelease event, serial 38, synthetic NO, window 0xc00001,
[2017-04-06 15:38:49.874617]     root 0x4fc, subw 0x0, time 50769259, (294,350), root:(4067,686),
[2017-04-06 15:38:49.874679]     state 0x8, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
[2017-04-06 15:38:49.874725]     XLookupString gives 0 bytes:
[2017-04-06 15:38:49.874764]     XFilterEvent returns: False

xfwm4:

[2017-04-06 15:37:24.439671] KeyPress event, serial 37, synthetic NO, window 0x4a00001,
[2017-04-06 15:37:24.439733]     root 0x4fc, subw 0x0, time 50683824, (247,293), root:(4060,738),
[2017-04-06 15:37:24.439799]     state 0x0, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
[2017-04-06 15:37:24.439871]     XLookupString gives 0 bytes:
[2017-04-06 15:37:24.439931]     XmbLookupString gives 0 bytes:
[2017-04-06 15:37:24.440004]     XFilterEvent returns: False
[2017-04-06 15:37:25.172882]
[2017-04-06 15:37:25.172965] EnterNotify event, serial 37, synthetic NO, window 0x4a00001,
[2017-04-06 15:37:25.173004]     root 0x4fc, subw 0x0, time 50684557, (251,296), root:(4064,741),
[2017-04-06 15:37:25.173059]     mode NotifyUngrab, detail NotifyAncestor, same_screen YES,
[2017-04-06 15:37:25.173098]     focus YES, state 264
[2017-04-06 15:37:25.173137]
[2017-04-06 15:37:25.173175] KeymapNotify event, serial 37, synthetic NO, window 0x0,
[2017-04-06 15:37:25.173212]     keys:  4294967292 0   0   0   0   0   0   0   1   0   0   0   0   0   0   0
[2017-04-06 15:37:25.173249]            0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
[2017-04-06 15:37:25.173283]
[2017-04-06 15:37:25.173318] FocusOut event, serial 37, synthetic NO, window 0x4a00001,
[2017-04-06 15:37:25.173356]     mode NotifyGrab, detail NotifyAncestor
[2017-04-06 15:37:25.173392]
[2017-04-06 15:37:25.173427] LeaveNotify event, serial 37, synthetic NO, window 0x4a00001,
[2017-04-06 15:37:25.173463]     root 0x4fc, subw 0x0, time 50684557, (251,296), root:(4064,741),
[2017-04-06 15:37:25.173500]     mode NotifyGrab, detail NotifyAncestor, same_screen YES,
[2017-04-06 15:37:25.173534]     focus YES, state 264
[2017-04-06 15:37:25.205176]
[2017-04-06 15:37:25.205264] ConfigureNotify event, serial 37, synthetic YES, window 0x4a00001,
[2017-04-06 15:37:25.205339]     event 0x4a00001, window 0x4a00001, (3818,449), width 580, height 618,
[2017-04-06 15:37:25.205411]     border_width 0, above 0x0, override NO
[2017-04-06 15:37:25.240279]
[2017-04-06 15:37:25.240362] ConfigureNotify event, serial 37, synthetic YES, window 0x4a00001,
[2017-04-06 15:37:25.240442]     event 0x4a00001, window 0x4a00001, (3818,450), width 580, height 618,
[2017-04-06 15:37:25.240515]     border_width 0, above 0x0, override NO
[2017-04-06 15:37:25.252894]
[2017-04-06 15:37:25.252982] ConfigureNotify event, serial 37, synthetic YES, window 0x4a00001,
[2017-04-06 15:37:25.253059]     event 0x4a00001, window 0x4a00001, (3819,451), width 580, height 618,
[2017-04-06 15:37:25.253122]     border_width 0, above 0x0, override NO
[2017-04-06 15:37:25.271163]
[2017-04-06 15:37:25.271241] ConfigureNotify event, serial 37, synthetic YES, window 0x4a00001,
[2017-04-06 15:37:25.271289]     event 0x4a00001, window 0x4a00001, (3819,452), width 580, height 618,
[2017-04-06 15:37:25.271328]     border_width 0, above 0x0, override NO
[2017-04-06 15:37:25.300971]
[2017-04-06 15:37:25.301041] ConfigureNotify event, serial 37, synthetic YES, window 0x4a00001,
[2017-04-06 15:37:25.301082]     event 0x4a00001, window 0x4a00001, (3820,452), width 580, height 618,
[2017-04-06 15:37:25.301120]     border_width 0, above 0x0, override NO
[2017-04-06 15:37:25.378067]
[2017-04-06 15:37:25.378137] ConfigureNotify event, serial 37, synthetic YES, window 0x4a00001,
[2017-04-06 15:37:25.378179]     event 0x4a00001, window 0x4a00001, (3820,453), width 580, height 618,
[2017-04-06 15:37:25.378217]     border_width 0, above 0x0, override NO
[2017-04-06 15:37:25.410005]
[2017-04-06 15:37:25.410074] ConfigureNotify event, serial 37, synthetic YES, window 0x4a00001,
[2017-04-06 15:37:25.410116]     event 0x4a00001, window 0x4a00001, (3821,453), width 580, height 618,
[2017-04-06 15:37:25.410154]     border_width 0, above 0x0, override NO
[2017-04-06 15:37:26.411517]
[2017-04-06 15:37:26.411730] ConfigureNotify event, serial 37, synthetic YES, window 0x4a00001,
[2017-04-06 15:37:26.411794]     event 0x4a00001, window 0x4a00001, (3821,453), width 580, height 618,
[2017-04-06 15:37:26.411834]     border_width 0, above 0x0, override NO
[2017-04-06 15:37:26.411872]
[2017-04-06 15:37:26.411906] FocusIn event, serial 37, synthetic NO, window 0x4a00001,
[2017-04-06 15:37:26.411940]     mode NotifyUngrab, detail NotifyAncestor
[2017-04-06 15:37:26.411973]
[2017-04-06 15:37:26.412006] KeymapNotify event, serial 37, synthetic NO, window 0x0,
[2017-04-06 15:37:26.412039]     keys:  1   0   0   0   0   0   0   0   1   0   0   0   0   0   0   0
[2017-04-06 15:37:26.412073]            0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
[2017-04-06 15:37:26.412106]
[2017-04-06 15:37:26.412139] EnterNotify event, serial 37, synthetic NO, window 0x4a00001,
[2017-04-06 15:37:26.412173]     root 0x4fc, subw 0x0, time 50685796, (247,293), root:(4068,746),
[2017-04-06 15:37:26.412206]     mode NotifyUngrab, detail NotifyAncestor, same_screen YES,
[2017-04-06 15:37:26.412239]     focus YES, state 8
[2017-04-06 15:37:26.412272]
[2017-04-06 15:37:26.412305] KeymapNotify event, serial 37, synthetic NO, window 0x0,
[2017-04-06 15:37:26.412338]     keys:  4294967292 0   0   0   0   0   0   0   1   0   0   0   0   0   0   0
[2017-04-06 15:37:26.412383]            0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
[2017-04-06 15:37:27.311420]
[2017-04-06 15:37:27.311504] KeyRelease event, serial 37, synthetic NO, window 0x4a00001,
[2017-04-06 15:37:27.311544]     root 0x4fc, subw 0x0, time 50686696, (247,293), root:(4068,746),
[2017-04-06 15:37:27.311601]     state 0x8, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
[2017-04-06 15:37:27.311677]     XLookupString gives 0 bytes:
[2017-04-06 15:37:27.311725]     XFilterEvent returns: False

It's also interesting to me that xfwm4 generates ConfigureNotify events while I move the window, but blackbox doesn't generate any until I finish moving it.

@bbidulock
Copy link
Owner

First off: I hate Firefox because it breaks so many client focus rules. It often steals focus. I find that Chromium behaves way better.

That said, blackbox focus handling is not the best. Most WMs properly intercept the Alt-mouse at the frame, grab the pointer, and do not allow the event to propagate to the client inside the frame. Is looks like blackbox is allowing the mouse click event to pass to the client in some cases, or maybe is not grabbing the pointer with the correct attributes.

As for the ConfigureNotify events, ICCCM 2.0 only requires the WM to generate a synthetic ConfigureNotify event to the client when the window changes in size (and not when the window only moves). Looking at the ConfigureNotify events that xfwm4 generates (synthetic YES), they only indicate that the window moved and not that it has resized and are, therefore, unnecessary from an interaction viewpoint. When coding synthetic notifies, bad things happen when you miss one (the frame resizes but the client window inside does not), so from a coding perspective it is better to err on the side of sending too many synthetic configure notifies than to miss sending one that resizes the window.

@rprichard
Copy link
Author

Most WMs properly intercept the Alt-mouse at the frame, grab the pointer, and do not allow the event to propagate to the client inside the frame. Is looks like blackbox is allowing the mouse click event to pass to the client in some cases, or maybe is not grabbing the pointer with the correct attributes.

I didn't see ButtonPress/ButtonRelease events in the testing I did, but maybe they are getting through? The trouble is the KeyPress/KeyRelease events for Alt. It would be intrusive to suppress the Alt KeyPress event, because it can happen long before the mouse is pressed. It probably wouldn't work to suppress the Alt KeyRelease if the KeyPress is delivered to the app. (I'd guess the imbalance would break at least something?)

I have focus-follows-mouse enabled, so I can test Firefox by pressing Alt down, then briefly switching focus away and back to Firefox, then releasing Alt. The focus switching prevents the menu from activating.

I tested Openbox and Metacity with xev, and alt-dragging generates the same FocusOut/FocusIn events as xfwm4. Alt-dragging does not activate the Firefox menu. The convention is that FocusOut is generated once the move/resize operation starts (typically at mouse-down or soon after), and FocusIn is generated on mouse-up.

The WMs generate the same FocusOut/FocusIn events even when I move/resize the window using the window frame (i.e. without using Alt).

@bbidulock bbidulock added the enhancement The report requests an enhancement beyond the intended behaviour. label May 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The report requests an enhancement beyond the intended behaviour.
Projects
None yet
Development

No branches or pull requests

2 participants