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

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: 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
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 Display* target_display = nullptr;
529 for (Display* display : display_manager()->displays()) {
530 if (display->platform_display()->GetBounds().Contains(*location)) {
531 target_display = display;
532 break;
533 }
534 }
535
536 // TODO(kylechar): Better handle locations outside the window when running
537 // with X11. These locations crop up when windows overlap or when dragging.
sky 2016/08/11 20:58:04 I believe this will also happen on some devices th
kylechar 2016/08/12 16:09:11 Yep, it definitely needs more work. This will avoi
538 if (!target_display) {
539 LOG(ERROR) << "Invalid event location " << location->ToString();
sky 2016/08/11 20:58:04 Make this a DVLOG(1) given it can happen in normal
kylechar 2016/08/12 16:09:11 Done.
540 target_display = *(display_manager()->displays().begin());
541 }
542
543 WindowManagerDisplayRoot* display_root =
544 target_display->GetWindowManagerDisplayRootForUser(user_id());
545
546 if (!display_root)
527 return nullptr; 547 return nullptr;
528 548
529 // TODO(sky): this isn't right. To correctly implement need bounds of 549 // 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. 550 // to the screen space.
531 Display* display = *(display_manager()->displays().begin()); 551 gfx::Point origin = target_display->root_window()->bounds().origin();
sky 2016/08/11 20:58:04 The location of the root is always 0, 0. Don't you
kylechar 2016/08/12 16:09:11 I'll change it to use the PlatformDisplay bounds b
sky 2016/08/12 16:47:46 I think we need to put them at 0, 0, otherwise I w
532 WindowManagerDisplayRoot* display_root = 552 location->Offset(-origin.x(), -origin.y());
533 display->GetWindowManagerDisplayRootForUser(user_id()); 553 return display_root->root();
534 return display_root ? display_root->root() : nullptr;
535 } 554 }
536 555
537 void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) { 556 void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) {
538 window_server()->SendToPointerWatchers(event, user_id(), 557 window_server()->SendToPointerWatchers(event, user_id(),
539 nullptr /* ignore_tree */); 558 nullptr /* ignore_tree */);
540 } 559 }
541 560
542 } // namespace ws 561 } // namespace ws
543 } // namespace ui 562 } // namespace ui
OLDNEW
« services/ui/ws/event_dispatcher_delegate.h ('K') | « 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