dtwm/dtbar: the focus leaves a client over an icon or the bar (t0255)

With focus-follows-pointer (sys.resources: Dtwm*keyboardFocusPolicy: pointer)
a move from a terminal straight onto a desktop icon or onto dtbar kept the
terminal as the keyboard focus: the icon windows did not select EnterNotify,
and McdeDesktopEvent returns True for every event of an icon, so the
workspace's root/backdrop enter path (HandleWsEnterNotify -> Do_Focus_Key
(NULL)) never ran.  The bar is a window of its own and dtwm does not focus
it, so hovering it changed nothing either.

- WmMcdeDesktop.c: the icon windows select EnterWindowMask, and their
  EnterNotify calls Do_Focus_Key(NULL, time, ALWAYS_SET_FOCUS) -- the focus
  goes to the pointer root and dtwm clears the active client.
- dtbar.c: the shell already had EnterWindowMask for the menu refresh; on a
  normal enter it now sets the input focus to PointerRoot unless the root or
  the bar already has it.  A menu's grab (NotifyGrab) is left alone, so
  keyboard menu handling is untouched.

Measured under Xvfb :89 (1024x768, pointer policy, Toronto backdrop, dtbar,
two xterms at +56+126 and +406+326):
- before: xterm A -> bar kept xterm A; xterm B -> Computer icon kept xterm B.
- after: A -> icon focus 1 (PointerRoot), B -> icon 1, A -> bar 1,
  B -> backdrop 1; hovering A or B again focuses that xterm; the front panel
  still takes the focus itself, and the client loses it (unchanged).
make mcde-linux MCDE_DIRS="install programs/dtwm programs/dtbar" exit=0;
"check programs/dtbar" 1 PASS, 0 FAIL; MCDE_DIRS=plist
"mcde-plist-check: ok".

AGENTS.md: the window/focus paragraph says what an icon or the bar now does.
This commit is contained in:
lotherk committed 2026-11-16 14:53:18 +00:00
1 parent 37d566dac5
commit b05823daf3
3 files changed
+29 -2

No files matched your search

+5 -1
View File
@@ -150,7 +150,11 @@ narratives and test notes, is `docs/reference/mcde-agents-history-2026-11-13.txt
`4DWm` app-defaults say; `Alt+Button2` resizes a window like `Alt+Button1`
moves it. The palette `IRIX.dp` carries the reference's greys
(`sgilightgray` #c0c0c0, `sgibrightgray` #e0e0e0); focus follows the
pointer without auto-raise by default; zones and full screen use Command+Ctrl
pointer without auto-raise by default; a client straight onto a desktop
icon or the bar clears the keyboard focus (the icon windows select
EnterWindowMask and WmMcdeDesktop calls Do_Focus_Key(NULL); dtbar sets the
input focus to PointerRoot on its EnterNotify), so a non-client area never
leaves the last terminal focused (t0255); zones and full screen use Command+Ctrl
keys; the outline is XOR or four thin windows, never FlashOutline. An
iconified window shows image and label (`Dtwm*iconDecoration: label image`,
85x67 pictures) and the icons fill a tight column at the left edge
+15
View File
@@ -1413,6 +1413,21 @@ 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;
XGetInputFocus(dpy, &f, &revert);
if (f != PointerRoot && f != None &&
f != XtWindow(shell))
XSetInputFocus(dpy, PointerRoot,
RevertToPointerRoot, ev->xcrossing.time);
}
break;
case VisibilityNotify:
if (ev->xvisibility.window == XtWindow(shell) &&
+9 -1
View File
@@ -1197,6 +1197,13 @@ McdeDesktopEvent(XEvent *event)
if (event->xexpose.count == 0)
DeskDraw(i);
return True;
case EnterNotify:
/* From a client straight onto an icon there is no root or
* backdrop crossing, so the workspace's enter handler never
* runs: the focus goes to the desktop here (tasksd t0255). */
Do_Focus_Key((ClientData *) NULL, event->xcrossing.time,
ALWAYS_SET_FOCUS);
return True;
case ClientMessage:
if (event->xclient.message_type == deskXdndEnter) {
deskXdndSource = (Window) event->xclient.data.l[0];
@@ -1724,7 +1731,8 @@ DeskWindow(int i)
a.background_pixel = deskBg;
a.border_pixel = deskFg;
a.event_mask = ExposureMask | ButtonPressMask | ButtonReleaseMask |
Button1MotionMask | StructureNotifyMask | PropertyChangeMask;
Button1MotionMask | StructureNotifyMask | PropertyChangeMask |
EnterWindowMask;
it->win = XCreateWindow(deskDpy, deskRoot, it->x, it->y,
DESK_CELL_W, DESK_CELL_H, 0, CopyFromParent, InputOutput,
CopyFromParent,