Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15-SP4:Update
xdg-desktop-portal-gtk.25122
xdg-desktop-portal-gtk-idle-timeout.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File xdg-desktop-portal-gtk-idle-timeout.patch of Package xdg-desktop-portal-gtk.25122
Index: xdg-desktop-portal-gtk-1.10.0/src/background.c =================================================================== --- xdg-desktop-portal-gtk-1.10.0.orig/src/background.c +++ xdg-desktop-portal-gtk-1.10.0/src/background.c @@ -101,6 +101,8 @@ static gboolean handle_get_app_state (XdpImplBackground *object, GDBusMethodInvocation *invocation) { + idle_timeout_inhibit (); + g_debug ("background: handle GetAppState"); if (app_state == NULL) @@ -114,6 +116,8 @@ handle_get_app_state (XdpImplBackground else xdp_impl_background_complete_get_app_state (object, invocation, app_state); + idle_timeout_release (); + return TRUE; } @@ -400,6 +404,8 @@ handle_enable_autostart (XdpImplBackgrou g_autofree char *commandline = NULL; g_autoptr(GKeyFile) keyfile = NULL; + idle_timeout_inhibit (); + g_debug ("background: handle EnableAutostart"); file = g_strconcat (arg_app_id, ".desktop", NULL); @@ -458,6 +464,7 @@ handle_enable_autostart (XdpImplBackgrou out: xdp_impl_background_complete_enable_autostart (object, invocation, result); + idle_timeout_release (); return TRUE; } Index: xdg-desktop-portal-gtk-1.10.0/src/idle-timeout.h =================================================================== --- /dev/null +++ xdg-desktop-portal-gtk-1.10.0/src/idle-timeout.h @@ -0,0 +1,4 @@ +#pragma once + +void idle_timeout_inhibit (void); +void idle_timeout_release (void); Index: xdg-desktop-portal-gtk-1.10.0/src/inhibit.c =================================================================== --- xdg-desktop-portal-gtk-1.10.0.orig/src/inhibit.c +++ xdg-desktop-portal-gtk-1.10.0/src/inhibit.c @@ -14,6 +14,8 @@ #include "inhibit.h" #include "request.h" +#include "idle-timeout.h" + enum { INHIBIT_LOGOUT = 1, INHIBIT_SWITCH = 2, @@ -448,6 +450,8 @@ inhibit_session_close (Session *session) g_debug ("Closing inhibit session %s", ((Session *)inhibit_session)->id); active_sessions = g_list_remove (active_sessions, session); + + idle_timeout_release (); } static void @@ -480,6 +484,8 @@ inhibit_session_new (const char *app_id, { InhibitSession *inhibit_session; + idle_timeout_inhibit (); + g_debug ("Creating inhibit session %s", session_handle); inhibit_session = g_object_new (inhibit_session_get_type (), Index: xdg-desktop-portal-gtk-1.10.0/src/print.c =================================================================== --- xdg-desktop-portal-gtk-1.10.0.orig/src/print.c +++ xdg-desktop-portal-gtk-1.10.0/src/print.c @@ -42,6 +42,8 @@ #include "gtkbackports.h" +#include "idle-timeout.h" + typedef struct { char *app_id; GtkPageSetup *page_setup; @@ -265,6 +267,8 @@ print_file (int fd, // ensures the app_name won't be NULL even if the app_id.desktop file doesn't exist g_autofree char *app_name = g_strdup (app_id); + idle_timeout_inhibit (); + if (!g_str_has_suffix (app_id, ".desktop")) { app_desktop_fullname = g_strconcat (app_id, ".desktop", NULL); @@ -287,13 +291,19 @@ print_file (int fd, #if GTK_CHECK_VERSION (3, 22, 0) if (job && !gtk_print_job_set_source_fd (job, fd, error)) - return FALSE; + { + idle_timeout_release (); + return FALSE; + } #endif istream = (GUnixInputStream *)g_unix_input_stream_new (fd, FALSE); if ((fd2 = g_file_open_tmp (PACKAGE_NAME "XXXXXX", &filename, error)) == -1) - return FALSE; + { + idle_timeout_release (); + return FALSE; + } ostream = (GUnixOutputStream *)g_unix_output_stream_new (fd2, TRUE); @@ -302,21 +312,29 @@ print_file (int fd, G_OUTPUT_STREAM_SPLICE_NONE, NULL, error) == -1) - return FALSE; + { + idle_timeout_release (); + return FALSE; + } if (job) { if (!gtk_print_job_set_source_file (job, filename, error)) - return FALSE; + { + idle_timeout_release (); + return FALSE; + } - gtk_print_job_send (job, NULL, NULL, NULL); + idle_timeout_inhibit (); + gtk_print_job_send (job, (GtkPrintJobCompleteFunc) idle_timeout_release, NULL, NULL); } else { if (!launch_preview (filename, title, settings, page_setup, error)) - { - unlink (filename); - return FALSE; - } + { + unlink (filename); + idle_timeout_release (); + return FALSE; + } } /* The file will be removed when the GtkPrintJob closes it (once the job is @@ -325,6 +343,7 @@ print_file (int fd, if (!preview) unlink (filename); + idle_timeout_release (); return TRUE; } Index: xdg-desktop-portal-gtk-1.10.0/src/request.c =================================================================== --- xdg-desktop-portal-gtk-1.10.0.orig/src/request.c +++ xdg-desktop-portal-gtk-1.10.0/src/request.c @@ -21,6 +21,8 @@ #include "request.h" +#include "idle-timeout.h" + #include <string.h> static void request_skeleton_iface_init (XdpImplRequestIface *iface); @@ -52,6 +54,8 @@ request_skeleton_iface_init (XdpImplRequ static void request_init (Request *request) { + /* Prevent process from exiting as long as a request exists */ + idle_timeout_inhibit (); } static void @@ -64,6 +68,9 @@ request_finalize (GObject *object) g_free (request->id); G_OBJECT_CLASS (request_parent_class)->finalize (object); + + /* Process can exit when there are no more outstanding requests */ + idle_timeout_release (); } static void Index: xdg-desktop-portal-gtk-1.10.0/src/session.c =================================================================== --- xdg-desktop-portal-gtk-1.10.0.orig/src/session.c +++ xdg-desktop-portal-gtk-1.10.0/src/session.c @@ -19,6 +19,8 @@ #include "session.h" +#include "idle-timeout.h" + enum { PROP_0, @@ -148,6 +150,9 @@ session_finalize (GObject *object) { Session *session = (Session *)object; + /* Allow the process to exit when there are no active sessions left */ + idle_timeout_release (); + g_hash_table_remove (sessions, session->id); g_free (session->id); @@ -162,6 +167,9 @@ session_constructed (GObject *object) g_hash_table_insert (sessions, g_strdup (session->id), session); + /* Prevent the process from exiting while there are active sessions */ + idle_timeout_inhibit (); + G_OBJECT_CLASS (session_parent_class)->constructed (object); } Index: xdg-desktop-portal-gtk-1.10.0/src/xdg-desktop-portal-gtk.c =================================================================== --- xdg-desktop-portal-gtk-1.10.0.orig/src/xdg-desktop-portal-gtk.c +++ xdg-desktop-portal-gtk-1.10.0/src/xdg-desktop-portal-gtk.c @@ -80,10 +80,17 @@ #include "wallpaper.h" #endif +#include "idle-timeout.h" + +/* Process should go away this long after last request has been handled */ +#define IDLE_TIMEOUT_MS 1000 static GMainLoop *loop = NULL; static GHashTable *outstanding_handles = NULL; +static gint idle_timeout_id; +static gint idle_timeout_inhibit_count; + static gboolean opt_verbose; static gboolean opt_replace; static gboolean show_version; @@ -250,6 +257,51 @@ on_name_lost (GDBusConnection *connectio g_main_loop_quit (loop); } +static gboolean +on_idle_timeout (void) +{ + g_main_loop_quit (loop); + return FALSE; +} + +static void +idle_timeout_stop (void) +{ + if (idle_timeout_id) + { + g_source_remove (idle_timeout_id); + idle_timeout_id = 0; + } +} + +static void +idle_timeout_restart (void) +{ + idle_timeout_stop (); + idle_timeout_id = g_timeout_add (IDLE_TIMEOUT_MS, (GSourceFunc) on_idle_timeout, NULL); +} + +void +idle_timeout_inhibit (void) +{ + idle_timeout_stop (); + idle_timeout_inhibit_count++; +} + +void +idle_timeout_release (void) +{ + if (idle_timeout_inhibit_count == 0) + { + g_warning ("Mismatched idle timeout inhibitor release"); + return; + } + + idle_timeout_inhibit_count--; + if (idle_timeout_inhibit_count == 0) + idle_timeout_restart (); +} + int main (int argc, char *argv[]) { @@ -323,6 +375,7 @@ main (int argc, char *argv[]) NULL, NULL); + idle_timeout_restart (); g_main_loop_run (loop); g_bus_unown_name (owner_id);
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor