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

Side by Side Diff: components/mus/ws/window_manager_state.cc

Issue 2089023002: Promotes remaining global window manager state into WindowManagerState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: override Created 4 years, 6 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
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 "components/mus/ws/window_manager_state.h" 5 #include "components/mus/ws/window_manager_state.h"
6 6
7 #include <queue>
8
9 #include "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
10 #include "components/mus/common/event_matcher_util.h" 8 #include "components/mus/common/event_matcher_util.h"
11 #include "components/mus/ws/accelerator.h" 9 #include "components/mus/ws/accelerator.h"
12 #include "components/mus/ws/display_manager.h" 10 #include "components/mus/ws/display_manager.h"
13 #include "components/mus/ws/platform_display.h" 11 #include "components/mus/ws/platform_display.h"
14 #include "components/mus/ws/server_window.h" 12 #include "components/mus/ws/server_window.h"
15 #include "components/mus/ws/user_display_manager.h" 13 #include "components/mus/ws/user_display_manager.h"
16 #include "components/mus/ws/user_id_tracker.h" 14 #include "components/mus/ws/user_id_tracker.h"
15 #include "components/mus/ws/window_manager_display_root.h"
17 #include "components/mus/ws/window_server.h" 16 #include "components/mus/ws/window_server.h"
18 #include "components/mus/ws/window_tree.h" 17 #include "components/mus/ws/window_tree.h"
19 #include "services/shell/public/interfaces/connector.mojom.h" 18 #include "services/shell/public/interfaces/connector.mojom.h"
20 #include "ui/events/event.h" 19 #include "ui/events/event.h"
21 20
22 namespace mus { 21 namespace mus {
23 namespace ws { 22 namespace ws {
24 namespace { 23 namespace {
25 24
26 // Debug accelerator IDs start far above the highest valid Windows command ID 25 // Debug accelerator IDs start far above the highest valid Windows command ID
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 ServerWindowTracker tracker_; 86 ServerWindowTracker tracker_;
88 const ClientSpecificId client_id_; 87 const ClientSpecificId client_id_;
89 base::WeakPtr<Accelerator> accelerator_; 88 base::WeakPtr<Accelerator> accelerator_;
90 89
91 DISALLOW_COPY_AND_ASSIGN(ProcessedEventTarget); 90 DISALLOW_COPY_AND_ASSIGN(ProcessedEventTarget);
92 }; 91 };
93 92
94 WindowManagerState::QueuedEvent::QueuedEvent() {} 93 WindowManagerState::QueuedEvent::QueuedEvent() {}
95 WindowManagerState::QueuedEvent::~QueuedEvent() {} 94 WindowManagerState::QueuedEvent::~QueuedEvent() {}
96 95
97 WindowManagerState::WindowManagerState(Display* display, 96 WindowManagerState::WindowManagerState(WindowTree* window_tree)
98 PlatformDisplay* platform_display) 97 : window_tree_(window_tree), event_dispatcher_(this), weak_factory_(this) {
99 : WindowManagerState(display, 98 frame_decoration_values_ = mojom::FrameDecorationValues::New();
100 platform_display, 99 frame_decoration_values_->max_title_bar_button_width = 0u;
101 false,
102 shell::mojom::kRootUserID) {}
103 100
104 WindowManagerState::WindowManagerState(Display* display, 101 AddDebugAccelerators();
105 PlatformDisplay* platform_display, 102 }
106 const UserId& user_id)
107 : WindowManagerState(display, platform_display, true, user_id) {}
108 103
109 WindowManagerState::~WindowManagerState() {} 104 WindowManagerState::~WindowManagerState() {}
110 105
106 void WindowManagerState::SetFrameDecorationValues(
107 mojom::FrameDecorationValuesPtr values) {
108 got_frame_decoration_values_ = true;
109 frame_decoration_values_ = values.Clone();
110 display_manager()
111 ->GetUserDisplayManager(user_id())
112 ->OnFrameDecorationValuesChanged();
113 }
114
111 bool WindowManagerState::SetCapture(ServerWindow* window, 115 bool WindowManagerState::SetCapture(ServerWindow* window,
112 ClientSpecificId client_id) { 116 ClientSpecificId client_id) {
113 // TODO(sky): capture should be a singleton. Need to route to WindowServer
114 // so that all other EventDispatchers are updated.
115 DCHECK(IsActive()); 117 DCHECK(IsActive());
116 if (capture_window() == window && 118 if (capture_window() == window &&
117 client_id == event_dispatcher_.capture_window_client_id()) { 119 client_id == event_dispatcher_.capture_window_client_id()) {
118 return true; 120 return true;
119 } 121 }
120 DCHECK(!window || root_->Contains(window)); 122 #if !defined(NDEBUG)
123 if (window) {
124 WindowManagerDisplayRoot* display_root =
125 display_manager()->GetWindowManagerDisplayRoot(window);
126 DCHECK(display_root && display_root->window_manager_state() == this);
127 }
128 #endif
121 return event_dispatcher_.SetCaptureWindow(window, client_id); 129 return event_dispatcher_.SetCaptureWindow(window, client_id);
122 } 130 }
123 131
124 void WindowManagerState::ReleaseCaptureBlockedByModalWindow( 132 void WindowManagerState::ReleaseCaptureBlockedByModalWindow(
125 const ServerWindow* modal_window) { 133 const ServerWindow* modal_window) {
126 event_dispatcher_.ReleaseCaptureBlockedByModalWindow(modal_window); 134 event_dispatcher_.ReleaseCaptureBlockedByModalWindow(modal_window);
127 } 135 }
128 136
129 void WindowManagerState::ReleaseCaptureBlockedByAnyModalWindow() { 137 void WindowManagerState::ReleaseCaptureBlockedByAnyModalWindow() {
130 event_dispatcher_.ReleaseCaptureBlockedByAnyModalWindow(); 138 event_dispatcher_.ReleaseCaptureBlockedByAnyModalWindow();
131 } 139 }
132 140
133 void WindowManagerState::AddSystemModalWindow(ServerWindow* window) { 141 void WindowManagerState::AddSystemModalWindow(ServerWindow* window) {
134 DCHECK(!window->transient_parent()); 142 DCHECK(!window->transient_parent());
135 event_dispatcher_.AddSystemModalWindow(window); 143 event_dispatcher_.AddSystemModalWindow(window);
136 } 144 }
137 145
146 const UserId& WindowManagerState::user_id() const {
147 return window_tree_->user_id();
148 }
149
138 void WindowManagerState::OnWillDestroyTree(WindowTree* tree) { 150 void WindowManagerState::OnWillDestroyTree(WindowTree* tree) {
139 if (tree_awaiting_input_ack_ != tree) 151 if (tree_awaiting_input_ack_ != tree)
140 return; 152 return;
153
141 // The WindowTree is dying. So it's not going to ack the event. 154 // The WindowTree is dying. So it's not going to ack the event.
142 // If the dying tree matches the root |tree_| marked as handled so we don't 155 // If the dying tree matches the root |tree_| marked as handled so we don't
143 // notify it of accelerators. 156 // notify it of accelerators.
144 OnEventAck(tree_awaiting_input_ack_, tree == tree_ 157 OnEventAck(tree_awaiting_input_ack_, tree == window_tree_
145 ? mojom::EventResult::HANDLED 158 ? mojom::EventResult::HANDLED
146 : mojom::EventResult::UNHANDLED); 159 : mojom::EventResult::UNHANDLED);
147 } 160 }
148 161
149 WindowManagerState::WindowManagerState(Display* display,
150 PlatformDisplay* platform_display,
151 bool is_user_id_valid,
152 const UserId& user_id)
153 : display_(display),
154 platform_display_(platform_display),
155 is_user_id_valid_(is_user_id_valid),
156 user_id_(user_id),
157 event_dispatcher_(this),
158 weak_factory_(this) {
159 root_.reset(window_server()->CreateServerWindow(
160 window_server()->display_manager()->GetAndAdvanceNextRootId(),
161 ServerWindow::Properties()));
162 // Our root is always a child of the Display's root. Do this
163 // before the WindowTree has been created so that the client doesn't get
164 // notified of the add, bounds change and visibility change.
165 root_->SetBounds(gfx::Rect(display->root_window()->bounds().size()));
166 root_->SetVisible(true);
167 display->root_window()->Add(root_.get());
168
169 event_dispatcher_.set_root(root_.get());
170
171 AddDebugAccelerators();
172 }
173
174 bool WindowManagerState::IsActive() const { 162 bool WindowManagerState::IsActive() const {
175 return display()->GetActiveWindowManagerState() == this; 163 return window_server()->user_id_tracker()->active_id() == user_id();
176 } 164 }
177 165
178 void WindowManagerState::Activate(const gfx::Point& mouse_location_on_screen) { 166 void WindowManagerState::Activate(const gfx::Point& mouse_location_on_screen) {
179 root_->SetVisible(true); 167 SetAllRootWindowsVisible(true);
180 event_dispatcher_.Reset(); 168 event_dispatcher_.Reset();
181 event_dispatcher_.SetMousePointerScreenLocation(mouse_location_on_screen); 169 event_dispatcher_.SetMousePointerScreenLocation(mouse_location_on_screen);
182 } 170 }
183 171
184 void WindowManagerState::Deactivate() { 172 void WindowManagerState::Deactivate() {
185 root_->SetVisible(false); 173 SetAllRootWindowsVisible(false);
186 event_dispatcher_.Reset(); 174 event_dispatcher_.Reset();
187 // The tree is no longer active, so no point in dispatching any further 175 // The tree is no longer active, so no point in dispatching any further
188 // events. 176 // events.
189 std::queue<std::unique_ptr<QueuedEvent>> event_queue; 177 std::queue<std::unique_ptr<QueuedEvent>> event_queue;
190 event_queue.swap(event_queue_); 178 event_queue.swap(event_queue_);
191 } 179 }
192 180
193 void WindowManagerState::ProcessEvent(const ui::Event& event) { 181 void WindowManagerState::ProcessEvent(const ui::Event& event) {
194 // If this is still waiting for an ack from a previously sent event, then 182 // If this is still waiting for an ack from a previously sent event, then
195 // queue up the event to be dispatched once the ack is received. 183 // queue up the event to be dispatched once the ack is received.
(...skipping 19 matching lines...) Expand all
215 } 203 }
216 tree_awaiting_input_ack_ = nullptr; 204 tree_awaiting_input_ack_ = nullptr;
217 event_ack_timer_.Stop(); 205 event_ack_timer_.Stop();
218 206
219 if (result == mojom::EventResult::UNHANDLED && post_target_accelerator_) 207 if (result == mojom::EventResult::UNHANDLED && post_target_accelerator_)
220 OnAccelerator(post_target_accelerator_->id(), *event_awaiting_input_ack_); 208 OnAccelerator(post_target_accelerator_->id(), *event_awaiting_input_ack_);
221 209
222 ProcessNextEventFromQueue(); 210 ProcessNextEventFromQueue();
223 } 211 }
224 212
213 const WindowServer* WindowManagerState::window_server() const {
214 return window_tree_->window_server();
215 }
216
225 WindowServer* WindowManagerState::window_server() { 217 WindowServer* WindowManagerState::window_server() {
226 return display_->window_server(); 218 return window_tree_->window_server();
219 }
220
221 DisplayManager* WindowManagerState::display_manager() {
222 return window_tree_->display_manager();
223 }
224
225 const DisplayManager* WindowManagerState::display_manager() const {
226 return window_tree_->display_manager();
227 }
228
229 void WindowManagerState::SetAllRootWindowsVisible(bool value) {
230 for (Display* display : display_manager()->displays()) {
231 WindowManagerDisplayRoot* display_root =
232 display->GetWindowManagerDisplayRootForUser(user_id());
233 if (display_root)
234 display_root->root()->SetVisible(value);
235 }
236 }
237
238 ServerWindow* WindowManagerState::GetWindowManagerRoot(ServerWindow* window) {
239 for (Display* display : display_manager()->displays()) {
240 WindowManagerDisplayRoot* display_root =
241 display->GetWindowManagerDisplayRootForUser(user_id());
242 if (display_root && display_root->root()->parent() == window)
243 return display_root->root();
244 }
245 NOTREACHED();
246 return nullptr;
227 } 247 }
228 248
229 void WindowManagerState::OnEventAckTimeout(ClientSpecificId client_id) { 249 void WindowManagerState::OnEventAckTimeout(ClientSpecificId client_id) {
230 WindowTree* hung_tree = window_server()->GetTreeWithId(client_id); 250 WindowTree* hung_tree = window_server()->GetTreeWithId(client_id);
231 if (hung_tree && !hung_tree->janky()) 251 if (hung_tree && !hung_tree->janky())
232 tree_->ClientJankinessChanged(hung_tree); 252 window_tree_->ClientJankinessChanged(hung_tree);
233 OnEventAck(tree_awaiting_input_ack_, mojom::EventResult::UNHANDLED); 253 OnEventAck(tree_awaiting_input_ack_, mojom::EventResult::UNHANDLED);
234 } 254 }
235 255
236 void WindowManagerState::QueueEvent( 256 void WindowManagerState::QueueEvent(
237 const ui::Event& event, 257 const ui::Event& event,
238 std::unique_ptr<ProcessedEventTarget> processed_event_target) { 258 std::unique_ptr<ProcessedEventTarget> processed_event_target) {
239 std::unique_ptr<QueuedEvent> queued_event(new QueuedEvent); 259 std::unique_ptr<QueuedEvent> queued_event(new QueuedEvent);
240 queued_event->event = ui::Event::Clone(event); 260 queued_event->event = ui::Event::Clone(event);
241 queued_event->processed_target = std::move(processed_event_target); 261 queued_event->processed_target = std::move(processed_event_target);
242 event_queue_.push(std::move(queued_event)); 262 event_queue_.push(std::move(queued_event));
(...skipping 17 matching lines...) Expand all
260 return; 280 return;
261 } 281 }
262 } 282 }
263 } 283 }
264 284
265 void WindowManagerState::DispatchInputEventToWindowImpl( 285 void WindowManagerState::DispatchInputEventToWindowImpl(
266 ServerWindow* target, 286 ServerWindow* target,
267 ClientSpecificId client_id, 287 ClientSpecificId client_id,
268 const ui::Event& event, 288 const ui::Event& event,
269 base::WeakPtr<Accelerator> accelerator) { 289 base::WeakPtr<Accelerator> accelerator) {
270 if (target == root_->parent()) 290 if (target && target->parent() == nullptr)
271 target = root_.get(); 291 target = GetWindowManagerRoot(target);
272 292
273 if (event.IsMousePointerEvent()) { 293 if (event.IsMousePointerEvent()) {
274 DCHECK(event_dispatcher_.mouse_cursor_source_window()); 294 DCHECK(event_dispatcher_.mouse_cursor_source_window());
275 295
276 int32_t cursor_id = 0; 296 int32_t cursor_id = 0;
277 if (event_dispatcher_.GetCurrentMouseCursor(&cursor_id)) 297 if (event_dispatcher_.GetCurrentMouseCursor(&cursor_id)) {
278 display_->UpdateNativeCursor(cursor_id); 298 WindowManagerDisplayRoot* display_root =
299 display_manager()->GetWindowManagerDisplayRoot(target);
300 display_root->display()->UpdateNativeCursor(cursor_id);
301 }
279 } 302 }
280 303
281 WindowTree* tree = window_server()->GetTreeWithId(client_id); 304 WindowTree* tree = window_server()->GetTreeWithId(client_id);
282 305
283 // TOOD(sad): Adjust this delay, possibly make this dynamic. 306 // TOOD(sad): Adjust this delay, possibly make this dynamic.
284 const base::TimeDelta max_delay = base::debug::BeingDebugged() 307 const base::TimeDelta max_delay = base::debug::BeingDebugged()
285 ? base::TimeDelta::FromDays(1) 308 ? base::TimeDelta::FromDays(1)
286 : GetDefaultAckTimerDelay(); 309 : GetDefaultAckTimerDelay();
287 event_ack_timer_.Start( 310 event_ack_timer_.Start(
288 FROM_HERE, max_delay, 311 FROM_HERE, max_delay,
289 base::Bind(&WindowManagerState::OnEventAckTimeout, 312 base::Bind(&WindowManagerState::OnEventAckTimeout,
290 weak_factory_.GetWeakPtr(), tree->id())); 313 weak_factory_.GetWeakPtr(), tree->id()));
291 314
292 tree_awaiting_input_ack_ = tree; 315 tree_awaiting_input_ack_ = tree;
293 if (accelerator) { 316 if (accelerator) {
294 event_awaiting_input_ack_ = ui::Event::Clone(event); 317 event_awaiting_input_ack_ = ui::Event::Clone(event);
295 post_target_accelerator_ = accelerator; 318 post_target_accelerator_ = accelerator;
296 } 319 }
297 320
298 // Ignore |tree| because it will receive the event via normal dispatch. 321 // Ignore |tree| because it will receive the event via normal dispatch.
299 window_server()->SendToEventObservers(event, user_id_, tree); 322 window_server()->SendToEventObservers(event, user_id(), tree);
300 323
301 tree->DispatchInputEvent(target, event); 324 tree->DispatchInputEvent(target, event);
302 } 325 }
303 326
304 void WindowManagerState::AddDebugAccelerators() { 327 void WindowManagerState::AddDebugAccelerators() {
305 // Always register the accelerators, even if they only work in debug, so that 328 // Always register the accelerators, even if they only work in debug, so that
306 // keyboard behavior is the same in release and debug builds. 329 // keyboard behavior is the same in release and debug builds.
307 mojom::EventMatcherPtr matcher = CreateKeyMatcher( 330 mojom::EventMatcherPtr matcher = CreateKeyMatcher(
308 ui::mojom::KeyboardCode::S, ui::mojom::kEventFlagControlDown | 331 ui::mojom::KeyboardCode::S, ui::mojom::kEventFlagControlDown |
309 ui::mojom::kEventFlagAltDown | 332 ui::mojom::kEventFlagAltDown |
310 ui::mojom::kEventFlagShiftDown); 333 ui::mojom::kEventFlagShiftDown);
311 event_dispatcher_.AddAccelerator(kPrintWindowsDebugAcceleratorId, 334 event_dispatcher_.AddAccelerator(kPrintWindowsDebugAcceleratorId,
312 std::move(matcher)); 335 std::move(matcher));
313 } 336 }
314 337
315 bool WindowManagerState::HandleDebugAccelerator(uint32_t accelerator_id) { 338 bool WindowManagerState::HandleDebugAccelerator(uint32_t accelerator_id) {
316 #if !defined(NDEBUG) 339 #if !defined(NDEBUG)
317 if (accelerator_id == kPrintWindowsDebugAcceleratorId) { 340 if (accelerator_id == kPrintWindowsDebugAcceleratorId) {
318 // Error so it will be collected in system logs. 341 // Error so it will be collected in system logs.
319 LOG(ERROR) << "ServerWindow hierarchy:\n" 342 for (Display* display : display_manager()->displays()) {
320 << root()->GetDebugWindowHierarchy(); 343 WindowManagerDisplayRoot* display_root =
344 display->GetWindowManagerDisplayRootForUser(user_id());
345 if (display_root) {
346 LOG(ERROR) << "ServerWindow hierarchy:\n"
347 << display_root->root()->GetDebugWindowHierarchy();
348 }
349 }
321 return true; 350 return true;
322 } 351 }
323 #endif 352 #endif
324 return false; 353 return false;
325 } 354 }
326 355
327 //////////////////////////////////////////////////////////////////////////////// 356 ////////////////////////////////////////////////////////////////////////////////
328 // EventDispatcherDelegate: 357 // EventDispatcherDelegate:
329 358
330 void WindowManagerState::OnAccelerator(uint32_t accelerator_id, 359 void WindowManagerState::OnAccelerator(uint32_t accelerator_id,
331 const ui::Event& event) { 360 const ui::Event& event) {
332 DCHECK(IsActive()); 361 DCHECK(IsActive());
333 if (HandleDebugAccelerator(accelerator_id)) 362 if (HandleDebugAccelerator(accelerator_id))
334 return; 363 return;
335 tree_->OnAccelerator(accelerator_id, event); 364 window_tree_->OnAccelerator(accelerator_id, event);
336 } 365 }
337 366
338 void WindowManagerState::SetFocusedWindowFromEventDispatcher( 367 void WindowManagerState::SetFocusedWindowFromEventDispatcher(
339 ServerWindow* new_focused_window) { 368 ServerWindow* new_focused_window) {
340 DCHECK(IsActive()); 369 DCHECK(IsActive());
341 display_->SetFocusedWindow(new_focused_window); 370 window_server()->SetFocusedWindow(new_focused_window);
342 } 371 }
343 372
344 ServerWindow* WindowManagerState::GetFocusedWindowForEventDispatcher() { 373 ServerWindow* WindowManagerState::GetFocusedWindowForEventDispatcher() {
345 return display()->GetFocusedWindow(); 374 return window_server()->GetFocusedWindow();
346 } 375 }
347 376
348 void WindowManagerState::SetNativeCapture() { 377 void WindowManagerState::SetNativeCapture(ServerWindow* window) {
349 DCHECK(IsActive()); 378 DCHECK(IsActive());
350 platform_display_->SetCapture(); 379 WindowManagerDisplayRoot* display_root =
380 display_manager()->GetWindowManagerDisplayRoot(window);
381 DCHECK(display_root);
382 platform_display_with_capture_ = display_root->display()->platform_display();
383 platform_display_with_capture_->SetCapture();
351 } 384 }
352 385
353 void WindowManagerState::ReleaseNativeCapture() { 386 void WindowManagerState::ReleaseNativeCapture() {
354 platform_display_->ReleaseCapture(); 387 // Tests trigger calling this without a corresponding SetNativeCapture().
388 // TODO(sky): maybe abstract this away so that DCHECK can be added?
389 if (!platform_display_with_capture_)
390 return;
391
392 platform_display_with_capture_->ReleaseCapture();
393 platform_display_with_capture_ = nullptr;
355 } 394 }
356 395
357 void WindowManagerState::OnServerWindowCaptureLost(ServerWindow* window) { 396 void WindowManagerState::OnServerWindowCaptureLost(ServerWindow* window) {
358 DCHECK(window); 397 DCHECK(window);
359 window_server()->ProcessLostCapture(window); 398 window_server()->ProcessLostCapture(window);
360 } 399 }
361 400
362 void WindowManagerState::OnMouseCursorLocationChanged(const gfx::Point& point) { 401 void WindowManagerState::OnMouseCursorLocationChanged(const gfx::Point& point) {
363 window_server()->display_manager()->GetUserDisplayManager(user_id_)-> 402 window_server()
364 OnMouseCursorLocationChanged(point); 403 ->display_manager()
404 ->GetUserDisplayManager(user_id())
405 ->OnMouseCursorLocationChanged(point);
365 } 406 }
366 407
367 void WindowManagerState::DispatchInputEventToWindow(ServerWindow* target, 408 void WindowManagerState::DispatchInputEventToWindow(ServerWindow* target,
368 ClientSpecificId client_id, 409 ClientSpecificId client_id,
369 const ui::Event& event, 410 const ui::Event& event,
370 Accelerator* accelerator) { 411 Accelerator* accelerator) {
371 DCHECK(IsActive()); 412 DCHECK(IsActive());
372 // TODO(sky): this needs to see if another wms has capture and if so forward 413 // TODO(sky): this needs to see if another wms has capture and if so forward
373 // to it. 414 // to it.
374 if (event_ack_timer_.IsRunning()) { 415 if (event_ack_timer_.IsRunning()) {
(...skipping 13 matching lines...) Expand all
388 const ServerWindow* window, 429 const ServerWindow* window,
389 bool in_nonclient_area) { 430 bool in_nonclient_area) {
390 WindowTree* tree = 431 WindowTree* tree =
391 in_nonclient_area ? window_server()->GetTreeWithId(window->id().client_id) 432 in_nonclient_area ? window_server()->GetTreeWithId(window->id().client_id)
392 : window_server()->GetTreeWithRoot(window); 433 : window_server()->GetTreeWithRoot(window);
393 if (!tree) { 434 if (!tree) {
394 if (in_nonclient_area) { 435 if (in_nonclient_area) {
395 // Being the root of the tree means we may get events outside the bounds 436 // Being the root of the tree means we may get events outside the bounds
396 // of the platform window. Because the root has a client id of 0, 437 // of the platform window. Because the root has a client id of 0,
397 // no WindowTree is found for it and we have to special case it here. 438 // no WindowTree is found for it and we have to special case it here.
398 DCHECK_EQ(window, root_.get()); 439 tree = window_tree_;
399 tree = tree_;
400 } else { 440 } else {
401 tree = window_server()->GetTreeWithId(window->id().client_id); 441 tree = window_server()->GetTreeWithId(window->id().client_id);
402 } 442 }
403 } 443 }
404 return tree->id(); 444 return tree->id();
405 } 445 }
406 446
447 ServerWindow* WindowManagerState::GetRootWindowContaining(
448 const gfx::Point& location) {
449 if (display_manager()->displays().empty())
450 return nullptr;
451
452 // TODO(sky): this isn't right. To correctly implement need bounds of
453 // Display, which we aren't tracking yet. For now, use the first display.
454 Display* display = *(display_manager()->displays().begin());
455 WindowManagerDisplayRoot* display_root =
456 display->GetWindowManagerDisplayRootForUser(user_id());
457 return display_root ? display_root->root() : nullptr;
458 }
459
407 void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) { 460 void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) {
408 window_server()->SendToEventObservers(event, user_id_, 461 window_server()->SendToEventObservers(event, user_id(),
409 nullptr /* ignore_tree */); 462 nullptr /* ignore_tree */);
410 } 463 }
411 464
412 } // namespace ws 465 } // namespace ws
413 } // namespace mus 466 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/window_manager_state.h ('k') | components/mus/ws/window_manager_state_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698