mirror_window_test_api.cc 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright (c) 2013 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "ash/display/mirror_window_test_api.h"
  5. #include "ash/display/cursor_window_controller.h"
  6. #include "ash/display/mirror_window_controller.h"
  7. #include "ash/display/root_window_transformers.h"
  8. #include "ash/display/window_tree_host_manager.h"
  9. #include "ash/host/root_window_transformer.h"
  10. #include "ash/shell.h"
  11. #include "ui/gfx/geometry/point.h"
  12. namespace ash {
  13. std::vector<aura::WindowTreeHost*> MirrorWindowTestApi::GetHosts() const {
  14. std::vector<aura::WindowTreeHost*> hosts;
  15. for (auto* window : Shell::Get()
  16. ->window_tree_host_manager()
  17. ->mirror_window_controller()
  18. ->GetAllRootWindows()) {
  19. hosts.emplace_back(window->GetHost());
  20. }
  21. return hosts;
  22. }
  23. ui::mojom::CursorType MirrorWindowTestApi::GetCurrentCursorType() const {
  24. return Shell::Get()
  25. ->window_tree_host_manager()
  26. ->cursor_window_controller()
  27. ->cursor_.type();
  28. }
  29. const gfx::Point& MirrorWindowTestApi::GetCursorHotPoint() const {
  30. return Shell::Get()
  31. ->window_tree_host_manager()
  32. ->cursor_window_controller()
  33. ->hot_point_;
  34. }
  35. gfx::Point MirrorWindowTestApi::GetCursorHotPointLocationInRootWindow() const {
  36. return GetCursorWindow()->GetBoundsInRootWindow().origin() +
  37. GetCursorHotPoint().OffsetFromOrigin();
  38. }
  39. const aura::Window* MirrorWindowTestApi::GetCursorWindow() const {
  40. return Shell::Get()
  41. ->window_tree_host_manager()
  42. ->cursor_window_controller()
  43. ->cursor_window_.get();
  44. }
  45. gfx::Point MirrorWindowTestApi::GetCursorLocation() const {
  46. gfx::Point point = GetCursorWindow()->GetBoundsInScreen().origin();
  47. const gfx::Point hot_point = GetCursorHotPoint();
  48. point.Offset(hot_point.x(), hot_point.y());
  49. return point;
  50. }
  51. } // namespace ash