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

Side by Side 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: Return if there is no windows with keyboard focus. 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 5 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "ui/aura/client/aura_constants.h" 9 #include "ui/aura/client/aura_constants.h"
10 #include "ui/aura/client/cursor_client.h" 10 #include "ui/aura/client/cursor_client.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 internal::NativeWidgetDelegate* delegate) 252 internal::NativeWidgetDelegate* delegate)
253 : desktop_window_tree_host_(NULL), 253 : desktop_window_tree_host_(NULL),
254 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), 254 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET),
255 close_widget_factory_(this), 255 close_widget_factory_(this),
256 content_window_container_(NULL), 256 content_window_container_(NULL),
257 content_window_(new aura::Window(this)), 257 content_window_(new aura::Window(this)),
258 native_widget_delegate_(delegate), 258 native_widget_delegate_(delegate),
259 last_drop_operation_(ui::DragDropTypes::DRAG_NONE), 259 last_drop_operation_(ui::DragDropTypes::DRAG_NONE),
260 restore_focus_on_activate_(false), 260 restore_focus_on_activate_(false),
261 restore_focus_on_window_focus_(false), 261 restore_focus_on_window_focus_(false),
262 intercept_all_keys_on_focus_(false),
262 cursor_(gfx::kNullCursor), 263 cursor_(gfx::kNullCursor),
263 widget_type_(Widget::InitParams::TYPE_WINDOW) { 264 widget_type_(Widget::InitParams::TYPE_WINDOW) {
264 aura::client::SetFocusChangeObserver(content_window_, this); 265 aura::client::SetFocusChangeObserver(content_window_, this);
265 aura::client::SetActivationChangeObserver(content_window_, this); 266 aura::client::SetActivationChangeObserver(content_window_, this);
266 } 267 }
267 268
268 DesktopNativeWidgetAura::~DesktopNativeWidgetAura() { 269 DesktopNativeWidgetAura::~DesktopNativeWidgetAura() {
269 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) 270 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET)
270 delete native_widget_delegate_; 271 delete native_widget_delegate_;
271 else 272 else
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 807
807 bool DesktopNativeWidgetAura::IsAlwaysOnTop() const { 808 bool DesktopNativeWidgetAura::IsAlwaysOnTop() const {
808 return content_window_ && desktop_window_tree_host_->IsAlwaysOnTop(); 809 return content_window_ && desktop_window_tree_host_->IsAlwaysOnTop();
809 } 810 }
810 811
811 void DesktopNativeWidgetAura::SetVisibleOnAllWorkspaces(bool always_visible) { 812 void DesktopNativeWidgetAura::SetVisibleOnAllWorkspaces(bool always_visible) {
812 if (content_window_) 813 if (content_window_)
813 desktop_window_tree_host_->SetVisibleOnAllWorkspaces(always_visible); 814 desktop_window_tree_host_->SetVisibleOnAllWorkspaces(always_visible);
814 } 815 }
815 816
817 void DesktopNativeWidgetAura::SetInterceptAllKeys(bool want_all_keys) {
818 // Enable immediately if the window is active.
819 if (IsActive()) {
ananta 2014/08/15 18:07:26 IsActive is not going to work correctly as it uses
820 desktop_window_tree_host_->SetInterceptAllKeys(want_all_keys);
821 }
822 intercept_all_keys_on_focus_ = want_all_keys;
823 }
824
816 void DesktopNativeWidgetAura::Maximize() { 825 void DesktopNativeWidgetAura::Maximize() {
817 if (content_window_) 826 if (content_window_)
818 desktop_window_tree_host_->Maximize(); 827 desktop_window_tree_host_->Maximize();
819 } 828 }
820 829
821 void DesktopNativeWidgetAura::Minimize() { 830 void DesktopNativeWidgetAura::Minimize() {
822 if (content_window_) 831 if (content_window_)
823 desktop_window_tree_host_->Minimize(); 832 desktop_window_tree_host_->Minimize();
824 } 833 }
825 834
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 return native_widget_delegate_->CanActivate(); 1076 return native_widget_delegate_->CanActivate();
1068 } 1077 }
1069 1078
1070 //////////////////////////////////////////////////////////////////////////////// 1079 ////////////////////////////////////////////////////////////////////////////////
1071 // DesktopNativeWidgetAura, aura::client::ActivationChangeObserver 1080 // DesktopNativeWidgetAura, aura::client::ActivationChangeObserver
1072 // implementation: 1081 // implementation:
1073 1082
1074 void DesktopNativeWidgetAura::OnWindowActivated(aura::Window* gained_active, 1083 void DesktopNativeWidgetAura::OnWindowActivated(aura::Window* gained_active,
1075 aura::Window* lost_active) { 1084 aura::Window* lost_active) {
1076 DCHECK(content_window_ == gained_active || content_window_ == lost_active); 1085 DCHECK(content_window_ == gained_active || content_window_ == lost_active);
1086
1087 if (intercept_all_keys_on_focus_) {
1088 desktop_window_tree_host_->SetInterceptAllKeys(gained_active ==
1089 content_window_);
1090 }
1091
1077 if (gained_active == content_window_ && restore_focus_on_activate_) { 1092 if (gained_active == content_window_ && restore_focus_on_activate_) {
1078 restore_focus_on_activate_ = false; 1093 restore_focus_on_activate_ = false;
1079 GetWidget()->GetFocusManager()->RestoreFocusedView(); 1094 GetWidget()->GetFocusManager()->RestoreFocusedView();
1080 } else if (lost_active == content_window_ && GetWidget()->HasFocusManager()) { 1095 } else if (lost_active == content_window_ && GetWidget()->HasFocusManager()) {
1081 DCHECK(!restore_focus_on_activate_); 1096 DCHECK(!restore_focus_on_activate_);
1082 restore_focus_on_activate_ = true; 1097 restore_focus_on_activate_ = true;
1083 // Pass in false so that ClearNativeFocus() isn't invoked. 1098 // Pass in false so that ClearNativeFocus() isn't invoked.
1084 GetWidget()->GetFocusManager()->StoreFocusedView(false); 1099 GetWidget()->GetFocusManager()->StoreFocusedView(false);
1085 } 1100 }
1086 } 1101 }
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 if (cursor_reference_count_ == 0) { 1228 if (cursor_reference_count_ == 0) {
1214 // We are the last DesktopNativeWidgetAura instance, and we are responsible 1229 // We are the last DesktopNativeWidgetAura instance, and we are responsible
1215 // for cleaning up |cursor_manager_|. 1230 // for cleaning up |cursor_manager_|.
1216 delete cursor_manager_; 1231 delete cursor_manager_;
1217 native_cursor_manager_ = NULL; 1232 native_cursor_manager_ = NULL;
1218 cursor_manager_ = NULL; 1233 cursor_manager_ = NULL;
1219 } 1234 }
1220 } 1235 }
1221 1236
1222 } // namespace views 1237 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698