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

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

Issue 2451323002: Remove RestoreFocusedView in OnWindowActivated for DesktopNativeWidgetAura (Closed)
Patch Set: based on comments Created 4 years, 1 month 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
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_native_widget_aura.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/macros.h" 8 #include "base/macros.h"
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 wm::CursorManager* DesktopNativeWidgetAura::cursor_manager_ = NULL; 237 wm::CursorManager* DesktopNativeWidgetAura::cursor_manager_ = NULL;
238 238
239 DesktopNativeWidgetAura::DesktopNativeWidgetAura( 239 DesktopNativeWidgetAura::DesktopNativeWidgetAura(
240 internal::NativeWidgetDelegate* delegate) 240 internal::NativeWidgetDelegate* delegate)
241 : desktop_window_tree_host_(NULL), 241 : desktop_window_tree_host_(NULL),
242 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), 242 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET),
243 content_window_container_(NULL), 243 content_window_container_(NULL),
244 content_window_(new aura::Window(this)), 244 content_window_(new aura::Window(this)),
245 native_widget_delegate_(delegate), 245 native_widget_delegate_(delegate),
246 last_drop_operation_(ui::DragDropTypes::DRAG_NONE), 246 last_drop_operation_(ui::DragDropTypes::DRAG_NONE),
247 restore_focus_on_activate_(false),
248 cursor_(gfx::kNullCursor), 247 cursor_(gfx::kNullCursor),
249 widget_type_(Widget::InitParams::TYPE_WINDOW), 248 widget_type_(Widget::InitParams::TYPE_WINDOW),
250 close_widget_factory_(this) { 249 close_widget_factory_(this) {
251 aura::client::SetFocusChangeObserver(content_window_, this); 250 aura::client::SetFocusChangeObserver(content_window_, this);
252 aura::client::SetActivationChangeObserver(content_window_, this); 251 aura::client::SetActivationChangeObserver(content_window_, this);
253 } 252 }
254 253
255 DesktopNativeWidgetAura::~DesktopNativeWidgetAura() { 254 DesktopNativeWidgetAura::~DesktopNativeWidgetAura() {
256 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) 255 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET)
257 delete native_widget_delegate_; 256 delete native_widget_delegate_;
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 1073
1075 //////////////////////////////////////////////////////////////////////////////// 1074 ////////////////////////////////////////////////////////////////////////////////
1076 // DesktopNativeWidgetAura, aura::client::ActivationChangeObserver 1075 // DesktopNativeWidgetAura, aura::client::ActivationChangeObserver
1077 // implementation: 1076 // implementation:
1078 1077
1079 void DesktopNativeWidgetAura::OnWindowActivated( 1078 void DesktopNativeWidgetAura::OnWindowActivated(
1080 aura::client::ActivationChangeObserver::ActivationReason reason, 1079 aura::client::ActivationChangeObserver::ActivationReason reason,
1081 aura::Window* gained_active, 1080 aura::Window* gained_active,
1082 aura::Window* lost_active) { 1081 aura::Window* lost_active) {
1083 DCHECK(content_window_ == gained_active || content_window_ == lost_active); 1082 DCHECK(content_window_ == gained_active || content_window_ == lost_active);
1084 if (gained_active == content_window_ && restore_focus_on_activate_) { 1083 if (lost_active == content_window_ && GetWidget()->HasFocusManager()) {
1085 restore_focus_on_activate_ = false;
1086 GetWidget()->GetFocusManager()->RestoreFocusedView();
1087 } else if (lost_active == content_window_ && GetWidget()->HasFocusManager()) {
1088 DCHECK(!restore_focus_on_activate_);
1089 restore_focus_on_activate_ = true;
1090 // Pass in false so that ClearNativeFocus() isn't invoked. 1084 // Pass in false so that ClearNativeFocus() isn't invoked.
1091 GetWidget()->GetFocusManager()->StoreFocusedView(false); 1085 GetWidget()->GetFocusManager()->StoreFocusedView(false);
1092 } 1086 }
1093 } 1087 }
1094 1088
1095 //////////////////////////////////////////////////////////////////////////////// 1089 ////////////////////////////////////////////////////////////////////////////////
1096 // DesktopNativeWidgetAura, aura::client::FocusChangeObserver implementation: 1090 // DesktopNativeWidgetAura, aura::client::FocusChangeObserver implementation:
1097 1091
1098 void DesktopNativeWidgetAura::OnWindowFocused(aura::Window* gained_focus, 1092 void DesktopNativeWidgetAura::OnWindowFocused(aura::Window* gained_focus,
1099 aura::Window* lost_focus) { 1093 aura::Window* lost_focus) {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 if (cursor_reference_count_ == 0) { 1180 if (cursor_reference_count_ == 0) {
1187 // We are the last DesktopNativeWidgetAura instance, and we are responsible 1181 // We are the last DesktopNativeWidgetAura instance, and we are responsible
1188 // for cleaning up |cursor_manager_|. 1182 // for cleaning up |cursor_manager_|.
1189 delete cursor_manager_; 1183 delete cursor_manager_;
1190 native_cursor_manager_ = NULL; 1184 native_cursor_manager_ = NULL;
1191 cursor_manager_ = NULL; 1185 cursor_manager_ = NULL;
1192 } 1186 }
1193 } 1187 }
1194 1188
1195 } // namespace views 1189 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_native_widget_aura.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698