[gtk/wip/alexl/broadway7: 13/16] broadway: More multi-display fixes



commit 2c3bc348ec01a9e27db970c000a9b1289f1c02b2
Author: Alexander Larsson <alexl redhat com>
Date:   Fri Mar 29 11:13:24 2019 +0100

    broadway: More multi-display fixes
    
    When doing idle flushing, do so per display rather than a global
    and some find_display hack.

 gdk/broadway/gdkdisplay-broadway.c | 25 ++++++++++++++++++++++++
 gdk/broadway/gdkdisplay-broadway.h |  2 ++
 gdk/broadway/gdkprivate-broadway.h |  2 ++
 gdk/broadway/gdksurface-broadway.c | 39 +-------------------------------------
 4 files changed, 30 insertions(+), 38 deletions(-)
---
diff --git a/gdk/broadway/gdkdisplay-broadway.c b/gdk/broadway/gdkdisplay-broadway.c
index 4cb868c635..e3ba560f88 100644
--- a/gdk/broadway/gdkdisplay-broadway.c
+++ b/gdk/broadway/gdkdisplay-broadway.c
@@ -386,6 +386,31 @@ gdk_broadway_display_ensure_texture (GdkDisplay *display,
   return data->id;
 }
 
+static gboolean
+flush_idle (gpointer data)
+{
+  GdkDisplay *display = data;
+  GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (display);
+
+  broadway_display->idle_flush_id = 0;
+  gdk_display_flush (display);
+
+  return FALSE;
+}
+
+void
+gdk_broadway_display_flush_in_idle (GdkDisplay *display)
+{
+  GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (display);
+
+  if (broadway_display->idle_flush_id == 0)
+    {
+      broadway_display->idle_flush_id = g_idle_add (flush_idle, g_object_ref (display));
+      g_source_set_name_by_id (broadway_display->idle_flush_id, "[gtk] flush_idle");
+    }
+}
+
+
 static void
 gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
 {
diff --git a/gdk/broadway/gdkdisplay-broadway.h b/gdk/broadway/gdkdisplay-broadway.h
index e028381c54..a8d6819c82 100644
--- a/gdk/broadway/gdkdisplay-broadway.h
+++ b/gdk/broadway/gdkdisplay-broadway.h
@@ -56,6 +56,8 @@ struct _GdkBroadwayDisplay
   GdkMonitor *monitor;
 
   GHashTable *texture_cache;
+
+  guint idle_flush_id;
 };
 
 struct _GdkBroadwayDisplayClass
diff --git a/gdk/broadway/gdkprivate-broadway.h b/gdk/broadway/gdkprivate-broadway.h
index ec6393606b..6f9e126dff 100644
--- a/gdk/broadway/gdkprivate-broadway.h
+++ b/gdk/broadway/gdkprivate-broadway.h
@@ -41,6 +41,8 @@
 guint32 gdk_broadway_display_ensure_texture (GdkDisplay *display,
                                              GdkTexture *texture);
 
+void gdk_broadway_display_flush_in_idle (GdkDisplay *display);
+
 void gdk_broadway_surface_set_nodes (GdkSurface *surface,
                                      GArray *nodes,
                                      GPtrArray *node_textures);
diff --git a/gdk/broadway/gdksurface-broadway.c b/gdk/broadway/gdksurface-broadway.c
index f5a11a3167..580f1fecf3 100644
--- a/gdk/broadway/gdksurface-broadway.c
+++ b/gdk/broadway/gdksurface-broadway.c
@@ -73,39 +73,6 @@ G_DEFINE_TYPE (GdkSurfaceImplBroadway,
                gdk_surface_impl_broadway,
                GDK_TYPE_SURFACE_IMPL)
 
-static GdkDisplay *
-find_broadway_display (void)
-{
-  GdkDisplay *display;
-  GSList *list, *l;
-
-  display = NULL;
-
-  list = gdk_display_manager_list_displays (gdk_display_manager_get ());
-  for (l = list; l; l = l->next)
-    {
-      if (GDK_IS_BROADWAY_DISPLAY (l->data))
-        {
-          display = l->data;
-          break;
-        }
-    }
-  g_slist_free (list);
-
-  return display;
-}
-
-static guint flush_id = 0;
-
-static gboolean
-flush_idle (gpointer data)
-{
-  flush_id = 0;
-
-  gdk_display_flush (find_broadway_display ());
-
-  return FALSE;
-}
 
 /* We need to flush in an idle rather than AFTER_PAINT, as the clock
    is frozen during e.g. surface resizes so the paint will not happen
@@ -113,11 +80,7 @@ flush_idle (gpointer data)
 static void
 queue_flush (GdkSurface *surface)
 {
-  if (flush_id == 0)
-    {
-      flush_id = g_idle_add (flush_idle, NULL);
-      g_source_set_name_by_id (flush_id, "[gtk] flush_idle");
-    }
+  gdk_broadway_display_flush_in_idle (gdk_surface_get_display (surface));
 }
 
 static void


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