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 {
|
||||
|
||||
Reference in new issue
Block a user