blob: 3676965be35d6d595d502e5cf178034f4fb446fa [file] [log] [blame]
Shawn Gallea787ef552018-11-27 23:29:241// 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 Courtney99f3e9fc2019-04-03 09:07:2010#include "components/exo/surface.h"
11#include "components/exo/surface_observer.h"
chinsenj46a97662021-07-01 21:37:4112#include "ui/gfx/geometry/size_f.h"
Eliot Courtney99f3e9fc2019-04-03 09:07:2013#include "ui/wm/public/activation_change_observer.h"
14
Shawn Gallea787ef552018-11-27 23:29:2415struct wl_client;
Eliot Courtney99f3e9fc2019-04-03 09:07:2016struct wl_resource;
Shawn Gallea787ef552018-11-27 23:29:2417
18namespace exo {
jonahwilliams9fdb3fed2021-10-13 18:24:4419
20class ShellSurfaceBase;
21
Shawn Gallea787ef552018-11-27 23:29:2422namespace wayland {
23
yjliu9edcefd2022-01-25 02:00:3324constexpr uint32_t kZAuraShellVersion = 29;
Shawn Gallea787ef552018-11-27 23:29:2425
Daniel Nicoarae3befc02019-06-27 19:46:1026// 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 Gallea787ef552018-11-27 23:29:2429void bind_aura_shell(wl_client* client,
30 void* data,
31 uint32_t version,
32 uint32_t id);
33
Eliot Courtney99f3e9fc2019-04-03 09:07:2034class AuraSurface : public SurfaceObserver,
35 public ::wm::ActivationChangeObserver {
36 public:
37 AuraSurface(Surface* surface, wl_resource* resource);
Peter Boström09c01822021-09-20 22:43:2738
39 AuraSurface(const AuraSurface&) = delete;
40 AuraSurface& operator=(const AuraSurface&) = delete;
41
Eliot Courtney99f3e9fc2019-04-03 09:07:2042 ~AuraSurface() override;
43
44 void SetFrame(SurfaceFrameType type);
Mitsuru Oshimac061d9e2021-01-29 18:52:0745 void SetServerStartResize();
Eliot Courtney99f3e9fc2019-04-03 09:07:2046 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 Piqued507c5f2020-11-11 22:47:0550 void SetClientSurfaceId(const char* client_surface_id);
Eliot Courtney99f3e9fc2019-04-03 09:07:2051 void SetOcclusionTracking(bool tracking);
Nicholas Hollingumde1f81b52019-10-09 02:57:1852 void Activate();
53 void DrawAttention();
Chloe Pelling8a8acdeb2020-07-07 10:45:2054 void SetFullscreenMode(uint32_t mode);
Antonio Gomesd7fcbe62021-02-24 18:30:4955 void IntentToSnap(uint32_t snap_direction);
Cattalyya Nuengsigkapianffc39612021-10-02 00:14:2356 void SetSnapPrimary();
57 void SetSnapSecondary();
Antonio Gomesd7fcbe62021-02-24 18:30:4958 void UnsetSnap();
Shengsong Tan394e2602021-04-07 00:25:2759 void SetWindowSessionId(int32_t window_session_id);
Antonio Gomes22056e22021-04-16 16:56:1960 void SetCanGoBack();
61 void UnsetCanGoBack();
chinsenj46a97662021-07-01 21:37:4162 void SetPip();
63 void UnsetPip();
64 void SetAspectRatio(const gfx::SizeF& aspect_ratio);
Minju Kim98aa08c4f2021-08-10 02:01:4565 void MoveToDesk(int desk_index);
Minju Kim3c300e502021-09-02 09:08:4766 void SetInitialWorkspace(const char* initial_workspace);
Stefan Kuhnedcbdde02021-09-24 19:54:1467 void Pin(bool trusted);
68 void Unpin();
jonahwilliams9fdb3fed2021-10-13 18:24:4469 void SetOrientationLock(uint32_t orientation_lock);
Eliot Courtney99f3e9fc2019-04-03 09:07:2070
71 // Overridden from SurfaceObserver:
72 void OnSurfaceDestroying(Surface* surface) override;
73 void OnWindowOcclusionChanged(Surface* surface) override;
Abhijeet Kandalkard354a702021-03-23 21:52:4674 void OnFrameLockingChanged(Surface* surface, bool lock) override;
Minju Kim98aa08c4f2021-08-10 02:01:4575 void OnDeskChanged(Surface* surface, int state) override;
yjliu9edcefd2022-01-25 02:00:3376 void ThrottleFrameRate(bool on) override;
Eliot Courtney99f3e9fc2019-04-03 09:07:2077
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 Courtney62eec492021-07-15 08:11:5188 virtual void SendOcclusionState(
89 const aura::Window::OcclusionState occlusion_state);
Eliot Courtney99f3e9fc2019-04-03 09:07:2090
91 private:
92 Surface* surface_;
93 wl_resource* const resource_;
94
Eliot Courtney62eec492021-07-15 08:11:5195 void ComputeAndSendOcclusion(
Eliot Courtney99f3e9fc2019-04-03 09:07:2096 const aura::Window::OcclusionState occlusion_state,
97 const SkRegion& occluded_region);
Eliot Courtney99f3e9fc2019-04-03 09:07:2098};
99
jonahwilliams9fdb3fed2021-10-13 18:24:44100// Provides an implementation for top level operations on the shell.
101class 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);
yjliu7d456082021-11-02 18:39:37109 void SetClientSubmitsSurfacesInPixelCoordinates(bool enable);
110
111 private:
112 ShellSurfaceBase* shell_surface_;
113};
114
115class 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);
jonahwilliams9fdb3fed2021-10-13 18:24:44123
124 private:
125 ShellSurfaceBase* shell_surface_;
126};
127
Shawn Gallea787ef552018-11-27 23:29:24128} // namespace wayland
129} // namespace exo
130
Eliot Courtney99f3e9fc2019-04-03 09:07:20131#endif // COMPONENTS_EXO_WAYLAND_ZAURA_SHELL_H_