Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(565)

Unified Diff: ui/views/widget/desktop_aura/desktop_native_widget_aura.cc

Issue 297123002: API proposal for chrome.app.window to intercept all keys. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comments to explain logic behind posting instead of directly handling keyboard events. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
index 9d1861e41db23fb1956fcc03e03065064455200c..e2e25e82555fdc20e9389db54bab7f14c907d41b 100644
--- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
+++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
@@ -259,6 +259,7 @@ DesktopNativeWidgetAura::DesktopNativeWidgetAura(
last_drop_operation_(ui::DragDropTypes::DRAG_NONE),
restore_focus_on_activate_(false),
restore_focus_on_window_focus_(false),
+ intercept_all_keys_on_focus_(false),
cursor_(gfx::kNullCursor),
widget_type_(Widget::InitParams::TYPE_WINDOW) {
aura::client::SetFocusChangeObserver(content_window_, this);
@@ -813,6 +814,14 @@ void DesktopNativeWidgetAura::SetVisibleOnAllWorkspaces(bool always_visible) {
desktop_window_tree_host_->SetVisibleOnAllWorkspaces(always_visible);
}
+void DesktopNativeWidgetAura::SetInterceptAllKeys(bool want_all_keys) {
+ // Enable immediately if the window is active.
+ if (IsActive()) {
+ desktop_window_tree_host_->SetInterceptAllKeys(want_all_keys);
+ }
+ intercept_all_keys_on_focus_ = want_all_keys;
+}
+
void DesktopNativeWidgetAura::Maximize() {
if (content_window_)
desktop_window_tree_host_->Maximize();
@@ -1074,6 +1083,12 @@ bool DesktopNativeWidgetAura::ShouldActivate() const {
void DesktopNativeWidgetAura::OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) {
DCHECK(content_window_ == gained_active || content_window_ == lost_active);
+
+ if (intercept_all_keys_on_focus_) {
+ desktop_window_tree_host_->SetInterceptAllKeys(gained_active ==
+ content_window_);
+ }
+
if (gained_active == content_window_ && restore_focus_on_activate_) {
restore_focus_on_activate_ = false;
GetWidget()->GetFocusManager()->RestoreFocusedView();

Powered by Google App Engine
This is Rietveld 408576698