GNOME Bugzilla – Bug 143349
GDK cannot give input focus to an override_redirect window
Last modified: 2010-12-17 06:02:28 UTC
Gtk+ 2.4.1 gdk_window_focus in gdkwindow-x11.c uses the EWMH hint _NET_ACTIVE_WINDOW if available to ask the window manager to give focus to the top level window. This does not seem to work for override_redirect windows, and so in order to give an override_redirect window input focus you have to use XSetInputFocus directly. I think the fix is to always use XSetInputFocus if the window is override_redirect in gdk_window_focus().
Sounds reasonable. Do you have a patch ?
I think this is correct but I have also found that if I grab the pointer and keyboard, focus seems to work correctly without the patch and I don't quite understand why that is the case. I have not yet tested this patch either. Index: gdkwindow-x11.c =================================================================== RCS file: /cvs/gnome/gtk+/gdk/x11/gdkwindow-x11.c,v retrieving revision 1.206 diff -p -u -r1.206 gdkwindow-x11.c --- a/gdkwindow-x11.c 6 May 2004 02:57:01 -0000 1.206 +++ b/gdkwindow-x11.c 11 Jun 2004 04:37:58 -0000 @@ -1690,6 +1690,7 @@ void gdk_window_focus (GdkWindow *window, guint32 timestamp) { + XWindowAttributes attrs; GdkDisplay *display; g_return_if_fail (GDK_IS_WINDOW (window)); @@ -1698,8 +1699,13 @@ gdk_window_focus (GdkWindow *window, return; display = GDK_WINDOW_DISPLAY (window); + + XGetWindowAttributes (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), + &attrs); - if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window), + if (!attrs.override_redirect && + gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window), gdk_atom_intern ("_NET_ACTIVE_WINDOW" , FALSE))) { XEvent xev;
during grabs, events are not delivered as normal, thats why things appear to work when the pointer is grabbed to the override redirect.
Thank you for taking the time to report this bug and helping to make GTK+ better. We are sorry that we do not always have the capacity to look at all reported bugs in a timely manner. There have been many changes in GTK+ since that time you reported the bug and your problem may have been fixed with some of the updates. It would help us a lot if you could test a current, supported, GTK+ version (2.22 or, even better, current master). If you can test it, and it is still an issue, we would appreciate if you could upload any log / test case that are relevant for this particular issue.
Closing this bug report as no further information has been provided. Please feel free to reopen this bug if you can provide the information asked for. Thanks!