swc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/swc
Log | Files | Refs | README | LICENSE

commit 44bda0166da64f16657f01d5b46cd82cc2de4493
parent f61ca83f2a978704aa33bac4abbd0a390df5d4c4
Author: Michael Forney <mforney@mforney.org>
Date:   Tue, 24 Mar 2015 00:00:16 -0700

launch: Send activation message when already on the target VT

In this case, a VT_ACTIVATE call won't trigger the acquire signal,
causing the VT to be stuck in graphics mode with the keyboard off and
the compositor to think it is not active.

Fixes #21.

Diffstat:
Mlaunch/launch.c | 34+++++++++++++++++++++++-----------
1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/launch/launch.c b/launch/launch.c @@ -164,6 +164,24 @@ void __attribute__((noreturn,format(printf,1,2))) exit(EXIT_FAILURE); } +static void activate(void) +{ + struct swc_launch_event event = { .type = SWC_LAUNCH_EVENT_ACTIVATE }; + + start_devices(); + send(launcher.socket, &event, sizeof event, 0); + launcher.active = true; +} + +static void deactivate(void) +{ + struct swc_launch_event event = { .type = SWC_LAUNCH_EVENT_DEACTIVATE }; + + send(launcher.socket, &event, sizeof event, 0); + stop_devices(true); + launcher.active = false; +} + static void handle_chld(int signal) { int status; @@ -176,22 +194,14 @@ static void handle_chld(int signal) static void handle_usr1(int signal) { - struct swc_launch_event event = { .type = SWC_LAUNCH_EVENT_DEACTIVATE }; - - send(launcher.socket, &event, sizeof event, 0); - stop_devices(true); + deactivate(); ioctl(launcher.tty_fd, VT_RELDISP, 1); - launcher.active = false; } static void handle_usr2(int signal) { - struct swc_launch_event event = { .type = SWC_LAUNCH_EVENT_ACTIVATE }; - ioctl(launcher.tty_fd, VT_RELDISP, VT_ACKACQ); - start_devices(); - send(launcher.socket, &event, sizeof event, 0); - launcher.active = true; + activate(); } static void forward_signal(int signal) @@ -392,7 +402,9 @@ static void setup_tty(int fd) goto error1; } - if (!nflag) + if (vt == original_vt_state.vt) + activate(); + else if (!nflag) { if (ioctl(fd, VT_ACTIVATE, vt) == -1) {