libinput: don't use weston_config when configuring input devices

Instead add callbacks to the drm and fbdev backends and pass that to
the input backens so that when a new device needs to be configured
that is called and the compositor can configure it.

Signed-off-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
dev
Giulio Camuffo 9 years ago committed by Pekka Paalanen
parent d52f3b775b
commit 8aedf7b11e
  1. 3
      Makefile.am
  2. 3
      src/compositor-drm.c
  3. 11
      src/compositor-drm.h
  4. 3
      src/compositor-fbdev.c
  5. 11
      src/compositor-fbdev.h
  6. 31
      src/libinput-device.c
  7. 2
      src/libinput-device.h
  8. 7
      src/libinput-seat.c
  9. 9
      src/libinput-seat.h
  10. 27
      src/main.c

@ -65,7 +65,8 @@ weston_LDFLAGS = -export-dynamic
weston_CPPFLAGS = $(AM_CPPFLAGS) -DIN_WESTON weston_CPPFLAGS = $(AM_CPPFLAGS) -DIN_WESTON
weston_CFLAGS = $(AM_CFLAGS) $(COMPOSITOR_CFLAGS) $(LIBUNWIND_CFLAGS) weston_CFLAGS = $(AM_CFLAGS) $(COMPOSITOR_CFLAGS) $(LIBUNWIND_CFLAGS)
weston_LDADD = $(COMPOSITOR_LIBS) $(LIBUNWIND_LIBS) \ weston_LDADD = $(COMPOSITOR_LIBS) $(LIBUNWIND_LIBS) \
$(DLOPEN_LIBS) -lm $(CLOCK_GETTIME_LIBS) libshared.la $(DLOPEN_LIBS) -lm $(CLOCK_GETTIME_LIBS) \
$(LIBINPUT_BACKEND_LIBS) libshared.la
weston_SOURCES = \ weston_SOURCES = \
src/git-version.h \ src/git-version.h \

