diff --git a/programs/dtbar/dtbar.c b/programs/dtbar/dtbar.c index 8fd0e43c..558a3c63 100644 --- a/programs/dtbar/dtbar.c +++ b/programs/dtbar/dtbar.c @@ -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: diff --git a/programs/dtwm/WmEvent.c b/programs/dtwm/WmEvent.c index 023c7a32..b636f7da 100644 --- a/programs/dtwm/WmEvent.c +++ b/programs/dtwm/WmEvent.c @@ -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); }