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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 native_widget_delegate_->OnNativeWidgetActivationChanged(active); | 343 native_widget_delegate_->OnNativeWidgetActivationChanged(active); |
344 aura::client::ActivationClient* activation_client = | 344 aura::client::ActivationClient* activation_client = |
345 aura::client::GetActivationClient(host_->window()); | 345 aura::client::GetActivationClient(host_->window()); |
346 if (!activation_client) | 346 if (!activation_client) |
347 return; | 347 return; |
348 if (active) { | 348 if (active) { |
349 if (GetWidget()->HasFocusManager()) { | 349 if (GetWidget()->HasFocusManager()) { |
350 // This function can be called before the focus manager has had a | 350 // This function can be called before the focus manager has had a |
351 // chance to set the focused view. In which case we should get the | 351 // chance to set the focused view. In which case we should get the |
352 // last focused view. | 352 // last focused view. |
353 View* view_for_activation = | 353 views::FocusManager* focus_manager = GetWidget()->GetFocusManager(); |
354 GetWidget()->GetFocusManager()->GetFocusedView() ? | 354 View* view_for_activation = focus_manager->GetFocusedView() |
355 GetWidget()->GetFocusManager()->GetFocusedView() : | 355 ? focus_manager->GetFocusedView() |
356 GetWidget()->GetFocusManager()->GetStoredFocusView(); | 356 : focus_manager->GetStoredFocusView(); |
357 if (!view_for_activation) | 357 if (!view_for_activation) |
358 view_for_activation = GetWidget()->GetRootView(); | 358 view_for_activation = GetWidget()->GetRootView(); |
| 359 else if (view_for_activation == focus_manager->GetStoredFocusView()) |
| 360 focus_manager->RestoreFocusedView(); |
359 activation_client->ActivateWindow( | 361 activation_client->ActivateWindow( |
360 view_for_activation->GetWidget()->GetNativeView()); | 362 view_for_activation->GetWidget()->GetNativeView()); |
361 // Refreshes the focus info to IMF in case that IMF cached the old info | 363 // Refreshes the focus info to IMF in case that IMF cached the old info |
362 // about focused text input client when it was "inactive". | 364 // about focused text input client when it was "inactive". |
363 GetInputMethod()->OnFocus(); | 365 GetInputMethod()->OnFocus(); |
364 } | 366 } |
365 } else { | 367 } else { |
366 // If we're not active we need to deactivate the corresponding | 368 // If we're not active we need to deactivate the corresponding |
367 // aura::Window. This way if a child widget is active it gets correctly | 369 // aura::Window. This way if a child widget is active it gets correctly |
368 // deactivated (child widgets don't get native desktop activation changes, | 370 // deactivated (child widgets don't get native desktop activation changes, |
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1184 if (cursor_reference_count_ == 0) { | 1186 if (cursor_reference_count_ == 0) { |
1185 // We are the last DesktopNativeWidgetAura instance, and we are responsible | 1187 // We are the last DesktopNativeWidgetAura instance, and we are responsible |
1186 // for cleaning up |cursor_manager_|. | 1188 // for cleaning up |cursor_manager_|. |
1187 delete cursor_manager_; | 1189 delete cursor_manager_; |
1188 native_cursor_manager_ = NULL; | 1190 native_cursor_manager_ = NULL; |
1189 cursor_manager_ = NULL; | 1191 cursor_manager_ = NULL; |
1190 } | 1192 } |
1191 } | 1193 } |
1192 | 1194 |
1193 } // namespace views | 1195 } // namespace views |
OLD | NEW |