Skip to content

fix(positioning): keep drag-docked widgets clear of the clock on secondary taskbars - #236

Open
adamt-eng wants to merge 1 commit into
CodeZeno:mainfrom
adamt-eng:main
Open

adamt-eng wants to merge 1 commit into
CodeZeno:mainfrom
adamt-eng:main

Conversation

@adamt-eng

Copy link
Copy Markdown

Summary

  • A widget dragged onto a secondary monitor's taskbar could end up under that taskbar's clock. Enabling another provider, or anything else that widens the widget, grew it to the right into the clock, and it stayed there until the next drag.
  • Cause: the drag clamp in surface_screen_rect keeps a drag-docked widget left of TrayNotifyWnd. Shell_SecondaryTrayWnd has no TrayNotifyWnd, so on a secondary taskbar the clamp only knew the end of the bar. The clock there (SystemTray.OmniButton on Windows 11) is only visible to the UI Automation occupancy reader, which is why starting a drag snapped the widget back into the free slot.
  • Fix: when a taskbar has no TrayNotifyWnd, a drag-docked placement is clamped against the notification area measured by the occupancy reader (the extent of its reserved rectangles). The widget now grows away from the clock, as it does on the primary taskbar.
  • The measured area is remembered per taskbar and bounds, and only a successful sample replaces it. A hidden or unreadable bar therefore does not release the clamp, while turning the clock off does.
  • The taskbar watchdog also watches the measured area when there is no TrayNotifyWnd, so a widget placed at startup before the first sample is repositioned once the clock is known.
  • Out of scope: tray-referenced placements (authored themes and tray-snapped docks) still anchor to the end of a secondary bar. Only the runtime drag clamp changes, and the primary taskbar path is untouched because TrayNotifyWnd still wins.

Testing

  • CI on my fork passed for this commit (https://github.com/adamt-eng/Claude-Code-Usage-Monitor/actions/runs/45721289455): cargo fmt --all -- --check, cargo clippy --locked --all-targets -- -D warnings, cargo test --locked (670 passed, 0 failed, 6 ignored), cargo build --locked --release, repository checks and dependency security. Not run locally: this machine has no MSVC toolchain.
  • New regression tests with dummy geometry: drag_docked_widget_stays_clear_of_a_secondary_taskbar_clock (clamps against the measured clock, falls back to the end of the bar without a sample, prefers TrayNotifyWnd, leaves tray-referenced placements alone) and measured_tray_follows_the_latest_sample_of_the_same_taskbar_geometry.
  • Manual: Windows 11 Pro (build 26200), two monitors (primary 3840×2160 at 175%, secondary 1920×1080 at 100%), Classic theme, release build of this commit from CI. With the widget dragged against the clock on the secondary taskbar, enabling another provider made it grow to the left and stay beside the clock. Before the fix the same steps left it under the clock.
  • Not tested manually: vertical taskbars, auto-hide taskbars, Windows 10, and a secondary taskbar with its clock turned off.

Checklist

  • I have read CONTRIBUTING.md and CODE_OF_CONDUCT.md.
  • The change is focused and contains no credentials or sensitive data.
  • I have added or updated relevant documentation and tests, where applicable.
  • Theme changes: I have updated tests/snapshots/themes and checked the new images
    (see CONTRIBUTING.md, Theme changes).
  • New providers: every_provider_meets_the_contract passes with a redacted fixture
    (see CONTRIBUTING.md, Provider changes).
  • I have left changelog and version changes to maintainers unless requested.

🤖 Generated with Claude Code

…ndary taskbars

A secondary taskbar has no TrayNotifyWnd, so the drag clamp only knew the
end of the bar and a widget that grew wider slid under the clock. Clamp
against the notification area measured by the occupancy reader instead,
remember it while a sample is unavailable, and let the watchdog reposition
once it is first measured.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant