| 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/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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 drag_drop_client_.reset(); | 362 drag_drop_client_.reset(); |
| 363 | 363 |
| 364 aura::client::SetEventClient(host->window(), NULL); | 364 aura::client::SetEventClient(host->window(), NULL); |
| 365 event_client_.reset(); | 365 event_client_.reset(); |
| 366 } | 366 } |
| 367 | 367 |
| 368 void DesktopNativeWidgetAura::HandleActivationChanged(bool active) { | 368 void DesktopNativeWidgetAura::HandleActivationChanged(bool active) { |
| 369 native_widget_delegate_->OnNativeWidgetActivationChanged(active); | 369 native_widget_delegate_->OnNativeWidgetActivationChanged(active); |
| 370 aura::client::ActivationClient* activation_client = | 370 aura::client::ActivationClient* activation_client = |
| 371 aura::client::GetActivationClient(host_->window()); | 371 aura::client::GetActivationClient(host_->window()); |
| 372 if (!activation_client) { | 372 if (!activation_client) |
| 373 GetInputMethod()->GetLogCollector()->AddString( | |
| 374 "Missing OnFocus call when activating due to no activation client."); | |
| 375 return; | 373 return; |
| 376 } | |
| 377 if (active) { | 374 if (active) { |
| 378 if (GetWidget()->HasFocusManager()) { | 375 if (GetWidget()->HasFocusManager()) { |
| 379 // This function can be called before the focus manager has had a | 376 // This function can be called before the focus manager has had a |
| 380 // chance to set the focused view. In which case we should get the | 377 // chance to set the focused view. In which case we should get the |
| 381 // last focused view. | 378 // last focused view. |
| 382 View* view_for_activation = | 379 View* view_for_activation = |
| 383 GetWidget()->GetFocusManager()->GetFocusedView() ? | 380 GetWidget()->GetFocusManager()->GetFocusedView() ? |
| 384 GetWidget()->GetFocusManager()->GetFocusedView() : | 381 GetWidget()->GetFocusManager()->GetFocusedView() : |
| 385 GetWidget()->GetFocusManager()->GetStoredFocusView(); | 382 GetWidget()->GetFocusManager()->GetStoredFocusView(); |
| 386 if (!view_for_activation) | 383 if (!view_for_activation) |
| 387 view_for_activation = GetWidget()->GetRootView(); | 384 view_for_activation = GetWidget()->GetRootView(); |
| 388 activation_client->ActivateWindow( | 385 activation_client->ActivateWindow( |
| 389 view_for_activation->GetWidget()->GetNativeView()); | 386 view_for_activation->GetWidget()->GetNativeView()); |
| 390 // Refreshes the focus info to IMF in case that IMF cached the old info | 387 // Refreshes the focus info to IMF in case that IMF cached the old info |
| 391 // about focused text input client when it was "inactive". | 388 // about focused text input client when it was "inactive". |
| 392 GetInputMethod()->OnFocus(); | 389 GetInputMethod()->OnFocus(); |
| 393 } else { | |
| 394 GetInputMethod()->GetLogCollector()->AddString( | |
| 395 "Missing OnFocus call when activating due to no focus manager."); | |
| 396 } | 390 } |
| 397 } else { | 391 } else { |
| 398 // If we're not active we need to deactivate the corresponding | 392 // If we're not active we need to deactivate the corresponding |
| 399 // aura::Window. This way if a child widget is active it gets correctly | 393 // aura::Window. This way if a child widget is active it gets correctly |
| 400 // deactivated (child widgets don't get native desktop activation changes, | 394 // deactivated (child widgets don't get native desktop activation changes, |
| 401 // only aura activation changes). | 395 // only aura activation changes). |
| 402 aura::Window* active_window = activation_client->GetActiveWindow(); | 396 aura::Window* active_window = activation_client->GetActiveWindow(); |
| 403 if (active_window) { | 397 if (active_window) { |
| 404 activation_client->DeactivateWindow(active_window); | 398 activation_client->DeactivateWindow(active_window); |
| 405 GetInputMethod()->OnBlur(); | 399 GetInputMethod()->OnBlur(); |
| (...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 if (cursor_reference_count_ == 0) { | 1206 if (cursor_reference_count_ == 0) { |
| 1213 // We are the last DesktopNativeWidgetAura instance, and we are responsible | 1207 // We are the last DesktopNativeWidgetAura instance, and we are responsible |
| 1214 // for cleaning up |cursor_manager_|. | 1208 // for cleaning up |cursor_manager_|. |
| 1215 delete cursor_manager_; | 1209 delete cursor_manager_; |
| 1216 native_cursor_manager_ = NULL; | 1210 native_cursor_manager_ = NULL; |
| 1217 cursor_manager_ = NULL; | 1211 cursor_manager_ = NULL; |
| 1218 } | 1212 } |
| 1219 } | 1213 } |
| 1220 | 1214 |
| 1221 } // namespace views | 1215 } // namespace views |
| OLD | NEW |