On 11/01/16 09:41 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 <[email protected]> > --- > Makefile.am | 4 +++- > man/weston.ini.man | 6 ++++++ > src/compositor-drm.c | 16 ++-------------- > src/compositor-fbdev.c | 18 +++--------------- > src/compositor-rpi.c | 17 ++--------------- > src/compositor.h | 2 ++ > src/launcher-bindings.c | 49 > +++++++++++++++++++++++++++++++++++++++++++++++++ > src/launcher-bindings.h | 26 ++++++++++++++++++++++++++ > src/main.c | 5 +++++ > 9 files changed, 98 insertions(+), 45 deletions(-) > create mode 100644 src/launcher-bindings.c > create mode 100644 src/launcher-bindings.h > > diff --git a/Makefile.am b/Makefile.am > index cbb3b57..18f3801 100644 > --- a/Makefile.am > +++ b/Makefile.am > @@ -145,7 +145,9 @@ libsession_helper_la_SOURCES = \ > src/launcher-impl.h \ > src/weston-launch.h \ > src/launcher-weston-launch.c \ > - src/launcher-direct.c > + src/launcher-direct.c \ > + src/launcher-bindings.c \ > + src/launcher-bindings.h > libsession_helper_la_CFLAGS = $(AM_CFLAGS) $(LIBDRM_CFLAGS) $(PIXMAN_CFLAGS) > $(COMPOSITOR_CFLAGS) > libsession_helper_la_LIBADD = $(LIBDRM_LIBS) > > 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..8663cf3 100644 > --- a/src/compositor-drm.c > +++ b/src/compositor-drm.c > @@ -54,6 +54,7 @@ > #include "pixman-renderer.h" > #include "libinput-seat.h" > #include "launcher-util.h" > +#include "launcher-bindings.h" > #include "vaapi-recorder.h" > #include "presentation_timing-server-protocol.h" > #include "linux-dmabuf.h" > @@ -2815,15 +2816,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 +3068,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 +3143,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..2f486b9 100644 > --- a/src/compositor-fbdev.c > +++ b/src/compositor-fbdev.c > @@ -45,6 +45,7 @@ > #include "shared/helpers.h" > #include "compositor.h" > #include "launcher-util.h" > +#include "launcher-bindings.h" > #include "pixman-renderer.h" > #include "libinput-seat.h" > #include "gl-renderer.h" > @@ -741,15 +742,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 +749,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 +785,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..64bd6bc 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 > @@ -50,6 +49,7 @@ > #include "compositor.h" > #include "rpi-renderer.h" > #include "launcher-util.h" > +#include "launcher-bindings.h" > #include "libinput-seat.h" > #include "presentation_timing-server-protocol.h" > > @@ -448,15 +448,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 +459,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 +496,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-bindings.c b/src/launcher-bindings.c > new file mode 100644 > index 0000000..39941a3 > --- /dev/null > +++ b/src/launcher-bindings.c > @@ -0,0 +1,49 @@ > +/* > + * Copyright (c) 2016 General Electric Company. > + * > + * Permission to use, copy, modify, distribute, and sell this software and > + * its documentation for any purpose is hereby granted without fee, provided > + * that the above copyright notice appear in all copies and that both that > + * copyright notice and this permission notice appear in supporting > + * documentation, and that the name of the copyright holders not be used in > + * advertising or publicity pertaining to distribution of the software > + * without specific, written prior permission. The copyright holders make > + * no representations about the suitability of this software for any > + * purpose. It is provided "as is" without express or implied warranty. > + * > + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS > + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND > + * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY > + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER > + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF > + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN > + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. > + */ > + > +#include <linux/input.h> > + > +#include "launcher-bindings.h" > +#include "launcher-util.h" > + > +static void > +switch_vt_binding(struct weston_seat *seat, 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-bindings.h b/src/launcher-bindings.h > new file mode 100644 > index 0000000..597a425 > --- /dev/null > +++ b/src/launcher-bindings.h > @@ -0,0 +1,26 @@ > +/* > + * Copyright (c) 2016 General Electric Company. > + * > + * Permission to use, copy, modify, distribute, and sell this software and > + * its documentation for any purpose is hereby granted without fee, provided > + * that the above copyright notice appear in all copies and that both that > + * copyright notice and this permission notice appear in supporting > + * documentation, and that the name of the copyright holders not be used in > + * advertising or publicity pertaining to distribution of the software > + * without specific, written prior permission. The copyright holders make > + * no representations about the suitability of this software for any > + * purpose. It is provided "as is" without express or implied warranty. > + * > + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS > + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND > + * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY > + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER > + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF > + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN > + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. > + */ > +
Couldn't these just go into launcher-util? If we really need new files, we should have protective ifdefs in the header. That sorted and this is Reviewed-by: Derek Foreman <[email protected]> > +#include "compositor.h" > + > +void > +weston_setup_vt_switch_bindings(struct weston_compositor *compositor); > 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); > _______________________________________________ wayland-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/wayland-devel
