[PATCH v2 1/3] compositor-{drm, fbdev, rpi}: Make VT switching configurable

Derek Foreman derekf at osg.samsung.com
Tue Jan 12 07:31:12 PST 2016


On 12/01/16 04:21 AM, Bob Ham wrote:
> 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 at collabora.com>
> Reviewed-by: Derek Foreman <derekf at osg.samsung.com>
> ---
>  man/weston.ini.man     |  6 ++++++
>  src/compositor-drm.c   | 15 +--------------
>  src/compositor-fbdev.c | 17 ++---------------
>  src/compositor-rpi.c   | 16 +---------------
>  src/compositor.h       |  2 ++
>  src/launcher-util.c    | 25 +++++++++++++++++++++++++
>  src/launcher-util.h    |  3 +++
>  src/main.c             |  5 +++++
>  8 files changed, 45 insertions(+), 44 deletions(-)
> 
> diff --git a/man/weston.ini.man b/man/weston.ini.man
> index a9b6026..4f97c4d 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 ea6f3cd..8b9882e 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 f7782d8..36d7ae0 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 4d7ea7b..f48ddc4 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 2848674..130b258 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 e1beef6..bbdface 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,27 @@ weston_launcher_restore(struct weston_launcher *launcher)
>  {
>  	launcher->iface->restore(launcher);
>  }
> +
> +
> +static void
> +switch_vt_binding(struct weston_seat *seat, uint32_t time, uint32_t key, void *data)

Keyboard bindings take a keyboard instead of a seat these days.

Nothing even used the pointer so it's a harmless warning - I fixed it up
when landing.

The series is pushed now, thanks!
Derek

> +{
> +	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 a2219f6..93321ab 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
> diff --git a/src/main.c b/src/main.c
> index 6d2216f..1850fa6 100644
> --- a/src/main.c
> +++ b/src/main.c
> @@ -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);
> 



More information about the wayland-devel mailing list