From 2fa7aa3c7193e4f0bc50a9394e64d3d56afea8a9 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Sat, 13 Aug 2016 01:55:42 +1000 Subject: [PATCH] Save the thumbar buttons when setting them Then restore the buttons when restoring the taskbar icon --- atom/browser/api/atom_api_window.cc | 2 +- atom/browser/native_window_views.cc | 6 ++++-- atom/browser/ui/win/taskbar_host.cc | 8 ++++++++ atom/browser/ui/win/taskbar_host.h | 4 ++++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index af402de0776..1327d8de6f1 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -606,7 +606,7 @@ bool Window::SetThumbarButtons(mate::Arguments* args) { } auto window = static_cast(window_.get()); return window->taskbar_host().SetThumbarButtons( - window->GetAcceleratedWidget(), buttons); + window_->GetAcceleratedWidget(), buttons); #else return false; #endif diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index af793719cdd..5f5ca68749c 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -726,10 +726,12 @@ void NativeWindowViews::SetSkipTaskbar(bool skip) { CLSCTX_INPROC_SERVER)) || FAILED(taskbar->HrInit())) return; - if (skip) + if (skip) { taskbar->DeleteTab(GetAcceleratedWidget()); - else + } else { taskbar->AddTab(GetAcceleratedWidget()); + taskbar_host_.RestoreThumbarButtons(GetAcceleratedWidget()); + } #elif defined(USE_X11) SetWMSpecState(GetAcceleratedWidget(), skip, GetAtom("_NET_WM_STATE_SKIP_TASKBAR")); diff --git a/atom/browser/ui/win/taskbar_host.cc b/atom/browser/ui/win/taskbar_host.cc index fd49d28fd70..00bff1c88ae 100644 --- a/atom/browser/ui/win/taskbar_host.cc +++ b/atom/browser/ui/win/taskbar_host.cc @@ -115,9 +115,17 @@ bool TaskbarHost::SetThumbarButtons( r = taskbar_->ThumbBarAddButtons(window, kMaxButtonsCount, thumb_buttons); thumbar_buttons_added_ = true; + last_buttons_ = buttons; return SUCCEEDED(r); } +void TaskbarHost::RestoreThumbarButtons(HWND window) { + if (thumbar_buttons_added_) { + thumbar_buttons_added_ = false; + SetThumbarButtons(window, last_buttons_); + } +} + bool TaskbarHost::SetProgressBar( HWND window, double value, const std::string& mode) { if (!InitializeTaskbar()) diff --git a/atom/browser/ui/win/taskbar_host.h b/atom/browser/ui/win/taskbar_host.h index c76340cd6ef..a9263d9e898 100644 --- a/atom/browser/ui/win/taskbar_host.h +++ b/atom/browser/ui/win/taskbar_host.h @@ -34,6 +34,8 @@ class TaskbarHost { bool SetThumbarButtons( HWND window, const std::vector& buttons); + void RestoreThumbarButtons(HWND window); + // Set the progress state in taskbar. bool SetProgressBar(HWND window, double value, const std::string& mode); @@ -57,6 +59,8 @@ class TaskbarHost { using CallbackMap = std::map; CallbackMap callback_map_; + std::vector last_buttons_; + // The COM object of taskbar. base::win::ScopedComPtr taskbar_;