fix: disappearing thumbar after win.hide() (#28390)

* fix: disappearing thumbar after win.hide()

* Add descriptive comment

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
trop[bot]
2021-03-25 12:16:13 -07:00
committed by GitHub
parent 00367f0b13
commit 50cc80c44e
3 changed files with 13 additions and 2 deletions

View File

@@ -442,6 +442,14 @@ void NativeWindowViews::Hide() {
if (!features::IsUsingOzonePlatform() && global_menu_bar_)
global_menu_bar_->OnWindowUnmapped();
#endif
#if defined(OS_WIN)
// When the window is removed from the taskbar via win.hide(),
// the thumbnail buttons need to be set up again.
// Ensure that when the window is hidden,
// the taskbar host is notified that it should re-add them.
taskbar_host_.SetThumbarButtonsAdded(false);
#endif
}
bool NativeWindowViews::IsVisible() {

View File

@@ -114,11 +114,12 @@ bool TaskbarHost::SetThumbarButtons(HWND window,
// Finally add them to taskbar.
HRESULT r;
if (thumbar_buttons_added_)
if (thumbar_buttons_added_) {
r = taskbar_->ThumbBarUpdateButtons(window, kMaxButtonsCount,
thumb_buttons);
else
} else {
r = taskbar_->ThumbBarAddButtons(window, kMaxButtonsCount, thumb_buttons);
}
thumbar_buttons_added_ = true;
last_buttons_ = buttons;

View File

@@ -60,6 +60,8 @@ class TaskbarHost {
// Called by the window that there is a button in thumbar clicked.
bool HandleThumbarButtonEvent(int button_id);
void SetThumbarButtonsAdded(bool added) { thumbar_buttons_added_ = added; }
private:
// Initialize the taskbar object.
bool InitializeTaskbar();