diff --git a/gdk/wayland/gdkglcontext-wayland.c b/gdk/wayland/gdkglcontext-wayland.c index 3db9db5ac4..03fcea2843 100644 --- a/gdk/wayland/gdkglcontext-wayland.c +++ b/gdk/wayland/gdkglcontext-wayland.c @@ -224,6 +224,7 @@ gdk_wayland_gl_context_end_frame (GdkDrawContext *draw_context, context_wayland->egl_config); gdk_wayland_surface_sync (surface); + gdk_wayland_surface_request_frame (surface); if (display_wayland->have_egl_swap_buffers_with_damage && damage != NULL) { diff --git a/gdk/wayland/gdkprivate-wayland.h b/gdk/wayland/gdkprivate-wayland.h index 4df2f33ffd..8de1b63831 100644 --- a/gdk/wayland/gdkprivate-wayland.h +++ b/gdk/wayland/gdkprivate-wayland.h @@ -89,6 +89,7 @@ guint _gdk_wayland_cursor_get_next_image_index (GdkWaylandDisplay *display, guint *next_image_delay); void gdk_wayland_surface_sync (GdkSurface *surface); +void gdk_wayland_surface_request_frame (GdkSurface *surface); void _gdk_wayland_surface_register_dnd (GdkSurface *surface); GdkDragContext *_gdk_wayland_surface_drag_begin (GdkSurface *surface, diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c index d771fd1857..cfa8319178 100644 --- a/gdk/wayland/gdksurface-wayland.c +++ b/gdk/wayland/gdksurface-wayland.c @@ -513,12 +513,30 @@ on_frame_clock_before_paint (GdkFrameClock *clock, } } +void +gdk_wayland_surface_request_frame (GdkSurface *surface) +{ + GdkSurfaceImplWayland *impl = GDK_SURFACE_IMPL_WAYLAND (surface->impl); + struct wl_callback *callback; + GdkFrameClock *clock; + + if (impl->awaiting_frame) + return; + + clock = gdk_surface_get_frame_clock (surface); + + callback = wl_surface_frame (impl->display_server.wl_surface); + wl_callback_add_listener (callback, &frame_listener, surface); + _gdk_frame_clock_freeze (clock); + impl->pending_frame_counter = gdk_frame_clock_get_frame_counter (clock); + impl->awaiting_frame = TRUE; +} + static void on_frame_clock_after_paint (GdkFrameClock *clock, GdkSurface *surface) { GdkSurfaceImplWayland *impl = GDK_SURFACE_IMPL_WAYLAND (surface->impl); - struct wl_callback *callback; if (!impl->pending_commit) return; @@ -526,9 +544,7 @@ on_frame_clock_after_paint (GdkFrameClock *clock, if (surface->update_freeze_count > 0) return; - callback = wl_surface_frame (impl->display_server.wl_surface); - wl_callback_add_listener (callback, &frame_listener, surface); - _gdk_frame_clock_freeze (clock); + gdk_wayland_surface_request_frame (surface); /* Before we commit a new buffer, make sure we've backfilled * undrawn parts from any old committed buffer @@ -551,8 +567,6 @@ on_frame_clock_after_paint (GdkFrameClock *clock, impl->pending_buffer_attached = FALSE; impl->pending_commit = FALSE; - impl->pending_frame_counter = gdk_frame_clock_get_frame_counter (clock); - impl->awaiting_frame = TRUE; g_signal_emit (impl, signals[COMMITTED], 0); } diff --git a/gdk/wayland/gdkvulkancontext-wayland.c b/gdk/wayland/gdkvulkancontext-wayland.c index b5e82139f5..714ae6de4b 100644 --- a/gdk/wayland/gdkvulkancontext-wayland.c +++ b/gdk/wayland/gdkvulkancontext-wayland.c @@ -67,6 +67,7 @@ gdk_vulkan_context_wayland_end_frame (GdkDrawContext *context, GdkSurface *surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context)); gdk_wayland_surface_sync (surface); + gdk_wayland_surface_request_frame (surface); GDK_DRAW_CONTEXT_CLASS (gdk_wayland_vulkan_context_parent_class)->end_frame (context, painted, damage); }