[gtk/wip/chergert/for-4-6: 25/56] macos: check for best_monitor before using
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/for-4-6: 25/56] macos: check for best_monitor before using
- Date: Wed, 16 Mar 2022 19:25:45 +0000 (UTC)
commit 7369ce58da7c5beda6e5f385cf0f7c09a8089b0a
Author: Christian Hergert <christian hergert me>
Date: Mon Feb 28 13:57:29 2022 -0800
macos: check for best_monitor before using
Make sure we have a monitor to enqueue/dequeue from before using it. That
also allows us to use this from destroy and what-not.
gdk/macos/gdkmacossurface.c | 41 +++++++++++++++++------------------------
1 file changed, 17 insertions(+), 24 deletions(-)
---
diff --git a/gdk/macos/gdkmacossurface.c b/gdk/macos/gdkmacossurface.c
index 83860033c1..42ff05385b 100644
--- a/gdk/macos/gdkmacossurface.c
+++ b/gdk/macos/gdkmacossurface.c
@@ -72,9 +72,12 @@ _gdk_macos_surface_request_frame (GdkMacosSurface *self)
if (self->awaiting_frame)
return;
- self->awaiting_frame = TRUE;
- _gdk_macos_monitor_add_frame_callback (GDK_MACOS_MONITOR (self->best_monitor), self);
- gdk_surface_freeze_updates (GDK_SURFACE (self));
+ if (self->best_monitor != NULL)
+ {
+ self->awaiting_frame = TRUE;
+ _gdk_macos_monitor_add_frame_callback (GDK_MACOS_MONITOR (self->best_monitor), self);
+ gdk_surface_freeze_updates (GDK_SURFACE (self));
+ }
}
static void
@@ -85,9 +88,12 @@ _gdk_macos_surface_cancel_frame (GdkMacosSurface *self)
if (!self->awaiting_frame)
return;
- self->awaiting_frame = FALSE;
- _gdk_macos_monitor_remove_frame_callback (GDK_MACOS_MONITOR (self->best_monitor), self);
- gdk_surface_thaw_updates (GDK_SURFACE (self));
+ if (self->best_monitor != NULL)
+ {
+ self->awaiting_frame = FALSE;
+ _gdk_macos_monitor_remove_frame_callback (GDK_MACOS_MONITOR (self->best_monitor), self);
+ gdk_surface_thaw_updates (GDK_SURFACE (self));
+ }
}
void
@@ -199,7 +205,9 @@ gdk_macos_surface_hide (GdkSurface *surface)
self->show_on_next_swap = FALSE;
- was_mapped = GDK_SURFACE_IS_MAPPED (GDK_SURFACE (self));
+ _gdk_macos_surface_cancel_frame (self);
+
+ was_mapped = GDK_SURFACE_IS_MAPPED (surface);
was_key = [self->window isKeyWindow];
seat = gdk_display_get_default_seat (surface->display);
@@ -222,13 +230,6 @@ gdk_macos_surface_hide (GdkSurface *surface)
[parentWindow showAndMakeKey:YES];
}
}
-
- if (self->awaiting_frame)
- {
- self->awaiting_frame = FALSE;
- _gdk_macos_monitor_remove_frame_callback (GDK_MACOS_MONITOR (self->best_monitor), self);
- gdk_surface_freeze_updates (surface);
- }
}
static int
@@ -469,16 +470,8 @@ gdk_macos_surface_destroy (GdkSurface *surface,
GdkMacosWindow *window = g_steal_pointer (&self->window);
GdkFrameClock *frame_clock;
- if (self->best_monitor)
- {
- if (self->awaiting_frame)
- {
- _gdk_macos_monitor_remove_frame_callback (GDK_MACOS_MONITOR (self->best_monitor), self);
- self->awaiting_frame = FALSE;
- }
-
- g_clear_object (&self->best_monitor);
- }
+ _gdk_macos_surface_cancel_frame (self);
+ g_clear_object (&self->best_monitor);
if ((frame_clock = gdk_surface_get_frame_clock (GDK_SURFACE (self))))
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]