Include CanFocus on Windows and map to state
This commit is contained in:
parent
0ac3969c6a
commit
be79417a03
6 changed files with 63 additions and 5 deletions
|
@ -48,6 +48,7 @@
|
|||
#include "ui/views/window/native_frame_view.h"
|
||||
#elif defined(OS_WIN)
|
||||
#include "atom/browser/ui/views/win_frame_view.h"
|
||||
#include "atom/browser/ui/win/atom_desktop_native_widget_aura.h"
|
||||
#include "atom/browser/ui/win/atom_desktop_window_tree_host_win.h"
|
||||
#include "skia/ext/skia_utils_win.h"
|
||||
#include "ui/base/win/shell.h"
|
||||
|
@ -148,7 +149,8 @@ NativeWindowViews::NativeWindowViews(
|
|||
resizable_(true),
|
||||
maximizable_(true),
|
||||
minimizable_(true),
|
||||
fullscreenable_(true) {
|
||||
fullscreenable_(true),
|
||||
focusable_(true) {
|
||||
options.Get(options::kTitle, &title_);
|
||||
options.Get(options::kAutoHideMenuBar, &menu_bar_autohide_);
|
||||
|
||||
|
@ -196,16 +198,14 @@ NativeWindowViews::NativeWindowViews(
|
|||
if (transparent() && !has_frame())
|
||||
params.shadow_type = views::Widget::InitParams::SHADOW_TYPE_NONE;
|
||||
|
||||
bool focusable;
|
||||
if (options.Get(options::kFocusable, &focusable) && !focusable)
|
||||
if (options.Get(options::kFocusable, &focusable_) && !focusable_)
|
||||
params.activatable = views::Widget::InitParams::ACTIVATABLE_NO;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
if (parent)
|
||||
params.parent = parent->GetNativeWindow();
|
||||
|
||||
params.native_widget =
|
||||
new views::DesktopNativeWidgetAura(window_.get());
|
||||
params.native_widget = new AtomDeskopNativeWidgetAura(window_.get(), this);
|
||||
atom_desktop_window_tree_host_win_ = new AtomDesktopWindowTreeHostWin(
|
||||
this,
|
||||
window_.get(),
|
||||
|
@ -806,6 +806,7 @@ void NativeWindowViews::SetContentProtection(bool enable) {
|
|||
}
|
||||
|
||||
void NativeWindowViews::SetFocusable(bool focusable) {
|
||||
focusable_ = focusable;
|
||||
#if defined(OS_WIN)
|
||||
LONG ex_style = ::GetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE);
|
||||
if (focusable)
|
||||
|
|
|
@ -130,6 +130,7 @@ class NativeWindowViews : public NativeWindow,
|
|||
|
||||
#if defined(OS_WIN)
|
||||
TaskbarHost& taskbar_host() { return taskbar_host_; }
|
||||
bool CanFocus();
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
@ -262,6 +263,7 @@ class NativeWindowViews : public NativeWindow,
|
|||
bool maximizable_;
|
||||
bool minimizable_;
|
||||
bool fullscreenable_;
|
||||
bool focusable_;
|
||||
std::string title_;
|
||||
gfx::Size widget_size_;
|
||||
|
||||
|
|
|
@ -202,4 +202,8 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) {
|
|||
}
|
||||
}
|
||||
|
||||
bool NativeWindowViews::CanFocus() {
|
||||
return focusable_ && IsVisible();
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
20
atom/browser/ui/win/atom_desktop_native_widget_aura.cc
Normal file
20
atom/browser/ui/win/atom_desktop_native_widget_aura.cc
Normal file
|
@ -0,0 +1,20 @@
|
|||
// Copyright (c) 2017 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/ui/win/atom_desktop_native_widget_aura.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
AtomDeskopNativeWidgetAura::AtomDeskopNativeWidgetAura(
|
||||
views::internal::NativeWidgetDelegate* delegate,
|
||||
NativeWindowViews* window)
|
||||
: views::DesktopNativeWidgetAura(delegate),
|
||||
window_(window) {
|
||||
}
|
||||
|
||||
bool AtomDeskopNativeWidgetAura::CanFocus() {
|
||||
return window_->CanFocus();
|
||||
}
|
||||
|
||||
} // namespace atom
|
29
atom/browser/ui/win/atom_desktop_native_widget_aura.h
Normal file
29
atom/browser/ui/win/atom_desktop_native_widget_aura.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
// Copyright (c) 2017 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_UI_WIN_ATOM_DESKTOP_NATIVE_WIDGET_AURA_H_
|
||||
#define ATOM_BROWSER_UI_WIN_ATOM_DESKTOP_NATIVE_WIDGET_AURA_H_
|
||||
|
||||
#include "atom/browser/native_window_views.h"
|
||||
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
class AtomDeskopNativeWidgetAura : public views::DesktopNativeWidgetAura {
|
||||
public:
|
||||
AtomDeskopNativeWidgetAura(views::internal::NativeWidgetDelegate* delegate,
|
||||
NativeWindowViews* window);
|
||||
|
||||
// aura::WindowDelegate
|
||||
bool CanFocus() override;
|
||||
|
||||
private:
|
||||
NativeWindowViews* window_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomDeskopNativeWidgetAura);
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_UI_WIN_ATOM_DESKTOP_NATIVE_WIDGET_AURA_H_
|
|
@ -317,6 +317,8 @@
|
|||
'atom/browser/ui/views/submenu_button.h',
|
||||
'atom/browser/ui/views/win_frame_view.cc',
|
||||
'atom/browser/ui/views/win_frame_view.h',
|
||||
'atom/browser/ui/win/atom_desktop_native_widget_aura.cc',
|
||||
'atom/browser/ui/win/atom_desktop_native_widget_aura.h',
|
||||
'atom/browser/ui/win/atom_desktop_window_tree_host_win.cc',
|
||||
'atom/browser/ui/win/atom_desktop_window_tree_host_win.h',
|
||||
'atom/browser/ui/win/jump_list.cc',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue