# Source: ext/src/mcde/AGENTS.md as of 2026-11-13, before the refactor (verbatim)

# ext/src/mcde -- MCDE, the Makronix Common Desktop Environment

## What it is

The Makronix fork of CDE 2.5.3 (`IMPORT`), on its way to a desktop that works as
one: one System Preferences, a software update, the small things that belong
together (`GOAL.md` of the Makronix tree, "MCDE").  Makronix ships it in
place of CDE; pkgsrc builds it on any platform from `pkgsrc/`.

## The philosophy -- binding from the first commit (Konrad, 2026-11-09)

1. **CDE, Motif, Xlib, X11 only.**  No GTK, no Qt, no compositor, no scripting
   language as a requirement.  It must be fast and run on machines of 1995.
2. **C99 and POSIX (POSIX.1-2008, XSI where CDE already needs it).**  New code
   compiles with `-std=c99 -D_POSIX_C_SOURCE=200809L` and nothing beyond what
   POSIX and the X/Motif libraries give.  MCDE runs on NetBSD and on Linux and
   builds through pkgsrc on both.
3. **The operating system is behind one layer: `lib/McdeSys`.**  Everything that
   differs between systems -- users and groups, network and Wi-Fi, time zone,
   host name, services at boot, software update, later display, sound and
   printers -- goes through the functions declared in
   `include/Mcde/McdeSys.h`.  A program (the System Preferences, dtlogin's
   helpers, ...) never calls `useradd`, `ifconfig`, `wpa_supplicant`,
   `/etc/rc.conf` or `systemctl` itself, and never has an `#ifdef __NetBSD__`.
   Each system has one backend in `lib/McdeSys/<system>.c` (`netbsd.c` first,
   `linux.c` next); a backend uses the system's own tools the documented way.
4. **Installed with pkgsrc, in conflict with CDE.**  `pkgsrc/Makefile` carries
   `CONFLICTS+= cde-[0-9]*`; MCDE and CDE are never installed together.

## What is in it

- The CDE 2.5.3 tree (first commit unchanged), with the nine fixes of pkgsrc
  `wm/cde` folded in.
- `pkgsrc/` -- the recipe (`mcde-0.1.0`).  The distfile and `distinfo` come from
  `tools/mcde-dist.sh` of the Makronix tree (`git archive` of a commit).
- `motif/` -- Motif 2.3.8 with pkgsrc x11/motif's 28 patches and MCDE's own
  fixes (Command key, exported menu bars, Xft renditions).  Outside pkgsrc
  MCDE builds it itself into ${prefix}/lib for its own programs
  (configure.ac, --with-private-motif, the default).  Through pkgsrc -- on
  Makronix -- it is the system's Motif: `pkgsrc-motif/` is the recipe of
  x11/mcde-motif (the same archive, WRKSRC motif/, otherwise pkgsrc's
  x11/motif recipe and PLIST; CONFLICTS motif), wm/mcde links it with
  --without-private-motif, and the build VM's mk.conf sets MOTIFBASE so
  every other Motif package takes it too (tools/vmbuild/mk-cde.conf).
  Konrad, 2026-11-13: "mcde baut sein eigenes motif, wenn es nicht makronix
  ist".  motif/Makefile.am is automake-foreign: pkgsrc's autoreconf -fiv of
  wm/mcde reaches it through AC_CONFIG_SUBDIRS.
- `IMPORT` -- where it came from.
- `include/Mcde/McdeSys.h` -- the system layer's contract; `lib/McdeSys`
  (libMcdeSys) implements the first part: `common.c` (POSIX), `netbsd.c`,
  `linux.c` (chosen by the `NETBSD` conditional), `mcde_sys_info` and
  `mcde_sys_power`.  `test_sysinfo` (`make check`) prints what the computer
  tells and checks what must hold; passed on Linux and in the NetBSD build VM.
- `programs/icons/MakronixDtlogo.pm` -- the Makronix logo, the default of dtlogin
  (`programs/dtlogin/config/Xresources.src`).
- `programs/dtfile/Navigation.c` -- the file manager window's navigation: toolbar
  (back, forward, view, search), sidebar with the places, history per window,
  free space in the status line.  Hooked into `FileMgr.c` at four places
  marked "MCDE"; the search into `FilterFiles` (`File.c`, `_McdeNavHidden`),
  its text kept per window in Navigation.c, not in FileMgrData (saved as
  resources).  The first window's directory does not come through
  ShowNewDirectory: the view buttons and the history are set once its data
  is attached.  `ChangeDir.c` compared two empty ToolTalk paths and called
  every folder "restricted"; it compares real paths only.  Tested on Xvfb:
  Icons pressed at start, List, a place, Back, Forward, the search.
