compositor-{drm, fbdev, rpi}: Make VT switching configurable

Add a new boolean weston.ini option, "vt-switching" to enable or
disable Ctrl-Alt-Fn key combinations.

Signed-off-by: Bob Ham <bob.ham@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>

(Derek Foreman changed the prototype for switch_vt_binding to
have a weston_keyboard * instead of weston_seat *.  The pointer
wasn't used, so this is just a warning fix.)
diff --git a/src/launcher-util.c b/src/launcher-util.c
index e1beef6..03b9d63 100644
--- a/src/launcher-util.c
+++ b/src/launcher-util.c
@@ -32,6 +32,7 @@
 #include "launcher-impl.h"
 
 #include <unistd.h>
+#include <linux/input.h>
 
 static struct launcher_interface *ifaces[] = {
 #ifdef HAVE_SYSTEMD_LOGIN
@@ -89,3 +90,28 @@
 {
 	launcher->iface->restore(launcher);
 }
+
+
+static void
+switch_vt_binding(struct weston_keyboard *keyboard,
+		  uint32_t time, uint32_t key, void *data)
+{
+	struct weston_compositor *compositor = data;
+
+	weston_launcher_activate_vt(compositor->launcher, key - KEY_F1 + 1);
+}
+
+WL_EXPORT void
+weston_setup_vt_switch_bindings(struct weston_compositor *compositor)
+{
+	uint32_t key;
+
+	if (compositor->vt_switching == false)
+		return;
+
+	for (key = KEY_F1; key < KEY_F9; key++)
+		weston_compositor_add_key_binding(compositor, key,
+						  MODIFIER_CTRL | MODIFIER_ALT,
+						  switch_vt_binding,
+						  compositor);
+}