From 2cbedd1874f1cc2edc1218f8fdf1c6e44c681862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Fri, 18 Sep 2009 17:29:49 -0400 Subject: [PATCH] Terminate on Ctrl-Alt-Backspace So that 10 years from now we can have a huge flamewar about it. --- wayland-system-compositor.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/wayland-system-compositor.c b/wayland-system-compositor.c index 02cf84c1..ab8eb761 100644 --- a/wayland-system-compositor.c +++ b/wayland-system-compositor.c @@ -132,11 +132,12 @@ struct wlsc_compositor { uint32_t current_frame; struct wl_event_source *drm_source; - uint32_t meta_state; + uint32_t modifier_state; struct wl_list animate_list; }; -#define META_DOWN 256 +#define MODIFIER_CTRL (1 << 8) +#define MODIFIER_ALT (1 << 9) struct wlsc_vector { GLdouble x, y, z; @@ -1001,16 +1002,38 @@ notify_key(struct wlsc_input_device *device, { struct wlsc_compositor *compositor = device->ec; uint32_t *k, *end; + uint32_t modifier; if (!compositor->vt_active) return; - switch (key | compositor->meta_state) { - case KEY_BACKSPACE | META_DOWN: + switch (key | compositor->modifier_state) { + case KEY_BACKSPACE | MODIFIER_CTRL | MODIFIER_ALT: on_term_signal(SIGTERM, compositor); return; } + switch (key) { + case KEY_LEFTCTRL: + case KEY_RIGHTCTRL: + modifier = MODIFIER_CTRL; + break; + + case KEY_LEFTALT: + case KEY_RIGHTALT: + modifier = MODIFIER_ALT; + break; + + default: + modifier = 0; + break; + } + + if (state) + compositor->modifier_state |= modifier; + else + compositor->modifier_state &= ~modifier; + end = device->keys.data + device->keys.size; for (k = device->keys.data; k < end; k++) { if (*k == key)