Skip to content

A lightweight, macOS-style dock for Windows 11, with glass visuals, smooth magnification, and Genie effect.

feat(dock): improve window preview handling during diagonal movement

CristianOlivera1943987342265
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 27a3020..13c8b5a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,9 @@ copia la sección de la versión que se publica a la release de GitHub.
### English
+- Fixed window previews disappearing while moving diagonally from the Dock icon
+ towards an outer card. The handoff area follows the picker width on every Dock
+ edge and delayed mouse-leave messages no longer cancel a newer hover.
- The music/video popup now shows playback progress and elapsed/total time when
provided by the player. The speaker button on its right opens a vertical volume
capsule beside the player, with mute at the bottom. Timeline events and the
@@ -22,6 +25,9 @@ copia la sección de la versión que se publica a la release de GitHub.
### Español
+- Corregido el cierre de previsualizaciones al ir en diagonal desde el icono
+ hacia una miniatura lateral. La zona de paso se adapta al selector en cada
+ borde del Dock; las salidas tardías del ratón no cancelan un hover más reciente.
- El popup de música/vídeo muestra el progreso y los tiempos transcurrido/total
cuando el reproductor los proporciona. El icono de audio a la derecha abre una
cápsula de volumen vertical junto al panel, con silencio debajo. Se detiene el
diff --git a/apps/dock/src/app.rs b/apps/dock/src/app.rs
index b19be49..0e90fe3 100644
--- a/apps/dock/src/app.rs
+++ b/apps/dock/src/app.rs
@@ -2239,6 +2239,19 @@ impl App {
}
}
+ fn on_tracked_mouse_leave(&mut self) -> Result<()> {
+ let mut point = POINT::default();
+ // Moving/resizing the magnified input area can queue a leave before
+ // the pointer re-enters. Do not discard a newer hover/dwell on delivery.
+ if unsafe { GetCursorPos(&mut point) }.is_ok()
+ && unsafe { windows::Win32::UI::WindowsAndMessaging::WindowFromPoint(point) }
+ == self.input
+ {
+ return self.on_mouse_move();
+ }
+ self.on_mouse_leave()
+ }
+
fn on_mouse_leave(&mut self) -> Result<()> {
if !self.hovering || self.drag.is_some() || self.drag_over || self.menu_open {
return Ok(());
@@ -5061,6 +5074,7 @@ pub fn multi_window_view_tick() {
&& !view.tick()?
{
app.close_preview();
+ app.render()?;
}
Ok(())
});
@@ -5136,7 +5150,7 @@ pub fn multi_window_view_scroll(previous: bool) {
pub fn multi_window_view_dismiss() {
with_app("cerrar vistas", |app| {
app.close_preview();
- Ok(())
+ app.render()
});
}
@@ -5484,7 +5498,7 @@ unsafe extern "system" fn wndproc(hwnd: HWND, msg: u32, w: WPARAM, l: LPARAM) ->
with_app("iconos del shell", App::assets_ready);
}
WM_MOUSEMOVE => with_app("movimiento del ratón", App::on_mouse_move),
- WM_MOUSELEAVE => with_app("salida del ratón", App::on_mouse_leave),
+ WM_MOUSELEAVE => with_app("salida del ratón", App::on_tracked_mouse_leave),
WM_LBUTTONDOWN => with_app("pulsación", App::on_press),
WM_LBUTTONUP => with_app_then("clic", App::on_release),
WM_MBUTTONUP => with_app_then("clic central", App::on_middle_click),
diff --git a/apps/dock/src/multi_window_view.rs b/apps/dock/src/multi_window_view.rs
index 7563821..0d77ac5 100644
--- a/apps/dock/src/multi_window_view.rs
+++ b/apps/dock/src/multi_window_view.rs
@@ -153,26 +153,51 @@ impl MultiWindowLayout {
if contains(self.bounds, point) || contains(anchor, point) {
return true;
}
- // A bridge between the source icon and the view lets the pointer reach
- // it without keeping the popup open over unrelated applications.
- let bridge = match self.edge {
- DockEdge::Bottom => RECT {
- top: self.bounds.bottom.min(anchor.top),
- ..anchor
- },
- DockEdge::Left => RECT {
- right: self.bounds.left.max(anchor.right),
- ..anchor
- },
- DockEdge::Right => RECT {
- left: self.bounds.right.min(anchor.left),
- ..anchor
- },
- };
- contains(bridge, point)
+ // Widen towards the whole picker: a diagonal path to an outer card
+ // must stay connected, even when the picker is clamped to a screen edge.
+ // The narrow end still belongs only to the source icon.
+ match self.edge {
+ DockEdge::Bottom => in_handoff(
+ (point.x, point.y),
+ (anchor.left, anchor.right),
+ (self.bounds.left, self.bounds.right),
+ (anchor.top, self.bounds.bottom),
+ ),
+ DockEdge::Left => in_handoff(
+ (point.y, point.x),
+ (anchor.top, anchor.bottom),
+ (self.bounds.top, self.bounds.bottom),
+ (anchor.right, self.bounds.left),
+ ),
+ DockEdge::Right => in_handoff(
+ (point.y, point.x),
+ (anchor.top, anchor.bottom),
+ (self.bounds.top, self.bounds.bottom),
+ (anchor.left, self.bounds.right),
+ ),
+ }
}
}
+fn in_handoff(
+ point: (i32, i32),
+ source: (i32, i32),
+ picker: (i32, i32),
+ faces: (i32, i32),
+) -> bool {
+ let distance = f64::from(faces.1) - f64::from(faces.0);
+ if distance == 0.0 {
+ return false;
+ }
+ let t = (f64::from(point.1) - f64::from(faces.0)) / distance;
+ if !(0.0..=1.0).contains(&t) {
+ return false;
+ }
+ let left = f64::from(source.0) + (f64::from(picker.0) - f64::from(source.0)) * t;
+ let right = f64::from(source.1) + (f64::from(picker.1) - f64::from(source.1)) * t;
+ f64::from(point.0) >= left && f64::from(point.0) < right
+}
+
fn contains(rect: RECT, point: POINT) -> bool {
point.x >= rect.left && point.x < rect.right && point.y >= rect.top && point.y < rect.bottom
}
@@ -599,9 +624,7 @@ impl MultiWindowView {
/// Returns false after Escape, an outside click, or leaving the view/icon bridge.
pub fn tick(&mut self) -> Result<bool> {
- if tracker::foreground_window() != self.foreground {
- return Ok(false);
- }
+ let foreground = tracker::foreground_window();
let mut point = POINT::default();
// SAFETY: Read-only pointer/key state queries; no global input hook.
let (escape, mouse_down) = unsafe {
@@ -611,6 +634,20 @@ impl MultiWindowView {
GetAsyncKeyState(i32::from(VK_LBUTTON.0)) < 0,
)
};
+ self.tick_at(point, foreground, escape, mouse_down, Instant::now())
+ }
+
+ fn tick_at(
+ &mut self,
+ point: POINT,
+ foreground: isize,
+ escape: bool,
+ mouse_down: bool,
+ now: Instant,
+ ) -> Result<bool> {
+ if foreground != self.foreground {
+ return Ok(false);
+ }
let inside = self.layout.keeps_open(self.anchor, point);
if escape || (mouse_down && !self.mouse_was_down && !inside) {
return Ok(false);
@@ -618,7 +655,7 @@ impl MultiWindowView {
self.mouse_was_down = mouse_down;
if inside {
self.left_at = None;
- } else if self.left_at.get_or_insert_with(Instant::now).elapsed() >= LEAVE_DELAY {
+ } else if now.saturating_duration_since(*self.left_at.get_or_insert(now)) >= LEAVE_DELAY {
return Ok(false);
}
self.update()?;
@@ -886,6 +923,38 @@ mod tests {
)?;
view.animated = false;
view.update()?;
+ let bounds = view.layout.bounds;
+ let source = view.anchor;
+ let diagonal = POINT {
+ x: ((source.left + source.right) / 2 + bounds.left + 18) / 2,
+ y: (source.top + bounds.bottom) / 2,
+ };
+ assert!(
+ diagonal.x < source.left,
+ "exercise a diagonal outside the old icon-width bridge"
+ );
+ let now = Instant::now();
+ assert!(view.tick_at(diagonal, view.foreground, false, false, now)?);
+ assert!(
+ view.tick_at(
+ diagonal,
+ view.foreground,
+ false,
+ false,
+ now + LEAVE_DELAY + Duration::from_secs(1)
+ )?,
+ "moving slowly to another card must not close the picker"
+ );
+ let outside = POINT {
+ x: bounds.right + 100,
+ y: bounds.bottom + 100,
+ };
+ let later = now + Duration::from_secs(2);
+ assert!(view.tick_at(outside, view.foreground, false, false, later)?);
+ assert!(!view.tick_at(outside, view.foreground, false, false, later + LEAVE_DELAY)?);
+ assert!(view.tick_at(diagonal, view.foreground, false, false, later + LEAVE_DELAY)?);
+ assert!(!view.tick_at(diagonal, view.foreground, true, false, later + LEAVE_DELAY)?);
+ assert!(!view.tick_at(outside, view.foreground, false, true, later + LEAVE_DELAY)?);
for (&source, rect) in windows.iter().zip(&view.layout.cards) {
let image = view
.thumbnails
@@ -1016,6 +1085,99 @@ mod tests {
}
}
+ #[test]
+ fn diagonal_paths_reach_each_preview_without_leaving_the_handoff_area() {
+ for scale in [1.0, 1.25, 2.0] {
+ for origin in [0, -1920] {
+ let screen = RECT {
+ left: origin,
+ top: -200,
+ right: origin + 1920,
+ bottom: 1080,
+ };
+ for (edge, anchor) in [
+ (
+ DockEdge::Bottom,
+ RECT {
+ left: origin + 160,
+ top: 950,
+ right: origin + 240,
+ bottom: 1030,
+ },
+ ),
+ (
+ DockEdge::Left,
+ RECT {
+ left: origin + 14,
+ top: 480,
+ right: origin + 94,
+ bottom: 560,
+ },
+ ),
+ (
+ DockEdge::Right,
+ RECT {
+ left: origin + 1826,
+ top: 480,
+ right: origin + 1906,
+ bottom: 560,
+ },
+ ),
+ ] {
+ let layout = MultiWindowLayout::new(screen, anchor, edge, scale, 3);
+ let b = layout.bounds;
+ for fraction in [0.1, 0.5, 0.9] {
+ let (source, target) = match edge {
+ DockEdge::Bottom => (
+ POINT {
+ x: (anchor.left + anchor.right) / 2,
+ y: anchor.top,
+ },
+ POINT {
+ x: b.left + ((b.right - b.left) as f32 * fraction) as i32,
+ y: b.bottom - 1,
+ },
+ ),
+ DockEdge::Left => (
+ POINT {
+ x: anchor.right - 1,
+ y: (anchor.top + anchor.bottom) / 2,
+ },
+ POINT {
+ x: b.left + 1,
+ y: b.top + ((b.bottom - b.top) as f32 * fraction) as i32,
+ },
+ ),
+ DockEdge::Right => (
+ POINT {
+ x: anchor.left,
+ y: (anchor.top + anchor.bottom) / 2,
+ },
+ POINT {
+ x: b.right - 1,
+ y: b.top + ((b.bottom - b.top) as f32 * fraction) as i32,
+ },
+ ),
+ };
+ for step in 0..=10 {
+ let t = step as f32 / 10.0;
+ let point = POINT {
+ x: (source.x as f32 + (target.x - source.x) as f32 * t).round()
+ as i32,
+ y: (source.y as f32 + (target.y - source.y) as f32 * t).round()
+ as i32,
+ };
+ assert!(
+ layout.keeps_open(anchor, point),
+ "edge={edge:?} scale={scale} target={fraction} step={step} point={point:?}"
+ );
+ }
+ }
+ }
+ }
+ }
+ }
+
#[test]
fn pointer_should_cross_gap_from_icon_without_dismissing() {
let anchor = RECT {