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

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

Issue 2237003002: Find display root ServerWindow for located events in mus. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add_display
Patch Set: Fix tests. Created 4 years, 4 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/window_manager_state.h ('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/window_manager_state.h" 5 #include "services/ui/ws/window_manager_state.h"
6 6
7 #include <utility>
8
7 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
8 #include "services/shell/public/interfaces/connector.mojom.h" 10 #include "services/shell/public/interfaces/connector.mojom.h"
9 #include "services/ui/common/event_matcher_util.h" 11 #include "services/ui/common/event_matcher_util.h"
10 #include "services/ui/ws/accelerator.h" 12 #include "services/ui/ws/accelerator.h"
11 #include "services/ui/ws/display_manager.h" 13 #include "services/ui/ws/display_manager.h"
12 #include "services/ui/ws/platform_display.h" 14 #include "services/ui/ws/platform_display.h"
13 #include "services/ui/ws/server_window.h" 15 #include "services/ui/ws/server_window.h"
14 #include "services/ui/ws/user_display_manager.h" 16 #include "services/ui/ws/user_display_manager.h"
15 #include "services/ui/ws/user_id_tracker.h" 17 #include "services/ui/ws/user_id_tracker.h"
16 #include "services/ui/ws/window_manager_display_root.h" 18 #include "services/ui/ws/window_manager_display_root.h"
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 } 517 }
516 518
517 if (!tree) { 519 if (!tree) {
518 DCHECK(in_nonclient_area); 520 DCHECK(in_nonclient_area);
519 tree = window_tree_; 521 tree = window_tree_;
520 } 522 }
521 return tree->id(); 523 return tree->id();
522 } 524 }
523 525
524 ServerWindow* WindowManagerState::GetRootWindowContaining( 526 ServerWindow* WindowManagerState::GetRootWindowContaining(
525 const gfx::Point& location) { 527 gfx::Point* location) {
526 if (display_manager()->displays().empty()) 528 if (display_manager()->displays().empty())
529 return nullptr;
530
531 Display* target_display = nullptr;
532 for (Display* display : display_manager()->displays()) {
533 if (display->platform_display()->GetBounds().Contains(*location)) {
534 target_display = display;
535 break;
536 }
537 }
538
539 // TODO(kylechar): Better handle locations outside the window. Overlapping X11
540 // windows, dragging and touch sensors need to be handled properly.
541 if (!target_display) {
542 DVLOG(1) << "Invalid event location " << location->ToString();
543 target_display = *(display_manager()->displays().begin());
544 }
545
546 WindowManagerDisplayRoot* display_root =
547 target_display->GetWindowManagerDisplayRootForUser(user_id());
548
549 if (!display_root)
527 return nullptr; 550 return nullptr;
528 551
529 // TODO(sky): this isn't right. To correctly implement need bounds of 552 // Translate the location to be relative to the display instead of relative
530 // Display, which we aren't tracking yet. For now, use the first display. 553 // to the screen space.
531 Display* display = *(display_manager()->displays().begin()); 554 gfx::Point origin = target_display->platform_display()->GetBounds().origin();
532 WindowManagerDisplayRoot* display_root = 555 *location -= origin.OffsetFromOrigin();
533 display->GetWindowManagerDisplayRootForUser(user_id()); 556 return display_root->root();
534 return display_root ? display_root->root() : nullptr;
535 } 557 }
536 558
537 void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) { 559 void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) {
538 window_server()->SendToPointerWatchers(event, user_id(), 560 window_server()->SendToPointerWatchers(event, user_id(),
539 nullptr /* ignore_tree */); 561 nullptr /* ignore_tree */);
540 } 562 }
541 563
542 } // namespace ws 564 } // namespace ws
543 } // namespace ui 565 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/window_manager_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698