Better focus setting for EWMH window managers.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@26749 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fredkiefer 2008-07-07 23:02:46 +00:00
parent 46e08881cf
commit 3d514fa728
2 changed files with 61 additions and 3 deletions

View file

@ -1,3 +1,11 @@
2008-07-08 Fred Kiefer <FredKiefer@gmx.de>
* Source/x11/XGServerWindow.m (-setinputfocus:): For EWMH window
managers set the user time before requesting focus.
* Source/x11/XGServerWindow.m (-setinputstate:): For EWMH window
managers set active window status.
Based on patch by Hubert Chathi <hubert@uhoreg.ca>.
2008-06-26 Fred Kiefer <FredKiefer@gmx.de> 2008-06-26 Fred Kiefer <FredKiefer@gmx.de>
* Source/cairo/CairoGState.m (-copyWithZone:): Use a runtime * Source/cairo/CairoGState.m (-copyWithZone:): Use a runtime

View file

@ -1556,6 +1556,7 @@ _get_next_prop_new_event(Display *display, XEvent *event, char *arg)
pid_atom, XA_CARDINAL, pid_atom, XA_CARDINAL,
32, PropModeReplace, 32, PropModeReplace,
(unsigned char*)&pid, 1); (unsigned char*)&pid, 1);
// FIXME: Need to set WM_CLIENT_MACHINE as well.
} }
/* We need to determine the offsets between the actual decorated window /* We need to determine the offsets between the actual decorated window
@ -2001,12 +2002,15 @@ _get_next_prop_new_event(Display *display, XEvent *event, char *arg)
window->numProtocols = 0; window->numProtocols = 0;
window->protocols[window->numProtocols++] = generic.take_focus_atom; window->protocols[window->numProtocols++] = generic.take_focus_atom;
window->protocols[window->numProtocols++] = generic.delete_win_atom; window->protocols[window->numProtocols++] = generic.delete_win_atom;
// Add ping protocol for EWMH
if ((generic.wm & XGWM_EWMH) != 0)
{
window->protocols[window->numProtocols++] = generic.net_wm_ping_atom; window->protocols[window->numProtocols++] = generic.net_wm_ping_atom;
}
if ((generic.wm & XGWM_WINDOWMAKER) != 0) if ((generic.wm & XGWM_WINDOWMAKER) != 0)
{ {
window->protocols[window->numProtocols++] = generic.miniaturize_atom; window->protocols[window->numProtocols++] = generic.miniaturize_atom;
} }
// FIXME Add ping protocol for EWMH
XSetWMProtocols(dpy, window->ident, window->protocols, window->numProtocols); XSetWMProtocols(dpy, window->ident, window->protocols, window->numProtocols);
window->exposedRects = [NSMutableArray new]; window->exposedRects = [NSMutableArray new];
@ -3612,6 +3616,21 @@ static BOOL didCreatePixmaps;
return; return;
} }
if ((generic.wm & XGWM_EWMH) != 0)
{
static Atom user_time_atom = None;
Time last = [self lastTime];
if (user_time_atom == None)
{
user_time_atom = XInternAtom(dpy, "_NET_WM_USER_TIME", False);
}
NSDebugLLog(@"Focus", @"Setting user time for %d to %ul", window->ident, last);
XChangeProperty(dpy, window->ident, user_time_atom, XA_CARDINAL, 32,
PropModeReplace, (unsigned char *)&last, 1);
}
NSDebugLLog(@"Focus", @"Setting focus to %d", window->number); NSDebugLLog(@"Focus", @"Setting focus to %d", window->number);
generic.desiredFocusWindow = win; generic.desiredFocusWindow = win;
generic.focusRequestNumber = XNextRequest(dpy); generic.focusRequestNumber = XNextRequest(dpy);
@ -3646,6 +3665,37 @@ static BOOL didCreatePixmaps;
data2: 0 data2: 0
data3: 0]; data3: 0];
} }
else if ((generic.wm & XGWM_EWMH) != 0)
{
if ((st == GSTitleBarKey) || (st == GSTitleBarMain))
{
static Atom active_window_atom = None;
gswindow_device_t *window = WINDOW_WITH_TAG(win);
if (win == 0 || window == 0)
{
return;
}
if (active_window_atom == None)
{
active_window_atom = XInternAtom(window->display,
"_NET_ACTIVE_WINDOW", False);
}
/*
* Work around "focus stealing prevention" by first asking for focus
* before we try to take it.
*/
[self _sendRoot: window->root
type: active_window_atom
window: window->ident
data0: 1
data1: [self lastTime]
data2: 0
data3: 0];
}
}
} }
/** Sets the transparancy value for the whole window */ /** Sets the transparancy value for the whole window */