CI / test (push) Successful in 1m35s
Opening the launcher (Super tap or its panel button) now also shows every window of the workspace scaled down beside it, over the dimmed wallpaper, like GNOME's Activities overview: a natural layout (rows, one scale, aspect ratios kept, never enlarged), minimized windows dimmed, windows gliding in and out over 220 ms. Hover lights a window and shows a close button; click brings it forward and closes the overview and launcher; middle-click closes the window; Escape or a click on empty space closes it. Typing in the launcher's search fades the windows whose title and app id don't match. - compositor/host/overview.mbt: layout, area beside the launcher, hit testing, easing, input and draw ops; previews reuse the Alt+Tab thumbnails (10 fps refresh, nothing redrawn once settled). - New shortcut "overview" (Super+W) in the shortcut table, rebindable in Settings > Shortcuts. - chandra-ctl / control socket: "shortcut ID" runs any shortcut by id. - Both renderers keep only one large scaled copy per image (a gliding preview is drawn at a new size every frame) and draw images up to 4096 px. - Tests: layout packing and aspect ratio, balance, hit testing, animation, Super tap + click, Super+W + Escape/empty click, search filter, middle click, inspector, control command; screenshots of 1/4/9 windows in dark and light. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hgo3PfGPY8wwv21ZZS
154 lines
5.8 KiB
MoonBit
154 lines
5.8 KiB
MoonBit
///| Keyboard shortcuts: the compositor's end of the shortcut table (compositor/shell/shortcuts.mbt).
|
|
///
|
|
/// Every key press that isn't a modifier is looked up as a combo (the held modifiers plus the key)
|
|
/// and, when a shortcut has it, runs that shortcut's action instead of reaching a client; its
|
|
/// release is swallowed too. A Super tap (Super pressed and let go alone) runs the shortcut bound to
|
|
/// "Super", the launcher by default. Window switching is driven from switcher.mbt, which reads its
|
|
/// combo from the same table. While the settings module's Shortcuts tab waits for a new combo
|
|
/// (`shell.shortcut_capturing()`), the next combo pressed is taken for it here and does nothing else.
|
|
|
|
///| The modifiers held now, as combo bits. The Super and Alt keys are tracked from their own key
|
|
/// events as well, as the nested host doesn't always report them in the modifier mask.
|
|
pub fn ChandraCompositor::held_mods(self : ChandraCompositor) -> UInt {
|
|
let mut m = self.mods & @shell.combo_mods
|
|
if self.super_down {
|
|
m = m | @shell.mod_logo
|
|
}
|
|
if self.alt_down {
|
|
m = m | @shell.mod_alt
|
|
}
|
|
m
|
|
}
|
|
|
|
///| Keep track of the Super and Alt keys (for combos and the Super tap).
|
|
fn ChandraCompositor::track_modifier_key(self : ChandraCompositor, code : UInt, pressed : Bool) -> Unit {
|
|
if code == key_lsuper || code == key_rsuper {
|
|
self.super_down = pressed
|
|
} else if code == key_lalt || code == key_ralt {
|
|
self.alt_down = pressed
|
|
}
|
|
}
|
|
|
|
///| While the Shortcuts tab waits for a combo: take the next one for it. Escape cancels, Backspace
|
|
/// unbinds; a Super tap binds "Super". True when the key was used (it goes nowhere else).
|
|
fn ChandraCompositor::capture_key(self : ChandraCompositor, code : UInt, pressed : Bool) -> Bool {
|
|
let shell = self.shell
|
|
if shell.shortcut_capturing() < 0 {
|
|
// The release of a key the capture took.
|
|
if !pressed && self.capture_swallow.contains(code) {
|
|
self.capture_swallow.retain(c => c != code)
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
self.super_solo = false
|
|
if code == key_lsuper || code == key_rsuper {
|
|
if pressed {
|
|
self.capture_super = true
|
|
} else if self.capture_super {
|
|
self.capture_super = false
|
|
ignore(shell.finish_shortcut_capture(Some({ mods: 0U, key: @shell.key_super })))
|
|
}
|
|
return true // Super never reaches clients
|
|
}
|
|
if @shell.is_modifier_key(code) {
|
|
return false // other modifiers pass, so clients keep their state right
|
|
}
|
|
self.capture_super = false
|
|
if !pressed {
|
|
return true
|
|
}
|
|
self.capture_swallow.push(code)
|
|
let mods = self.held_mods()
|
|
if mods == 0U && code == key_esc {
|
|
shell.cancel_shortcut_capture()
|
|
} else if mods == 0U && code == key_backspace {
|
|
ignore(shell.finish_shortcut_capture(None))
|
|
} else {
|
|
ignore(shell.finish_shortcut_capture(Some({ mods, key: code })))
|
|
}
|
|
self.damage.mark_full()
|
|
true
|
|
}
|
|
|
|
///| A key for the shortcut table: runs the action bound to the combo it makes with the held
|
|
/// modifiers. True when the key was used (neither it nor its release reaches a client).
|
|
fn ChandraCompositor::shortcut_key(self : ChandraCompositor, code : UInt, pressed : Bool) -> Bool {
|
|
if !pressed {
|
|
if self.sc_swallow.contains(code) {
|
|
self.sc_swallow.retain(c => c != code)
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
if @shell.is_modifier_key(code) || self.shell.inspecting() {
|
|
return false
|
|
}
|
|
let combo : @shell.KeyCombo = { mods: self.held_mods(), key: code }
|
|
match self.shell.shortcuts.lookup(combo) {
|
|
// Window switching is the switcher's (switcher_key runs before this).
|
|
Some(SwitchWindows) => false
|
|
// Super+2 .. Super+9 aren't in the table: they follow the "Open dock app" combo.
|
|
None | Some(DockApps) =>
|
|
match self.shell.shortcuts.dock_app(combo) {
|
|
Some(n) if self.open_dock_app(n) => {
|
|
self.sc_swallow.push(code)
|
|
self.super_solo = false
|
|
true
|
|
}
|
|
Some(_) => false
|
|
None => false
|
|
}
|
|
Some(action) => {
|
|
self.sc_swallow.push(code)
|
|
self.run_shortcut(action)
|
|
true
|
|
}
|
|
}
|
|
}
|
|
|
|
///| A Super tap: the shortcut bound to "Super" (the launcher by default), if any.
|
|
fn ChandraCompositor::super_tap(self : ChandraCompositor) -> Unit {
|
|
match self.shell.shortcuts.lookup({ mods: 0U, key: @shell.key_super }) {
|
|
None | Some(SwitchWindows) => ()
|
|
Some(action) => self.run_shortcut(action)
|
|
}
|
|
}
|
|
|
|
///| Do what a shortcut stands for.
|
|
pub fn ChandraCompositor::run_shortcut(self : ChandraCompositor, action : @shell.ShortcutAction) -> Unit {
|
|
self.super_solo = false
|
|
match action {
|
|
Launcher =>
|
|
if !self.shell.inspecting() {
|
|
self.shell.toggle_launcher()
|
|
self.overview_sync() // the overview opens (or closes) with it
|
|
}
|
|
ShowDesktop => self.toggle_show_desktop()
|
|
Overview => if !self.shell.inspecting() { self.toggle_overview() }
|
|
SwitchWindows => ()
|
|
ShotRegion => self.take_screenshot(ShotMode::Region)
|
|
ShotFull => self.take_screenshot(ShotMode::FullScreen)
|
|
ShotActiveWindow => self.take_screenshot(ShotMode::ActiveWindow)
|
|
ShotWindowUnderCursor => self.take_screenshot(ShotMode::WindowUnderCursor)
|
|
RecordRegion => self.toggle_recording(ShotMode::Region)
|
|
RecordScreen => self.toggle_recording(ShotMode::FullScreen)
|
|
RecordWindow => self.toggle_recording(ShotMode::WindowUnderCursor)
|
|
DockApps => ignore(self.open_dock_app(1))
|
|
}
|
|
}
|
|
|
|
///| Super+`n`: the dock's `n`-th app, as if its icon were clicked. False when there is no dock
|
|
/// or no such app (the key then goes to the focused window as usual).
|
|
fn ChandraCompositor::open_dock_app(self : ChandraCompositor, n : Int) -> Bool {
|
|
if self.shell.inspecting() || !self.shell.open_dock_item(n) {
|
|
return false
|
|
}
|
|
self.run_shell_actions()
|
|
self.damage.mark_full()
|
|
true
|
|
}
|
|
|
|
///| evdev code of Backspace (unbinds while capturing).
|
|
let key_backspace : UInt = 14
|