From 2ece9e2885df9ae049c4a9c6c19277da6a1ba78e Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 9 Jul 2016 21:49:15 +0900 Subject: [PATCH 1/2] Add thickFrame option --- atom/browser/native_window_views.cc | 23 ++++++++++++++++++----- atom/browser/native_window_views.h | 3 +++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 63ed8d9058c3..58d7a352fcbc 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -135,6 +135,10 @@ NativeWindowViews::NativeWindowViews( menu_bar_autohide_(false), menu_bar_visible_(false), menu_bar_alt_pressed_(false), +#if defined(OS_WIN) + enabled_a11y_support_(false), + thick_frame_(true), +#endif keyboard_event_handler_(new views::UnhandledKeyboardEventHandler), disable_count_(0), use_content_size_(false), @@ -152,6 +156,11 @@ NativeWindowViews::NativeWindowViews( options.Get(options::kResizable, &resizable_); options.Get(options::kMinimizable, &minimizable_); options.Get(options::kMaximizable, &maximizable_); + + // Transparent window must not have thick frame. + options.Get("thickFrame", &thick_frame_); + if (transparent()) + thick_frame_ = false; #endif if (enable_larger_than_screen()) @@ -287,13 +296,13 @@ NativeWindowViews::NativeWindowViews( if (maximizable_) frame_style |= WS_MAXIMIZEBOX; // We should not show a frame for transparent window. - if (transparent()) + if (!thick_frame_) frame_style &= ~(WS_THICKFRAME | WS_CAPTION); ::SetWindowLong(GetAcceleratedWidget(), GWL_STYLE, frame_style); } - if (transparent()) { - // Transparent window on Windows has to have WS_EX_COMPOSITED style. + if (!thick_frame_) { + // Window without thick frame 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); @@ -513,7 +522,7 @@ void NativeWindowViews::SetContentSizeConstraints( void NativeWindowViews::SetResizable(bool resizable) { #if defined(OS_WIN) - if (!transparent()) + if (thick_frame_) FlipWindowStyle(GetAcceleratedWidget(), resizable, WS_THICKFRAME); #elif defined(USE_X11) if (resizable != resizable_) { @@ -536,7 +545,11 @@ void NativeWindowViews::SetResizable(bool resizable) { bool NativeWindowViews::IsResizable() { #if defined(OS_WIN) - return ::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE) & WS_THICKFRAME; + if (thick_frame_) { + return ::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE) & WS_THICKFRAME; + } else { + return CanResize(); + } #else return CanResize(); #endif diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index a7614e178f15..f3ca27077fe8 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -220,6 +220,9 @@ class NativeWindowViews : public NativeWindow, // If true we have enabled a11y bool enabled_a11y_support_; + // Whether to show the WS_THICKFRAME style. + bool thick_frame_; + // The icons of window and taskbar. base::win::ScopedHICON window_icon_; base::win::ScopedHICON app_icon_; From b70090170de330c0f918d87a1588dd650b919fec Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 9 Jul 2016 21:52:45 +0900 Subject: [PATCH 2/2] docs: thickFrame option --- docs/api/browser-window.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index ba07e0bf167b..3d48b30010ed 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -174,6 +174,9 @@ It creates a new `BrowserWindow` with native properties as set by the `options`. this below. * `titleBarStyle` String - The style of window title bar. See more about this below. + * `thickFrame` Boolean - Use `WS_THICKFRAME` style for frameless windows on + Windows, which adds standard window frame. Setting it to `false` will remove + window shadow and window animations. Default is `true`. * `webPreferences` Object - Settings of web page's features. See more about this below.