From 9a7ad67d65c2bc03d6ae322a95d744579c0d0c4d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 5 Feb 2014 16:53:43 -0800 Subject: [PATCH] window: Delay scheduled redraws if we start maximize or fullscreen protocol When we set the fullscreen flag, we have to wait for the corresponding configure event and then attach a buffer of that size to indicate that we've successfully gone fullscreen/maximized. Without this patch, we can schedule a redraw and go through with it after setting maximize/fullscreen and end up attaching a buffer of the wrong size. In practice, what happens is that pressing the maximize button triggers setting maximized, but also triggers a redraw to paint the maxmize button. Without this change, repainting the button triggers a repaint that attaches the same size buffer immediately. https://bugs.freedesktop.org/show_bug.cgi?id=71927 --- clients/window.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/clients/window.c b/clients/window.c index 9e02b0e..7eb2cdc 100644 --- a/clients/window.c +++ b/clients/window.c @@ -4120,6 +4120,39 @@ window_schedule_redraw(struct window *window) window_schedule_redraw_task(window); } +static void +configure_sync_callback(void *data, + struct wl_callback *callback, uint32_t time) +{ + struct window *window = data; + + DBG("scheduling redraw from maximize sync callback\n"); + + wl_callback_destroy(callback); + + window->redraw_task_scheduled = 0; + window_schedule_redraw_task(window); +} + +static struct wl_callback_listener configure_sync_callback_listener = { + configure_sync_callback, +}; + +static void +window_delay_redraw(struct window *window) +{ + struct wl_callback *callback; + + DBG("delay scheduled redraw for maximize configure\n"); + if (window->redraw_task_scheduled) + wl_list_remove(&window->redraw_task.link); + + window->redraw_task_scheduled = 1; + callback = wl_display_sync(window->display->display); + wl_callback_add_listener(callback, + &configure_sync_callback_listener, window); +} + int window_is_fullscreen(struct window *window) { @@ -4140,6 +4173,8 @@ window_set_fullscreen(struct window *window, int fullscreen) xdg_surface_set_fullscreen(window->xdg_surface); else xdg_surface_unset_fullscreen(window->xdg_surface); + + window_delay_redraw(window); } int @@ -4162,6 +4197,8 @@ window_set_maximized(struct window *window, int maximized) xdg_surface_set_maximized(window->xdg_surface); else xdg_surface_unset_maximized(window->xdg_surface); + + window_delay_redraw(window); } void -- 2.7.4