After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 123366 - The visual bell changes my focus
The visual bell changes my focus
Status: RESOLVED FIXED
Product: metacity
Classification: Other
Component: general
2.6.x
Other Linux
: Normal minor
: METACITY2.6.x
Assigned To: Metacity maintainers list
Metacity maintainers list
Depends on:
Blocks: 155450
 
 
Reported: 2003-09-27 13:14 UTC by Carlos Perelló Marín
Modified: 2005-02-25 20:14 UTC
See Also:
GNOME target: ---
GNOME version: 2.9/2.10


Attachments
Fix the problem (621 bytes, patch)
2005-02-25 18:19 UTC, Elijah Newren
none Details | Review
Don't forget to ignore LeaveNotify events too (1.54 KB, patch)
2005-02-25 19:22 UTC, Elijah Newren
accepted-commit_now Details | Review

Description Carlos Perelló Marín 2003-09-27 13:14:08 UTC
With the visual bell (full screen one) the focus changes to the window
where I have the mouse cursor.

I think it should remember the window that has the focus before the screen
movement instead of follow the normal window manager preference. (My
preference is that the focus follows the mouse cursor, but sometimes I
change it with Ctrl+Tab and the mouse cursor is not inside the window with
focus)
Comment 1 Carlos Perelló Marín 2003-09-29 23:56:58 UTC
Moved to metacity, that's the application that implements the visual bell
Comment 2 Havoc Pennington 2003-09-30 00:00:20 UTC
We can reset the focus after the visual bell completes, I guess. Could
be tricky with race conditions. Need output-only windows. ;-)

Or better I think there's some code to ignore certain EnterNotify
events in there already, so maybe could just use that.
Comment 3 Rob Adams 2003-09-30 00:05:47 UTC
should be able to use
meta_display_increment_focus_sentinel and
meta_display_decrement_focus_sentinel before and after the visual bell
to handle everything perfectly.  Assuming we have a timestamp for the
bell event.
Comment 4 Rob Adams 2003-09-30 00:15:42 UTC
actually that's not quite right, but you should be able to simply add
a meta_display_increment_focus_sentinel right before the XFlush in
meta_bell_flash_screen and then all EnterNotify events will be ignored
on that display until the PropertyNotify for the metacity_sentinel. 
That should give us what we want, no?
Comment 5 Elijah Newren 2005-02-25 18:19:20 UTC
Created attachment 37942 [details] [review]
Fix the problem

The other recent visual_bell bug reminded me about this one.  Anyway, as Rob
says, the metacity sentinel can fix this.  However, using it will introduce a
race condition for mouse & sloppy focus modes (if the user moves the mouse
quickly enough into a new window at the time the visual bell occurs then the
window won't get focused when it should; I have verified I can trigger this
race and get the wrong window focused in that case).  Therefore, the metacity
sentinel should only be used when mouse_mode is false (see bug 167545); that
will handle the case that Carlos is worried about.  

There are a couple cases that this approach can't handle, but they're in corner
cases that are inherently busted anyway: (1) if mouse_mode is false but the
user decides to move the mouse real quick, the same race condition exists (but
users mixing keynav and mousenav are screwed anyway, as pointed out in bug
167545), (2) there are a couple ways to break mousenav invariants without
mouse_mode being false (new window or use of the tasklist or window selector
applet); in these cases the sentinel won't be set and the window under the
mouse will gain focus.	The proposal in bug 152004 will solve the new window
case.  In the other two cases, users get what they deserve for using mousenav
and requesting that a window not under the mouse be activated.
Comment 6 Elijah Newren 2005-02-25 19:22:40 UTC
Created attachment 37946 [details] [review]
Don't forget to ignore LeaveNotify events too

So I've been running with this patch and the annoying visual bell turned on for
a while in order to catch any problems.  Looks like we forgot to ignore
LeaveNotify events too, meaning that in mouse focus mode we can get windows to
get unfocused when in keynav mode.  In general, LeaveNotify events should be
ignored when EnterNotify ones are, so this patch just makes that change along
in addition to changes from the previous patch.
Comment 7 Havoc Pennington 2005-02-25 20:08:40 UTC
Comment on attachment 37946 [details] [review]
Don't forget to ignore LeaveNotify events too

Seems plausible.
Comment 8 Elijah Newren 2005-02-25 20:14:29 UTC
committed.