Files
hypr-xp/docs/xp-start-menu-research.md

18 KiB
Raw Permalink Blame History

Windows XP Start Menu for Hyprland (Ubuntu 26.04 LTS) — Architecture & Implementation Blueprint

1. Executive Summary

The cleanest, most pixel-accurate way to build a two-column Windows XP Start Menu for Hyprland on Ubuntu 26.04 LTS is a resident Python 3 + PyGObject (Gtk 3.0 + GtkLayerShell 0.1) daemon that reuses the exact GTK3 widget hierarchy and CSS classes already compiled into all 9 installed xfce-winxp-tc themes under /usr/local/share/themes/<theme>/gtk-3.0/gtk.css.

  • Zero new system dependencies: Gtk 3.0, GtkLayerShell 0.10.0, Gio/GioUnix, and GdkPixbuf are already installed and verified working (is_supported: True on Wayland).
  • Zero duplicated theme artwork: By using .csd, .wintc-personal-menu, .start-userpane, .start-vuserpane, .start-columns, .start-programs-column, .start-places-column, .start-logoffpane, and .start-all-programs, the menu automatically inherits all 9 themes' PNG border-images, gradients, fonts, and colors.
  • Wayland-native UX: Replaces fragile X11-style cascading Gtk.Menu popups with an in-place Gtk.Stack left-pane switch (Pinned/MFU ↔ All Programs ↔ Live Search), paired with a transparent GtkLayerShell backdrop layer + Hyprland socket2 IPC for reliable click-outside dismissal.

2. Upstream xfce-winxp-tc Start Menu Analysis

