Skip to content

Commit

Permalink
Don't try to initialize gtk, use GMainLoop instead.
Browse files Browse the repository at this point in the history
The xdg-desktop-portal process is not exiting when the session
ends (because of linuxmint/cinnamon-session@a5d4be9515 - the
session bus is never killed).

Because its background implementation regularly polls for app
states, it can trigger xdg-desktop-portal-xapp to launch while
no session is running, and no xserver (for that dead session).

This fails because gtk_init() kills our xapp portal process
immediately, and xdg-desktop-portal is stuck waiting on a dbus
response that will never arrive. It eventually times out, and
things generally right themselves.

The Gtk code was added back while refactoring the settings portal.
We've ended up not using any gtk code for now, so this can just
be removed.

If we ever do need to ignore gtk failure in the future (if we
don't fix the cinnamon-session bug), we might use gtk_init_check
instead of gtk_init. This will fail but not terminate the program.

The main issue here is that xdg-desktop-portal isn't terminating,
and/or shouldn't be requesting app states when there's no active
session. This needs to be fixed in cinnamon-session.

Fixes: #20
Fixes: linuxmint/cinnamon#12321
  • Loading branch information
mtwebster committed Aug 2, 2024
1 parent 2d008d2 commit 54fca8b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
1 change: 0 additions & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Maintainer: Linux Mint <[email protected]>
Build-Depends:
debhelper-compat (= 13),
libglib2.0-dev (>= 2.44),
libgtk-3-dev (>= 3.0),

This comment has been minimized.

Copy link
@Fantu

Fantu Aug 10, 2024

@mtwebster libgtk-3-dev is still needed for gdk
Without can't build in clean environment: https://salsa.debian.org/cinnamon-team/xdg-desktop-portal-xapp/-/jobs/6101621

This comment has been minimized.

Copy link
@mtwebster

mtwebster Aug 10, 2024

Author Member

Sorry about that
b364687

meson (>= 0.53.0),
systemd (>= 242),
xdg-desktop-portal-dev (>= 1.7.1),
Expand Down
5 changes: 3 additions & 2 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ built_sources += gnome.gdbus_codegen(
config_entries = {
'GETTEXT_PACKAGE' : '"@0@"'.format(meson.project_name()),
'LOCALEDIR': '"@0@"'.format(prefix / get_option('localedir')),
'PACKAGE_STRING': '"xdg-desktop-portal-xapp @0@"'.format(meson.project_version())
'PACKAGE_STRING': '"xdg-desktop-portal-xapp @0@"'.format(meson.project_version()),
'G_LOG_DOMAIN': '"xdg-desktop-portal-xapp"'

}
config = configuration_data(config_entries)
built_sources += configure_file(output: 'config.h', configuration: config)
Expand All @@ -59,7 +61,6 @@ deps = [
meson.get_compiler('c').find_library('m'),
dependency('glib-2.0', version: '>= 2.44'),
dependency('gio-unix-2.0'),
dependency('gtk+-3.0'),
dependency('gdk-3.0'),
xdg_desktop_portal_dep,
]
Expand Down
2 changes: 0 additions & 2 deletions src/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <glib/gi18n.h>
#include <gio/gio.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>

#include "settings.h"
#include "utils.h"
Expand Down Expand Up @@ -57,7 +56,6 @@ settings_bundle_free (SettingsBundle *bundle)
g_free (bundle);
}

// static GVariant *get_gtk_theme (gpointer data);
static GVariant *get_color_scheme (gpointer data);
static GVariant *get_high_contrast (gpointer data);

Expand Down
8 changes: 4 additions & 4 deletions src/xdg-desktop-portal-xapp.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include <gio/gio.h>
#include <gio/gdesktopappinfo.h>
#include <gio/gunixfdlist.h>
#include <gtk/gtk.h>

#include <glib/gi18n.h>
#include <locale.h>
Expand All @@ -51,6 +50,7 @@
#include "settings.h"
#include "wallpaper.h"

static GMainLoop *loop = NULL;
static GHashTable *outstanding_handles = NULL;

static gboolean opt_verbose;
Expand Down Expand Up @@ -160,7 +160,7 @@ on_name_lost (GDBusConnection *connection,
gpointer user_data)
{
g_debug ("name lost");
gtk_main_quit ();
g_main_loop_quit (loop);
}

int
Expand Down Expand Up @@ -244,7 +244,7 @@ main (int argc, char *argv[])

g_set_prgname ("xdg-desktop-portal-xapp");

gtk_init (NULL, NULL);
loop = g_main_loop_new (NULL, FALSE);

outstanding_handles = g_hash_table_new (g_str_hash, g_str_equal);

Expand All @@ -264,7 +264,7 @@ main (int argc, char *argv[])
NULL,
NULL);

gtk_main ();
g_main_loop_run (loop);
g_bus_unown_name (owner_id);

return 0;
Expand Down

0 comments on commit 54fca8b

Please sign in to comment.