From fa9cbf6c7df3803211fa054e6ca6cfcf66666aa4 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 19 May 2019 02:53:17 +0000 Subject: [PATCH] x11: Fix handling of frame clock freezes Now that popups share the frame clock of their parent, we have to be much more careful about freezing the clock, since that may stop updates for another surface. This commit makes two changes that make the X11 handling of the frame clock more similar to the Wayland backend: - Use gdk_surface_freeze_updates instead of gdk_surface_freeze_toplevel_updates to avoid affecting the frame clock - Bail out early in before_paint/after_paint if the surface is frozen, to avoid affecting the frame clock Together, these two make the X11 popup surface type work without freezing updates for the toplevel. --- gdk/x11/gdkdisplay-x11.c | 4 ++-- gdk/x11/gdksurface-x11.c | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index 62de7d39e9..60a8892c59 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -878,7 +878,7 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator, } if (toplevel) - gdk_surface_freeze_toplevel_updates (surface); + gdk_surface_freeze_updates (surface); _gdk_x11_surface_grab_check_unmap (surface, xevent->xany.serial); } @@ -901,7 +901,7 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator, 0); if (toplevel) - gdk_surface_thaw_toplevel_updates (surface); + gdk_surface_thaw_updates (surface); } return_val = FALSE; diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c index c4887c0fbc..64a1d11cca 100644 --- a/gdk/x11/gdksurface-x11.c +++ b/gdk/x11/gdksurface-x11.c @@ -745,6 +745,9 @@ static void on_frame_clock_before_paint (GdkFrameClock *clock, GdkSurface *surface) { + if (surface->update_freeze_count > 0) + return; + gdk_x11_surface_predict_presentation_time (surface); gdk_x11_surface_begin_frame (surface, FALSE); } @@ -753,8 +756,10 @@ static void on_frame_clock_after_paint (GdkFrameClock *clock, GdkSurface *surface) { - gdk_x11_surface_end_frame (surface); + if (surface->update_freeze_count > 0) + return; + gdk_x11_surface_end_frame (surface); } static void @@ -909,7 +914,7 @@ _gdk_x11_display_create_surface (GdkDisplay *display, connect_frame_clock (surface); - gdk_surface_freeze_toplevel_updates (surface); + gdk_surface_freeze_updates (surface); if (parent) {