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

Side by Side Diff: services/ui/ws/modal_window_controller.cc

Issue 2737003002: Fix event targeting for sub-windows of system modal windows in mus+ash. (Closed)
Patch Set: Addressed feedback. Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « services/ui/ws/event_dispatcher_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "services/ui/ws/modal_window_controller.h" 5 #include "services/ui/ws/modal_window_controller.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "services/ui/ws/event_dispatcher.h" 9 #include "services/ui/ws/event_dispatcher.h"
10 #include "services/ui/ws/server_window.h" 10 #include "services/ui/ws/server_window.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 if (modal_window->transient_parent() && 71 if (modal_window->transient_parent() &&
72 !modal_window->transient_parent()->Contains(window)) { 72 !modal_window->transient_parent()->Contains(window)) {
73 return false; 73 return false;
74 } 74 }
75 75
76 return true; 76 return true;
77 } 77 }
78 78
79 bool ModalWindowController::IsWindowBlocked(const ServerWindow* window) const { 79 bool ModalWindowController::IsWindowBlocked(const ServerWindow* window) const {
80 DCHECK(window); 80 DCHECK(window);
81 return GetActiveSystemModalWindow() || GetModalChildForWindowAncestor(window); 81 return GetTargetForWindow(window) != window;
82 } 82 }
83 83
84 const ServerWindow* ModalWindowController::GetTargetForWindow( 84 const ServerWindow* ModalWindowController::GetTargetForWindow(
85 const ServerWindow* window) const { 85 const ServerWindow* window) const {
86 // TODO(moshayedi): crbug.com/697127. Handle windows which are modal to 86 // TODO(moshayedi): crbug.com/697127. Handle MODAL_TYPE_CHILD.
87 // children of their transient parent.
88 ServerWindow* system_modal_window = GetActiveSystemModalWindow(); 87 ServerWindow* system_modal_window = GetActiveSystemModalWindow();
89 if (system_modal_window) 88 if (system_modal_window)
90 return system_modal_window; 89 return system_modal_window->Contains(window) ? window : system_modal_window;
90
91 return window ? GetWindowModalTargetForWindow(window) : nullptr; 91 return window ? GetWindowModalTargetForWindow(window) : nullptr;
92 } 92 }
93 93
94 ServerWindow* ModalWindowController::GetActiveSystemModalWindow() const { 94 ServerWindow* ModalWindowController::GetActiveSystemModalWindow() const {
95 for (auto it = system_modal_windows_.rbegin(); 95 for (auto it = system_modal_windows_.rbegin();
96 it != system_modal_windows_.rend(); it++) { 96 it != system_modal_windows_.rend(); it++) {
97 ServerWindow* modal = *it; 97 ServerWindow* modal = *it;
98 if (modal->IsDrawn()) 98 if (modal->IsDrawn())
99 return modal; 99 return modal;
100 } 100 }
(...skipping 18 matching lines...) Expand all
119 // Move the most recently shown window to the end of the list. 119 // Move the most recently shown window to the end of the list.
120 auto it = std::find(system_modal_windows_.begin(), 120 auto it = std::find(system_modal_windows_.begin(),
121 system_modal_windows_.end(), window); 121 system_modal_windows_.end(), window);
122 DCHECK(it != system_modal_windows_.end()); 122 DCHECK(it != system_modal_windows_.end());
123 system_modal_windows_.splice(system_modal_windows_.end(), 123 system_modal_windows_.splice(system_modal_windows_.end(),
124 system_modal_windows_, it); 124 system_modal_windows_, it);
125 } 125 }
126 126
127 } // namespace ws 127 } // namespace ws
128 } // namespace ui 128 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/event_dispatcher_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698