From 6be69bd4db79cfa9caac2726903a92e62b331171 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Tue, 20 May 2025 08:32:59 +0200 Subject: [PATCH 4/5] session: Add helper function is_connected() No functional change. Signed-off-by: Olivier Fourdan --- src/gpd-session.c | 22 +++++++++++++++------- src/gpd-session.h | 1 - 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/gpd-session.c b/src/gpd-session.c index 4916cf6..b477a53 100644 --- a/src/gpd-session.c +++ b/src/gpd-session.c @@ -91,6 +91,14 @@ is_session_cancelled (GpdSession *session) return priv->cancellable && g_cancellable_is_cancelled (priv->cancellable); } +static gboolean +is_gpd_session_connected (GpdSession *session) +{ + GpdSessionPrivate *priv = gpd_session_get_instance_private (session); + + return priv->connected; +} + static void on_stream_ready (GpdStream *stream, GpdSession *session) @@ -135,7 +143,7 @@ finish_start_session (GpdSession *session) g_object_unref (result); priv->started = TRUE; - if (priv->connected && GPD_SESSION_GET_CLASS (session)->stream_ready) + if (is_gpd_session_connected (session) && GPD_SESSION_GET_CLASS (session)->stream_ready) GPD_SESSION_GET_CLASS (session)->stream_ready (session, priv->stream); } @@ -626,7 +634,7 @@ gpd_session_connect_monitor (GpdSession *session, GVariantBuilder properties_variant; g_debug ("%s", __func__); - if (priv->connected) + if (is_gpd_session_connected (session)) { g_warning ("A session is already active"); return FALSE; @@ -651,7 +659,7 @@ gpd_session_connect_window (GpdSession *session, GVariantBuilder properties_variant; g_debug ("%s", __func__); - if (priv->connected) + if (is_gpd_session_connected (session)) { g_warning ("A session is already active"); return FALSE; @@ -679,7 +687,7 @@ gpd_session_notify_keyboard_keycode (GpdSession *session, GpdDBusRemoteDesktopSession *session_proxy = priv->remote_desktop_session; g_debug ("%s", __func__); - if (!priv->connected) + if (!is_gpd_session_connected (session)) { g_warning ("Not connected"); return FALSE; @@ -710,7 +718,7 @@ gpd_session_notify_keyboard_keysym (GpdSession *session, GpdDBusRemoteDesktopSession *session_proxy = priv->remote_desktop_session; g_debug ("%s", __func__); - if (!priv->connected) + if (!is_gpd_session_connected (session)) { g_warning ("Not connected"); return FALSE; @@ -741,7 +749,7 @@ gpd_session_notify_pointer_button (GpdSession *session, GpdDBusRemoteDesktopSession *session_proxy = priv->remote_desktop_session; g_debug ("%s", __func__); - if (!priv->connected) + if (!is_gpd_session_connected (session)) { g_warning ("Not connected"); return FALSE; @@ -773,7 +781,7 @@ gpd_session_notify_pointer_motion_absolute (GpdSession *session, const char *stream_path; g_debug ("%s", __func__); - if (!priv->connected) + if (!is_gpd_session_connected (session)) { g_warning ("Not connected"); return FALSE; diff --git a/src/gpd-session.h b/src/gpd-session.h index 4a5e55d..a7ad021 100644 --- a/src/gpd-session.h +++ b/src/gpd-session.h @@ -65,7 +65,6 @@ gboolean gpd_session_notify_pointer_button (GpdSession *session, gboolean gpd_session_notify_pointer_motion_absolute (GpdSession *session, double x, double y); - void gpd_session_start (GpdSession *session); void gpd_session_stop (GpdSession *session); -- 2.49.0