summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2012-01-18 12:42:16 -0500
committerKristian Høgsberg <krh@bitplanet.net>2012-01-18 12:42:16 -0500
commit08fcbf0f3d1995b8b895a8811845b2f30ad21a40 (patch)
treea9f130c9dddfcf2bc91d523f05e0e4c7fb865463
parent62d2774956c9ae2845bcebd29f681f5211b4f8fd (diff)
tty: Use SIGUSR1 for both enter and leave signals
Now that we track has_vt, we can use the same handler for both enter and leave.
-rw-r--r--src/tty.c37
1 files changed, 14 insertions, 23 deletions
diff --git a/src/tty.c b/src/tty.c
index 1353205..249f5bb 100644
--- a/src/tty.c
+++ b/src/tty.c
@@ -40,33 +40,26 @@ struct tty {
struct termios terminal_attributes;
struct wl_event_source *input_source;
- struct wl_event_source *enter_vt_source;
- struct wl_event_source *leave_vt_source;
+ struct wl_event_source *vt_source;
tty_vt_func_t vt_func;
int vt, starting_vt, has_vt;
};
-static int on_enter_vt(int signal_number, void *data)
+static int vt_handler(int signal_number, void *data)
{
struct tty *tty = data;
- ioctl(tty->fd, VT_RELDISP, VT_ACKACQ);
+ if (tty->has_vt) {
+ tty->vt_func(tty->compositor, TTY_LEAVE_VT);
+ tty->has_vt = 0;
- tty->vt_func(tty->compositor, TTY_ENTER_VT);
- tty->has_vt = 1;
-
- return 1;
-}
-
-static int
-on_leave_vt(int signal_number, void *data)
-{
- struct tty *tty = data;
-
- tty->vt_func(tty->compositor, TTY_LEAVE_VT);
- tty->has_vt = 0;
+ ioctl(tty->fd, VT_RELDISP, 1);
+ } else {
+ ioctl(tty->fd, VT_RELDISP, VT_ACKACQ);
- ioctl(tty->fd, VT_RELDISP, 1);
+ tty->vt_func(tty->compositor, TTY_ENTER_VT);
+ tty->has_vt = 1;
+ }
return 1;
}
@@ -191,16 +184,14 @@ tty_create(struct weston_compositor *compositor, tty_vt_func_t vt_func,
tty->has_vt = 1;
mode.mode = VT_PROCESS;
mode.relsig = SIGUSR1;
- mode.acqsig = SIGUSR2;
+ mode.acqsig = SIGUSR1;
if (ioctl(tty->fd, VT_SETMODE, &mode) < 0) {
fprintf(stderr, "failed to take control of vt handling\n");
return NULL;
}
- tty->leave_vt_source =
- wl_event_loop_add_signal(loop, SIGUSR1, on_leave_vt, tty);
- tty->enter_vt_source =
- wl_event_loop_add_signal(loop, SIGUSR2, on_enter_vt, tty);
+ tty->vt_source =
+ wl_event_loop_add_signal(loop, SIGUSR1, vt_handler, tty);
return tty;
}