zaura_shell.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. // Copyright 2018 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 COMPONENTS_EXO_WAYLAND_ZAURA_SHELL_H_
  5. #define COMPONENTS_EXO_WAYLAND_ZAURA_SHELL_H_
  6. #include <stdint.h>
  7. #include "chromeos/ui/base/window_state_type.h"
  8. #include "components/exo/surface.h"
  9. #include "components/exo/surface_observer.h"
  10. #include "components/exo/wayland/wayland_display_observer.h"
  11. #include "ui/gfx/geometry/insets.h"
  12. #include "ui/gfx/geometry/size_f.h"
  13. #include "ui/wm/public/activation_change_observer.h"
  14. struct wl_client;
  15. struct wl_resource;
  16. namespace exo {
  17. class ShellSurface;
  18. class ShellSurfaceBase;
  19. namespace wayland {
  20. class SerialTracker;
  21. constexpr uint32_t kZAuraShellVersion = 40;
  22. // Adds bindings to the Aura Shell. Normally this implies Ash on ChromeOS
  23. // builds. On non-ChromeOS builds the protocol provides access to Aura windowing
  24. // system.
  25. void bind_aura_shell(wl_client* client,
  26. void* data,
  27. uint32_t version,
  28. uint32_t id);
  29. class AuraSurface : public SurfaceObserver,
  30. public ::wm::ActivationChangeObserver {
  31. public:
  32. AuraSurface(Surface* surface, wl_resource* resource);
  33. AuraSurface(const AuraSurface&) = delete;
  34. AuraSurface& operator=(const AuraSurface&) = delete;
  35. ~AuraSurface() override;
  36. void SetFrame(SurfaceFrameType type);
  37. void SetServerStartResize();
  38. void SetFrameColors(SkColor active_frame_color, SkColor inactive_frame_color);
  39. void SetParent(AuraSurface* parent, const gfx::Point& position);
  40. void SetStartupId(const char* startup_id);
  41. void SetApplicationId(const char* application_id);
  42. void SetClientSurfaceId(const char* client_surface_id);
  43. void SetOcclusionTracking(bool tracking);
  44. void Activate();
  45. void DrawAttention();
  46. void SetFullscreenMode(uint32_t mode);
  47. void IntentToSnap(uint32_t snap_direction);
  48. void SetSnapPrimary();
  49. void SetSnapSecondary();
  50. void UnsetSnap();
  51. void SetWindowSessionId(int32_t window_session_id);
  52. void SetCanGoBack();
  53. void UnsetCanGoBack();
  54. void SetPip();
  55. void UnsetPip();
  56. void SetAspectRatio(const gfx::SizeF& aspect_ratio);
  57. void MoveToDesk(int desk_index);
  58. void SetInitialWorkspace(const char* initial_workspace);
  59. void Pin(bool trusted);
  60. void Unpin();
  61. void SetOrientationLock(uint32_t orientation_lock);
  62. // Overridden from SurfaceObserver:
  63. void OnSurfaceDestroying(Surface* surface) override;
  64. void OnWindowOcclusionChanged(Surface* surface) override;
  65. void OnFrameLockingChanged(Surface* surface, bool lock) override;
  66. void OnDeskChanged(Surface* surface, int state) override;
  67. void ThrottleFrameRate(bool on) override;
  68. // Overridden from ActivationChangeObserver:
  69. void OnWindowActivating(ActivationReason reason,
  70. aura::Window* gaining_active,
  71. aura::Window* losing_active) override;
  72. void OnWindowActivated(ActivationReason reason,
  73. aura::Window* gained_active,
  74. aura::Window* lost_active) override {}
  75. protected:
  76. virtual void SendOcclusionFraction(float occlusion_fraction);
  77. virtual void SendOcclusionState(
  78. const aura::Window::OcclusionState occlusion_state);
  79. private:
  80. Surface* surface_;
  81. wl_resource* const resource_;
  82. void ComputeAndSendOcclusion(
  83. const aura::Window::OcclusionState occlusion_state,
  84. const SkRegion& occluded_region);
  85. };
  86. // Provides an implementation for top level operations on the shell.
  87. class AuraToplevel {
  88. public:
  89. AuraToplevel(ShellSurface* shell_surface,
  90. SerialTracker* const serial_tracker,
  91. wl_resource* aura_toplevel_resource,
  92. wl_resource* xdg_toplevel_resource);
  93. AuraToplevel(const AuraToplevel&) = delete;
  94. AuraToplevel& operator=(const AuraToplevel&) = delete;
  95. virtual ~AuraToplevel();
  96. void SetOrientationLock(uint32_t lock_type);
  97. void SetClientSubmitsSurfacesInPixelCoordinates(bool enable);
  98. void SetClientUsesScreenCoordinates();
  99. void SetWindowBounds(int32_t x, int32_t y, int32_t width, int32_t height);
  100. void SetRestoreInfo(int32_t restore_session_id, int32_t restore_window_id);
  101. void SetRestoreInfoWithWindowIdSource(
  102. int32_t restore_session_id,
  103. const std::string& restore_window_id_source);
  104. void SetSystemModal(bool modal);
  105. void SetFloat();
  106. void UnsetFloat();
  107. void OnConfigure(const gfx::Rect& bounds,
  108. chromeos::WindowStateType state_type,
  109. bool resizing,
  110. bool activated);
  111. virtual void OnOriginChange(const gfx::Point& origin);
  112. void SetDecoration(SurfaceFrameType type);
  113. void SetZOrder(ui::ZOrderLevel z_order);
  114. ShellSurface* shell_surface_;
  115. SerialTracker* const serial_tracker_;
  116. wl_resource* xdg_toplevel_resource_;
  117. wl_resource* aura_toplevel_resource_;
  118. bool supports_window_bounds_ = false;
  119. base::WeakPtrFactory<AuraToplevel> weak_ptr_factory_{this};
  120. };
  121. class AuraPopup {
  122. public:
  123. AuraPopup(ShellSurfaceBase* shell_surface);
  124. AuraPopup(const AuraPopup&) = delete;
  125. AuraPopup& operator=(const AuraPopup&) = delete;
  126. ~AuraPopup();
  127. void SetClientSubmitsSurfacesInPixelCoordinates(bool enable);
  128. void SetDecoration(SurfaceFrameType type);
  129. void SetMenu();
  130. private:
  131. ShellSurfaceBase* shell_surface_;
  132. };
  133. class AuraOutput : public WaylandDisplayObserver {
  134. public:
  135. AuraOutput(wl_resource* resource, WaylandDisplayHandler* display_handler);
  136. AuraOutput(const AuraOutput&) = delete;
  137. AuraOutput& operator=(const AuraOutput&) = delete;
  138. ~AuraOutput() override;
  139. // Overridden from WaylandDisplayObserver:
  140. bool SendDisplayMetrics(const display::Display& display,
  141. uint32_t changed_metrics) override;
  142. void OnOutputDestroyed() override;
  143. bool HasDisplayHandlerForTesting() const;
  144. protected:
  145. virtual void SendInsets(const gfx::Insets& insets);
  146. virtual void SendLogicalTransform(int32_t transform);
  147. private:
  148. wl_resource* const resource_;
  149. WaylandDisplayHandler* display_handler_;
  150. };
  151. } // namespace wayland
  152. } // namespace exo
  153. #endif // COMPONENTS_EXO_WAYLAND_ZAURA_SHELL_H_