Shawn Gallea | 787ef55 | 2018-11-27 23:29:24 | [diff] [blame] | 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 | |
| 5 | #ifndef COMPONENTS_EXO_WAYLAND_ZAURA_SHELL_H_ |
| 6 | #define COMPONENTS_EXO_WAYLAND_ZAURA_SHELL_H_ |
| 7 | |
| 8 | #include <stdint.h> |
| 9 | |
Eliot Courtney | 99f3e9fc | 2019-04-03 09:07:20 | [diff] [blame] | 10 | #include "components/exo/surface.h" |
| 11 | #include "components/exo/surface_observer.h" |
chinsenj | 46a9766 | 2021-07-01 21:37:41 | [diff] [blame] | 12 | #include "ui/gfx/geometry/size_f.h" |
Eliot Courtney | 99f3e9fc | 2019-04-03 09:07:20 | [diff] [blame] | 13 | #include "ui/wm/public/activation_change_observer.h" |
| 14 | |
Shawn Gallea | 787ef55 | 2018-11-27 23:29:24 | [diff] [blame] | 15 | struct wl_client; |
Eliot Courtney | 99f3e9fc | 2019-04-03 09:07:20 | [diff] [blame] | 16 | struct wl_resource; |
Shawn Gallea | 787ef55 | 2018-11-27 23:29:24 | [diff] [blame] | 17 | |
| 18 | namespace exo { |
jonahwilliams | 9fdb3fed | 2021-10-13 18:24:44 | [diff] [blame] | 19 | |
| 20 | class ShellSurfaceBase; |
| 21 | |
Shawn Gallea | 787ef55 | 2018-11-27 23:29:24 | [diff] [blame] | 22 | namespace wayland { |
| 23 | |
yjliu | 9edcefd | 2022-01-25 02:00:33 | [diff] [blame^] | 24 | constexpr uint32_t kZAuraShellVersion = 29; |
Shawn Gallea | 787ef55 | 2018-11-27 23:29:24 | [diff] [blame] | 25 | |
Daniel Nicoara | e3befc0 | 2019-06-27 19:46:10 | [diff] [blame] | 26 | // Adds bindings to the Aura Shell. Normally this implies Ash on ChromeOS |
| 27 | // builds. On non-ChromeOS builds the protocol provides access to Aura windowing |
| 28 | // system. |
Shawn Gallea | 787ef55 | 2018-11-27 23:29:24 | [diff] [blame] | 29 | void bind_aura_shell(wl_client* client, |
| 30 | void* data, |
| 31 | uint32_t version, |
| 32 | uint32_t id); |
| 33 | |
Eliot Courtney | 99f3e9fc | 2019-04-03 09:07:20 | [diff] [blame] | 34 | class AuraSurface : public SurfaceObserver, |
| 35 | public ::wm::ActivationChangeObserver { |
| 36 | public: |
| 37 | AuraSurface(Surface* surface, wl_resource* resource); |
Peter Boström | 09c0182 | 2021-09-20 22:43:27 | [diff] [blame] | 38 | |
| 39 | AuraSurface(const AuraSurface&) = delete; |
| 40 | AuraSurface& operator=(const AuraSurface&) = delete; |
| 41 | |
Eliot Courtney | 99f3e9fc | 2019-04-03 09:07:20 | [diff] [blame] | 42 | ~AuraSurface() override; |
| 43 | |
| 44 | void SetFrame(SurfaceFrameType type); |
Mitsuru Oshima | c061d9e | 2021-01-29 18:52:07 | [diff] [blame] | 45 | void SetServerStartResize(); |
Eliot Courtney | 99f3e9fc | 2019-04-03 09:07:20 | [diff] [blame] | 46 | void SetFrameColors(SkColor active_frame_color, SkColor inactive_frame_color); |
| 47 | void SetParent(AuraSurface* parent, const gfx::Point& position); |
| 48 | void SetStartupId(const char* startup_id); |
| 49 | void SetApplicationId(const char* application_id); |
Lloyd Pique | d507c5f | 2020-11-11 22:47:05 | [diff] [blame] | 50 | void SetClientSurfaceId(const char* client_surface_id); |
Eliot Courtney | 99f3e9fc | 2019-04-03 09:07:20 | [diff] [blame] | 51 | void SetOcclusionTracking(bool tracking); |
Nicholas Hollingum | de1f81b5 | 2019-10-09 02:57:18 | [diff] [blame] | 52 | void Activate(); |
| 53 | void DrawAttention(); |
Chloe Pelling | 8a8acdeb | 2020-07-07 10:45:20 | [diff] [blame] | 54 | void SetFullscreenMode(uint32_t mode); |
Antonio Gomes | d7fcbe6 | 2021-02-24 18:30:49 | [diff] [blame] | 55 | void IntentToSnap(uint32_t snap_direction); |
Cattalyya Nuengsigkapian | ffc3961 | 2021-10-02 00:14:23 | [diff] [blame] | 56 | void SetSnapPrimary(); |
| 57 | void SetSnapSecondary(); |
Antonio Gomes | d7fcbe6 | 2021-02-24 18:30:49 | [diff] [blame] | 58 | void UnsetSnap(); |
Shengsong Tan | 394e260 | 2021-04-07 00:25:27 | [diff] [blame] | 59 | void SetWindowSessionId(int32_t window_session_id); |
Antonio Gomes | 22056e2 | 2021-04-16 16:56:19 | [diff] [blame] | 60 | void SetCanGoBack(); |
| 61 | void UnsetCanGoBack(); |
chinsenj | 46a9766 | 2021-07-01 21:37:41 | [diff] [blame] | 62 | void SetPip(); |
| 63 | void UnsetPip(); |
| 64 | void SetAspectRatio(const gfx::SizeF& aspect_ratio); |
Minju Kim | 98aa08c4f | 2021-08-10 02:01:45 | [diff] [blame] | 65 | void MoveToDesk(int desk_index); |
Minju Kim | 3c300e50 | 2021-09-02 09:08:47 | [diff] [blame] | 66 | void SetInitialWorkspace(const char* initial_workspace); |
Stefan Kuhne | dcbdde0 | 2021-09-24 19:54:14 | [diff] [blame] | 67 | void Pin(bool trusted); |
| 68 | void Unpin(); |
jonahwilliams | 9fdb3fed | 2021-10-13 18:24:44 | [diff] [blame] | 69 | void SetOrientationLock(uint32_t orientation_lock); |
Eliot Courtney | 99f3e9fc | 2019-04-03 09:07:20 | [diff] [blame] | 70 | |
| 71 | // Overridden from SurfaceObserver: |
| 72 | void OnSurfaceDestroying(Surface* surface) override; |
| 73 | void OnWindowOcclusionChanged(Surface* surface) override; |
Abhijeet Kandalkar | d354a70 | 2021-03-23 21:52:46 | [diff] [blame] | 74 | void OnFrameLockingChanged(Surface* surface, bool lock) override; |
Minju Kim | 98aa08c4f | 2021-08-10 02:01:45 | [diff] [blame] | 75 | void OnDeskChanged(Surface* surface, int state) override; |
yjliu | 9edcefd | 2022-01-25 02:00:33 | [diff] [blame^] | 76 | void ThrottleFrameRate(bool on) override; |
Eliot Courtney | 99f3e9fc | 2019-04-03 09:07:20 | [diff] [blame] | 77 | |
| 78 | // Overridden from ActivationChangeObserver: |
| 79 | void OnWindowActivating(ActivationReason reason, |
| 80 | aura::Window* gaining_active, |
| 81 | aura::Window* losing_active) override; |
| 82 | void OnWindowActivated(ActivationReason reason, |
| 83 | aura::Window* gained_active, |
| 84 | aura::Window* lost_active) override {} |
| 85 | |
| 86 | protected: |
| 87 | virtual void SendOcclusionFraction(float occlusion_fraction); |
Eliot Courtney | 62eec49 | 2021-07-15 08:11:51 | [diff] [blame] | 88 | virtual void SendOcclusionState( |
| 89 | const aura::Window::OcclusionState occlusion_state); |
Eliot Courtney | 99f3e9fc | 2019-04-03 09:07:20 | [diff] [blame] | 90 | |
| 91 | private: |
| 92 | Surface* surface_; |
| 93 | wl_resource* const resource_; |
| 94 | |
Eliot Courtney | 62eec49 | 2021-07-15 08:11:51 | [diff] [blame] | 95 | void ComputeAndSendOcclusion( |
Eliot Courtney | 99f3e9fc | 2019-04-03 09:07:20 | [diff] [blame] | 96 | const aura::Window::OcclusionState occlusion_state, |
| 97 | const SkRegion& occluded_region); |
Eliot Courtney | 99f3e9fc | 2019-04-03 09:07:20 | [diff] [blame] | 98 | }; |
| 99 | |
jonahwilliams | 9fdb3fed | 2021-10-13 18:24:44 | [diff] [blame] | 100 | // Provides an implementation for top level operations on the shell. |
| 101 | class AuraToplevel { |
| 102 | public: |
| 103 | AuraToplevel(ShellSurfaceBase* shell_surface); |
| 104 | AuraToplevel(const AuraToplevel&) = delete; |
| 105 | AuraToplevel& operator=(const AuraToplevel&) = delete; |
| 106 | ~AuraToplevel(); |
| 107 | |
| 108 | void SetOrientationLock(uint32_t lock_type); |
yjliu | 7d45608 | 2021-11-02 18:39:37 | [diff] [blame] | 109 | void SetClientSubmitsSurfacesInPixelCoordinates(bool enable); |
| 110 | |
| 111 | private: |
| 112 | ShellSurfaceBase* shell_surface_; |
| 113 | }; |
| 114 | |
| 115 | class AuraPopup { |
| 116 | public: |
| 117 | AuraPopup(ShellSurfaceBase* shell_surface); |
| 118 | AuraPopup(const AuraPopup&) = delete; |
| 119 | AuraPopup& operator=(const AuraPopup&) = delete; |
| 120 | ~AuraPopup(); |
| 121 | |
| 122 | void SetClientSubmitsSurfacesInPixelCoordinates(bool enable); |
jonahwilliams | 9fdb3fed | 2021-10-13 18:24:44 | [diff] [blame] | 123 | |
| 124 | private: |
| 125 | ShellSurfaceBase* shell_surface_; |
| 126 | }; |
| 127 | |
Shawn Gallea | 787ef55 | 2018-11-27 23:29:24 | [diff] [blame] | 128 | } // namespace wayland |
| 129 | } // namespace exo |
| 130 | |
Eliot Courtney | 99f3e9fc | 2019-04-03 09:07:20 | [diff] [blame] | 131 | #endif // COMPONENTS_EXO_WAYLAND_ZAURA_SHELL_H_ |