ash_window_tree_host.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // Copyright 2014 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 ASH_HOST_ASH_WINDOW_TREE_HOST_H_
  5. #define ASH_HOST_ASH_WINDOW_TREE_HOST_H_
  6. #include <memory>
  7. #include "ash/ash_export.h"
  8. #include "ui/display/display.h"
  9. namespace aura {
  10. class WindowTreeHost;
  11. }
  12. namespace gfx {
  13. class Insets;
  14. class Rect;
  15. }
  16. namespace ui {
  17. class LocatedEvent;
  18. }
  19. namespace ash {
  20. struct AshWindowTreeHostInitParams;
  21. class RootWindowTransformer;
  22. class ASH_EXPORT AshWindowTreeHost {
  23. public:
  24. AshWindowTreeHost();
  25. virtual ~AshWindowTreeHost();
  26. static std::unique_ptr<AshWindowTreeHost> Create(
  27. const AshWindowTreeHostInitParams& init_params);
  28. // Confines the cursor to the bounds of the root window. This should do
  29. // nothing if allow_confine_cursor() returns false.
  30. virtual void ConfineCursorToRootWindow() = 0;
  31. // Clips the cursor to the given |bounds_in_root|.
  32. virtual void ConfineCursorToBoundsInRoot(const gfx::Rect& bounds_in_root) = 0;
  33. // Returns the last used bounds to confine the mouse cursor in the host's
  34. // window's pixels.
  35. virtual gfx::Rect GetLastCursorConfineBoundsInPixels() const = 0;
  36. virtual void SetRootWindowTransformer(
  37. std::unique_ptr<RootWindowTransformer> transformer) = 0;
  38. virtual gfx::Insets GetHostInsets() const = 0;
  39. virtual aura::WindowTreeHost* AsWindowTreeHost() = 0;
  40. // Stop listening for events in preparation for shutdown.
  41. virtual void PrepareForShutdown() {}
  42. virtual void RegisterMirroringHost(AshWindowTreeHost* mirroring_ash_host) {}
  43. virtual void UpdateCursorConfig() = 0;
  44. virtual void ClearCursorConfig() = 0;
  45. virtual void UpdateRootWindowSize() = 0;
  46. protected:
  47. // Returns true if cursor confinement should be allowed. For development
  48. // builds this will return false, for ease of switching between windows,
  49. // unless --ash-constrain-pointer-to-root is provided. This is always true on
  50. // a Chrome OS device.
  51. bool allow_confine_cursor() const { return allow_confine_cursor_; }
  52. // Translates the native mouse location into screen coordinates.
  53. void TranslateLocatedEvent(ui::LocatedEvent* event);
  54. private:
  55. const bool allow_confine_cursor_;
  56. };
  57. } // namespace ash
  58. #endif // ASH_HOST_ASH_WINDOW_TREE_HOST_H_