On Wed, 27 Jun 2012 at 21:55:07 +0300, Yuri Karaban wrote: > Hi > > I'm having troubles with focus when I use GTK3 applications > (particularly sakura terminal emulator and transmission bittorrent > client). > > It's very easy to reproduce the problem. Launch sakura, move mouse > pointer over the terminal window, switch to other workspace with > keyboard and return to original workspace. After this steps, sakura > stops to receive the focus events and cursor is always shown as > inactive. (When you try, make sure you're using gtk3 version of sakura). > > I investigated the problem. It's because gtk3 use xinput protocol by > default (gtk2 use core protocol). And I noticed one subtle difference > in event handling while switching workspaces: > > 1. Core protocol > > When workspace switched, LeaveNotify event is generated and > xevent->xcrossing.focus is true (which is correct, window has focus > before switching). > > 2. XInput > > When workspace switched, XI_Leave event is generated, but > focus member of XILeaveEvent is false (but window actually has focus) > > So because of this issue gtk misbehaves and starts to ignore focus > events at all. > > My supposition is following: XInput focus and сore protocol focus notion > is orthogonal, i.e. XSetInputFocus(3) does not affect XInput focus and > XISetFocus(3) does not affect core protocol.
The man page of XISetFocus says that: "XISetFocus causes the X server to generate core, XI and XI2 focus events." So perhaps the solution would be to replace XSetInputFocus() with XISetFocus(). > So if focus was not set with XISetFocus by window manager it can't be > detected by XI_Leave event. (I'm not an expert in X protocol, it's just > my thoughts. If you know more you may tell better). > > If I right, solution is to modify window manager to set both focuses > (use XSetInputFocus as well as XISetFocus). > > If I'm wrong, and problem is not in window manager, I'm wondering how so > obvious bug got unnoticed by other people, which are using other window > managers. > > Also Matthew Hague has similar problem with Awesome window manager: > > https://bugzilla.gnome.org/show_bug.cgi?id=677329 > > It may also confirm that problem is window manager related. > > PS. The workaround for this bug is to force gtk3 to use core protcol: > > export GDK_CORE_DEVICE_EVENTS=1 > > PPS. https://bugzilla.gnome.org/show_bug.cgi?id=677329 Thanks for the analysis. I noticed this annoying behavior with Evince lately. Did you research this any further? -- To unsubscribe, send mail to [email protected].
