Skip to content

feat(widget): add a custom left margin for the taskbar widget - #1133

Open
wjingshan wants to merge 1 commit into
unchihugo:masterfrom
wjingshan:pr/custom-widget-left-margin
Open

wjingshan wants to merge 1 commit into
unchihugo:masterfrom
wjingshan:pr/custom-widget-left-margin

Conversation

@wjingshan

Copy link
Copy Markdown
Contributor

Summary

Adds an optional custom left margin so the taskbar widget can be pinned at an exact distance from the start of the taskbar.

Motivation

The widget position is always derived from the position setting plus the automatic padding, which snaps the widget next to the native Widgets/weather button (and falls back to "20 px + visualizer width" when that UI Automation lookup times out). The existing "custom spacing" value is only a relative offset, so there is no way to place the widget at a fixed distance. Related: #718, #1116, #518.

Type of Change

  • Feature
  • Bug fix
  • Refactor (no functional changes)
  • Style (formatting, naming)
  • Other

What Changed

  • New settings TaskbarWidgetUseCustomLeftMargin (default off) and TaskbarWidgetLeftMargin (0–2000 px, default 20) plus a ...Text property.
  • TaskbarWindow.PositionWidget(): with the position set to "near start" and the toggle on, primaryPos is set to the configured distance (scaled by the taskbar DPI), skipping the automatic padding and the visualizer offset; the existing manual padding is still applied on top.
  • PositionVisualizer(): if the visualizer would be pushed before the start of the taskbar, it is now placed after the widget instead, so a small margin cannot push it off-screen.
  • Settings UI: new card with a numeric text box + toggle (the page grid got one additional row).
  • Localization: new keys in Dictionary-en-US.xaml.

Additional Information

Verified on Windows 11 25H2 (x64, 200% scaling): margin 300 → widget's left edge at exactly 600 physical px; margin 10 → widget at 20 px with the visualizer automatically moved to its right side. The toggle is off by default, so the current behaviour is unchanged.

Checklist

  • Code changes are manually tested and working.
  • Formatting and naming are consistent with the project (dotnet format --verify-no-changes passes for the touched files).
  • Self-review of changes is done.
  • AI tools were used (if yes, I reviewed and fully understand the changes myself).

The widget position was always derived from the position setting plus the
automatic padding (which snaps it next to the native Widgets button), so there
was no way to place it at an exact distance from the start of the taskbar.

- new "TaskbarWidgetUseCustomLeftMargin" toggle and "TaskbarWidgetLeftMargin"
  value (0-2000 px, default 20) with a numeric text box
- with the position set to "near start" the widget's left edge (top edge on a
  vertical taskbar) is placed at exactly that distance, ignoring the automatic
  padding; the existing manual padding still adds an offset on top
- the visualizer is moved to the right of the widget when there is not enough
  room on the left, so a small margin can no longer push it off the taskbar

Disabled by default, so nothing changes unless the toggle is turned on.
@github-actions github-actions Bot added TaskbarWindow Changes to TaskbarWindow; the container for taskbar widgets Taskbar Widget Changes to the Taskbar Media Widget labels Sep 12, 2026
@github-actions

github-actions Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@wjingshan

Copy link
Copy Markdown
Contributor Author

I have read and agree to the FluentFlyout CLA

@unchihugo unchihugo left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @wjingshan, we already have a feature doing exactly what you've described in the PR description. What's the purpose of an additional margin setting?

@wjingshan

wjingshan commented Sep 16, 2026 via email

Copy link
Copy Markdown
Contributor Author

@wjingshan

Copy link
Copy Markdown
Contributor Author

Thanks for taking a look! Let me clarify the difference from the existing Custom spacing (TaskbarWidgetManualPadding), because that one is a relative offset:

TaskbarWidgetManualPadding is added on top of a base position that is recalculated on every update from the position setting and the automatic padding. The automatic padding resolves the native Widgets/weather button through UI Automation — and when that lookup fails or times out (there are Timeout querying taskbar XAML element: WidgetsButton warnings in the log, which is what happens on my machine) the base silently falls back to a different value (20 px + visualizer width). So the same spacing value can end up in a different place, and there is no way to express "leave me at least N px of room at the start".

The new TaskbarWidgetLeftMargin is an absolute anchor: the widget's left edge is placed exactly N DIP from the start of the taskbar, independent of the Widgets button lookup. Verified on Windows 11 25H2 @200% scaling: margin 300 → the widget's left edge lands at exactly 600 physical px; margin 10 → widget at 20 px with the visualizer automatically moved to its right side so it cannot be pushed off the taskbar.

The use case is avoiding other taskbar tools that can only sit flush against the start of the taskbar (e.g. TrafficMonitor): they overlap the widget, and a relative offset cannot reserve space for them reliably.

That said, I'm not attached to having a second padding-like setting. If you prefer, I can:

  • fold this into the existing padding expander as a "fixed position" mode instead of adding a separate card, or
  • make the existing custom spacing act as an absolute offset when automatic padding is turned off, or
  • close this PR if you think the existing option already covers it.

Happy to adjust — just let me know which direction you prefer. And sorry for the email-formatted reply above, that was sent from the mail client and quoted the whole thread.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Taskbar Widget Changes to the Taskbar Media Widget TaskbarWindow Changes to TaskbarWindow; the container for taskbar widgets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants