Skip to content

Keep taskbar search box away from the tray - #817

Merged
srwi merged 6 commits into
srwi:developfrom
ArneBouten:fix/taskbar-box-position
Oct 31, 2026
Merged

srwi merged 6 commits into
srwi:developfrom
ArneBouten:fix/taskbar-box-position

Conversation

@ArneBouten

@ArneBouten ArneBouten commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #816

  • Use the TrayNotifyWnd rect as an obstacle, so the box can't end up under the tray when the UIA search for tray icons comes back empty.
  • If no tray is found at all, keep the current position until the taskbar reports its layout again.
  • Ignore tray icons that lie inside the notification area. They are already covered by it, and the press animation of the "Show hidden icons" button briefly reports a larger rect, which made the box shift when opening the overflow.
  • Follow the tray edge on every taskbar event. TrayNotifyWnd is a plain window, so reading its rect is cheap, and the box gets out of the way as soon as the tray grows instead of after the debounce and the full measurement. It also slides a bit quicker there (150 ms instead of the usual 250 ms), so it clears the tray right away.

Tested on Windows 11 26H2 (1920×1080, 100%, left-aligned taskbar): placement is unchanged in normal use, the box returns to the right spot after an Explorer restart, it no longer shifts when the "Show hidden icons" button is clicked, and it moves out of the way within a few frames when a tray icon appears.

@srwi srwi 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 @ArneBouten! Thank you very much for looking into this!

The solution of using the win32 tray window as the blocking element looks very good! I tried doing something similar but couldn't get it to work reliably but this seems to work well for me too.

Only move to a new position once it has been stable for 5 s, as long as the current position is still free. This stops the box from shifting back and forth during short taskbar reflows or when a tray icon briefly disappears (e.g. Google Drive restarting a process every ~20 s here). Moves needed to avoid an overlap still happen right away.

I noticed this during my testing when removing a tray icon, the search bar didn't move back into place right away which felt broken at first. I totally understand wanting to avoid jumping when an app restarts constantly, but I feel like this fixes an external issue at the expense of general UI responsiveness. Personally I would prefer the search box to feel snappy and move immediately. Could we drop the 5s delay?

Comment thread EverythingToolbar/TaskbarWindow.xaml.cs Outdated
/// Returns true if the box can stay where it is for now, i.e. its current position is still free
/// and the new position has not been stable for <see cref="StableMoveDelay"/> yet.
/// </summary>
private bool ShouldWaitForStableLayout(WidgetBounds bounds)

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.

I don't think the increasing timeouts actually work as intended in practice here.

During an Explorer restart Windows fires taskbar events that keep the existing _repositionTimer active (firing every 150 ms). Because _repositionTimer triggers ApplyMeasuredLayout so quickly, it will increment _incompleteLayoutRetries every 150 ms and burn through all 5 retries in under a second so the increasing timeouts never really get used anyway.

Wouldn't it be much simpler to just drop the extra timer and retries and do something like:

if (!layout.HasTray)
    return;

If the tray really isn't ready yet for a split second while Explorer loads, we simply do nothing and keep our current position. As soon as Explorer finishes setting up the tray, it will fire fresh taskbar events anyway, which will automatically trigger UpdatePosition() and place the box properly.

What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, they burned through in under a second anyway. Replaced with if (!layout.HasTray) return;.

Move the search box as soon as the new position is known, and when no tray is found keep the current position until the taskbar reports its layout again.
The notification area is a plain window, so its edge can be read on every taskbar event instead of waiting for the full measurement. Getting out of the way of a growing tray uses a slightly shorter slide.
@ArneBouten

ArneBouten commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the review! Both done:

  • Dropped the 5 s delay, the box moves right away now. The flickering I was working around was Google Drive crashing in a loop on my machine, so not something to design around.
  • Replaced the retries with if (!layout.HasTray) return;.

I also added a small separate commit that follows the tray edge on every taskbar event, so the box no longer overlaps the "Show hidden icons" button for a moment when a tray icon appears. Feel free to drop it if you'd rather keep this PR minimal.

@ArneBouten
ArneBouten requested a review from srwi October 30, 2026 01:47
@srwi

srwi commented Oct 31, 2026

Copy link
Copy Markdown
Owner

Looks great, thanks a lot for the contribution!

@srwi
srwi merged commit bb69ff8 into srwi:develop Oct 31, 2026
4 checks passed
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.

Taskbar search box sometimes moves under the tray icons

2 participants