9.1 kB 136 lines
7e68a437
⋯
desktop/shell/PANELS.md
download raw history
at main Markdown

c8-shell: app charms, status, quick settings, tray #

Part of the shell's notes (CLAUDE.md beside this file, which has panels.c itself: charms, switcher, the snap pick).

App charms: context.c gives the app in front (Start hidden, MRU head) its own Search and Settings charms when it serves org.cont8nuum.Charms1 at /org/cont8nuum/Charms under a bus name equal to its app_id (documented in c8-protocols). Several copies of an app queue for that name; the shell protocol sends each window's pid, and begin picks the queued owner with that pid (ListQueuedOwners + GetConnectionUnixProcessID, else the first) and calls its unique name. Super+S / the Search charm calls Search("") (400 ms, no auto-start): an answer opens a search pane (a right flyout: box, the app's results, "Search everywhere" to Start's search), an error opens Start's search (start_open_search). Settings calls GetSettings: the app's commands (a c8ui_nav, edge to edge like PC settings' page list) replace Personalise above the quick tiles (panels_open_settings_with(body)); page commands show controls (GetSettingsPage, built from aa{sv}: toggle, choice, buttons, slider, text, button, link, heading, paragraph) behind a back arrow (an app whose only command is one page skips the list: the page opens under the list's "Settings" header, cx.single), action ones call the app and close. SettingsChanged refetches; the same controls are updated in place. panels_close calls context_closed (stale replies drop by serial). Try it with desktop/widgets/build/examples/c8-charms-demo in a nested session; run that under dbus-run-session so it doesn't take the real session's bus names.

Status and quick settings: status.c (shared with c8-lock) watches NetworkManager and UPower on the system bus (reads on a worker thread, debounced; subscribed only to what the icons show: NM's own object, active connections, UPower's object and its DisplayDevice, and the access point in use, watch_ap, heard only when its strength moves a bar: every NM property change used to wake the shell and read it all again throughout each Wi-Fi scan) and draws the network/battery icons (battery all red with a "!" at STATUS_BATTERY_CRITICAL, 15 %, draining; notify.c's first warning), shown left of the charms clock and after the date on the lock screen. quick.c is the Settings flyout's nine tiles, three rows (Network, Volume, Brightness, Notifications: hide for 1/3/8 h via notify_hide_for, critical ones still show; Power menu, topped by the power modes from profiles.c (power-profiles-daemon's org.freedesktop.UPower.PowerProfiles, ActiveProfile set over Properties.Set; shown when it offers more than one); Keyboard opens PC settings; and a row Windows 8 didn't have: Night light and Airplane mode, switches filled with the accent while on (quick_lit), and Second screen, which opens that flyout) plus the level popup (Volume's is a mixer once an app plays sound: rows across the flyout, one per app over the volume's own, each its icon or first letter (a click mutes), its name over its slider and the number; more than fit the height scroll, the wheel off the sliders, l->first. With no app it's the one upright slider, as Brightness. media_apps_get in media.c reads pactl -f json list sink-inputs, an app's streams as one, by name, MEDIA_APPS_MAX 32, so no pactl, no apps; read at the flyout's making and every LEVEL_POLL_MS while open; in XR the rows go over the bar's level, LEVEL_ROWS_MAX in view; what was set in the last LEVEL_HOLD_MS isn't taken back from a poll) and the Networks flyout, which uses network.c (Wi-Fi list from NM, connect with a key through AddAndActivateConnection, a connection that never worked is deleted again, Airplane mode blocks every radio through rfkill.c). media.c has the volume/brightness setters they use. In XR the charms bar holds Switch, Start and Settings (no Search: from the bar it only opened Start's search, behind the bar, and typing on Start does that) and Volume and Brightness (quick_row_new, on_bar in quick.c, each as wide as a charm and touching the charms: 95 px tiles after a 16 px pad read as a stray gap after Settings). Network isn't a button there or a tile in the card: it's the Settings card's Networks page. The other six tiles are a 3x2 grid in the Settings card (quick_tiles_new leaves out the bar's and, while !panels_headed(), Network; each tile exists once and q.tiles stays right). All nine on the bar made it ~1650 px wide plus the tray, which was unusable; it's ~900 now. Everything that opens from the bar is a card above it (show_on_bar, centred, BAR_ABOVE_GAP apart, with the keyboard), rising in (c8ui_widget_enter_up), and wide and low (BAR_CARD_W 880 by BAR_CARD_H 380 at most): cards three quarters of the screen high pushed the bar under the view's bottom. Settings and Networks are one card, a c8ui_pivot of two pages (settings_card, panels.c), each laid out sideways: the app's settings or Start's Personalise (two columns there) beside the six tiles and "Change PC settings"; airplane mode beside the Wi-Fi list (quick_networks_new, made the first time its page shows, since it has NetworkManager scan). The pivot names the pages, so nothing in them has a "Settings" heading of its own (panels_headed, which context.c's title_block/body_padding and panels.c's heading ask). The Settings charm and Super+I open it at Settings and put it away again, whichever page is up (panels_settings_card); the headers, Ctrl+Tab or a swipe turn it. A new Networks page is made before the old one is destroyed, so networks_destroyed only cleans up for the one q.net_page names. Power and Notifications are cards too (panels_show_card, measured: power modes beside a row of buttons; a row of buttons), as are an app's search pane, Second screen and tray menus (show_flyout, the full card size). The level is a card too (open_level with l->row: panels_show_bar_card, LEVEL_CARD_W, as high as level_room, panels_card_height as apps come and go; arrows set it). It used to be an overlay on the bar with room made above it and an idle timer, as the bar had no keyboard; now it closes as every card does: Escape, a press off the bar, looking up (compositor), or opening another one, which replaces it. Closing, a card drops away (bar_above_leave: c8ui_widget_leave_down, the bar surface shrinking C8UI_LEAVE_MS later in above_left; anything shown before then replaces it at once). Tested headless: Settings closed by its charm with the bar pinned (the card fades down, the bar stays put). Switch toggles by p.open, Volume and Brightness by panels_mark/panels_is (enum opener in shell.h; the open key is cleared by anything else showing). The switcher is a row of pictures there too (switch_above; Left/Right step it). A card changing the bar surface's size used to blink the bar: c8ui drew a frame of the new layout at the old size, pushing the bar out; surface.c now suspends a shell surface's drawing from a resizing set_rect until its configure. Tested headless (no IMU, Super+C or Super+I, wlrctl, frames dumped every 500 ms): the bar without Search, the Settings card over an app (its name, no Personalise) and over Start (Personalise in two columns, no scrolling at 380), the Networks header turning it to Networks (the real Wi-Fi list), Super+I closing it, the Power, Notifications and Second screen cards, the bar staying put as a card opens. Earlier: Volume rising without a blink, Brightness replacing it, a press off the bar, Switch's toggle, Alt+Tab with the bar down. Untested: looking up and down with a card open (needs a moving mock head), connecting from the card, an app's own settings in the card, the mixer's rows, the glasses.

Outside XR too, Settings over an app shows no Personalise (that's Start's): Personalise only while Start is up, else a "Settings" heading over the app's name (context_front_title, any app, not only those with a bus name) and "This app has no settings here." (plain_new). Tested headless in 2D over foot.

Tray icons: tray.c owns org.kde.StatusNotifierWatcher (the names are only historical; plain D-Bus, nothing of KDE installed) and so is the one host. Items (bus name + path, Menu, IconName or the best IconPixmap; Passive ones are hidden) refetch on their New* signals and drop when their bus name vanishes. panels.c draws them at the foot of the charms bar, two columns, bottom-aligned (charms_bar, redone on tray_listen; above the clock the pointer couldn't reach them); left click = Activate, right/hold or an ItemIsMenu item = its com.canonical.dbusmenu shown as a c8ui_menu_show_items menu in a flyout (an item without one gets ContextMenu), middle = SecondaryActivate. Activation gives the app no XDG token, so raising its window is up to the app. Not done: IconThemePath, overlay icons, dbusmenu LayoutUpdated (the menu is read when opened). Tested headless: registering an item. Untested: drawing and the menus.