From cd243d4c858d9193ba0eeab778c488b74505d0e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Thu, 1 Nov 2018 18:24:28 +0100 Subject: [PATCH xserver 5/7] xwayland: Add xwl_present_unrealize_window When a window is unrealized, a pending frame callback may never be called, which could result in repeatedly freezing until the frame timer fires after a second. Fixes these symptoms when switching from fullscreen to windowed mode in sauerbraten. (cherry picked from commit 8c9538573cb9a342897eb3fb4b0c1e4ed917bd0e) --- hw/xwayland/xwayland-present.c | 16 ++++++++++++++++ hw/xwayland/xwayland.c | 5 +++++ hw/xwayland/xwayland.h | 1 + 3 files changed, 22 insertions(+) diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c index e6dca5ed0..7e49cb366 100644 --- a/hw/xwayland/xwayland-present.c +++ b/hw/xwayland/xwayland-present.c @@ -519,6 +519,22 @@ xwl_present_flips_stop(WindowPtr window) xwl_present_reset_timer(xwl_present_window); } +void +xwl_present_unrealize_window(WindowPtr window) +{ + struct xwl_present_window *xwl_present_window = xwl_present_window_priv(window); + + if (!xwl_present_window || !xwl_present_window->frame_callback) + return; + + /* The pending frame callback may never be called, so drop it and shorten + * the frame timer interval. + */ + wl_callback_destroy(xwl_present_window->frame_callback); + xwl_present_window->frame_callback = NULL; + xwl_present_reset_timer(xwl_present_window); +} + static present_wnmd_info_rec xwl_present_info = { .version = PRESENT_SCREEN_INFO_VERSION, .get_crtc = xwl_present_get_crtc, diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c index 988b8e17d..7e6e0ab25 100644 --- a/hw/xwayland/xwayland.c +++ b/hw/xwayland/xwayland.c @@ -609,6 +609,11 @@ xwl_unrealize_window(WindowPtr window) xwl_screen->UnrealizeWindow = screen->UnrealizeWindow; screen->UnrealizeWindow = xwl_unrealize_window; +#ifdef GLAMOR_HAS_GBM + if (xwl_screen->present) + xwl_present_unrealize_window(window); +#endif + xwl_window = xwl_window_get(window); if (!xwl_window) return ret; diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h index a79f836ad..463622669 100644 --- a/hw/xwayland/xwayland.h +++ b/hw/xwayland/xwayland.h @@ -454,6 +454,7 @@ void xwl_glamor_egl_make_current(struct xwl_screen *xwl_screen); #ifdef GLAMOR_HAS_GBM Bool xwl_present_init(ScreenPtr screen); void xwl_present_cleanup(WindowPtr window); +void xwl_present_unrealize_window(WindowPtr window); #endif /* GLAMOR_HAS_GBM */ #ifdef XV -- 2.19.2