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 "ui/aura/client/activation_client.h" | 8 #include "ui/aura/client/activation_client.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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
222 new corewm::InputMethodEventFilter(root->GetAcceleratedWidget())); | 222 new corewm::InputMethodEventFilter(root->GetAcceleratedWidget())); |
223 input_method_event_filter_->SetInputMethodPropertyInRootWindow(root); | 223 input_method_event_filter_->SetInputMethodPropertyInRootWindow(root); |
224 root_window_event_filter_->AddHandler(input_method_event_filter_.get()); | 224 root_window_event_filter_->AddHandler(input_method_event_filter_.get()); |
225 } | 225 } |
226 | 226 |
227 void DesktopNativeWidgetAura::CreateCaptureClient(aura::RootWindow* root) { | 227 void DesktopNativeWidgetAura::CreateCaptureClient(aura::RootWindow* root) { |
228 DCHECK(!capture_client_.get()); | 228 DCHECK(!capture_client_.get()); |
229 capture_client_.reset(new corewm::ScopedCaptureClient(root)); | 229 capture_client_.reset(new corewm::ScopedCaptureClient(root)); |
230 } | 230 } |
231 | 231 |
232 void DesktopNativeWidgetAura::HandleActivationChanged(bool active) { | |
233 native_widget_delegate_->OnNativeWidgetActivationChanged(active); | |
234 aura::client::ActivationClient* activation_client = | |
235 aura::client::GetActivationClient(root_window_.get()); | |
236 if (!activation_client) | |
237 return; | |
238 if (active) { | |
239 if (GetWidget()->HasFocusManager()) { | |
240 // This function can be called before the focus manager has had a | |
241 // chance to set the focused view. In which case we should get the | |
242 // last focused view. | |
243 View* focus_view = GetWidget()->GetFocusManager()->GetFocusedView(); | |
244 if (!focus_view) | |
245 focus_view = GetWidget()->GetFocusManager()->GetStoredFocusView(); | |
246 if (focus_view) | |
247 activation_client->ActivateWindow( | |
248 focus_view->GetWidget()->GetNativeView()); | |
sky
2013/09/03 18:21:51
Shouldn't we activate something if we can't find a
ananta
2013/09/03 19:03:31
Added code to activate the root view, if we don't
| |
249 } | |
250 } else { | |
251 // If we're not active we need to deactivate the corresponding | |
252 // aura::Window. This way if a child widget is active it gets correctly | |
253 // deactivated (child widgets don't get native desktop activation changes, | |
254 // only aura activation changes). | |
255 aura::Window* active_window = activation_client->GetActiveWindow(); | |
256 if (active_window) | |
257 activation_client->DeactivateWindow(active_window); | |
258 } | |
259 } | |
260 | |
232 //////////////////////////////////////////////////////////////////////////////// | 261 //////////////////////////////////////////////////////////////////////////////// |
233 // DesktopNativeWidgetAura, internal::NativeWidgetPrivate implementation: | 262 // DesktopNativeWidgetAura, internal::NativeWidgetPrivate implementation: |
234 | 263 |
235 void DesktopNativeWidgetAura::InitNativeWidget( | 264 void DesktopNativeWidgetAura::InitNativeWidget( |
236 const Widget::InitParams& params) { | 265 const Widget::InitParams& params) { |
237 ownership_ = params.ownership; | 266 ownership_ = params.ownership; |
238 | 267 |
239 NativeWidgetAura::RegisterNativeWidgetForWindow(this, window_); | 268 NativeWidgetAura::RegisterNativeWidgetForWindow(this, window_); |
240 window_->SetType(GetAuraWindowTypeForWidgetType(params.type)); | 269 window_->SetType(GetAuraWindowTypeForWidgetType(params.type)); |
241 window_->SetTransparent(true); | 270 window_->SetTransparent(true); |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
923 } | 952 } |
924 | 953 |
925 //////////////////////////////////////////////////////////////////////////////// | 954 //////////////////////////////////////////////////////////////////////////////// |
926 // DesktopNativeWidgetAura, NativeWidget implementation: | 955 // DesktopNativeWidgetAura, NativeWidget implementation: |
927 | 956 |
928 ui::EventHandler* DesktopNativeWidgetAura::GetEventHandler() { | 957 ui::EventHandler* DesktopNativeWidgetAura::GetEventHandler() { |
929 return this; | 958 return this; |
930 } | 959 } |
931 | 960 |
932 } // namespace views | 961 } // namespace views |
OLD | NEW |