@ -3121,7 +3121,8 @@ drm_backend_create(struct weston_compositor *compositor,
create_sprites(b); create_sprites(b);
if (udev_input_init(&b->input, if (udev_input_init(&b->input,
compositor, b->udev, seat_id) < 0) { compositor, b->udev, seat_id,
config->configure_device) < 0) {
weston_log("failed to create input devices\n"); weston_log("failed to create input devices\n");
goto err_sprite; goto err_sprite;
} }

@ -36,6 +36,8 @@ extern "C" {
#define WESTON_DRM_BACKEND_CONFIG_VERSION 1 #define WESTON_DRM_BACKEND_CONFIG_VERSION 1
struct libinput_device;
enum weston_drm_backend_output_mode { enum weston_drm_backend_output_mode {
/** The output is disabled */ /** The output is disabled */
WESTON_DRM_BACKEND_OUTPUT_OFF, WESTON_DRM_BACKEND_OUTPUT_OFF,
@ -117,6 +119,15 @@ struct weston_drm_backend_config {
bool use_current_mode, bool use_current_mode,
const char *name, const char *name,
struct weston_drm_backend_output_config *output_config); struct weston_drm_backend_output_config *output_config);
/** Callback used to configure input devices.
*
* This function will be called by the backend when a new input device
* needs to be configured.
* If NULL the device will use the default configuration.
*/
void (*configure_device)(struct weston_compositor *compositor,
struct libinput_device *device);
bool use_current_mode; bool use_current_mode;
}; };

@ -797,7 +797,8 @@ fbdev_backend_create(struct weston_compositor *compositor, int *argc, char *argv
if (fbdev_output_create(backend, param->device) < 0) if (fbdev_output_create(backend, param->device) < 0)
goto out_launcher; goto out_launcher;
udev_input_init(&backend->input, compositor, backend->udev, seat_id); udev_input_init(&backend->input, compositor, backend->udev,
seat_id, param->configure_device);
compositor->backend = &backend->base; compositor->backend = &backend->base;
return backend; return backend;

@ -34,6 +34,8 @@ extern "C" {
#define WESTON_FBDEV_BACKEND_CONFIG_VERSION 1 #define WESTON_FBDEV_BACKEND_CONFIG_VERSION 1
struct libinput_device;
struct weston_fbdev_backend_config { struct weston_fbdev_backend_config {
struct weston_backend_config base; struct weston_backend_config base;
@ -42,6 +44,15 @@ struct weston_fbdev_backend_config {
int use_gl; int use_gl;
uint32_t output_transform; uint32_t output_transform;
/** Callback used to configure input devices.
*
* This function will be called by the backend when a new input device
* needs to be configured.
* If NULL the device will use the default configuration.
*/
void (*configure_device)(struct weston_compositor *compositor,
struct libinput_device *device);
}; };
#ifdef __cplusplus #ifdef __cplusplus

@ -39,7 +39,6 @@
#include "compositor.h" #include "compositor.h"
#include "libinput-device.h" #include "libinput-device.h"
#include "shared/helpers.h" #include "shared/helpers.h"
#include "weston.h"
void void
evdev_led_update(struct evdev_device *device, enum weston_led weston_leds) evdev_led_update(struct evdev_device *device, enum weston_led weston_leds)
@ -430,7 +429,7 @@ notify_output_destroy(struct wl_listener *listener, void *data)
* can't do that, so we need to convert the calibration to the normalized * can't do that, so we need to convert the calibration to the normalized
* format libinput expects. * format libinput expects.
*/ */
static void void
evdev_device_set_calibration(struct evdev_device *device) evdev_device_set_calibration(struct evdev_device *device)
{ {
struct udev *udev; struct udev *udev;
@ -524,32 +523,6 @@ evdev_device_set_output(struct evdev_device *device,
evdev_device_set_calibration(device); evdev_device_set_calibration(device);
} }
static void
configure_device(struct evdev_device *device)
{
struct weston_compositor *compositor = device->seat->compositor;
struct weston_config_section *s;
struct weston_config *config = wet_get_config(compositor);
int enable_tap;
int enable_tap_default;
s = weston_config_get_section(config,
"libinput", NULL, NULL);
if (libinput_device_config_tap_get_finger_count(device->device) > 0) {
enable_tap_default =
libinput_device_config_tap_get_default_enabled(
device->device);
weston_config_section_get_bool(s, "enable_tap",
&enable_tap,
enable_tap_default);
libinput_device_config_tap_set_enabled(device->device,
enable_tap);
}
evdev_device_set_calibration(device);
}
struct evdev_device * struct evdev_device *
evdev_device_create(struct libinput_device *libinput_device, evdev_device_create(struct libinput_device *libinput_device,
struct weston_seat *seat) struct weston_seat *seat)
@ -583,8 +556,6 @@ evdev_device_create(struct libinput_device *libinput_device,
libinput_device_set_user_data(libinput_device, device); libinput_device_set_user_data(libinput_device, device);
libinput_device_ref(libinput_device); libinput_device_ref(libinput_device);
configure_device(device);
return device; return device;
} }

@ -71,6 +71,8 @@ evdev_device_destroy(struct evdev_device *device);
void void
evdev_notify_keyboard_focus(struct weston_seat *seat, evdev_notify_keyboard_focus(struct weston_seat *seat,
struct wl_list *evdev_devices); struct wl_list *evdev_devices);
void
evdev_device_set_calibration(struct evdev_device *device);
int int
dispatch_libinput(struct libinput *libinput); dispatch_libinput(struct libinput *libinput);

@ -79,6 +79,9 @@ device_added(struct udev_input *input, struct libinput_device *libinput_device)
if (device == NULL) if (device == NULL)
return; return;
if (input->configure_device != NULL)
input->configure_device(c, device->device);
evdev_device_set_calibration(device);
udev_seat = (struct udev_seat *) seat; udev_seat = (struct udev_seat *) seat;
wl_list_insert(udev_seat->devices_list.prev, &device->link); wl_list_insert(udev_seat->devices_list.prev, &device->link);
@ -279,7 +282,8 @@ libinput_log_func(struct libinput *libinput,
int int
udev_input_init(struct udev_input *input, struct weston_compositor *c, udev_input_init(struct udev_input *input, struct weston_compositor *c,
struct udev *udev, const char *seat_id) struct udev *udev, const char *seat_id,
udev_configure_device_t configure_device)
{ {
enum libinput_log_priority priority = LIBINPUT_LOG_PRIORITY_INFO; enum libinput_log_priority priority = LIBINPUT_LOG_PRIORITY_INFO;
const char *log_priority = NULL; const char *log_priority = NULL;
@ -287,6 +291,7 @@ udev_input_init(struct udev_input *input, struct weston_compositor *c,
memset(input, 0, sizeof *input); memset(input, 0, sizeof *input);
input->compositor = c; input->compositor = c;
input->configure_device = configure_device;
log_priority = getenv("WESTON_LIBINPUT_LOG_PRIORITY"); log_priority = getenv("WESTON_LIBINPUT_LOG_PRIORITY");

@ -33,17 +33,23 @@
#include "compositor.h" #include "compositor.h"
struct libinput_device;
struct udev_seat { struct udev_seat {
struct weston_seat base; struct weston_seat base;
struct wl_list devices_list; struct wl_list devices_list;
struct wl_listener output_create_listener; struct wl_listener output_create_listener;
}; };
typedef void (*udev_configure_device_t)(struct weston_compositor *compositor,
struct libinput_device *device);
struct udev_input { struct udev_input {
struct libinput *libinput; struct libinput *libinput;
struct wl_event_source *libinput_source; struct wl_event_source *libinput_source;
struct weston_compositor *compositor; struct weston_compositor *compositor;
int suspended; int suspended;
udev_configure_device_t configure_device;
}; };
int int
@ -54,7 +60,8 @@ int
udev_input_init(struct udev_input *input, udev_input_init(struct udev_input *input,
struct weston_compositor *c, struct weston_compositor *c,
struct udev *udev, struct udev *udev,
const char *seat_id); const char *seat_id,
udev_configure_device_t configure_device);
void void
udev_input_destroy(struct udev_input *input); udev_input_destroy(struct udev_input *input);

@ -38,6 +38,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <libinput.h>
#ifdef HAVE_LIBUNWIND #ifdef HAVE_LIBUNWIND
#define UNW_LOCAL_ONLY #define UNW_LOCAL_ONLY
@ -873,6 +874,30 @@ drm_configure_output(struct weston_compositor *c,
return mode; return mode;
} }
static void
configure_input_device(struct weston_compositor *compositor,
struct libinput_device *device)
{
struct weston_config_section *s;
struct weston_config *config = wet_get_config(compositor);
int enable_tap;
int enable_tap_default;
s = weston_config_get_section(config,
"libinput", NULL, NULL);
if (libinput_device_config_tap_get_finger_count(device) > 0) {
enable_tap_default =
libinput_device_config_tap_get_default_enabled(
device);
weston_config_section_get_bool(s, "enable_tap",
&enable_tap,
enable_tap_default);
libinput_device_config_tap_set_enabled(device,
enable_tap);
}
}
static int static int
load_drm_backend(struct weston_compositor *c, const char *backend, load_drm_backend(struct weston_compositor *c, const char *backend,
int *argc, char **argv, struct weston_config *wc) int *argc, char **argv, struct weston_config *wc)
@ -899,6 +924,7 @@ load_drm_backend(struct weston_compositor *c, const char *backend,
config.base.struct_version = WESTON_DRM_BACKEND_CONFIG_VERSION; config.base.struct_version = WESTON_DRM_BACKEND_CONFIG_VERSION;
config.base.struct_size = sizeof(struct weston_drm_backend_config); config.base.struct_size = sizeof(struct weston_drm_backend_config);
config.configure_output = drm_configure_output; config.configure_output = drm_configure_output;
config.configure_device = configure_input_device;
ret = load_backend_new(c, backend, &config.base); ret = load_backend_new(c, backend, &config.base);
@ -1021,6 +1047,7 @@ load_fbdev_backend(struct weston_compositor *c, char const * backend,
config.base.struct_version = WESTON_FBDEV_BACKEND_CONFIG_VERSION; config.base.struct_version = WESTON_FBDEV_BACKEND_CONFIG_VERSION;
config.base.struct_size = sizeof(struct weston_fbdev_backend_config); config.base.struct_size = sizeof(struct weston_fbdev_backend_config);
config.configure_device = configure_input_device;
/* load the actual wayland backend and configure it */ /* load the actual wayland backend and configure it */
ret = load_backend_new(c, backend, &config.base); ret = load_backend_new(c, backend, &config.base);

Loading…
Cancel
Save