Skip to content

fix(windows): update thumbnail toolbar instead of re-adding it - #117

Open
StillMisty wants to merge 1 commit into
libnativeapi:mainfrom
StillMisty:fix/windows-thumbnail-toolbar-update-first
Open

StillMisty wants to merge 1 commit into
libnativeapi:mainfrom
StillMisty:fix/windows-thumbnail-toolbar-update-first

Conversation

@StillMisty

Copy link
Copy Markdown

Summary

ThumbBarAddButtons is not a replace call once the toolbar exists. Windows 11
build 26300 returns S_OK from a second ThumbBarAddButtons while leaving the
existing toolbar untouched, so calling it first on every sync meant
ThumbBarUpdateButtons never ran: button icons / enabled flags stopped
following after the first add (clicks and the progress indicator still worked).

Root cause

SyncThumbnailToolbarOnWindowThread() adds first and only falls back to update
on E_INVALIDARG; the new shell never returns E_INVALIDARG for an existing
toolbar.

Fix

Update first once a toolbar has been created for the current shell taskbar
item, and fall back to ThumbBarAddButtons on E_INVALIDARG (toolbar gone
after the shell recreated the taskbar item). ReplayAllOnWindowThread() still
resets the flag on TaskbarButtonCreated, so hide/restore and Explorer restart
keep working. thumbbar_initialized_ is now set to true on any successful
sync: a toolbar cannot be removed from a taskbar item, only its buttons
cleared, so the next sync must not add again.

Verification

Verified on Windows 11 build 26300 with a Flutter app using the
TaskbarThumbnailButton property setters: icons, enabled state and tooltips
now follow immediately; hide-to-tray/restore and Explorer restart still
recreate the toolbar; progress indicator unaffected.

Note

The umbrella spec specs/window-taskbar.md in libnativeapi/nativeapi
(section 3) still describes the add-first heuristic and should be updated when
this is synced.

Reported in libnativeapi/nativeapi#90.

ThumbBarAddButtons is not a replace call once the toolbar exists. Windows 11
build 26300 returns S_OK from a second ThumbBarAddButtons while leaving the
toolbar untouched, so calling it first on every sync meant
ThumbBarUpdateButtons never ran: button icons / enabled flags stopped
following after the first add (clicks and the progress indicator still
worked).

Update first once a toolbar has been created for the current shell taskbar
item, and fall back to ThumbBarAddButtons on E_INVALIDARG (toolbar gone after
the shell recreated the taskbar item). ReplayAllOnWindowThread still resets
the flag on TaskbarButtonCreated.

Verified on Windows 11 build 26300: icons, enabled state and tooltips follow
immediately; hide-to-tray/restore and Explorer restart still recreate the
toolbar.

Refs libnativeapi/nativeapi#90
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.

1 participant