meta-agl-core: add Upstream-Status tag to patches
[AGL/meta-agl.git] / meta-agl-core / recipes-graphics / wayland / weston / 0001-simple-touch-Add-maximized-fullscreen-states.patch
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
5
6 Helpful to have other states like maximized or fullscreen for
7 the simple-touch client.
8
9 Upstream-Status: Pending
10
11 Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
12 ---
13  clients/simple-touch.c | 55 ++++++++++++++++++++++++++++++++++++------
14  1 file changed, 48 insertions(+), 7 deletions(-)
15
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;
23         int width, height;
24 +       int init_width, init_height;
25         bool running;
26         bool wait_for_configure;
27 +       bool needs_buffer_update;
28         bool has_argb;
29 +       bool maximized;
30 +       bool fullscreen;
31  };
32  
33  static struct buffer *
34 @@ -111,7 +115,7 @@ create_shm_buffer(struct touch *touch)
35  }
36  
37  static void
38 -initial_redraw(void *data)
39 +redraw(void *data)
40  {
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);
45         assert(buffer);
46  
47 +       if (touch->buffer)
48 +               free(touch->buffer);
49 +
50         touch->buffer = buffer;
51  
52         /* paint the "work-area" */
53 @@ -283,9 +290,10 @@ handle_xdg_surface_configure(void *data, struct xdg_surface *surface,
54  
55         xdg_surface_ack_configure(surface, serial);
56  
57 -       if (touch->wait_for_configure) {
58 -               initial_redraw(touch);
59 +       if (touch->wait_for_configure || touch->needs_buffer_update) {
60 +               redraw(touch);
61                 touch->wait_for_configure = false;
62 +               touch->needs_buffer_update = false;
63         }
64  }
65  
66 @@ -340,9 +348,40 @@ static const struct wl_registry_listener registry_listener = {
67  
68  static void
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)
73  {
74 +       struct touch *touch = data;
75 +       uint32_t *p;
76 +
77 +       touch->fullscreen = false;
78 +       touch->maximized = false;
79 +
80 +       wl_array_for_each(p, states) {
81 +               uint32_t state = *p;
82 +               switch (state) {
83 +               case XDG_TOPLEVEL_STATE_FULLSCREEN:
84 +                       touch->fullscreen = true;
85 +                       break;
86 +               case XDG_TOPLEVEL_STATE_MAXIMIZED:
87 +                       touch->maximized = true;
88 +                       break;
89 +               }
90 +       }
91 +
92 +       if (width > 0 && height > 0) {
93 +               if (!touch->fullscreen && !touch->maximized) {
94 +                       touch->init_width = width;
95 +                       touch->init_width = height;
96 +               }
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;
102 +
103 +       }
104 +
105 +       touch->needs_buffer_update = true;
106  }
107  
108  static void
109 @@ -371,6 +410,7 @@ touch_create(int width, int height)
110         assert(touch->display);
111  
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, &registry_listener, touch);
116         wl_display_dispatch(touch->display);
117 @@ -386,8 +426,8 @@ touch_create(int width, int height)
118                 exit(1);
119         }
120  
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);
126  
127         touch->xdg_surface =
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);
134  
135         touch->running = true;
136 -- 
137 2.35.1
138