1 From 666300564093838c7d6a723fbce7e3b1a719e873 Mon Sep 17 00:00:00 2001
2 From: Marius Vlad <marius.vlad@collabora.com>
3 Date: Thu, 22 Dec 2022 18:27:14 +0200
4 Subject: [PATCH 1/3] simple-touch: Add maximized/fullscreen states
6 Helpful to have other states like maximized or fullscreen for
7 the simple-touch client.
9 Upstream-Status: Pending
11 Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
13 clients/simple-touch.c | 55 ++++++++++++++++++++++++++++++++++++------
14 1 file changed, 48 insertions(+), 7 deletions(-)
16 diff --git a/clients/simple-touch.c b/clients/simple-touch.c
17 index 6559aa24d..e32013161 100644
18 --- a/clients/simple-touch.c
19 +++ b/clients/simple-touch.c
20 @@ -64,9 +64,13 @@ struct touch {
21 struct xdg_toplevel *xdg_toplevel;
22 struct buffer *buffer;
24 + int init_width, init_height;
26 bool wait_for_configure;
27 + bool needs_buffer_update;
33 static struct buffer *
34 @@ -111,7 +115,7 @@ create_shm_buffer(struct touch *touch)
38 -initial_redraw(void *data)
41 struct touch *touch = data;
42 struct buffer *buffer = NULL;
43 @@ -119,6 +123,9 @@ initial_redraw(void *data)
44 buffer = create_shm_buffer(touch);
48 + free(touch->buffer);
50 touch->buffer = buffer;
52 /* paint the "work-area" */
53 @@ -283,9 +290,10 @@ handle_xdg_surface_configure(void *data, struct xdg_surface *surface,
55 xdg_surface_ack_configure(surface, serial);
57 - if (touch->wait_for_configure) {
58 - initial_redraw(touch);
59 + if (touch->wait_for_configure || touch->needs_buffer_update) {
61 touch->wait_for_configure = false;
62 + touch->needs_buffer_update = false;
66 @@ -340,9 +348,40 @@ static const struct wl_registry_listener registry_listener = {
69 handle_toplevel_configure(void *data, struct xdg_toplevel *xdg_toplevel,
70 - int32_t width, int32_t height,
71 - struct wl_array *state)
72 + int32_t width, int32_t height, struct wl_array *states)
74 + struct touch *touch = data;
77 + touch->fullscreen = false;
78 + touch->maximized = false;
80 + wl_array_for_each(p, states) {
81 + uint32_t state = *p;
83 + case XDG_TOPLEVEL_STATE_FULLSCREEN:
84 + touch->fullscreen = true;
86 + case XDG_TOPLEVEL_STATE_MAXIMIZED:
87 + touch->maximized = true;
92 + if (width > 0 && height > 0) {
93 + if (!touch->fullscreen && !touch->maximized) {
94 + touch->init_width = width;
95 + touch->init_width = height;
97 + touch->width = width;
98 + touch->height = height;
99 + } else if (!touch->fullscreen && !touch->maximized) {
100 + touch->width = touch->init_width;
101 + touch->height = touch->init_height;
105 + touch->needs_buffer_update = true;
109 @@ -371,6 +410,7 @@ touch_create(int width, int height)
110 assert(touch->display);
112 touch->has_argb = false;
113 + touch->buffer = NULL;
114 touch->registry = wl_display_get_registry(touch->display);
115 wl_registry_add_listener(touch->registry, ®istry_listener, touch);
116 wl_display_dispatch(touch->display);
117 @@ -386,8 +426,8 @@ touch_create(int width, int height)
121 - touch->width = width;
122 - touch->height = height;
123 + touch->init_width = width;
124 + touch->init_height = height;
125 touch->surface = wl_compositor_create_surface(touch->compositor);
128 @@ -403,6 +443,7 @@ touch_create(int width, int height)
129 xdg_toplevel_set_title(touch->xdg_toplevel, "simple-touch");
130 xdg_toplevel_set_app_id(touch->xdg_toplevel, "simple-touch");
131 touch->wait_for_configure = true;
132 + touch->needs_buffer_update = false;
133 wl_surface_commit(touch->surface);
135 touch->running = true;