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

* fix: disappearing thumbar after win.hide()

* Add descriptive comment
This commit is contained in:
Shelley Vohr 2021-03-25 11:02:47 +00:00 committed by GitHub
parent b9b734c9c4
commit 1453a8e743
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View file

@ -442,6 +442,14 @@ void NativeWindowViews::Hide() {
if (!features::IsUsingOzonePlatform() && global_menu_bar_) if (!features::IsUsingOzonePlatform() && global_menu_bar_)
global_menu_bar_->OnWindowUnmapped(); global_menu_bar_->OnWindowUnmapped();
#endif #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() { bool NativeWindowViews::IsVisible() {

View file

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

View file

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