[gtk+] Stop using the root window in gdk_window_create_similar_image_surface



commit c08a6a062fdef4ca76f657456363a77e9f1137aa
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Nov 5 19:30:54 2017 -0500

    Stop using the root window in gdk_window_create_similar_image_surface
    
    Just create a plain image surface if we don't get a window.
    This should work just fine and lets us drop another implicit
    use of the root window.

 gdk/gdkwindow.c |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)
---
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 729654d..2687dc0 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -6016,20 +6016,23 @@ gdk_window_create_similar_image_surface (GdkWindow *     window,
                                         int             height,
                                         int             scale)
 {
-  GdkWindowImplClass *impl_class;
-  cairo_surface_t *window_surface, *surface;
+  cairo_surface_t *surface;
 
-  g_return_val_if_fail (window ==NULL || GDK_IS_WINDOW (window), NULL);
+  g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
 
   if (window == NULL)
-    window = gdk_display_get_root_window (gdk_display_get_default ());
-
-  impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl);
-
-  if (impl_class->create_similar_image_surface)
-    surface = impl_class->create_similar_image_surface (window, format, width, height);
+    {
+      surface = cairo_image_surface_create (format, width, height);
+    }
+  else if (GDK_WINDOW_IMPL_GET_CLASS (window->impl)->create_similar_image_surface)
+    {
+      surface =
+        GDK_WINDOW_iMPL_GET_CLASS (window->impl)->create_similar_image_surface (window, format, width, 
height);
+    }
   else
     {
+      cairo_surface_t *window_surface;
+
       window_surface = gdk_window_ref_impl_surface (window);
       surface =
         cairo_surface_create_similar_image (window_surface,


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