Remove tint from hovered area

This commit is contained in:
entailz 2026-04-28 14:58:36 -07:00
parent 9a09eea348
commit 7ff9399178

View file

@ -38,7 +38,6 @@ const C_SEL: [u8; 4] = [0x00, 0x00, 0x00, 0x00];
const C_BDR: [u8; 4] = [0x00, 0x00, 0x00, 0xFF];
const DEFAULT_HINT: [u8; 4] = [0x40, 0x40, 0x40, 0x40];
const DEFAULT_HOV: [u8; 4] = [0x80, 0x80, 0x80, 0x80];
fn rgba_to_bgra_premult(rgba: u32) -> [u8; 4] {
let r = ((rgba >> 24) & 0xFF) as u8;
@ -49,15 +48,6 @@ fn rgba_to_bgra_premult(rgba: u32) -> [u8; 4] {
[pm(b), pm(g), pm(r), a]
}
fn derive_hover(rgba: u32) -> [u8; 4] {
let r = ((rgba >> 24) & 0xFF) as u32;
let g = ((rgba >> 16) & 0xFF) as u32;
let b = ((rgba >> 8) & 0xFF) as u32;
let a = ((rgba & 0xFF) as u32 * 2).min(255);
let pm = |c: u32| -> u8 { ((c * a) / 255) as u8 };
[pm(b), pm(g), pm(r), a as u8]
}
const BDR: i32 = 2;
pub struct HintBox {
@ -132,7 +122,6 @@ struct St {
hover: Option<usize>,
restrict: bool,
c_hint: [u8; 4],
c_hov: [u8; 4],
running: bool,
result: Option<Geometry>,
@ -376,7 +365,6 @@ impl St {
let buf_size = s.buf_size;
let c_hint = self.c_hint;
let c_hov = self.c_hov;
let box_data: Vec<(i32, i32, i32, i32, bool)> = self
.boxes
.iter()
@ -399,17 +387,11 @@ impl St {
let bx1 = ((bx + bw - lx) * scale).max(0).min(pw);
let by1 = ((by + bh - ly) * scale).max(0).min(ph);
if bx0 < bx1 && by0 < by1 {
fill(
data,
stride,
bx0,
by0,
bx1,
by1,
if *is_hov { c_hov } else { c_hint },
);
if *is_hov {
fill(data, stride, bx0, by0, bx1, by1, C_SEL);
draw_border(data, stride, pw, ph, bx0, by0, bx1, by1, BDR * scale, C_BDR);
} else {
fill(data, stride, bx0, by0, bx1, by1, c_hint);
}
}
}
@ -842,9 +824,9 @@ pub fn select_region(
.bind::<WpCursorShapeManagerV1, _, _>(&qh, 1..=1, ())
.ok();
let (c_hint, c_hov) = match hint_rgba {
Some(rgba) => (rgba_to_bgra_premult(rgba), derive_hover(rgba)),
None => (DEFAULT_HINT, DEFAULT_HOV),
let c_hint = match hint_rgba {
Some(rgba) => rgba_to_bgra_premult(rgba),
None => DEFAULT_HINT,
};
let mut st = St {
@ -872,7 +854,6 @@ pub fn select_region(
hover: None,
restrict,
c_hint,
c_hov,
running: true,
result: None,
};