Skip to content

Snap widget to taskbar regions and resize bars to fit - #17

Closed
Helveg wants to merge 2 commits into
CodeZeno:mainfrom
Helveg:layout
Closed

Snap widget to taskbar regions and resize bars to fit#17
Helveg wants to merge 2 commits into
CodeZeno:mainfrom
Helveg:layout

Conversation

@Helveg

@Helveg Helveg commented Apr 27, 2026

Copy link
Copy Markdown

I added a bit of layout logic so that the widget can be easily placed into open places on the taskbar, and also resizes and relayouts on changes.

Summary

  • Dragging the widget now shows translucent highlights over open taskbar regions; the one under the cursor lights up, and dropping snaps the widget into it.
    Releasing outside any valid region reverts to the pre-drag position.
  • The widget resizes to fill the dropped region by stretching its progress-bar segments (clamped between 5 and 12 design-pixels). Regions on the left half of the
    taskbar left-align the widget; regions on the right half right-align.
  • Open regions are computed from HWND enumeration plus a UIA scan of XAML hosts (DesktopWindowContentBridge) so Win11 pinned/running apps are accounted for. The
    UIA cache refreshes off the UI thread on a 500 ms tick and after every drag, and the widget auto-resizes if its current region shrinks below the minimum fit (jumping
    to the nearest valid region).
  • New --debug-render flag overlays red-bordered boxes with class+size labels around every detected occupant, for diagnosing detection.

@CodeZeno

Copy link
Copy Markdown
Owner

@Helveg, thank you again for putting so much thought into this! Your handling of the awkward Windows 11 taskbar internals was especially impressive, including the UIA scan for XAML-hosted icons, open-region highlights, invalid-drop recovery, and adaptive segment sizing.

With v2.0 now released, the underlying placement and sizing problem this PR set out to solve is covered through the new Theme Studio. I did not merge this exact implementation, as v2 takes a broader theme-driven approach instead of automatically detecting open regions and showing drop highlights.

Users can now:

  • Nest the widget directly inside a taskbar
  • Position it relative to a monitor, taskbar, or system tray on any display
  • Independently choose the reference point and widget attachment point
  • Fine-tune X/Y offsets, width, and height
  • Use expressions for responsive sizing and layouts
  • Preview changes and apply them live

For a placement similar to the original widget:

  1. Right-click the tray icon and open the Dashboard.
  2. Open Theme Studio and duplicate the read-only Classic v1 theme.
  3. Select the Classic taskbar widget root and expand Positioning.
  4. Set Nest to Taskbar and Reference to System Tray on the desired display.
  5. Attach the system tray’s bottom-left point to the widget’s bottom-right point, then adjust the offsets or size as needed.
  6. Save the theme, or enable Live apply while tuning it.

This gives people control over exactly where the widget lives while also supporting multiple monitors and fully custom widget designs.

Really appreciate the work and care you put into exploring this, @Helveg. It directly targeted one of the most awkward parts of fitting a custom widget naturally into the Windows taskbar. With the new v2 system now released and covering the broader use case, I’m going to close this PR as superseded. Thank you! 🚀

@CodeZeno CodeZeno closed this Aug 15, 2026
@Helveg

Helveg commented Aug 17, 2026

Copy link
Copy Markdown
Author

Beautiful! Thanks for the reply and the work :)

@Helveg
Helveg deleted the layout branch August 17, 2026 08:45
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.

2 participants