diff --git a/AGENTS.md b/AGENTS.md index 4fdb9d5c..1abbe923 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -174,6 +174,17 @@ narratives and test notes, is `docs/reference/mcde-agents-history-2026-11-13.txt it Cmd+Delete said `TT_ERR_NO_MATCH ... disposition was not queue or start` and left the file (measured 2026-11-15, t0206); with it the file is in `~/.dt/Trash` and the Trash Can window lists it. +- **Window titles are UTF-8** in the reference's face. The title has its own + XFontSet (`WmInitWs.c`: Adobe Helvetica 14 bold oblique, the 4Dwm face, plus + an ISO10646 fallback); `DrawWindowTitle` draws `_NET_WM_NAME` (or WM_NAME + converted from compound text with `_XmStringUngenerate`) with + `Xutf8DrawString` and clears the title box first. Motif's XmString path + cannot draw UTF-8 under a non-UTF-8 locale -- with `LC_CTYPE=C` a + `_NET_WM_NAME` of "Grüße 日本" appeared as the JIS bytes "FJK\" (measured + 2026-11-22). The `_NET_WM_NAME` atoms are interned whether or not EWMH is + on, and `0010.language` gives a session without a language + `LC_CTYPE=C.UTF-8`: XCreateFontSet builds for the locale, and in C the set + had only ASCII (font set test: "Grüße" 17 px instead of 43). - **Windows**: dtwm places and maximizes below the bar; the title sits at the left of the bar (`Dtwm*titleLeft: True`, the 4Dwm `SG_titleLeft`; the CDE default is centred) and the frame is 7 pixels wide, as the reference's @@ -181,9 +192,11 @@ narratives and test notes, is `docs/reference/mcde-agents-history-2026-11-13.txt moves it. The palette `IRIX.dp` carries the reference's greys (`sgilightgray` #c0c0c0, `sgibrightgray` #e0e0e0); focus follows the 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 + icon clears the keyboard focus (the icon windows select EnterWindowMask + and WmMcdeDesktop calls Do_Focus_Key(NULL)); the bar is no focus target: + dtbar sets `_MCDE_NO_FOCUS` and dtwm's focus-follows-pointer path skips + such a client, so the program keeps the keyboard and its menu (t0255), 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`, diff --git a/programs/dtlogin/config/0010.language b/programs/dtlogin/config/0010.language index 8a7e61d4..be2a03db 100755 --- a/programs/dtlogin/config/0010.language +++ b/programs/dtlogin/config/0010.language @@ -19,3 +19,14 @@ if [ -r "$HOME/.dt/language" ]; then fi unset mcde_lang fi + +# MCDE: without a language the session ran in C, and a UTF-8 window title was +# drawn as ASCII (measured 2026-11-22 on the MacBook: "Grüße 日本" appeared as +# the JIS bytes "FJK\"). A UTF-8 LC_CTYPE lets XmString and the title font set +# do their work; the language itself stays as it is. +case "${LC_ALL:-${LC_CTYPE:-${LANG:-}}}" in +*UTF-8*|*utf8*|*UTF8*) ;; +*) LC_CTYPE=C.UTF-8 + export LC_CTYPE + ;; +esac diff --git a/programs/dtwm/WmCDecor.c b/programs/dtwm/WmCDecor.c index 85f83ded..54b58021 100644 --- a/programs/dtwm/WmCDecor.c +++ b/programs/dtwm/WmCDecor.c @@ -1220,6 +1220,39 @@ void GetTextBox (ClientData *pcd, XRectangle *pBox) * *************************************<->***********************************/ +/* MCDE: a title drawn with a font set, so UTF-8 is UTF-8. The font set is + * the IRIX face with an ISO10646 fallback (WmInitWs.c); Motif's XmString path + * leaves a UTF-8 _NET_WM_NAME empty under a non-UTF-8 locale (measured + * 2026-11-22 on the MacBook). The clip is the title box, so long titles end + * where XmStringDraw ended them. */ +static void +DrawUtf8Title(Display *dpy, Window win, GC gc, XRectangle *box, + const char *text, Boolean center) +{ + XFontSet fs = wmGD.titleFontSet; + XFontSetExtents *e; + XRectangle clip; + int textW, ascent, x, y; + + if (fs == NULL || text == NULL) + return; + /* the old title must go: an update can come without eraseFirst, and a + * character the set cannot draw would leave the old glyphs behind */ + XClearArea(dpy, win, box->x, box->y, box->width, box->height, False); + e = XExtentsOfFontSet(fs); + textW = Xutf8TextEscapement(fs, text, (int) strlen(text)); + ascent = -e->max_logical_extent.y; + x = box->x; + if (center) + x += ((int) box->width - textW) / 2; + y = box->y + ((int) box->height - e->max_logical_extent.height) / 2 + + ascent; + clip = *box; + XSetClipRectangles(dpy, gc, 0, 0, &clip, 1, Unsorted); + Xutf8DrawImageString(dpy, win, fs, gc, x, y, text, (int) strlen(text)); + XSetClipMask(dpy, gc, None); +} + void DrawWindowTitle (ClientData *pcd, Boolean eraseFirst) { GC clientGC; @@ -1278,7 +1311,11 @@ void DrawWindowTitle (ClientData *pcd, Boolean eraseFirst) /* MCDE: Dtwm*titleLeft puts the title at the left, as 4Dwm did * (SG_titleLeft); the CDE default stays centred */ - WmDrawXmString(DISPLAY, win, fontList, title, clientGC, + if (pcd->titleUtf8 != NULL && wmGD.titleFontSet != NULL) + DrawUtf8Title(DISPLAY, win, clientGC, &textBox, pcd->titleUtf8, + pcd->pSD != NULL && pcd->pSD->titleLeft ? False : True); + else + WmDrawXmString(DISPLAY, win, fontList, title, clientGC, textBox.x, textBox.y, textBox.width, &textBox, pcd->pSD != NULL && pcd->pSD->titleLeft ? False : True); diff --git a/programs/dtwm/WmGlobal.h b/programs/dtwm/WmGlobal.h index 0dad67dc..a3072034 100644 --- a/programs/dtwm/WmGlobal.h +++ b/programs/dtwm/WmGlobal.h @@ -1689,6 +1689,7 @@ typedef struct _ClientData int fullscreenWidth; /* fullscreen width */ int fullscreenHeight; /* fullscreen height */ XmString instantTitle; /* instant title */ + char *titleUtf8; /* the title as UTF-8 (WM_NAME/_NET_WM_NAME) */ /* client window frame graphic data: */ @@ -1901,6 +1902,7 @@ typedef struct _WmGlobalData String displayString; /* used for putenv in F_Exec */ Display *display; /* display we are running to */ Display *display1; /* second display connection */ + XFontSet titleFontSet; /* the IRIX title face, UTF-8 capable */ int statusColorServer; /* CSERVE_NORMAL, CSERVE_NOT_AVAILABLE */ DtWmpParseBuf *pWmPB; /* global parse buffer */ int numScreens; /* number of screens */ diff --git a/programs/dtwm/WmInitWs.c b/programs/dtwm/WmInitWs.c index fec283fc..7749df08 100644 --- a/programs/dtwm/WmInitWs.c +++ b/programs/dtwm/WmInitWs.c @@ -475,6 +475,33 @@ void InitWmGlobal (int argc, char *argv [], char *environ []) ExitWM (WM_ERROR_EXIT_VALUE); } + /* MCDE: _NET_WM_NAME is the UTF-8 title, and dtwm reads it whether or not + * EWMH support is on. WmEwmh.c interns these atoms only when EWMH is + * enabled; without them HasProperty(atom 0) said no and a UTF-8 title fell + * back to WM_NAME (compound text), which drew the JIS bytes as "FJK\" + * (measured 2026-11-22 on the MacBook). */ + wmGD.xa_UTF8_STRING = XInternAtom (DISPLAY, "UTF8_STRING", False); + wmGD.xa__NET_WM_NAME = XInternAtom (DISPLAY, "_NET_WM_NAME", False); + wmGD.xa__NET_WM_VISIBLE_NAME = + XInternAtom (DISPLAY, "_NET_WM_VISIBLE_NAME", False); + + /* MCDE: the title face of the reference (Helvetica 14 bold oblique, as + * 4Dwm had it) with an ISO10646 fallback, so a UTF-8 title can be drawn + * with Xutf8DrawString; Motif's XmString path cannot do that under a + * non-UTF-8 locale (measured 2026-11-22: a UTF-8 _NET_WM_NAME left the + * title bar empty). Missing charsets are not a reason not to start. */ + { + char **missing = NULL; + int nmissing = 0; + + wmGD.titleFontSet = XCreateFontSet (DISPLAY, + "-adobe-helvetica-bold-o-normal--14-*-*-*-*-*-iso10646-1," + "-misc-fixed-bold-r-normal--13-*-*-*-*-*-iso10646-1", + &missing, &nmissing, NULL); + if (missing != NULL) + XFreeStringList (missing); + } + #if defined(sun) && defined(ALLPLANES) { int dummy; diff --git a/programs/dtwm/WmManage.c b/programs/dtwm/WmManage.c index 05880174..5a0124d2 100644 --- a/programs/dtwm/WmManage.c +++ b/programs/dtwm/WmManage.c @@ -1207,6 +1207,8 @@ void WithdrawWindow (ClientData *pCD) if ((pCD->clientFlags & CLIENT_HINTS_TITLE) && pCD->clientTitle) { XmStringFree (pCD->clientTitle); + if (pCD->titleUtf8 != NULL) + XtFree (pCD->titleUtf8); } if ((pCD->iconFlags & ICON_HINTS_TITLE) && pCD->iconTitle) diff --git a/programs/dtwm/WmWinInfo.c b/programs/dtwm/WmWinInfo.c index f0e65fe7..1036fa01 100644 --- a/programs/dtwm/WmWinInfo.c +++ b/programs/dtwm/WmWinInfo.c @@ -52,6 +52,9 @@ * include extern functions */ #include "WmWinInfo.h" + +extern XtPointer _XmStringUngenerate(XmString, XmStringTag, + XmTextType, XmTextType); #include "WmCDInfo.h" #include "WmCDecor.h" #include "WmCPlace.h" @@ -134,6 +137,8 @@ GetClientInfo (WmScreenData *pSD, Window clientWindow, long manageFlags) return (NULL); } + pCD->titleUtf8 = NULL; + /* * Initialize the data structure: @@ -2151,12 +2156,28 @@ ProcessWmWindowTitle (ClientData *pCD, Boolean firstTime) (netStr = GetUtf8String (DISPLAY, win, wmGD.xa__NET_WM_NAME))) { title_xms = XmStringCreateLocalized (netStr); + if (pCD->titleUtf8 != NULL) + XtFree (pCD->titleUtf8); + pCD->titleUtf8 = XtNewString (netStr); XFree (netStr); } else if ((!firstTime || hasWmName) && XGetWMName(DISPLAY, win, &wmNameProp)) { title_xms = WmICCCMToXmString(&wmNameProp); + if (pCD->titleUtf8 != NULL) { + XtFree (pCD->titleUtf8); + pCD->titleUtf8 = NULL; + } + if (title_xms != NULL) { + char *u = (char *) _XmStringUngenerate (title_xms, NULL, + XmCHARSET_TEXT, XmCHARSET_TEXT); + + if (u != NULL) { + pCD->titleUtf8 = XtNewString (u); + XtFree (u); + } + } if (wmNameProp.value) XFree ((char*)wmNameProp.value); } } @@ -2209,6 +2230,9 @@ ProcessWmWindowTitle (ClientData *pCD, Boolean firstTime) (netStr = GetUtf8String (DISPLAY, win, wmGD.xa__NET_WM_VISIBLE_NAME))) { pCD->instantTitle = XmStringCreateLocalized (netStr); + if (pCD->titleUtf8 != NULL) + XtFree (pCD->titleUtf8); + pCD->titleUtf8 = XtNewString (netStr); XFree (netStr); }