- `programs/dtfile/NetView.c` -- "Network" in the sidebar: the computers
  that announce themselves (mcde_sys_net_browse, run after the view is
  drawn), what the chosen one offers (SFTP files, SSH terminal, NFS
  exports, SMB shares -- listed, not opened: NetBSD has no SMB client that
  mounts), and "Connect to Server:" for sftp://, nfs://, afp://.  A share
  is mounted on ~/Network/HOST[/NAME] (mcde_sys_net_mount) and opened in
  the window; a server that wants a password gets a dialog with a starred
  field.  The view replaces the work area as Columns.c does; going to any
  folder (Back, a place, a view) leaves it.
- `programs/dtfile/Columns.c` -- the column view, the fourth view button: a
  column per folder from Home (or /) down to the window's folder, a preview
  on the right (type icon, kind from TYPE_LABEL and MIME_TYPE, size, date).
  A folder chosen becomes the window's folder through _McdeNavGoTo
  (ChangeDirectoryToParent), and _McdeNavVisit lets the columns follow Back,
  Forward and places; a double click runs the type's first action.  The
  columns are a sibling of CDE's work frame: managed first, then the work
  frame unmanaged, with the form around at XmRESIZE_NONE -- otherwise the
  window shrank (measured).
- `programs/dtterm/Tabs.c` -- tabs: the window holds an XmTabStack, every tab a
  page (an XmPanedWindow, `mcdeSplit`) of whole DtTermViews.  Ctrl+Shift+T new
  tab, Ctrl+Shift+D split (one more view in the page: Xt cannot reparent, so
  every tab is a page from the start), Ctrl+Shift+W closes the view, the tab
  with its last, Ctrl+Shift+Left/Right switch; a program's title goes to its tab (TermParse.c), the window shows
  the front tab's.  dtterm draws through Xft (`TermPrimRenderXft.c`) and reads
  UTF-8 (setlocale in `DtTermMain.c`, from MakroDE).
- `programs/dtbar/dtbar.c` -- the bar at the top of the screen: the M menu,
  the menus of the program with the focus, the clock.  The protocol is
  `include/Mcde/GlobalMenu.h` (a selection, properties, client messages);
  the program side is `lib/DtSvc/DtUtil2/McdeGlobalMenu.c`, started by
  `DtInitialize`, so every CDE program takes part without a change of its own
  and without a change of its own: an Xt create hook finds its XmMenuBar, the
  bar hides it (unmanaged) and shows its tree, a click calls the button's
  own callback.  Motif refuses the accelerators of an unmanaged menu bar
  (RCPopup.c, AllWidgetsAccessible), so the hidden bar is marked with
  `_XmMenuBarSetExported` (motif/lib/Xm/RowColumnP.h, our Motif) and its
  shortcuts keep working -- dtpad Command+F with the bar running, tested.
  A push button named options/preferences/settings/global (or labelled
  Preferences, Options..., Settings..., Global...) without a shortcut gets
  Command+comma, as on every desktop of that kind (dtterm: Global Options,
  tested).  The
  text form is `McdeMenuModel.c` with its test (`test_menumodel`, `make
  check`).  A foreign window is registered with a hidden core widget, never
  with a shell (a shell stops on "Event with wrong window").
  `MCDE_NO_GLOBAL_MENU` keeps a program's menu bar in its window,
  `MCDE_GLOBAL_MENU_DEBUG` logs what the program side does.
  The M menu: About This Computer (`about.c`: logo, system, version,
  processor, memory, startup disk, More Info -- from `mcde_sys_info`),
  Software Update (not yet), System Settings, Favourites (`~/.dt/favourites`)
  and Recent Items (`~/.dt/recent`; `items.c` with `test_items`), Force Quit
  (`forcequit.c`, XKillClient), Sleep/Restart/Shut Down (`mcde_sys_power`,
  the last two ask first), Lock Screen, Log Out with the user's name.  Never
  test the power items to the end on a development host: dtbar runs as the
  user there, and the system may let the user shut it down.
  Right of the menus, left of the clock (`status.c`): volume (a slider in
  the menu -- `menuscale.c` gives XmScale Motif's XmQTmenuSavvy trait with
  XmeTraitSet, so a menu takes it; Mute; the wheel over the speaker),
  Bluetooth (on/off), network (the cards, not bridges or containers) and,
  on a machine that has one, the battery (charge, power source, time left;
  NetBSD's envsys(4) dictionary, Linux's /sys/class/power_supply,
  `docs/reference/battery.txt` in the Makronix tree), all through McdeSys;
  icons are CDE icon files (`icons/Mcde*.t.pm`).  The status menu bar has a
  fixed width, 30 pixels an icon (`StatusWidth`): the form sized it before
  the icons and the bar squeezed them to 10 pixels.  Test sound only against a private PulseAudio
  (null sink, own socket): the slider changes the volume it reaches.
  dtwm places and maximizes windows below the bar (`McdeExcludeBar` in
  `programs/dtwm/WmMultiHead.c`); a full-screen window covers it.
  The bar shows a program's menus only while one of its windows has the
  focus: dtwm publishes the focused client as `_NET_ACTIVE_WINDOW` (EWMH;
  `SetNetActiveWindow` in WmEwmh.c, called from SetKeyboardFocus and where
  the focus is dropped), and the bar compares it with the menus' owner --
  the window itself, a dialog of it (WM_TRANSIENT_FOR), or a window of the
  same program (WM_CLIENT_LEADER).  A program without a global menu in
  front: the bar shows only the M menu (Konrad, 2026-11-13).  The bar has
  colour set 5, the programs' background, not set 6 of a menu bar
  (`Dtbar*secondaryColorSetId: 5`).
