screen_position_client.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Copyright (c) 2012 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. #ifndef UI_AURA_CLIENT_SCREEN_POSITION_CLIENT_H_
  5. #define UI_AURA_CLIENT_SCREEN_POSITION_CLIENT_H_
  6. #include "ui/aura/aura_export.h"
  7. #include "ui/aura/window.h"
  8. namespace gfx {
  9. class Display;
  10. class Rect;
  11. }
  12. namespace aura {
  13. class Window;
  14. namespace client {
  15. // An interface implemented by an object that changes coordinates within a root
  16. // Window into system coordinates.
  17. class AURA_EXPORT ScreenPositionClient {
  18. public:
  19. virtual ~ScreenPositionClient() {}
  20. // Converts the |screen_point| from a given |window|'s coordinate space
  21. // into screen coordinate space.
  22. // TODO(crbug.com/773331): remove int version of point conversion when
  23. // current usage are changed to use float version.
  24. virtual void ConvertPointToScreen(const Window* window,
  25. gfx::PointF* point) = 0;
  26. virtual void ConvertPointFromScreen(const Window* window,
  27. gfx::PointF* point) = 0;
  28. void ConvertPointToScreen(const Window* window, gfx::Point* point);
  29. void ConvertPointFromScreen(const Window* window, gfx::Point* point);
  30. // Converts the |screen_point| from root window host's coordinate of
  31. // into screen coordinate space.
  32. // A typical example of using this function instead of ConvertPointToScreen is
  33. // when X's native input is captured by a drag operation.
  34. // See the comments for ash::GetRootWindowRelativeToWindow for details.
  35. virtual void ConvertHostPointToScreen(Window* root_window,
  36. gfx::Point* point) = 0;
  37. // Sets the bounds of the window. The implementation is responsible
  38. // for finding out and translating the right coordinates for the |window|.
  39. virtual void SetBounds(Window* window,
  40. const gfx::Rect& bounds,
  41. const display::Display& display) = 0;
  42. // Converts |point| from |window|'s coordinate space into screen coordinate
  43. // space. Ignores any transforms that may be applied on |window| or its window
  44. // hieraichy.
  45. void ConvertPointToScreenIgnoringTransforms(const Window* window,
  46. gfx::Point* point);
  47. void ConvertPointToRootWindowIgnoringTransforms(const Window* window,
  48. gfx::Point* point);
  49. protected:
  50. // Returns the origin of the host platform-window in system DIP coordinates.
  51. virtual gfx::Point GetRootWindowOriginInScreen(
  52. const aura::Window* root_window) = 0;
  53. };
  54. // Sets/Gets the activation client on the Window.
  55. AURA_EXPORT void SetScreenPositionClient(Window* root_window,
  56. ScreenPositionClient* client);
  57. AURA_EXPORT ScreenPositionClient* GetScreenPositionClient(
  58. const Window* root_window);
  59. } // namespace client
  60. } // namespace aura
  61. #endif // UI_AURA_CLIENT_SCREEN_POSITION_CLIENT_H_