summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2012-04-10 00:11:50 -0400
committerKristian Høgsberg <krh@bitplanet.net>2012-04-10 00:35:09 -0400
commit5d1c0c58ad137eaa1ec31440afe0b757f3f9ab8b (patch)
tree359b480e14447fdfd4364a0258d8873f33dd179e
parenta00d60f6ac23ea1418025fb474e56c86af6f003e (diff)
drm: Add vt switch keybindings
-rw-r--r--src/compositor-drm.c17
-rw-r--r--src/compositor.h3
-rw-r--r--src/tty.c6
3 files changed, 26 insertions, 0 deletions
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 763ffc83..8bbf8674 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -29,6 +29,7 @@
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
+#include <linux/input.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
@@ -1542,6 +1543,16 @@ vt_func(struct weston_compositor *compositor, int event)
};
}
+static void
+switch_vt_binding(struct wl_input_device *device, uint32_t time,
+ uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
+{
+ struct drm_compositor *ec = data;
+
+ if (state)
+ tty_activate_vt(ec->tty, key - KEY_F1 + 1);
+}
+
static const char default_seat[] = "seat0";
static struct weston_compositor *
@@ -1554,6 +1565,7 @@ drm_compositor_create(struct wl_display *display,
struct udev_device *device, *drm_device;
const char *path, *device_seat;
struct wl_event_loop *loop;
+ uint32_t key;
ec = malloc(sizeof *ec);
if (ec == NULL)
@@ -1614,6 +1626,11 @@ drm_compositor_create(struct wl_display *display,
if (weston_compositor_init(&ec->base, display) < 0)
return NULL;
+ for (key = KEY_F1; key < KEY_F9; key++)
+ weston_compositor_add_binding(&ec->base, key, 0, 0,
+ MODIFIER_CTRL | MODIFIER_ALT,
+ switch_vt_binding, ec);
+
wl_list_init(&ec->sprite_list);
create_sprites(ec);
diff --git a/src/compositor.h b/src/compositor.h
index a49b6669..1b37356e 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -518,6 +518,9 @@ tty_create(struct weston_compositor *compositor,
void
tty_destroy(struct tty *tty);
+int
+tty_activate_vt(struct tty *tty, int vt);
+
struct screenshooter *
screenshooter_create(struct weston_compositor *ec);
diff --git a/src/tty.c b/src/tty.c
index 651c5cd2..e029d551 100644
--- a/src/tty.c
+++ b/src/tty.c
@@ -104,6 +104,12 @@ try_open_vt(struct tty *tty)
return fd;
}
+int
+tty_activate_vt(struct tty *tty, int vt)
+{
+ return ioctl(tty->fd, VT_ACTIVATE, vt);
+}
+
struct tty *
tty_create(struct weston_compositor *compositor, tty_vt_func_t vt_func,
int tty_nr)