Bug 1646499 - Fix GTK_USE_PORTAL env variable evaluation. r=stransky
authorMichael Weghorn <m.weghorn@posteo.de>
Wed, 24 Jun 2020 08:06:00 +0000
changeset 537087 8226410d91fd5707d468c0160bc965adee55e959
parent 537086 b3d9f2fe4edd8788e45393d287bb2fa242dbd0eb
child 537088 1c0f9cde882b0fdad4ce9b466f054c9eb6e381bd
push id119800
push userrmaries@mozilla.com
push dateWed, 24 Jun 2020 09:33:42 +0000
treeherderautoland@8226410d91fd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstransky
bugs1646499, 1517074
milestone79.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1646499 - Fix GTK_USE_PORTAL env variable evaluation. r=stransky While the comment for 'GetFlatpakPortalEnv' said "We use the same code as gtk_should_use_portal() to detect if we're in flatpak env", this was not actually true, since the code only checked whether the environment variable 'GTK_USE_PORTAL' was set at all, ignoring its value, while the gtk implementation checks that it is set and that the first character is '1' (which was already true in the gtk as of the commit that the comment refers to, [1]). Adapt it to check for the actual value here, according to what is also done at [2], so that setting 'GTK_USE_PORTAL=0' or 'GTK_USE_PORTAL=1' in the environment works as expected. I ran into this while looking at why bug 1517074 still occured with the native file chooser presumably having been disabled by starting Firefox using GTK_USE_PORTAL=0 firefox with gtk 3.24.20 that does not yet have the fix for gtk issue [3]. [1] https://github.com/GNOME/gtk/blob/e0ce028c88858b96aeda9e41734a39a3a04f705d/gtk/gtkprivate.c#L272 [2] https://searchfox.org/mozilla-central/rev/37932bfc600f97ec923464086dc12cdaa72aefde/widget/gtk/nsFilePicker.cpp#608 [3] https://gitlab.gnome.org/GNOME/gtk/-/issues/1820 Differential Revision: https://phabricator.services.mozilla.com/D80073
toolkit/system/gnome/nsGIOService.cpp
--- a/toolkit/system/gnome/nsGIOService.cpp
+++ b/toolkit/system/gnome/nsGIOService.cpp
@@ -18,27 +18,27 @@
 #include <gtk/gtk.h>
 #ifdef MOZ_ENABLE_DBUS
 #  include <dbus/dbus-glib.h>
 #  include <dbus/dbus-glib-lowlevel.h>
 #endif
 
 using namespace mozilla;
 
-// We use the same code as gtk_should_use_portal() to detect if we're in flatpak
-// env
+// s. a. the code gtk_should_use_portal() uses to detect if in flatpak env
 // https://github.com/GNOME/gtk/blob/e0ce028c88858b96aeda9e41734a39a3a04f705d/gtk/gtkprivate.c#L272
 static bool GetFlatpakPortalEnv() {
   bool shouldUsePortal;
   char* path;
   path = g_build_filename(g_get_user_runtime_dir(), "flatpak-info", nullptr);
   if (g_file_test(path, G_FILE_TEST_EXISTS)) {
     shouldUsePortal = true;
   } else {
-    shouldUsePortal = (g_getenv("GTK_USE_PORTAL") != nullptr);
+    const char* portalEnvString = g_getenv("GTK_USE_PORTAL");
+    shouldUsePortal = portalEnvString != nullptr && atoi(portalEnvString) != 0;
   }
   g_free(path);
   return shouldUsePortal;
 }
 
 static bool GetShouldUseFlatpakPortal() {
   static bool sFlatpakPortalEnv = GetFlatpakPortalEnv();
   return Preferences::HasUserValue("widget.use-xdg-desktop-portal")