diff options
author | Eli Schwartz <eschwartz93@gmail.com> | 2024-06-03 01:30:21 -0400 |
---|---|---|
committer | Sam James <sam@gentoo.org> | 2024-06-03 07:34:27 +0100 |
commit | cd6f9b32382e738032c2a302fb08bfeb2030190f (patch) | |
tree | 119568f2ae7a85fc53de192c5378fca9e178c8d5 | |
parent | gnome-extra/cinnamon-session: add 6.0.4 (diff) | |
download | gentoo-cd6f9b32382e738032c2a302fb08bfeb2030190f.tar.gz gentoo-cd6f9b32382e738032c2a302fb08bfeb2030190f.tar.bz2 gentoo-cd6f9b32382e738032c2a302fb08bfeb2030190f.zip |
gnome-extra/cinnamon-session: backport fix for crash in 6.x
Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
Closes: https://github.com/gentoo/gentoo/pull/36989
Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r-- | gnome-extra/cinnamon-session/cinnamon-session-6.0.4.ebuild | 2 | ||||
-rw-r--r-- | gnome-extra/cinnamon-session/files/0001-cs-presence.c-Fix-CsmPresence-idle-handling.patch | 303 |
2 files changed, 305 insertions, 0 deletions
diff --git a/gnome-extra/cinnamon-session/cinnamon-session-6.0.4.ebuild b/gnome-extra/cinnamon-session/cinnamon-session-6.0.4.ebuild index cefd1f0a4183..8da2d3ffc0b8 100644 --- a/gnome-extra/cinnamon-session/cinnamon-session-6.0.4.ebuild +++ b/gnome-extra/cinnamon-session/cinnamon-session-6.0.4.ebuild @@ -66,6 +66,8 @@ PATCHES=( # Fix bad systemd include # https://github.com/linuxmint/cinnamon-session/pull/164 "${FILESDIR}/${PN}-6.0.0-fix-optional-systemd.patch" + # fix crash on idle + "${FILESDIR}"/0001-cs-presence.c-Fix-CsmPresence-idle-handling.patch ) src_prepare() { diff --git a/gnome-extra/cinnamon-session/files/0001-cs-presence.c-Fix-CsmPresence-idle-handling.patch b/gnome-extra/cinnamon-session/files/0001-cs-presence.c-Fix-CsmPresence-idle-handling.patch new file mode 100644 index 000000000000..01a194f7cb7b --- /dev/null +++ b/gnome-extra/cinnamon-session/files/0001-cs-presence.c-Fix-CsmPresence-idle-handling.patch @@ -0,0 +1,303 @@ +From 55e9291629cc028793e22b738214ecababe65c4b Mon Sep 17 00:00:00 2001 +From: Michael Webster <miketwebster@gmail.com> +Date: Wed, 24 Jan 2024 09:14:01 -0500 +Subject: [PATCH] cs-presence.c: Fix CsmPresence idle handling. + +Idle detection was broken since 5.4, as gnome-idle-monitor (in +libcinnamon-desktop) was looking for the wrong muffin interface +names. + +This file was also adapted incompletely to the new idle-monitor +API. + +requires: +linuxmint/cinnamon-desktop@d0f8c74a7864786cf04 +--- + cinnamon-session/csm-presence.c | 130 +++++++++++++++++++------------- + cinnamon-session/csm-presence.h | 6 -- + 2 files changed, 77 insertions(+), 59 deletions(-) + +diff --git a/cinnamon-session/csm-presence.c b/cinnamon-session/csm-presence.c +index 1fd3d7c..69da703 100644 +--- a/cinnamon-session/csm-presence.c ++++ b/cinnamon-session/csm-presence.c +@@ -64,16 +64,12 @@ struct CsmPresencePrivate + + enum { + PROP_0, +- PROP_STATUS, +- PROP_STATUS_TEXT, + PROP_IDLE_ENABLED, + PROP_IDLE_TIMEOUT, + }; + +- + enum { + STATUS_CHANGED, +- STATUS_TEXT_CHANGED, + LAST_SIGNAL + }; + +@@ -99,6 +95,10 @@ csm_presence_error_quark (void) + return quark_volatile; + } + ++static void idle_became_active_cb (GnomeIdleMonitor *idle_monitor, ++ guint id, ++ gpointer user_data); ++ + static gboolean + csm_presence_set_status_text (CsmPresence *presence, + const char *status_text, +@@ -120,6 +120,8 @@ csm_presence_set_status_text (CsmPresence *presence, + + if (status_text != NULL) { + presence->priv->status_text = g_strdup (status_text); ++ } else { ++ presence->priv->status_text = g_strdup (""); + } + + csm_exported_presence_set_status_text (presence->priv->skeleton, presence->priv->status_text); +@@ -128,11 +130,11 @@ csm_presence_set_status_text (CsmPresence *presence, + return TRUE; + } + +-static gboolean ++static void + csm_presence_set_status (CsmPresence *presence, + guint status) + { +- g_return_val_if_fail (CSM_IS_PRESENCE (presence), FALSE); ++ g_return_if_fail (CSM_IS_PRESENCE (presence)); + + if (status != presence->priv->status) { + presence->priv->status = status; +@@ -140,7 +142,6 @@ csm_presence_set_status (CsmPresence *presence, + csm_exported_presence_emit_status_changed (presence->priv->skeleton, presence->priv->status); + g_signal_emit (presence, signals[STATUS_CHANGED], 0, presence->priv->status); + } +- return TRUE; + } + + static void +@@ -158,6 +159,11 @@ set_session_idle (CsmPresence *presence, + /* save current status */ + presence->priv->saved_status = presence->priv->status; + csm_presence_set_status (presence, CSM_PRESENCE_STATUS_IDLE); ++ ++ gnome_idle_monitor_add_user_active_watch (presence->priv->idle_monitor, ++ idle_became_active_cb, ++ presence, ++ NULL); + } else { + if (presence->priv->status != CSM_PRESENCE_STATUS_IDLE) { + g_debug ("CsmPresence: already not idle, ignoring"); +@@ -171,27 +177,27 @@ set_session_idle (CsmPresence *presence, + } + } + +-static gboolean +-on_idle_timeout (GnomeIdleMonitor *monitor, +- guint id, +- gboolean condition, +- CsmPresence *presence) ++static void ++idle_became_idle_cb (GnomeIdleMonitor *idle_monitor, ++ guint id, ++ gpointer user_data) + { +- gboolean handled; +- +- handled = TRUE; +- set_session_idle (presence, condition); ++ CsmPresence *presence = user_data; ++ set_session_idle (presence, TRUE); ++} + +- return handled; ++static void ++idle_became_active_cb (GnomeIdleMonitor *idle_monitor, ++ guint id, ++ gpointer user_data) ++{ ++ CsmPresence *presence = user_data; ++ set_session_idle (presence, FALSE); + } + + static void + reset_idle_watch (CsmPresence *presence) + { +- if (presence->priv->idle_monitor == NULL) { +- return; +- } +- + if (presence->priv->idle_watch_id > 0) { + g_debug ("CsmPresence: removing idle watch (%i)", presence->priv->idle_watch_id); + gnome_idle_monitor_remove_watch (presence->priv->idle_monitor, +@@ -199,12 +205,11 @@ reset_idle_watch (CsmPresence *presence) + presence->priv->idle_watch_id = 0; + } + +- if (! presence->priv->screensaver_active +- && presence->priv->idle_enabled ++ if (presence->priv->idle_enabled + && presence->priv->idle_timeout > 0) { + presence->priv->idle_watch_id = gnome_idle_monitor_add_idle_watch (presence->priv->idle_monitor, + presence->priv->idle_timeout, +- (GnomeIdleMonitorWatchFunc) on_idle_timeout, ++ idle_became_idle_cb, + presence, + NULL); + g_debug ("CsmPresence: adding idle watch (%i) for %d secs", +@@ -229,11 +234,36 @@ on_screensaver_g_signal (GDBusProxy *proxy, + g_variant_get (parameters, + "(b)", &is_active); + +- g_debug ("screensaver status changed: %d", is_active); ++ if (presence->priv->screensaver_active != is_active) { ++ presence->priv->screensaver_active = is_active; ++ set_session_idle (presence, is_active); ++ } ++} ++ ++static void ++screensaver_get_active_cb (GDBusProxy *screensaver_proxy, ++ GAsyncResult *res, ++ CsmPresence *presence) ++{ ++ g_autoptr(GVariant) data = NULL; ++ g_autoptr(GError) error = NULL; ++ gboolean is_active; + ++ data = g_dbus_proxy_call_finish (screensaver_proxy, res, &error); ++ if (!data) { ++ if (error) { ++ g_warning ("Could not retrieve current screensaver active state: %s", ++ error->message); ++ } else { ++ g_warning ("Could not retrieve current screensaver active state!"); ++ } ++ ++ return; ++ } ++ ++ g_variant_get (data, "(b)", &is_active); + if (presence->priv->screensaver_active != is_active) { + presence->priv->screensaver_active = is_active; +- reset_idle_watch (presence); + set_session_idle (presence, is_active); + } + } +@@ -248,14 +278,25 @@ on_screensaver_name_owner_changed (GDBusProxy *proxy, + + presence = CSM_PRESENCE (user_data); + name_owner = g_dbus_proxy_get_name_owner (proxy); ++ if (name_owner == NULL) { ++ g_debug ("Detected that screensaver has left the bus"); + +- if (name_owner && g_strcmp0 (name_owner, CS_NAME)) { +- g_warning ("Detected that screensaver has appeared on the bus"); +- } else { +- g_warning ("Detected that screensaver has left the bus"); ++ presence->priv->screensaver_active = FALSE; + set_session_idle (presence, FALSE); +- reset_idle_watch (presence); ++ } else { ++ g_debug ("Detected that screensaver has aquired the bus"); ++ ++ g_dbus_proxy_call (presence->priv->screensaver_proxy, ++ "GetActive", ++ NULL, ++ G_DBUS_CALL_FLAGS_NO_AUTO_START, ++ 1000, ++ NULL, ++ (GAsyncReadyCallback) screensaver_get_active_cb, ++ presence); + } ++ ++ g_free (name_owner); + } + + static gboolean +@@ -352,7 +393,8 @@ csm_presence_constructor (GType type, + } + + presence->priv->screensaver_proxy = g_dbus_proxy_new_sync (presence->priv->connection, +- G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, ++ G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START | ++ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, + NULL, + CS_NAME, + CS_PATH, +@@ -424,12 +466,6 @@ csm_presence_set_property (GObject *object, + self = CSM_PRESENCE (object); + + switch (prop_id) { +- case PROP_STATUS: +- csm_presence_set_status (self, g_value_get_uint (value)); +- break; +- case PROP_STATUS_TEXT: +- csm_presence_set_status_text (self, g_value_get_string (value), NULL); +- break; + case PROP_IDLE_ENABLED: + csm_presence_set_idle_enabled (self, g_value_get_boolean (value)); + break; +@@ -453,12 +489,6 @@ csm_presence_get_property (GObject *object, + self = CSM_PRESENCE (object); + + switch (prop_id) { +- case PROP_STATUS: +- g_value_set_uint (value, self->priv->status); +- break; +- case PROP_STATUS_TEXT: +- g_value_set_string (value, self->priv->status_text ? self->priv->status_text : ""); +- break; + case PROP_IDLE_ENABLED: + g_value_set_boolean (value, self->priv->idle_enabled); + break; +@@ -482,15 +512,9 @@ csm_presence_finalize (GObject *object) + presence->priv->idle_watch_id = 0; + } + +- if (presence->priv->status_text != NULL) { +- g_free (presence->priv->status_text); +- presence->priv->status_text = NULL; +- } +- +- if (presence->priv->idle_monitor != NULL) { +- g_object_unref (presence->priv->idle_monitor); +- presence->priv->idle_monitor = NULL; +- } ++ g_clear_pointer (&presence->priv->status_text, g_free); ++ g_clear_object (&presence->priv->idle_monitor); ++ g_clear_object (&presence->priv->screensaver_proxy); + + G_OBJECT_CLASS (csm_presence_parent_class)->finalize (object); + } +diff --git a/cinnamon-session/csm-presence.h b/cinnamon-session/csm-presence.h +index 41de5aa..d2713ab 100644 +--- a/cinnamon-session/csm-presence.h ++++ b/cinnamon-session/csm-presence.h +@@ -50,9 +50,6 @@ struct _CsmPresenceClass + + void (* status_changed) (CsmPresence *presence, + guint status); +- void (* status_text_changed) (CsmPresence *presence, +- const char *status_text); +- + }; + + typedef enum { +@@ -69,9 +66,6 @@ typedef enum + } CsmPresenceError; + + #define CSM_PRESENCE_ERROR csm_presence_error_quark () +-GType csm_presence_error_get_type (void); +-#define CSM_PRESENCE_TYPE_ERROR (csm_presence_error_get_type ()) +- + GQuark csm_presence_error_quark (void); + + GType csm_presence_get_type (void) G_GNUC_CONST; +-- +2.44.2 + |