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 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 WindowManagerDisplayRoot* target_display_root = nullptr; | 633 WindowManagerDisplayRoot* target_display_root = nullptr; |
634 for (auto& display_root_ptr : window_manager_display_roots_) { | 634 for (auto& display_root_ptr : window_manager_display_roots_) { |
635 if (display_root_ptr->display()->platform_display()->GetBounds().Contains( | 635 if (display_root_ptr->display()->GetDisplay().bounds().Contains( |
636 *location)) { | 636 *location)) { |
637 target_display_root = display_root_ptr.get(); | 637 target_display_root = display_root_ptr.get(); |
638 break; | 638 break; |
639 } | 639 } |
640 } | 640 } |
641 | 641 |
642 // TODO(kylechar): Better handle locations outside the window. Overlapping X11 | 642 // TODO(kylechar): Better handle locations outside the window. Overlapping X11 |
643 // windows, dragging and touch sensors need to be handled properly. | 643 // windows, dragging and touch sensors need to be handled properly. |
644 if (!target_display_root) { | 644 if (!target_display_root) { |
645 DVLOG(1) << "Invalid event location " << location->ToString(); | 645 DVLOG(1) << "Invalid event location " << location->ToString(); |
646 target_display_root = window_manager_display_roots_.begin()->get(); | 646 target_display_root = window_manager_display_roots_.begin()->get(); |
647 } | 647 } |
648 | 648 |
649 // Translate the location to be relative to the display instead of relative | 649 // Translate the location to be relative to the display instead of relative |
650 // to the screen space. | 650 // to the screen space. |
651 gfx::Point origin = | 651 gfx::Point origin = |
652 target_display_root->display()->platform_display()->GetBounds().origin(); | 652 target_display_root->display()->GetDisplay().bounds().origin(); |
653 *location -= origin.OffsetFromOrigin(); | 653 *location -= origin.OffsetFromOrigin(); |
654 return target_display_root->root(); | 654 return target_display_root->root(); |
655 } | 655 } |
656 | 656 |
657 void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) { | 657 void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) { |
658 window_server()->SendToPointerWatchers(event, user_id(), nullptr, /* window */ | 658 window_server()->SendToPointerWatchers(event, user_id(), nullptr, /* window */ |
659 nullptr /* ignore_tree */, | 659 nullptr /* ignore_tree */, |
660 event_processing_display_id_); | 660 event_processing_display_id_); |
661 if (event.IsMousePointerEvent()) | 661 if (event.IsMousePointerEvent()) |
662 UpdateNativeCursorFromDispatcher(); | 662 UpdateNativeCursorFromDispatcher(); |
663 } | 663 } |
664 | 664 |
665 void WindowManagerState::OnWindowEmbeddedAppDisconnected(ServerWindow* window) { | 665 void WindowManagerState::OnWindowEmbeddedAppDisconnected(ServerWindow* window) { |
666 for (auto iter = orphaned_window_manager_display_roots_.begin(); | 666 for (auto iter = orphaned_window_manager_display_roots_.begin(); |
667 iter != orphaned_window_manager_display_roots_.end(); ++iter) { | 667 iter != orphaned_window_manager_display_roots_.end(); ++iter) { |
668 if ((*iter)->root() == window) { | 668 if ((*iter)->root() == window) { |
669 window->RemoveObserver(this); | 669 window->RemoveObserver(this); |
670 orphaned_window_manager_display_roots_.erase(iter); | 670 orphaned_window_manager_display_roots_.erase(iter); |
671 return; | 671 return; |
672 } | 672 } |
673 } | 673 } |
674 NOTREACHED(); | 674 NOTREACHED(); |
675 } | 675 } |
676 | 676 |
677 } // namespace ws | 677 } // namespace ws |
678 } // namespace ui | 678 } // namespace ui |
OLD | NEW |