meta-agl-core: add Upstream-Status tag to patches
[AGL/meta-agl.git] / meta-agl-core / recipes-graphics / wayland / weston / 0001-libweston-desktop-xdg-shell-Add-tiled-orientation-st.patch
1 From 6ab4713d3eba589aa1f39eee2b48c81906d7ba87 Mon Sep 17 00:00:00 2001
2 From: Marius Vlad <marius.vlad@collabora.com>
3 Date: Tue, 16 Aug 2022 13:34:19 +0300
4 Subject: [PATCH] libweston/desktop/xdg-shell: Add tiled orientation states
5
6 With the help of a newly introduced function, weston_desktop_surface_set_orientation(),
7 this patch adds missing tiled states from the xdg-shell protocol.
8 The orientation state is passed on as a bitmask enumeration flag, which the
9 shell can set, allowing multiple tiling states at once.
10
11 These new states are incorporated the same way as the others, retaining
12 the set state, but also avoiding sending new configure events if nothing
13 changed since previously acked data.
14
15 Upstream-Status: Pending
16
17 Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
18 (cherry-picked from 37a3025d893def991dec59587d17672aa3bf967a)
19
20 Note that this was actually ported because libweston-desktop is not
21 embedded into libweston and the structure changed in upstream.
22 ---
23  include/libweston-desktop/libweston-desktop.h | 11 ++++++
24  libweston-desktop/internal.h                  |  2 +
25  libweston-desktop/surface.c                   | 10 +++++
26  libweston-desktop/xdg-shell.c                 | 38 +++++++++++++++++++
27  4 files changed, 61 insertions(+)
28
29 diff --git a/include/libweston-desktop/libweston-desktop.h b/include/libweston-desktop/libweston-desktop.h
30 index 3e7ac73..c296d16 100644
31 --- a/include/libweston-desktop/libweston-desktop.h
32 +++ b/include/libweston-desktop/libweston-desktop.h
33 @@ -44,6 +44,14 @@ enum weston_desktop_surface_edge {
34         WESTON_DESKTOP_SURFACE_EDGE_BOTTOM_RIGHT = 10,
35  };
36  
37 +enum weston_top_level_tiled_orientation {
38 +       WESTON_TOP_LEVEL_TILED_ORIENTATION_NONE         = 0 << 0,
39 +       WESTON_TOP_LEVEL_TILED_ORIENTATION_LEFT         = 1 << 1,
40 +       WESTON_TOP_LEVEL_TILED_ORIENTATION_RIGHT        = 1 << 2,
41 +       WESTON_TOP_LEVEL_TILED_ORIENTATION_TOP          = 1 << 3,
42 +       WESTON_TOP_LEVEL_TILED_ORIENTATION_BOTTOM       = 1 << 4,
43 +};
44 +
45  struct weston_desktop;
46  struct weston_desktop_client;
47  struct weston_desktop_surface;
48 @@ -163,6 +171,9 @@ void
49  weston_desktop_surface_set_size(struct weston_desktop_surface *surface,
50                                 int32_t width, int32_t height);
51  void
52 +weston_desktop_surface_set_orientation(struct weston_desktop_surface *surface,
53 +                                      enum weston_top_level_tiled_orientation tile_orientation);
54 +void
55  weston_desktop_surface_close(struct weston_desktop_surface *surface);
56  void
57  weston_desktop_surface_add_metadata_listener(struct weston_desktop_surface *surface,
58 diff --git a/libweston-desktop/internal.h b/libweston-desktop/internal.h
59 index 2606d27..8afdede 100644
60 --- a/libweston-desktop/internal.h
61 +++ b/libweston-desktop/internal.h
62 @@ -100,6 +100,8 @@ struct weston_desktop_surface_implementation {
63                              void *user_data, bool resizing);
64         void (*set_size)(struct weston_desktop_surface *surface,
65                          void *user_data, int32_t width, int32_t height);
66 +       void (*set_orientation)(struct weston_desktop_surface *surface,
67 +                               void *user_data, enum weston_top_level_tiled_orientation tiled_orientation);
68         void (*committed)(struct weston_desktop_surface *surface, void *user_data,
69                           int32_t sx, int32_t sy);
70         void (*update_position)(struct weston_desktop_surface *surface,
71 diff --git a/libweston-desktop/surface.c b/libweston-desktop/surface.c
72 index 433f08a..6b3f4ae 100644
73 --- a/libweston-desktop/surface.c
74 +++ b/libweston-desktop/surface.c
75 @@ -506,6 +506,16 @@ weston_desktop_surface_set_size(struct weston_desktop_surface *surface, int32_t
76                                                   width, height);
77  }
78  
79 +WL_EXPORT void
80 +weston_desktop_surface_set_orientation(struct weston_desktop_surface *surface,
81 +                                      enum weston_top_level_tiled_orientation tile_orientation)
82 +{
83 +       if (surface->implementation->set_orientation != NULL)
84 +               surface->implementation->set_orientation(surface,
85 +                                                        surface->implementation_data,
86 +                                                        tile_orientation);
87 +}
88 +
89  WL_EXPORT void
90  weston_desktop_surface_close(struct weston_desktop_surface *surface)
91  {
92 diff --git a/libweston-desktop/xdg-shell.c b/libweston-desktop/xdg-shell.c
93 index ff76c39..1e49147 100644
94 --- a/libweston-desktop/xdg-shell.c
95 +++ b/libweston-desktop/xdg-shell.c
96 @@ -94,6 +94,7 @@ struct weston_desktop_xdg_toplevel_state {
97         bool fullscreen;
98         bool resizing;
99         bool activated;
100 +       uint32_t tiled_orientation;
101  };
102  
103  struct weston_desktop_xdg_toplevel_configure {
104 @@ -624,6 +625,29 @@ weston_desktop_xdg_toplevel_send_configure(struct weston_desktop_xdg_toplevel *t
105                 s = wl_array_add(&states, sizeof(uint32_t));
106                 *s = XDG_TOPLEVEL_STATE_ACTIVATED;
107         }
108 +       if (toplevel->pending.state.tiled_orientation &
109 +           WESTON_TOP_LEVEL_TILED_ORIENTATION_LEFT) {
110 +               s = wl_array_add(&states, sizeof(uint32_t));
111 +               *s = XDG_TOPLEVEL_STATE_TILED_LEFT;
112 +       }
113 +
114 +       if (toplevel->pending.state.tiled_orientation &
115 +           WESTON_TOP_LEVEL_TILED_ORIENTATION_RIGHT) {
116 +               s = wl_array_add(&states, sizeof(uint32_t));
117 +               *s = XDG_TOPLEVEL_STATE_TILED_RIGHT;
118 +       }
119 +
120 +       if (toplevel->pending.state.tiled_orientation &
121 +           WESTON_TOP_LEVEL_TILED_ORIENTATION_TOP) {
122 +               s = wl_array_add(&states, sizeof(uint32_t));
123 +               *s = XDG_TOPLEVEL_STATE_TILED_TOP;
124 +       }
125 +
126 +       if (toplevel->pending.state.tiled_orientation &
127 +           WESTON_TOP_LEVEL_TILED_ORIENTATION_BOTTOM) {
128 +               s = wl_array_add(&states, sizeof(uint32_t));
129 +               *s = XDG_TOPLEVEL_STATE_TILED_BOTTOM;
130 +       }
131  
132         xdg_toplevel_send_configure(toplevel->resource,
133                                     toplevel->pending.size.width,
134 @@ -686,6 +710,16 @@ weston_desktop_xdg_toplevel_set_size(struct weston_desktop_surface *dsurface,
135         weston_desktop_xdg_surface_schedule_configure(&toplevel->base);
136  }
137  
138 +static void
139 +weston_desktop_xdg_toplevel_set_orientation(struct weston_desktop_surface *surface, void *user_data,
140 +                                           enum weston_top_level_tiled_orientation tiled_orientation)
141 +{
142 +       struct weston_desktop_xdg_toplevel *toplevel = user_data;
143 +
144 +       toplevel->pending.state.tiled_orientation = tiled_orientation;
145 +       weston_desktop_xdg_surface_schedule_configure(&toplevel->base);
146 +}
147 +
148  static void
149  weston_desktop_xdg_toplevel_committed(struct weston_desktop_xdg_toplevel *toplevel,
150                                       int32_t sx, int32_t sy)
151 @@ -1096,6 +1130,9 @@ weston_desktop_xdg_toplevel_state_compare(struct weston_desktop_xdg_toplevel *to
152                 return false;
153         if (toplevel->pending.state.resizing != configured.state.resizing)
154                 return false;
155 +       if (toplevel->pending.state.tiled_orientation !=
156 +           configured.state.tiled_orientation)
157 +               return false;
158  
159         if (toplevel->pending.size.width == configured.size.width &&
160             toplevel->pending.size.height == configured.size.height)
161 @@ -1440,6 +1477,7 @@ static const struct weston_desktop_surface_implementation weston_desktop_xdg_sur
162         .set_resizing = weston_desktop_xdg_toplevel_set_resizing,
163         .set_activated = weston_desktop_xdg_toplevel_set_activated,
164         .set_size = weston_desktop_xdg_toplevel_set_size,
165 +       .set_orientation = weston_desktop_xdg_toplevel_set_orientation,
166  
167         .get_maximized = weston_desktop_xdg_toplevel_get_maximized,
168         .get_fullscreen = weston_desktop_xdg_toplevel_get_fullscreen,
169 -- 
170 2.35.1
171