Repository navigation
Keep taskbar search box away from the tray - #817
Conversation
srwi
left a comment
There was a problem hiding this comment.
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?
| /// 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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
|
Thanks for the review! Both done:
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. |
|
Looks great, thanks a lot for the contribution! |
Fixes #816
TrayNotifyWndrect as an obstacle, so the box can't end up under the tray when the UIA search for tray icons comes back empty.TrayNotifyWndis 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.