Kristian Høgsberg | 3018b44 | 2012-04-27 15:02:56 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2012 Intel Corporation |
Pekka Paalanen | d1c426e | 2013-02-08 17:01:27 +0200 | [diff] [blame] | 3 | * Copyright © 2013 Collabora, Ltd. |
Kristian Høgsberg | 3018b44 | 2012-04-27 15:02:56 -0400 | [diff] [blame] | 4 | * |
Bryce Harrington | 2cc9297 | 2015-06-11 15:39:40 -0700 | [diff] [blame] | 5 | * Permission is hereby granted, free of charge, to any person obtaining |
| 6 | * a copy of this software and associated documentation files (the |
| 7 | * "Software"), to deal in the Software without restriction, including |
| 8 | * without limitation the rights to use, copy, modify, merge, publish, |
| 9 | * distribute, sublicense, and/or sell copies of the Software, and to |
| 10 | * permit persons to whom the Software is furnished to do so, subject to |
| 11 | * the following conditions: |
Kristian Høgsberg | 3018b44 | 2012-04-27 15:02:56 -0400 | [diff] [blame] | 12 | * |
Bryce Harrington | 2cc9297 | 2015-06-11 15:39:40 -0700 | [diff] [blame] | 13 | * The above copyright notice and this permission notice (including the |
| 14 | * next paragraph) shall be included in all copies or substantial |
| 15 | * portions of the Software. |
| 16 | * |
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 24 | * SOFTWARE. |
Kristian Høgsberg | 3018b44 | 2012-04-27 15:02:56 -0400 | [diff] [blame] | 25 | */ |
| 26 | |
Bryce Harrington | 12cc405 | 2014-11-19 17:18:33 -0800 | [diff] [blame] | 27 | #include "config.h" |
| 28 | |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 29 | #include "weston-test-client-helper.h" |
U. Artie Eoff | 1ae298f | 2012-09-28 06:39:30 -0700 | [diff] [blame] | 30 | |
| 31 | static void |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 32 | check_pointer(struct client *client, int x, int y) |
U. Artie Eoff | 1ae298f | 2012-09-28 06:39:30 -0700 | [diff] [blame] | 33 | { |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 34 | int sx, sy; |
U. Artie Eoff | 1ae298f | 2012-09-28 06:39:30 -0700 | [diff] [blame] | 35 | |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 36 | /* check that the client got the global pointer update */ |
| 37 | assert(client->test->pointer_x == x); |
| 38 | assert(client->test->pointer_y == y); |
U. Artie Eoff | 1ae298f | 2012-09-28 06:39:30 -0700 | [diff] [blame] | 39 | |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 40 | /* Does global pointer map onto the surface? */ |
| 41 | if (surface_contains(client->surface, x, y)) { |
| 42 | /* check that the surface has the pointer focus */ |
| 43 | assert(client->input->pointer->focus == client->surface); |
| 44 | |
| 45 | /* |
| 46 | * check that the local surface pointer maps |
| 47 | * to the global pointer. |
| 48 | */ |
| 49 | sx = client->input->pointer->x + client->surface->x; |
| 50 | sy = client->input->pointer->y + client->surface->y; |
| 51 | assert(sx == x); |
| 52 | assert(sy == y); |
| 53 | } else { |
| 54 | /* |
| 55 | * The global pointer does not map onto surface. So |
| 56 | * check that it doesn't have the pointer focus. |
| 57 | */ |
| 58 | assert(client->input->pointer->focus == NULL); |
U. Artie Eoff | 1ae298f | 2012-09-28 06:39:30 -0700 | [diff] [blame] | 59 | } |
| 60 | } |
| 61 | |
| 62 | static void |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 63 | check_pointer_move(struct client *client, int x, int y) |
U. Artie Eoff | 1ae298f | 2012-09-28 06:39:30 -0700 | [diff] [blame] | 64 | { |
Derek Foreman | f6a6592 | 2015-02-24 09:32:14 -0600 | [diff] [blame] | 65 | weston_test_move_pointer(client->test->weston_test, x, y); |
Pekka Paalanen | f2aa64f | 2012-12-12 14:26:41 +0200 | [diff] [blame] | 66 | client_roundtrip(client); |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 67 | check_pointer(client, x, y); |
| 68 | } |
U. Artie Eoff | 1ae298f | 2012-09-28 06:39:30 -0700 | [diff] [blame] | 69 | |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 70 | TEST(test_pointer_top_left) |
| 71 | { |
| 72 | struct client *client; |
| 73 | int x, y; |
U. Artie Eoff | 1ae298f | 2012-09-28 06:39:30 -0700 | [diff] [blame] | 74 | |
Pekka Paalanen | 4ac06ff | 2015-03-26 12:56:10 +0200 | [diff] [blame] | 75 | client = create_client_and_test_surface(46, 76, 111, 134); |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 76 | assert(client); |
| 77 | |
| 78 | /* move pointer outside top left */ |
| 79 | x = client->surface->x - 1; |
| 80 | y = client->surface->y - 1; |
| 81 | assert(!surface_contains(client->surface, x, y)); |
| 82 | check_pointer_move(client, x, y); |
| 83 | |
| 84 | /* move pointer on top left */ |
| 85 | x += 1; y += 1; |
| 86 | assert(surface_contains(client->surface, x, y)); |
| 87 | check_pointer_move(client, x, y); |
| 88 | |
| 89 | /* move pointer outside top left */ |
| 90 | x -= 1; y -= 1; |
| 91 | assert(!surface_contains(client->surface, x, y)); |
| 92 | check_pointer_move(client, x, y); |
| 93 | } |
| 94 | |
| 95 | TEST(test_pointer_bottom_left) |
| 96 | { |
| 97 | struct client *client; |
| 98 | int x, y; |
| 99 | |
Pekka Paalanen | 4ac06ff | 2015-03-26 12:56:10 +0200 | [diff] [blame] | 100 | client = create_client_and_test_surface(99, 100, 100, 98); |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 101 | assert(client); |
| 102 | |
| 103 | /* move pointer outside bottom left */ |
| 104 | x = client->surface->x - 1; |
| 105 | y = client->surface->y + client->surface->height; |
| 106 | assert(!surface_contains(client->surface, x, y)); |
| 107 | check_pointer_move(client, x, y); |
| 108 | |
| 109 | /* move pointer on bottom left */ |
| 110 | x += 1; y -= 1; |
| 111 | assert(surface_contains(client->surface, x, y)); |
| 112 | check_pointer_move(client, x, y); |
| 113 | |
| 114 | /* move pointer outside bottom left */ |
| 115 | x -= 1; y += 1; |
| 116 | assert(!surface_contains(client->surface, x, y)); |
| 117 | check_pointer_move(client, x, y); |
| 118 | } |
| 119 | |
| 120 | TEST(test_pointer_top_right) |
| 121 | { |
| 122 | struct client *client; |
| 123 | int x, y; |
| 124 | |
Pekka Paalanen | 4ac06ff | 2015-03-26 12:56:10 +0200 | [diff] [blame] | 125 | client = create_client_and_test_surface(48, 100, 67, 100); |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 126 | assert(client); |
| 127 | |
| 128 | /* move pointer outside top right */ |
| 129 | x = client->surface->x + client->surface->width; |
| 130 | y = client->surface->y - 1; |
| 131 | assert(!surface_contains(client->surface, x, y)); |
| 132 | check_pointer_move(client, x, y); |
| 133 | |
| 134 | /* move pointer on top right */ |
| 135 | x -= 1; y += 1; |
| 136 | assert(surface_contains(client->surface, x, y)); |
| 137 | check_pointer_move(client, x, y); |
| 138 | |
| 139 | /* move pointer outside top right */ |
| 140 | x += 1; y -= 1; |
| 141 | assert(!surface_contains(client->surface, x, y)); |
| 142 | check_pointer_move(client, x, y); |
| 143 | } |
| 144 | |
| 145 | TEST(test_pointer_bottom_right) |
| 146 | { |
| 147 | struct client *client; |
| 148 | int x, y; |
| 149 | |
Pekka Paalanen | 4ac06ff | 2015-03-26 12:56:10 +0200 | [diff] [blame] | 150 | client = create_client_and_test_surface(100, 123, 100, 69); |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 151 | assert(client); |
| 152 | |
| 153 | /* move pointer outside bottom right */ |
| 154 | x = client->surface->x + client->surface->width; |
| 155 | y = client->surface->y + client->surface->height; |
| 156 | assert(!surface_contains(client->surface, x, y)); |
| 157 | check_pointer_move(client, x, y); |
| 158 | |
| 159 | /* move pointer on bottom right */ |
| 160 | x -= 1; y -= 1; |
| 161 | assert(surface_contains(client->surface, x, y)); |
| 162 | check_pointer_move(client, x, y); |
| 163 | |
| 164 | /* move pointer outside bottom right */ |
| 165 | x += 1; y += 1; |
| 166 | assert(!surface_contains(client->surface, x, y)); |
| 167 | check_pointer_move(client, x, y); |
| 168 | } |
| 169 | |
| 170 | TEST(test_pointer_top_center) |
| 171 | { |
| 172 | struct client *client; |
| 173 | int x, y; |
| 174 | |
Pekka Paalanen | 4ac06ff | 2015-03-26 12:56:10 +0200 | [diff] [blame] | 175 | client = create_client_and_test_surface(100, 201, 100, 50); |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 176 | assert(client); |
| 177 | |
| 178 | /* move pointer outside top center */ |
| 179 | x = client->surface->x + client->surface->width/2; |
| 180 | y = client->surface->y - 1; |
| 181 | assert(!surface_contains(client->surface, x, y)); |
| 182 | check_pointer_move(client, x, y); |
| 183 | |
| 184 | /* move pointer on top center */ |
| 185 | y += 1; |
| 186 | assert(surface_contains(client->surface, x, y)); |
| 187 | check_pointer_move(client, x, y); |
| 188 | |
| 189 | /* move pointer outside top center */ |
| 190 | y -= 1; |
| 191 | assert(!surface_contains(client->surface, x, y)); |
| 192 | check_pointer_move(client, x, y); |
| 193 | } |
| 194 | |
| 195 | TEST(test_pointer_bottom_center) |
| 196 | { |
| 197 | struct client *client; |
| 198 | int x, y; |
| 199 | |
Pekka Paalanen | 4ac06ff | 2015-03-26 12:56:10 +0200 | [diff] [blame] | 200 | client = create_client_and_test_surface(100, 45, 67, 100); |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 201 | assert(client); |
| 202 | |
| 203 | /* move pointer outside bottom center */ |
| 204 | x = client->surface->x + client->surface->width/2; |
| 205 | y = client->surface->y + client->surface->height; |
| 206 | assert(!surface_contains(client->surface, x, y)); |
| 207 | check_pointer_move(client, x, y); |
| 208 | |
| 209 | /* move pointer on bottom center */ |
| 210 | y -= 1; |
| 211 | assert(surface_contains(client->surface, x, y)); |
| 212 | check_pointer_move(client, x, y); |
| 213 | |
| 214 | /* move pointer outside bottom center */ |
| 215 | y += 1; |
| 216 | assert(!surface_contains(client->surface, x, y)); |
| 217 | check_pointer_move(client, x, y); |
| 218 | } |
| 219 | |
| 220 | TEST(test_pointer_left_center) |
| 221 | { |
| 222 | struct client *client; |
| 223 | int x, y; |
| 224 | |
Pekka Paalanen | 4ac06ff | 2015-03-26 12:56:10 +0200 | [diff] [blame] | 225 | client = create_client_and_test_surface(167, 45, 78, 100); |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 226 | assert(client); |
| 227 | |
| 228 | /* move pointer outside left center */ |
| 229 | x = client->surface->x - 1; |
| 230 | y = client->surface->y + client->surface->height/2; |
| 231 | assert(!surface_contains(client->surface, x, y)); |
| 232 | check_pointer_move(client, x, y); |
| 233 | |
| 234 | /* move pointer on left center */ |
| 235 | x += 1; |
| 236 | assert(surface_contains(client->surface, x, y)); |
| 237 | check_pointer_move(client, x, y); |
| 238 | |
| 239 | /* move pointer outside left center */ |
| 240 | x -= 1; |
| 241 | assert(!surface_contains(client->surface, x, y)); |
| 242 | check_pointer_move(client, x, y); |
| 243 | } |
| 244 | |
| 245 | TEST(test_pointer_right_center) |
| 246 | { |
| 247 | struct client *client; |
| 248 | int x, y; |
| 249 | |
Pekka Paalanen | 4ac06ff | 2015-03-26 12:56:10 +0200 | [diff] [blame] | 250 | client = create_client_and_test_surface(110, 37, 100, 46); |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 251 | assert(client); |
| 252 | |
| 253 | /* move pointer outside right center */ |
| 254 | x = client->surface->x + client->surface->width; |
| 255 | y = client->surface->y + client->surface->height/2; |
| 256 | assert(!surface_contains(client->surface, x, y)); |
| 257 | check_pointer_move(client, x, y); |
| 258 | |
| 259 | /* move pointer on right center */ |
| 260 | x -= 1; |
| 261 | assert(surface_contains(client->surface, x, y)); |
| 262 | check_pointer_move(client, x, y); |
| 263 | |
| 264 | /* move pointer outside right center */ |
| 265 | x += 1; |
| 266 | assert(!surface_contains(client->surface, x, y)); |
| 267 | check_pointer_move(client, x, y); |
| 268 | } |
| 269 | |
| 270 | TEST(test_pointer_surface_move) |
| 271 | { |
| 272 | struct client *client; |
| 273 | |
Pekka Paalanen | 4ac06ff | 2015-03-26 12:56:10 +0200 | [diff] [blame] | 274 | client = create_client_and_test_surface(100, 100, 100, 100); |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 275 | assert(client); |
| 276 | |
| 277 | /* move pointer outside of client */ |
| 278 | assert(!surface_contains(client->surface, 50, 50)); |
| 279 | check_pointer_move(client, 50, 50); |
| 280 | |
| 281 | /* move client center to pointer */ |
| 282 | move_client(client, 0, 0); |
| 283 | assert(surface_contains(client->surface, 50, 50)); |
| 284 | check_pointer(client, 50, 50); |
U. Artie Eoff | 1ae298f | 2012-09-28 06:39:30 -0700 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | static int |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 288 | output_contains_client(struct client *client) |
U. Artie Eoff | 1ae298f | 2012-09-28 06:39:30 -0700 | [diff] [blame] | 289 | { |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 290 | struct output *output = client->output; |
| 291 | struct surface *surface = client->surface; |
| 292 | |
| 293 | return !(output->x >= surface->x + surface->width |
| 294 | || output->x + output->width <= surface->x |
| 295 | || output->y >= surface->y + surface->height |
| 296 | || output->y + output->height <= surface->y); |
U. Artie Eoff | 1ae298f | 2012-09-28 06:39:30 -0700 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | static void |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 300 | check_client_move(struct client *client, int x, int y) |
U. Artie Eoff | 1ae298f | 2012-09-28 06:39:30 -0700 | [diff] [blame] | 301 | { |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 302 | move_client(client, x, y); |
| 303 | |
| 304 | if (output_contains_client(client)) { |
| 305 | assert(client->surface->output == client->output); |
U. Artie Eoff | 1ae298f | 2012-09-28 06:39:30 -0700 | [diff] [blame] | 306 | } else { |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 307 | assert(client->surface->output == NULL); |
U. Artie Eoff | 1ae298f | 2012-09-28 06:39:30 -0700 | [diff] [blame] | 308 | } |
| 309 | } |
| 310 | |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 311 | TEST(test_surface_output) |
U. Artie Eoff | 1ae298f | 2012-09-28 06:39:30 -0700 | [diff] [blame] | 312 | { |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 313 | struct client *client; |
| 314 | int x, y; |
U. Artie Eoff | 1ae298f | 2012-09-28 06:39:30 -0700 | [diff] [blame] | 315 | |
Pekka Paalanen | 4ac06ff | 2015-03-26 12:56:10 +0200 | [diff] [blame] | 316 | client = create_client_and_test_surface(100, 100, 100, 100); |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 317 | assert(client); |
U. Artie Eoff | 1ae298f | 2012-09-28 06:39:30 -0700 | [diff] [blame] | 318 | |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 319 | assert(output_contains_client(client)); |
U. Artie Eoff | 1ae298f | 2012-09-28 06:39:30 -0700 | [diff] [blame] | 320 | |
| 321 | /* not visible */ |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 322 | x = 0; |
| 323 | y = -client->surface->height; |
| 324 | check_client_move(client, x, y); |
| 325 | |
U. Artie Eoff | 1ae298f | 2012-09-28 06:39:30 -0700 | [diff] [blame] | 326 | /* visible */ |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 327 | check_client_move(client, x, ++y); |
| 328 | |
U. Artie Eoff | 1ae298f | 2012-09-28 06:39:30 -0700 | [diff] [blame] | 329 | /* not visible */ |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 330 | x = -client->surface->width; |
| 331 | y = 0; |
| 332 | check_client_move(client, x, y); |
| 333 | |
U. Artie Eoff | 1ae298f | 2012-09-28 06:39:30 -0700 | [diff] [blame] | 334 | /* visible */ |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 335 | check_client_move(client, ++x, y); |
| 336 | |
U. Artie Eoff | 1ae298f | 2012-09-28 06:39:30 -0700 | [diff] [blame] | 337 | /* not visible */ |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 338 | x = client->output->width; |
| 339 | y = 0; |
| 340 | check_client_move(client, x, y); |
| 341 | |
U. Artie Eoff | 1ae298f | 2012-09-28 06:39:30 -0700 | [diff] [blame] | 342 | /* visible */ |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 343 | check_client_move(client, --x, y); |
| 344 | assert(output_contains_client(client)); |
| 345 | |
U. Artie Eoff | 1ae298f | 2012-09-28 06:39:30 -0700 | [diff] [blame] | 346 | /* not visible */ |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 347 | x = 0; |
| 348 | y = client->output->height; |
| 349 | check_client_move(client, x, y); |
| 350 | assert(!output_contains_client(client)); |
| 351 | |
U. Artie Eoff | 1ae298f | 2012-09-28 06:39:30 -0700 | [diff] [blame] | 352 | /* visible */ |
U. Artie Eoff | 84f9db5 | 2012-12-07 13:50:33 -0800 | [diff] [blame] | 353 | check_client_move(client, x, --y); |
| 354 | assert(output_contains_client(client)); |
Kristian Høgsberg | 3018b44 | 2012-04-27 15:02:56 -0400 | [diff] [blame] | 355 | } |
Pekka Paalanen | d1c426e | 2013-02-08 17:01:27 +0200 | [diff] [blame] | 356 | |
| 357 | static void |
| 358 | buffer_release_handler(void *data, struct wl_buffer *buffer) |
| 359 | { |
| 360 | int *released = data; |
| 361 | |
| 362 | *released = 1; |
| 363 | } |
| 364 | |
| 365 | static struct wl_buffer_listener buffer_listener = { |
| 366 | buffer_release_handler |
| 367 | }; |
| 368 | |
| 369 | TEST(buffer_release) |
| 370 | { |
| 371 | struct client *client; |
| 372 | struct wl_surface *surface; |
Pekka Paalanen | 7789acd | 2016-05-20 18:01:05 +0300 | [diff] [blame^] | 373 | struct buffer *buf1; |
| 374 | struct buffer *buf2; |
| 375 | struct buffer *buf3; |
Pekka Paalanen | d1c426e | 2013-02-08 17:01:27 +0200 | [diff] [blame] | 376 | int buf1_released = 0; |
| 377 | int buf2_released = 0; |
| 378 | int buf3_released = 0; |
| 379 | int frame; |
| 380 | |
Pekka Paalanen | 4ac06ff | 2015-03-26 12:56:10 +0200 | [diff] [blame] | 381 | client = create_client_and_test_surface(100, 100, 100, 100); |
Pekka Paalanen | d1c426e | 2013-02-08 17:01:27 +0200 | [diff] [blame] | 382 | assert(client); |
| 383 | surface = client->surface->wl_surface; |
| 384 | |
Pekka Paalanen | 7789acd | 2016-05-20 18:01:05 +0300 | [diff] [blame^] | 385 | buf1 = create_shm_buffer_a8r8g8b8(client, 100, 100); |
| 386 | wl_buffer_add_listener(buf1->proxy, &buffer_listener, &buf1_released); |
Pekka Paalanen | d1c426e | 2013-02-08 17:01:27 +0200 | [diff] [blame] | 387 | |
Pekka Paalanen | 7789acd | 2016-05-20 18:01:05 +0300 | [diff] [blame^] | 388 | buf2 = create_shm_buffer_a8r8g8b8(client, 100, 100); |
| 389 | wl_buffer_add_listener(buf2->proxy, &buffer_listener, &buf2_released); |
Pekka Paalanen | d1c426e | 2013-02-08 17:01:27 +0200 | [diff] [blame] | 390 | |
Pekka Paalanen | 7789acd | 2016-05-20 18:01:05 +0300 | [diff] [blame^] | 391 | buf3 = create_shm_buffer_a8r8g8b8(client, 100, 100); |
| 392 | wl_buffer_add_listener(buf3->proxy, &buffer_listener, &buf3_released); |
Pekka Paalanen | d1c426e | 2013-02-08 17:01:27 +0200 | [diff] [blame] | 393 | |
| 394 | /* |
| 395 | * buf1 must never be released, since it is replaced before |
| 396 | * it is committed, therefore it never becomes busy. |
| 397 | */ |
| 398 | |
Pekka Paalanen | 7789acd | 2016-05-20 18:01:05 +0300 | [diff] [blame^] | 399 | wl_surface_attach(surface, buf1->proxy, 0, 0); |
| 400 | wl_surface_attach(surface, buf2->proxy, 0, 0); |
Pekka Paalanen | d1c426e | 2013-02-08 17:01:27 +0200 | [diff] [blame] | 401 | frame_callback_set(surface, &frame); |
| 402 | wl_surface_commit(surface); |
| 403 | frame_callback_wait(client, &frame); |
| 404 | assert(buf1_released == 0); |
| 405 | /* buf2 may or may not be released */ |
| 406 | assert(buf3_released == 0); |
| 407 | |
Pekka Paalanen | 7789acd | 2016-05-20 18:01:05 +0300 | [diff] [blame^] | 408 | wl_surface_attach(surface, buf3->proxy, 0, 0); |
Pekka Paalanen | d1c426e | 2013-02-08 17:01:27 +0200 | [diff] [blame] | 409 | frame_callback_set(surface, &frame); |
| 410 | wl_surface_commit(surface); |
| 411 | frame_callback_wait(client, &frame); |
| 412 | assert(buf1_released == 0); |
| 413 | assert(buf2_released == 1); |
| 414 | /* buf3 may or may not be released */ |
| 415 | |
Pekka Paalanen | 924cd94 | 2016-05-20 17:25:38 +0300 | [diff] [blame] | 416 | wl_surface_attach(surface, client->surface->buffer->proxy, 0, 0); |
Pekka Paalanen | d1c426e | 2013-02-08 17:01:27 +0200 | [diff] [blame] | 417 | frame_callback_set(surface, &frame); |
| 418 | wl_surface_commit(surface); |
| 419 | frame_callback_wait(client, &frame); |
| 420 | assert(buf1_released == 0); |
| 421 | assert(buf2_released == 1); |
| 422 | assert(buf3_released == 1); |
| 423 | } |