On Windows focusable: false also means skipTaskbar: true

This commit is contained in:
Cheng Zhao 2016-06-13 17:24:45 +09:00
parent 8eca728e0a
commit 50f1837097
3 changed files with 14 additions and 7 deletions

View file

@ -153,7 +153,7 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) {
SetFullScreen(true); SetFullScreen(true);
} }
bool skip; bool skip;
if (options.Get(options::kSkipTaskbar, &skip) && skip) { if (options.Get(options::kSkipTaskbar, &skip)) {
SetSkipTaskbar(skip); SetSkipTaskbar(skip);
} }
bool kiosk; bool kiosk;

View file

@ -181,6 +181,10 @@ NativeWindowViews::NativeWindowViews(
if (transparent() && !has_frame()) if (transparent() && !has_frame())
params.shadow_type = views::Widget::InitParams::SHADOW_TYPE_NONE; params.shadow_type = views::Widget::InitParams::SHADOW_TYPE_NONE;
bool focusable;
if (options.Get(options::kFocusable, &focusable) && !focusable)
params.activatable = views::Widget::InitParams::ACTIVATABLE_NO;
#if defined(OS_WIN) #if defined(OS_WIN)
params.native_widget = params.native_widget =
new views::DesktopNativeWidgetAura(window_.get()); new views::DesktopNativeWidgetAura(window_.get());
@ -696,10 +700,12 @@ void NativeWindowViews::SetFocusable(bool focusable) {
#if defined(OS_WIN) #if defined(OS_WIN)
LONG ex_style = ::GetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE); LONG ex_style = ::GetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE);
if (focusable) if (focusable)
ex_style |= WS_EX_NOACTIVATE;
else
ex_style &= ~WS_EX_NOACTIVATE; ex_style &= ~WS_EX_NOACTIVATE;
else
ex_style |= WS_EX_NOACTIVATE;
::SetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE, ex_style); ::SetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE, ex_style);
SetSkipTaskbar(!focusable);
Focus(false);
#endif #endif
} }

View file

@ -55,7 +55,8 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
* `closable` Boolean - Whether window is closable. This is not implemented * `closable` Boolean - Whether window is closable. This is not implemented
on Linux. Default is `true`. on Linux. Default is `true`.
* `focusable` Boolean - Whether the window can be focused. Default is * `focusable` Boolean - Whether the window can be focused. Default is
`true`. `true`. On Windows setting `focusable: false` also implies setting
`skipTaskbar: true`.
* `alwaysOnTop` Boolean - Whether the window should always stay on top of * `alwaysOnTop` Boolean - Whether the window should always stay on top of
other windows. Default is `false`. other windows. Default is `false`.
* `fullscreen` Boolean - Whether the window should show in fullscreen. When * `fullscreen` Boolean - Whether the window should show in fullscreen. When
@ -955,10 +956,10 @@ All mouse events happened in this window will be passed to the window below
this window, but if this window has focus, it will still receive keyboard this window, but if this window has focus, it will still receive keyboard
events. events.
### `win.setActivatable(activatable)` _Windows_ ### `win.setFocusable(focusable)` _Windows_
* `activatable` Boolean * `focusable` Boolean
Changes whether the window can be activated. Changes whether the window can be focused.
[blink-feature-string]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in [blink-feature-string]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in