From aea2135016a45c90b28d5e1c89fdd46787d328de Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 31 May 2016 17:47:45 +0900 Subject: [PATCH] Keep copies of window icons --- atom/browser/native_window_views.cc | 10 +++++++--- atom/browser/native_window_views.h | 5 +++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 21bff63..e699892 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -786,12 +786,16 @@ gfx::AcceleratedWidget NativeWindowViews::GetAcceleratedWidget() { } #if defined(OS_WIN) -void NativeWindowViews::SetIcon(HICON small_icon, HICON app_icon) { +void NativeWindowViews::SetIcon(HICON window_icon, HICON app_icon) { + // We are responsible for storing the images. + window_icon_ = base::win::ScopedHICON(CopyIcon(window_icon)); + app_icon_ = base::win::ScopedHICON(CopyIcon(app_icon)); + HWND hwnd = GetAcceleratedWidget(); SendMessage(hwnd, WM_SETICON, ICON_SMALL, - reinterpret_cast(small_icon)); + reinterpret_cast(window_icon_.get())); SendMessage(hwnd, WM_SETICON, ICON_BIG, - reinterpret_cast(app_icon)); + reinterpret_cast(app_icon_.get())); } #elif defined(USE_X11) void NativeWindowViews::SetIcon(const gfx::ImageSkia& icon) { diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index 85c7ddb..909c5b6 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -17,6 +17,7 @@ #if defined(OS_WIN) #include "atom/browser/ui/win/message_handler_delegate.h" #include "atom/browser/ui/win/taskbar_host.h" +#include "base/win/scoped_gdi_object.h" #endif namespace views { @@ -205,6 +206,10 @@ class NativeWindowViews : public NativeWindow, // If true we have enabled a11y bool enabled_a11y_support_; + + // The icons of window and taskbar. + base::win::ScopedHICON window_icon_; + base::win::ScopedHICON app_icon_; #endif // Handles unhandled keyboard messages coming back from the renderer process. -- 2.7.4