Files
mcde/AGENTS.md
T
lotherkandClaude Opus 5.5 dffeaf9b17 mcde: Wi-Fi in System Settings: the networks in reach, joining one
McdeSys implements mcde_sys_wifi_scan and mcde_sys_wifi_join.  NetBSD
does what sysinst does (src/usr.sbin/sysinst/net.c): a network block in
/etc/wpa_supplicant.conf -- a new file gets the example's ctrl_interface
for the wheel group, so wpa_cli answers users -- and wpa_supplicant,
wpa_supplicant_flags and dhcpcd in rc.conf, each line replaced or added;
then both are restarted.  Scanning asks wpa_cli scan_results, else
ifconfig -v IF list scan (root).  Linux uses nmcli.  The sources are in
docs/reference/wifi.txt.

The Network pane lists the networks of the first Wi-Fi card with signal
and lock, scanned once the pane is drawn.  Join... opens a terminal where
su asks for the administrator's password and dtsystemsettings -join-wifi
IF SSID-HEX asks for the network's password without echo: the name goes
as hexadecimal, the password on no command line of MCDE's (nmcli takes it
on its own on Linux; said in linux.c).

Measured on the Linux host: test_sysinfo finds 5 networks on wlp0s20f3
(read only); the pane lists them on Xvfb; -join-wifi as a user refuses
with "Only the administrator can join" and refuses a bad name.  Not
measured: joining (never on this host), NetBSD scanning and joining
(no Wi-Fi in the build VM).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 08:37:38 +00:00

14 KiB

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).
  • 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/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 Motif patch: an Xt create hook finds its XmMenuBar, the bar hides it and shows its tree, a click calls the button's own callback. 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.
  • 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.
  • 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; CDE's style manager 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 "0ColorPalette: 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 lists the Wi-Fi 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. 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 DtwmmcdeSlideshow 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 Xsession.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.

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.