diff --git a/Cargo.lock b/Cargo.lock index 214df5d..17d7544 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -38,7 +38,7 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "claude-code-usage-monitor" -version = "1.2.9" +version = "1.2.10" dependencies = [ "dirs", "native-tls", diff --git a/Cargo.toml b/Cargo.toml index 2bbc81f..eaa393d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "claude-code-usage-monitor" -version = "1.2.9" +version = "1.2.10" edition = "2021" license = "MIT" description = "Windows taskbar widget for monitoring Claude Code usage and rate limits" diff --git a/src/window.rs b/src/window.rs index 7d76600..441b741 100644 --- a/src/window.rs +++ b/src/window.rs @@ -1323,18 +1323,18 @@ fn position_at_taskbar() { let widget_width = total_widget_width(); let widget_height = sc(WIDGET_HEIGHT); + let y = compute_anchor_y(anchor_top, anchor_height, widget_height); if embedded { // Child window: coordinates relative to parent (taskbar) let x = tray_left - taskbar_rect.left - widget_width - tray_offset; - let y = (anchor_top - taskbar_rect.top) + (anchor_height - widget_height) / 2; - native_interop::move_window(hwnd, x, y, widget_width, widget_height); + native_interop::move_window(hwnd, x, y - taskbar_rect.top, widget_width, widget_height); diagnose::log(format!( - "positioned embedded widget at x={x} y={y} w={widget_width} h={widget_height}" + "positioned embedded widget at x={x} y={} w={widget_width} h={widget_height}", + y - taskbar_rect.top )); } else { // Topmost popup: screen coordinates let x = tray_left - widget_width - tray_offset; - let y = anchor_top + (anchor_height - widget_height) / 2; native_interop::move_window(hwnd, x, y, widget_width, widget_height); diagnose::log(format!( "positioned fallback widget at x={x} y={y} w={widget_width} h={widget_height}" @@ -1342,6 +1342,12 @@ fn position_at_taskbar() { } } +fn compute_anchor_y(anchor_top: i32, anchor_height: i32, widget_height: i32) -> i32 { + let anchor_bottom = anchor_top + anchor_height; + let bottom_padding = (anchor_height - widget_height).clamp(0, sc(6)); + (anchor_bottom - widget_height - bottom_padding).max(anchor_top) +} + /// WinEvent callback for tray icon location changes unsafe extern "system" fn on_tray_location_changed( _hook: HWINEVENTHOOK, @@ -1574,20 +1580,18 @@ unsafe extern "system" fn wnd_proc( } let widget_width = total_widget_width(); let widget_height = sc(WIDGET_HEIGHT); + let y = compute_anchor_y(anchor_top, anchor_height, widget_height); if s.embedded { let x = tray_left - taskbar_rect.left - widget_width - new_offset; - let y = - (anchor_top - taskbar_rect.top) + (anchor_height - widget_height) / 2; native_interop::move_window( hwnd_val, x, - y, + y - taskbar_rect.top, widget_width, widget_height, ); } else { let x = tray_left - widget_width - new_offset; - let y = anchor_top + (anchor_height - widget_height) / 2; native_interop::move_window( hwnd_val, x,