Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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. Overlapping X11 | |
| 537 // windows, dragging and touch sensors need to be handled properly. | |
| 538 if (!target_display) { | |
| 539 DVLOG(1) << "Invalid event location " << location->ToString(); | |
| 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->platform_display()->GetBounds().origin(); |
| 532 WindowManagerDisplayRoot* display_root = | 552 location->Offset(-origin.x(), -origin.y()); |
|
sky
2016/08/12 16:47:46
Typically we do something like:
*location -= origi
kylechar
2016/08/12 17:25:12
Done.
| |
| 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 |
| OLD | NEW |