Window frames in the style of V's Flatkit Aurorae theme, the classic frame as a setting
CI / test (push) Canceled after 52s
CI / test (push) Canceled after 52s
The default frame now follows codegod100/kde aurorae (Flatkit / Flatkit Dark): the kit's neutral title bar, a 1px outline with 10px top corners, a hairline under the title, a soft 16px shadow all round, a centred title and 24px flat buttons with hover and pressed fills (close turns red). 38px title bar, 1px border. Maximized: no shadow, square corners. - scene: WindowStyle (frame sizes, button layout, hit test) and build_window_decoration; the shadow is part of the decoration ops, so the three rasterisers lost their own offset shadow and redraw 18px around a changed window. - host: the frame size follows the style (work area, wm title-bar room, CSD client boxes, hit zones, screenshots); title-bar buttons track hover, show pressed, act on release. - Settings > Session > Flat window frames (off: the old Breeze-like frame), saved as :window-style :breeze; an unknown value is logged. - docs/window-frames.md; tests for both styles' pixels, button states and switching. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hmKDDLLES2aBrrnPxT
This commit is contained in:
20 files changed
+1005
-142
No files matched your search
+149
-45
@@ -20,12 +20,27 @@ pub(all) struct HostWindow {
|
||||
mut geo_y : Int
|
||||
}
|
||||
|
||||
///| Height of the server-side title bar above `geometry`, and the frame's side/bottom border:
|
||||
/// the layout in `@scene.build_breeze_decoration` (outer box w + 4, h + 34).
|
||||
let frame_top : Int = 32
|
||||
///| The window style in use (Settings > Session > Flat window frames). Global because the frame's
|
||||
/// size is part of every window's on-screen box (`client_rect`); the compositor sets it from the
|
||||
/// shell's setting (`ChandraCompositor::apply_window_style`).
|
||||
let window_style : Ref[@scene.WindowStyle] = { val: @scene.WindowStyle::Flat }
|
||||
|
||||
///|
|
||||
let frame_side : Int = 2
|
||||
///| Height of the server-side frame above `geometry` (title bar, outline, hairline) ...
|
||||
fn frame_top() -> Int {
|
||||
window_style.val.frame_top()
|
||||
}
|
||||
|
||||
///| ... and its border left, right and below.
|
||||
fn frame_side() -> Int {
|
||||
window_style.val.frame_side()
|
||||
}
|
||||
|
||||
///| The frame's outer box around a server-decorated window's `geometry`.
|
||||
fn frame_rect(g : @scene.Rect) -> @scene.Rect {
|
||||
let t = frame_top()
|
||||
let s = frame_side()
|
||||
@scene.Rect::new(g.x - s, g.y - t, g.w + 2 * s, g.h + t + s)
|
||||
}
|
||||
|
||||
///| The box the client's own window fills on screen. A server-decorated window's is its
|
||||
/// geometry (Chandra's frame goes around it); a client-decorated one takes the frame's whole
|
||||
@@ -33,7 +48,7 @@ let frame_side : Int = 2
|
||||
pub fn HostWindow::client_rect(self : HostWindow) -> @scene.Rect {
|
||||
let g = self.geometry
|
||||
if self.csd && !self.fullscreen {
|
||||
@scene.Rect::new(g.x - frame_side, g.y - frame_top, g.w + 2 * frame_side, g.h + frame_top + frame_side)
|
||||
frame_rect(g)
|
||||
} else {
|
||||
g
|
||||
}
|
||||
@@ -207,6 +222,10 @@ pub(all) struct ChandraCompositor {
|
||||
mut mods_latched : UInt
|
||||
mut mods_locked : UInt
|
||||
mut mods_group : UInt
|
||||
/// The title-bar button under the pointer and the one held down: (window, button), button
|
||||
/// 1 minimize, 2 maximize, 3 close. A press shows pressed; the release over it acts.
|
||||
mut deco_hover : (UInt64, Int)?
|
||||
mut deco_pressed : (UInt64, Int)?
|
||||
}
|
||||
|
||||
///|
|
||||
@@ -221,11 +240,14 @@ pub fn ChandraCompositor::new(
|
||||
Some(s) => s
|
||||
None => return None
|
||||
}
|
||||
// A new compositor starts in the default style; the shell's setting is applied from the
|
||||
// first frame on (`sync_window_style`).
|
||||
window_style.val = @scene.WindowStyle::Flat
|
||||
let wm = @wm.WmState::new(
|
||||
inner_gap=8,
|
||||
outer_gap=8,
|
||||
titlebar_h=32,
|
||||
border_w=2,
|
||||
titlebar_h=frame_top(),
|
||||
border_w=frame_side(),
|
||||
)
|
||||
let work_area = work_area_for(output_w, output_h, theme)
|
||||
let shell = @shell.DesktopShell::new(socket_path)
|
||||
@@ -249,6 +271,8 @@ pub fn ChandraCompositor::new(
|
||||
mods_latched: 0U,
|
||||
mods_locked: 0U,
|
||||
mods_group: 0U,
|
||||
deco_hover: None,
|
||||
deco_pressed: None,
|
||||
settings_portal: None,
|
||||
control: None,
|
||||
login_session: false,
|
||||
@@ -333,7 +357,7 @@ fn work_area_for(w : Int, h : Int, theme : @scene.ThemeTokens, kiosk~ : Bool = f
|
||||
}
|
||||
@wm.compute_work_area(
|
||||
{ x: 0, y: 0, w, h },
|
||||
excl_top=32, // room for the server-side title bar drawn above each client
|
||||
excl_top=frame_top(), // room for the server-side title bar drawn above each client
|
||||
excl_bottom=theme.panel_height,
|
||||
)
|
||||
}
|
||||
@@ -584,7 +608,7 @@ pub fn ChandraCompositor::step(self : ChandraCompositor) -> Unit {
|
||||
(Some(r), Some(win)) =>
|
||||
if r.is_floating && !r.maximized && !r.fullscreen && self.wm.drag is None && self.split_drag is None {
|
||||
// A client-decorated window's size includes the room of Chandra's frame.
|
||||
let (w, h) = if win.csd { (w - 2 * frame_side, h - frame_top - frame_side) } else { (w, h) }
|
||||
let (w, h) = if win.csd { (w - 2 * frame_side(), h - frame_top() - frame_side()) } else { (w, h) }
|
||||
self.apply_actions(self.wm.handle_request(wid, @wm.WindowRequest::ResizeTo(w, h), self.work_area))
|
||||
}
|
||||
_ => ()
|
||||
@@ -781,6 +805,7 @@ pub fn ChandraCompositor::restore_state(self : ChandraCompositor) -> Unit {
|
||||
let st = self.shell.load_state()
|
||||
self.shell.apply_state(st)
|
||||
self.apply_theme()
|
||||
self.sync_window_style()
|
||||
match st.layout {
|
||||
Some(0) => self.set_layout_mode(@wm.LayoutMode::Tiling)
|
||||
Some(1) => self.set_layout_mode(@wm.LayoutMode::Monocle)
|
||||
@@ -793,6 +818,7 @@ pub fn ChandraCompositor::restore_state(self : ChandraCompositor) -> Unit {
|
||||
fn ChandraCompositor::build_scene(
|
||||
self : ChandraCompositor,
|
||||
) -> (@scene.SceneGraph, Bool) {
|
||||
self.sync_window_style()
|
||||
self.flush_configures()
|
||||
self.overview_sync()
|
||||
let scene = @scene.SceneGraph::new(self.output_w, self.output_h)
|
||||
@@ -823,15 +849,40 @@ fn ChandraCompositor::build_scene(
|
||||
surface: win.surface,
|
||||
})
|
||||
}
|
||||
Some(win) if win.fullscreen =>
|
||||
scene.windows.push({
|
||||
id: win.id,
|
||||
title: win.title,
|
||||
app_id: win.app_id,
|
||||
focused: win.focused,
|
||||
fullscreen: true,
|
||||
geometry: win.geometry,
|
||||
deco_insets: (0, 0, 0, 0),
|
||||
deco_ops: [],
|
||||
surface: win.surface,
|
||||
})
|
||||
Some(win) => {
|
||||
let (insets, deco_ops) = @scene.build_breeze_decoration(
|
||||
win.title,
|
||||
win.app_id,
|
||||
win.focused,
|
||||
win.fullscreen,
|
||||
win.geometry.w + 4,
|
||||
win.geometry.h + 34,
|
||||
let outer = frame_rect(win.geometry)
|
||||
let btn = fn(st : (UInt64, Int)?) {
|
||||
match st {
|
||||
Some((w, b)) if w == win.id => b
|
||||
_ => 0
|
||||
}
|
||||
}
|
||||
let (insets, deco_ops) = @scene.build_window_decoration(
|
||||
window_style.val,
|
||||
{
|
||||
title: win.title,
|
||||
app_id: win.app_id,
|
||||
focused: win.focused,
|
||||
maximized: win.maximized,
|
||||
hover: btn(self.deco_hover),
|
||||
pressed: btn(self.deco_pressed),
|
||||
},
|
||||
outer.w,
|
||||
outer.h,
|
||||
self.theme,
|
||||
fn(s, size, bold) { @renderer.text_width(s, size, bold, false) },
|
||||
)
|
||||
scene.windows.push({
|
||||
id: win.id,
|
||||
@@ -1010,7 +1061,7 @@ pub fn ChandraCompositor::handle_gfx_events(
|
||||
Some(win) =>
|
||||
if px >= win.geometry.x &&
|
||||
px < win.geometry.x + win.geometry.w &&
|
||||
py >= win.geometry.y - 32 &&
|
||||
py >= win.geometry.y - frame_top() &&
|
||||
py < win.geometry.y + win.geometry.h {
|
||||
self.apply_actions(
|
||||
self.wm.handle_request(wid, @wm.WindowRequest::Activate, self.work_area),
|
||||
@@ -1201,7 +1252,8 @@ fn ChandraCompositor::window_at(self : ChandraCompositor, x : Int, y : Int) -> (
|
||||
if x >= g.x && x < g.x + g.w && y >= g.y && y < g.y + g.h {
|
||||
return Some((win.id, true))
|
||||
}
|
||||
if x >= g.x - 2 && x < g.x + g.w + 2 && y >= g.y - 32 && y < g.y {
|
||||
let f = frame_rect(g)
|
||||
if x >= f.x && x < f.x + f.w && y >= f.y && y < g.y {
|
||||
return Some((win.id, false))
|
||||
}
|
||||
}
|
||||
@@ -1314,7 +1366,7 @@ fn ChandraCompositor::resize_at(
|
||||
let g = win.geometry
|
||||
let l = g.x
|
||||
let r = g.x + g.w
|
||||
let t = g.y - 32
|
||||
let t = g.y - frame_top()
|
||||
let b = g.y + g.h
|
||||
if x >= l - 6 && x < r + 6 && y >= t - 6 && y < b + 6 {
|
||||
if !rec.is_floating || rec.maximized || rec.fullscreen {
|
||||
@@ -1358,7 +1410,7 @@ fn ChandraCompositor::resize_at(
|
||||
}
|
||||
|
||||
///| Title-bar button under (x, y) for window `wid`: 1 minimize, 2 maximize, 3 close, 0 none.
|
||||
/// Mirrors the layout in `build_breeze_decoration` (18px buttons, 8px apart, 10px from the right edge).
|
||||
/// The layout is the window style's (`@scene.WindowStyle::buttons`), as drawn.
|
||||
fn ChandraCompositor::title_button_at(
|
||||
self : ChandraCompositor,
|
||||
wid : UInt64,
|
||||
@@ -1366,29 +1418,48 @@ fn ChandraCompositor::title_button_at(
|
||||
y : Int,
|
||||
) -> Int {
|
||||
match self.windows.get(wid) {
|
||||
None => 0
|
||||
Some(win) => {
|
||||
let g = win.geometry
|
||||
let outer_w = g.w + 4
|
||||
let lx = x - (g.x - 2)
|
||||
let ly = y - (g.y - 32)
|
||||
let size = 18
|
||||
let by = (32 - size) / 2
|
||||
if ly < by - 3 || ly >= by + size + 3 {
|
||||
return 0
|
||||
Some(win) if !win.csd && !win.fullscreen => {
|
||||
let f = frame_rect(win.geometry)
|
||||
window_style.val.button_at(f.w, x - f.x, y - f.y)
|
||||
}
|
||||
_ => 0
|
||||
}
|
||||
}
|
||||
|
||||
///| Track the title-bar button under the pointer (drawn in its hover state), redrawing when it
|
||||
/// changes. While a button is held, only that one shows hovered (pressed) when under the pointer.
|
||||
fn ChandraCompositor::title_button_hover(self : ChandraCompositor, x : Int, y : Int) -> Unit {
|
||||
let now = match self.window_at(x, y) {
|
||||
Some((wid, false)) =>
|
||||
match self.title_button_at(wid, x, y) {
|
||||
0 => None
|
||||
b => Some((wid, b))
|
||||
}
|
||||
let close_x = outer_w - 10 - size
|
||||
let max_x = close_x - 8 - size
|
||||
let min_x = max_x - 8 - size
|
||||
if lx >= close_x - 3 && lx < close_x + size + 3 {
|
||||
3
|
||||
} else if lx >= max_x - 3 && lx < max_x + size + 3 {
|
||||
2
|
||||
} else if lx >= min_x - 3 && lx < min_x + size + 3 {
|
||||
1
|
||||
} else {
|
||||
0
|
||||
_ => None
|
||||
}
|
||||
if now != self.deco_hover {
|
||||
self.deco_hover = now
|
||||
self.damage.mark_full()
|
||||
}
|
||||
}
|
||||
|
||||
///| A release ends a press on a title-bar button: the button acts when the pointer is still over
|
||||
/// it (moving off first cancels, as in KWin). True when there was such a press.
|
||||
fn ChandraCompositor::release_title_button(self : ChandraCompositor, x : Int, y : Int) -> Bool {
|
||||
match self.deco_pressed {
|
||||
None => false
|
||||
Some((wid, btn)) => {
|
||||
self.deco_pressed = None
|
||||
self.damage.mark_full()
|
||||
let over = match self.window_at(x, y) {
|
||||
Some((w, false)) if w == wid => self.title_button_at(wid, x, y) == btn
|
||||
_ => false
|
||||
}
|
||||
if over {
|
||||
self.deco_hover = None
|
||||
self.press_title_button(wid, btn)
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1472,6 +1543,31 @@ fn ChandraCompositor::window_command(
|
||||
self.damage.mark_full()
|
||||
}
|
||||
|
||||
///| Use the shell's window style (Settings > Session > Flat window frames) if it isn't the one in
|
||||
/// use: the frame's size changes, so the work area, the tiled layout and every client-decorated
|
||||
/// window's size (it fills the frame's box) follow.
|
||||
pub fn ChandraCompositor::sync_window_style(self : ChandraCompositor) -> Unit {
|
||||
let style = self.shell.window_style
|
||||
if style == window_style.val {
|
||||
return
|
||||
}
|
||||
window_style.val = style
|
||||
self.wm.titlebar_h = frame_top()
|
||||
self.wm.border_w = frame_side()
|
||||
self.work_area = work_area_for(self.output_w, self.output_h, self.theme, kiosk=self.kiosk_strict())
|
||||
self.apply_actions(self.wm.fit_work_area(self.work_area))
|
||||
for _, win in self.windows {
|
||||
if win.csd {
|
||||
self.configure_window(win)
|
||||
}
|
||||
}
|
||||
self.deco_hover = None
|
||||
self.deco_pressed = None
|
||||
self.last_frame = None
|
||||
self.last_sig = None
|
||||
self.damage.mark_full()
|
||||
}
|
||||
|
||||
///| Use the dark (configured) or the light theme, as the shell's Dark mode setting says, for the
|
||||
/// shell, the panel modules, the window decorations and the switcher; redraws everything, and
|
||||
/// (in the login session) tells apps through the system preference.
|
||||
@@ -1493,6 +1589,7 @@ fn ChandraCompositor::run_shell_actions(self : ChandraCompositor) -> Unit {
|
||||
@shell.ShellAction::FocusWindow(wid) => self.activate_task(wid)
|
||||
@shell.ShellAction::Logout => self.quit_requested = true
|
||||
@shell.ShellAction::ThemeChanged => self.apply_theme()
|
||||
@shell.ShellAction::WindowStyleChanged => self.sync_window_style()
|
||||
@shell.ShellAction::AuthAgentChanged => self.auth_agent_setting_changed()
|
||||
@shell.ShellAction::Screenshot(code) => self.screenshot_request(code)
|
||||
@shell.ShellAction::SystemPower(a) => self.system_power(a)
|
||||
@@ -1522,9 +1619,9 @@ fn ChandraCompositor::handle_at(
|
||||
let slop = 3
|
||||
for h in self.wm.split_handles(self.work_area) {
|
||||
let r = h.rect
|
||||
// Title bars sit 32px above the windows, so the hit area reaches up over them.
|
||||
// Title bars sit above the windows, so the hit area reaches up over them.
|
||||
let hit = if h.horizontal {
|
||||
x >= r.x - slop && x < r.x + r.w + slop && y >= r.y - 32 && y < r.y + r.h
|
||||
x >= r.x - slop && x < r.x + r.w + slop && y >= r.y - frame_top() && y < r.y + r.h
|
||||
} else {
|
||||
y >= r.y - slop && y < r.y + r.h + slop && x >= r.x && x < r.x + r.w
|
||||
}
|
||||
@@ -1652,6 +1749,7 @@ pub fn ChandraCompositor::handle_input(
|
||||
if self.overview_motion(xi, yi) {
|
||||
return
|
||||
}
|
||||
self.title_button_hover(xi, yi)
|
||||
if self.title_bar_motion(xi, yi) {
|
||||
return
|
||||
}
|
||||
@@ -1796,6 +1894,9 @@ pub fn ChandraCompositor::handle_input(
|
||||
if self.overview_button(button, pressed, xi, yi) {
|
||||
return
|
||||
}
|
||||
if !pressed && self.release_title_button(xi, yi) {
|
||||
return
|
||||
}
|
||||
if !pressed && button == 272U {
|
||||
self.title_bar_release()
|
||||
}
|
||||
@@ -1844,7 +1945,10 @@ pub fn ChandraCompositor::handle_input(
|
||||
Some((wid, false)) => {
|
||||
let btn = self.title_button_at(wid, xi, yi)
|
||||
if btn != 0 {
|
||||
self.press_title_button(wid, btn)
|
||||
// Shown pressed until the release, which acts if it is still over the button.
|
||||
self.leave_pointer()
|
||||
self.deco_pressed = Some((wid, btn))
|
||||
self.damage.mark_full()
|
||||
return
|
||||
}
|
||||
if button == 272U && self.resize_at(xi, yi) is None {
|
||||
|
||||
@@ -100,7 +100,7 @@ test "a GTK window draws its own frame: no second title bar, and its shadow is n
|
||||
assert_eq((win.geo_x, win.geo_y), (gtk_shadow, gtk_shadow))
|
||||
// The client is asked to fill the frame's whole box: where Chandra's title bar would be is its own.
|
||||
let r = win.client_rect()
|
||||
assert_eq((r.w, r.h), (win.geometry.w + 4, win.geometry.h + 34))
|
||||
assert_eq((r.w, r.h), (win.geometry.w + 2, win.geometry.h + 39))
|
||||
let (w, h) = gtk_frame(comp, c, shm, surf, xdg, tl)
|
||||
assert_eq((w, h), (r.w, r.h))
|
||||
let red = Some(@scene.Rgba::new(0xff, 0, 0, 0xff))
|
||||
@@ -204,7 +204,7 @@ test "Chrome asking to draw its own frame gets it, instead of a second one aroun
|
||||
let win = comp.windows.get(1UL).unwrap()
|
||||
assert_true(win.csd)
|
||||
let r = win.client_rect()
|
||||
assert_eq((r.w, r.h), (win.geometry.w + 4, win.geometry.h + 34))
|
||||
assert_eq((r.w, r.h), (win.geometry.w + 2, win.geometry.h + 39))
|
||||
|
||||
// unset_mode: back to Chandra's frame.
|
||||
c.send(@wayland.WireWriter::new().finish_msg(deco, 2U))
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
///| Window frames: the flat (Flatkit Aurorae) style's button states, and switching styles.
|
||||
|
||||
///|
|
||||
test "title-bar buttons hover, show pressed, act on release and cancel when left" {
|
||||
let socket_path = "/tmp/wayland-moon-decohover-" + @sys.getpid().to_string() + ".sock"
|
||||
let comp = @host.ChandraCompositor::new(socket_path, @scene.ThemeTokens::moon_night(), 1280, 720).unwrap()
|
||||
ignore(open_and_configure_client(comp, socket_path, "A", "a"))
|
||||
ignore(comp.compose_frame())
|
||||
let (mx, my) = button_centre(comp, 1UL, 2)
|
||||
let move = fn(x : Int, y : Int, t : UInt) {
|
||||
comp.handle_input(@nested.InputEvent::PointerMove(x.to_double(), y.to_double()), t)
|
||||
}
|
||||
move(mx, my, 1U)
|
||||
assert_eq(comp.deco_hover, Some((1UL, 2)))
|
||||
move(mx - 28, my, 2U)
|
||||
assert_eq(comp.deco_hover, Some((1UL, 1)))
|
||||
// Press maximize: shown pressed, nothing happens yet.
|
||||
move(mx, my, 3U)
|
||||
let w0 = comp.windows.get(1UL).unwrap().geometry.w
|
||||
comp.handle_input(@nested.InputEvent::PointerButton(272U, true), 4U)
|
||||
assert_eq(comp.deco_pressed, Some((1UL, 2)))
|
||||
assert_eq(comp.windows.get(1UL).unwrap().geometry.w, w0)
|
||||
ignore(comp.compose_frame())
|
||||
// Moving off and releasing cancels.
|
||||
move(mx, my + 60, 5U)
|
||||
comp.handle_input(@nested.InputEvent::PointerButton(272U, false), 6U)
|
||||
assert_eq(comp.deco_pressed, None)
|
||||
assert_eq(comp.windows.get(1UL).unwrap().geometry.w, w0)
|
||||
// Press and release over it: it maximizes.
|
||||
move(mx, my, 7U)
|
||||
comp.handle_input(@nested.InputEvent::PointerButton(272U, true), 8U)
|
||||
comp.handle_input(@nested.InputEvent::PointerButton(272U, false), 9U)
|
||||
assert_true(comp.windows.get(1UL).unwrap().maximized)
|
||||
// Off the title bar nothing is hovered.
|
||||
move(600, 400, 10U)
|
||||
assert_eq(comp.deco_hover, None)
|
||||
}
|
||||
|
||||
///|
|
||||
test "Flat window frames off switches to the classic frame: sizes, layout and state.edn follow" {
|
||||
let socket_path = "/tmp/wayland-moon-decostyle-" + @sys.getpid().to_string() + ".sock"
|
||||
let comp = @host.ChandraCompositor::new(socket_path, @scene.ThemeTokens::moon_night(), 1280, 720).unwrap()
|
||||
ignore(open_and_configure_client(comp, socket_path, "A", "a"))
|
||||
ignore(comp.compose_frame())
|
||||
let flat_area = comp.work_area
|
||||
assert_eq(comp.shell.window_style, @scene.WindowStyle::Flat)
|
||||
assert_eq(comp.wm.titlebar_h, 38)
|
||||
// The settings module's sixth switch, "Flat window frames", off.
|
||||
comp.shell.set_session_setting(5, false)
|
||||
ignore(comp.compose_frame())
|
||||
assert_eq(comp.shell.window_style, @scene.WindowStyle::Breeze)
|
||||
assert_eq((comp.wm.titlebar_h, comp.wm.border_w), (32, 2))
|
||||
assert_eq(comp.work_area.y, flat_area.y - 6)
|
||||
// The tiled window moved up with the work area.
|
||||
let g = comp.windows.get(1UL).unwrap().geometry
|
||||
assert_eq(g.y, comp.work_area.y + 8)
|
||||
// The classic buttons are where they are drawn: the close button 10px from the right edge.
|
||||
let outer_w = g.w + 4
|
||||
let close = @scene.WindowStyle::Breeze.buttons(outer_w)[2].1
|
||||
assert_eq(close.x, outer_w - 28)
|
||||
comp.shell.set_session_setting(5, true)
|
||||
ignore(comp.compose_frame())
|
||||
assert_eq(comp.work_area, flat_area)
|
||||
}
|
||||
|
||||
///|
|
||||
test "state.edn :window-style :breeze turns Flat window frames off" {
|
||||
if @sys.getenv("CHANDRA_TEST_CONFIG") == "1" {
|
||||
let dir = @sys.getenv("XDG_CONFIG_HOME") + "/chandra"
|
||||
assert_true(@sys.mkdir_p(dir))
|
||||
let state0 = @sys.read_file_bytes(dir + "/state.edn")
|
||||
ignore(@sys.write_file_bytes(dir + "/state.edn", @utf8.encode("{:window-style :breeze}\n")))
|
||||
let boot = fn() {
|
||||
let s = @shell.DesktopShell::new("x")
|
||||
s.persist = true
|
||||
s.set_output(@scene.ThemeTokens::moon_night(), 1280, 720)
|
||||
ignore(s.slots())
|
||||
s.apply_state(s.load_state())
|
||||
s
|
||||
}
|
||||
let a = boot()
|
||||
assert_eq(a.window_style, @scene.WindowStyle::Breeze)
|
||||
a.set_session_setting(5, true)
|
||||
let text = @utf8.decode_lossy(@sys.read_file_bytes(dir + "/state.edn"))
|
||||
assert_false(text.contains("window-style"))
|
||||
a.set_session_setting(5, false)
|
||||
let text = @utf8.decode_lossy(@sys.read_file_bytes(dir + "/state.edn"))
|
||||
assert_true(text.contains(":window-style :breeze"))
|
||||
assert_eq(boot().window_style, @scene.WindowStyle::Breeze)
|
||||
ignore(@sys.write_file_bytes(dir + "/state.edn", state0))
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,16 @@ fn new_comp(tag : String) -> @host.ChandraCompositor {
|
||||
comp
|
||||
}
|
||||
|
||||
///| Centre of title-bar button `n` (1 minimize, 2 maximize, 3 close) of window `wid`, in the
|
||||
/// default (flat) window style.
|
||||
fn button_centre(comp : @host.ChandraCompositor, wid : UInt64, n : Int) -> (Int, Int) {
|
||||
let style = @scene.WindowStyle::Flat
|
||||
let g = comp.windows.get(wid).unwrap().geometry
|
||||
let (ox, oy) = (g.x - style.frame_side(), g.y - style.frame_top())
|
||||
let r = style.buttons(g.w + 2 * style.frame_side())[n - 1].1
|
||||
(ox + r.x + r.w / 2, oy + r.y + r.h / 2)
|
||||
}
|
||||
|
||||
///| Drain everything the compositor sent this client as (object, opcode) pairs.
|
||||
fn drain_msgs(c : TestWaylandClient) -> Array[(UInt, UInt)] {
|
||||
let scratch : FixedArray[Byte] = FixedArray::make(65536, b'\x00')
|
||||
@@ -223,14 +233,8 @@ test "title-bar buttons minimize, maximize and close windows" {
|
||||
let (c, _shm, _surf, _xdg, tl, _deco) = open_and_configure_client(comp, socket_path, "A", "a")
|
||||
let _b = open_and_configure_client(comp, socket_path, "B", "b")
|
||||
ignore(comp.compose_frame())
|
||||
// Button centres, from the decoration layout (18px buttons, 10px from the right edge).
|
||||
let btn = fn(wid : UInt64, n : Int) {
|
||||
let g = comp.windows.get(wid).unwrap().geometry
|
||||
let outer_w = g.w + 4
|
||||
let x = g.x - 2 + outer_w - 10 - 9 - (3 - n) * 26
|
||||
let y = g.y - 32 + 16
|
||||
(x, y)
|
||||
}
|
||||
// Button centres, from the flat frame's layout (24px buttons, 8px from the right edge).
|
||||
let btn = fn(wid : UInt64, n : Int) { button_centre(comp, wid, n) }
|
||||
let click = fn(p : (Int, Int), t : UInt) {
|
||||
click_at(comp, p.0, p.1, t)
|
||||
}
|
||||
@@ -1694,8 +1698,8 @@ test "open_settings opens the settings module on the tab asked for" {
|
||||
assert_eq(pr.h, 40 + (1 + 5 + 6) * 28 + 6)
|
||||
assert_true(comp.shell.open_settings(Session))
|
||||
ignore(comp.compose_frame())
|
||||
// The five settings, then Face unlock (a heading; chandra-face isn't installed in tests).
|
||||
assert_eq(comp.shell.slot_popup_rect(slot).h, 40 + 7 * 28 + 6)
|
||||
// The six settings, then Face unlock (a heading; chandra-face isn't installed in tests).
|
||||
assert_eq(comp.shell.slot_popup_rect(slot).h, 40 + 8 * 28 + 6)
|
||||
assert_true(
|
||||
comp.shell.slot_popup_texts(slot).iter().any(t => t.0.has_prefix("Lighter animations (")),
|
||||
)
|
||||
|
||||
@@ -10,7 +10,8 @@ test "resize redraws the desktop at the new output size" {
|
||||
let after = comp.compose_frame()
|
||||
assert_eq((after.width, after.height), (900, 560))
|
||||
assert_eq((comp.output_w, comp.output_h), (900, 560))
|
||||
assert_eq(comp.work_area.h, 560 - 32 - comp.theme.panel_height)
|
||||
// The flat frame's 38px title bar is kept free at the top.
|
||||
assert_eq(comp.work_area.h, 560 - 38 - comp.theme.panel_height)
|
||||
assert_eq(comp.server.output_w, 900)
|
||||
comp.close()
|
||||
}
|
||||
@@ -224,7 +224,7 @@ fn ChandraCompositor::outer_rect(self : ChandraCompositor, wid : UInt64) -> @sce
|
||||
let r = if win.fullscreen {
|
||||
g
|
||||
} else {
|
||||
@scene.Rect::new(g.x - 2, g.y - 32, g.w + 4, g.h + 34)
|
||||
frame_rect(g)
|
||||
}
|
||||
Some(self.clip_to_screen(r))
|
||||
}
|
||||
|
||||
@@ -118,12 +118,12 @@ test "escape cancels the overlay; a click on a window selects it; W takes the ac
|
||||
let g = comp.windows.get(1UL).unwrap().geometry
|
||||
chord(comp, [125U, 42U], 65U, 31U, 10U)
|
||||
click_at(comp, g.x + 20, g.y + 20, 20U)
|
||||
assert_eq(comp.screenshot_selection(), Some(@scene.Rect::new(g.x - 2, g.y - 32, g.w + 4, g.h + 34)))
|
||||
assert_eq(comp.screenshot_selection(), Some(@scene.Rect::new(g.x - 1, g.y - 38, g.w + 2, g.h + 39)))
|
||||
// W takes the active window (B) instead.
|
||||
key(comp, 17U, true, 30U)
|
||||
key(comp, 17U, false, 31U)
|
||||
let gb = comp.windows.get(2UL).unwrap().geometry
|
||||
assert_eq(png_size(@sys.read_file_bytes(comp.last_screenshot())), (gb.w + 4, gb.h + 34))
|
||||
assert_eq(png_size(@sys.read_file_bytes(comp.last_screenshot())), (gb.w + 2, gb.h + 39))
|
||||
}
|
||||
|
||||
///|
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
///| Draw one window in `style` over a flat grey backdrop and return the frame (window geometry at
|
||||
/// (40, 60), 200 x 100, an opaque white client).
|
||||
fn deco_frame(
|
||||
style : @scene.WindowStyle,
|
||||
theme : @scene.ThemeTokens,
|
||||
focused~ : Bool = true,
|
||||
maximized~ : Bool = false,
|
||||
hover~ : Int = 0,
|
||||
pressed~ : Int = 0,
|
||||
) -> @renderer.Pixmap {
|
||||
let scene = @scene.SceneGraph::new(320, 220)
|
||||
scene.background_ops = [@scene.DrawOp::FillRect(@scene.Rect::new(0, 0, 320, 220), @scene.Rgba::new(128, 128, 128, 255), 0)]
|
||||
let g = @scene.Rect::new(40, 60, 200, 100)
|
||||
let (insets, deco_ops) = @scene.build_window_decoration(
|
||||
style,
|
||||
{ title: "Files", app_id: "org.kde.dolphin", focused, maximized, hover, pressed },
|
||||
g.w + 2 * style.frame_side(),
|
||||
g.h + style.frame_top() + style.frame_side(),
|
||||
theme,
|
||||
fn(s, size, bold) { @renderer.text_width(s, size, bold, false) },
|
||||
)
|
||||
let px : Array[Byte] = Array(capacity=200 * 100 * 4)
|
||||
for _i = 0; _i < 200 * 100 * 4; _i = _i + 1 {
|
||||
px.push(b'\xff')
|
||||
}
|
||||
scene.windows.push({
|
||||
id: 1UL,
|
||||
title: "Files",
|
||||
app_id: "org.kde.dolphin",
|
||||
focused,
|
||||
fullscreen: false,
|
||||
geometry: g,
|
||||
deco_insets: insets,
|
||||
deco_ops,
|
||||
surface: Some({ width: 200, height: 100, stride: 800, format: 0, bytes: Bytes::from_array(px), host_id: 0U }),
|
||||
})
|
||||
@renderer.render_scene(scene)
|
||||
}
|
||||
|
||||
///|
|
||||
fn px_of(p : @renderer.Pixmap, x : Int, y : Int) -> @scene.Rgba {
|
||||
p.pixel(x, y).unwrap()
|
||||
}
|
||||
|
||||
///|
|
||||
fn darker(a : @scene.Rgba, b : @scene.Rgba) -> Bool {
|
||||
a.r.to_int() < b.r.to_int()
|
||||
}
|
||||
|
||||
///|
|
||||
test "flat frame: 38px title bar, 1px outline, hairline, kit colours (light and dark)" {
|
||||
let style = @scene.WindowStyle::Flat
|
||||
assert_eq((style.frame_top(), style.frame_side()), (38, 1))
|
||||
let light = deco_frame(style, @scene.ThemeTokens::moon_day())
|
||||
// Frame outer box: (39, 22) to (241, 161). Outline (#DADADE), title fill (#F6F6F7), hairline.
|
||||
assert_eq(px_of(light, 120, 22), @scene.Rgba::from_hex("#DADADE"))
|
||||
assert_eq(px_of(light, 120, 23), @scene.Rgba::from_hex("#F6F6F7"))
|
||||
assert_eq(px_of(light, 44, 27), @scene.Rgba::from_hex("#F6F6F7"))
|
||||
assert_eq(px_of(light, 120, 59), @scene.Rgba::from_hex("#DADADE"))
|
||||
assert_eq(px_of(light, 39, 100), @scene.Rgba::from_hex("#DADADE"))
|
||||
assert_eq(px_of(light, 240, 100), @scene.Rgba::from_hex("#DADADE"))
|
||||
assert_eq(px_of(light, 120, 160), @scene.Rgba::from_hex("#DADADE"))
|
||||
// The client starts right under the hairline.
|
||||
assert_eq(px_of(light, 120, 60), @scene.Rgba::new(255, 255, 255, 255))
|
||||
// Rounded top corners: the corner pixel is backdrop (with shadow), not frame.
|
||||
assert_true(px_of(light, 39, 22).r.to_int() < 128)
|
||||
let dark = deco_frame(style, @scene.ThemeTokens::moon_night())
|
||||
assert_eq(px_of(dark, 120, 23), @scene.Rgba::from_hex("#1C1C1F"))
|
||||
assert_eq(px_of(dark, 120, 22), @scene.Rgba::from_hex("#3A3A40"))
|
||||
}
|
||||
|
||||
///|
|
||||
test "flat frame: soft shadow all round, stronger focused, none maximized" {
|
||||
let style = @scene.WindowStyle::Flat
|
||||
let theme = @scene.ThemeTokens::moon_day()
|
||||
let grey = @scene.Rgba::new(128, 128, 128, 255)
|
||||
let f = deco_frame(style, theme)
|
||||
// Left, right, above and below the frame, fading out by 16px.
|
||||
for p in [(37, 100), (243, 100), (120, 20), (120, 163), (37, 163), (243, 163)] {
|
||||
assert_true(darker(px_of(f, p.0, p.1), grey))
|
||||
}
|
||||
assert_true(darker(px_of(f, 37, 100), px_of(f, 30, 100)))
|
||||
assert_eq(px_of(f, 20, 100), grey)
|
||||
assert_eq(px_of(f, 120, 2), grey)
|
||||
let unfocused = deco_frame(style, theme, focused=false)
|
||||
assert_true(darker(px_of(f, 37, 100), px_of(unfocused, 37, 100)))
|
||||
let maxed = deco_frame(style, theme, maximized=true)
|
||||
assert_eq(px_of(maxed, 37, 100), grey)
|
||||
// Square corners when maximized.
|
||||
assert_eq(px_of(maxed, 39, 22), @scene.Rgba::from_hex("#DADADE"))
|
||||
}
|
||||
|
||||
///|
|
||||
test "flat frame: buttons are flat at rest, filled on hover and press, close turns red" {
|
||||
let style = @scene.WindowStyle::Flat
|
||||
let theme = @scene.ThemeTokens::moon_day()
|
||||
let outer_w = 202
|
||||
let buttons = style.buttons(outer_w)
|
||||
assert_eq(buttons.map(b => b.0), [1, 2, 3])
|
||||
// 24px buttons 4px apart, 8px from the right edge, centred in the title bar.
|
||||
assert_eq(buttons[2].1, @scene.Rect::new(outer_w - 32, 7, 24, 24))
|
||||
assert_eq(buttons[1].1.x, outer_w - 60)
|
||||
assert_eq(style.button_at(outer_w, outer_w - 20, 19), 3)
|
||||
assert_eq(style.button_at(outer_w, outer_w - 48, 19), 2)
|
||||
assert_eq(style.button_at(outer_w, outer_w - 76, 19), 1)
|
||||
assert_eq(style.button_at(outer_w, 40, 19), 0)
|
||||
// Close button corner (inside its 6px radius): title colour at rest, red on hover, darker red
|
||||
// pressed. Frame origin is (39, 22).
|
||||
let (cx, cy) = (39 + buttons[2].1.x + 3, 22 + 7 + 12)
|
||||
let rest = deco_frame(style, theme)
|
||||
assert_eq(px_of(rest, cx, cy), @scene.Rgba::from_hex("#F6F6F7"))
|
||||
assert_eq(px_of(deco_frame(style, theme, hover=3), cx, cy), @scene.Rgba::from_hex("#D12D3A"))
|
||||
assert_eq(px_of(deco_frame(style, theme, pressed=3), cx, cy), @scene.Rgba::from_hex("#B8232F"))
|
||||
let (mx, my) = (39 + buttons[1].1.x + 2, 22 + 7 + 12)
|
||||
assert_eq(px_of(deco_frame(style, theme, hover=2), mx, my), @scene.Rgba::from_hex("#EDEDEF"))
|
||||
assert_eq(px_of(deco_frame(style, theme, pressed=2), mx, my), @scene.Rgba::from_hex("#DEDEE2"))
|
||||
}
|
||||
|
||||
///|
|
||||
test "breeze frame keeps its 32px title bar and offset shadow" {
|
||||
let style = @scene.WindowStyle::Breeze
|
||||
assert_eq((style.frame_top(), style.frame_side()), (32, 2))
|
||||
let f = deco_frame(style, @scene.ThemeTokens::moon_night())
|
||||
let grey = @scene.Rgba::new(128, 128, 128, 255)
|
||||
// Shadow 4px right / 6px down only: none to the left or above.
|
||||
assert_true(darker(px_of(f, 244, 100), grey))
|
||||
assert_true(darker(px_of(f, 120, 165), grey))
|
||||
assert_eq(px_of(f, 36, 100), grey)
|
||||
assert_eq(px_of(f, 120, 26), grey)
|
||||
}
|
||||
@@ -772,23 +772,9 @@ pub fn render_scene(scene : @scene.SceneGraph) -> Pixmap {
|
||||
// 2. Windows layer (bottom-to-top)
|
||||
for win in scene.windows {
|
||||
if !win.fullscreen {
|
||||
let (top, right, bottom, left) = win.deco_insets
|
||||
let outer_x = win.geometry.x - left
|
||||
let outer_y = win.geometry.y - top
|
||||
let outer_w = win.geometry.w + left + right
|
||||
let outer_h = win.geometry.h + top + bottom
|
||||
|
||||
// Subtle drop shadow. The window covers most of it, so only the strips that stick out
|
||||
// (right and bottom) are blended instead of the whole shadow rectangle.
|
||||
let shadow = @scene.Rect::new(outer_x + 4, outer_y + 6, outer_w, outer_h)
|
||||
let shadow_col = @scene.Rgba::new(0, 0, 0, 80)
|
||||
fill_rounded_rect(pixmap, shadow, shadow_col, 8, Some(@scene.Rect::new(outer_x + outer_w, outer_y, 4, outer_h + 6)))
|
||||
fill_rounded_rect(pixmap, shadow, shadow_col, 8, Some(@scene.Rect::new(outer_x, outer_y + outer_h, outer_w + 4, 6)))
|
||||
// The title bar is slightly translucent when unfocused, so keep the shadow under it.
|
||||
fill_rounded_rect(pixmap, shadow, shadow_col, 8, Some(@scene.Rect::new(outer_x, outer_y, outer_w, top + 2)))
|
||||
|
||||
// Breeze SSD decoration draw-ops
|
||||
draw_ops(pixmap, win.deco_ops, outer_x, outer_y)
|
||||
let (top, _, _, left) = win.deco_insets
|
||||
// The frame: title bar, outline, buttons and its shadow (`@scene.build_window_decoration`).
|
||||
draw_ops(pixmap, win.deco_ops, win.geometry.x - left, win.geometry.y - top)
|
||||
}
|
||||
|
||||
// Client wl_shm surface
|
||||
|
||||
@@ -10,6 +10,10 @@ pub fn build_breeze_decoration(String, String, Bool, Bool, Int32, Int32, ThemeTo
|
||||
|
||||
pub fn build_shell_ops(Int32, Int32, ThemeTokens, String, Array[String]) -> (Array[DrawOp], Array[DrawOp])
|
||||
|
||||
pub fn build_window_decoration(WindowStyle, DecorationState, Int32, Int32, ThemeTokens, (String, Int32, Bool) -> Int32) -> ((Int32, Int32, Int32, Int32), Array[DrawOp])
|
||||
|
||||
pub let decoration_shadow_reach : Int32
|
||||
|
||||
// Errors
|
||||
|
||||
// Types and methods
|
||||
@@ -22,6 +26,15 @@ pub fn DamageTracker::mark_rect(Self, Rect) -> Unit
|
||||
pub fn DamageTracker::new() -> Self
|
||||
pub fn DamageTracker::take_damage(Self, Int32, Int32) -> Array[Rect]
|
||||
|
||||
pub(all) struct DecorationState {
|
||||
title : String
|
||||
app_id : String
|
||||
focused : Bool
|
||||
maximized : Bool
|
||||
hover : Int32
|
||||
pressed : Int32
|
||||
}
|
||||
|
||||
#derive(Eq)
|
||||
pub(all) enum DrawOp {
|
||||
FillRect(Rect, Rgba, Int32)
|
||||
@@ -35,6 +48,8 @@ pub(all) enum DrawOp {
|
||||
Image(Rect, UInt32)
|
||||
}
|
||||
|
||||
type FlatColors
|
||||
|
||||
pub(all) struct PanelWidgetNode {
|
||||
id : String
|
||||
rect : Rect
|
||||
@@ -92,6 +107,7 @@ pub(all) enum TextAlign {
|
||||
Right
|
||||
}
|
||||
|
||||
#derive(Eq)
|
||||
pub(all) struct ThemePalette {
|
||||
desktop_top : Rgba
|
||||
desktop_bottom : Rgba
|
||||
@@ -105,6 +121,7 @@ pub(all) struct ThemePalette {
|
||||
border : Rgba
|
||||
}
|
||||
|
||||
#derive(Eq)
|
||||
pub(all) struct ThemeTokens {
|
||||
name : String
|
||||
palette : ThemePalette
|
||||
@@ -114,6 +131,7 @@ pub(all) struct ThemeTokens {
|
||||
panel_height : Int32
|
||||
}
|
||||
pub fn ThemeTokens::from_json_string(String) -> Self
|
||||
pub fn ThemeTokens::is_dark(Self) -> Bool
|
||||
pub fn ThemeTokens::moon_day() -> Self
|
||||
pub fn ThemeTokens::moon_night() -> Self
|
||||
|
||||
@@ -129,6 +147,18 @@ pub(all) struct WindowSceneNode {
|
||||
surface : ShmBufferSnapshot?
|
||||
}
|
||||
|
||||
#derive(Eq, @debug.Debug)
|
||||
pub(all) enum WindowStyle {
|
||||
Flat
|
||||
Breeze
|
||||
}
|
||||
pub fn WindowStyle::button_at(Self, Int32, Int32, Int32) -> Int32
|
||||
pub fn WindowStyle::buttons(Self, Int32) -> Array[(Int32, Rect, Int32)]
|
||||
pub fn WindowStyle::frame_side(Self) -> Int32
|
||||
pub fn WindowStyle::frame_top(Self) -> Int32
|
||||
pub fn WindowStyle::name(Self) -> String
|
||||
pub fn WindowStyle::parse(String) -> Self?
|
||||
|
||||
// Type aliases
|
||||
|
||||
// Traits
|
||||
@@ -561,3 +561,431 @@ pub fn build_shell_ops(
|
||||
|
||||
(bg_ops, panel_ops)
|
||||
}
|
||||
|
||||
///| How Chandra draws the frame around a server-decorated window. `Flat` follows V's Flatkit
|
||||
/// Aurorae theme (github.com/codegod100/kde, aurorae/): the kit's neutral title bar, a 1px
|
||||
/// outline with 10px top corners, a hairline under the title, a soft 16px shadow all round, a
|
||||
/// centred title and 24px flat buttons that show a hover / pressed fill (close turns red).
|
||||
/// `Breeze` is the frame Chandra drew before: accent outline, 18px round buttons, offset shadow.
|
||||
#derive(Eq, Debug)
|
||||
pub(all) enum WindowStyle {
|
||||
Flat
|
||||
Breeze
|
||||
}
|
||||
|
||||
///| The name state.edn stores (`:window-style :flat` / `:breeze`).
|
||||
pub fn WindowStyle::name(self : WindowStyle) -> String {
|
||||
match self {
|
||||
Flat => "flat"
|
||||
Breeze => "breeze"
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn WindowStyle::parse(s : String) -> WindowStyle? {
|
||||
match s {
|
||||
"flat" => Some(Flat)
|
||||
"breeze" => Some(Breeze)
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
|
||||
///| Height of the frame above the client: the title bar, its outline and the line under it.
|
||||
pub fn WindowStyle::frame_top(self : WindowStyle) -> Int {
|
||||
match self {
|
||||
Flat => flat_title_h
|
||||
Breeze => 32
|
||||
}
|
||||
}
|
||||
|
||||
///| Width of the frame left, right and below the client.
|
||||
pub fn WindowStyle::frame_side(self : WindowStyle) -> Int {
|
||||
match self {
|
||||
Flat => 1
|
||||
Breeze => 2
|
||||
}
|
||||
}
|
||||
|
||||
///| How far around the frame the decoration's ops may draw (its shadow): hosts redraw this much
|
||||
/// around a window that moved.
|
||||
pub let decoration_shadow_reach : Int = 18
|
||||
|
||||
///| Flat: the outline row, 36px of title bar with the 24px buttons centred, and the hairline:
|
||||
/// 38px, TitleEdgeTop 7 + TitleHeight 24 + TitleEdgeBottom 7 in Flatkitrc.
|
||||
let flat_title_h : Int = 38
|
||||
|
||||
///|
|
||||
let flat_radius : Int = 10
|
||||
|
||||
///|
|
||||
let flat_button : Int = 24
|
||||
|
||||
///|
|
||||
let flat_button_gap : Int = 4
|
||||
|
||||
///| From the frame's right edge to the close button (TitleEdgeRight 7 + the outline).
|
||||
let flat_button_margin : Int = 8
|
||||
|
||||
///|
|
||||
let flat_shadow : Int = 16
|
||||
|
||||
///| The title-bar buttons of a frame `outer_w` wide, in the frame's coordinates, as
|
||||
/// (button, rect, slop): 1 minimize, 2 maximize, 3 close; slop widens the click target.
|
||||
pub fn WindowStyle::buttons(self : WindowStyle, outer_w : Int) -> Array[(Int, Rect, Int)] {
|
||||
match self {
|
||||
Flat => {
|
||||
let y = (flat_title_h - flat_button) / 2
|
||||
let close_x = outer_w - flat_button_margin - flat_button
|
||||
let max_x = close_x - flat_button_gap - flat_button
|
||||
let min_x = max_x - flat_button_gap - flat_button
|
||||
[
|
||||
(1, Rect::new(min_x, y, flat_button, flat_button), 2),
|
||||
(2, Rect::new(max_x, y, flat_button, flat_button), 2),
|
||||
(3, Rect::new(close_x, y, flat_button, flat_button), 2),
|
||||
]
|
||||
}
|
||||
Breeze => {
|
||||
let size = 18
|
||||
let y = (32 - size) / 2
|
||||
let close_x = outer_w - 10 - size
|
||||
let max_x = close_x - 8 - size
|
||||
let min_x = max_x - 8 - size
|
||||
[
|
||||
(1, Rect::new(min_x, y, size, size), 3),
|
||||
(2, Rect::new(max_x, y, size, size), 3),
|
||||
(3, Rect::new(close_x, y, size, size), 3),
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///| The button (1 minimize, 2 maximize, 3 close) at (lx, ly) in a frame `outer_w` wide; 0 none.
|
||||
pub fn WindowStyle::button_at(self : WindowStyle, outer_w : Int, lx : Int, ly : Int) -> Int {
|
||||
for b in self.buttons(outer_w) {
|
||||
let (id, r, slop) = b
|
||||
if lx >= r.x - slop && lx < r.x + r.w + slop && ly >= r.y - slop && ly < r.y + r.h + slop {
|
||||
return id
|
||||
}
|
||||
}
|
||||
0
|
||||
}
|
||||
|
||||
///| One window's decoration: what it shows and the pointer's state over its buttons.
|
||||
pub(all) struct DecorationState {
|
||||
title : String
|
||||
app_id : String
|
||||
focused : Bool
|
||||
maximized : Bool
|
||||
/// The button under the pointer (1 minimize, 2 maximize, 3 close; 0 none) ...
|
||||
hover : Int
|
||||
/// ... and the one held down.
|
||||
pressed : Int
|
||||
}
|
||||
|
||||
///| Colours of the Flat frame: flatkit's KitColors (lib/src/theme.dart in codegod100/flutterkit),
|
||||
/// as aurorae/generate.py has them.
|
||||
struct FlatColors {
|
||||
background : Rgba
|
||||
hover : Rgba
|
||||
pressed : Rgba
|
||||
border : Rgba
|
||||
text : Rgba
|
||||
text_dim : Rgba
|
||||
danger : Rgba
|
||||
danger_hover : Rgba
|
||||
on_danger : Rgba
|
||||
/// Shadow opacity (0-255) at the outline, focused and unfocused.
|
||||
shadow : Int
|
||||
shadow_inactive : Int
|
||||
}
|
||||
|
||||
///|
|
||||
fn flat_colors(dark : Bool) -> FlatColors {
|
||||
if dark {
|
||||
{
|
||||
background: Rgba::from_hex("#1C1C1F"),
|
||||
hover: Rgba::from_hex("#323237"),
|
||||
pressed: Rgba::from_hex("#3C3C42"),
|
||||
border: Rgba::from_hex("#3A3A40"),
|
||||
text: Rgba::from_hex("#EDEDF0"),
|
||||
text_dim: Rgba::from_hex("#A0A0A8"),
|
||||
danger: Rgba::from_hex("#E5484D"),
|
||||
danger_hover: Rgba::from_hex("#EC5F63"),
|
||||
on_danger: Rgba::from_hex("#FFFFFF"),
|
||||
shadow: 115, // 0.45
|
||||
shadow_inactive: 71, // 0.28
|
||||
}
|
||||
} else {
|
||||
{
|
||||
background: Rgba::from_hex("#F6F6F7"),
|
||||
hover: Rgba::from_hex("#EDEDEF"),
|
||||
pressed: Rgba::from_hex("#DEDEE2"),
|
||||
border: Rgba::from_hex("#DADADE"),
|
||||
text: Rgba::from_hex("#1E1E22"),
|
||||
text_dim: Rgba::from_hex("#66666E"),
|
||||
danger: Rgba::from_hex("#D12D3A"),
|
||||
danger_hover: Rgba::from_hex("#B8232F"),
|
||||
on_danger: Rgba::from_hex("#FFFFFF"),
|
||||
shadow: 51, // 0.20
|
||||
shadow_inactive: 28, // 0.11
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///| True for a dark theme (its surface colour is dark): Moon Night, not Moon Day.
|
||||
pub fn ThemeTokens::is_dark(self : ThemeTokens) -> Bool {
|
||||
let s = self.palette.surface
|
||||
s.r.to_int() * 299 + s.g.to_int() * 587 + s.b.to_int() * 114 < 128 * 1000
|
||||
}
|
||||
|
||||
///| The shadow's falloff from the outline out, as (fraction of the reach, fraction of the
|
||||
/// opacity): SHADOW_STOPS in aurorae/generate.py.
|
||||
let shadow_stops : Array[(Double, Double)] = [
|
||||
(0.0, 1.0),
|
||||
(0.15, 0.72),
|
||||
(0.35, 0.40),
|
||||
(0.6, 0.15),
|
||||
(0.8, 0.05),
|
||||
(1.0, 0.0),
|
||||
]
|
||||
|
||||
///| Shadow opacity (0-255) at `t` (0 at the outline, 1 at the shadow's reach).
|
||||
fn shadow_alpha(max_a : Int, t : Double) -> Int {
|
||||
let mut i = 0
|
||||
while i + 1 < shadow_stops.length() && shadow_stops[i + 1].0 < t {
|
||||
i = i + 1
|
||||
}
|
||||
if i + 1 >= shadow_stops.length() {
|
||||
return 0
|
||||
}
|
||||
let (t0, f0) = shadow_stops[i]
|
||||
let (t1, f1) = shadow_stops[i + 1]
|
||||
let f = f0 + (f1 - f0) * ((t - t0) / (t1 - t0))
|
||||
(max_a.to_double() * f + 0.5).to_int().clamp(min=0, max=255)
|
||||
}
|
||||
|
||||
///| A soft shadow all round a frame `w` x `h` with rounded top corners (`radius`) and square
|
||||
/// bottom ones, drawn in 2px bands out to `flat_shadow`. The straight edges are 1-band rows and
|
||||
/// columns; each corner stacks translucent rounded rectangles inside a square clip, so their sum
|
||||
/// fades with the distance from the corner's arc (the radial gradients of decoration.svg).
|
||||
/// Everything is plain spans: cheap for the software rasterisers.
|
||||
fn push_flat_shadow(ops : Array[DrawOp], w : Int, h : Int, radius : Int, max_a : Int) -> Unit {
|
||||
let step = 2
|
||||
let bands = flat_shadow / step
|
||||
// Opacity of band k (1 = next to the outline), and of the layer that adds it over band k + 1.
|
||||
let total = Array::make(bands + 2, 0)
|
||||
for k = 1; k <= bands; k = k + 1 {
|
||||
total[k] = shadow_alpha(max_a, (k.to_double() - 0.5) / bands.to_double())
|
||||
}
|
||||
let layer = Array::make(bands + 2, 0)
|
||||
for k = 1; k <= bands; k = k + 1 {
|
||||
let outer = 255 - total[k + 1]
|
||||
layer[k] = if outer <= 0 {
|
||||
0
|
||||
} else {
|
||||
(255.0 * (1.0 - (255 - total[k]).to_double() / outer.to_double()) + 0.5).to_int().clamp(min=0, max=255)
|
||||
}
|
||||
}
|
||||
let black = fn(a : Int) { Rgba::new(0, 0, 0, a) }
|
||||
// Edges.
|
||||
for k = 1; k <= bands; k = k + 1 {
|
||||
let c = black(total[k])
|
||||
if total[k] == 0 {
|
||||
continue
|
||||
}
|
||||
let d = k * step
|
||||
ops.push(FillRect(Rect::new(radius, -d, w - 2 * radius, step), c, 0))
|
||||
ops.push(FillRect(Rect::new(0, h + d - step, w, step), c, 0))
|
||||
ops.push(FillRect(Rect::new(-d, radius, step, h - radius), c, 0))
|
||||
ops.push(FillRect(Rect::new(w + d - step, radius, step, h - radius), c, 0))
|
||||
}
|
||||
// Corners: top ones round about the outline's arc, bottom ones about the square corner.
|
||||
let reach = flat_shadow
|
||||
let corners = [
|
||||
(Rect::new(-reach, -reach, reach + radius, reach + radius), radius),
|
||||
(Rect::new(w - radius, -reach, reach + radius, reach + radius), radius),
|
||||
(Rect::new(-reach, h, reach, reach), 0),
|
||||
(Rect::new(w, h, reach, reach), 0),
|
||||
]
|
||||
for corner in corners {
|
||||
let (clip, r0) = corner
|
||||
ops.push(PushClip(clip))
|
||||
for k = bands; k >= 1; k = k - 1 {
|
||||
if layer[k] > 0 {
|
||||
let d = k * step
|
||||
ops.push(FillRect(Rect::new(-d, -d, w + 2 * d, h + 2 * d), black(layer[k]), r0 + d))
|
||||
}
|
||||
}
|
||||
ops.push(PopClip)
|
||||
}
|
||||
}
|
||||
|
||||
///| The Breeze frame's drop shadow, offset 4px right and 6px down; only the strips that stick
|
||||
/// out from under the window (and the part under the translucent title bar) are blended.
|
||||
fn push_breeze_shadow(ops : Array[DrawOp], w : Int, h : Int, top : Int) -> Unit {
|
||||
let shadow = Rect::new(4, 6, w, h)
|
||||
let col = Rgba::new(0, 0, 0, 80)
|
||||
for strip in [Rect::new(w, 0, 4, h + 6), Rect::new(0, h, w + 4, 6), Rect::new(0, 0, w, top + 2)] {
|
||||
ops.push(PushClip(strip))
|
||||
ops.push(FillRect(shadow, col, 8))
|
||||
ops.push(PopClip)
|
||||
}
|
||||
}
|
||||
|
||||
///| Shorten `label` with ".." until `text_w` says it fits in `max_w` pixels ("" if nothing does).
|
||||
fn fit_title(label : String, max_w : Int, text_w : (String) -> Int) -> String {
|
||||
if text_w(label) <= max_w {
|
||||
return label
|
||||
}
|
||||
let chars = label.to_array()
|
||||
let mut n = chars.length() - 1
|
||||
while n > 0 {
|
||||
let s = String::from_array(chars[:n]) + ".."
|
||||
if text_w(s) <= max_w {
|
||||
return s
|
||||
}
|
||||
n = n - 1
|
||||
}
|
||||
""
|
||||
}
|
||||
|
||||
///| A window's frame (title bar, outline, shadow and buttons) in `style`, as draw ops in the
|
||||
/// coordinates of its outer box (`outer_w` x `outer_h`: the client plus `style`'s frame), and the
|
||||
/// frame's insets (top, right, bottom, left). `text_w(s, size, bold)` measures title text.
|
||||
pub fn build_window_decoration(
|
||||
style : WindowStyle,
|
||||
d : DecorationState,
|
||||
outer_w : Int,
|
||||
outer_h : Int,
|
||||
tokens : ThemeTokens,
|
||||
text_w : (String, Int, Bool) -> Int,
|
||||
) -> ((Int, Int, Int, Int), Array[DrawOp]) {
|
||||
match style {
|
||||
Breeze => {
|
||||
let (insets, deco) = build_breeze_decoration(d.title, d.app_id, d.focused, false, outer_w, outer_h, tokens)
|
||||
let ops : Array[DrawOp] = []
|
||||
push_breeze_shadow(ops, outer_w, outer_h, insets.0)
|
||||
// Hover / pressed: a ring around the button, in the accent colour while pressed.
|
||||
for b in style.buttons(outer_w) {
|
||||
let (id, r, _) = b
|
||||
if id == d.pressed {
|
||||
deco.push(StrokeRect(Rect::new(r.x - 1, r.y - 1, r.w + 2, r.h + 2), tokens.palette.accent, 2, 10))
|
||||
} else if id == d.hover {
|
||||
deco.push(StrokeRect(Rect::new(r.x - 1, r.y - 1, r.w + 2, r.h + 2), tokens.palette.foreground_muted, 1, 10))
|
||||
}
|
||||
}
|
||||
ops.append(deco)
|
||||
(insets, ops)
|
||||
}
|
||||
Flat => build_flat_decoration(d, outer_w, outer_h, tokens, text_w)
|
||||
}
|
||||
}
|
||||
|
||||
///| Flatkit's frame (see `WindowStyle::Flat`). Maximized: no shadow and square corners.
|
||||
fn build_flat_decoration(
|
||||
d : DecorationState,
|
||||
w : Int,
|
||||
h : Int,
|
||||
tokens : ThemeTokens,
|
||||
text_w : (String, Int, Bool) -> Int,
|
||||
) -> ((Int, Int, Int, Int), Array[DrawOp]) {
|
||||
let c = flat_colors(tokens.is_dark())
|
||||
let top = flat_title_h
|
||||
let radius = if d.maximized { 0 } else { flat_radius }
|
||||
let ops : Array[DrawOp] = []
|
||||
if !d.maximized {
|
||||
push_flat_shadow(ops, w, h, radius, if d.focused { c.shadow } else { c.shadow_inactive })
|
||||
}
|
||||
// Title bar inside its outline: two rounded fills, clipped to the title bar so nothing is
|
||||
// drawn under the client (a translucent client shows what is behind it, not the frame).
|
||||
ops.push(PushClip(Rect::new(0, 0, w, top)))
|
||||
ops.push(FillRect(Rect::new(0, 0, w, top + radius), c.border, radius))
|
||||
ops.push(FillRect(Rect::new(1, 1, w - 2, top + radius), c.background, if radius > 1 { radius - 1 } else { 0 }))
|
||||
ops.push(PopClip)
|
||||
// The hairline under the title, then the outline down the sides and along the bottom.
|
||||
ops.push(FillRect(Rect::new(1, top - 1, w - 2, 1), c.border, 0))
|
||||
ops.push(FillRect(Rect::new(0, top, 1, h - top), c.border, 0))
|
||||
ops.push(FillRect(Rect::new(w - 1, top, 1, h - top), c.border, 0))
|
||||
ops.push(FillRect(Rect::new(1, h - 1, w - 2, 1), c.border, 0))
|
||||
|
||||
// Buttons: nothing behind the glyph at rest, the hover / pressed fill under the pointer.
|
||||
let buttons = WindowStyle::Flat.buttons(w)
|
||||
for b in buttons {
|
||||
let (id, r, _) = b
|
||||
let close = id == 3
|
||||
let state = if id == d.pressed { 2 } else if id == d.hover { 1 } else { 0 }
|
||||
let fill = match (state, close) {
|
||||
(1, true) => Some(c.danger)
|
||||
(2, true) => Some(c.danger_hover)
|
||||
(1, false) => Some(c.hover)
|
||||
(2, false) => Some(c.pressed)
|
||||
_ => None
|
||||
}
|
||||
match fill {
|
||||
Some(col) => ops.push(FillRect(r, col, 6))
|
||||
None => ()
|
||||
}
|
||||
let fg = if close && state > 0 {
|
||||
c.on_danger
|
||||
} else if d.focused || state > 0 {
|
||||
c.text
|
||||
} else {
|
||||
c.text_dim
|
||||
}
|
||||
push_flat_glyph(ops, id, d.maximized, r.x, r.y, fg)
|
||||
}
|
||||
|
||||
// Title: centred on the whole bar while it fits between the buttons on both sides, else
|
||||
// shortened and left of the buttons.
|
||||
let size = if tokens.font_size > 1 { tokens.font_size - 1 } else { tokens.font_size }
|
||||
let fg = if d.focused { c.text } else { c.text_dim }
|
||||
let label = if d.title.length() > 0 { d.title } else { d.app_id }
|
||||
let first_btn = buttons[0].1.x
|
||||
let side = w - first_btn + 8
|
||||
let measure = fn(s : String) { text_w(s, size, true) }
|
||||
let tw = measure(label)
|
||||
let cy = top / 2
|
||||
if tw <= w - 2 * side {
|
||||
ops.push(Text(w / 2, cy, label, size, fg, Center, true))
|
||||
} else {
|
||||
let shown = fit_title(label, first_btn - 8 - 12, measure)
|
||||
if shown.length() > 0 {
|
||||
ops.push(Text(12, cy, shown, size, fg, Left, true))
|
||||
}
|
||||
}
|
||||
((top, 1, 1, 1), ops)
|
||||
}
|
||||
|
||||
///| A button glyph in its 24px box at (x, y): the 1.5px line icons of aurorae/generate.py, as
|
||||
/// 1px lines with a faint second line beside them for the half pixel.
|
||||
fn push_flat_glyph(ops : Array[DrawOp], id : Int, maximized : Bool, x : Int, y : Int, fg : Rgba) -> Unit {
|
||||
let soft = fg.with_alpha(fg.a.to_int() * 2 / 5)
|
||||
match id {
|
||||
1 => {
|
||||
ops.push(FillRect(Rect::new(x + 8, y + 12, 9, 1), fg, 0))
|
||||
ops.push(FillRect(Rect::new(x + 8, y + 13, 9, 1), soft, 0))
|
||||
}
|
||||
2 =>
|
||||
if maximized {
|
||||
// Restore: a front square and the corner of one behind it.
|
||||
ops.push(StrokeRect(Rect::new(x + 7, y + 9, 8, 8), fg, 1, 2))
|
||||
ops.push(StrokeRect(Rect::new(x + 8, y + 10, 6, 6), soft, 1, 1))
|
||||
ops.push(FillRect(Rect::new(x + 10, y + 7, 6, 1), fg, 0))
|
||||
ops.push(FillRect(Rect::new(x + 17, y + 8, 1, 6), fg, 0))
|
||||
ops.push(FillRect(Rect::new(x + 16, y + 7, 1, 1), soft, 0))
|
||||
ops.push(FillRect(Rect::new(x + 10, y + 8, 6, 1), soft, 0))
|
||||
ops.push(FillRect(Rect::new(x + 16, y + 8, 1, 6), soft, 0))
|
||||
} else {
|
||||
ops.push(StrokeRect(Rect::new(x + 7, y + 7, 10, 10), fg, 1, 2))
|
||||
ops.push(StrokeRect(Rect::new(x + 8, y + 8, 8, 8), soft, 1, 1))
|
||||
}
|
||||
_ => {
|
||||
ops.push(Line(x + 8, y + 8, x + 16, y + 16, fg, 1))
|
||||
ops.push(Line(x + 16, y + 8, x + 8, y + 16, fg, 1))
|
||||
ops.push(Line(x + 9, y + 8, x + 16, y + 15, soft, 1))
|
||||
ops.push(Line(x + 8, y + 9, x + 15, y + 16, soft, 1))
|
||||
ops.push(Line(x + 15, y + 8, x + 8, y + 15, soft, 1))
|
||||
ops.push(Line(x + 16, y + 9, x + 9, y + 16, soft, 1))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -155,6 +155,8 @@ pub(all) enum ShellAction {
|
||||
Logout
|
||||
/// The Dark mode setting changed: the compositor swaps the theme (see `dark_mode`).
|
||||
ThemeChanged
|
||||
/// The Flat window frames setting changed: the compositor redraws frames in the new style.
|
||||
WindowStyleChanged
|
||||
/// The password dialog setting changed: the compositor registers its polkit agent or leaves.
|
||||
AuthAgentChanged
|
||||
/// The screenshot module asked for a screenshot or recording (code: see the compositor's
|
||||
@@ -294,6 +296,9 @@ pub(all) struct DesktopShell {
|
||||
mut render_choice : RenderMode?
|
||||
/// Dark mode (the configured theme) or light (Moon Day); saved as `:theme :light` when off.
|
||||
mut dark_mode : Bool
|
||||
/// How window frames look (Flat window frames on: Flatkit's; off: the classic Breeze-like
|
||||
/// one); saved as `:window-style :breeze` when off. The compositor follows it.
|
||||
mut window_style : @scene.WindowStyle
|
||||
/// Power: minutes without input before the login session turns the screen off / suspends
|
||||
/// (0: never). Saved in state.edn as :power {:screen-off 10 :suspend 0} when not the defaults.
|
||||
mut screen_off_min : Int
|
||||
@@ -466,6 +471,7 @@ pub fn DesktopShell::new(display : String) -> DesktopShell {
|
||||
render_forced: false,
|
||||
render_choice: None,
|
||||
dark_mode: true,
|
||||
window_style: @scene.WindowStyle::Flat,
|
||||
screen_off_min: default_screen_off_min,
|
||||
suspend_min: default_suspend_min,
|
||||
shortcuts: Shortcuts::defaults(),
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
/// :desktop-card {:x 900 :y 24} ; where the desktop card was dragged to (absent: default spot)
|
||||
/// :wallpaper :aurora ; the settings module's wallpaper (absent: :plasma-glow)
|
||||
/// :theme :light ; the settings module's Dark mode switch is off (absent: dark)
|
||||
/// :window-style :breeze ; Flat window frames is off: the classic frame (absent: :flat)
|
||||
/// :power {:screen-off 5 :suspend 30} ; minutes without input before the screen goes off /
|
||||
/// ; the computer suspends, 0 never (absent: 10 and 0)
|
||||
/// :shortcuts {:show-desktop "Super+Ctrl+D" :screenshot-full ""}
|
||||
@@ -53,6 +54,8 @@ pub(all) struct SavedState {
|
||||
native_auth_agent : Bool?
|
||||
/// From `:render`: :software or :hardware chosen in Settings (absent: as detected).
|
||||
render : RenderMode?
|
||||
/// From `:window-style`: :flat or :breeze (absent: flat).
|
||||
window_style : @scene.WindowStyle?
|
||||
}
|
||||
|
||||
///|
|
||||
@@ -66,7 +69,7 @@ let layout_names : Array[String] = ["tiling", "monocle", "floating"]
|
||||
///| The keys this build owns; everything else in the file is kept as it is.
|
||||
let owned_keys : Array[String] = [
|
||||
"layout", "recent", "desktop-card", "windows", "wallpaper", "restore-session", "remember-windows",
|
||||
"theme", "power", "shortcuts", "terminal", "auth-agent", "render",
|
||||
"theme", "power", "shortcuts", "terminal", "auth-agent", "render", "window-style",
|
||||
]
|
||||
|
||||
///| How state.edn names each wallpaper, in `@libshell.wallpaper_names` order.
|
||||
@@ -116,6 +119,7 @@ pub fn DesktopShell::load_state(self : DesktopShell) -> SavedState {
|
||||
terminal: None,
|
||||
native_auth_agent: None,
|
||||
render: None,
|
||||
window_style: None,
|
||||
}
|
||||
}
|
||||
let entries = read_state_file()
|
||||
@@ -253,6 +257,22 @@ pub fn DesktopShell::load_state(self : DesktopShell) -> SavedState {
|
||||
}
|
||||
_ => []
|
||||
},
|
||||
window_style: match lookup_key(entries, "window-style") {
|
||||
None => None
|
||||
Some(Keyword(k)) | Some(Text(k)) =>
|
||||
match @scene.WindowStyle::parse(k) {
|
||||
Some(st) => Some(st)
|
||||
None => {
|
||||
@sys.log("chandra: state.edn: unknown :window-style :" + k +
|
||||
" (use :flat or :breeze); keeping the flat frame. Pick one in Settings > Session.")
|
||||
None
|
||||
}
|
||||
}
|
||||
Some(_) => {
|
||||
@sys.log("chandra: state.edn: :window-style must be :flat or :breeze; keeping the flat frame.")
|
||||
None
|
||||
}
|
||||
},
|
||||
dark_mode: match lookup_key(entries, "theme") {
|
||||
Some(Keyword("light")) => Some(false)
|
||||
Some(Keyword("dark")) => Some(true)
|
||||
@@ -282,6 +302,13 @@ pub fn DesktopShell::apply_state(self : DesktopShell, st : SavedState) -> Unit {
|
||||
Some(b) => self.dark_mode = b
|
||||
None => ()
|
||||
}
|
||||
match st.window_style {
|
||||
Some(w) if w != self.window_style => {
|
||||
self.window_style = w
|
||||
self.actions.push(WindowStyleChanged)
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
match st.power.0 {
|
||||
Some(m) if m >= 0 => self.screen_off_min = m
|
||||
_ => ()
|
||||
@@ -406,6 +433,9 @@ pub fn DesktopShell::save_state(self : DesktopShell) -> Unit {
|
||||
if !self.dark_mode {
|
||||
entries.insert(2, (@edn.Value::Keyword("theme"), @edn.Value::Keyword("light")))
|
||||
}
|
||||
if self.window_style != @scene.WindowStyle::Flat {
|
||||
entries.insert(2, (@edn.Value::Keyword("window-style"), @edn.Value::Keyword(self.window_style.name())))
|
||||
}
|
||||
if !self.remember_windows {
|
||||
entries.insert(2, (@edn.Value::Keyword("remember-windows"), @edn.Value::Bool(false)))
|
||||
}
|
||||
|
||||
@@ -760,7 +760,7 @@ pub fn DesktopShell::set_wallpaper(self : DesktopShell, i : Int) -> Unit {
|
||||
///| The session settings the session settings module lists, in index order.
|
||||
let session_setting_names : Array[String] = [
|
||||
"Reopen windows at login", "Remember window positions", "Dark mode", "Chandra password dialog",
|
||||
render_setting_name,
|
||||
render_setting_name, "Flat window frames",
|
||||
]
|
||||
|
||||
///| The rendering switch (its label is made by `render_setting_label`).
|
||||
@@ -777,7 +777,8 @@ fn DesktopShell::session_settings_bits(self : DesktopShell) -> Int {
|
||||
(if self.remember_windows { 2 } else { 0 }) |
|
||||
(if self.dark_mode { 4 } else { 0 }) |
|
||||
(if self.native_auth_agent { 8 } else { 0 }) |
|
||||
(if self.software_render() { 16 } else { 0 })
|
||||
(if self.software_render() { 16 } else { 0 }) |
|
||||
(if self.window_style == @scene.WindowStyle::Flat { 32 } else { 0 })
|
||||
}
|
||||
|
||||
///| Turn session setting `i` on or off (ignored when out of range) and remember it in state.edn.
|
||||
@@ -796,6 +797,13 @@ pub fn DesktopShell::set_session_setting(self : DesktopShell, i : Int, on : Bool
|
||||
self.actions.push(AuthAgentChanged)
|
||||
}
|
||||
4 => self.choose_software_render(on)
|
||||
5 => {
|
||||
let style = if on { @scene.WindowStyle::Flat } else { @scene.WindowStyle::Breeze }
|
||||
if self.window_style != style {
|
||||
self.window_style = style
|
||||
self.actions.push(WindowStyleChanged)
|
||||
}
|
||||
}
|
||||
_ => return
|
||||
}
|
||||
@wasm.publish_session_settings(self.session_settings_bits())
|
||||
|
||||
Reference in new issue
Block a user