const int kMenuBarHeight = 25;
#endif
+#if defined(OS_WIN)
+void FlipWindowStyle(HWND handle, bool on, DWORD flag) {
+ DWORD style = ::GetWindowLong(handle, GWL_STYLE);
+ if (on)
+ style |= flag;
+ else
+ style &= ~flag;
+ ::SetWindowLong(handle, GWL_STYLE, style);
+}
+#endif
+
bool IsAltKey(const content::NativeWebKeyboardEvent& event) {
return event.windowsKeyCode == ui::VKEY_MENU;
}
menu_bar_alt_pressed_(false),
keyboard_event_handler_(new views::UnhandledKeyboardEventHandler),
use_content_size_(false),
+ movable_(true),
resizable_(true),
maximizable_(true),
- movable_(true),
minimizable_(true) {
options.Get(options::kTitle, &title_);
options.Get(options::kAutoHideMenuBar, &menu_bar_autohide_);
// On Windows we rely on the CanResize() to indicate whether window can be
// resized, and it should be set before window is created.
options.Get(options::kResizable, &resizable_);
- options.Get(options::kMovable, &movable_);
options.Get(options::kMinimizable, &minimizable_);
options.Get(options::kMaximizable, &maximizable_);
#endif
last_window_state_ = ui::SHOW_STATE_FULLSCREEN;
else
last_window_state_ = ui::SHOW_STATE_NORMAL;
-
last_normal_size_ = gfx::Size(widget_size_);
- DWORD style = ::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE);
- style |= WS_THICKFRAME | WS_CAPTION | WS_MINIMIZEBOX;
+ if (!has_frame()) {
+ // Set Window style so that we get a minimize and maximize animation when
+ // frameless.
+ DWORD frame_style = WS_CAPTION;
+ if (resizable_)
+ frame_style |= WS_THICKFRAME;
+ if (minimizable_)
+ frame_style |= WS_MINIMIZEBOX;
+ if (maximizable_)
+ frame_style |= WS_MAXIMIZEBOX;
+ // We should not show a frame for transparent window.
+ if (transparent())
+ frame_style &= ~(WS_THICKFRAME | WS_CAPTION);
+ ::SetWindowLong(GetAcceleratedWidget(), GWL_STYLE, frame_style);
+ }
if (transparent()) {
- DWORD ex_style = ::GetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE);
+ // Transparent window on Windows has to have WS_EX_COMPOSITED style.
+ LONG ex_style = ::GetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE);
ex_style |= WS_EX_COMPOSITED;
::SetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE, ex_style);
-
- if (!has_frame()) {
- // We should not show a frame for transparent window.
- style &= ~(WS_THICKFRAME | WS_CAPTION);
- }
- }
-
- if (!transparent() || !has_frame()) {
- ::SetWindowLong(GetAcceleratedWidget(), GWL_STYLE, style);
}
#endif
void NativeWindowViews::SetResizable(bool resizable) {
#if defined(OS_WIN)
- // WS_MAXIMIZEBOX => Maximize button
- // WS_MINIMIZEBOX => Minimize button
- // WS_THICKFRAME => Resize handle
- if (!transparent()) {
- DWORD style = ::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE);
- if (resizable) {
- style |= WS_THICKFRAME;
- } else {
- style &= ~(WS_THICKFRAME);
- }
- ::SetWindowLong(GetAcceleratedWidget(), GWL_STYLE, style);
- }
+ if (!transparent())
+ FlipWindowStyle(GetAcceleratedWidget(), resizable, WS_THICKFRAME);
#elif defined(USE_X11)
if (resizable != resizable_) {
// On Linux there is no "resizable" property of a window, we have to set
}
bool NativeWindowViews::IsResizable() {
- return resizable_;
+ return CanResize();
}
void NativeWindowViews::SetMovable(bool movable) {
bool NativeWindowViews::IsMovable() {
#if defined(OS_WIN)
return movable_;
-#elif defined(USE_X11)
- return true;
+#else
+ return true; // Not implemented on Linux.
#endif
}
void NativeWindowViews::SetMinimizable(bool minimizable) {
#if defined(OS_WIN)
- if (!transparent()) {
- DWORD style = ::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE);
- if (minimizable)
- style |= WS_MINIMIZEBOX;
- else
- style &= (~WS_MINIMIZEBOX);
- ::SetWindowLong(GetAcceleratedWidget(), GWL_STYLE, style);
- }
+ FlipWindowStyle(GetAcceleratedWidget(), minimizable, WS_MINIMIZEBOX);
#endif
-
minimizable_ = minimizable;
}
bool NativeWindowViews::IsMinimizable() {
#if defined(OS_WIN)
- return ::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE) & WS_MINIMIZEBOX;
-#elif defined(USE_X11)
- return true;
+ return CanMinimize();
+#else
+ return true; // CanMinimize() Not implemented on Linux.
#endif
}
void NativeWindowViews::SetMaximizable(bool maximizable) {
#if defined(OS_WIN)
- DWORD style = ::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE);
- if (maximizable) {
- style |= WS_MAXIMIZEBOX;
- } else {
- style &= (~WS_MAXIMIZEBOX);
- }
- ::SetWindowLong(GetAcceleratedWidget(), GWL_STYLE, style);
+ FlipWindowStyle(GetAcceleratedWidget(), maximizable, WS_MAXIMIZEBOX);
#endif
+ maximizable_ = maximizable;
}
bool NativeWindowViews::IsMaximizable() {
#if defined(OS_WIN)
- return ::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE) & WS_MAXIMIZEBOX;
-#elif defined(USE_X11)
- return true;
+ return CanMaximize();
+#else
+ return true; // CanMaximize() Not implemented on Linux.
#endif
}
}
bool NativeWindowViews::CanMaximize() const {
- return resizable_;
+ return resizable_ && maximizable_;
}
bool NativeWindowViews::CanMinimize() const {