[gtk/wip/chergert/quartz4u] macos: only allow a single display connection



commit 2adc0c1f1858d8b24263e4b17ae10758b3e692b1
Author: Christian Hergert <chergert redhat com>
Date:   Wed May 6 11:38:28 2020 -0700

    macos: only allow a single display connection

 gdk/macos/gdkmacosdisplay.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/gdk/macos/gdkmacosdisplay.c b/gdk/macos/gdkmacosdisplay.c
index c3ff6f5d26..401ac6cb90 100644
--- a/gdk/macos/gdkmacosdisplay.c
+++ b/gdk/macos/gdkmacosdisplay.c
@@ -585,9 +585,17 @@ gdk_macos_display_init (GdkMacosDisplay *self)
 GdkDisplay *
 _gdk_macos_display_open (const gchar *display_name)
 {
-  GdkMacosDisplay *self;
+  static GdkMacosDisplay *self;
   ProcessSerialNumber psn = { 0, kCurrentProcess };
 
+  /* Until we can have multiple GdkMacosEventSource instances
+   * running concurrently, we can't exactly support multiple
+   * display connections. So just short-circuit if we already
+   * have one active.
+   */
+  if (self != NULL)
+    return NULL;
+
   GDK_NOTE (MISC, g_message ("opening display %s", display_name ? display_name : ""));
 
   /* Make the current process a foreground application, i.e. an app
@@ -618,6 +626,8 @@ _gdk_macos_display_open (const gchar *display_name)
       g_source_attach (event_source, NULL);
     }
 
+  g_object_add_weak_pointer (G_OBJECT (self), (gpointer *)&self);
+
   gdk_display_emit_opened (GDK_DISPLAY (self));
 
   return GDK_DISPLAY (self);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]