Merge pull request #6415 from electron/thick-frame
Add thickFrame option for BrowserWindow
This commit is contained in:
commit
b87c3c4b2d
3 changed files with 24 additions and 5 deletions
|
@ -135,6 +135,10 @@ NativeWindowViews::NativeWindowViews(
|
||||||
menu_bar_autohide_(false),
|
menu_bar_autohide_(false),
|
||||||
menu_bar_visible_(false),
|
menu_bar_visible_(false),
|
||||||
menu_bar_alt_pressed_(false),
|
menu_bar_alt_pressed_(false),
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
enabled_a11y_support_(false),
|
||||||
|
thick_frame_(true),
|
||||||
|
#endif
|
||||||
keyboard_event_handler_(new views::UnhandledKeyboardEventHandler),
|
keyboard_event_handler_(new views::UnhandledKeyboardEventHandler),
|
||||||
disable_count_(0),
|
disable_count_(0),
|
||||||
use_content_size_(false),
|
use_content_size_(false),
|
||||||
|
@ -152,6 +156,11 @@ NativeWindowViews::NativeWindowViews(
|
||||||
options.Get(options::kResizable, &resizable_);
|
options.Get(options::kResizable, &resizable_);
|
||||||
options.Get(options::kMinimizable, &minimizable_);
|
options.Get(options::kMinimizable, &minimizable_);
|
||||||
options.Get(options::kMaximizable, &maximizable_);
|
options.Get(options::kMaximizable, &maximizable_);
|
||||||
|
|
||||||
|
// Transparent window must not have thick frame.
|
||||||
|
options.Get("thickFrame", &thick_frame_);
|
||||||
|
if (transparent())
|
||||||
|
thick_frame_ = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (enable_larger_than_screen())
|
if (enable_larger_than_screen())
|
||||||
|
@ -287,13 +296,13 @@ NativeWindowViews::NativeWindowViews(
|
||||||
if (maximizable_)
|
if (maximizable_)
|
||||||
frame_style |= WS_MAXIMIZEBOX;
|
frame_style |= WS_MAXIMIZEBOX;
|
||||||
// We should not show a frame for transparent window.
|
// We should not show a frame for transparent window.
|
||||||
if (transparent())
|
if (!thick_frame_)
|
||||||
frame_style &= ~(WS_THICKFRAME | WS_CAPTION);
|
frame_style &= ~(WS_THICKFRAME | WS_CAPTION);
|
||||||
::SetWindowLong(GetAcceleratedWidget(), GWL_STYLE, frame_style);
|
::SetWindowLong(GetAcceleratedWidget(), GWL_STYLE, frame_style);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (transparent()) {
|
if (!thick_frame_) {
|
||||||
// Transparent window on Windows has to have WS_EX_COMPOSITED style.
|
// Window without thick frame has to have WS_EX_COMPOSITED style.
|
||||||
LONG ex_style = ::GetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE);
|
LONG ex_style = ::GetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE);
|
||||||
ex_style |= WS_EX_COMPOSITED;
|
ex_style |= WS_EX_COMPOSITED;
|
||||||
::SetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE, ex_style);
|
::SetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE, ex_style);
|
||||||
|
@ -513,7 +522,7 @@ void NativeWindowViews::SetContentSizeConstraints(
|
||||||
|
|
||||||
void NativeWindowViews::SetResizable(bool resizable) {
|
void NativeWindowViews::SetResizable(bool resizable) {
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
if (!transparent())
|
if (thick_frame_)
|
||||||
FlipWindowStyle(GetAcceleratedWidget(), resizable, WS_THICKFRAME);
|
FlipWindowStyle(GetAcceleratedWidget(), resizable, WS_THICKFRAME);
|
||||||
#elif defined(USE_X11)
|
#elif defined(USE_X11)
|
||||||
if (resizable != resizable_) {
|
if (resizable != resizable_) {
|
||||||
|
@ -536,7 +545,11 @@ void NativeWindowViews::SetResizable(bool resizable) {
|
||||||
|
|
||||||
bool NativeWindowViews::IsResizable() {
|
bool NativeWindowViews::IsResizable() {
|
||||||
#if defined(OS_WIN)
|
#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
|
#else
|
||||||
return CanResize();
|
return CanResize();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -220,6 +220,9 @@ class NativeWindowViews : public NativeWindow,
|
||||||
// If true we have enabled a11y
|
// If true we have enabled a11y
|
||||||
bool enabled_a11y_support_;
|
bool enabled_a11y_support_;
|
||||||
|
|
||||||
|
// Whether to show the WS_THICKFRAME style.
|
||||||
|
bool thick_frame_;
|
||||||
|
|
||||||
// The icons of window and taskbar.
|
// The icons of window and taskbar.
|
||||||
base::win::ScopedHICON window_icon_;
|
base::win::ScopedHICON window_icon_;
|
||||||
base::win::ScopedHICON app_icon_;
|
base::win::ScopedHICON app_icon_;
|
||||||
|
|
|
@ -174,6 +174,9 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
|
||||||
this below.
|
this below.
|
||||||
* `titleBarStyle` String - The style of window title bar. See more about this
|
* `titleBarStyle` String - The style of window title bar. See more about this
|
||||||
below.
|
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
|
* `webPreferences` Object - Settings of web page's features. See more about
|
||||||
this below.
|
this below.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue