macos: be more careful about freezing/thawing surfaces

We need to avoid conflating the managing of frame callbacks from
the freeze/thaw mechanics and ensure we don't perform extra thaw
requests at the wrong time.
This commit is contained in:
Christian Hergert 2022-02-01 16:06:08 -08:00
parent 8a4fd3f2af
commit f644925570
3 changed files with 18 additions and 12 deletions

View File

@ -301,10 +301,14 @@ gdk_macos_display_frame_cb (gpointer data)
iter = iter->next;
_gdk_macos_surface_publish_timings (surface,
source->presentation_time,
source->refresh_interval);
_gdk_macos_display_remove_frame_callback (self, surface);
_gdk_macos_surface_thaw (surface,
source->presentation_time,
source->refresh_interval);
if (GDK_SURFACE_IS_MAPPED (GDK_SURFACE (surface)))
gdk_surface_thaw_updates (GDK_SURFACE (surface));
}
return G_SOURCE_CONTINUE;
@ -993,8 +997,6 @@ _gdk_macos_display_add_frame_callback (GdkMacosDisplay *self,
*/
g_queue_push_head_link (&self->awaiting_frames, &surface->frame);
gdk_surface_freeze_updates (GDK_SURFACE (surface));
if (self->awaiting_frames.length == 1)
gdk_display_link_source_unpause ((GdkDisplayLinkSource *)self->frame_source);
}

View File

@ -104,7 +104,7 @@ void _gdk_macos_surface_resize (GdkMacosSurface
void _gdk_macos_surface_update_fullscreen_state (GdkMacosSurface *self);
void _gdk_macos_surface_update_position (GdkMacosSurface *self);
void _gdk_macos_surface_show (GdkMacosSurface *self);
void _gdk_macos_surface_thaw (GdkMacosSurface *self,
void _gdk_macos_surface_publish_timings (GdkMacosSurface *self,
gint64 predicted_presentation_time,
gint64 refresh_interval);
CGContextRef _gdk_macos_surface_acquire_context (GdkMacosSurface *self,

View File

@ -125,6 +125,8 @@ gdk_macos_surface_hide (GdkSurface *surface)
g_assert (GDK_IS_MACOS_SURFACE (self));
_gdk_macos_display_remove_frame_callback (GDK_MACOS_DISPLAY (surface->display), self);
was_mapped = GDK_SURFACE_IS_MAPPED (GDK_SURFACE (self));
seat = gdk_display_get_default_seat (surface->display);
@ -199,7 +201,11 @@ gdk_macos_surface_end_frame (GdkMacosSurface *self)
if ((timings = gdk_frame_clock_get_current_timings (frame_clock)))
self->pending_frame_counter = timings->frame_counter;
_gdk_macos_display_add_frame_callback (GDK_MACOS_DISPLAY (display), self);
if (GDK_SURFACE_IS_MAPPED (GDK_SURFACE (self)))
{
_gdk_macos_display_add_frame_callback (GDK_MACOS_DISPLAY (display), self);
gdk_surface_freeze_updates (GDK_SURFACE (self));
}
}
static void
@ -718,17 +724,15 @@ _gdk_macos_surface_update_position (GdkMacosSurface *self)
}
void
_gdk_macos_surface_thaw (GdkMacosSurface *self,
gint64 presentation_time,
gint64 refresh_interval)
_gdk_macos_surface_publish_timings (GdkMacosSurface *self,
gint64 presentation_time,
gint64 refresh_interval)
{
GdkFrameTimings *timings;
GdkFrameClock *frame_clock;
g_return_if_fail (GDK_IS_MACOS_SURFACE (self));
gdk_surface_thaw_updates (GDK_SURFACE (self));
if (!(frame_clock = gdk_surface_get_frame_clock (GDK_SURFACE (self))))
return;