diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-09-09 06:01:46 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-09-09 06:01:46 +0200 |
commit | 8089bbab4b8384c0b2c0922d3964ab163ef04e52 (patch) | |
tree | 975ff0fba0c23926f2b7052b71e30f33d2e6b873 /src | |
parent | implement support for get-vt and configure-vt messages (diff) | |
download | mds-8089bbab4b8384c0b2c0922d3964ab163ef04e52.tar.gz mds-8089bbab4b8384c0b2c0922d3964ab163ef04e52.tar.bz2 mds-8089bbab4b8384c0b2c0922d3964ab163ef04e52.tar.xz |
broadcast switching-vt
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | src/mds-vt.c | 37 | ||||
-rw-r--r-- | src/mds-vt.h | 10 |
2 files changed, 42 insertions, 5 deletions
diff --git a/src/mds-vt.c b/src/mds-vt.c index 8784058..8b2f276 100644 --- a/src/mds-vt.c +++ b/src/mds-vt.c @@ -371,12 +371,15 @@ int master_loop(void) { if (switching_vt) { - /* FIXME */ + int leaving = switching_vt == 1; + switching_vt = 0; + r = switch_vt(leaving); } - - if (r = mds_message_read(&received, socket_fd), r == 0) - if (r = handle_message(), r == 0) - continue; + else + if (r = mds_message_read(&received, socket_fd), r == 0) + r = handle_message(); + if (r == 0) + continue; if (r == -2) { @@ -414,6 +417,30 @@ int master_loop(void) /** + * Perform a VT switch requested by the OS kernel + * + * @param leave_foreground Whether the display is leaving the foreground + * @return Zero on success, -1 on error + */ +int switch_vt(int leave_foreground) +{ + char buf[46 + 12 + 3 * sizeof(int)]; + + sprintf(buf, + "Command: switching-vt\n" + "Message ID: %" PRIu32 "\n" + "Status: %s\n" + "\n", + message_id, + leave_foreground ? "deactivating" : "activating"); + + message_id = message_id == UINT32_MAX ? 0 : (message_id + 1); + + return -!!full_send(buf, strlen(buf)); +} + + +/** * Handle the received message * * @return Zero on success, -1 on error diff --git a/src/mds-vt.h b/src/mds-vt.h index 922e543..93e05de 100644 --- a/src/mds-vt.h +++ b/src/mds-vt.h @@ -25,6 +25,16 @@ #include <linux/vt.h> + +/** + * Perform a VT switch requested by the OS kernel + * + * @param leave_foreground Whether the display is leaving the foreground + * @return Zero on success, -1 on error + */ +int switch_vt(int leave_foreground); + + /** * Handle the received message * |