- The desktop's own programs -- mcdesoundd, dtlaunch, dtterm -dropdown,
  dtbar, the login items -- are started by dtsession, not by Xsession:
  `programs/dtlogin/config/sys.sessionetc.src` (installed as
  config/sys.sessionetc) sources the scripts of `config/sessionetc.d`, and
  dtsession runs it before the user's ~/.dt/sessions/sessionetc (StartEtc,
  SmRestore.c), after the session's resources and the colour server are
  there.  Started from Xsession.d they came up before dtsession and took
  `*background` from the user's ~/.Xdefaults: a purple bar on 2026-11-13
  (the user's base16 theme), measured by restarting dtbar in the running
  session.
- "Always on Top" (dtwm, `programs/dtwm/WmFunction.c`): `ClientData.mcdeAbove`
  per window, set by `f.mcde_above` (a toggle with a check mark in the
  window menu, WmMenu.c) or by `_NET_WM_STATE_ABOVE` (WmEwmh.c, also when a
  client maps with it set, WmManage.c).  Every raise of another window ends
  with the windows kept on top raised again, lowest first, so any number of
  them keep their order; a new window and a workspace switch do the same.
  Upstream kept one `pSD->topClient` and raised it on every VisibilityNotify;
  that is gone.  The entry is in sys.dtwmrc (messages 8-10, all locales) and
  in the built-in menu (dtwm.msg set 62, 71), which dtwm takes when there is
  no sys.dtwmrc for $LANG (C.UTF-8).  Tested on Xvfb with four xterms and
  `_NET_WM_STATE` client messages: the stack follows, dtwm stays up.
- The front panel (`programs/types/dtwm.fp.src`, Konrad 2026-11-11): left of
  the workspace switch Files (drawer: Home, Desktop, Documents, Downloads
  -- file controls, so a dropped file is moved there), Mail (drawer: Text
  Editor, Calendar, Calculator, Icon Editor), Terminal (drawer: Disk
  Utility, System Settings), Network (dtfile on ~/Network; drawer: Remote
  Login -- `programs/dtterm/dtremotelogin` in a dtterm -- and Sharing),
  Desktop Style (drawer: CDE's printers, Applications, help); right of it
  only the running programs and the trash.  No clock and date: the bar has
  them.  The actions are at the end of `types/dt.dt.src` (McdeNetwork,
  McdeDiskUtility, ...): no shell variables and no CDE_INSTALLATION_TOP
  inside '...' there (docs/reference/frontpanel.txt in the Makronix tree).
  The home folders are made at login (`dtlogin/config/0075.homefolders`).
  dtwm keeps the switch in the middle of the screen (`Center` in
  WmMcdePanel.c): after every change of the right part the shell is moved
  by as much as the switch's centre is off, less the frame offset learnt
  from the first move; measured exact at 800, 1024 and 1920 wide, with and
  without running programs.  Icons McdeDisk and McdeNetwork (l, m, t) in
  `programs/icons`, CDE's symbolic colours.
- `programs/dtappscan` -- the applications by category, what is installed
  only (CDE's appmanager lists Firefox and Skype whether they are there or
  not).  Desktop entries of $XDG_DATA_HOME, $XDG_DATA_DIRS, /usr/pkg/share,
  /usr/local/share, /usr/share (Desktop Entry Specification 1.5,
  docs/reference/desktop-entry.txt in the Makronix tree: TryExec or the
  program on the PATH, Hidden hides an id for good, OnlyShowIn/NotShowIn,
  Name[lang], field codes out, %f/%u make the action take files) and a table
  of the desktop's own programs.  Writes ~/.dt/types/mcde-apps.dt (one
  ACTION each: no '$' in EXEC_STRING), ~/.dt/icons/McdeApp_*.[lmt].pm (PNG
  through libpng to XPM, 4 bits a channel -- Motif draws some PNGs in blue
  only) and ~/.dt/Applications/<Category>/<Action> (CDE action files).  Run
  at login by Xsession.d/0077.dtappscan; dtfile's place "Applications" and
  the action Dtappmgr (the panel's Applications) open ~/.dt/Applications.
  `dtappscan -v` lists what it found.  Tested with made-up entries (12
  checks) and with this host's 166 entries in a session.  In a test session
  the icons need XMICONSEARCHPATH (':'-separated), the actions
  DTDATABASESEARCHPATH with $HOME/.dt/types.
- dtfile: the folder ~/Network is the network -- going there (the place,
  `dtfile -dir ~/Network`, Back) shows NetView (`IsNetworkDir` in
  Navigation.c); shares are mounted below it.
- `programs/dtthemesync` -- every toolkit looks like MCDE ("MCDE is king",
  Konrad).  From the session's palette (dtsession.0.colorPalette, the *.dp
  where the colour server looks) and *mcde.fontName/fontSize: each set's
  foreground, select colour and shadows by Motif's XmCalculateColorRGB, as
  the colour server makes them (an Xt shell must exist first, else Motif
  reads no display); the sets' jobs from docs/reference/cde-colorsets.txt
  in the Makronix tree (1 active, 4 text, 5 main, 6 menus and dialogs).
  Writes X resources (*foreground, *background, *color0-15, XTerm*), GTK 1
  (~/.gtkrc), GTK 2/3/4 themes ~/.themes/MCDE-a|MCDE-b (3 and 4 import the
  built-in theme and put MCDE's colours and Motif's bevels over it, no
  shadows, radii or animations), qt5ct/qt6ct schemes with Fusion
  (QT_QPA_PLATFORMTHEME=qt5ct from Xsession.d/0078.dtthemesync), kdeglobals.
  Live: dtthemesync -daemon is the XSETTINGS manager (started by the first
  run, its output closed); every run flips Net/ThemeName between MCDE-a
  and MCDE-b, so running GTK programs load the new files; GTK 1 gets
  _GTK_READ_RCFILES.  System Settings runs it when a palette or font is
  chosen.  Tested on Xvfb: gtk-query-settings reports MCDE-a and Hack 10;
  gtkhash (GTK 3) changed from Arizona to Default while it ran (its menu bar
  #499 2a7 = Default's set 6).  zenity on this host is GTK 4 with
  libadwaita, which follows no theme.  Not yet: GTK 3/4 buttons keep
  Adwaita's shape (its selectors win), Java, GNUstep, FLTK, FOX, XView,
  Wine, Firefox's userChrome.
- Zones of the screen and full screen (`programs/dtwm/WmMcdeSnap.c`): every
  monitor below the bar is 3 columns x 2 rows; dragging a window to the top
  or bottom edge shows the zone of that column, the middle of the left or
  right edge a half, the outer parts the corner zones; sliding along the
  edges joins zones; release takes the zone, a later drop elsewhere gives the
  size before back.  The target outline is XOR while dtwm holds the server
  (freezeOnConfig) and four thin windows otherwise -- never FlashOutline.
  f.mcde_snap NAME (left-half, right-half, top, bottom, the six zones,
  left/middle/right columns, restore) and f.mcde_fullscreen; window menu
  "Full Screen", keys Command+Ctrl+F, Command+Ctrl+arrows,
  Command+Ctrl+BackSpace, Command+Tab, Command+M (Command is Mod4, dtkeys;
  all locales and the built-in fallbacks).  GetConfigEvent polled XQueryPointer
  without end when the server was not grabbed, even for opaque moves (177
  CPU ticks in 3 s with a window held still): it polls only to flash an
  outline now (0 ticks).  Tested on Xvfb with XTest drags; such a test needs
  -xrm "Dtwm*freezeOnConfig: False", since XTest waits while the server is
  grabbed.
- The Command key (Konrad: shortcuts by the place of a key): the key left of
  the space bar is Command = Mod4 on every keyboard, the one left of it
  Option = Alt (Mod1, where Motif's mnemonics stay), then Ctrl.
  `programs/dtkeys` (Xlib only, run by Xsession.d/0072.dtkeys) exchanges left
  Alt and left Windows key on a PC keyboard; a Macintosh keyboard is so
  already (mcde_sys_keyboard_is_mac: NetBSD macppc or an Apple USB keyboard
  in usbdevs -v; Linux vendor 05ac with a kbd handler).  ~/.dt/keyboard
  "type: auto|pc|mac"; the root window's _MCDE_KEYS keeps a second run from
  exchanging back; `dtkeys off` undoes it.  Command+C/X/V/A in every Motif
  text field (motif/lib/Xm/Transltns.c, before the self-insert), dtterm
  Command+C/V/T/W/Left/Right (Tabs.c; other Command keys do not reach the
  program; Ctrl+C stays the interrupt), dtwm Command+Tab/M and Command+Ctrl
  for zones and full screen.  Tested on Xvfb: exchange, no second exchange,
  off; dtpad Command+A, Command+C to the clipboard; dtterm paste, new tab,
  tab switch.  The programs' menu shortcuts on letter keys are Command too:
  every app-defaults catalog (programs/localized/*/app-defaults) says
  Mod4<Key>x and shows "Cmd+X" (dtpad Command+F opens Find/Change, tested).
  What a user sees may be translated (MCDE, sysinst); configuration is
  English (Konrad: "konfigurationen und sowas, alles nur englisch"): the
  bindings are Mod4<Key>, Shift<Key>, Ctrl<Key> in every catalog -- the
  translated Strg<Key>, Skift<Key>, MayÇs<Key> Xt never understood are gone
  -- while a German menu shows "Strg+Einfg"; Command is "Cmd" everywhere.  Xvfb starts afresh (keymap and properties gone) when its last
  client leaves: keep one (xprop -root -spy) in such a test.
- Displays (System Settings > Displays, programs/dtsystemsettings/displays.c;
  the monitors themselves in libDtSvc for the pane and dtwm alike:
  `include/Mcde/Displays.h`, the arithmetic without X in
  lib/DtSvc/DtUtil2/McdeDispConf.c with `test_displays` (make check), RandR
  and the file in McdeDisplays.c; libDtSvc links Xrandr): the
  monitors as rectangles to drag, docked to each other; per monitor on/off,
  resolution, rotation, main display; mirror.  RandR 1.3 (libXrandr,
  optional in configure: HAVE_XRANDR), set as xrandr(1) does: changing
  CRTCs off, screen size, CRTCs on.  Apply asks "Keep these display
  settings?" and goes back by itself after 15 s.  Konrad's rules: the main
  display carries top bar and front panel, the others show the same backdrop
  only, workspaces are shared; MCDE remembers a MONITOR (EDID maker, product,
  serial; "output-NAME" without EDID), also while it is unplugged:
  ~/.dt/displays, "display ID on WxH RATE X Y ROTATION [primary]";
  Xsession.d/0071.displays runs `dtsystemsettings -apply-displays` at login.
  Tested on Xorg with the dummy driver (one output, DUMMY0): -apply-displays
  2048x1536 -> 1280x1024, an unknown mode and all-off refused; in the pane
  1024x768 applied and back after 16 s without an answer, kept with Keep
  and written.  Plug and play in dtwm (`programs/dtwm/WmMcdeDisplays.c`,
  Konrad): dtwm selects RandR's output and screen changes.  A monitor
  plugged in is switched on as ~/.dt/displays remembers it, else right of
  the others in its preferred mode (one switched off in System Settings
  stays off); one unplugged is switched off.  On a screen change every
  window keeps its monitor's id and its place on it (ClientData.mcdeMonitor,
  mcdeMonX/Y); a window whose monitor is gone waits on the main display
  (mcdeRescued) and goes back when the monitor returns.  Xinerama's heads
  are read anew (McdeHeadsChanged) and the front panel centres on the main
  display (McdePanelMonitorsChanged).  Tested: dtwm starts with it on
  Xvfb, the check at login changes nothing when nothing was plugged, and it
  keeps running; plugging itself was not measured -- Xvfb cannot change
  its outputs and Xorg's dummy driver needs a console user.  Widgets and
  icons are not yet moved back.
- Focus: Dtwm*keyboardFocusPolicy: pointer and Dtwm*focusAutoRaise: False
  in sys.resources (MCDE's default, Konrad); the Style Manager's Window
  settings change them as in CDE, and so do System Settings: Mouse,
  "Windows" (two switches and Apply, which writes the resources as dtstyle
  does and restarts dtwm with _DtWmRestartNoConfirm).  Keyboard has the kind
  (find out, PC, Macintosh): ~/.dt/keyboard and dtkeys at once.  Tested on
  Xvfb: PC exchanges the keys at the click; Apply put focusAutoRaise True
  into RESOURCE_MANAGER and dtwm ran on.
- `programs/dtwm/WmMcdePanel.c` -- the programs left of the trash in the
  front panel.  A program a control of the main row or of a drawer names is
  in the dock and not shown again.  Kept programs
  (~/.dt/panel-apps: CLASS <tab> COMMAND), then the running ones no main
  panel control names (CLIENT_NAME, or a PUSH_ACTION beginning with the
  class).  Click: raise on its workspace, or start a kept one (F_Exec).
  Right button: Keep in Panel / Remove from Panel -- posted from CDE's
  PostPopupMenu (PopupMenu.c), whose post-from grab on the control form
  takes the button before any child; dragging left with button 1 keeps
  too.  The command: WM_COMMAND, else _NET_WM_PID and
  mcde_sys_process_command, else the class in lower case.  Every MCDE
  program sets both on its top-level windows when they are first mapped
  (`lib/DtSvc/DtUtil2/McdeWmHints.c`, called from
  _DtMcdeGlobalMenuInitialize, which DtInitialize and dtterm both reach;
  WM_COMMAND only where Xt has not set it, from the application shell's
  XtNargv).  The buttons are
  CDE's _DtCreateControl gadgets: their events come to the part (an
  XtAddEventHandler on a gadget crashed).  A blank of the same width in the
  arrow row keeps the drawers' arrows over their controls.  Colours and
  pattern are taken from the panel row, so the part follows the palette
  (measured with Default and Arizona in a dtsession).  In a session the
  panel's shell did not grow by itself and the form squeezed the part to a
  pixel: Grow widens the shell by the difference and sets the part's width
  again.  Updated 200 ms after ManageWindow / UnManageWindow.
- `programs/dtwm/WmSlideshow.c` -- backdrops from picture files and the
  slideshow of a folder.  "f.change_backdrop PATH 0 STYLE": pixmap 0 makes
  dtwm load the file itself (XmGetPixmap: XPM, XBM, PNG, JPEG); the request
  is read from the end, so a path may hold blanks.  "f.mcde_slideshow
  INTERVAL RANDOM STYLE FOLDER" (minutes, 0 = off) and, at the start, the
  resource Dtwm*mcdeSlideshow in the same form; every workspace of the
  screen changes together.  Scaled backdrops (Fit, Fill) use Xrender's
  bilinear filter.  Pictures are loaded with McdeImageGetPixmap
  (`include/Mcde/Image.h`, `lib/DtSvc/DtUtil2/McdeImage.c`): PNG through
  libpng, the rest through XmGetPixmap -- Motif 2.3.8 draws an RGB PNG
  without alpha as its blue channel only (docs/reference/motif-png.txt in
  the Makronix tree).  Give such pixmaps back with McdeImageFreePixmap.
- Backup (`lib/McdeSys/backup.c`, `programs/dtbackup`): BorgBackup to a
  partition of its own -- borg init -e repokey-blake2, create -x of / (and
  /home), prune by settings (keep_hourly/daily/weekly/monthly, -1 = every
  one), compact; the watcher deletes the oldest backups, never the newest,
  while the disk has less than min_free percent free, before and after a
  run.  /etc/mcde-backup.conf, the passphrase in /etc/mcde-backup.pass
  (root, 0600: the hourly run needs nobody; the disk is encrypted against
  whoever takes it, not against this computer's root), the last run in
  /var/db/mcde-backup.state; hourly by a "# MCDE backup" block in root's
  crontab running `dtbackup run` (no X).  docs/reference/borg.txt.
  The pane (`programs/dtsystemsettings/backup.c`): the hourly switch, Choose
  Disk... (partitions not the system's, a password twice, starred), Back
  Up Now (dtbackup in a terminal), Restore... (a path of a backup into
  ~/Restored), the kept counts and the free-space limit.
- `programs/dtdiskutility` -- the disks: drives with their partitions on
  the left; on the right name, model, size, file system, mount point and a
  bar of used and free; First Aid (Verify Disk: fsck -n; Verify and Repair
  Permissions: mcde_sys_permissions against /etc/mtree/set.*) and Erase
  (one partition over a whole drive, FFS, FAT32 or ext4, after a warning
  that names the drive); Mount and Unmount.  Changing needs root; as a user
  Unlock... starts it again under su in a terminal.  Never erase, mount or
  repair anything on the development host or the build VM's disk in a
  test.
- `programs/dtsystemsettings` -- the settings of the computer in one window:
  four bands (Personal, Hardware, Internet & Network, System) of icons
  (`panes.c`, plain C with `test_panes`), a click opens the pane in the
  window, "Show All" goes back, `-pane ID` opens one at once (the bar's
  "... Settings..." items do).  Drawn here through McdeSys: Sound, Network,
  Bluetooth, Date & Time, About, Keyboard, Mouse, Appearance, Fonts,
  Desktop, Screen Saver, Startup; CDE's style manager (Language) and
  printer tool open
  for their panes until those are drawn here.  Accounts (`accounts.c`):
  the people (uid 1000..59999), add, delete, password, administrator, all
  through McdeSys; not as root the pane offers "Unlock...": a terminal where
  `su -m root` asks for the password and starts the pane as root.  Software
  Update (`update.c`): running/available version, new packages, source;
  "Update Now..." runs `dtsystemsettings -apply-update` (mcde_sys_update_apply)
  as root in a terminal.
  Keyboard and Mouse (`input.c`): settings of the X server, not of the
  system, so no McdeSys: Xlib (XChangeKeyboardControl, XkbSetAutoRepeatRate,
  XChangePointerControl, XSetPointerMapping) at once, and the properties
  `_DT_SM_KEYBOARD_INFO`/`_DT_SM_POINTER_INFO` on dtsession's window as
  dtstyle sends them, so dtsession saves them at logout.  dtsession saves
  and restores the XKB repeat delay and interval too (`SmSave.c`
  PrintRepeatRate, `SmRestore.c`; resources RepeatDelay, RepeatInterval),
  and keeps every button of the pointer map (`Sm.h` pointerMap[256]; it was
  5 and the save overflowed it with a mouse of more buttons -- Xvfb has 10).
  Appearance and Fonts (`appearance.c`): the palettes (*.dp, where the
  colour server looks) drawn as rows of their colours; a choice merges
  "*0*ColorPalette: NAME.dp" with _DtAddToResource as dtstyle does, and
  takes effect at the next login (TrueColor: the colour server cannot
  change allocated colours).  Fonts sets *mcde.fontName and *mcde.fontSize
  (sys.resources) the same way, for programs started afterwards; the
  families come from Xft.  dtsession saves RESOURCE_MANAGER at logout
  (`SmSave.c`, OutputResource), so both persist.
  Network (`network.c`, docs/reference/netconfig.txt in the Makronix
  tree): "Show:" Network Status (every card, a light, a sentence,
  Configure...) or one card with the tabs TCP/IP (Configure IPv4: Using
  DHCP, Using DHCP with manual address, Manually, Off; address, mask,
  router, DHCP client ID, Renew DHCP Lease; Configure IPv6), DNS (servers,
  search domains; what resolv.conf has now below), Wi-Fi and Ethernet (ID,
  media, MTU); the lock and Apply Now as Accounts has them.  McdeSys
  `mcde_sys_net_config`/`_configure`/`_renew`: NetBSD one block per
  interface in /etc/dhcpcd.conf ("# MCDE network IF begin/end"), as
  ifconfig.if(5) recommends, sysinst's static address in ifconfig.IF read
  and moved there, applied with dhcpcd -n IF; Linux the NetworkManager
  profile of the device (nmcli connection modify/up).  Never apply on the
  development host or in the build VM over its ssh card.
  The Wi-Fi tab lists the networks in reach (`wifi.c`,
  mcde_sys_wifi_scan: NetBSD wpa_cli scan_results, else ifconfig -v IF
  list scan as root; Linux nmcli -t).  "Join..." opens a terminal: su, then
  `dtsystemsettings -join-wifi IF [SSID as hex]`, which asks the network's
  password without echo and calls mcde_sys_wifi_join (NetBSD: a network
  block in /etc/wpa_supplicant.conf, wpa_supplicant and dhcpcd in rc.conf,
  as sysinst does -- docs/reference/wifi.txt; Linux: nmcli device wifi
  connect).  Never test joining on the development host.
  Sharing (`sharing.c`): switches for SSH, SMB, NFS, AFP and AppleTalk and
  one list of shared folders, through McdeSys (`lib/McdeSys/share.c`: the
  list in /etc/mcde-shares and a "# MCDE shares begin/end" block in
  exports, smb.conf and afp.conf; the backends switch rc.conf + rc.d on
  NetBSD -- pkgsrc's example rc.d scripts copied to /etc/rc.d first, NFS is
  rpcbind, mountd, nfsd, nfslocking; mountd needs /etc/exports -- and
  systemctl on Linux).  Root only; Unlock... as in Accounts.
  docs/reference/sharing.txt.  Never switch SSH in the build VM: ssh is the
  way in.
  Startup (`startup.c`): resume or home session and asking before logout
  (_DtSetSmState, SM_STATE_START|SM_STATE_CONFIRM) and "Save These Windows
  as Home Session" (_DT_SM_SAVE_TO_HOME), as dtstyle sends them; and the
  programs opened at login, ~/.dt/login-items, started by
  `programs/dtlogin/config/0095.loginitems` (sessionetc.d, after 5 seconds,
  each through sh in the background).
  Date & Time chooses the time zone (`timezone.c`): regions and places
  from mcde_sys_timezones (zone1970.tab); "Set Time Zone" runs
  mcde_sys_timezone_set as root at once, otherwise
  `dtsystemsettings -set-timezone ZONE` in a terminal after su(1).  The
  link /etc/localtime is made beside the old one and renamed over it.
  Desktop and Screen Saver (`desktop.c`): one pane, two pages.  Desktop:
  a preview of the backdrop in use, the places on the left (CDE's
  backdrops, ~/.dt/backdrops, ~/Pictures, folders in
  ~/.dt/backdrop-folders, "Choose Folder..."), their pictures small on the
  right -- each cell is made when its picture is (an idle work proc), since
  a label's pixmap set later was not drawn -- the style, and "Change
  picture" with interval and random order (dtwm: f.mcde_slideshow, and the
  resource Dtwm*mcdeSlideshow for the next login).  Screen Saver: the
  savers of $DTSCREENSAVERLIST with a running preview (_DtSaverStart), the
  minutes until it starts and the password, to dtsession as dtstyle sends
  them.
  Test a session through logout and login with dtaction ExitSession and
  DTDATABASESEARCHPATH set; a dtsession started without Xsession does not
  get its resources loaded, so the double-click time is not measured that
  way.
- McdeSys users and update: `users.c` (getpwent/getgrnam, useradd/userdel),
  the backends for password and the administrators' group -- NetBSD hashes
  with pw_gensalt(3)/crypt(3) for `usermod -p` and, having no tool to remove
  a group member (usermod -G only appends, measured), rewrites the group's
  line the way user.c does (temporary file, rename); Linux uses chpasswd on
  stdin and gpasswd.  Update: NetBSD reads the source from
  `/etc/makronix/update` (a release directory whose `RELEASE` file has the
  first line of its /etc/release), applies with sysupgrade(8) and
  `pkg_add -uu`; Linux uses apt-get.  Tested as root in the NetBSD build VM:
  add with password, administrator on and off, new password, delete; the
  group file afterwards byte for byte as before.
- `programs/dtterm/Dropdown.c` -- `dtterm -dropdown`: full width, 40 % high,
  override-redirect, hidden until its key (`dropdownKey`, F12), then it slides
  down below the top bar and takes the keyboard; the key sends it up.  The
  key is grabbed on the root window and taken in dtterm's own event dispatcher
  (`XtSetEventDispatcher`): a root window registered with a widget did not
  bring it.  Started by `sessionetc.d/0085.dtdropdown`.  Test with an XTest
  event on the key's own keycode: `xdotool key F12` maps F12 to a spare
  keycode, which the grab never sees (measured).
- `programs/dtterm/Profiles.c` -- terminal profiles (font, colours, command)
  from `~/.dt/dtterm.profiles`, else `config/dtterm.profiles`; the parser is
  plain C with its own test (`test_profiles.c`, `make check`).  A view with a
  profile is named `profile_<name>`: its colours are resources of that name,
  its font an Xft render table handed to the view (TermView passes it on),
  its command `DtNsubprocessArgv`.  Window > New Tab / New Tab with Profile
  come from a hook in `TermViewMenu.c` (`_DtTermViewMenuSetNewTab`);
  `dtterm -profile NAME`; the profile "Default" is the starting one.
- The desktop's sounds (docs/MCDE-PROGRAMS.md A1-A4): `lib/McdeSound`
  (`include/Mcde/Sound.h`) reads a theme -- an X resource file,
  `*Launch.soundfile: launch.wav`, the files beside it -- and sends an
  event as a ClientMessage `_MCDE_SOUND_EVENT` to the owner of the
  selection `_MCDE_SOUND_SERVER`; `programs/mcdesoundd` owns it (one per
  display), drops a repeat within 50 ms and plays through McdeSys
  (`mcde_sys_sound_play`: paplay where a PulseAudio server answers, else
  audioplay(1) on NetBSD and aplay(1) on Linux, started in a grandchild so
  the daemon never waits), the X bell when there is no player.  Started by
  `sessionetc.d/0075.mcdesoundd`.  dtfile plays OpenFolder (FileMgr.c,
  once per folder), dtterm's bell TerminalBell (libDtTerm, which links
  libMcdeSound), dtwm DeskSwitch; System Settings, Sound lists and plays
  the events and switches the theme.  Themes: Camouflage and Base in
  `programs/mcdesoundd/themes`, 16-bit mono 44.1 kHz WAV tones made for
  MCDE on 2026-11-12 (no file from elsewhere); the program that made them
  was not kept -- a new sound comes with what makes it.
- `programs/dtphoto` -- the raster editor (docs/MCDE-PROGRAMS.md C1): menu
  bar, toolbox and status line with a 2.5 / 3.0 switch; BMP open and save,
  one-step undo, four zoom steps, marquee, fill, crop and the painting
  tools.  The menus are data, `share/dtphoto/dtphoto.menu` (a line ending
  in "@2.5" or "@3.0" is read only there; "sub NAME" ... "endsub").
- `programs/dtpaint` -- the simple paint program (C4): toolbox, colour box,
  canvas; pencil, brush, eraser, fill, pick colour, line, rectangle,
  ellipse, rounded rectangle, undo, invert, flip, BMP.  Select, text,
  curve, polygon, airbrush and zoom are drawn but do nothing yet.
- `programs/dttoolbox` -- the toolchest (B1-B5): a window of menus from a
  chestrc (`$DTTB_CHESTRC`, `~/.chestrc`, else `share/toolchest/
  system.chestrc`): "Menu NAME [dynamic] {", f.menu, f.exec,
  f.checkexec.sh, f.separator; include lines are skipped.  Dynamic menus
  come from a property `_SGI_MENU_<name>` on the window the root's
  `_SGI__MENU_WINDOW` names, read when it changes and every 500 ms.

## Building it

- On the Linux build host, for development: `make mcde-linux` in the Makronix
  root (`tools/mcde-linux.sh`; `MCDE_DIRS=programs/dtfile` for one directory,
  `MCDE_DIRS=install` to install into `build/mcde-root/dt`).
- For Makronix and any pkgsrc platform: the recipe in `pkgsrc/`.
- The C dialect is set by `configure.ac` itself (`-std=gnu11` and five GCC 14
  downgrades, also handed to the ksh93 build of dtksh as
  `MCDE_DIALECT_CFLAGS`): no build system needs to know about it.

## What may be changed, and how

- Anything; it is ours.  Keep the licence headers (LGPL, `COPYING`): the
  "CDE - Common Desktop Environment" lines at the top of the files are
  attribution, not branding, and stay.
- Branding is what a user sees: names in dialogs, the version string
  (`DtVERSION_STRING`, "MCDE x.y.z (CDE 2.5.3)"), logos.  `DtVERSION`,
  `DtREVISION`, `DtUPDATE_LEVEL` stay at 2.5.3: they are the API level programs
  test against.
- Not yet: the install prefix (`${PREFIX}/dt`) and the tarname `cde` (from it
  come `share/cde` and `etc/cde`); they move together, with the PLIST, in one
  step.
- After a change: commit, then `tools/mcde-dist.sh` (archive and distinfo from
  that commit), then build with pkgsrc.  The archive is made from commits only.
