@@ -234,6 +234,10 @@ static void layer_surface_unmap(struct wlr_layer_surface_v1 *surface) {
234
234
}
235
235
236
236
surface -> configured = surface -> mapped = false;
237
+ if (surface -> configure_idle ) {
238
+ wl_event_source_remove (surface -> configure_idle );
239
+ surface -> configure_idle = NULL ;
240
+ }
237
241
}
238
242
239
243
static void layer_surface_destroy (struct wlr_layer_surface_v1 * surface ) {
@@ -256,45 +260,48 @@ static void layer_surface_resource_destroy(struct wl_resource *resource) {
256
260
}
257
261
}
258
262
259
- static bool layer_surface_state_changed ( struct wlr_layer_surface_v1 * surface ) {
260
- struct wlr_layer_surface_v1_configure last_acked ;
261
- struct wlr_layer_surface_v1_configure * configure ;
262
- if ( wl_list_empty ( & surface -> configure_list )) {
263
- last_acked . width = surface -> pending . actual_width ;
264
- last_acked . height = surface -> pending . actual_height ;
265
- configure = & last_acked ;
266
- } else {
267
- configure = wl_container_of ( surface -> configure_list . prev ,
268
- configure , link ) ;
263
+ static void surface_send_configure ( void * data ) {
264
+ struct wlr_layer_surface_v1 * surface = data ;
265
+
266
+ surface -> configure_idle = NULL ;
267
+
268
+ struct wlr_layer_surface_v1_configure * configure =
269
+ calloc ( 1 , sizeof ( * configure )) ;
270
+ if ( configure == NULL ) {
271
+ wl_client_post_no_memory ( wl_resource_get_client ( surface -> resource ));
272
+ return ;
269
273
}
270
274
271
- bool changed = configure -> width != surface -> scheduled .width
272
- || configure -> height != surface -> scheduled .height ;
273
- return changed ;
275
+ wl_list_insert (surface -> configure_list .prev , & configure -> link );
276
+ configure -> serial = surface -> scheduled .serial ;
277
+ configure -> width = surface -> scheduled .width ;
278
+ configure -> height = surface -> scheduled .height ;
279
+
280
+ zwlr_layer_surface_v1_send_configure (surface -> resource ,
281
+ configure -> serial , configure -> width , configure -> height );
282
+ }
283
+
284
+ static uint32_t schedule_configure (struct wlr_layer_surface_v1 * surface ) {
285
+ struct wl_client * client = wl_resource_get_client (surface -> resource );
286
+ struct wl_display * display = wl_client_get_display (client );
287
+ struct wl_event_loop * loop = wl_display_get_event_loop (display );
288
+
289
+ if (surface -> configure_idle == NULL ) {
290
+ surface -> scheduled .serial = wl_display_next_serial (display );
291
+ surface -> configure_idle = wl_event_loop_add_idle (loop ,
292
+ surface_send_configure , surface );
293
+ if (surface -> configure_idle == NULL ) {
294
+ wl_client_post_no_memory (client );
295
+ }
296
+ }
297
+ return surface -> scheduled .serial ;
274
298
}
275
299
276
- void wlr_layer_surface_v1_configure (struct wlr_layer_surface_v1 * surface ,
300
+ uint32_t wlr_layer_surface_v1_set_size (struct wlr_layer_surface_v1 * surface ,
277
301
uint32_t width , uint32_t height ) {
278
302
surface -> scheduled .width = width ;
279
303
surface -> scheduled .height = height ;
280
- if (layer_surface_state_changed (surface )) {
281
- struct wl_display * display =
282
- wl_client_get_display (wl_resource_get_client (surface -> resource ));
283
- struct wlr_layer_surface_v1_configure * configure =
284
- calloc (1 , sizeof (struct wlr_layer_surface_v1_configure ));
285
- if (configure == NULL ) {
286
- wl_client_post_no_memory (wl_resource_get_client (surface -> resource ));
287
- return ;
288
- }
289
- surface -> scheduled .serial = wl_display_next_serial (display );
290
- wl_list_insert (surface -> configure_list .prev , & configure -> link );
291
- configure -> width = width ;
292
- configure -> height = height ;
293
- configure -> serial = surface -> scheduled .serial ;
294
- zwlr_layer_surface_v1_send_configure (surface -> resource ,
295
- configure -> serial , configure -> width ,
296
- configure -> height );
297
- }
304
+ return schedule_configure (surface );
298
305
}
299
306
300
307
void wlr_layer_surface_v1_destroy (struct wlr_layer_surface_v1 * surface ) {
0 commit comments