[gnome-flashback/wip/muktupavels/idle-monitor-separate-process] idle-monitor: move to separate process
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback/wip/muktupavels/idle-monitor-separate-process] idle-monitor: move to separate process
- Date: Mon, 23 May 2022 13:10:50 +0000 (UTC)
commit 93dc0870ae9b0cb1f67689f5c1f4f20233895f29
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Mon May 23 16:02:50 2022 +0300
idle-monitor: move to separate process
configure.ac | 2 +-
daemons/Makefile.am | 1 +
.../idle-monitor}/Makefile.am | 21 +-
.../idle-monitor}/flashback-idle-monitor.c | 0
.../idle-monitor}/flashback-idle-monitor.h | 0
daemons/idle-monitor/gf-idle-monitor-main.c | 219 +++++++++++++++++++++
.../idle-monitor}/meta-backend.c | 0
.../idle-monitor}/meta-backend.h | 0
.../idle-monitor}/meta-idle-monitor-xsync.c | 0
.../idle-monitor}/meta-idle-monitor-xsync.h | 0
.../idle-monitor}/meta-idle-monitor.c | 0
.../idle-monitor}/meta-idle-monitor.h | 0
.../idle-monitor}/org.gnome.Mutter.IdleMonitor.xml | 0
data/autostart/Makefile.am | 4 +
.../gnome-flashback-idle-monitor.desktop.in.in | 10 +
gnome-flashback/Makefile.am | 2 -
gnome-flashback/gf-application.c | 4 -
po/POTFILES.in | 1 +
18 files changed, 248 insertions(+), 16 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 4ffd377..9e351f4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -454,6 +454,7 @@ AC_CONFIG_FILES([
daemons/Makefile
daemons/clipboard/Makefile
+ daemons/idle-monitor/Makefile
daemons/media-keys/Makefile
gnome-flashback/Makefile
@@ -463,7 +464,6 @@ AC_CONFIG_FILES([
gnome-flashback/libcommon/Makefile
gnome-flashback/libdesktop/Makefile
gnome-flashback/libend-session-dialog/Makefile
- gnome-flashback/libidle-monitor/Makefile
gnome-flashback/libinput-settings/Makefile
gnome-flashback/libinput-sources/Makefile
gnome-flashback/libnotifications/Makefile
diff --git a/daemons/Makefile.am b/daemons/Makefile.am
index c501fa8..6b65522 100644
--- a/daemons/Makefile.am
+++ b/daemons/Makefile.am
@@ -2,6 +2,7 @@ NULL =
SUBDIRS = \
clipboard \
+ idle-monitor \
media-keys \
$(NULL)
diff --git a/gnome-flashback/libidle-monitor/Makefile.am b/daemons/idle-monitor/Makefile.am
similarity index 69%
rename from gnome-flashback/libidle-monitor/Makefile.am
rename to daemons/idle-monitor/Makefile.am
index a9dd980..ee8830d 100644
--- a/gnome-flashback/libidle-monitor/Makefile.am
+++ b/daemons/idle-monitor/Makefile.am
@@ -1,24 +1,26 @@
NULL =
-noinst_LTLIBRARIES = \
- libidle-monitor.la \
+libexec_PROGRAMS = \
+ gnome-flashback-idle-monitor \
$(NULL)
-libidle_monitor_la_CPPFLAGS = \
- -DG_LOG_DOMAIN=\"idle-monitor\" \
+gnome_flashback_idle_monitor_CPPFLAGS = \
+ -DG_LOG_DOMAIN=\"gnome-flashback-idle-monitor\" \
-DG_LOG_USE_STRUCTURED=1 \
+ -I$(top_builddir)/daemons/idle-monitor \
+ -I$(top_srcdir) \
$(NULL)
-libidle_monitor_la_CFLAGS = \
+gnome_flashback_idle_monitor_CFLAGS = \
$(IDLE_MONITOR_CFLAGS) \
$(WARN_CFLAGS) \
$(AM_CFLAGS) \
- -I$(top_builddir)/gnome-flashback/libidle-monitor \
$(NULL)
-libidle_monitor_la_SOURCES = \
+gnome_flashback_idle_monitor_SOURCES = \
flashback-idle-monitor.c \
flashback-idle-monitor.h \
+ gf-idle-monitor-main.c \
meta-dbus-idle-monitor.c \
meta-dbus-idle-monitor.h \
meta-backend.c \
@@ -29,12 +31,13 @@ libidle_monitor_la_SOURCES = \
meta-idle-monitor-xsync.h \
$(NULL)
-libidle_monitor_la_LDFLAGS = \
+gnome_flashback_idle_monitor_LDFLAGS = \
$(WARN_LDFLAGS) \
$(AM_LDFLAGS) \
$(NULL)
-libidle_monitor_la_LIBADD = \
+gnome_flashback_idle_monitor_LDADD = \
+ $(top_builddir)/dbus/libdbus.la \
$(IDLE_MONITOR_LIBS) \
$(NULL)
diff --git a/gnome-flashback/libidle-monitor/flashback-idle-monitor.c
b/daemons/idle-monitor/flashback-idle-monitor.c
similarity index 100%
rename from gnome-flashback/libidle-monitor/flashback-idle-monitor.c
rename to daemons/idle-monitor/flashback-idle-monitor.c
diff --git a/gnome-flashback/libidle-monitor/flashback-idle-monitor.h
b/daemons/idle-monitor/flashback-idle-monitor.h
similarity index 100%
rename from gnome-flashback/libidle-monitor/flashback-idle-monitor.h
rename to daemons/idle-monitor/flashback-idle-monitor.h
diff --git a/daemons/idle-monitor/gf-idle-monitor-main.c b/daemons/idle-monitor/gf-idle-monitor-main.c
new file mode 100644
index 0000000..f7ef026
--- /dev/null
+++ b/daemons/idle-monitor/gf-idle-monitor-main.c
@@ -0,0 +1,219 @@
+/*
+ * Copyright (C) 2022 Alberts Muktupāvels
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <glib-unix.h>
+#include <gtk/gtk.h>
+#include <stdlib.h>
+
+#include "dbus/gf-session-manager-gen.h"
+#include "dbus/gf-sm-client-private-gen.h"
+#include "flashback-idle-monitor.h"
+
+static char *startup_id = NULL;
+static GMainLoop *loop = NULL;
+static GfSmClientPrivateGen *client_private = NULL;
+
+static gboolean
+on_term_signal (gpointer user_data)
+{
+ g_main_loop_quit (loop);
+
+ return G_SOURCE_REMOVE;
+}
+
+static gboolean
+on_int_signal (gpointer user_data)
+{
+ g_main_loop_quit (loop);
+
+ return G_SOURCE_REMOVE;
+}
+
+static void
+respond_to_end_session (void)
+{
+ gf_sm_client_private_gen_call_end_session_response (client_private,
+ TRUE,
+ "",
+ NULL,
+ NULL,
+ NULL);
+}
+
+static void
+end_session_cb (GfSmClientPrivateGen *object,
+ guint flags,
+ gpointer user_data)
+{
+ respond_to_end_session ();
+}
+
+static void
+query_end_session_cb (GfSmClientPrivateGen *object,
+ guint flags,
+ gpointer user_data)
+{
+ respond_to_end_session ();
+}
+
+static void
+stop_cb (GfSmClientPrivateGen *object,
+ gpointer user_data)
+{
+ g_main_loop_quit (loop);
+}
+
+static void
+client_private_ready_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GError *error;
+
+ error = NULL;
+ client_private = gf_sm_client_private_gen_proxy_new_for_bus_finish (res,
+ &error);
+
+ if (error != NULL)
+ {
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_warning ("Failed to get a client private proxy: %s", error->message);
+
+ g_error_free (error);
+ return;
+ }
+
+ g_signal_connect (client_private,
+ "end-session",
+ G_CALLBACK (end_session_cb),
+ NULL);
+
+ g_signal_connect (client_private,
+ "query-end-session",
+ G_CALLBACK (query_end_session_cb),
+ NULL);
+
+ g_signal_connect (client_private,
+ "stop",
+ G_CALLBACK (stop_cb),
+ NULL);
+}
+
+static void
+register_client_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GError *error;
+ char *client_id;
+
+ error = NULL;
+ gf_session_manager_gen_call_register_client_finish (GF_SESSION_MANAGER_GEN (source_object),
+ &client_id,
+ res,
+ &error);
+
+ if (error != NULL)
+ {
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_warning ("Failed to register client: %s", error->message);
+
+ g_error_free (error);
+ return;
+ }
+
+ gf_sm_client_private_gen_proxy_new_for_bus (G_BUS_TYPE_SESSION,
+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+ "org.gnome.SessionManager",
+ client_id,
+ NULL,
+ client_private_ready_cb,
+ NULL);
+
+ g_free (client_id);
+}
+
+static void
+session_manager_ready_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GError *error;
+ GfSessionManagerGen *session_manager;
+
+ error = NULL;
+ session_manager = gf_session_manager_gen_proxy_new_for_bus_finish (res,
+ &error);
+
+ if (error != NULL)
+ {
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_warning ("Failed to get session manager proxy: %s", error->message);
+
+ g_error_free (error);
+ return;
+ }
+
+ gf_session_manager_gen_call_register_client (session_manager,
+ "gnome-flashback-idle-monitor",
+ startup_id,
+ NULL,
+ register_client_cb,
+ NULL);
+
+ g_object_unref (session_manager);
+}
+
+int
+main (int argc,
+ char *argv[])
+{
+ const char *autostart_id;
+ FlashbackIdleMonitor *idle_monitor;
+
+ autostart_id = g_getenv ("DESKTOP_AUTOSTART_ID");
+ startup_id = g_strdup (autostart_id != NULL ? autostart_id : "");
+ g_unsetenv ("DESKTOP_AUTOSTART_ID");
+
+ gtk_init (&argc, &argv);
+
+ loop = g_main_loop_new (NULL, FALSE);
+ idle_monitor = flashback_idle_monitor_new ();
+
+ g_unix_signal_add (SIGTERM, on_term_signal, NULL);
+ g_unix_signal_add (SIGINT, on_int_signal, NULL);
+
+ gf_session_manager_gen_proxy_new_for_bus (G_BUS_TYPE_SESSION,
+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
+ G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
+ "org.gnome.SessionManager",
+ "/org/gnome/SessionManager",
+ NULL,
+ session_manager_ready_cb,
+ NULL);
+
+ g_main_loop_run (loop);
+ g_main_loop_unref (loop);
+
+ g_object_unref (idle_monitor);
+ g_clear_object (&client_private);
+ g_free (startup_id);
+
+ return EXIT_SUCCESS;
+}
diff --git a/gnome-flashback/libidle-monitor/meta-backend.c b/daemons/idle-monitor/meta-backend.c
similarity index 100%
rename from gnome-flashback/libidle-monitor/meta-backend.c
rename to daemons/idle-monitor/meta-backend.c
diff --git a/gnome-flashback/libidle-monitor/meta-backend.h b/daemons/idle-monitor/meta-backend.h
similarity index 100%
rename from gnome-flashback/libidle-monitor/meta-backend.h
rename to daemons/idle-monitor/meta-backend.h
diff --git a/gnome-flashback/libidle-monitor/meta-idle-monitor-xsync.c
b/daemons/idle-monitor/meta-idle-monitor-xsync.c
similarity index 100%
rename from gnome-flashback/libidle-monitor/meta-idle-monitor-xsync.c
rename to daemons/idle-monitor/meta-idle-monitor-xsync.c
diff --git a/gnome-flashback/libidle-monitor/meta-idle-monitor-xsync.h
b/daemons/idle-monitor/meta-idle-monitor-xsync.h
similarity index 100%
rename from gnome-flashback/libidle-monitor/meta-idle-monitor-xsync.h
rename to daemons/idle-monitor/meta-idle-monitor-xsync.h
diff --git a/gnome-flashback/libidle-monitor/meta-idle-monitor.c b/daemons/idle-monitor/meta-idle-monitor.c
similarity index 100%
rename from gnome-flashback/libidle-monitor/meta-idle-monitor.c
rename to daemons/idle-monitor/meta-idle-monitor.c
diff --git a/gnome-flashback/libidle-monitor/meta-idle-monitor.h b/daemons/idle-monitor/meta-idle-monitor.h
similarity index 100%
rename from gnome-flashback/libidle-monitor/meta-idle-monitor.h
rename to daemons/idle-monitor/meta-idle-monitor.h
diff --git a/gnome-flashback/libidle-monitor/org.gnome.Mutter.IdleMonitor.xml
b/daemons/idle-monitor/org.gnome.Mutter.IdleMonitor.xml
similarity index 100%
rename from gnome-flashback/libidle-monitor/org.gnome.Mutter.IdleMonitor.xml
rename to daemons/idle-monitor/org.gnome.Mutter.IdleMonitor.xml
diff --git a/data/autostart/Makefile.am b/data/autostart/Makefile.am
index 9395aa4..5012e86 100644
--- a/data/autostart/Makefile.am
+++ b/data/autostart/Makefile.am
@@ -3,6 +3,7 @@ NULL =
autostartdir = $(sysconfdir)/xdg/autostart
autostart_DATA = \
gnome-flashback-clipboard.desktop \
+ gnome-flashback-idle-monitor.desktop \
gnome-flashback-media-keys.desktop \
gnome-flashback-nm-applet.desktop \
$(NULL)
@@ -16,6 +17,7 @@ autostart_DATA = \
EXTRA_DIST = \
gnome-flashback-clipboard.desktop.in.in \
+ gnome-flashback-idle-monitor.desktop.in.in \
gnome-flashback-media-keys.desktop.in.in \
gnome-flashback-nm-applet.desktop.in \
$(NULL)
@@ -23,6 +25,8 @@ EXTRA_DIST = \
CLEANFILES = \
gnome-flashback-clipboard.desktop.in \
gnome-flashback-clipboard.desktop \
+ gnome-flashback-idle-monitor.desktop.in \
+ gnome-flashback-idle-monitor.desktop \
gnome-flashback-media-keys.desktop.in \
gnome-flashback-media-keys.desktop \
gnome-flashback-nm-applet.desktop \
diff --git a/data/autostart/gnome-flashback-idle-monitor.desktop.in.in
b/data/autostart/gnome-flashback-idle-monitor.desktop.in.in
new file mode 100644
index 0000000..5ef9f67
--- /dev/null
+++ b/data/autostart/gnome-flashback-idle-monitor.desktop.in.in
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Type=Application
+Name=Idle Monitor (GNOME Flashback)
+Exec=@libexecdir@/gnome-flashback-idle-monitor
+AutostartCondition=GSettings org.gnome.gnome-flashback idle-monitor
+OnlyShowIn=GNOME-Flashback;
+NoDisplay=true
+X-GNOME-Autostart-Phase=Initialization
+X-GNOME-Autostart-Notify=true
+X-GNOME-AutoRestart=true
diff --git a/gnome-flashback/Makefile.am b/gnome-flashback/Makefile.am
index 3b8c87f..a61a83e 100644
--- a/gnome-flashback/Makefile.am
+++ b/gnome-flashback/Makefile.am
@@ -7,7 +7,6 @@ SUBDIRS = \
libcommon \
libdesktop \
libend-session-dialog \
- libidle-monitor \
libinput-settings \
libinput-sources \
libnotifications \
@@ -65,7 +64,6 @@ gnome_flashback_LDADD = \
$(top_builddir)/gnome-flashback/libautomount-manager/libautomount-manager.la \
$(top_builddir)/gnome-flashback/libdesktop/libdesktop.la \
$(top_builddir)/gnome-flashback/libend-session-dialog/libend-session-dialog.la \
- $(top_builddir)/gnome-flashback/libidle-monitor/libidle-monitor.la \
$(top_builddir)/gnome-flashback/libinput-settings/libinput-settings.la \
$(top_builddir)/gnome-flashback/libinput-sources/libinput-sources.la \
$(top_builddir)/gnome-flashback/libnotifications/libnotifications.la \
diff --git a/gnome-flashback/gf-application.c b/gnome-flashback/gf-application.c
index c3981bd..0023199 100644
--- a/gnome-flashback/gf-application.c
+++ b/gnome-flashback/gf-application.c
@@ -29,7 +29,6 @@
#include "libautomount-manager/gsd-automount-manager.h"
#include "libdesktop/gf-desktop.h"
#include "libend-session-dialog/gf-end-session-dialog.h"
-#include "libidle-monitor/flashback-idle-monitor.h"
#include "libinput-settings/gf-input-settings.h"
#include "libinput-sources/gf-input-sources.h"
#include "libnotifications/gf-notifications.h"
@@ -56,7 +55,6 @@ struct _GfApplication
GtkStyleProvider *provider;
GsdAutomountManager *automount;
- FlashbackIdleMonitor *idle_monitor;
FlashbackPolkit *polkit;
FlashbackShell *shell;
GfA11yKeyboard *a11y_keyboard;
@@ -213,7 +211,6 @@ settings_changed (GSettings *settings,
}
SETTING_CHANGED (automount, "automount-manager", gsd_automount_manager_new)
- SETTING_CHANGED (idle_monitor, "idle-monitor", flashback_idle_monitor_new)
SETTING_CHANGED (polkit, "polkit", flashback_polkit_new)
SETTING_CHANGED (shell, "shell", flashback_shell_new)
SETTING_CHANGED (a11y_keyboard, "a11y-keyboard", gf_a11y_keyboard_new)
@@ -269,7 +266,6 @@ gf_application_dispose (GObject *object)
g_clear_object (&application->provider);
g_clear_object (&application->automount);
- g_clear_object (&application->idle_monitor);
g_clear_object (&application->polkit);
g_clear_object (&application->shell);
g_clear_object (&application->a11y_keyboard);
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 30a0779..4ef9ccf 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -5,6 +5,7 @@ daemons/media-keys/gsd-media-keys-manager.c
daemons/media-keys/gsd-screenshot-utils.c
data/applications/gnome-flashback.desktop.in.in
data/autostart/gnome-flashback-clipboard.desktop.in.in
+data/autostart/gnome-flashback-idle-monitor.desktop.in.in
data/autostart/gnome-flashback-media-keys.desktop.in.in
data/autostart/gnome-flashback-nm-applet.desktop.in
data/directories/X-GNOME-Flashback-Settings.directory.desktop.in
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]