dtwm: UTF-8 window titles in the IRIX face

The title was drawn from an XmString with the client fontList, a single X
font: under LC_CTYPE=C a UTF-8 _NET_WM_NAME became the JIS bytes "FJK\" and
the umlaut was dropped (measured 2026-11-22 on the MacBook; xmessage with
_NET_WM_NAME "Grüße 日本").

The title has its own XFontSet now -- the reference's Helvetica 14 bold
oblique with an ISO10646 fallback -- and DrawWindowTitle draws the UTF-8 text
with Xutf8DrawString, clearing the box first so a character the set cannot
draw leaves no old glyph behind.  The text comes from _NET_WM_NAME when the
client sets it (the atoms are interned even when EWMH is off) and from
WM_NAME otherwise, converted from compound text with _XmStringUngenerate;
titleUtf8 is freed with the client and zeroed when the ClientData is
allocated (XtMalloc, not XtCalloc -- the first version crashed on the
garbage).

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, 10 fonts instead of 1).

Measured: make -C programs/dtwm rc=0, 0 errors; the MacBook title bar reads
"Grüße" in the IRIX face.
This commit is contained in:
lotherk committed 2026-11-22 17:32:34 +01:00
1 parent 0fa42ac765
commit 067b95ecb3
7 files changed
+120 -4

No files matched your search

+16 -3
View File
@@ -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`,
+11
View File
@@ -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
+38 -1
View File
@@ -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);
+2
View File
@@ -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 */
+27
View File
@@ -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;
+2
View File
@@ -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)
+24
View File
@@ -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);
}