Skip to content

Commit 7ef75f4

Browse files
committed
v1.2.9
- Improved vertical placement
1 parent 65cf2b5 commit 7ef75f4

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
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.8"
3+
version = "1.2.9"
44
edition = "2021"
55
license = "MIT"
66
description = "Windows taskbar widget for monitoring Claude Code usage and rate limits"

src/window.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,10 +1309,14 @@ fn position_at_taskbar() {
13091309

13101310
let taskbar_height = taskbar_rect.bottom - taskbar_rect.top;
13111311
let mut tray_left = taskbar_rect.right;
1312+
let mut anchor_top = taskbar_rect.top;
1313+
let mut anchor_height = taskbar_height;
13121314

13131315
if let Some(tray_hwnd) = native_interop::find_child_window(taskbar_hwnd, "TrayNotifyWnd") {
13141316
if let Some(tray_rect) = native_interop::get_window_rect_safe(tray_hwnd) {
13151317
tray_left = tray_rect.left;
1318+
anchor_top = tray_rect.top;
1319+
anchor_height = tray_rect.bottom - tray_rect.top;
13161320
}
13171321
}
13181322

@@ -1322,15 +1326,15 @@ fn position_at_taskbar() {
13221326
if embedded {
13231327
// Child window: coordinates relative to parent (taskbar)
13241328
let x = tray_left - taskbar_rect.left - widget_width - tray_offset;
1325-
let y = (taskbar_height - widget_height) / 2;
1329+
let y = (anchor_top - taskbar_rect.top) + (anchor_height - widget_height) / 2;
13261330
native_interop::move_window(hwnd, x, y, widget_width, widget_height);
13271331
diagnose::log(format!(
13281332
"positioned embedded widget at x={x} y={y} w={widget_width} h={widget_height}"
13291333
));
13301334
} else {
13311335
// Topmost popup: screen coordinates
13321336
let x = tray_left - widget_width - tray_offset;
1333-
let y = taskbar_rect.top + (taskbar_height - widget_height) / 2;
1337+
let y = anchor_top + (anchor_height - widget_height) / 2;
13341338
native_interop::move_window(hwnd, x, y, widget_width, widget_height);
13351339
diagnose::log(format!(
13361340
"positioned fallback widget at x={x} y={y} w={widget_width} h={widget_height}"
@@ -1556,19 +1560,24 @@ unsafe extern "system" fn wnd_proc(
15561560
if let Some(taskbar_rect) = native_interop::get_taskbar_rect(taskbar_hwnd) {
15571561
let taskbar_height = taskbar_rect.bottom - taskbar_rect.top;
15581562
let mut tray_left = taskbar_rect.right;
1563+
let mut anchor_top = taskbar_rect.top;
1564+
let mut anchor_height = taskbar_height;
15591565
if let Some(tray_hwnd) =
15601566
native_interop::find_child_window(taskbar_hwnd, "TrayNotifyWnd")
15611567
{
15621568
if let Some(tray_rect) = native_interop::get_window_rect_safe(tray_hwnd)
15631569
{
15641570
tray_left = tray_rect.left;
1571+
anchor_top = tray_rect.top;
1572+
anchor_height = tray_rect.bottom - tray_rect.top;
15651573
}
15661574
}
15671575
let widget_width = total_widget_width();
15681576
let widget_height = sc(WIDGET_HEIGHT);
15691577
if s.embedded {
15701578
let x = tray_left - taskbar_rect.left - widget_width - new_offset;
1571-
let y = (taskbar_height - widget_height) / 2;
1579+
let y =
1580+
(anchor_top - taskbar_rect.top) + (anchor_height - widget_height) / 2;
15721581
native_interop::move_window(
15731582
hwnd_val,
15741583
x,
@@ -1578,7 +1587,7 @@ unsafe extern "system" fn wnd_proc(
15781587
);
15791588
} else {
15801589
let x = tray_left - widget_width - new_offset;
1581-
let y = taskbar_rect.top + (taskbar_height - widget_height) / 2;
1590+
let y = anchor_top + (anchor_height - widget_height) / 2;
15821591
native_interop::move_window(
15831592
hwnd_val,
15841593
x,

0 commit comments

Comments
 (0)