}
void Tray::SetImage(v8::Isolate* isolate, mate::Handle<NativeImage> image) {
- image_.Reset(isolate, image.ToV8());
#if defined(OS_WIN)
tray_icon_->SetImage(image->GetHICON(GetSystemMetrics(SM_CXSMICON)));
#else
void Tray::SetPressedImage(v8::Isolate* isolate,
mate::Handle<NativeImage> image) {
- pressed_image_.Reset(isolate, image.ToV8());
#if defined(OS_WIN)
tray_icon_->SetPressedImage(image->GetHICON(GetSystemMetrics(SM_CXSMICON)));
#else
private:
v8::Local<v8::Object> ModifiersToObject(v8::Isolate* isolate, int modifiers);
- v8::Global<v8::Object> image_;
- v8::Global<v8::Object> pressed_image_;
v8::Global<v8::Object> menu_;
scoped_ptr<TrayIcon> tray_icon_;
return GetNativeWindow()->GetHost()->GetAcceleratedWidget();
}
+#if defined(OS_WIN)
+void NativeWindowViews::SetIcon(HICON small_icon, HICON app_icon) {
+ HWND hwnd = GetAcceleratedWidget();
+ SendMessage(hwnd, WM_SETICON, ICON_SMALL,
+ reinterpret_cast<LPARAM>(small_icon));
+ SendMessage(hwnd, WM_SETICON, ICON_BIG,
+ reinterpret_cast<LPARAM>(app_icon));
+}
+#elif defined(USE_X11)
void NativeWindowViews::SetIcon(const gfx::ImageSkia& icon) {
views::DesktopWindowTreeHostX11* tree_host =
views::DesktopWindowTreeHostX11::GetHostForXID(GetAcceleratedWidget());
static_cast<views::DesktopWindowTreeHost*>(tree_host)->SetWindowIcons(
icon, icon);
}
+#endif
void NativeWindowViews::OnWidgetActivationChanged(
views::Widget* widget, bool active) {
} // namespace
-void NativeWindowViews::SetIcon(HICON small_icon, HICON app_icon) {
- HWND hwnd = GetAcceleratedWidget();
- SendMessage(hwnd, WM_SETICON, ICON_SMALL,
- reinterpret_cast<LPARAM>(small_icon));
- SendMessage(hwnd, WM_SETICON, ICON_BIG,
- reinterpret_cast<LPARAM>(app_icon));
-}
-
bool NativeWindowViews::ExecuteWindowsCommand(int command_id) {
std::string command = AppCommandToString(command_id);
NotifyWindowExecuteWindowsCommand(command);
icon_id_(id),
window_(window),
message_id_(message),
- icon_(NULL),
menu_model_(NULL) {
NOTIFYICONDATA icon_data;
InitIconData(&icon_data);
InitIconData(&icon_data);
icon_data.uFlags |= NIF_MESSAGE;
icon_data.uCallbackMessage = message_id_;
- icon_data.hIcon = icon_;
+ icon_data.hIcon = icon_.get();
// If we have an image, then set the NIF_ICON flag, which tells
// Shell_NotifyIcon() to set the image for the status icon it creates.
if (icon_data.hIcon)
}
void NotifyIcon::SetImage(HICON image) {
+ icon_ = base::win::ScopedHICON(CopyIcon(image));
+
// Create the icon.
- icon_ = image;
NOTIFYICONDATA icon_data;
InitIconData(&icon_data);
icon_data.uFlags |= NIF_ICON;
#include "base/macros.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
+#include "base/win/scoped_gdi_object.h"
namespace gfx {
class Point;
UINT message_id_;
// The currently-displayed icon for the window.
- HICON icon_;
+ base::win::ScopedHICON icon_;
// The context menu.
ui::SimpleMenuModel* menu_model_;