91 lines
3.2 KiB
Diff
91 lines
3.2 KiB
Diff
|
From 1c7830cc105bfe217abe6f304f4785bbeab209f6 Mon Sep 17 00:00:00 2001
|
||
|
From: David Herrmann <dh.herrmann@gmail.com>
|
||
|
Date: Mon, 29 Sep 2014 14:59:01 +0200
|
||
|
Subject: [PATCH] terminal: add sysview_seat_switch_to()
|
||
|
|
||
|
Add helper to perform session switches on a specific seat whenever we
|
||
|
retrieve a VT-switch keyboard event.
|
||
|
---
|
||
|
src/libsystemd-terminal/sysview-internal.h | 1 +
|
||
|
src/libsystemd-terminal/sysview.c | 28 ++++++++++++++++++++++++++++
|
||
|
src/libsystemd-terminal/sysview.h | 1 +
|
||
|
3 files changed, 30 insertions(+)
|
||
|
|
||
|
diff --git a/src/libsystemd-terminal/sysview-internal.h b/src/libsystemd-terminal/sysview-internal.h
|
||
|
index d9f7fe3301..39ff933eaa 100644
|
||
|
--- a/src/libsystemd-terminal/sysview-internal.h
|
||
|
+++ b/src/libsystemd-terminal/sysview-internal.h
|
||
|
@@ -88,6 +88,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(sysview_session*, sysview_session_free);
|
||
|
struct sysview_seat {
|
||
|
sysview_context *context;
|
||
|
char *name;
|
||
|
+ char *path;
|
||
|
|
||
|
Hashmap *session_map;
|
||
|
Hashmap *device_map;
|
||
|
diff --git a/src/libsystemd-terminal/sysview.c b/src/libsystemd-terminal/sysview.c
|
||
|
index cd776f62d8..919fadf6fe 100644
|
||
|
--- a/src/libsystemd-terminal/sysview.c
|
||
|
+++ b/src/libsystemd-terminal/sysview.c
|
||
|
@@ -391,6 +391,10 @@ int sysview_seat_new(sysview_seat **out, sysview_context *c, const char *name) {
|
||
|
if (!seat->name)
|
||
|
return -ENOMEM;
|
||
|
|
||
|
+ r = sd_bus_path_encode("/org/freedesktop/login1/seat", seat->name, &seat->path);
|
||
|
+ if (r < 0)
|
||
|
+ return r;
|
||
|
+
|
||
|
seat->session_map = hashmap_new(&string_hash_ops);
|
||
|
if (!seat->session_map)
|
||
|
return -ENOMEM;
|
||
|
@@ -422,6 +426,7 @@ sysview_seat *sysview_seat_free(sysview_seat *seat) {
|
||
|
|
||
|
hashmap_free(seat->device_map);
|
||
|
hashmap_free(seat->session_map);
|
||
|
+ free(seat->path);
|
||
|
free(seat->name);
|
||
|
free(seat);
|
||
|
|
||
|
@@ -434,6 +439,29 @@ const char *sysview_seat_get_name(sysview_seat *seat) {
|
||
|
return seat->name;
|
||
|
}
|
||
|
|
||
|
+int sysview_seat_switch_to(sysview_seat *seat, uint32_t nr) {
|
||
|
+ _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
|
||
|
+ int r;
|
||
|
+
|
||
|
+ assert_return(seat, -EINVAL);
|
||
|
+ assert_return(seat->context->sysbus, -EINVAL);
|
||
|
+
|
||
|
+ r = sd_bus_message_new_method_call(seat->context->sysbus,
|
||
|
+ &m,
|
||
|
+ "org.freedesktop.login1",
|
||
|
+ seat->path,
|
||
|
+ "org.freedesktop.login1.Seat",
|
||
|
+ "SwitchTo");
|
||
|
+ if (r < 0)
|
||
|
+ return r;
|
||
|
+
|
||
|
+ r = sd_bus_message_append(m, "u", nr);
|
||
|
+ if (r < 0)
|
||
|
+ return r;
|
||
|
+
|
||
|
+ return sd_bus_send(seat->context->sysbus, m, NULL);
|
||
|
+}
|
||
|
+
|
||
|
/*
|
||
|
* Contexts
|
||
|
*/
|
||
|
diff --git a/src/libsystemd-terminal/sysview.h b/src/libsystemd-terminal/sysview.h
|
||
|
index f691e492d5..31b800f698 100644
|
||
|
--- a/src/libsystemd-terminal/sysview.h
|
||
|
+++ b/src/libsystemd-terminal/sysview.h
|
||
|
@@ -137,6 +137,7 @@ void sysview_session_release_control(sysview_session *session);
|
||
|
*/
|
||
|
|
||
|
const char *sysview_seat_get_name(sysview_seat *seat);
|
||
|
+int sysview_seat_switch_to(sysview_seat *seat, uint32_t nr);
|
||
|
|
||
|
/*
|
||
|
* Contexts
|