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.)
This commit is contained in:
Bob Ham 2016-01-12 10:21:47 +00:00 committed by Derek Foreman
parent 5d43af3e88
commit 91880f1e9e
8 changed files with 46 additions and 44 deletions

View file

@ -455,6 +455,12 @@ sets the default state of the numlock on weston startup for the backends which
support it. support it.
.RE .RE
.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" .SH "TERMINAL SECTION"
Contains settings for the weston terminal application (weston-terminal). It Contains settings for the weston terminal application (weston-terminal). It
allows to customize the font and shell of the command line interface. allows to customize the font and shell of the command line interface.

View file

@ -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 * Find primary GPU
* Some systems may have multiple DRM devices attached to a single seat. This * 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 udev_device *drm_device;
struct wl_event_loop *loop; struct wl_event_loop *loop;
const char *path; const char *path;
uint32_t key;
weston_log("initializing drm backend\n"); weston_log("initializing drm backend\n");
@ -3152,10 +3142,7 @@ drm_backend_create(struct weston_compositor *compositor,
b->prev_state = WESTON_COMPOSITOR_ACTIVE; b->prev_state = WESTON_COMPOSITOR_ACTIVE;
for (key = KEY_F1; key < KEY_F9; key++) weston_setup_vt_switch_bindings(compositor);
weston_compositor_add_key_binding(compositor, key,
MODIFIER_CTRL | MODIFIER_ALT,
switch_vt_binding, compositor);
wl_list_init(&b->sprite_list); wl_list_init(&b->sprite_list);
create_sprites(b); create_sprites(b);

View file

@ -741,15 +741,6 @@ fbdev_restore(struct weston_compositor *compositor)
weston_launcher_restore(compositor->launcher); 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 * static struct fbdev_backend *
fbdev_backend_create(struct weston_compositor *compositor, int *argc, char *argv[], fbdev_backend_create(struct weston_compositor *compositor, int *argc, char *argv[],
struct weston_config *config, struct weston_config *config,
@ -757,7 +748,6 @@ fbdev_backend_create(struct weston_compositor *compositor, int *argc, char *argv
{ {
struct fbdev_backend *backend; struct fbdev_backend *backend;
const char *seat_id = default_seat; const char *seat_id = default_seat;
uint32_t key;
weston_log("initializing fbdev backend\n"); 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->prev_state = WESTON_COMPOSITOR_ACTIVE;
backend->use_pixman = !param->use_gl; backend->use_pixman = !param->use_gl;
for (key = KEY_F1; key < KEY_F9; key++) weston_setup_vt_switch_bindings(compositor);
weston_compositor_add_key_binding(compositor, key,
MODIFIER_CTRL | MODIFIER_ALT,
switch_vt_binding,
compositor);
if (backend->use_pixman) { if (backend->use_pixman) {
if (pixman_renderer_init(compositor) < 0) if (pixman_renderer_init(compositor) < 0)
goto out_launcher; goto out_launcher;

View file

@ -37,7 +37,6 @@
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <linux/input.h>
#include <libudev.h> #include <libudev.h>
#ifdef HAVE_BCM_HOST #ifdef HAVE_BCM_HOST
@ -448,15 +447,6 @@ rpi_restore(struct weston_compositor *compositor)
weston_launcher_restore(compositor->launcher); 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 { struct rpi_parameters {
int tty; int tty;
struct rpi_renderer_parameters renderer; struct rpi_renderer_parameters renderer;
@ -468,7 +458,6 @@ rpi_backend_create(struct weston_compositor *compositor,
struct rpi_parameters *param) struct rpi_parameters *param)
{ {
struct rpi_backend *backend; struct rpi_backend *backend;
uint32_t key;
weston_log("initializing Raspberry Pi backend\n"); 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", weston_log("Dispmanx planes are %s buffered.\n",
backend->single_buffer ? "single" : "double"); backend->single_buffer ? "single" : "double");
for (key = KEY_F1; key < KEY_F9; key++) weston_setup_vt_switch_bindings(compositor);
weston_compositor_add_key_binding(compositor, key,
MODIFIER_CTRL | MODIFIER_ALT,
switch_vt_binding, compositor);
/* /*
* bcm_host_init() creates threads. * bcm_host_init() creates threads.

View file

@ -751,6 +751,8 @@ struct weston_compositor {
int32_t kb_repeat_rate; int32_t kb_repeat_rate;
int32_t kb_repeat_delay; int32_t kb_repeat_delay;
bool vt_switching;
clockid_t presentation_clock; clockid_t presentation_clock;
int32_t repaint_msec; int32_t repaint_msec;

View file

@ -32,6 +32,7 @@
#include "launcher-impl.h" #include "launcher-impl.h"
#include <unistd.h> #include <unistd.h>
#include <linux/input.h>
static struct launcher_interface *ifaces[] = { static struct launcher_interface *ifaces[] = {
#ifdef HAVE_SYSTEMD_LOGIN #ifdef HAVE_SYSTEMD_LOGIN
@ -89,3 +90,28 @@ weston_launcher_restore(struct weston_launcher *launcher)
{ {
launcher->iface->restore(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);
}

View file

@ -52,4 +52,7 @@ weston_launcher_activate_vt(struct weston_launcher *launcher, int vt);
void void
weston_launcher_restore(struct weston_launcher *launcher); weston_launcher_restore(struct weston_launcher *launcher);
void
weston_setup_vt_switch_bindings(struct weston_compositor *compositor);
#endif #endif

View file

@ -499,6 +499,7 @@ weston_compositor_init_config(struct weston_compositor *ec,
struct xkb_rule_names xkb_names; struct xkb_rule_names xkb_names;
struct weston_config_section *s; struct weston_config_section *s;
int repaint_msec; int repaint_msec;
int vt_switching;
s = weston_config_get_section(config, "keyboard", NULL, NULL); s = weston_config_get_section(config, "keyboard", NULL, NULL);
weston_config_section_get_string(s, "keymap_rules", 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", weston_config_section_get_int(s, "repeat-delay",
&ec->kb_repeat_delay, 400); &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); s = weston_config_get_section(config, "core", NULL, NULL);
weston_config_section_get_int(s, "repaint-window", &repaint_msec, weston_config_section_get_int(s, "repaint-window", &repaint_msec,
ec->repaint_msec); ec->repaint_msec);