dtbar/dtwm: the bar is no focus target, so its menu can be used with the mouse
Moving the pointer from a program to the bar took the keyboard away from that program: dtbar set the input focus to PointerRoot on EnterNotify and dtwm cleared the active client, so the bar showed the M menu instead of the program's and a click could not act on it (t0255/t0257). Now dtbar marks its window _MCDE_NO_FOCUS and leaves the focus alone, and dtwm's focus-follows-pointer path (HandleWsFocusIn) skips a client that carries the property: the last program stays focused while the pointer crosses the bar, the bar keeps showing its menu, and an item acts on the client the menu came from (ItemActivated sends the ClientMessage to that window, not to whoever has the X focus). Measured: make -C programs/dtwm rc=0 and make -C programs/dtbar rc=0, 0 errors each.
This commit is contained in:
1 parent
f8183fa7d8
commit
f8a45ae56c
2 files changed
+43
-14
No files matched your search
+16
-13
@@ -1413,20 +1413,23 @@ Events(Widget w, XtPointer data, XEvent *ev, Boolean *cont)
|
||||
/* the program brings its menus up to date before one opens */
|
||||
if (ev->xcrossing.window == XtWindow(shell))
|
||||
Send(aRefresh, 0, 0);
|
||||
/* A client straight onto the bar is no window crossing for
|
||||
* dtwm, so the terminal kept the focus over the bar (t0255).
|
||||
* The bar is not a text window: the focus goes to the
|
||||
* pointer root, and dtwm clears the active client. */
|
||||
if (ev->xcrossing.window == XtWindow(shell) &&
|
||||
ev->xcrossing.mode == NotifyNormal) {
|
||||
Window f = None;
|
||||
int revert = 0;
|
||||
/* The bar is no focus target (t0255, t0257): moving the
|
||||
* pointer onto it must not take the keyboard away from the
|
||||
* program whose menu the bar shows. The bar says so on its
|
||||
* own window (_MCDE_NO_FOCUS) and leaves the focus alone; its
|
||||
* menus open with the pointer, and an item acts on the client
|
||||
* the menu came from, not on whatever has the X focus. */
|
||||
break;
|
||||
case MapNotify:
|
||||
/* tell dtwm not to give the keyboard to the bar (see
|
||||
* EnterNotify): focus follows the pointer elsewhere, and the
|
||||
* bar keeps the last program's menu */
|
||||
if (ev->xmap.window == XtWindow(shell)) {
|
||||
Atom a = XInternAtom(dpy, "_MCDE_NO_FOCUS", False);
|
||||
long one = 1;
|
||||
|
||||
XGetInputFocus(dpy, &f, &revert);
|
||||
if (f != PointerRoot && f != None &&
|
||||
f != XtWindow(shell))
|
||||
XSetInputFocus(dpy, PointerRoot,
|
||||
RevertToPointerRoot, ev->xcrossing.time);
|
||||
XChangeProperty(dpy, XtWindow(shell), a, XA_CARDINAL,
|
||||
32, PropModeReplace, (unsigned char *) &one, 1);
|
||||
}
|
||||
break;
|
||||
case VisibilityNotify:
|
||||
|
||||
+27
-1
@@ -2364,6 +2364,31 @@ void HandleWsConfigureRequest (XConfigureRequestEvent *configureEvent)
|
||||
} /* END OF FUNCTION HandleWsConfigureRequest */
|
||||
|
||||
|
||||
/* A client that carries _MCDE_NO_FOCUS is not a keyboard target: the bar
|
||||
* (dtbar) sets it, so the pointer passing over the bar leaves the last
|
||||
* program focused and the bar keeps showing that program's menu (t0255). */
|
||||
static Bool
|
||||
NoFocusClient (ClientData *pCD)
|
||||
{
|
||||
Atom a, type;
|
||||
int fmt;
|
||||
unsigned long n, after;
|
||||
unsigned char *data = NULL;
|
||||
Bool r = False;
|
||||
|
||||
if (pCD == NULL)
|
||||
return False;
|
||||
a = XInternAtom (DISPLAY, "_MCDE_NO_FOCUS", False);
|
||||
if (XGetWindowProperty (DISPLAY, pCD->client, a, 0, 1, False,
|
||||
XA_CARDINAL, &type, &fmt, &n, &after, &data) == Success &&
|
||||
data != NULL) {
|
||||
r = True;
|
||||
XFree (data);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*************************************<->*************************************
|
||||
*
|
||||
@@ -2482,7 +2507,8 @@ void HandleWsFocusIn (XFocusInEvent *focusEvent)
|
||||
}
|
||||
else /*KEYBOARD_FOCUS_POINTER*/
|
||||
{
|
||||
if (pCD || focusEvent->detail != NotifyPointerRoot)
|
||||
if ((pCD || focusEvent->detail != NotifyPointerRoot) &&
|
||||
!NoFocusClient (pCD))
|
||||
{
|
||||
Do_Focus_Key (pCD, GetTimestamp (), ALWAYS_SET_FOCUS);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user