Skip to content

Commit ba84737

Browse files
committed
v1.2.10
- Anchor monitor to the bottom of the taskbar to help with any positioning issues
1 parent 7ef75f4 commit ba84737

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "claude-code-usage-monitor"
3-
version = "1.2.9"
3+
version = "1.2.10"
44
edition = "2021"
55
license = "MIT"
66
description = "Windows taskbar widget for monitoring Claude Code usage and rate limits"

src/window.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,25 +1323,31 @@ fn position_at_taskbar() {
13231323
let widget_width = total_widget_width();
13241324

13251325
let widget_height = sc(WIDGET_HEIGHT);
1326+
let y = compute_anchor_y(anchor_top, anchor_height, widget_height);
13261327
if embedded {
13271328
// Child window: coordinates relative to parent (taskbar)
13281329
let x = tray_left - taskbar_rect.left - widget_width - tray_offset;
1329-
let y = (anchor_top - taskbar_rect.top) + (anchor_height - widget_height) / 2;
1330-
native_interop::move_window(hwnd, x, y, widget_width, widget_height);
1330+
native_interop::move_window(hwnd, x, y - taskbar_rect.top, widget_width, widget_height);
13311331
diagnose::log(format!(
1332-
"positioned embedded widget at x={x} y={y} w={widget_width} h={widget_height}"
1332+
"positioned embedded widget at x={x} y={} w={widget_width} h={widget_height}",
1333+
y - taskbar_rect.top
13331334
));
13341335
} else {
13351336
// Topmost popup: screen coordinates
13361337
let x = tray_left - widget_width - tray_offset;
1337-
let y = anchor_top + (anchor_height - widget_height) / 2;
13381338
native_interop::move_window(hwnd, x, y, widget_width, widget_height);
13391339
diagnose::log(format!(
13401340
"positioned fallback widget at x={x} y={y} w={widget_width} h={widget_height}"
13411341
));
13421342
}
13431343
}
13441344

1345+
fn compute_anchor_y(anchor_top: i32, anchor_height: i32, widget_height: i32) -> i32 {
1346+
let anchor_bottom = anchor_top + anchor_height;
1347+
let bottom_padding = (anchor_height - widget_height).clamp(0, sc(6));
1348+
(anchor_bottom - widget_height - bottom_padding).max(anchor_top)
1349+
}
1350+
13451351
/// WinEvent callback for tray icon location changes
13461352
unsafe extern "system" fn on_tray_location_changed(
13471353
_hook: HWINEVENTHOOK,
@@ -1574,20 +1580,18 @@ unsafe extern "system" fn wnd_proc(
15741580
}
15751581
let widget_width = total_widget_width();
15761582
let widget_height = sc(WIDGET_HEIGHT);
1583+
let y = compute_anchor_y(anchor_top, anchor_height, widget_height);
15771584
if s.embedded {
15781585
let x = tray_left - taskbar_rect.left - widget_width - new_offset;
1579-
let y =
1580-
(anchor_top - taskbar_rect.top) + (anchor_height - widget_height) / 2;
15811586
native_interop::move_window(
15821587
hwnd_val,
15831588
x,
1584-
y,
1589+
y - taskbar_rect.top,
15851590
widget_width,
15861591
widget_height,
15871592
);
15881593
} else {
15891594
let x = tray_left - widget_width - new_offset;
1590-
let y = anchor_top + (anchor_height - widget_height) / 2;
15911595
native_interop::move_window(
15921596
hwnd_val,
15931597
x,

0 commit comments

Comments
 (0)