[PATCH,X11] Always focus key event proxy in gdk_window_focus()



The attached patch focuses the X11-backend key event proxy on a call to
gdk_window_focus() and removes the circuitous _NET_ACTIVE_WINDOW message.

The unpatched function:
1) Is misnamed, since it sometimes requests activation of a window
   which may be different from focusing the window.
2) When focusing a window, focuses the wrong window and may cause
   Gtk+ to act as if if used a PointerRoot focus model internally.
3) Will need to be changed if the _NET_ACTIVE_WINDOW message is
   retained because that message will be changing. (See wm-spec
   in CVS HEAD.)


Cheers,
Greg
Index: gdk/x11/gdkwindow-x11.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkwindow-x11.c,v
retrieving revision 1.203
diff -p -u -r1.203 gdkwindow-x11.c
--- gdk/x11/gdkwindow-x11.c	6 Mar 2004 03:37:20 -0000	1.203
+++ gdk/x11/gdkwindow-x11.c	9 Mar 2004 09:58:49 -0000
@@ -1679,7 +1679,8 @@ gdk_window_focus (GdkWindow *window,
                   guint32    timestamp)
 {
   GdkDisplay *display;
-  
+  GdkToplevelX11 *toplevel;
+
   g_return_if_fail (GDK_IS_WINDOW (window));
 
   if (GDK_WINDOW_DESTROYED (window))
@@ -1687,39 +1688,16 @@ gdk_window_focus (GdkWindow *window,
 
   display = GDK_WINDOW_DISPLAY (window);
 
-  if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
-					   gdk_atom_intern ("_NET_ACTIVE_WINDOW", FALSE)))
-    {
-      XEvent xev;
+  XRaiseWindow (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window));
 
-      xev.xclient.type = ClientMessage;
-      xev.xclient.serial = 0;
-      xev.xclient.send_event = True;
-      xev.xclient.window = GDK_WINDOW_XWINDOW (window);
-      xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display,
-									"_NET_ACTIVE_WINDOW");
-      xev.xclient.format = 32;
-      xev.xclient.data.l[0] = 0;
-      xev.xclient.data.l[1] = 0;
-      xev.xclient.data.l[2] = 0;
-      xev.xclient.data.l[3] = 0;
-      xev.xclient.data.l[4] = 0;
-      
-      XSendEvent (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XROOTWIN (window), False,
-                  SubstructureRedirectMask | SubstructureNotifyMask,
-                  &xev);
-    }
-  else
-    {
-      XRaiseWindow (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window));
+  toplevel = _gdk_x11_window_get_toplevel (window);
 
-      /* There is no way of knowing reliably whether we are viewable;
-       * _gdk_x11_set_input_focus_safe() traps errors asynchronously.
-       */
-      _gdk_x11_set_input_focus_safe (display, GDK_WINDOW_XID (window),
-				     RevertToParent,
-				     timestamp);
-    }
+  /* There is no way of knowing reliably whether we are viewable;
+   * _gdk_x11_set_input_focus_safe() traps errors asynchronously.
+   */
+  _gdk_x11_set_input_focus_safe (display, toplevel->focus_window,
+				 RevertToParent,
+				 timestamp);
 }
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]