OLD | NEW |
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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 internal::NativeWidgetDelegate* delegate) | 249 internal::NativeWidgetDelegate* delegate) |
250 : desktop_window_tree_host_(NULL), | 250 : desktop_window_tree_host_(NULL), |
251 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), | 251 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), |
252 close_widget_factory_(this), | 252 close_widget_factory_(this), |
253 can_activate_(true), | 253 can_activate_(true), |
254 content_window_container_(NULL), | 254 content_window_container_(NULL), |
255 content_window_(new aura::Window(this)), | 255 content_window_(new aura::Window(this)), |
256 native_widget_delegate_(delegate), | 256 native_widget_delegate_(delegate), |
257 last_drop_operation_(ui::DragDropTypes::DRAG_NONE), | 257 last_drop_operation_(ui::DragDropTypes::DRAG_NONE), |
258 restore_focus_on_activate_(false), | 258 restore_focus_on_activate_(false), |
259 restore_focus_on_window_focus_(false), | |
260 cursor_(gfx::kNullCursor), | 259 cursor_(gfx::kNullCursor), |
261 widget_type_(Widget::InitParams::TYPE_WINDOW) { | 260 widget_type_(Widget::InitParams::TYPE_WINDOW) { |
262 aura::client::SetFocusChangeObserver(content_window_, this); | 261 aura::client::SetFocusChangeObserver(content_window_, this); |
263 aura::client::SetActivationChangeObserver(content_window_, this); | 262 aura::client::SetActivationChangeObserver(content_window_, this); |
264 } | 263 } |
265 | 264 |
266 DesktopNativeWidgetAura::~DesktopNativeWidgetAura() { | 265 DesktopNativeWidgetAura::~DesktopNativeWidgetAura() { |
267 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) | 266 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) |
268 delete native_widget_delegate_; | 267 delete native_widget_delegate_; |
269 else | 268 else |
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1074 //////////////////////////////////////////////////////////////////////////////// | 1073 //////////////////////////////////////////////////////////////////////////////// |
1075 // DesktopNativeWidgetAura, aura::client::FocusChangeObserver implementation: | 1074 // DesktopNativeWidgetAura, aura::client::FocusChangeObserver implementation: |
1076 | 1075 |
1077 void DesktopNativeWidgetAura::OnWindowFocused(aura::Window* gained_focus, | 1076 void DesktopNativeWidgetAura::OnWindowFocused(aura::Window* gained_focus, |
1078 aura::Window* lost_focus) { | 1077 aura::Window* lost_focus) { |
1079 if (content_window_ == gained_focus) { | 1078 if (content_window_ == gained_focus) { |
1080 desktop_window_tree_host_->OnNativeWidgetFocus(); | 1079 desktop_window_tree_host_->OnNativeWidgetFocus(); |
1081 native_widget_delegate_->OnNativeFocus(lost_focus); | 1080 native_widget_delegate_->OnNativeFocus(lost_focus); |
1082 | 1081 |
1083 // If focus is moving from a descendant Window to |content_window_| then | 1082 // If focus is moving from a descendant Window to |content_window_| then |
1084 // native activation hasn't changed. Still, the InputMethod and FocusManager | 1083 // native activation hasn't changed. We still need to inform the InputMethod |
1085 // must be informed of the Window focus change. | 1084 // we've been focused though. |
1086 InputMethod* input_method = GetWidget()->GetInputMethod(); | 1085 InputMethod* input_method = GetWidget()->GetInputMethod(); |
1087 if (input_method) | 1086 if (input_method) |
1088 input_method->OnFocus(); | 1087 input_method->OnFocus(); |
1089 | |
1090 if (restore_focus_on_window_focus_) { | |
1091 restore_focus_on_window_focus_ = false; | |
1092 GetWidget()->GetFocusManager()->RestoreFocusedView(); | |
1093 } | |
1094 } else if (content_window_ == lost_focus) { | 1088 } else if (content_window_ == lost_focus) { |
1095 desktop_window_tree_host_->OnNativeWidgetBlur(); | 1089 desktop_window_tree_host_->OnNativeWidgetBlur(); |
1096 native_widget_delegate_->OnNativeBlur(gained_focus); | 1090 native_widget_delegate_->OnNativeBlur( |
1097 | 1091 aura::client::GetFocusClient(content_window_)->GetFocusedWindow()); |
1098 DCHECK(!restore_focus_on_window_focus_); | |
1099 restore_focus_on_window_focus_ = true; | |
1100 GetWidget()->GetFocusManager()->StoreFocusedView(false); | |
1101 } | 1092 } |
1102 } | 1093 } |
1103 | 1094 |
1104 //////////////////////////////////////////////////////////////////////////////// | 1095 //////////////////////////////////////////////////////////////////////////////// |
1105 // DesktopNativeWidgetAura, views::internal::InputMethodDelegate: | 1096 // DesktopNativeWidgetAura, views::internal::InputMethodDelegate: |
1106 | 1097 |
1107 void DesktopNativeWidgetAura::DispatchKeyEventPostIME(const ui::KeyEvent& key) { | 1098 void DesktopNativeWidgetAura::DispatchKeyEventPostIME(const ui::KeyEvent& key) { |
1108 FocusManager* focus_manager = | 1099 FocusManager* focus_manager = |
1109 native_widget_delegate_->AsWidget()->GetFocusManager(); | 1100 native_widget_delegate_->AsWidget()->GetFocusManager(); |
1110 native_widget_delegate_->OnKeyEvent(const_cast<ui::KeyEvent*>(&key)); | 1101 native_widget_delegate_->OnKeyEvent(const_cast<ui::KeyEvent*>(&key)); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 if (cursor_reference_count_ == 0) { | 1194 if (cursor_reference_count_ == 0) { |
1204 // We are the last DesktopNativeWidgetAura instance, and we are responsible | 1195 // We are the last DesktopNativeWidgetAura instance, and we are responsible |
1205 // for cleaning up |cursor_manager_|. | 1196 // for cleaning up |cursor_manager_|. |
1206 delete cursor_manager_; | 1197 delete cursor_manager_; |
1207 native_cursor_manager_ = NULL; | 1198 native_cursor_manager_ = NULL; |
1208 cursor_manager_ = NULL; | 1199 cursor_manager_ = NULL; |
1209 } | 1200 } |
1210 } | 1201 } |
1211 | 1202 |
1212 } // namespace views | 1203 } // namespace views |
OLD | NEW |