diff options
author | Bob Ham <bob.ham@collabora.com> | 2016-01-12 10:21:47 +0000 |
---|---|---|
committer | Derek Foreman <derekf@osg.samsung.com> | 2016-01-12 09:21:28 -0600 |
commit | 91880f1e9e612eecfeb192343378da24088fc694 (patch) | |
tree | 8c98236530aed355e89d3e848a628a8147e7620a | |
parent | 5d43af3e8888f18a4982d980b8c760d9726a9a92 (diff) |
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.)
-rw-r--r-- | man/weston.ini.man | 6 | ||||
-rw-r--r-- | src/compositor-drm.c | 15 | ||||
-rw-r--r-- | src/compositor-fbdev.c | 17 | ||||
-rw-r--r-- | src/compositor-rpi.c | 16 | ||||
-rw-r--r-- | src/compositor.h | 2 | ||||
-rw-r--r-- | src/launcher-util.c | 26 | ||||
-rw-r--r-- | src/launcher-util.h | 3 | ||||
-rw-r--r-- | src/main.c | 5 |
8 files changed, 46 insertions, 44 deletions
diff --git a/man/weston.ini.man b/man/weston.ini.man index a9b60267..4f97c4d0 100644 --- a/man/weston.ini.man +++ b/man/weston.ini.man @@ -455,6 +455,12 @@ sets the default state of the numlock on weston startup for the backends which support it. .RE .RE +.TP 7 +.BI "vt-switching=" "true" +Whether to allow the use of Ctrl+Alt+Fn key combinations to switch away from +the compositor's virtual console. +.RE +.RE .SH "TERMINAL SECTION" Contains settings for the weston terminal application (weston-terminal). It allows to customize the font and shell of the command line interface. diff --git a/src/compositor-drm.c b/src/compositor-drm.c index ea6f3cdf..8b9882e6 100644 --- a/src/compositor-drm.c +++ b/src/compositor-drm.c @@ -2815,15 +2815,6 @@ session_notify(struct wl_listener *listener, void *data) }; } -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); -} - /* * Find primary GPU * Some systems may have multiple DRM devices attached to a single seat. This @@ -3076,7 +3067,6 @@ drm_backend_create(struct weston_compositor *compositor, struct udev_device *drm_device; struct wl_event_loop *loop; const char *path; - uint32_t key; weston_log("initializing drm backend\n"); @@ -3152,10 +3142,7 @@ drm_backend_create(struct weston_compositor *compositor, b->prev_state = WESTON_COMPOSITOR_ACTIVE; - for (key = KEY_F1; key < KEY_F9; key++) - weston_compositor_add_key_binding(compositor, key, - MODIFIER_CTRL | MODIFIER_ALT, - switch_vt_binding, compositor); + weston_setup_vt_switch_bindings(compositor); wl_list_init(&b->sprite_list); create_sprites(b); diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c index f7782d85..36d7ae0a 100644 --- a/src/compositor-fbdev.c +++ b/src/compositor-fbdev.c @@ -741,15 +741,6 @@ fbdev_restore(struct weston_compositor *compositor) weston_launcher_restore(compositor->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); -} - static struct fbdev_backend * fbdev_backend_create(struct weston_compositor *compositor, int *argc, char *argv[], struct weston_config *config, @@ -757,7 +748,6 @@ fbdev_backend_create(struct weston_compositor *compositor, int *argc, char *argv { struct fbdev_backend *backend; const char *seat_id = default_seat; - uint32_t key; weston_log("initializing fbdev backend\n"); @@ -794,11 +784,8 @@ fbdev_backend_create(struct weston_compositor *compositor, int *argc, char *argv backend->prev_state = WESTON_COMPOSITOR_ACTIVE; backend->use_pixman = !param->use_gl; - for (key = KEY_F1; key < KEY_F9; key++) - weston_compositor_add_key_binding(compositor, key, - MODIFIER_CTRL | MODIFIER_ALT, - switch_vt_binding, - compositor); + weston_setup_vt_switch_bindings(compositor); + if (backend->use_pixman) { if (pixman_renderer_init(compositor) < 0) goto out_launcher; diff --git a/src/compositor-rpi.c b/src/compositor-rpi.c index 4d7ea7b0..f48ddc4d 100644 --- a/src/compositor-rpi.c +++ b/src/compositor-rpi.c @@ -37,7 +37,6 @@ #include <fcntl.h> #include <unistd.h> -#include <linux/input.h> #include <libudev.h> #ifdef HAVE_BCM_HOST @@ -448,15 +447,6 @@ rpi_restore(struct weston_compositor *compositor) weston_launcher_restore(compositor->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); -} - struct rpi_parameters { int tty; struct rpi_renderer_parameters renderer; @@ -468,7 +458,6 @@ rpi_backend_create(struct weston_compositor *compositor, struct rpi_parameters *param) { struct rpi_backend *backend; - uint32_t key; weston_log("initializing Raspberry Pi backend\n"); @@ -506,10 +495,7 @@ rpi_backend_create(struct weston_compositor *compositor, weston_log("Dispmanx planes are %s buffered.\n", backend->single_buffer ? "single" : "double"); - for (key = KEY_F1; key < KEY_F9; key++) - weston_compositor_add_key_binding(compositor, key, - MODIFIER_CTRL | MODIFIER_ALT, - switch_vt_binding, compositor); + weston_setup_vt_switch_bindings(compositor); /* * bcm_host_init() creates threads. diff --git a/src/compositor.h b/src/compositor.h index 28486745..130b2585 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -751,6 +751,8 @@ struct weston_compositor { int32_t kb_repeat_rate; int32_t kb_repeat_delay; + bool vt_switching; + clockid_t presentation_clock; int32_t repaint_msec; diff --git a/src/launcher-util.c b/src/launcher-util.c index e1beef6b..03b9d632 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 @@ weston_launcher_restore(struct weston_launcher *launcher) { 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); +} diff --git a/src/launcher-util.h b/src/launcher-util.h index a2219f67..93321ab7 100644 --- a/src/launcher-util.h +++ b/src/launcher-util.h @@ -52,4 +52,7 @@ weston_launcher_activate_vt(struct weston_launcher *launcher, int vt); void weston_launcher_restore(struct weston_launcher *launcher); +void +weston_setup_vt_switch_bindings(struct weston_compositor *compositor); + #endif @@ -499,6 +499,7 @@ weston_compositor_init_config(struct weston_compositor *ec, struct xkb_rule_names xkb_names; struct weston_config_section *s; int repaint_msec; + int vt_switching; s = weston_config_get_section(config, "keyboard", NULL, NULL); weston_config_section_get_string(s, "keymap_rules", @@ -520,6 +521,10 @@ weston_compositor_init_config(struct weston_compositor *ec, weston_config_section_get_int(s, "repeat-delay", &ec->kb_repeat_delay, 400); + weston_config_section_get_bool(s, "vt-switching", + &vt_switching, true); + ec->vt_switching = vt_switching; + s = weston_config_get_section(config, "core", NULL, NULL); weston_config_section_get_int(s, "repaint-window", &repaint_msec, ec->repaint_msec); |