From 557e30fd951fbb220d97e1f62b375854e4d3e57d Mon Sep 17 00:00:00 2001 From: nerdopolis Date: Tue, 30 Apr 2024 21:09:16 -0400 Subject: [PATCH] Switch back to the greeter when logind emits SecureAttentionKey --- src/lightdm.c | 8 ++++++++ src/login1.c | 22 ++++++++++++++++++++++ src/login1.h | 2 ++ 3 files changed, 32 insertions(+) diff --git a/src/lightdm.c b/src/lightdm.c index 2821a1c9..b4694efc 100644 --- a/src/lightdm.c +++ b/src/lightdm.c @@ -551,6 +551,13 @@ login1_service_seat_removed_cb (Login1Service *service, Login1Seat *login1_seat) remove_login1_seat (login1_seat); } +static void +login1_service_seat_attention_key_cb (Login1Service *service, Login1Seat *login1_seat) +{ + Seat *seat = display_manager_get_seat (display_manager, login1_seat_get_id (login1_seat)); + seat_switch_to_greeter (seat); +} + int main (int argc, char **argv) { @@ -891,6 +898,7 @@ main (int argc, char **argv) { g_signal_connect (login1_service_get_instance (), LOGIN1_SERVICE_SIGNAL_SEAT_ADDED, G_CALLBACK (login1_service_seat_added_cb), NULL); g_signal_connect (login1_service_get_instance (), LOGIN1_SERVICE_SIGNAL_SEAT_REMOVED, G_CALLBACK (login1_service_seat_removed_cb), NULL); + g_signal_connect (login1_service_get_instance (), LOGIN1_SERVICE_SIGNAL_SEAT_ATTENTION_KEY, G_CALLBACK (login1_service_seat_attention_key_cb), NULL); for (GList *link = login1_service_get_seats (login1_service_get_instance ()); link; link = link->next) { diff --git a/src/login1.c b/src/login1.c index 7fe84119..40ba46a8 100644 --- a/src/login1.c +++ b/src/login1.c @@ -14,6 +14,7 @@ #include #include "login1.h" +#include "seat.h" #define LOGIN1_SERVICE_NAME "org.freedesktop.login1" #define LOGIN1_OBJECT_NAME "/org/freedesktop/login1" @@ -22,6 +23,7 @@ enum { SEAT_ADDED, SEAT_REMOVED, + SEAT_ATTENTION_KEY, LAST_SERVICE_SIGNAL }; static guint service_signals[LAST_SERVICE_SIGNAL] = { 0 }; @@ -248,6 +250,18 @@ signal_cb (GDBusConnection *connection, g_signal_emit (service, service_signals[SEAT_REMOVED], 0, seat); } } + else if (strcmp (signal_name, "SecureAttentionKey") == 0) + { + const gchar *id, *path; + g_variant_get (parameters, "(&s&o)", &id, &path); + + Login1Seat *seat = login1_service_get_seat (service, id); + if (seat) + { + g_signal_emit (service, service_signals[SEAT_ATTENTION_KEY], 0, seat); + } + + } } gboolean @@ -498,6 +512,14 @@ login1_service_class_init (Login1ServiceClass *klass) NULL, NULL, NULL, G_TYPE_NONE, 1, LOGIN1_SEAT_TYPE); + service_signals[SEAT_ATTENTION_KEY] = + g_signal_new (LOGIN1_SERVICE_SIGNAL_SEAT_ATTENTION_KEY, + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (Login1ServiceClass, seat_attention_key), + NULL, NULL, + NULL, + G_TYPE_NONE, 1, LOGIN1_SEAT_TYPE); } const gchar * diff --git a/src/login1.h b/src/login1.h index d956242c..a3855972 100644 --- a/src/login1.h +++ b/src/login1.h @@ -24,6 +24,7 @@ G_BEGIN_DECLS #define LOGIN1_SERVICE_SIGNAL_SEAT_ADDED "seat-added" #define LOGIN1_SERVICE_SIGNAL_SEAT_REMOVED "seat-removed" +#define LOGIN1_SERVICE_SIGNAL_SEAT_ATTENTION_KEY "seat-attention-key" #define LOGIN1_SEAT_SIGNAL_CAN_GRAPHICAL_CHANGED "can-graphical-changed" #define LOGIN1_SIGNAL_ACTIVE_SESION_CHANGED "active-session-changed" @@ -50,6 +51,7 @@ typedef struct GObjectClass parent_class; void (*seat_added)(Login1Service *service, Login1Seat *seat); void (*seat_removed)(Login1Service *service, Login1Seat *seat); + void (*seat_attention_key)(Login1Service *service, Login1Seat *seat); } Login1ServiceClass; GType login1_service_get_type (void);