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> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 } | 623 } |
624 DCHECK(tree); | 624 DCHECK(tree); |
625 return tree->id(); | 625 return tree->id(); |
626 } | 626 } |
627 | 627 |
628 ServerWindow* WindowManagerState::GetRootWindowContaining( | 628 ServerWindow* WindowManagerState::GetRootWindowContaining( |
629 gfx::Point* location) { | 629 gfx::Point* location) { |
630 if (window_manager_display_roots_.empty()) | 630 if (window_manager_display_roots_.empty()) |
631 return nullptr; | 631 return nullptr; |
632 | 632 |
| 633 // TODO(riajiang): This is broken for HDPI because it mixes PPs and DIPs. See |
| 634 // http://crbug.com/701036 for details. |
633 WindowManagerDisplayRoot* target_display_root = nullptr; | 635 WindowManagerDisplayRoot* target_display_root = nullptr; |
634 for (auto& display_root_ptr : window_manager_display_roots_) { | 636 for (auto& display_root_ptr : window_manager_display_roots_) { |
635 if (display_root_ptr->display()->platform_display()->GetBounds().Contains( | 637 if (display_root_ptr->display()->GetDisplay().bounds().Contains( |
636 *location)) { | 638 *location)) { |
637 target_display_root = display_root_ptr.get(); | 639 target_display_root = display_root_ptr.get(); |
638 break; | 640 break; |
639 } | 641 } |
640 } | 642 } |
641 | 643 |
642 // TODO(kylechar): Better handle locations outside the window. Overlapping X11 | 644 // TODO(kylechar): Better handle locations outside the window. Overlapping X11 |
643 // windows, dragging and touch sensors need to be handled properly. | 645 // windows, dragging and touch sensors need to be handled properly. |
644 if (!target_display_root) { | 646 if (!target_display_root) { |
645 DVLOG(1) << "Invalid event location " << location->ToString(); | 647 DVLOG(1) << "Invalid event location " << location->ToString(); |
646 target_display_root = window_manager_display_roots_.begin()->get(); | 648 target_display_root = window_manager_display_roots_.begin()->get(); |
647 } | 649 } |
648 | 650 |
649 // Translate the location to be relative to the display instead of relative | 651 // Translate the location to be relative to the display instead of relative |
650 // to the screen space. | 652 // to the screen space. |
651 gfx::Point origin = | 653 gfx::Point origin = |
652 target_display_root->display()->platform_display()->GetBounds().origin(); | 654 target_display_root->display()->GetDisplay().bounds().origin(); |
653 *location -= origin.OffsetFromOrigin(); | 655 *location -= origin.OffsetFromOrigin(); |
654 return target_display_root->root(); | 656 return target_display_root->root(); |
655 } | 657 } |
656 | 658 |
657 void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) { | 659 void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) { |
658 window_server()->SendToPointerWatchers(event, user_id(), nullptr, /* window */ | 660 window_server()->SendToPointerWatchers(event, user_id(), nullptr, /* window */ |
659 nullptr /* ignore_tree */, | 661 nullptr /* ignore_tree */, |
660 event_processing_display_id_); | 662 event_processing_display_id_); |
661 if (event.IsMousePointerEvent()) | 663 if (event.IsMousePointerEvent()) |
662 UpdateNativeCursorFromDispatcher(); | 664 UpdateNativeCursorFromDispatcher(); |
663 } | 665 } |
664 | 666 |
665 void WindowManagerState::OnWindowEmbeddedAppDisconnected(ServerWindow* window) { | 667 void WindowManagerState::OnWindowEmbeddedAppDisconnected(ServerWindow* window) { |
666 for (auto iter = orphaned_window_manager_display_roots_.begin(); | 668 for (auto iter = orphaned_window_manager_display_roots_.begin(); |
667 iter != orphaned_window_manager_display_roots_.end(); ++iter) { | 669 iter != orphaned_window_manager_display_roots_.end(); ++iter) { |
668 if ((*iter)->root() == window) { | 670 if ((*iter)->root() == window) { |
669 window->RemoveObserver(this); | 671 window->RemoveObserver(this); |
670 orphaned_window_manager_display_roots_.erase(iter); | 672 orphaned_window_manager_display_roots_.erase(iter); |
671 return; | 673 return; |
672 } | 674 } |
673 } | 675 } |
674 NOTREACHED(); | 676 NOTREACHED(); |
675 } | 677 } |
676 | 678 |
677 } // namespace ws | 679 } // namespace ws |
678 } // namespace ui | 680 } // namespace ui |
OLD | NEW |