#include "atom/browser/api/atom_api_web_contents.h"
#include "atom/browser/browser.h"
#include "atom/browser/native_window.h"
+#include "atom/common/api/atom_api_native_image.h"
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/gfx_converter.h"
#include "atom/common/native_mate_converters/gurl_converter.h"
window_->InitFromOptions(options);
window_->AddObserver(this);
AttachAsUserData(window_.get());
+
+#if defined(OS_WIN)
+ // Sets the window icon.
+ mate::Handle<NativeImage> icon;
+ if (options.Get(options::kIcon, &icon) && !icon.IsEmpty()) {
+ static_cast<NativeWindowViews*>(window_.get())->SetIcon(
+ icon->GetHICON(GetSystemMetrics(SM_CXSMICON)), icon->GetHICON(256));
+ }
+#endif
}
Window::~Window() {
// mode.
ui::GpuSwitchingManager::SetTransparent(transparent_);
- // Read icon before window is created.
- options.Get(options::kIcon, &icon_);
-
WindowList::AddWindow(this);
}
bool transparent() const { return transparent_; }
SkRegion* draggable_region() const { return draggable_region_.get(); }
bool enable_larger_than_screen() const { return enable_larger_than_screen_; }
- gfx::ImageSkia icon() const { return icon_; }
void set_has_dialog_attached(bool has_dialog_attached) {
has_dialog_attached_ = has_dialog_attached;
// Whether window can be resized larger than screen.
bool enable_larger_than_screen_;
- // Window icon.
- gfx::ImageSkia icon_;
-
// The windows has been closed.
bool is_closed_;
std::string window_type;
if (options.Get(options::kType, &window_type))
SetWindowType(GetAcceleratedWidget(), window_type);
+
+ // Set window icon.
+ options.Get(options::kIcon, &icon_);
+ window_->UpdateWindowIcon();
#endif
// Add web view.
use_content_size_)
size = ContentSizeToWindowSize(size);
- window_->UpdateWindowIcon();
window_->CenterWindow(size);
Layout();
}
return true;
}
+#if defined(USE_X11)
gfx::ImageSkia NativeWindowViews::GetWindowAppIcon() {
- return icon();
+ return icon_;
}
gfx::ImageSkia NativeWindowViews::GetWindowIcon() {
return GetWindowAppIcon();
}
+#endif
views::Widget* NativeWindowViews::GetWidget() {
return window_.get();
gfx::AcceleratedWidget GetAcceleratedWidget() override;
- views::Widget* widget() const { return window_.get(); }
-
#if defined(OS_WIN)
+ void SetIcon(HICON small_icon, HICON app_icon);
+
TaskbarHost& taskbar_host() { return taskbar_host_; }
#endif
+ views::Widget* widget() const { return window_.get(); }
+
private:
// views::WidgetObserver:
void OnWidgetActivationChanged(
bool CanMinimize() const override;
base::string16 GetWindowTitle() const override;
bool ShouldHandleSystemCommands() const override;
+#if defined(USE_X11)
gfx::ImageSkia GetWindowAppIcon() override;
gfx::ImageSkia GetWindowIcon() override;
+#endif
views::Widget* GetWidget() override;
const views::Widget* GetWidget() const override;
views::View* GetContentsView() override;
// MessageHandlerDelegate:
bool PreHandleMSG(
UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) override;
-
void HandleSizeEvent(WPARAM w_param, LPARAM l_param);
#endif
// we need to make sure size constraints are restored when window becomes
// resizable again.
extensions::SizeConstraints old_size_constraints_;
+
+ // Window icon.
+ gfx::ImageSkia icon_;
#elif defined(OS_WIN)
// Weak ref.
AtomDesktopWindowTreeHostWin* atom_desktop_window_tree_host_win_;
// If true we have enabled a11y
bool enabled_a11y_support_;
-
#endif
// Handles unhandled keyboard messages coming back from the renderer process.
} // 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);