From dc8dfd2cc74c7ccd02a76eb8fead1978804640ef Mon Sep 17 00:00:00 2001 From: lotherk Date: Sat, 14 Nov 2026 09:59:02 +0000 Subject: [PATCH] MCDE dtsystemsettings: Appearance, the four groups and the fonts (t0099) The pane is the reference's form now: Appearance (a menu of the palettes with the chosen palette's eight colours as a strip under it, then "In use:"), Highlight Color (the eight colours of the active palette, written as *highlightColor and *selectColor for programs started later), the scroll bars, the number of recent items, font smoothing -- and the fonts, which lose their own pane (the "fonts" id still opens Appearance, the entry is gone from the overview). What the pane writes is what the session reads: **ColorPalette, *highlightColor, *selectColor _DtAddToResource Dtwm*mcdeTitleBarDoubleClick: none|minimize then dtwm restarts ~/.dt/recent.conf: applications=N, documents=N, servers=N ~/.config/fontconfig/conf.d/60-mcde-antialias.conf antialias=false dtwm gained the title-bar double click: a new resource (WmResNames.h, WmGlobal.h, WmResource.c, default "none") and, in CheckButtonPressBuiltin (WmCEvent.c), the double-click branch on the title -- F_Minimize or F_Maximize instead of the move. dtbar's Recent Items and Connect to Server's history now read their counts from ~/.dt/recent.conf (ItemsPush/FillRecent, ReadLines/RecentAdd). Two things the task itself said to drop are dropped, with the reason in the pane: Motif has no separate arrow buttons at both ends of a scroll bar and no smooth scrolling (an animation), and a click in a Motif scroll bar pages while the middle button jumps to the place. Font smoothing is a fontconfig rule, not *Xft.antialias: measured here, Xft ignores that X resource (205 grey levels with and without it), while a antialias=false rule gives 2. The rule reaches GTK and Qt as well (one look). Measured under Xvfb with xdotool: - "Off" + Apply -> the file is written and an Xft render test in the same session drops from 205 distinct grey levels to 2; with the size limit 20 the same test (size 12) gives 2, with 4 it gives 205 -- the rule holds only up to the size. - the title-bar box + Apply writes Dtwm*mcdeTitleBarDoubleClick: minimize, dtwm restarts, and a double click on dtpad's title bar leaves its window "Map State: IsUnMapped" (IsViewable before). - a palette choice writes *0*ColorPalette: Camouflage.dp (and dtthemesync's colours), the strip and the Highlight menu follow it. - Documents=5 with eight entries in ~/.dt/recent shows five in the bar's Recent Items; Servers=0 leaves the Connect to Server field at "sftp://", Servers=10 prefills the stored address. Pictures: docs/screenshots/leopard/System-Preferences-Appearance-mcde.png (the four groups) and ...-Appearance-fonts-mcde.png (scrolled to the fonts). make check: test_panes PASS. Open: a highlight colour reaches programs started later, not the running ones; "Applications" has no recent list to feed; the dtwm value takes effect when the window manager restarts (the Apply button does it); the antialias rule is read at program start; and the fonts list is six rows inside the scrolled pane. --- AGENTS.md | 17 +- programs/dtbar/dtbar.c | 41 +- programs/dtfile/Connect.c | 42 +- programs/dtsystemsettings/appearance.c | 651 +++++++++++++++++++++++-- programs/dtsystemsettings/main.c | 8 +- programs/dtsystemsettings/panes.c | 8 +- programs/dtwm/WmCEvent.c | 23 +- programs/dtwm/WmGlobal.h | 1 + programs/dtwm/WmResNames.h | 3 + programs/dtwm/WmResource.c | 10 + 10 files changed, 751 insertions(+), 53 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index fcf72830..10d8dbf0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -45,9 +45,9 @@ narratives and test notes, is `docs/reference/mcde-agents-history-2026-11-13.txt (Command key in `lib/Xm/Transltns.c`, exported menu bars `_XmMenuBarSetExported`, Xft renditions). Outside pkgsrc MCDE builds it itself (`configure.ac`, `--with-private-motif`, the default); through pkgsrc - on Makronix it is the system's Motif (`--without-private-motif`, `MOTIFBASE` - in `tools/vmbuild/mk-cde.conf`). Konrad, 2026-11-13: MCDE builds its own - Motif when it is not Makronix. + on Makronix it is the system's Motif (`--without-private-motif`), and the + recipe/buildlink direct other Motif packages to it. Konrad, 2026-11-13: MCDE + builds its own Motif when it is not Makronix. - `lib/McdeSys` (libMcdeSys; `test_sysinfo`), `lib/McdeSound` (`include/Mcde/Sound.h`), `lib/DtSvc/DtUtil2/Mcde*.c` (global menu client side, menu model, images, display arithmetic and RandR, WM hints); @@ -97,6 +97,9 @@ narratives and test notes, is `docs/reference/mcde-agents-history-2026-11-13.txt keys; the outline is XOR or four thin windows, never FlashOutline. The main display carries bar and front panel, the others the backdrop only; workspaces are shared; MCDE remembers a monitor (EDID) in `~/.dt/displays`. + A double click on a window's title bar does `Dtwm*mcdeTitleBarDoubleClick` + (`none` by default, `minimize` or `maximize`); the Appearance pane writes + it and restarts dtwm (`_DtWmRestartNoConfirm`). - **Front panel**: Files, Mail, Terminal, Network, Desktop Style left of the workspace switch (Konrad, 2026-11-11), running programs and trash right. No clock in the panel (the bar has it). Actions at the end of `types/dt.dt.src` @@ -105,6 +108,14 @@ narratives and test notes, is `docs/reference/mcde-agents-history-2026-11-13.txt - **Pictures**: PNG goes through `McdeImageGetPixmap` (libpng), because Motif 2.3.8 draws an RGB PNG as its blue channel only (`docs/reference/motif-png.txt`); free with `McdeImageFreePixmap`. +- **Look settings**: System Settings > Appearance writes what the session + reads -- `**ColorPalette` and `*highlightColor`/`*selectColor` + (through `_DtAddToResource`, so programs started later use them), + `~/.dt/recent.conf` (`applications|documents|servers=N`, read by dtbar's + Recent Items and Connect to Server), and for font smoothing fontconfig's + `~/.config/fontconfig/conf.d/60-mcde-antialias.conf` (an `antialias=false` + rule; Xft ignores the `Xft.antialias` X resource here -- measured + 2026-11-14, so the file is what reaches every toolkit). - **Root actions** (accounts, network, sharing, time zone, update) run in a terminal after `su`, via `dtsystemsettings -`; backup is the exception: `dtbackup run` from root's crontab, passphrase in diff --git a/programs/dtbar/dtbar.c b/programs/dtbar/dtbar.c index e871214e..4ea11ac6 100644 --- a/programs/dtbar/dtbar.c +++ b/programs/dtbar/dtbar.c @@ -397,16 +397,47 @@ DtFile(const char *name, char *buf, size_t len) snprintf(buf, len, "%s/.dt/%s", home != NULL ? home : ".", name); } +/* how many Recent Items System Settings > Appearance asks for + * (~/.dt/recent.conf, "documents=N"); 10 when the file does not say */ +static int +RecentCount(void) +{ + char path[1024], line[256]; + const char *home = getenv("HOME"); + FILE *fp; + int n = 10; + + if (home == NULL || (size_t) snprintf(path, sizeof path, + "%s/.dt/recent.conf", home) >= sizeof path) + return 10; + if ((fp = fopen(path, "r")) == NULL) + return 10; + while (fgets(line, sizeof line, fp) != NULL) { + line[strcspn(line, "\r\n")] = '\0'; + if (strncmp(line, "documents=", 10) == 0) + n = atoi(line + 10); + } + fclose(fp); + if (n < 0) + n = 0; + if (n > ITEMS_MAX) + n = ITEMS_MAX; + return n; +} + static void Open(const Item *it) { char file[1024]; - int n; + int n, max; RunCommand(it->command); + max = RecentCount(); + if (max <= 0) + return; DtFile("recent", file, sizeof file); n = ItemsRead(file, recent, ITEMS_MAX); - n = ItemsPush(recent, n, 10, it); + n = ItemsPush(recent, n, max, it); (void) ItemsWrite(file, recent, n); } @@ -506,6 +537,12 @@ FillRecent(Widget w, XtPointer data, XtPointer call) Empty(recentMenu); DtFile("recent", file, sizeof file); n = ItemsRead(file, recent, ITEMS_MAX); + { + int max = RecentCount(); + + if (n > max) + n = max; + } for (i = 0; i < n; i++) Push(recentMenu, recent[i].label, 0, OpenRecent, (XtPointer) (size_t) i); diff --git a/programs/dtfile/Connect.c b/programs/dtfile/Connect.c index 463be300..3dfa38af 100644 --- a/programs/dtfile/Connect.c +++ b/programs/dtfile/Connect.c @@ -58,6 +58,34 @@ static Connect conn; static void RecentChosen(Widget w, XtPointer client, XtPointer call); +/* how many servers System Settings > Appearance asks for (~/.dt/recent.conf, + * "servers=N"); 10 when the file does not say */ +static int +RecentServers(void) +{ + char path[600], line[256]; + const char *home = getenv("HOME"); + FILE *fp; + int n = RECENT_MAX; + + if (home == NULL || (size_t) snprintf(path, sizeof path, + "%s/.dt/recent.conf", home) >= sizeof path) + return RECENT_MAX; + if ((fp = fopen(path, "r")) == NULL) + return RECENT_MAX; + while (fgets(line, sizeof line, fp) != NULL) { + line[strcspn(line, "\r\n")] = '\0'; + if (strncmp(line, "servers=", 8) == 0) + n = atoi(line + 8); + } + fclose(fp); + if (n < 0) + n = 0; + if (n > RECENT_MAX) + n = RECENT_MAX; + return n; +} + /* ---- the two files ------------------------------------------------------ */ static void @@ -137,13 +165,19 @@ static void RecentAdd(const char *address) { char *list[RECENT_MAX + 1]; + int max = RecentServers(); int n = ReadLines("servers.recent", list, RECENT_MAX), i, m = 0; char *out[RECENT_MAX]; + if (max <= 0) { + WriteLines("servers.recent", out, 0); + FreeLines(list, n); + return; + } for (i = 0; i < n; i++) - if (strcmp(list[i], address) != 0 && m < RECENT_MAX - 1) + if (strcmp(list[i], address) != 0 && m < max - 1) out[m++] = list[i]; - if (m < RECENT_MAX) + if (m < max) out[m++] = XtNewString(address); WriteLines("servers.recent", out, m); for (i = 0; i < n; i++) @@ -196,7 +230,7 @@ FillHistory(Widget w, XtPointer client, XtPointer call) XtVaGetValues(pd, XmNchildren, &kids, XmNnumChildren, &nk, NULL); for (k = 0; k < nk; k++) XtDestroyWidget(kids[k]); - n = ReadLines("servers.recent", list, RECENT_MAX); + n = ReadLines("servers.recent", list, RecentServers()); for (i = 0; i < n; i++) { XmString s = XmStringCreateLocalized(list[i]); Widget item = XtVaCreateManagedWidget("recentItem", @@ -488,7 +522,7 @@ _McdeConnectShow(FileMgrRec *rec) FillFavourites(); { char *recent[RECENT_MAX]; - int n = ReadLines("servers.recent", recent, RECENT_MAX); + int n = ReadLines("servers.recent", recent, RecentServers()); XmTextFieldSetString(conn.address, n > 0 ? recent[0] : "sftp://"); FreeLines(recent, n); diff --git a/programs/dtsystemsettings/appearance.c b/programs/dtsystemsettings/appearance.c index 219eaba7..5b50c2d0 100644 --- a/programs/dtsystemsettings/appearance.c +++ b/programs/dtsystemsettings/appearance.c @@ -28,6 +28,8 @@ #define _POSIX_C_SOURCE 200809L #include +#include +#include #include #include #include @@ -40,6 +42,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -77,15 +82,23 @@ ServerResource(Display *dpy, const char *name, const char *class, const char *de #define MAX_PALETTES 128 #define SWATCH 14 +#define ROW_LABEL_W 210 typedef struct { char name[64]; char path[512]; } Palette; +/* an option menu and its items: the value is the item's index */ +typedef struct { + Widget menu; + Widget item[16]; + int n; +} Opt; + static Palette pal[MAX_PALETTES]; static int npal; -static Widget appNote, appLogout; +static Widget appNote, appLogout, palNote, hiNote; static int PaletteCompare(const void *a, const void *b) @@ -183,24 +196,256 @@ ThemeSync(const char *palette) (void) waitpid(pid, NULL, 0); } +/* ---- the shape of the pane: a labelled row, its note, a separator -------- */ + +static Widget +Row(Widget col, const char *label) +{ + Widget row = XtVaCreateManagedWidget("row", xmRowColumnWidgetClass, col, + XmNorientation, XmHORIZONTAL, XmNspacing, 8, XmNmarginWidth, 0, + XmNmarginHeight, 0, NULL); + Widget l = Text(row, "rowLabel", label); + + XtVaSetValues(l, XmNwidth, ROW_LABEL_W, XmNrecomputeSize, False, + XmNalignment, XmALIGNMENT_END, NULL); + return row; +} + +/* a sentence under a row, aligned with the controls, not with the labels */ +static Widget +Note(Widget col, const char *text) +{ + Widget l = Text(col, "note", text); + + XtVaSetValues(l, XmNmarginLeft, ROW_LABEL_W + 8, NULL); + return l; +} + +/* a heading over the controls, in their column */ +static Widget +Heading(Widget col, const char *text) +{ + Widget row = Row(col, ""); + Widget l = Text(row, "heading", text); + + XtVaSetValues(l, XmNrenderTable, PaneFont(l, 10, True), NULL); + return l; +} + +static Widget +Sep(Widget col) +{ + return XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, col, + XmNorientation, XmHORIZONTAL, XmNmarginTop, 6, XmNmarginBottom, 6, + NULL); +} + +/* ---- option menus ------------------------------------------------------- */ + +static int +OptValue(const Opt *o) +{ + Widget h = NULL; + int i; + + if (o == NULL || o->menu == NULL) + return 0; + XtVaGetValues(o->menu, XmNmenuHistory, &h, NULL); + for (i = 0; i < o->n; i++) + if (o->item[i] == h) + return i; + return 0; +} + +static void +OptSet(Opt *o, int v) +{ + if (v < 0 || v >= o->n) + v = 0; + XtVaSetValues(o->menu, XmNmenuHistory, o->item[v], NULL); +} + +/* an option menu of LABELS; the callback gets the item's index as its data */ +static Widget +OptMenu(Widget parent, const char *name, const char *const *labels, int n, + int cur, XtCallbackProc cb, Opt *o) +{ + Arg a[2]; + Widget pd; + int i; + + XtSetArg(a[0], XmNvisibleItemCount, n < 12 ? n : 12); + o->menu = XmCreateOptionMenu(parent, (char *) name, a, 1); + pd = XmCreatePulldownMenu(o->menu, "optMenu", NULL, 0); + o->n = n < 16 ? n : 16; + for (i = 0; i < o->n; i++) { + XmString s = XmStringCreateLocalized((char *) labels[i]); + + o->item[i] = XtVaCreateManagedWidget("optItem", + xmPushButtonGadgetClass, pd, XmNlabelString, s, + XmNuserData, (XtPointer) (long) i, NULL); + XmStringFree(s); + if (cb != NULL) + XtAddCallback(o->item[i], XmNactivateCallback, cb, + (XtPointer) (long) i); + } + XtVaSetValues(o->menu, XmNsubMenuId, pd, NULL); + XtManageChild(o->menu); + OptSet(o, cur); + return o->menu; +} + +/* ---- the palette, its strip and the highlight colour -------------------- */ + +static Opt palOpt, hiOpt; +static Widget palStrip[8]; +static Pixmap palSwatch[8]; +static char palHex[8][40]; +static int palN; + +/* "#RRRRGGGGBBBB" reads as "#RRGGBB" in a menu; a name stays a name */ +static void +ShortColour(const char *in, char *out, size_t len) +{ + if (in[0] == '#' && strlen(in) == 13) + (void)snprintf(out, len, "#%c%c%c%c%c%c", in[1], in[2], + in[5], in[6], in[9], in[10]); + else + (void)snprintf(out, len, "%s", in); +} + +/* a small field of one colour; None when the name cannot be parsed */ +static Pixmap +ColourChip(Widget w, const char *colour, int size) +{ + Display *dpy = XtDisplay(w); + Screen *scr = XtScreen(w); + XColor c; + Pixmap pm; + GC gc; + + if (!XParseColor(dpy, DefaultColormapOfScreen(scr), colour, &c) || + !XAllocColor(dpy, DefaultColormapOfScreen(scr), &c)) + return None; + pm = XCreatePixmap(dpy, RootWindowOfScreen(scr), (unsigned) size, + (unsigned) size, (unsigned) DefaultDepthOfScreen(scr)); + gc = XCreateGC(dpy, pm, 0, NULL); + XSetForeground(dpy, gc, c.pixel); + XFillRectangle(dpy, pm, gc, 0, 0, (unsigned) size, (unsigned) size); + XFreeGC(dpy, gc); + return pm; +} + +/* the colours of the palette in use: the strip and the highlight menu follow + * it (the reference offers the palette's colours there) */ +static void +PaletteRead(Widget w, const char *path) +{ + FILE *fp = fopen(path, "r"); + char line[64]; + int n = 0, i; + + for (i = 0; i < 8; i++) { + palHex[i][0] = '\0'; + if (palSwatch[i] != None) { + XFreePixmap(XtDisplay(w), palSwatch[i]); + palSwatch[i] = None; + XtVaSetValues(palStrip[i], XmNlabelType, XmSTRING, + XmNlabelString, XmStringCreateLocalized((char *)""), + XmNlabelPixmap, None, NULL); + } + } + if (fp != NULL) { + while (n < 8 && fgets(line, sizeof line, fp) != NULL) { + Pixmap pm; + + line[strcspn(line, " \t\r\n")] = '\0'; + if (line[0] == '\0') + continue; + (void)snprintf(palHex[n], sizeof palHex[n], "%s", + line); + pm = ColourChip(w, line, SWATCH); + palSwatch[n] = pm; + if (pm != None) { + XmString s = XmStringCreateLocalized( + (char *) ""); + + XtVaSetValues(palStrip[n], XmNlabelType, + XmPIXMAP, XmNlabelPixmap, pm, + XmNlabelString, s, NULL); + XmStringFree(s); + } + n++; + } + fclose(fp); + } + palN = n; + for (i = 0; i < hiOpt.n; i++) { + char shown[64]; + XmString s; + Pixmap pm = None; + + if (i < palN) { + ShortColour(palHex[i], shown, sizeof shown); + pm = ColourChip(w, palHex[i], SWATCH - 2); + XtSetSensitive(hiOpt.item[i], True); + } else { + (void)snprintf(shown, sizeof shown, "-"); + XtSetSensitive(hiOpt.item[i], False); + } + s = XmStringCreateLocalized(shown); + XtVaSetValues(hiOpt.item[i], XmNlabelString, s, + XmNlabelType, pm != None ? XmPIXMAP_AND_STRING : XmSTRING, + XmNlabelPixmap, pm, XmNpixmapPlacement, XmPIXMAP_LEFT, NULL); + XmStringFree(s); + } +} + +/* the chosen palette: dtstyle's line (ColorMain.c), screen 0 as the colour + * server's; the session's colours change at the next login */ static void PaletteChosen(Widget w, XtPointer data, XtPointer call) { - const Palette *p = (const Palette *) data; + int i = (int) (long) data; char res[160]; - if (!((XmToggleButtonCallbackStruct *) call)->set) + if (i < 0 || i >= npal) return; - /* dtstyle's line (ColorMain.c), screen 0 as the colour server's */ + (void) call; + (void) w; snprintf(res, sizeof res, "*%d*ColorPalette: %s.dp\n", - XScreenNumberOfScreen(XtScreen(w)), p->name); - _DtAddToResource(XtDisplay(w), res); - snprintf(res, sizeof res, "%s.dp", p->name); + XScreenNumberOfScreen(XtScreen(appNote)), pal[i].name); + _DtAddToResource(XtDisplay(appNote), res); + snprintf(res, sizeof res, "%s.dp", pal[i].name); ThemeSync(res); snprintf(res, sizeof res, "%s: GTK programs follow now, MCDE's at the " - "next login.", p->name); + "next login.", pal[i].name); + SetText(palNote, res); + snprintf(res, sizeof res, "In use: %s.", pal[i].name); SetText(appNote, res); XtSetSensitive(appLogout, True); + PaletteRead(appNote, pal[i].path); +} + +/* the highlight colour: Motif's focus highlight and the select colour of the + * widgets that name one, for programs started after this */ +static void +HighlightChosen(Widget w, XtPointer data, XtPointer call) +{ + int i = (int) (long) data; + char res[200], note[160]; + + (void) w; + (void) call; + if (i < 0 || i >= palN) + return; + (void)snprintf(res, sizeof res, "*highlightColor: %s\n" + "*selectColor: %s\n", palHex[i], palHex[i]); + _DtAddToResource(XtDisplay(appNote), res); + ShortColour(palHex[i], note, sizeof note); + (void)snprintf(res, sizeof res, "Highlight %s: programs started from " + "now on use it.", note); + SetText(hiNote, res); } static void @@ -212,16 +457,236 @@ LogOutNow(Widget w, XtPointer data, XtPointer call) Spawn("dtaction ExitSession"); } +/* ---- the title bar double click (dtwm) ---------------------------------- */ + +/* libDtSvc (DtUtil1/WmRestart.c) has no header for it; input.c declares it + * the same way */ +int _DtWmRestartNoConfirm(Display *display, Window root); + +static Widget tbToggle, tbNote; + +static void +TitleApply(Widget w, XtPointer data, XtPointer call) +{ + Display *dpy = XtDisplay(tbToggle); + char res[96]; + + (void) w; + (void) data; + (void) call; + (void)snprintf(res, sizeof res, "Dtwm*mcdeTitleBarDoubleClick: %s\n", + XmToggleButtonGetState(tbToggle) ? "minimize" : "none"); + _DtAddToResource(dpy, res); + (void) _DtWmRestartNoConfirm(dpy, DefaultRootWindow(dpy)); + SetText(tbNote, "The window manager has restarted with it."); +} + +static Boolean +TitleOn(Display *dpy) +{ + char v[64]; + + ServerResource(dpy, "dtwm.mcdeTitleBarDoubleClick", + "Dtwm.McdeTitleBarDoubleClick", "none", v, sizeof v); + return strcasecmp(v, "minimize") == 0; +} + +/* ---- the number of recent items ----------------------------------------- */ + +static Opt recOpt[3]; +static const char *const recKeys[3] = { "applications", "documents", + "servers" }; +static const char *const recNames[3] = { "Applications", "Documents", + "Servers" }; +static const int recValues[] = { 0, 5, 10, 15, 20, 30, 50 }; +#define NRECVALUES ((int) (sizeof recValues / sizeof recValues[0])) + +static void +RecentFile(char *buf, size_t len) +{ + const char *home = getenv("HOME"); + + (void)snprintf(buf, len, "%s/.dt/recent.conf", home != NULL ? home : + "."); +} + +static void +RecentRead(int *v) +{ + char path[600], line[128]; + FILE *fp; + + for (int i = 0; i < 3; i++) + v[i] = 10; + RecentFile(path, sizeof path); + if ((fp = fopen(path, "r")) == NULL) + return; + while (fgets(line, sizeof line, fp) != NULL) { + int k; + + line[strcspn(line, "\r\n")] = '\0'; + for (k = 0; k < 3; k++) { + size_t l = strlen(recKeys[k]); + + if (strncmp(line, recKeys[k], l) == 0 && line[l] == '=') + v[k] = atoi(line + l + 1); + } + } + fclose(fp); +} + +static void +RecentWrite(void) +{ + char path[600]; + FILE *fp; + int i; + + RecentFile(path, sizeof path); + if ((fp = fopen(path, "w")) == NULL) + return; + for (i = 0; i < 3; i++) + fprintf(fp, "%s=%d\n", recKeys[i], + recValues[OptValue(&recOpt[i])]); + fclose(fp); +} + +static void +RecentChanged(Widget w, XtPointer data, XtPointer call) +{ + (void) w; + (void) data; + (void) call; + RecentWrite(); +} + +/* ---- font smoothing ----------------------------------------------------- */ + +static Opt aaOpt; +static Widget aaSize, aaNote; + +static void +AaFile(char *buf, size_t len) +{ + const char *home = getenv("HOME"); + + (void)snprintf(buf, len, "%s/.config/fontconfig/conf.d/" + "60-mcde-antialias.conf", home != NULL ? home : "."); +} + +/* ~/.config/fontconfig/conf.d/60-mcde-antialias.conf, the rule fontconfig + * (and with it Xft, GTK, Qt and everything else) follows for new programs */ +static void +AaWrite(int off, int minSize) +{ + char path[700], dir[700], tmp[740]; + FILE *fp; + char *p; + + AaFile(path, sizeof path); + if (off == 0 && minSize <= 0) { + (void)remove(path); + return; + } + /* the folders from the top down: conf.d needs fontconfig, that .config */ + (void)snprintf(dir, sizeof dir, "%s", path); + if ((p = strrchr(dir, '/')) != NULL) + *p = '\0'; + else + dir[0] = '\0'; + for (p = dir + 1; p != NULL && *p != '\0'; p++) + if (*p == '/') { + *p = '\0'; + (void)mkdir(dir, 0755); + *p = '/'; + } + if (dir[0] != '\0') + (void)mkdir(dir, 0755); + (void)snprintf(tmp, sizeof tmp, "%s.new", path); + if ((fp = fopen(tmp, "w")) == NULL) + return; + fputs("\n" + "\n" + "\n" + "\n" + " \n", fp); + if (off == 0 && minSize > 0) + fprintf(fp, " " + "%d\n", minSize); + fputs(" " + "false\n" + " \n" + "\n", fp); + fclose(fp); + (void)rename(tmp, path); +} + +/* the state the file describes: 2 off, 0 an upper size, -1 no rule */ +static int +AaRead(int *minSize) +{ + char path[700], line[256]; + FILE *fp; + int off = 0, min = -1; + + *minSize = 0; + AaFile(path, sizeof path); + if ((fp = fopen(path, "r")) == NULL) + return -1; + while (fgets(line, sizeof line, fp) != NULL) { + char *p; + + if (strstr(line, "name=\"size\"") != NULL) + min = 0; + if (min == 0 && (p = strstr(line, "")) != NULL) + min = atoi(p + 8); + } + fclose(fp); + if (min >= 0) { + *minSize = min; + return 0; + } + off = 1; + return 2; +} + +static void +AaApply(Widget w, XtPointer data, XtPointer call) +{ + char *text = XmTextFieldGetString(aaSize); + int min = text != NULL ? atoi(text) : 0; + int mode = OptValue(&aaOpt); + + (void) w; + (void) data; + (void) call; + if (min < 0 || min > 72) + min = 0; + AaWrite(mode == 2 ? 1 : 0, mode == 2 ? 0 : min); + SetText(aaNote, mode == 2 ? "Smoothing is off for new programs." + : min > 0 ? "Sizes up to this one are drawn without smoothing in " + "new programs." : "The programs decide themselves."); + XtFree(text); +} + +/* ---- the pane ----------------------------------------------------------- */ + Widget MakeAppearance(Widget parent) { Display *dpy = XtDisplay(parent); - Widget box = XtVaCreateWidget("appearance", xmRowColumnWidgetClass, - parent, XmNspacing, 6, NULL); - Widget sw, grid; - char dir[512], current[64], name[64], class[64]; + Widget sw = XtVaCreateManagedWidget("appearanceScroll", + xmScrolledWindowWidgetClass, parent, + XmNscrollingPolicy, XmAUTOMATIC, XmNwidth, 760, XmNheight, 640, + NULL); + Widget box = XtVaCreateManagedWidget("appearance", + xmRowColumnWidgetClass, sw, XmNspacing, 8, NULL); + Widget row, b; + char dir[512], current[64], name[64], class[64], buf[128]; const char *home = getenv("HOME"); int i, scr = XScreenNumberOfScreen(XtScreen(parent)); + char *palNames[MAX_PALETTES]; + XmString s; npal = 0; if (home != NULL) { @@ -240,31 +705,141 @@ MakeAppearance(Widget parent) strcmp(current + strlen(current) - 3, ".dp") == 0) current[strlen(current) - 3] = '\0'; - (void) Text(box, "label", "The colours of the desktop:"); - sw = XtVaCreateManagedWidget("palettes", xmScrolledWindowWidgetClass, - box, XmNscrollingPolicy, XmAUTOMATIC, XmNwidth, 560, - XmNheight, 300, NULL); - grid = XtVaCreateManagedWidget("grid", xmRowColumnWidgetClass, sw, - XmNpacking, XmPACK_COLUMN, XmNnumColumns, (npal + 3) / 4, - XmNorientation, XmHORIZONTAL, XmNradioBehavior, True, NULL); - for (i = 0; i < npal; i++) { - XmString s = XmStringCreateLocalized(pal[i].name); - Pixmap pm = Swatches(parent, pal[i].path); - Widget t; + /* 1: the palette and the highlight colour */ + row = Row(box, "Appearance:"); + if (npal > MAX_PALETTES) + npal = MAX_PALETTES; + for (i = 0; i < npal; i++) + palNames[i] = pal[i].name; + { + int cur = 0; - t = XtVaCreateManagedWidget("palette", xmToggleButtonWidgetClass, - grid, XmNlabelString, s, XmNindicatorOn, XmINDICATOR_NONE, - XmNshadowThickness, 2, XmNset, strcmp(pal[i].name, - current) == 0 ? XmSET : XmUNSET, - XmNlabelType, pm != None ? XmPIXMAP_AND_STRING : XmSTRING, - XmNlabelPixmap, pm, XmNpixmapPlacement, XmPIXMAP_TOP, - XmNalignment, XmALIGNMENT_CENTER, - /* Motif measured the pair a few pixels short of the - * Xft text and cut its bottom off (measured) */ - XmNmarginHeight, 6, NULL); + for (i = 0; i < npal; i++) + if (strcmp(pal[i].name, current) == 0) + cur = i; + (void) OptMenu(row, "palette", (const char *const *) palNames, + npal, cur, PaletteChosen, &palOpt); + } + (void) Note(box, "For the overall look of buttons, menus and " + "windows."); + palNote = Note(box, ""); + row = Row(box, ""); + row = XtVaCreateManagedWidget("paletteStrip", xmRowColumnWidgetClass, + row, XmNorientation, XmHORIZONTAL, XmNspacing, 2, + XmNmarginWidth, 0, XmNmarginHeight, 0, NULL); + for (i = 0; i < 8; i++) { + s = XmStringCreateLocalized((char *) ""); + palStrip[i] = XtVaCreateManagedWidget("chip", + xmLabelWidgetClass, row, XmNlabelString, s, + XmNlabelType, XmSTRING, XmNmarginWidth, 0, + XmNmarginHeight, 0, NULL); XmStringFree(s); - XtAddCallback(t, XmNvalueChangedCallback, PaletteChosen, - (XtPointer) &pal[i]); + palSwatch[i] = None; + } + + row = Row(box, "Highlight Color:"); + { + static const char *const dummy[] = { "-", "-", "-", "-", "-", + "-", "-", "-" }; + + (void) OptMenu(row, "highlight", dummy, 8, 0, HighlightChosen, + &hiOpt); + } + (void) Note(box, "For selected text."); + hiNote = Note(box, ""); + + (void) Sep(box); + + /* 2: the scroll bars and the title bar */ + (void) Heading(box, "Scroll bars:"); + (void) Note(box, "Motif pages a list when the scroll bar is clicked,\n" + "and jumps to the place with the middle button. Arrow buttons at\n" + "both ends and smooth scrolling are not part of Motif."); + row = Row(box, ""); + tbToggle = XtVaCreateManagedWidget("Minimize when double-clicking a " + "window title bar", xmToggleButtonWidgetClass, row, + XmNset, TitleOn(dpy) ? XmSET : XmUNSET, NULL); + XtVaSetValues(tbToggle, XmNalignment, XmALIGNMENT_BEGINNING, NULL); + row = Row(box, ""); + (void) Button(row, "Apply (restarts the window manager)", TitleApply, + NULL); + tbNote = Note(box, ""); + + (void) Sep(box); + + /* 3: the number of recent items */ + row = Row(box, "Number of Recent Items:"); + for (i = 0; i < 3; i++) { + static const char *const values[] = { "0", "5", "10", "15", + "20", "30", "50" }; + + if (i > 0) + (void) Text(row, "recentGap", " "); + (void) Text(row, "recentName", recNames[i]); + (void) OptMenu(row, "recent", values, NRECVALUES, 2, + RecentChanged, &recOpt[i]); + } + (void) Note(box, "Documents is the list in the bar's M menu, Servers " + "the addresses\nin Connect to Server; 0 leaves the list empty. " + "Applications has no\nlist of its own yet."); + { + int v[3]; + + RecentRead(v); + for (i = 0; i < 3; i++) { + int k; + + for (k = 0; k < NRECVALUES; k++) + if (recValues[k] == v[i]) + OptSet(&recOpt[i], k); + } + } + + (void) Sep(box); + + /* 4: font smoothing */ + row = Row(box, "Font smoothing style:"); + { + static const char *const styles[] = { "Automatic - best for the " + "main display", "On", "Off" }; + int min = 0, state = AaRead(&min); + int cur = state == 2 ? 2 : 0; + + (void) OptMenu(row, "smoothing", styles, 3, cur, NULL, &aaOpt); + XtAddCallback(aaOpt.item[0], XmNactivateCallback, AaApply, NULL); + XtAddCallback(aaOpt.item[1], XmNactivateCallback, AaApply, NULL); + XtAddCallback(aaOpt.item[2], XmNactivateCallback, AaApply, NULL); + row = Row(box, "Turn off smoothing below"); + aaSize = XtVaCreateManagedWidget("smoothingSize", + xmTextFieldWidgetClass, row, XmNcolumns, 3, NULL); + (void)snprintf(buf, sizeof buf, "%d", min > 0 ? min : 8); + XmTextFieldSetString(aaSize, buf); + (void) Text(row, "andSmaller", "and smaller."); + b = Button(row, "Apply", AaApply, NULL); + XtSetSensitive(b, True); + aaNote = Note(box, ""); + } + + (void) Sep(box); + + /* the fonts of every window (MakeFonts below) */ + (void) Heading(box, "Fonts:"); + { + Widget frow = Row(box, ""); + Widget fb = MakeFonts(frow); + + XtManageChild(fb); + } + + /* the palette of the session: the strip and the highlight colours */ + { + int cur = 0; + + for (i = 0; i < npal; i++) + if (strcmp(pal[i].name, current) == 0) + cur = i; + if (npal > 0) + PaletteRead(box, pal[cur].path); } appNote = Text(box, "note", ""); { @@ -275,7 +850,7 @@ MakeAppearance(Widget parent) } appLogout = PaneButton(box, "Log Out Now...", LogOutNow, NULL); XtSetSensitive(appLogout, False); - return box; + return sw; } /* ---- Fonts -------------------------------------------------------------- */ @@ -422,7 +997,7 @@ MakeFonts(Widget parent) } (void) Text(box, "label", "The font of every window:"); - XtSetArg(a[n], XmNvisibleItemCount, 10); n++; + XtSetArg(a[n], XmNvisibleItemCount, 6); n++; XtSetArg(a[n], XmNselectionPolicy, XmBROWSE_SELECT); n++; XtSetArg(a[n], XmNwidth, 320); n++; fontList = XmCreateScrolledList(box, "families", a, n); @@ -444,7 +1019,7 @@ MakeFonts(Widget parent) fontSize = XtVaCreateManagedWidget("size", xmScaleWidgetClass, box, XmNorientation, XmHORIZONTAL, XmNminimum, 7, XmNmaximum, 20, XmNvalue, atoi(size) >= 7 && atoi(size) <= 20 ? atoi(size) : 10, - XmNshowValue, True, XmNscaleWidth, 320, NULL); + XmNshowValue, True, XmNscaleWidth, 280, NULL); XtAddCallback(fontSize, XmNvalueChangedCallback, FontApply, NULL); fontPreview = Text(box, "preview", "The quick brown fox jumps over the lazy dog. 0123456789"); diff --git a/programs/dtsystemsettings/main.c b/programs/dtsystemsettings/main.c index 34ddedf1..fa7c27de 100644 --- a/programs/dtsystemsettings/main.c +++ b/programs/dtsystemsettings/main.c @@ -1178,6 +1178,12 @@ ShowPane(const Pane *p) w = MakeNetwork(paneArea); else if (strcmp(p->id, "bluetooth") == 0) w = MakeBluetooth(paneArea); + else if (strcmp(p->id, "appearance") == 0) { + w = MakeAppearance(paneArea); + /* palette, the four groups and the fonts need more room than + * the overview */ + XtVaSetValues(shell, XmNheight, 720, XmNwidth, 780, NULL); + } else if (strcmp(p->id, "datetime") == 0) { w = MakeDateTime(paneArea); /* calendar, clock and the two tabs need more room than the @@ -1202,8 +1208,6 @@ ShowPane(const Pane *p) w = MakeDesktop(paneArea); else if (strcmp(p->id, "screensaver") == 0) w = MakeScreenSaver(paneArea); - else if (strcmp(p->id, "fonts") == 0) - w = MakeFonts(paneArea); else if (strcmp(p->id, "keyboard") == 0) w = MakeKeyboard(paneArea); else if (strcmp(p->id, "mouse") == 0) diff --git a/programs/dtsystemsettings/panes.c b/programs/dtsystemsettings/panes.c index 194f522d..510ac88f 100644 --- a/programs/dtsystemsettings/panes.c +++ b/programs/dtsystemsettings/panes.c @@ -22,11 +22,10 @@ const char *const categoryNames[CAT_COUNT] = { const Pane panes[] = { { "appearance", "Appearance", CAT_PERSONAL, "DtColor.pm", PANE_OWN, - NULL, "appearance colours colors palette theme farben" }, + NULL, "appearance colours colors palette theme farben fonts " + "schrift schriften smoothing antialias" }, { "desktop", "Desktop", CAT_PERSONAL, "DtBkdrp.pm", PANE_OWN, NULL, "desktop background wallpaper hintergrund" }, - { "fonts", "Fonts", CAT_PERSONAL, "DtFont.pm", PANE_OWN, NULL, - "fonts schrift schriften" }, { "language", "Language", CAT_PERSONAL, "DtI18N.pm", PANE_OWN, NULL, "language sprache locale region formats datum" }, { "screensaver", "Screen Saver", CAT_PERSONAL, "DtScrn.pm", @@ -114,6 +113,9 @@ PaneFind(const char *id) if (id == NULL) return NULL; + /* the fonts are part of Appearance since t0099; the old id stays */ + if (strcmp(id, "fonts") == 0) + id = "appearance"; for (i = 0; i < paneCount; i++) if (strcmp(panes[i].id, id) == 0) return &panes[i]; diff --git a/programs/dtwm/WmCEvent.c b/programs/dtwm/WmCEvent.c index 7d676071..a98e8202 100644 --- a/programs/dtwm/WmCEvent.c +++ b/programs/dtwm/WmCEvent.c @@ -34,6 +34,8 @@ * Included Files: */ +#include + #include "WmGlobal.h" #include "WmICCC.h" @@ -1242,11 +1244,30 @@ void CheckButtonPressBuiltin (XButtonEvent *buttonEvent, Context context, Contex /* * Title component: * SELECT_BUTTON or DMANIP_BUTTON Press - - * start looking for a move. + * start looking for a move; a double click does + * what Dtwm*mcdeTitleBarDoubleClick asks (MCDE). */ PushGadgetIn (pCD, partContext); + if (wmGD.clickData.doubleClickContext == F_SUBCONTEXT_W_TITLE && + wmGD.mcdeTitleBarDoubleClick != NULL && + strcmp (wmGD.mcdeTitleBarDoubleClick, "none") != 0) + { + Boolean maximize = strcmp (wmGD.mcdeTitleBarDoubleClick, + "maximize") == 0; + + wmGD.clickData.clickPending = False; + wmGD.clickData.doubleClickPending = False; + if (maximize) + (void) F_Maximize ((String) NULL, pCD, + (XEvent *) buttonEvent); + else + (void) F_Minimize ((String) NULL, pCD, + (XEvent *) buttonEvent); + return; + } + /* * Fix for 5075 - Check to make sure that MWM_FUNC_MOVE is set in the * clientFunctions. This is necessary because the title diff --git a/programs/dtwm/WmGlobal.h b/programs/dtwm/WmGlobal.h index e8f7dfb1..2eb900ce 100644 --- a/programs/dtwm/WmGlobal.h +++ b/programs/dtwm/WmGlobal.h @@ -2051,6 +2051,7 @@ typedef struct _WmGlobalData int colormapFocusPolicy; /* resource */ String configFile; /* resource */ String cppCommand; /* resource */ + String mcdeTitleBarDoubleClick; /* resource: none|minimize|maximize */ Boolean deiconifyKeyFocus; /* resource */ int doubleClickTime; /* resource */ Boolean enableWarp; /* resource */ diff --git a/programs/dtwm/WmResNames.h b/programs/dtwm/WmResNames.h index cddc84c7..782ed674 100644 --- a/programs/dtwm/WmResNames.h +++ b/programs/dtwm/WmResNames.h @@ -64,6 +64,8 @@ #define WmNcolormapFocusPolicy "colormapFocusPolicy" #define WmNconfigFile "configFile" #define WmNcppCommand "cppCommand" +/* MCDE: what a double click on a window's title bar does (WmEvent.c) */ +#define WmNmcdeTitleBarDoubleClick "mcdeTitleBarDoubleClick" #define WmNdeiconifyKeyFocus "deiconifyKeyFocus" #define WmNdoubleClickTime "doubleClickTime" #define WmNenableWarp "enableWarp" @@ -227,6 +229,7 @@ #define WmCColormapFocusPolicy "ColormapFocusPolicy" #define WmCConfigFile "ConfigFile" #define WmCCppCommand "CppCommand" +#define WmCMcdeTitleBarDoubleClick "McdeTitleBarDoubleClick" #define WmCDeiconifyKeyFocus "DeiconifyKeyFocus" #define WmCDoubleClickTime "DoubleClickTime" #define WmCEnableWarp "EnableWarp" diff --git a/programs/dtwm/WmResource.c b/programs/dtwm/WmResource.c index 14651e25..29cee74c 100644 --- a/programs/dtwm/WmResource.c +++ b/programs/dtwm/WmResource.c @@ -718,6 +718,16 @@ XtResource wmGlobalResources[] = (XtPointer)True }, + { + WmNmcdeTitleBarDoubleClick, + WmCMcdeTitleBarDoubleClick, + XtRString, + sizeof (String), + XtOffsetOf(WmGlobalData, mcdeTitleBarDoubleClick), + XtRImmediate, + (XtPointer) "none" + }, + { WmNdoubleClickTime, WmCDoubleClickTime,