Skip to content

Fix vertical taskbar centering getting stuck off-center after the task list wraps - #5188

Open
zyoa wants to merge 2 commits into
valinet:masterfrom
zyoa:fix-vertical-taskbar-centering
Open

zyoa wants to merge 2 commits into
valinet:masterfrom
zyoa:fix-vertical-taskbar-centering

Conversation

@zyoa

@zyoa zyoa commented Sep 25, 2026

Copy link
Copy Markdown

Problem

With the Windows 10 taskbar on a vertical edge and centered alignment (e.g. OldTaskbarAl = 3, "Centered with Start button"), opening many windows at once makes the task buttons shift toward the tray. The taskbar stays that way after the windows are closed, and only restarting Explorer fixes it. While it is stuck, some running windows get no visible taskbar button at all.

Cause

TaskbarCenter_Center measures the band length as the distance from the first button to the second-to-last accessible child (kk - 1). When many buttons appear at once, the task list wraps onto a second column. The second column is off-screen on a vertical taskbar. The "last" button is then in that second column, so the measured length only covers the last column and comes out much too small. The too-small length makes the offset too large, which leaves less room, so the list stays wrapped. This repeats on every layout, so the state never recovers.

Values measured on an affected system (3840x2160, taskbar on the right, 16 button slots of 72px):

  • EPTBLEN stored on MSTaskListWClass: 432. The real length is 16 × 72 = 1152.
  • Accessible children: ids 1–17 at x=3747 (visible column, y 898..1690), ids 19–27 at x=3840 (wrapped, off-screen, y 898..1258).
  • Start button placed at y=834, which matches (2160 − 432 − 60) / 2 + 60.

Fix

This PR sums the extent of every distinct button slot (ids 1 .. kk-1) instead of using last − first:

  • It skips zero-size or -1 positions (hidden entries).
  • It counts consecutive children at the same position (grouped windows) once.

This gives the same result as before when the list is not wrapped, and the real length when it is. With the real length, the list returns to a single column, and the existing space-constrained branch takes over when it truly doesn't fit.

Testing

I built this with the repo's GitHub Actions workflow on my fork and installed it on Windows 11 26200. The setup was a vertical taskbar on the right, 3840x2160 at 150%, OldTaskbar = 2, and OldTaskbarAl = 3.

To reproduce the bug, a script opens N top-level windows at once, each with its own AppUserModelID so they don't combine. It then closes them all. After each step it reads EPTBLEN and the task buttons' MSAA locations.

Step EPTBLEN Slots (visible / off-screen) Group center (screen center = 1080)
Before 1080 15 / 0 1082
+14 windows 2088 29 / 0 top-aligned (space-constrained)
Closed 1080 15 / 0 1082
+30 windows 3240 44 / 1 top-aligned (space-constrained)
Closed 1080 15 / 0 1082

Without the fix, a similar burst of windows in daily use left the band stuck: EPTBLEN stayed at 432 with 5 buttons wrapped off-screen, and only restarting Explorer recovered it. Those are the values in the Cause section.

Side note, not part of this PR: the workflow downloads the latest ep_taskbar release. That is currently v1.0.3.0, whose GetVersion() returns 3, but master only accepts 2. A plain master build therefore falls back to the Windows 11 taskbar. I used ep_taskbar v1.0.2.0 for testing.

🤖 Generated with Claude Code

…raps

Measure the band length by summing the extent of every distinct button slot instead of first-to-last. When the task list wraps onto a second row/column, first-to-last only spans the last line, the reported length is too small, the band stays offset and the wrap becomes permanent (buttons off-center, some windows without a visible button).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pyrates999

Copy link
Copy Markdown

We don't accept vibe coded ai slop.

Summing every button slot is right when the list wraps outside of the taskbar, but a taskbar sized to several rows shows its lines side by side, and summing them overstates the length. Group slots into lines and use the longest line inside the taskbar, adding lines that fall outside of it on top.

The check uses the taskbar window rather than the task list window, because the task list grows past the taskbar edge when it wraps.

Co-Authored-By: Claude Opus 5.5 <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.

2 participants