Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(789)

Unified Diff: ui/views/widget/desktop_aura/desktop_native_widget_aura.cc

Issue 2919973002: desktop_aura: do not restore focused view if it has modal transient child (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
index b1f2574c975d26540f8bf072b1f11d50cbbe2050..7eccdfa762fa06f88d8cc8de0026d1093aba36af 100644
--- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
+++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
@@ -56,6 +56,7 @@
#include "ui/wm/core/visibility_controller.h"
#include "ui/wm/core/window_animations.h"
#include "ui/wm/core/window_modality_controller.h"
+#include "ui/wm/core/window_util.h"
#include "ui/wm/public/activation_client.h"
#if defined(OS_WIN)
@@ -72,6 +73,19 @@ DEFINE_UI_CLASS_PROPERTY_KEY(DesktopNativeWidgetAura*,
namespace {
+// Returns true if |widget| has modal transient child, otherwise false.
+bool HasModalTransientChild(const Widget* widget) {
+ DCHECK(widget);
+ for (auto* window : ::wm::GetTransientChildren(widget->GetNativeView())) {
+ ui::ModalType type = Widget::GetWidgetForNativeView(window)
sky 2017/06/02 17:34:10 Are you sure you don't want GetModalTransient(widg
Qiang(Joe) Xu 2017/06/02 21:37:08 I should use this. Thanks!
+ ->widget_delegate()
+ ->GetModalType();
+ if (type == ui::MODAL_TYPE_SYSTEM || type == ui::MODAL_TYPE_WINDOW)
+ return true;
+ }
+ return false;
+}
+
// This class provides functionality to create a top level widget to host a
// child window.
class DesktopNativeWidgetTopLevelHandler : public aura::WindowObserver {
@@ -364,11 +378,16 @@ void DesktopNativeWidgetAura::HandleActivationChanged(bool active) {
if (!view_for_activation) {
view_for_activation = GetWidget()->GetRootView();
} else if (view_for_activation == focus_manager->GetStoredFocusView()) {
- focus_manager->RestoreFocusedView();
- // Set to false if desktop native widget has activated activation
- // change, so that aura window activation change focus restore operation
- // can be ignored.
- restore_focus_on_activate_ = false;
+ // The desktop native widget may have modal transient child, whose focus
sky 2017/06/02 17:34:10 This just documents the code, the interesting part
Qiang(Joe) Xu 2017/06/02 21:37:08 Done.
+ // is not managed by |focus_manager|. We shall restore focus to modal
+ // window only in this case (crbug.com/727641).
+ if (!HasModalTransientChild(GetWidget())) {
+ focus_manager->RestoreFocusedView();
+ // Set to false if desktop native widget has activated activation
+ // change, so that aura window activation change focus restore
+ // operation can be ignored.
+ restore_focus_on_activate_ = false;
+ }
}
activation_client->ActivateWindow(
view_for_activation->GetWidget()->GetNativeView());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698