Files
chandra/compositor/host/showdesktop.mbt
T
VandClaude Opus 5.5 af774d76fe
CI / test (push) Failing after 16s
Rename the project to Chandra
moon-plasma / moonplasma / MoonPlasma / Moon Plasma become chandra / Chandra
everywhere: the WIT package (chandra:desktop, chandra:host, chandra:wm), the
MoonBit module (chandra/desktop) and generated bindings, the Rust host,
identifiers (ChandraCompositor), the session script (chandra-session) and
desktop entry (chandra.desktop), config and data paths
($XDG_CONFIG_HOME/chandra, share/chandra/modules), env vars (CHANDRA_*),
UI strings, docs and tests. The test fixture components are rebuilt against
the renamed WIT.

Saved panel.edn and state.edn are still read from the old
$XDG_CONFIG_HOME/moon-plasma until the first save writes the new copy.

The remote repository keeps its experiments/moon-plasma name for now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hi3L9oVBoRd373Qr4n
2026-11-25 17:12:57 +00:00

98 lines
2.6 KiB
MoonBit

///| Super+D: show the desktop.
///
/// Minimizes every visible window of the active workspace and remembers them; Super+D again
/// (while nothing is on screen) brings them back in their old stacking order with the one that
/// was on top focused. Opening or restoring a window in between starts over: the next Super+D
/// clears the screen again. Neither the D press nor its release reaches a client.
///|
/// evdev codes.
let key_d : UInt32 = 32
///|
let key_lsuper : UInt32 = 125
///|
let key_rsuper : UInt32 = 126
///|
/// Handle a key for Super+D. Returns true when the key is consumed (not for clients).
fn ChandraCompositor::show_desktop_key(
self : ChandraCompositor,
code : UInt32,
pressed : Bool,
) -> Bool {
if code == key_lsuper || code == key_rsuper {
self.super_down = pressed
return false // the Super tap (launcher) is handled by the caller
}
if code != key_d {
return false
}
if !pressed {
// The release of a D we swallowed must not reach a client either.
let swallowed = self.d_swallowed
self.d_swallowed = false
return swallowed
}
if !self.super_down || self.shell.inspecting() {
return false
}
self.d_swallowed = true
self.toggle_show_desktop()
true
}
///|
/// Minimize all visible windows of the active workspace, or restore the ones Super+D hid.
pub fn ChandraCompositor::toggle_show_desktop(
self : ChandraCompositor,
) -> Unit {
let visible = self.wm.stacking_order()
if visible.length() == 0 {
// Nothing on screen: bring back what we hid (bottom to top, so the old top ends up on top).
let hidden = self.desktop_hidden
self.desktop_hidden = []
let mut top : UInt64? = None
for wid in hidden {
match self.wm.windows.get(wid) {
Some(r) =>
if r.minimized {
self.apply_actions(
self.wm.handle_request(
wid,
@wm.WindowRequest::Minimize(false),
self.work_area,
),
)
top = Some(wid)
}
None => ()
}
}
match top {
Some(wid) => self.activate_window(wid)
None => ()
}
} else {
for wid in visible {
self.apply_actions(
self.wm.handle_request(
wid,
@wm.WindowRequest::Minimize(true),
self.work_area,
),
)
}
self.desktop_hidden = visible
self.set_kbd_focus(None)
}
self.damage.mark_full()
}
///|
/// True while Super+D has windows hidden that another Super+D would bring back.
pub fn ChandraCompositor::desktop_shown(self : ChandraCompositor) -> Bool {
self.desktop_hidden.length() > 0 && self.wm.stacking_order().length() == 0
}