From f5b8e40ce41605362b43d562928b7573253df219 Mon Sep 17 00:00:00 2001 From: Michael Aguiar Date: Thu, 3 Dec 2026 20:27:57 -0700 Subject: [PATCH 1/2] ALI-2649: Keep the bar and pointer hidden while the pointer rests on a video Hyprland sends the pointer's position again, unmoved, when what's under it changes: the control bar hiding, or the pointer itself hiding. Alias View took every pointer event as motion, so hiding them brought both straight back. The bar flashed every few seconds and the pointer never hid. A pointer event now counts as motion only when its position changed, or when the pointer comes back over the window. --- src/app.rs | 20 ++++++++++++++++++-- src/app/player_ui.rs | 16 ++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/app.rs b/src/app.rs index 13b7af5..061dcf7 100644 --- a/src/app.rs +++ b/src/app.rs @@ -75,6 +75,8 @@ pub struct App { text: Option, font_tried: bool, pointer: (f64, f64), + /// Whether the pointer is over the window, as far as its last event said. + pointer_in: bool, drag: Option<(f64, f64)>, pub playing: bool, pub anim_due: Option, @@ -149,6 +151,7 @@ impl App { text: None, font_tried: false, pointer: (0.0, 0.0), + pointer_in: false, drag: None, playing: true, anim_due: None, @@ -705,10 +708,23 @@ impl App { // Input. + /// Takes the pointer's place over the window, and says whether it moved. Hyprland + /// sends the pointer's place again, unmoved, when what's under it changes: the bar + /// hiding, or the pointer itself hiding. Taken as motion, that brought both straight + /// back, so a playing video never lost them. Coming back over the window counts as a + /// move even at the same place. + pub(super) fn pointer_moved(&mut self, x: f64, y: f64) -> bool { + let moved = !self.pointer_in || (x, y) != self.pointer; + (self.pointer, self.pointer_in) = ((x, y), true); + moved + } + pub fn input(&mut self, wl: &mut Wl, ev: Input) { if self.media.is_some() && self.grid.is_none() { - if let Input::Move { x, y } = ev { - self.pointer = (x * self.scale, y * self.scale); + match ev { + Input::Move { x, y } if !self.pointer_moved(x * self.scale, y * self.scale) => return, + Input::Leave => self.pointer_in = false, + _ => {} } if self.media_pointer(wl, &ev) { return; diff --git a/src/app/player_ui.rs b/src/app/player_ui.rs index a472829..6025543 100644 --- a/src/app/player_ui.rs +++ b/src/app/player_ui.rs @@ -779,6 +779,22 @@ mod tests { a } + #[test] + fn the_pointer_coming_again_to_the_same_place_is_not_motion() { + let t = Instant::now(); + let mut a = playing("clip.mp4", false, false); + assert!(a.pointer_moved(100.0, 80.0), "coming over the window counts"); + a.poke_controls(t); + a.expire_controls(t + motion::CONTROLS_HIDE); + assert!(a.pointer_hidden(), "hidden with the bar"); + // Hyprland repeats the place when the bar or the pointer hides. + assert!(!a.pointer_moved(100.0, 80.0), "the same place again isn't a move"); + assert!(a.pointer_hidden(), "so both stay hidden"); + assert!(a.pointer_moved(101.0, 80.0), "a real move is"); + a.pointer_in = false; + assert!(a.pointer_moved(101.0, 80.0), "back over the window counts, even at the same place"); + } + #[test] fn the_pointer_hides_with_the_bar_while_a_video_plays_and_motion_brings_it_back() { let t = Instant::now(); From dcda582d5516f4cdb591074619d668ba496cd78b Mon Sep 17 00:00:00 2001 From: Michael Aguiar Date: Thu, 3 Dec 2026 20:34:05 -0700 Subject: [PATCH 2/2] ALI-2649: Track the pointer in every view, and keep hover right when it stays put Review round 1: - The pointer's "over the window" state was only kept while a video or song was open, so leaving over the grid or a picture was missed. Every view now keeps it, through one App::pointer_moved that takes the raw event. - An unmoved event returned before the hover highlight was worked out, so a bar shown by a key press didn't highlight the control under a resting pointer. It now refreshes the hover without counting as motion. - The test goes through the raw event, so it covers scaling and leaving. --- src/app.rs | 30 ++++++++++++++++++++++-------- src/app/player_ui.rs | 27 +++++++++++++++++++++------ 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/src/app.rs b/src/app.rs index 061dcf7..0f76789 100644 --- a/src/app.rs +++ b/src/app.rs @@ -713,18 +713,32 @@ impl App { /// hiding, or the pointer itself hiding. Taken as motion, that brought both straight /// back, so a playing video never lost them. Coming back over the window counts as a /// move even at the same place. - pub(super) fn pointer_moved(&mut self, x: f64, y: f64) -> bool { - let moved = !self.pointer_in || (x, y) != self.pointer; - (self.pointer, self.pointer_in) = ((x, y), true); - moved + /// + /// Kept for every view, so a pointer that left over the grid still counts as coming + /// back once a video shows again. Events that aren't the pointer's count as moved. + pub(super) fn pointer_moved(&mut self, ev: &Input) -> bool { + match *ev { + Input::Move { x, y } => { + let p = (x * self.scale, y * self.scale); + let moved = !self.pointer_in || p != self.pointer; + (self.pointer, self.pointer_in) = (p, true); + moved + } + Input::Leave => { + self.pointer_in = false; + true + } + _ => true, + } } pub fn input(&mut self, wl: &mut Wl, ev: Input) { + let moved = self.pointer_moved(&ev); if self.media.is_some() && self.grid.is_none() { - match ev { - Input::Move { x, y } if !self.pointer_moved(x * self.scale, y * self.scale) => return, - Input::Leave => self.pointer_in = false, - _ => {} + if !moved { + // Not motion, but the bar may have come or gone under the pointer. + self.refresh_hover(); + return; } if self.media_pointer(wl, &ev) { return; diff --git a/src/app/player_ui.rs b/src/app/player_ui.rs index 6025543..184eb4e 100644 --- a/src/app/player_ui.rs +++ b/src/app/player_ui.rs @@ -343,6 +343,17 @@ impl App { self.a11y_dirty = true; } + /// Highlights the control under the pointer, if the bar is shown, without counting as + /// motion: for when the bar came or went while the pointer stayed put. + pub(super) fn refresh_hover(&mut self) { + let (x, y) = (self.pointer.0 as i32, self.pointer.1 as i32); + let hover = if self.controls.shown { self.bar_layout().and_then(|l| l.hit(x, y)) } else { None }; + if hover != self.controls.hover { + self.controls.hover = hover; + self.overlay_bar(); + } + } + /// The pointer, over a video or song. True if it was the player's. pub(super) fn media_pointer(&mut self, wl: &mut Wl, ev: &Input) -> bool { if self.media.is_none() || self.grid.is_some() { @@ -783,16 +794,20 @@ mod tests { fn the_pointer_coming_again_to_the_same_place_is_not_motion() { let t = Instant::now(); let mut a = playing("clip.mp4", false, false); - assert!(a.pointer_moved(100.0, 80.0), "coming over the window counts"); + a.scale = 2.0; + let at = |x, y| Input::Move { x, y }; + assert!(a.pointer_moved(&at(50.0, 40.0)), "coming over the window counts"); + assert_eq!(a.pointer, (100.0, 80.0), "kept in buffer pixels"); a.poke_controls(t); a.expire_controls(t + motion::CONTROLS_HIDE); assert!(a.pointer_hidden(), "hidden with the bar"); // Hyprland repeats the place when the bar or the pointer hides. - assert!(!a.pointer_moved(100.0, 80.0), "the same place again isn't a move"); - assert!(a.pointer_hidden(), "so both stay hidden"); - assert!(a.pointer_moved(101.0, 80.0), "a real move is"); - a.pointer_in = false; - assert!(a.pointer_moved(101.0, 80.0), "back over the window counts, even at the same place"); + assert!(!a.pointer_moved(&at(50.0, 40.0)), "the same place again isn't a move"); + a.refresh_hover(); + assert!(a.pointer_hidden() && !a.controls.shown, "so both stay hidden"); + assert!(a.pointer_moved(&at(50.5, 40.0)), "a real move is"); + assert!(a.pointer_moved(&Input::Leave)); + assert!(a.pointer_moved(&at(50.5, 40.0)), "back over the window counts, even at the same place"); } #[test]