Inspected files:

  • /home/carsten/.local/src/xfce-winxp-tc/shell/taskband/src/res/personal-menu.ui
  • /home/carsten/.local/src/xfce-winxp-tc/shell/taskband/src/res/start-menu.css
  • /home/carsten/.local/src/xfce-winxp-tc/shell/taskband/src/start/personal.c
  • /home/carsten/.local/src/xfce-winxp-tc/shell/taskband/src/start/progmenu.c
  • /home/carsten/.local/src/xfce-winxp-tc/themes/build-common/gtk-3.0-base/styling/start-menu.scss
  • /home/carsten/.local/src/xfce-winxp-tc/themes/build-common/gtk-3.0-base/override/wintc-start-menu.scss
  • Compiled /usr/local/share/themes/*/gtk-3.0/gtk.css (all 9 installed themes)

2.1 Upstream Widget Hierarchy & CSS Classes

From personal-menu.ui, personal.c, and start-menu.css, the exact GTK3 widget tree is:

GtkWindow (.csd .wintc-personal-menu)
└── GtkBox (vertical, #main-box)
    ├── GtkBox (.start-userpane, horizontal)
    │   ├── GtkBox (vertical — avatar container styled dynamically with userpic CSS)
    │   │   └── GtkEventBox (#eventbox-userpic)
    │   └── GtkLabel (#label-username-horz)
    ├── GtkBox (.start-columns, horizontal, expand=True)
    │   ├── GtkBox (.start-vuserpane, vertical — used ONLY by Professional theme)
    │   │   └── GtkLabel (#label-username-vert, angle=90, pack-type=end)
    │   ├── GtkBox (.start-programs-column, vertical, expand=True)
    │   │   └── GtkMenuBar (pack-direction=ttb)
    │   │       ├── GtkMenuItem (.start-default-item) [Pinned apps: bold name + gray subtitle]
    │   │       ├── GtkSeparatorMenuItem
    │   │       ├── GtkMenuItem [MFU / Recent apps]
    │   │       ├── GtkSeparatorMenuItem (valign=end, vexpand=True)
    │   │       └── GtkMenuItem (.start-all-programs)
    │   │           └── GtkBox (horizontal, halign=center)
    │   │               ├── GtkLabel ("All Programs")
    │   │               └── GtkBox (.arrow)
    │   └── GtkBox (.start-places-column, vertical)
    │       └── GtkMenuBar (pack-direction=ttb)
    │           ├── GtkMenuItem (.significant) [Bold Places: Documents, Pictures, Music, Computer]
    │           ├── GtkSeparatorMenuItem
    │           ├── GtkMenuItem [Control Panel, Theme Switcher, Display Settings, ...]
    │           ├── GtkSeparatorMenuItem
    │           └── GtkMenuItem [Run...]
    └── GtkBox (.start-logoffpane, horizontal)
        ├── GtkButton (#button-shutdown, pack-type=end)
        │   └── GtkBox (horizontal)
        │       ├── GtkBox (.shutdown-icon)
        │       └── GtkLabel ("Turn Off Computer")
        └── GtkButton (#button-logoff, pack-type=end)
            └── GtkBox (horizontal)
                ├── GtkBox (.logoff-icon)
                └── GtkLabel ("Log Off")

2.2 Compiled Theme Assets & Cross-Theme Differences (All 9 Themes)

Every theme in /usr/local/share/themes/<theme>/gtk-3.0/gtk.css already compiles ~37 .start-* rules referencing ../Resources/*.png:

  • Luna (Blue, Olive Green, Silver), Royale, Royale Noir, Zune style, Embedded style:

    • window.csd.wintc-personal-menu: background-color: rgba(0,0,0,0); border-style: none; (relies on PNG border-images on child panes for rounded top corners).
    • .start-userpane: start_userpane_body.png (or Silver's linear-gradient) + start_userpane_border.png; avatar frame uses .start-userpane box (user_tile_border.png, 48x48 via start-menu.css).
    • .start-programs-column: start_programs_border.png, white (#fff) in Luna/Silver/Olive, dark (#353F4D, #2F2F2F, #013C6B) in Royale Noir/Zune/Embedded.
    • .start-places-column: start_places_border.png, tinted (#D3E5FA, #F2F1E4, #E3E7EB, #5A606F, #666, #2E75AD).
    • .start-logoffpane: start_logoffpane_body.png + start_logoffpane_border.png, .logoff-icon / .shutdown-icon (24x24) with logoff_button.png / _hover.png and shutdown_button.png / _hover.png.
    • .start-all-programs .arrow: all_programs_arrow.png and all_programs_arrow_hover.png.
    • .start-vuserpane label: collapsed to font-size: 0pt via start-menu.css.
  • Windows Classic style:

    • window.csd.wintc-personal-menu: solid #D4D0C8 with 2px border-image: url("../Resources/popup_menu_border.png").
    • .start-userpane: linear-gradient(90deg, #09066A 0%, #A6CAF0 100%), avatar box hidden (min-height: 0px; min-width: 0px; opacity: 0.0).
    • .start-logoffpane: flat #D4D0C8 background, #0A246A hover highlight.
  • Professional (Windows 2000/NT-inspired vertical banner):

    • .start-userpane: hidden (label { font-size: 0pt }, avatar 0x0, opacity: 0.0).
    • .start-vuserpane: visible on the left (background-color: #5096F8, start_vert_userpane_body.png), vertical 90° label (14pt italic bold white).
    • .start-places-column: includes start_places.png watermark; menubar > menuitem:hover uses text underline instead of a solid fill.

Key takeaway: If we keep both .start-userpane and .start-vuserpane in the widget tree and load the upstream start-menu.css rules (at PRIORITY_APPLICATION - 1, below the GTK theme's PRIORITY_THEME? Wait: GTK PRIORITY_THEME is 200, PRIORITY_APPLICATION is 600, so rules in start-menu.css like .start-vuserpane label { font-size: 0pt } must be loaded at GTK_STYLE_PROVIDER_PRIORITY_USER - 1 or PRIORITY_THEME - 1 (199) so theme overrides in Professional and Windows Classic style win!).


3. Technology Comparison & Local Runtime Verification

3.1 Local Runtime Verification

Tested on this machine (Ubuntu 26.04 LTS / resolute, Hyprland):

  • python3 -c "import gi; gi.require_version('Gtk','3.0'); gi.require_version('GtkLayerShell','0.1'); from gi.repository import Gtk, GtkLayerShell, Gio, GdkPixbuf; print('OK')" → OK
  • GtkLayerShell version: 0.10.0, GtkLayerShell.is_supported() → True
  • Gio.DesktopAppInfo.get_all() → 43 visible .desktop applications (note: GLib 2.86+ emits a PyGIDeprecationWarning for Gio.DesktopAppInfo, recommending GioUnix.DesktopAppInfo with fallback to Gio.DesktopAppInfo).
  • apt-cache policy libgtk-3-dev libgtk-layer-shell-dev: available (3.24.52-0ubuntu1 and 0.10.0-1), not installed and not needed for Python + PyGObject.
  • Waybar v0.15.0 running with Hyprland IPC sockets at $XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket.sock and .socket2.sock.

3.2 Architecture Decisions

Decision Option A Option B (Recommended) Why
Language / Toolkit C/Vala + libgtk-layer-shell-dev Python 3 + PyGObject (Gtk 3.0 + GtkLayerShell 0.1) Zero build step, zero -dev packages, native GioUnix.DesktopAppInfo + Gtk.CssProvider, trivial JSON state/config handling.
Lifecycle On-demand launch per click Resident daemon (--daemon) + SIGUSR1 / Unix socket toggle On-demand cold-starts GTK3 + parses 43 .desktop files + loads theme CSS (~180–300 ms). Resident daemon toggles visibility in <10 ms (~40 MB RSS) and reloads theme on SIGHUP.
Click-outside Dismissal KeyboardMode.EXCLUSIVE + focus-out only Transparent full-screen GtkLayerShell backdrop + Escape + Hyprland socket2 IPC focus-out-event is unreliable across wlr-layer-shell surfaces on Hyprland. A transparent Layer.TOP backdrop window (mapped just before the menu window so the menu stacks above it) catches any outside click reliably; Hyprland socket2 (activewindow>>, workspace>>) catches keyboard window/workspace switches.
All Programs & Search Classic cascading Gtk.Menu popups In-place Gtk.Stack left-pane switch + live keyboard search Cascading Gtk.Menu submenus on Wayland wlr-layer-shell frequently misposition, clip at monitor edges, or break pointer grabs. An in-place Gtk.Stack (pinned ↔ all_programs ↔ search) stays inside the single layer surface, supports scrolling, and enables instant type-to-search.

4. Concrete Blueprint

  • Daemon & CLI toggle: ~/.local/bin/xp-start-menu (single Python script, or module in ~/.local/share/xp-start-menu/)
  • Pinned apps & MFU state: ~/.config/xp-start-menu/pinned.json and ~/.local/state/xp-start-menu/mfu.json
  • Hyprland startup: exec-once = ~/.local/bin/xp-start-menu --daemon
  • Toggle invocation: ~/.local/bin/xp-start-menu --toggle (sends toggle over $XDG_RUNTIME_DIR/xp-start-menu.sock, or SIGUSR1 to PID file).

4.2 Exact GTK3 Widget Tree & CSS Strategy

  1. Window & Transparency:

    • Create Gtk.Window(type=Gtk.WindowType.TOPLEVEL) with set_decorated(False), set_app_paintable(True), and screen.get_rgba_visual() set on the window so window.csd.wintc-personal-menu { background-color: rgba(0,0,0,0); } renders clean rounded top corners on Luna/Royale/Zune/Embedded.
    • Add CSS classes csd and wintc-personal-menu directly to win.get_style_context().
    • Configure GtkLayerShell:
      • init_for_window(win)
      • set_layer(win, GtkLayerShell.Layer.TOP)
      • set_anchor(win, GtkLayerShell.Edge.BOTTOM, True) and set_anchor(win, GtkLayerShell.Edge.LEFT, True)
      • set_margin(win, GtkLayerShell.Edge.BOTTOM, 0) (sits flush above Waybar's 30px exclusive zone) and set_margin(win, GtkLayerShell.Edge.LEFT, 0)
      • set_keyboard_mode(win, GtkLayerShell.KeyboardMode.ON_DEMAND) (allows typing immediately for search without stealing global compositor hotkeys like SUPER).
    • CSS Priority: Load base start-menu.css defaults at Gtk.STYLE_PROVIDER_PRIORITY_THEME - 1 (199) so the active GTK theme (PRIORITY_THEME = 200) overrides .start-vuserpane label (for Professional) and .start-userpane box (for Windows Classic style). Load small app-specific layout fixes (e.g. Gtk.Stack scrollbar/listbox reset, search entry styling) at Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION (600).
  2. Top User Pane (.start-userpane):

    • Avatar (48x48): Check ~/.face → /var/lib/AccountsService/icons/$USER → fallback /home/carsten/.local/src/xfce-winxp-tc/shell/taskband/src/res/userpic.bmp. Apply via Gtk.CssProvider on the parent Gtk.Box of #eventbox-userpic: * { background-image: url('...'); background-size: 100% 100%; }.
    • Username: pwd.getpwuid(os.getuid()).pw_gecos.split(',')[0] or pwd.getpwuid(os.getuid()).pw_name.
  3. Left Column (.start-programs-column, min-width: 182px–220px):

    • Uses a Gtk.Stack (transition_type=SLIDE_LEFT_RIGHT, duration=120) inside .start-programs-column:
      • Page 1 (pinned):
        • Pinned Apps (.start-default-item style: 32x32 luna icon, bold Name + muted GenericName subtitle):
          1. Firefox (firefox.desktop, subtitle Internet)
          2. Ghostty (com.mitchellh.ghostty.desktop, subtitle Command Prompt)
          3. Thunar (thunar.desktop, subtitle File Manager)
          4. Text Editor (org.gnome.TextEditor.desktop)
        • Gtk.Separator (styled to match menubar > separator)
        • Most Frequently Used (MFU) (up to 6 recently/frequently launched .desktop apps from mfu.json, 32x32 icon + single-line name).
        • Expanding spacer + Gtk.Separator + All Programs row (.start-all-programs with .arrow Gtk.Box so all_programs_arrow.png / _hover.png render natively).
      • Page 2 (all_programs):
        • Gtk.ScrolledWindow (vexpand=True, hscrollbar_policy=NEVER, min-content-height=320) containing categorized .desktop entries (16x16 icons) grouped into XP-style collapsible/flat sections (Accessories, Games, Internet, Multimedia, Office, System, Settings, Other).
        • Bottom Gtk.Separator + Back row (reversed arrow/label) returning to pinned.
      • Page 3 (search):
        • Activated automatically when typing any printable character while the menu is open (or via a subtle compact search Gtk.Entry at the top/bottom of the left column). Filters all GioUnix.DesktopAppInfo.get_all() entries by Name, GenericName, Comment, Keywords, and Exec. Return launches the top match; Escape clears search back to pinned (second Escape closes the menu).
  4. Right Column (.start-places-column, min-width: 178px):

    • All items use 24x24 luna icons and Gtk.MenuItem inside Gtk.MenuBar (pack-direction=ttb) so .start-places-column menubar > menuitem and .significant rules apply verbatim:
      • Bold (.significant):
        • My Documents (folder-documents) → thunar ~/Documents
        • My Pictures (folder-pictures) → thunar ~/Pictures
        • My Music (folder-music) → thunar ~/Music
        • My Computer (computer) → thunar computer:///
      • Gtk.SeparatorMenuItem
      • Regular:
        • Control Panel (preferences-other) → nwg-look (or xfce4-settings-manager if installed)
        • Theme Switcher (preferences-desktop-theme) → ~/.local/bin/xp-theme-switch --menu
        • Display Settings (preferences-desktop-display) → nwg-displays
      • Gtk.SeparatorMenuItem
      • Regular:
        • Run... (system-run) → ~/.config/hypr/scripts/xp-run.sh
  5. Bottom Logoff Pane (.start-logoffpane):

    • Right-aligned (pack-type=end) Gtk.Buttons matching personal-menu.ui:
      • Log Off (.logoff-icon + "Log Off") → ~/.config/hypr/scripts/xp-power-menu.sh (or direct hyprctl dispatch exit confirmation)
      • Turn Off Computer (.shutdown-icon + "Turn Off Computer") → ~/.config/hypr/scripts/xp-power-menu.sh

4.3 Waybar Start Button Integration

Currently ~/.config/waybar/config.jsonc defines custom/start with on-click only. To keep #custom-start visually pressed (start_button_press_body.png + start_button_press_border.png) while the Start Menu is open:

  1. Add "return-type": "json", "signal": 8, and "exec": "cat ${XDG_RUNTIME_DIR:-/tmp}/xp-start-menu.waybar 2>/dev/null || echo '{\"text\":\"start\",\"class\":\"closed\"}'" to custom/start in waybar/config.jsonc.
  2. In xp-start-menu daemon, whenever the menu opens or closes, atomically write {"text":"start","class":"open"} (or "closed") to $XDG_RUNTIME_DIR/xp-start-menu.waybar and run pkill -SIGRTMIN+8 waybar.
  3. In waybar/style.css (and xp-theme-switch template), style #custom-start.open identically to #custom-start:active.

5. Edge Cases & Gotchas

  1. Gtk.MenuBar / Gtk.MenuItem Click Handling Without Submenus: Inside GtkLayerShell, Gtk.MenuItem items without submenus fire "activate" on click, except if you attach a button-press-event that returns True without calling activate. Prefer connecting "activate" on Gtk.MenuItems and closing the menu before subprocess.Popen(..., start_new_session=True) so launched apps don't inherit the daemon's process group or layer-shell state.
  2. Backdrop Layer Stacking Order: On Hyprland, two Layer.TOP windows stack in creation/map order. Always show_all() the transparent backdrop window first, then show_all() the Start Menu window (or place the backdrop on Layer.TOP and the menu on Layer.OVERLAY—though TOP+TOP avoids covering Layer.OVERLAY lockscreens/notifications).
  3. Theme Hot-Reload: xp-theme-switch updates org.gnome.desktop.interface gtk-theme and icon-theme via gsettings. The daemon should connect to Gtk.Settings.get_default().connect("notify::gtk-theme-name", ...) (and SIGHUP) to refresh Gtk.IconTheme and re-evaluate Professional / Windows Classic style layout visibility if needed.
  4. Rounded Corners & Hyprland layerrule: In hyprland.conf, add layerrule = noanim, xp-start-menu (if a namespace is set via GtkLayerShell.set_namespace(win, "xp-start-menu")) so Hyprland doesn't apply fade/slide animations that lag behind the instant XP popup feel, and avoid forcing blur on the transparent backdrop layer.
  5. Multi-Monitor Targeting: Call GtkLayerShell.set_monitor(win, gdk_display.get_monitor_at_point(x, y)) using the active monitor from hyprctl -j monitors (focused: true) before show_all(), so pressing Super opens the Start Menu on the currently focused monitor.
  6. Minimum Height / Content Stability: Set a consistent min-height (~380–420px) on .start-columns so switching between Pinned (8–10 items), All Programs, and Search does not cause the menu window's top edge to jump vertically.