GNOME Bugzilla – Bug 154601
Fix middle-frame-click-to-lower focus inconsistency
Last modified: 2004-12-22 21:47:04 UTC
Apparently lowering a focused window via a middle click on the frame so that it drops below another window and such that the mouse enters the new window results in some funny behavior. It causes a LeaveNotify event to be generated with xcrossing.mode equal to neither NotifyGrab nor NotifyUngrab AND an EnterNotify event to be generated with xcrossing.mode equal to NotifyUngrab. This asymmetry is _really_ odd (I would expect both events to come from grabs, or neither event to come from a grab; I don't understand why there's a mixture). Anyway, since the EnterNotify is considered to have come from a grab, we need to manually focus the correct window in all focus modes (not just click to focus). Manually focusing the correct window, though, isn't quite enough for mouse focus because of another issue: LeaveNotify events in display.c use window->has_focus in order to determine whether to defocus the window in mouse focus mode. The patch I will attach changes this to window==display->expected_focus_window, but that depends on the patch in bug 154598 first being applied in order for this change to be correct. You'll note that there's a comment for EnterNotify events that says that window->has_focus has to be ignored due to possible race conditions, so making this change is a good idea for probably more than just this bug.
Created attachment 32259 [details] [review] Fix middle-click-on-frame-to-lower-window for mouse and sloppy focus modes. I've tested this patch combined with the one in bug 154598 in all three focus modes, and it fixes the bug for mouse and sloppy focus modes and leaves things working correctly in click-to-focus.
Created attachment 32260 [details] [review] Version of the patch to use iff the patch in bug 154598 is rejected Just in case Havoc likes the current meaning of expected_focus_window and doesn't want to change it, here's a patch that works without needing the patch in bug 154598.
Comment on attachment 32260 [details] [review] Version of the patch to use iff the patch in bug 154598 is rejected The patch in bug 154598 was accepted, so the other patch is the right one to use.
Comment on attachment 32259 [details] [review] Fix middle-click-on-frame-to-lower-window for mouse and sloppy focus modes. Works for me, thanks.