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

Side by Side Diff: ui/views/widget/desktop_aura/desktop_native_widget_aura.cc

Issue 438113002: Merge 286589 "Do not save and restore View focus on aura::Window..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/2062/src/
Patch Set: 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 | Annotate | Revision Log
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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 DesktopNativeWidgetAura::DesktopNativeWidgetAura( 251 DesktopNativeWidgetAura::DesktopNativeWidgetAura(
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),
262 cursor_(gfx::kNullCursor), 261 cursor_(gfx::kNullCursor),
263 widget_type_(Widget::InitParams::TYPE_WINDOW) { 262 widget_type_(Widget::InitParams::TYPE_WINDOW) {
264 aura::client::SetFocusChangeObserver(content_window_, this); 263 aura::client::SetFocusChangeObserver(content_window_, this);
265 aura::client::SetActivationChangeObserver(content_window_, this); 264 aura::client::SetActivationChangeObserver(content_window_, this);
266 } 265 }
267 266
268 DesktopNativeWidgetAura::~DesktopNativeWidgetAura() { 267 DesktopNativeWidgetAura::~DesktopNativeWidgetAura() {
269 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) 268 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET)
270 delete native_widget_delegate_; 269 delete native_widget_delegate_;
271 else 270 else
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 //////////////////////////////////////////////////////////////////////////////// 1087 ////////////////////////////////////////////////////////////////////////////////
1089 // DesktopNativeWidgetAura, aura::client::FocusChangeObserver implementation: 1088 // DesktopNativeWidgetAura, aura::client::FocusChangeObserver implementation:
1090 1089
1091 void DesktopNativeWidgetAura::OnWindowFocused(aura::Window* gained_focus, 1090 void DesktopNativeWidgetAura::OnWindowFocused(aura::Window* gained_focus,
1092 aura::Window* lost_focus) { 1091 aura::Window* lost_focus) {
1093 if (content_window_ == gained_focus) { 1092 if (content_window_ == gained_focus) {
1094 desktop_window_tree_host_->OnNativeWidgetFocus(); 1093 desktop_window_tree_host_->OnNativeWidgetFocus();
1095 native_widget_delegate_->OnNativeFocus(lost_focus); 1094 native_widget_delegate_->OnNativeFocus(lost_focus);
1096 1095
1097 // If focus is moving from a descendant Window to |content_window_| then 1096 // If focus is moving from a descendant Window to |content_window_| then
1098 // native activation hasn't changed. Still, the InputMethod and FocusManager 1097 // native activation hasn't changed. Still, the InputMethod must be informed
1099 // must be informed of the Window focus change. 1098 // of the Window focus change.
1100 InputMethod* input_method = GetWidget()->GetInputMethod(); 1099 InputMethod* input_method = GetWidget()->GetInputMethod();
1101 if (input_method) 1100 if (input_method)
1102 input_method->OnFocus(); 1101 input_method->OnFocus();
1103
1104 if (restore_focus_on_window_focus_) {
1105 restore_focus_on_window_focus_ = false;
1106 GetWidget()->GetFocusManager()->RestoreFocusedView();
1107 }
1108 } else if (content_window_ == lost_focus) { 1102 } else if (content_window_ == lost_focus) {
1109 desktop_window_tree_host_->OnNativeWidgetBlur(); 1103 desktop_window_tree_host_->OnNativeWidgetBlur();
1110 native_widget_delegate_->OnNativeBlur(gained_focus); 1104 native_widget_delegate_->OnNativeBlur(gained_focus);
1111
1112 DCHECK(!restore_focus_on_window_focus_);
1113 restore_focus_on_window_focus_ = true;
1114 GetWidget()->GetFocusManager()->StoreFocusedView(false);
1115 } 1105 }
1116 } 1106 }
1117 1107
1118 //////////////////////////////////////////////////////////////////////////////// 1108 ////////////////////////////////////////////////////////////////////////////////
1119 // DesktopNativeWidgetAura, views::internal::InputMethodDelegate: 1109 // DesktopNativeWidgetAura, views::internal::InputMethodDelegate:
1120 1110
1121 void DesktopNativeWidgetAura::DispatchKeyEventPostIME(const ui::KeyEvent& key) { 1111 void DesktopNativeWidgetAura::DispatchKeyEventPostIME(const ui::KeyEvent& key) {
1122 FocusManager* focus_manager = 1112 FocusManager* focus_manager =
1123 native_widget_delegate_->AsWidget()->GetFocusManager(); 1113 native_widget_delegate_->AsWidget()->GetFocusManager();
1124 native_widget_delegate_->OnKeyEvent(const_cast<ui::KeyEvent*>(&key)); 1114 native_widget_delegate_->OnKeyEvent(const_cast<ui::KeyEvent*>(&key));
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 if (cursor_reference_count_ == 0) { 1203 if (cursor_reference_count_ == 0) {
1214 // We are the last DesktopNativeWidgetAura instance, and we are responsible 1204 // We are the last DesktopNativeWidgetAura instance, and we are responsible
1215 // for cleaning up |cursor_manager_|. 1205 // for cleaning up |cursor_manager_|.
1216 delete cursor_manager_; 1206 delete cursor_manager_;
1217 native_cursor_manager_ = NULL; 1207 native_cursor_manager_ = NULL;
1218 cursor_manager_ = NULL; 1208 cursor_manager_ = NULL;
1219 } 1209 }
1220 } 1210 }
1221 1211
1222 } // namespace views 1212 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_native_widget_aura.h ('k') | ui/views/widget/native_widget_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698