| 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* view_for_activation = |
| 244 GetWidget()->GetFocusManager()->GetFocusedView() ? |
| 245 GetWidget()->GetFocusManager()->GetFocusedView() : |
| 246 GetWidget()->GetFocusManager()->GetStoredFocusView(); |
| 247 if (!view_for_activation) |
| 248 view_for_activation = GetWidget()->GetRootView(); |
| 249 activation_client->ActivateWindow( |
| 250 view_for_activation->GetWidget()->GetNativeView()); |
| 251 } |
| 252 } else { |
| 253 // If we're not active we need to deactivate the corresponding |
| 254 // aura::Window. This way if a child widget is active it gets correctly |
| 255 // deactivated (child widgets don't get native desktop activation changes, |
| 256 // only aura activation changes). |
| 257 aura::Window* active_window = activation_client->GetActiveWindow(); |
| 258 if (active_window) |
| 259 activation_client->DeactivateWindow(active_window); |
| 260 } |
| 261 } |
| 262 |
| 232 //////////////////////////////////////////////////////////////////////////////// | 263 //////////////////////////////////////////////////////////////////////////////// |
| 233 // DesktopNativeWidgetAura, internal::NativeWidgetPrivate implementation: | 264 // DesktopNativeWidgetAura, internal::NativeWidgetPrivate implementation: |
| 234 | 265 |
| 235 void DesktopNativeWidgetAura::InitNativeWidget( | 266 void DesktopNativeWidgetAura::InitNativeWidget( |
| 236 const Widget::InitParams& params) { | 267 const Widget::InitParams& params) { |
| 237 ownership_ = params.ownership; | 268 ownership_ = params.ownership; |
| 238 | 269 |
| 239 NativeWidgetAura::RegisterNativeWidgetForWindow(this, window_); | 270 NativeWidgetAura::RegisterNativeWidgetForWindow(this, window_); |
| 240 // Animations on TYPE_WINDOW are handled by the OS. Additionally if we animate | 271 // Animations on TYPE_WINDOW are handled by the OS. Additionally if we animate |
| 241 // these windows the size of the window gets augmented, effecting restore | 272 // these windows the size of the window gets augmented, effecting restore |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 } | 961 } |
| 931 | 962 |
| 932 //////////////////////////////////////////////////////////////////////////////// | 963 //////////////////////////////////////////////////////////////////////////////// |
| 933 // DesktopNativeWidgetAura, NativeWidget implementation: | 964 // DesktopNativeWidgetAura, NativeWidget implementation: |
| 934 | 965 |
| 935 ui::EventHandler* DesktopNativeWidgetAura::GetEventHandler() { | 966 ui::EventHandler* DesktopNativeWidgetAura::GetEventHandler() { |
| 936 return this; | 967 return this; |
| 937 } | 968 } |
| 938 | 969 |
| 939 } // namespace views | 970 } // namespace views |
| OLD | NEW |