[gtk/mountoperation-trees: 1/3] mountoperation: Survive on Wayland




commit 6a76fe41c6d278c097e40f689b55194e7688d90d
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Oct 4 20:15:43 2022 -0400

    mountoperation: Survive on Wayland
    
    The code was assuming it is dealing with an
    X11 display, and trigger assertions. Fix that
    to make it work at least as well as it does
    on Windows.

 gtk/gtkmountoperation-x11.c | 54 +++++++++++++++++++++++++--------------------
 1 file changed, 30 insertions(+), 24 deletions(-)
---
diff --git a/gtk/gtkmountoperation-x11.c b/gtk/gtkmountoperation-x11.c
index 251263303b..7239de8b7c 100644
--- a/gtk/gtkmountoperation-x11.c
+++ b/gtk/gtkmountoperation-x11.c
@@ -543,32 +543,35 @@ _gtk_mount_operation_lookup_context_get (GdkDisplay *display)
   context->pid_to_window = g_hash_table_new (g_direct_hash, g_direct_equal);
   context->display = display;
 
-  mapping = NULL;
-  mapping_length = 0;
-  get_window_list (context->display,
-                   gdk_x11_display_get_xdisplay (context->display),
-                   gdk_x11_display_get_xrootwindow (context->display),
-                   gdk_x11_get_xatom_by_name_for_display (context->display,
-                                                          "_NET_CLIENT_LIST"),
-                   &mapping,
-                   &mapping_length);
-  for (n = 0; n < mapping_length; n++)
+  if (GDK_IS_X11_DISPLAY (display))
     {
-      int pid;
-
-      if (!get_cardinal (context->display,
-                         GDK_DISPLAY_XDISPLAY (context->display),
-                         mapping[n],
-                         gdk_x11_get_xatom_by_name_for_display (context->display,
-                                                                "_NET_WM_PID"),
-                         &pid))
-        continue;
-
-      g_hash_table_insert (context->pid_to_window,
-                           GINT_TO_POINTER (pid),
-                           GINT_TO_POINTER ((int) mapping[n]));
+      mapping = NULL;
+      mapping_length = 0;
+      get_window_list (context->display,
+                       gdk_x11_display_get_xdisplay (context->display),
+                       gdk_x11_display_get_xrootwindow (context->display),
+                       gdk_x11_get_xatom_by_name_for_display (context->display,
+                                                              "_NET_CLIENT_LIST"),
+                       &mapping,
+                       &mapping_length);
+      for (n = 0; n < mapping_length; n++)
+        {
+          int pid;
+
+          if (!get_cardinal (context->display,
+                             GDK_DISPLAY_XDISPLAY (context->display),
+                             mapping[n],
+                             gdk_x11_get_xatom_by_name_for_display (context->display,
+                                                                    "_NET_WM_PID"),
+                             &pid))
+            continue;
+
+          g_hash_table_insert (context->pid_to_window,
+                               GINT_TO_POINTER (pid),
+                               GINT_TO_POINTER ((int) mapping[n]));
+        }
+      g_free (mapping);
     }
-  g_free (mapping);
 
   return context;
 }
@@ -1001,6 +1004,9 @@ _gtk_mount_operation_lookup_info (GtkMountOperationLookupContext *context,
   g_return_val_if_fail (out_command_line != NULL && *out_command_line == NULL, FALSE);
   g_return_val_if_fail (out_texture != NULL && *out_texture == NULL, FALSE);
 
+  if (!GDK_IS_X11_DISPLAY (context->display))
+    return FALSE;
+
   /* We perform two different lookups for name and icon size.. this is
    * because we want the name from the window with WINDOWID and this
    * normally does not give you an icon


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