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 Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
11 clients/simple-touch.c | 55 ++++++++++++++++++++++++++++++++++++------
12 1 file changed, 48 insertions(+), 7 deletions(-)
14 diff --git a/clients/simple-touch.c b/clients/simple-touch.c
15 index 6559aa24d..e32013161 100644
16 --- a/clients/simple-touch.c
17 +++ b/clients/simple-touch.c
18 @@ -64,9 +64,13 @@ struct touch {
19 struct xdg_toplevel *xdg_toplevel;
20 struct buffer *buffer;
22 + int init_width, init_height;
24 bool wait_for_configure;
25 + bool needs_buffer_update;
31 static struct buffer *
32 @@ -111,7 +115,7 @@ create_shm_buffer(struct touch *touch)
36 -initial_redraw(void *data)
39 struct touch *touch = data;
40 struct buffer *buffer = NULL;
41 @@ -119,6 +123,9 @@ initial_redraw(void *data)
42 buffer = create_shm_buffer(touch);
46 + free(touch->buffer);
48 touch->buffer = buffer;
50 /* paint the "work-area" */
51 @@ -283,9 +290,10 @@ handle_xdg_surface_configure(void *data, struct xdg_surface *surface,
53 xdg_surface_ack_configure(surface, serial);
55 - if (touch->wait_for_configure) {
56 - initial_redraw(touch);
57 + if (touch->wait_for_configure || touch->needs_buffer_update) {
59 touch->wait_for_configure = false;
60 + touch->needs_buffer_update = false;
64 @@ -340,9 +348,40 @@ static const struct wl_registry_listener registry_listener = {
67 handle_toplevel_configure(void *data, struct xdg_toplevel *xdg_toplevel,
68 - int32_t width, int32_t height,
69 - struct wl_array *state)
70 + int32_t width, int32_t height, struct wl_array *states)
72 + struct touch *touch = data;
75 + touch->fullscreen = false;
76 + touch->maximized = false;
78 + wl_array_for_each(p, states) {
79 + uint32_t state = *p;
81 + case XDG_TOPLEVEL_STATE_FULLSCREEN:
82 + touch->fullscreen = true;
84 + case XDG_TOPLEVEL_STATE_MAXIMIZED:
85 + touch->maximized = true;
90 + if (width > 0 && height > 0) {
91 + if (!touch->fullscreen && !touch->maximized) {
92 + touch->init_width = width;
93 + touch->init_width = height;
95 + touch->width = width;
96 + touch->height = height;
97 + } else if (!touch->fullscreen && !touch->maximized) {
98 + touch->width = touch->init_width;
99 + touch->height = touch->init_height;
103 + touch->needs_buffer_update = true;
107 @@ -371,6 +410,7 @@ touch_create(int width, int height)
108 assert(touch->display);
110 touch->has_argb = false;
111 + touch->buffer = NULL;
112 touch->registry = wl_display_get_registry(touch->display);
113 wl_registry_add_listener(touch->registry, ®istry_listener, touch);
114 wl_display_dispatch(touch->display);
115 @@ -386,8 +426,8 @@ touch_create(int width, int height)
119 - touch->width = width;
120 - touch->height = height;
121 + touch->init_width = width;
122 + touch->init_height = height;
123 touch->surface = wl_compositor_create_surface(touch->compositor);
126 @@ -403,6 +443,7 @@ touch_create(int width, int height)
127 xdg_toplevel_set_title(touch->xdg_toplevel, "simple-touch");
128 xdg_toplevel_set_app_id(touch->xdg_toplevel, "simple-touch");
129 touch->wait_for_configure = true;
130 + touch->needs_buffer_update = false;
131 wl_surface_commit(touch->surface);
133 touch->running = true;