srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/crates/wayland/src/native_lock.rs
diff options
context:
space:
mode:
authorsrdusr <[email protected]>2025-02-15 14:56:00 +0200
committersrdusr <[email protected]>2025-02-15 14:56:00 +0200
commit0a4c4b5941fe982ccb3d3175e26d9d83f0025ffd (patch)
tree7672d0af277664f457c6c9462925c0005fe35dcf /crates/wayland/src/native_lock.rs
parent413daa7ba2ea0ebd1424c024fd0566423aaea3f8 (diff)
downloadsrdwm-0a4c4b5941fe982ccb3d3175e26d9d83f0025ffd.tar.gz
srdwm-0a4c4b5941fe982ccb3d3175e26d9d83f0025ffd.zip
Checkpoint: preserve all uncommitted rust-rewrite worktree work
Safety commit before reconciling this worktree with main, which has diverged with its own separate fixes today. Nothing here is reviewed or curated yet - this exists purely so none of this work can be lost to a git operation, disk issue, or worktree cleanup while that reconciliation happens.
Diffstat (limited to 'crates/wayland/src/native_lock.rs')
-rw-r--r--crates/wayland/src/native_lock.rs38
1 files changed, 27 insertions, 11 deletions
diff --git a/crates/wayland/src/native_lock.rs b/crates/wayland/src/native_lock.rs
index ef59ba6..31c4fc3 100644
--- a/crates/wayland/src/native_lock.rs
+++ b/crates/wayland/src/native_lock.rs
@@ -357,7 +357,7 @@ where
/// `blit_glyph`/`rgb_to_bgra`), promoted to `pub(crate)` there rather than
/// duplicated here.
fn render_ui_box(native: &NativeLock, theme: &srdwm_core::LockConfig) -> (Vec<u8>, (i32, i32)) {
- use crate::decoration::{blit_glyph, find_system_font, rgb_to_bgra, FONT_PIXELS, TEXT_LEFT_PADDING};
+ use crate::decoration::{blit_glyph, find_system_font, rgb_to_bgra, round_bottom_corners, round_top_corners, FONT_PIXELS, TEXT_LEFT_PADDING};
const WIDTH: usize = 360;
const HEIGHT: usize = 170;
@@ -408,18 +408,34 @@ fn render_ui_box(native: &NativeLock, theme: &srdwm_core::LockConfig) -> (Vec<u8
// Border, drawn last so it isn't overdrawn by any fill above --
// same convention `render_context_menu`/`render_snap_flyout` use.
+ // 2px, matching `ThemeConfig::default_border_width` - a 1px line at
+ // this box's size read as a thin, easy-to-miss hairline rather than a
+ // deliberate frame around the box.
+ const BORDER: usize = 2;
let border_px = rgb_to_bgra(theme.box_border, 255);
- for x in 0..WIDTH {
- buf[x * 4..x * 4 + 4].copy_from_slice(&border_px);
- let last_row = (HEIGHT - 1) * WIDTH + x;
- buf[last_row * 4..last_row * 4 + 4].copy_from_slice(&border_px);
- }
- for y in 0..HEIGHT {
- let left = y * WIDTH;
- buf[left * 4..left * 4 + 4].copy_from_slice(&border_px);
- let right = y * WIDTH + WIDTH - 1;
- buf[right * 4..right * 4 + 4].copy_from_slice(&border_px);
+ for t in 0..BORDER {
+ for x in 0..WIDTH {
+ buf[(t * WIDTH + x) * 4..(t * WIDTH + x) * 4 + 4].copy_from_slice(&border_px);
+ let row = (HEIGHT - 1 - t) * WIDTH + x;
+ buf[row * 4..row * 4 + 4].copy_from_slice(&border_px);
+ }
+ for y in 0..HEIGHT {
+ let left = y * WIDTH + t;
+ buf[left * 4..left * 4 + 4].copy_from_slice(&border_px);
+ let right = y * WIDTH + WIDTH - 1 - t;
+ buf[right * 4..right * 4 + 4].copy_from_slice(&border_px);
+ }
}
+ // Rounded, like every other srdwm-drawn surface (titlebar, window
+ // border) - `LockConfig::corner_radius` existed as a config field
+ // (default 10) already, but nothing here ever actually read it, so the
+ // lock box always rendered as a hard flat rectangle regardless of its
+ // value. Clipping after the border fill above means the corner pixels
+ // of that border get cut along with the background, the same "cut,
+ // don't stroke" treatment `render_titlebar`'s own corners get.
+ round_top_corners(&mut buf, WIDTH, HEIGHT, theme.corner_radius, theme.corner_radius as i32);
+ round_bottom_corners(&mut buf, WIDTH, HEIGHT, theme.corner_radius);
+
(buf, (WIDTH as i32, HEIGHT as i32))
}