CDE's application manager shows a fixed list, installed or not. dtappscan reads the desktop entries of the installed packages (Desktop Entry Specification 1.5) and a table of the desktop's own programs, keeps what is on the PATH, and writes CDE actions, icons (PNG to XPM) and one folder per category in ~/.dt/Applications, at every login before the session loads its actions. The file manager has Applications among its places, and the application manager opens the same folder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
23 KiB
23 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)
- 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.
- C99 and POSIX (POSIX.1-2008, XSI where CDE already needs it). New code
compiles with
-std=c99 -D_POSIX_C_SOURCE=200809Land nothing beyond what POSIX and the X/Motif libraries give. MCDE runs on NetBSD and on Linux and builds through pkgsrc on both. - 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 ininclude/Mcde/McdeSys.h. A program (the System Preferences, dtlogin's helpers, ...) never callsuseradd,ifconfig,wpa_supplicant,/etc/rc.conforsystemctlitself, and never has an#ifdef __NetBSD__. Each system has one backend inlib/McdeSys/<system>.c(netbsd.cfirst,linux.cnext); a backend uses the system's own tools the documented way. - Installed with pkgsrc, in conflict with CDE.
pkgsrc/MakefilecarriesCONFLICTS+= 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/cdefolded in. pkgsrc/-- the recipe (mcde-0.1.0). The distfile anddistinfocome fromtools/mcde-dist.shof the Makronix tree (git archiveof 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 theNETBSDconditional),mcde_sys_infoandmcde_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 intoFileMgr.cat four places marked "MCDE"; the search intoFilterFiles(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.ccompared 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 inDtTermMain.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 isinclude/Mcde/GlobalMenu.h(a selection, properties, client messages); the program side islib/DtSvc/DtUtil2/McdeGlobalMenu.c, started byDtInitialize, 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 isMcdeMenuModel.cwith 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_MENUkeeps a program's menu bar in its window,MCDE_GLOBAL_MENU_DEBUGlogs what the program side does. The M menu: About This Computer (about.c: logo, system, version, processor, memory, startup disk, More Info -- frommcde_sys_info), Software Update (not yet), System Settings, Favourites (~/.dt/favourites) and Recent Items (~/.dt/recent;items.cwithtest_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.cgives 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.txtin 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 (McdeExcludeBarinprograms/dtwm/WmMultiHead.c); a full-screen window covers it.- "Always on Top" (dtwm,
programs/dtwm/WmFunction.c):ClientData.mcdeAboveper window, set byf.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 onepSD->topClientand 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_STATEclient 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/dtremoteloginin 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 oftypes/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 (Centerin 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) inprograms/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// (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 -vlists 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 (IsNetworkDirin Navigation.c); shares are mounted below it. 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 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 runningdtbackup 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 withtest_panes), a click opens the pane in the window, "Show All" goes back,-pane IDopens 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 wheresu -m rootasks for the password and starts the pane as root. Software Update (update.c): running/available version, new packages, source; "Update Now..." runsdtsystemsettings -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_INFOon 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.cPrintRepeatRate,SmRestore.c; resources RepeatDelay, RepeatInterval), and keeps every button of the pointer map (Sm.hpointerMap[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, thendtsystemsettings -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 byprograms/dtlogin/config/0095.loginitems(Xsession.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, otherwisedtsystemsettings -set-timezone ZONEin 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) forusermod -pand, 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 whoseRELEASEfile has the first line of its /etc/release), applies with sysupgrade(8) andpkg_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 byXsession.d/0085.dtdropdown. Test with an XTest event on the key's own keycode:xdotool key F12maps F12 to a spare keycode, which the grab never sees (measured).programs/dtterm/Profiles.c-- terminal profiles (font, colours, command) from~/.dt/dtterm.profiles, elseconfig/dtterm.profiles; the parser is plain C with its own test (test_profiles.c,make check). A view with a profile is namedprofile_<name>: its colours are resources of that name, its font an Xft render table handed to the view (TermView passes it on), its commandDtNsubprocessArgv. Window > New Tab / New Tab with Profile come from a hook inTermViewMenu.c(_DtTermViewMenuSetNewTab);dtterm -profile NAME; the profile "Default" is the starting one.
Building it
- On the Linux build host, for development:
make mcde-linuxin the Makronix root (tools/mcde-linux.sh;MCDE_DIRS=programs/dtfilefor one directory,MCDE_DIRS=installto install intobuild/mcde-root/dt). - For Makronix and any pkgsrc platform: the recipe in
pkgsrc/. - The C dialect is set by
configure.acitself (-std=gnu11and five GCC 14 downgrades, also handed to the ksh93 build of dtksh asMCDE_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_LEVELstay at 2.5.3: they are the API level programs test against. - Not yet: the install prefix (
${PREFIX}/dt) and the tarnamecde(from it comeshare/cdeandetc/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.