Add GDK_DEBUG=no-portals
authorMatthias Clasen <mclasen@redhat.com>
Wed, 14 Dec 2022 18:49:30 +0000 (13:49 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 14 Dec 2022 18:50:20 +0000 (13:50 -0500)
Fixes: #5441
gdk/gdk.c
gdk/gdkdebugprivate.h
gtk/gtkfiledialog.c

index 25e2d9af635e8d3571e8722b69932c64416278c2..3d1457e07568183e09840548c518e5522be89b60 100644 (file)
--- a/gdk/gdk.c
+++ b/gdk/gdk.c
@@ -118,7 +118,8 @@ static const GdkDebugKey gdk_debug_keys[] = {
   { "selection",       GDK_DEBUG_SELECTION, "Information about selections" },
   { "clipboard",       GDK_DEBUG_CLIPBOARD, "Information about clipboards" },
   { "nograbs",         GDK_DEBUG_NOGRABS, "Disable pointer and keyboard grabs (X11)", TRUE },
-  { "portals",         GDK_DEBUG_PORTALS, "Force the use of portals", TRUE },
+  { "portals",         GDK_DEBUG_PORTALS, "Force use of portals", TRUE },
+  { "no-portals",      GDK_DEBUG_NO_PORTALS, "Disable use of portals", TRUE },
   { "gl-disable",      GDK_DEBUG_GL_DISABLE, "Disable OpenGL support", TRUE },
   { "gl-debug",        GDK_DEBUG_GL_DEBUG, "Insert debugging information in OpenGL", TRUE },
   { "gl-legacy",       GDK_DEBUG_GL_LEGACY, "Use a legacy OpenGL context", TRUE },
@@ -359,6 +360,9 @@ gdk_should_use_portal (void)
   if (gdk_display_get_debug_flags (NULL) & GDK_DEBUG_PORTALS)
     return TRUE;
 
+  if (gdk_display_get_debug_flags (NULL) & GDK_DEBUG_NO_PORTALS)
+    return FALSE;
+
   if (gdk_running_in_sandbox ())
     return TRUE;
 
index d778414d584bf4b87601771175503088e89cf14e..c9baba28a78e8caa05708c3070100a7e06f191aa 100644 (file)
@@ -40,7 +40,8 @@ typedef enum {
   /* flags below are influencing behavior */
   GDK_DEBUG_NOGRABS         = 1 << 11,
   GDK_DEBUG_PORTALS         = 1 << 12,
-  GDK_DEBUG_GL_DISABLE      = 1 << 13,
+  GDK_DEBUG_NO_PORTALS      = 1 << 13,
+  GDK_DEBUG_GL_DISABLE      = 1 << 14,
   GDK_DEBUG_GL_LEGACY       = 1 << 16,
   GDK_DEBUG_GL_GLES         = 1 << 17,
   GDK_DEBUG_GL_DEBUG        = 1 << 18,
index d5cf620db5465cc87e282e6952d4ca17282f3b13..0c7a218aa75c0b97b0537ca3ed30ee95e7af7755 100644 (file)
@@ -25,6 +25,7 @@
 #include "gtkfilechoosernativeprivate.h"
 #include "gtkdialogerror.h"
 #include <glib/gi18n-lib.h>
+#include "gdk/gdkdebugprivate.h"
 
 /**
  * GtkFileDialog:
@@ -657,6 +658,7 @@ create_file_chooser (GtkFileDialog        *self,
   GtkFileChooserNative *chooser;
   const char *accept;
   const char *default_title, *title;
+  GdkDisplay *display;
 
   switch (action)
     {
@@ -685,7 +687,16 @@ create_file_chooser (GtkFileDialog        *self,
     title = default_title;
 
   chooser = gtk_file_chooser_native_new (title, parent, action, accept, _("_Cancel"));
-  gtk_file_chooser_native_set_use_portal (chooser, TRUE);
+
+  if (parent)
+    display = gtk_widget_get_display (GTK_WIDGET (parent));
+  else
+    display = gdk_display_get_default ();
+
+  if (GDK_DISPLAY_DEBUG_CHECK (display, NO_PORTALS))
+    gtk_file_chooser_native_set_use_portal (chooser, FALSE);
+  else
+    gtk_file_chooser_native_set_use_portal (chooser, TRUE);
 
   gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (chooser), self->modal);
   gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (chooser), select_multiple);