Skip to content

Commit

Permalink
Switch back to the greeter when logind emits SecureAttentionKey
Browse files Browse the repository at this point in the history
  • Loading branch information
n3rdopolis committed Sep 3, 2024
1 parent 8c22a51 commit 557e30f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/lightdm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down
22 changes: 22 additions & 0 deletions src/login1.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <gio/gio.h>

#include "login1.h"
#include "seat.h"

#define LOGIN1_SERVICE_NAME "org.freedesktop.login1"
#define LOGIN1_OBJECT_NAME "/org/freedesktop/login1"
Expand All @@ -22,6 +23,7 @@
enum {
SEAT_ADDED,
SEAT_REMOVED,
SEAT_ATTENTION_KEY,
LAST_SERVICE_SIGNAL
};
static guint service_signals[LAST_SERVICE_SIGNAL] = { 0 };
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 *
Expand Down
2 changes: 2 additions & 0 deletions src/login1.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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);
Expand Down

0 comments on commit 557e30f

Please sign in to comment.