Remove tint from hovered area
This commit is contained in:
parent
9a09eea348
commit
7ff9399178
1 changed files with 6 additions and 25 deletions
|
|
@ -38,7 +38,6 @@ const C_SEL: [u8; 4] = [0x00, 0x00, 0x00, 0x00];
|
||||||
const C_BDR: [u8; 4] = [0x00, 0x00, 0x00, 0xFF];
|
const C_BDR: [u8; 4] = [0x00, 0x00, 0x00, 0xFF];
|
||||||
|
|
||||||
const DEFAULT_HINT: [u8; 4] = [0x40, 0x40, 0x40, 0x40];
|
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] {
|
fn rgba_to_bgra_premult(rgba: u32) -> [u8; 4] {
|
||||||
let r = ((rgba >> 24) & 0xFF) as u8;
|
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]
|
[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;
|
const BDR: i32 = 2;
|
||||||
|
|
||||||
pub struct HintBox {
|
pub struct HintBox {
|
||||||
|
|
@ -132,7 +122,6 @@ struct St {
|
||||||
hover: Option<usize>,
|
hover: Option<usize>,
|
||||||
restrict: bool,
|
restrict: bool,
|
||||||
c_hint: [u8; 4],
|
c_hint: [u8; 4],
|
||||||
c_hov: [u8; 4],
|
|
||||||
|
|
||||||
running: bool,
|
running: bool,
|
||||||
result: Option<Geometry>,
|
result: Option<Geometry>,
|
||||||
|
|
@ -376,7 +365,6 @@ impl St {
|
||||||
let buf_size = s.buf_size;
|
let buf_size = s.buf_size;
|
||||||
|
|
||||||
let c_hint = self.c_hint;
|
let c_hint = self.c_hint;
|
||||||
let c_hov = self.c_hov;
|
|
||||||
let box_data: Vec<(i32, i32, i32, i32, bool)> = self
|
let box_data: Vec<(i32, i32, i32, i32, bool)> = self
|
||||||
.boxes
|
.boxes
|
||||||
.iter()
|
.iter()
|
||||||
|
|
@ -399,17 +387,11 @@ impl St {
|
||||||
let bx1 = ((bx + bw - lx) * scale).max(0).min(pw);
|
let bx1 = ((bx + bw - lx) * scale).max(0).min(pw);
|
||||||
let by1 = ((by + bh - ly) * scale).max(0).min(ph);
|
let by1 = ((by + bh - ly) * scale).max(0).min(ph);
|
||||||
if bx0 < bx1 && by0 < by1 {
|
if bx0 < bx1 && by0 < by1 {
|
||||||
fill(
|
|
||||||
data,
|
|
||||||
stride,
|
|
||||||
bx0,
|
|
||||||
by0,
|
|
||||||
bx1,
|
|
||||||
by1,
|
|
||||||
if *is_hov { c_hov } else { c_hint },
|
|
||||||
);
|
|
||||||
if *is_hov {
|
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);
|
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, ())
|
.bind::<WpCursorShapeManagerV1, _, _>(&qh, 1..=1, ())
|
||||||
.ok();
|
.ok();
|
||||||
|
|
||||||
let (c_hint, c_hov) = match hint_rgba {
|
let c_hint = match hint_rgba {
|
||||||
Some(rgba) => (rgba_to_bgra_premult(rgba), derive_hover(rgba)),
|
Some(rgba) => rgba_to_bgra_premult(rgba),
|
||||||
None => (DEFAULT_HINT, DEFAULT_HOV),
|
None => DEFAULT_HINT,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut st = St {
|
let mut st = St {
|
||||||
|
|
@ -872,7 +854,6 @@ pub fn select_region(
|
||||||
hover: None,
|
hover: None,
|
||||||
restrict,
|
restrict,
|
||||||
c_hint,
|
c_hint,
|
||||||
c_hov,
|
|
||||||
running: true,
|
running: true,
|
||||||
result: None,
|
result: None,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue