summaryrefslogtreecommitdiffstats
path: root/meta-agl-core/recipes-graphics/wayland/weston
diff options
context:
space:
mode:
Diffstat (limited to 'meta-agl-core/recipes-graphics/wayland/weston')
-rw-r--r--meta-agl-core/recipes-graphics/wayland/weston/0001-clients-Handle-missing-pointer_surface-is-there-s-no.patch30
-rw-r--r--meta-agl-core/recipes-graphics/wayland/weston/0001-libweston-Add-paint-node-destruction-into-weston_lay.patch60
-rw-r--r--meta-agl-core/recipes-graphics/wayland/weston/0001-libweston-Migrate-weston_seat_init-release-to-public.patch106
-rw-r--r--meta-agl-core/recipes-graphics/wayland/weston/0001-libweston-Send-name-description-update-wl_output-to-.patch115
-rw-r--r--meta-agl-core/recipes-graphics/wayland/weston/0001-libweston-desktop-xdg-shell-Add-tiled-orientation-st.patch169
-rw-r--r--meta-agl-core/recipes-graphics/wayland/weston/0001-simple-touch-Add-maximized-fullscreen-states.patch136
6 files changed, 90 insertions, 526 deletions
diff --git a/meta-agl-core/recipes-graphics/wayland/weston/0001-clients-Handle-missing-pointer_surface-is-there-s-no.patch b/meta-agl-core/recipes-graphics/wayland/weston/0001-clients-Handle-missing-pointer_surface-is-there-s-no.patch
new file mode 100644
index 000000000..202333a5e
--- /dev/null
+++ b/meta-agl-core/recipes-graphics/wayland/weston/0001-clients-Handle-missing-pointer_surface-is-there-s-no.patch
@@ -0,0 +1,30 @@
+From 6a847464de9e773f6d1490916d0df48a0f90eeba Mon Sep 17 00:00:00 2001
+From: Marius Vlad <marius.vlad@collabora.com>
+Date: Thu, 5 Oct 2023 16:27:34 +0300
+Subject: [PATCH] clients: Handle missing pointer_surface is there's no pointer
+ event
+
+Upstream-Status: Pending
+
+Bug-AGL: SPEC-4916
+Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
+---
+ clients/window.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/clients/window.c b/clients/window.c
+index 30f6410..882e9d5 100644
+--- a/clients/window.c
++++ b/clients/window.c
+@@ -3818,7 +3818,7 @@ pointer_surface_frame_callback(void *data, struct wl_callback *callback,
+ force_frame = false;
+ }
+
+- if (!input->pointer)
++ if (!input->pointer || !input->pointer_surface)
+ return;
+
+ if (input_set_pointer_special(input))
+--
+2.35.1
+
diff --git a/meta-agl-core/recipes-graphics/wayland/weston/0001-libweston-Add-paint-node-destruction-into-weston_lay.patch b/meta-agl-core/recipes-graphics/wayland/weston/0001-libweston-Add-paint-node-destruction-into-weston_lay.patch
new file mode 100644
index 000000000..19eadcf7f
--- /dev/null
+++ b/meta-agl-core/recipes-graphics/wayland/weston/0001-libweston-Add-paint-node-destruction-into-weston_lay.patch
@@ -0,0 +1,60 @@
+From cfde02d47a503cbfd0629bbfe0cb776686af8a91 Mon Sep 17 00:00:00 2001
+From: Marius Vlad <marius.vlad@collabora.com>
+Date: Tue, 9 Apr 2024 18:34:22 +0300
+Subject: [PATCH] libweston: Add paint node destruction into
+ weston_layer_entry_remove()
+
+This prevents a potential crash where users of
+weston_layer_entry_insert/layer_entry_remove() would see when moving
+views into a NULL layer (effectively unmapping the surface/view).
+
+Users that have migrated to the weston_view_move_to_layer() are immune
+to this issue because that takes care paint node destruction.
+
+Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
+---
+ libweston/compositor.c | 17 ++++++++++-------
+ 1 file changed, 10 insertions(+), 7 deletions(-)
+
+diff --git a/libweston/compositor.c b/libweston/compositor.c
+index bb29b83b5..ea257bb90 100644
+--- a/libweston/compositor.c
++++ b/libweston/compositor.c
+@@ -3980,17 +3980,10 @@ weston_view_move_to_layer(struct weston_view *view,
+ struct weston_layer_entry *layer)
+ {
+ bool was_mapped = view->is_mapped;
+- struct weston_paint_node *pnode, *pntmp;
+
+ if (layer == &view->layer_link)
+ return;
+
+- /* Remove all paint nodes because we have no idea what a layer change
+- * does to view visibility on any output.
+- */
+- wl_list_for_each_safe(pnode, pntmp, &view->paint_node_list, view_link)
+- weston_paint_node_destroy(pnode);
+-
+ view->surface->compositor->view_list_needs_rebuild = true;
+
+ /* Damage the view's old region, and remove it from the layer. */
+@@ -4020,6 +4013,16 @@ weston_view_move_to_layer(struct weston_view *view,
+ WL_EXPORT void
+ weston_layer_entry_remove(struct weston_layer_entry *entry)
+ {
++ struct weston_paint_node *pnode, *pntmp;
++ struct weston_view *view;
++
++ /* Remove all paint nodes because we have no idea what a layer change
++ * does to view visibility on any output.
++ */
++ view = container_of(entry, struct weston_view, layer_link);
++ wl_list_for_each_safe(pnode, pntmp, &view->paint_node_list, view_link)
++ weston_paint_node_destroy(pnode);
++
+ wl_list_remove(&entry->link);
+ wl_list_init(&entry->link);
+ entry->layer = NULL;
+--
+2.43.0
+
diff --git a/meta-agl-core/recipes-graphics/wayland/weston/0001-libweston-Migrate-weston_seat_init-release-to-public.patch b/meta-agl-core/recipes-graphics/wayland/weston/0001-libweston-Migrate-weston_seat_init-release-to-public.patch
deleted file mode 100644
index 02af7cbaf..000000000
--- a/meta-agl-core/recipes-graphics/wayland/weston/0001-libweston-Migrate-weston_seat_init-release-to-public.patch
+++ /dev/null
@@ -1,106 +0,0 @@
-From 4534fcab54409b08faf4445ed6780136b58afb63 Mon Sep 17 00:00:00 2001
-From: Marius Vlad <marius.vlad@collabora.com>
-Date: Mon, 28 Sep 2020 22:51:00 +0300
-Subject: [PATCH 1/2] libweston: Migrate weston_seat_init/release to public
- headers
-
-weston_seat_init/release needed for creating weston plug-ins that want
-manage seat/input on their own.
-
-Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
----
- include/libweston/libweston.h | 25 +++++++++++++++++++++++++
- libweston/libweston-internal.h | 31 +++----------------------------
- 2 files changed, 28 insertions(+), 28 deletions(-)
-
-diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h
-index 54ea008..59541f2 100644
---- a/include/libweston/libweston.h
-+++ b/include/libweston/libweston.h
-@@ -2053,6 +2053,31 @@ void
- weston_timeline_refresh_subscription_objects(struct weston_compositor *wc,
- void *object);
-
-+/* input, seat */
-+void
-+weston_seat_init(struct weston_seat *seat, struct weston_compositor *ec,
-+ const char *seat_name);
-+void
-+weston_seat_release(struct weston_seat *seat);
-+
-+void
-+weston_seat_init_pointer(struct weston_seat *seat);
-+
-+int
-+weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap);
-+
-+void
-+weston_seat_init_touch(struct weston_seat *seat);
-+
-+void
-+weston_seat_release_keyboard(struct weston_seat *seat);
-+
-+void
-+weston_seat_release_pointer(struct weston_seat *seat);
-+
-+void
-+weston_seat_release_touch(struct weston_seat *seat);
-+
- #ifdef __cplusplus
- }
- #endif
-diff --git a/libweston/libweston-internal.h b/libweston/libweston-internal.h
-index 66c38e8..f5c4c2c 100644
---- a/libweston/libweston-internal.h
-+++ b/libweston/libweston-internal.h
-@@ -168,44 +168,19 @@ weston_plane_init(struct weston_plane *plane,
- void
- weston_plane_release(struct weston_plane *plane);
-
--/* weston_seat */
--
- struct clipboard *
- clipboard_create(struct weston_seat *seat);
-
--void
--weston_seat_init(struct weston_seat *seat, struct weston_compositor *ec,
-- const char *seat_name);
--
--void
--weston_seat_repick(struct weston_seat *seat);
-+/* weston_seat */
-
- void
--weston_seat_release(struct weston_seat *seat);
-+weston_seat_update_keymap(struct weston_seat *seat, struct xkb_keymap *keymap);
-
- void
- weston_seat_send_selection(struct weston_seat *seat, struct wl_client *client);
-
- void
--weston_seat_init_pointer(struct weston_seat *seat);
--
--int
--weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap);
--
--void
--weston_seat_init_touch(struct weston_seat *seat);
--
--void
--weston_seat_release_keyboard(struct weston_seat *seat);
--
--void
--weston_seat_release_pointer(struct weston_seat *seat);
--
--void
--weston_seat_release_touch(struct weston_seat *seat);
--
--void
--weston_seat_update_keymap(struct weston_seat *seat, struct xkb_keymap *keymap);
-+weston_seat_repick(struct weston_seat *seat);
-
- void
- wl_data_device_set_keyboard_focus(struct weston_seat *seat);
---
-2.28.0
-
diff --git a/meta-agl-core/recipes-graphics/wayland/weston/0001-libweston-Send-name-description-update-wl_output-to-.patch b/meta-agl-core/recipes-graphics/wayland/weston/0001-libweston-Send-name-description-update-wl_output-to-.patch
deleted file mode 100644
index 46e305d12..000000000
--- a/meta-agl-core/recipes-graphics/wayland/weston/0001-libweston-Send-name-description-update-wl_output-to-.patch
+++ /dev/null
@@ -1,115 +0,0 @@
-From 5361d157ff6b11d5cb7a9f989abe5f376c9e2efa Mon Sep 17 00:00:00 2001
-From: Marius Vlad <marius.vlad@collabora.com>
-Date: Wed, 24 Aug 2022 11:43:06 +0300
-Subject: [PATCH] libweston: Send name,description, update wl_output to ver 4
-
-These have been in wayland a while back with version 1.20.0.
-
-We also need to update the test client helper with this bump, as
-those bind to version 4.
-
-Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
----
- libweston/compositor.c | 14 +++++++++++++-
- tests/weston-test-client-helper.c | 18 ++++++++++++++++++
- tests/weston-test-client-helper.h | 2 ++
- 3 files changed, 33 insertions(+), 1 deletion(-)
-
-diff --git a/libweston/compositor.c b/libweston/compositor.c
-index 1670c50..af7c71e 100644
---- a/libweston/compositor.c
-+++ b/libweston/compositor.c
-@@ -184,6 +184,12 @@ weston_mode_switch_send_events(struct weston_head *head,
- if (version >= WL_OUTPUT_SCALE_SINCE_VERSION && scale_changed)
- wl_output_send_scale(resource, output->current_scale);
-
-+ if (version >= WL_OUTPUT_NAME_SINCE_VERSION)
-+ wl_output_send_name(resource, head->name);
-+
-+ if (version >= WL_OUTPUT_DESCRIPTION_SINCE_VERSION)
-+ wl_output_send_description(resource, head->model);
-+
- if (version >= WL_OUTPUT_DONE_SINCE_VERSION)
- wl_output_send_done(resource);
- }
-@@ -5198,6 +5204,12 @@ bind_output(struct wl_client *client,
- mode->refresh);
- }
-
-+ if (version >= WL_OUTPUT_NAME_SINCE_VERSION)
-+ wl_output_send_name(resource, head->name);
-+
-+ if (version >= WL_OUTPUT_DESCRIPTION_SINCE_VERSION)
-+ wl_output_send_description(resource, head->model);
-+
- if (version >= WL_OUTPUT_DONE_SINCE_VERSION)
- wl_output_send_done(resource);
- }
-@@ -5206,7 +5218,7 @@ static void
- weston_head_add_global(struct weston_head *head)
- {
- head->global = wl_global_create(head->compositor->wl_display,
-- &wl_output_interface, 3,
-+ &wl_output_interface, 4,
- head, bind_output);
- }
-
-diff --git a/tests/weston-test-client-helper.c b/tests/weston-test-client-helper.c
-index 01c4b80..8369c40 100644
---- a/tests/weston-test-client-helper.c
-+++ b/tests/weston-test-client-helper.c
-@@ -715,6 +715,20 @@ output_handle_scale(void *data,
- output->scale = scale;
- }
-
-+static void
-+output_handle_name(void *data, struct wl_output *wl_output, const char *name)
-+{
-+ struct output *output = data;
-+ output->name = strdup(name);
-+}
-+
-+static void
-+output_handle_description(void *data, struct wl_output *wl_output, const char *desc)
-+{
-+ struct output *output = data;
-+ output->name = strdup(desc);
-+}
-+
- static void
- output_handle_done(void *data,
- struct wl_output *wl_output)
-@@ -729,6 +743,8 @@ static const struct wl_output_listener output_listener = {
- output_handle_mode,
- output_handle_done,
- output_handle_scale,
-+ output_handle_name,
-+ output_handle_description,
- };
-
- static void
-@@ -737,6 +753,8 @@ output_destroy(struct output *output)
- assert(wl_proxy_get_version((struct wl_proxy *)output->wl_output) >= 3);
- wl_output_release(output->wl_output);
- wl_list_remove(&output->link);
-+ free(output->name);
-+ free(output->desc);
- free(output);
- }
-
-diff --git a/tests/weston-test-client-helper.h b/tests/weston-test-client-helper.h
-index 8e1505d..9e05009 100644
---- a/tests/weston-test-client-helper.h
-+++ b/tests/weston-test-client-helper.h
-@@ -163,6 +163,8 @@ struct output {
- int height;
- int scale;
- int initialized;
-+ char *name;
-+ char *desc;
- };
-
- struct buffer {
---
-2.35.1
-
diff --git a/meta-agl-core/recipes-graphics/wayland/weston/0001-libweston-desktop-xdg-shell-Add-tiled-orientation-st.patch b/meta-agl-core/recipes-graphics/wayland/weston/0001-libweston-desktop-xdg-shell-Add-tiled-orientation-st.patch
deleted file mode 100644
index e0b8a3ba3..000000000
--- a/meta-agl-core/recipes-graphics/wayland/weston/0001-libweston-desktop-xdg-shell-Add-tiled-orientation-st.patch
+++ /dev/null
@@ -1,169 +0,0 @@
-From 6ab4713d3eba589aa1f39eee2b48c81906d7ba87 Mon Sep 17 00:00:00 2001
-From: Marius Vlad <marius.vlad@collabora.com>
-Date: Tue, 16 Aug 2022 13:34:19 +0300
-Subject: [PATCH] libweston/desktop/xdg-shell: Add tiled orientation states
-
-With the help of a newly introduced function, weston_desktop_surface_set_orientation(),
-this patch adds missing tiled states from the xdg-shell protocol.
-The orientation state is passed on as a bitmask enumeration flag, which the
-shell can set, allowing multiple tiling states at once.
-
-These new states are incorporated the same way as the others, retaining
-the set state, but also avoiding sending new configure events if nothing
-changed since previously acked data.
-
-Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
-(cherry-picked from 37a3025d893def991dec59587d17672aa3bf967a)
-
-Note that this was actually ported because libweston-desktop is not
-embedded into libweston and the structure changed in upstream.
----
- include/libweston-desktop/libweston-desktop.h | 11 ++++++
- libweston-desktop/internal.h | 2 +
- libweston-desktop/surface.c | 10 +++++
- libweston-desktop/xdg-shell.c | 38 +++++++++++++++++++
- 4 files changed, 61 insertions(+)
-
-diff --git a/include/libweston-desktop/libweston-desktop.h b/include/libweston-desktop/libweston-desktop.h
-index 3e7ac73..c296d16 100644
---- a/include/libweston-desktop/libweston-desktop.h
-+++ b/include/libweston-desktop/libweston-desktop.h
-@@ -44,6 +44,14 @@ enum weston_desktop_surface_edge {
- WESTON_DESKTOP_SURFACE_EDGE_BOTTOM_RIGHT = 10,
- };
-
-+enum weston_top_level_tiled_orientation {
-+ WESTON_TOP_LEVEL_TILED_ORIENTATION_NONE = 0 << 0,
-+ WESTON_TOP_LEVEL_TILED_ORIENTATION_LEFT = 1 << 1,
-+ WESTON_TOP_LEVEL_TILED_ORIENTATION_RIGHT = 1 << 2,
-+ WESTON_TOP_LEVEL_TILED_ORIENTATION_TOP = 1 << 3,
-+ WESTON_TOP_LEVEL_TILED_ORIENTATION_BOTTOM = 1 << 4,
-+};
-+
- struct weston_desktop;
- struct weston_desktop_client;
- struct weston_desktop_surface;
-@@ -163,6 +171,9 @@ void
- weston_desktop_surface_set_size(struct weston_desktop_surface *surface,
- int32_t width, int32_t height);
- void
-+weston_desktop_surface_set_orientation(struct weston_desktop_surface *surface,
-+ enum weston_top_level_tiled_orientation tile_orientation);
-+void
- weston_desktop_surface_close(struct weston_desktop_surface *surface);
- void
- weston_desktop_surface_add_metadata_listener(struct weston_desktop_surface *surface,
-diff --git a/libweston-desktop/internal.h b/libweston-desktop/internal.h
-index 2606d27..8afdede 100644
---- a/libweston-desktop/internal.h
-+++ b/libweston-desktop/internal.h
-@@ -100,6 +100,8 @@ struct weston_desktop_surface_implementation {
- void *user_data, bool resizing);
- void (*set_size)(struct weston_desktop_surface *surface,
- void *user_data, int32_t width, int32_t height);
-+ void (*set_orientation)(struct weston_desktop_surface *surface,
-+ void *user_data, enum weston_top_level_tiled_orientation tiled_orientation);
- void (*committed)(struct weston_desktop_surface *surface, void *user_data,
- int32_t sx, int32_t sy);
- void (*update_position)(struct weston_desktop_surface *surface,
-diff --git a/libweston-desktop/surface.c b/libweston-desktop/surface.c
-index 433f08a..6b3f4ae 100644
---- a/libweston-desktop/surface.c
-+++ b/libweston-desktop/surface.c
-@@ -506,6 +506,16 @@ weston_desktop_surface_set_size(struct weston_desktop_surface *surface, int32_t
- width, height);
- }
-
-+WL_EXPORT void
-+weston_desktop_surface_set_orientation(struct weston_desktop_surface *surface,
-+ enum weston_top_level_tiled_orientation tile_orientation)
-+{
-+ if (surface->implementation->set_orientation != NULL)
-+ surface->implementation->set_orientation(surface,
-+ surface->implementation_data,
-+ tile_orientation);
-+}
-+
- WL_EXPORT void
- weston_desktop_surface_close(struct weston_desktop_surface *surface)
- {
-diff --git a/libweston-desktop/xdg-shell.c b/libweston-desktop/xdg-shell.c
-index ff76c39..1e49147 100644
---- a/libweston-desktop/xdg-shell.c
-+++ b/libweston-desktop/xdg-shell.c
-@@ -94,6 +94,7 @@ struct weston_desktop_xdg_toplevel_state {
- bool fullscreen;
- bool resizing;
- bool activated;
-+ uint32_t tiled_orientation;
- };
-
- struct weston_desktop_xdg_toplevel_configure {
-@@ -624,6 +625,29 @@ weston_desktop_xdg_toplevel_send_configure(struct weston_desktop_xdg_toplevel *t
- s = wl_array_add(&states, sizeof(uint32_t));
- *s = XDG_TOPLEVEL_STATE_ACTIVATED;
- }
-+ if (toplevel->pending.state.tiled_orientation &
-+ WESTON_TOP_LEVEL_TILED_ORIENTATION_LEFT) {
-+ s = wl_array_add(&states, sizeof(uint32_t));
-+ *s = XDG_TOPLEVEL_STATE_TILED_LEFT;
-+ }
-+
-+ if (toplevel->pending.state.tiled_orientation &
-+ WESTON_TOP_LEVEL_TILED_ORIENTATION_RIGHT) {
-+ s = wl_array_add(&states, sizeof(uint32_t));
-+ *s = XDG_TOPLEVEL_STATE_TILED_RIGHT;
-+ }
-+
-+ if (toplevel->pending.state.tiled_orientation &
-+ WESTON_TOP_LEVEL_TILED_ORIENTATION_TOP) {
-+ s = wl_array_add(&states, sizeof(uint32_t));
-+ *s = XDG_TOPLEVEL_STATE_TILED_TOP;
-+ }
-+
-+ if (toplevel->pending.state.tiled_orientation &
-+ WESTON_TOP_LEVEL_TILED_ORIENTATION_BOTTOM) {
-+ s = wl_array_add(&states, sizeof(uint32_t));
-+ *s = XDG_TOPLEVEL_STATE_TILED_BOTTOM;
-+ }
-
- xdg_toplevel_send_configure(toplevel->resource,
- toplevel->pending.size.width,
-@@ -686,6 +710,16 @@ weston_desktop_xdg_toplevel_set_size(struct weston_desktop_surface *dsurface,
- weston_desktop_xdg_surface_schedule_configure(&toplevel->base);
- }
-
-+static void
-+weston_desktop_xdg_toplevel_set_orientation(struct weston_desktop_surface *surface, void *user_data,
-+ enum weston_top_level_tiled_orientation tiled_orientation)
-+{
-+ struct weston_desktop_xdg_toplevel *toplevel = user_data;
-+
-+ toplevel->pending.state.tiled_orientation = tiled_orientation;
-+ weston_desktop_xdg_surface_schedule_configure(&toplevel->base);
-+}
-+
- static void
- weston_desktop_xdg_toplevel_committed(struct weston_desktop_xdg_toplevel *toplevel,
- int32_t sx, int32_t sy)
-@@ -1096,6 +1130,9 @@ weston_desktop_xdg_toplevel_state_compare(struct weston_desktop_xdg_toplevel *to
- return false;
- if (toplevel->pending.state.resizing != configured.state.resizing)
- return false;
-+ if (toplevel->pending.state.tiled_orientation !=
-+ configured.state.tiled_orientation)
-+ return false;
-
- if (toplevel->pending.size.width == configured.size.width &&
- toplevel->pending.size.height == configured.size.height)
-@@ -1440,6 +1477,7 @@ static const struct weston_desktop_surface_implementation weston_desktop_xdg_sur
- .set_resizing = weston_desktop_xdg_toplevel_set_resizing,
- .set_activated = weston_desktop_xdg_toplevel_set_activated,
- .set_size = weston_desktop_xdg_toplevel_set_size,
-+ .set_orientation = weston_desktop_xdg_toplevel_set_orientation,
-
- .get_maximized = weston_desktop_xdg_toplevel_get_maximized,
- .get_fullscreen = weston_desktop_xdg_toplevel_get_fullscreen,
---
-2.35.1
-
diff --git a/meta-agl-core/recipes-graphics/wayland/weston/0001-simple-touch-Add-maximized-fullscreen-states.patch b/meta-agl-core/recipes-graphics/wayland/weston/0001-simple-touch-Add-maximized-fullscreen-states.patch
deleted file mode 100644
index 5634e8160..000000000
--- a/meta-agl-core/recipes-graphics/wayland/weston/0001-simple-touch-Add-maximized-fullscreen-states.patch
+++ /dev/null
@@ -1,136 +0,0 @@
-From 666300564093838c7d6a723fbce7e3b1a719e873 Mon Sep 17 00:00:00 2001
-From: Marius Vlad <marius.vlad@collabora.com>
-Date: Thu, 22 Dec 2022 18:27:14 +0200
-Subject: [PATCH 1/3] simple-touch: Add maximized/fullscreen states
-
-Helpful to have other states like maximized or fullscreen for
-the simple-touch client.
-
-Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
----
- clients/simple-touch.c | 55 ++++++++++++++++++++++++++++++++++++------
- 1 file changed, 48 insertions(+), 7 deletions(-)
-
-diff --git a/clients/simple-touch.c b/clients/simple-touch.c
-index 6559aa24d..e32013161 100644
---- a/clients/simple-touch.c
-+++ b/clients/simple-touch.c
-@@ -64,9 +64,13 @@ struct touch {
- struct xdg_toplevel *xdg_toplevel;
- struct buffer *buffer;
- int width, height;
-+ int init_width, init_height;
- bool running;
- bool wait_for_configure;
-+ bool needs_buffer_update;
- bool has_argb;
-+ bool maximized;
-+ bool fullscreen;
- };
-
- static struct buffer *
-@@ -111,7 +115,7 @@ create_shm_buffer(struct touch *touch)
- }
-
- static void
--initial_redraw(void *data)
-+redraw(void *data)
- {
- struct touch *touch = data;
- struct buffer *buffer = NULL;
-@@ -119,6 +123,9 @@ initial_redraw(void *data)
- buffer = create_shm_buffer(touch);
- assert(buffer);
-
-+ if (touch->buffer)
-+ free(touch->buffer);
-+
- touch->buffer = buffer;
-
- /* paint the "work-area" */
-@@ -283,9 +290,10 @@ handle_xdg_surface_configure(void *data, struct xdg_surface *surface,
-
- xdg_surface_ack_configure(surface, serial);
-
-- if (touch->wait_for_configure) {
-- initial_redraw(touch);
-+ if (touch->wait_for_configure || touch->needs_buffer_update) {
-+ redraw(touch);
- touch->wait_for_configure = false;
-+ touch->needs_buffer_update = false;
- }
- }
-
-@@ -340,9 +348,40 @@ static const struct wl_registry_listener registry_listener = {
-
- static void
- handle_toplevel_configure(void *data, struct xdg_toplevel *xdg_toplevel,
-- int32_t width, int32_t height,
-- struct wl_array *state)
-+ int32_t width, int32_t height, struct wl_array *states)
- {
-+ struct touch *touch = data;
-+ uint32_t *p;
-+
-+ touch->fullscreen = false;
-+ touch->maximized = false;
-+
-+ wl_array_for_each(p, states) {
-+ uint32_t state = *p;
-+ switch (state) {
-+ case XDG_TOPLEVEL_STATE_FULLSCREEN:
-+ touch->fullscreen = true;
-+ break;
-+ case XDG_TOPLEVEL_STATE_MAXIMIZED:
-+ touch->maximized = true;
-+ break;
-+ }
-+ }
-+
-+ if (width > 0 && height > 0) {
-+ if (!touch->fullscreen && !touch->maximized) {
-+ touch->init_width = width;
-+ touch->init_width = height;
-+ }
-+ touch->width = width;
-+ touch->height = height;
-+ } else if (!touch->fullscreen && !touch->maximized) {
-+ touch->width = touch->init_width;
-+ touch->height = touch->init_height;
-+
-+ }
-+
-+ touch->needs_buffer_update = true;
- }
-
- static void
-@@ -371,6 +410,7 @@ touch_create(int width, int height)
- assert(touch->display);
-
- touch->has_argb = false;
-+ touch->buffer = NULL;
- touch->registry = wl_display_get_registry(touch->display);
- wl_registry_add_listener(touch->registry, &registry_listener, touch);
- wl_display_dispatch(touch->display);
-@@ -386,8 +426,8 @@ touch_create(int width, int height)
- exit(1);
- }
-
-- touch->width = width;
-- touch->height = height;
-+ touch->init_width = width;
-+ touch->init_height = height;
- touch->surface = wl_compositor_create_surface(touch->compositor);
-
- touch->xdg_surface =
-@@ -403,6 +443,7 @@ touch_create(int width, int height)
- xdg_toplevel_set_title(touch->xdg_toplevel, "simple-touch");
- xdg_toplevel_set_app_id(touch->xdg_toplevel, "simple-touch");
- touch->wait_for_configure = true;
-+ touch->needs_buffer_update = false;
- wl_surface_commit(touch->surface);
-
- touch->running = true;
---
-2.35.1
-