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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 native_widget_delegate_->OnNativeWidgetActivationChanged(active); | 361 native_widget_delegate_->OnNativeWidgetActivationChanged(active); |
362 aura::client::ActivationClient* activation_client = | 362 aura::client::ActivationClient* activation_client = |
363 aura::client::GetActivationClient(host_->window()); | 363 aura::client::GetActivationClient(host_->window()); |
364 if (!activation_client) | 364 if (!activation_client) |
365 return; | 365 return; |
366 if (active) { | 366 if (active) { |
367 if (GetWidget()->HasFocusManager()) { | 367 if (GetWidget()->HasFocusManager()) { |
368 // This function can be called before the focus manager has had a | 368 // This function can be called before the focus manager has had a |
369 // chance to set the focused view. In which case we should get the | 369 // chance to set the focused view. In which case we should get the |
370 // last focused view. | 370 // last focused view. |
371 View* view_for_activation = | 371 views::FocusManager* focus_manager = GetWidget()->GetFocusManager(); |
372 GetWidget()->GetFocusManager()->GetFocusedView() ? | 372 View* view_for_activation = focus_manager->GetFocusedView() |
373 GetWidget()->GetFocusManager()->GetFocusedView() : | 373 ? focus_manager->GetFocusedView() |
374 GetWidget()->GetFocusManager()->GetStoredFocusView(); | 374 : focus_manager->GetStoredFocusView(); |
375 if (!view_for_activation) | 375 if (!view_for_activation) |
376 view_for_activation = GetWidget()->GetRootView(); | 376 view_for_activation = GetWidget()->GetRootView(); |
| 377 else if (view_for_activation == focus_manager->GetStoredFocusView()) |
| 378 focus_manager->RestoreFocusedView(); |
377 activation_client->ActivateWindow( | 379 activation_client->ActivateWindow( |
378 view_for_activation->GetWidget()->GetNativeView()); | 380 view_for_activation->GetWidget()->GetNativeView()); |
379 // Refreshes the focus info to IMF in case that IMF cached the old info | 381 // Refreshes the focus info to IMF in case that IMF cached the old info |
380 // about focused text input client when it was "inactive". | 382 // about focused text input client when it was "inactive". |
381 GetInputMethod()->OnFocus(); | 383 GetInputMethod()->OnFocus(); |
382 } | 384 } |
383 } else { | 385 } else { |
384 // If we're not active we need to deactivate the corresponding | 386 // If we're not active we need to deactivate the corresponding |
385 // aura::Window. This way if a child widget is active it gets correctly | 387 // aura::Window. This way if a child widget is active it gets correctly |
386 // deactivated (child widgets don't get native desktop activation changes, | 388 // deactivated (child widgets don't get native desktop activation changes, |
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 if (cursor_reference_count_ == 0) { | 1209 if (cursor_reference_count_ == 0) { |
1208 // We are the last DesktopNativeWidgetAura instance, and we are responsible | 1210 // We are the last DesktopNativeWidgetAura instance, and we are responsible |
1209 // for cleaning up |cursor_manager_|. | 1211 // for cleaning up |cursor_manager_|. |
1210 delete cursor_manager_; | 1212 delete cursor_manager_; |
1211 native_cursor_manager_ = NULL; | 1213 native_cursor_manager_ = NULL; |
1212 cursor_manager_ = NULL; | 1214 cursor_manager_ = NULL; |
1213 } | 1215 } |
1214 } | 1216 } |
1215 | 1217 |
1216 } // namespace views | 1218 } // namespace views |
OLD | NEW |