summaryrefslogtreecommitdiffstats
path: root/meta-agl-core/recipes-graphics/wayland/weston/0001-simple-touch-Add-maximized-fullscreen-states.patch
blob: 53a620ef77be0618039f64abb59f77f903138e2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
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.

Upstream-Status: Pending

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