From 86bdbfcd1c66937cdf7ce4a2b49ad2f854842294 Mon Sep 17 00:00:00 2001 From: AgentSeal Date: Sat, 18 Apr 2026 03:44:32 -0700 Subject: [PATCH] fix(desktop): anchor popover to top-right using configured width window.outer_size() returns (0, 0) on the first show, so the previous positioning snapped to top-left when the window had not been rendered yet. Derive the target x from the popover width declared in tauri.conf.json and scale margins by the monitor's scale factor so HiDPI displays land in the right spot. --- desktop/src-tauri/src/lib.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/desktop/src-tauri/src/lib.rs b/desktop/src-tauri/src/lib.rs index d46dc98..06a64b8 100644 --- a/desktop/src-tauri/src/lib.rs +++ b/desktop/src-tauri/src/lib.rs @@ -125,19 +125,22 @@ fn toggle_popover(app: &AppHandle) { /// so there is no reliable anchor to attach to. Top-right keeps the window visually /// close to the StatusNotifier area on every desktop we target (GNOME, KDE, Unity). fn position_popover_top_right(window: &tauri::WebviewWindow) { - const MARGIN_PX: u32 = 12; - const TOP_PANEL_PX: u32 = 36; + // Matches desktop/src-tauri/tauri.conf.json popover width (logical pixels). + const POPOVER_WIDTH_LOGICAL: f64 = 360.0; + const MARGIN_LOGICAL: f64 = 12.0; + const TOP_PANEL_LOGICAL: f64 = 36.0; let Ok(Some(monitor)) = window.primary_monitor() else { return; }; - let Ok(size) = window.outer_size() else { - return; - }; + let scale = monitor.scale_factor(); + let popover_w = (POPOVER_WIDTH_LOGICAL * scale) as u32; + let margin = (MARGIN_LOGICAL * scale) as u32; + let panel = (TOP_PANEL_LOGICAL * scale) as u32; let screen = monitor.size(); - let x = screen.width.saturating_sub(size.width).saturating_sub(MARGIN_PX); - let y = TOP_PANEL_PX; - let _ = window.set_position(tauri::PhysicalPosition::new(x, y)); + let x = screen.width.saturating_sub(popover_w).saturating_sub(margin); + let y = panel; + let _ = window.set_position(tauri::PhysicalPosition::new(x as i32, y as i32)); } mod commands {