Re: [PATCH,X11] Always focus key event proxy in gdk_window_focus()
- From: Gregory Merchan <merchan phys lsu edu>
- To: gtk-devel-list gnome org
- Subject: Re: [PATCH,X11] Always focus key event proxy in gdk_window_focus()
- Date: Tue, 9 Mar 2004 11:13:42 -0600
On Tue, Mar 09, 2004 at 05:09:54AM -0600, Gregory Merchan wrote:
> 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.
I've been asked for a better explanation, so here goes.
One part of this patch is, I hope, straightforward: when focus is set
on the X11 backend, it should be set to the window on which gdk expects
to receive key events. This can be done by changing the else clause to:
...
else
{
GdkToplevelX11 *toplevel;
toplevel = _gdk_x11_window_get_toplevel (window);
XRaiseWindow (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (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, toplevel->focus_window,
RevertToParent,
timestamp);
}
...
In the true branch of the conditional, a request is sent to the window
manager which, if honored, will cause gdk to receive a WM_TAKE_FOCUS.
Gdk's response to that message, when a window accepts focus, is to set
focus to the toplevel focus window. Changing the else clause makes the
behavior basically the same whether _NET_ACTIVE_WINDOW is supported or not.
I've gone a step further than this in the patch by entirely removing the
check for _NET_ACTIVE_WINDOW and the request made when that is supported.
1) It's not necessary. Applications are allowed to and in some cases
expected to change focus. Responding to WM_TAKE_FOCUS is just one
example of this.
2) It's inefficient. Sending the request adds to the burden of the window
manager and any apps that have selected SubstructureNotify on the root
window. When honored, it may require the window manager to set focus or
send a message back to the application.
3) The function name does not describe what the function does. Activation
may be different from focus. (I think it's a bad thing, but it can happen.)
4) There is no API to set focus so that key events are properly handled,
as will be needed to change to the globally active input model.
If those reasons are not sufficient, then I don't think I can make the case
for not using the _NET_ACTIVE_WINDOW request at this time. However, the
contents of that message are going to change with the next version of the
wm-spec, so at least the following changes will be needed.
- xev.xclient.data.l[0] = 0;
- xev.xclient.data.l[1] = 0;
+ xev.xclient.data.l[0] = 1;
+ xev.xclient.data.l[1] = timestamp;
The first member can be set to 1 if gdk_window_focus() isn't used by a pager;
otherwise, it should be 2. Also the third member is supposed to be set to the
requestor's currently active window (or 0). I haven't looked at how to get
that at this time.
Cheers,
Greg
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]