From 3e228b0b2ac6fbeee544764aa1c3aa1e7e501af1 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Tue, 19 Dec 2017 19:46:30 +0100 Subject: libinput backend: add wlr_input_device_is_libinput --- backend/libinput/events.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'backend') diff --git a/backend/libinput/events.c b/backend/libinput/events.c index c14aef01..758a9f25 100644 --- a/backend/libinput/events.c +++ b/backend/libinput/events.c @@ -53,6 +53,10 @@ static struct wlr_input_device *allocate_device( return wlr_dev; } +bool wlr_input_device_is_libinput(struct wlr_input_device *wlr_dev) { + return wlr_dev->impl == &input_device_impl; +} + static void handle_device_added(struct wlr_libinput_backend *backend, struct libinput_device *libinput_dev) { assert(backend && libinput_dev); -- cgit v1.2.3 From f83b16bc17ab9a95c23d235416acc2c26daa640d Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Tue, 19 Dec 2017 19:49:46 +0100 Subject: x11 backend: add wlr_output_is_x11 --- backend/x11/backend.c | 4 ++++ include/backend/x11.h | 1 - include/wlr/backend/x11.h | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) (limited to 'backend') diff --git a/backend/x11/backend.c b/backend/x11/backend.c index f6f9cfa8..0d0eaa5b 100644 --- a/backend/x11/backend.c +++ b/backend/x11/backend.c @@ -401,3 +401,7 @@ static struct wlr_output_impl output_impl = { .make_current = output_make_current, .swap_buffers = output_swap_buffers, }; + +bool wlr_output_is_x11(struct wlr_output *wlr_output) { + return wlr_output->impl == &output_impl; +} diff --git a/include/backend/x11.h b/include/backend/x11.h index 31a5138b..b845a41a 100644 --- a/include/backend/x11.h +++ b/include/backend/x11.h @@ -6,7 +6,6 @@ #include #include #include -#include #include struct wlr_x11_backend; diff --git a/include/wlr/backend/x11.h b/include/wlr/backend/x11.h index 3901649b..667bfd15 100644 --- a/include/wlr/backend/x11.h +++ b/include/wlr/backend/x11.h @@ -4,10 +4,12 @@ #include #include #include +#include struct wlr_backend *wlr_x11_backend_create(struct wl_display *display, const char *x11_display); bool wlr_backend_is_x11(struct wlr_backend *backend); +bool wlr_output_is_x11(struct wlr_output *output); #endif -- cgit v1.2.3 From dabfe159dea502a51617d90785343cee18cf408b Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Tue, 19 Dec 2017 19:55:18 +0100 Subject: wl backend: add wlr_output_is_wl --- backend/wayland/output.c | 4 ++++ include/backend/wayland.h | 1 - include/wlr/backend/wayland.h | 8 ++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) (limited to 'backend') diff --git a/backend/wayland/output.c b/backend/wayland/output.c index d841ec49..d76f6366 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -205,6 +205,10 @@ static struct wlr_output_impl output_impl = { .move_cursor = wlr_wl_output_move_cursor, }; +bool wlr_output_is_wl(struct wlr_output *wlr_output) { + return wlr_output->impl == &output_impl; +} + static void xdg_surface_handle_configure(void *data, struct zxdg_surface_v6 *xdg_surface, uint32_t serial) { struct wlr_wl_backend_output *output = data; diff --git a/include/backend/wayland.h b/include/backend/wayland.h index 41cd21c8..5d30745e 100644 --- a/include/backend/wayland.h +++ b/include/backend/wayland.h @@ -8,7 +8,6 @@ #include #include #include -#include #include #include diff --git a/include/wlr/backend/wayland.h b/include/wlr/backend/wayland.h index 43a0b72e..bed03f51 100644 --- a/include/wlr/backend/wayland.h +++ b/include/wlr/backend/wayland.h @@ -4,6 +4,7 @@ #include #include #include +#include #include /** @@ -11,6 +12,7 @@ * you must use wlr_wl_output_create to add them. */ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display); + /** * Adds a new output to this backend. You may remove outputs by destroying them. * Note that if called before initializing the backend, this will return NULL @@ -18,9 +20,15 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display); * the output_add signal). */ struct wlr_output *wlr_wl_output_create(struct wlr_backend *backend); + /** * True if the given backend is a wlr_wl_backend. */ bool wlr_backend_is_wl(struct wlr_backend *backend); +/** + * True if the given output is a wlr_wl_backend_output. + */ +bool wlr_output_is_wl(struct wlr_output *output); + #endif -- cgit v1.2.3 From be95147385b961c9734d2c4406df90d93f3d45a9 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Tue, 19 Dec 2017 19:59:08 +0100 Subject: drm backend: add wlr_output_is_drm --- backend/drm/drm.c | 4 ++++ include/backend/drm/drm.h | 1 - include/wlr/backend/drm.h | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) (limited to 'backend') diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 1fceff95..06f012a3 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -658,6 +658,10 @@ static struct wlr_output_impl output_impl = { .get_gamma_size = wlr_drm_connector_get_gamma_size, }; +bool wlr_output_is_drm(struct wlr_output *output) { + return output->impl == &output_impl; +} + static int retry_pageflip(void *data) { struct wlr_drm_connector *conn = data; wlr_log(L_INFO, "%s: Retrying pageflip", conn->output.name); diff --git a/include/backend/drm/drm.h b/include/backend/drm/drm.h index 1f70a103..278c387c 100644 --- a/include/backend/drm/drm.h +++ b/include/backend/drm/drm.h @@ -12,7 +12,6 @@ #include #include -#include #include #include "iface.h" diff --git a/include/wlr/backend/drm.h b/include/wlr/backend/drm.h index b3475703..133e4f69 100644 --- a/include/wlr/backend/drm.h +++ b/include/wlr/backend/drm.h @@ -4,10 +4,12 @@ #include #include #include +#include struct wlr_backend *wlr_drm_backend_create(struct wl_display *display, struct wlr_session *session, int gpu_fd, struct wlr_backend *parent); bool wlr_backend_is_drm(struct wlr_backend *backend); +bool wlr_output_is_drm(struct wlr_output *output); #endif -- cgit v1.2.3 From 995383b0490401494bf4999f46428b319e781820 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Tue, 19 Dec 2017 20:12:04 +0100 Subject: headless backend: add wlr_input_device_is_headless --- backend/headless/input_device.c | 4 ++++ include/wlr/backend/headless.h | 1 + 2 files changed, 5 insertions(+) (limited to 'backend') diff --git a/backend/headless/input_device.c b/backend/headless/input_device.c index 05def775..5c62e87f 100644 --- a/backend/headless/input_device.c +++ b/backend/headless/input_device.c @@ -19,6 +19,10 @@ static struct wlr_input_device_impl input_device_impl = { .destroy = input_device_destroy, }; +bool wlr_input_device_is_headless(struct wlr_input_device *wlr_dev) { + return wlr_dev->impl == &input_device_impl; +} + struct wlr_input_device *wlr_headless_add_input_device( struct wlr_backend *wlr_backend, enum wlr_input_device_type type) { struct wlr_headless_backend *backend = diff --git a/include/wlr/backend/headless.h b/include/wlr/backend/headless.h index 68ad84da..2c25beb0 100644 --- a/include/wlr/backend/headless.h +++ b/include/wlr/backend/headless.h @@ -10,5 +10,6 @@ struct wlr_output *wlr_headless_add_output(struct wlr_backend *backend, struct wlr_input_device *wlr_headless_add_input_device( struct wlr_backend *backend, enum wlr_input_device_type type); bool wlr_backend_is_headless(struct wlr_backend *backend); +bool wlr_input_device_is_headless(struct wlr_input_device *device); #endif -- cgit v1.2.3 From d9eaca6c9fa162c3b47ce61ecdeab4dc73620b0a Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Tue, 19 Dec 2017 20:17:47 +0100 Subject: headless backend: add wlr_output_is_headless --- backend/headless/output.c | 4 ++++ include/backend/headless.h | 1 - include/wlr/backend/headless.h | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) (limited to 'backend') diff --git a/backend/headless/output.c b/backend/headless/output.c index 9c4ba35e..511c2c53 100644 --- a/backend/headless/output.c +++ b/backend/headless/output.c @@ -82,6 +82,10 @@ static const struct wlr_output_impl output_impl = { .swap_buffers = output_swap_buffers, }; +bool wlr_output_is_headless(struct wlr_output *wlr_output) { + return wlr_output->impl == &output_impl; +} + static int signal_frame(void *data) { struct wlr_headless_output *output = data; wl_signal_emit(&output->wlr_output.events.frame, &output->wlr_output); diff --git a/include/backend/headless.h b/include/backend/headless.h index 91ff37dd..f1948c07 100644 --- a/include/backend/headless.h +++ b/include/backend/headless.h @@ -3,7 +3,6 @@ #include #include -#include struct wlr_headless_backend { struct wlr_backend backend; diff --git a/include/wlr/backend/headless.h b/include/wlr/backend/headless.h index 2c25beb0..8995f7cb 100644 --- a/include/wlr/backend/headless.h +++ b/include/wlr/backend/headless.h @@ -3,6 +3,7 @@ #include #include +#include struct wlr_backend *wlr_headless_backend_create(struct wl_display *display); struct wlr_output *wlr_headless_add_output(struct wlr_backend *backend, @@ -11,5 +12,6 @@ struct wlr_input_device *wlr_headless_add_input_device( struct wlr_backend *backend, enum wlr_input_device_type type); bool wlr_backend_is_headless(struct wlr_backend *backend); bool wlr_input_device_is_headless(struct wlr_input_device *device); +bool wlr_output_is_headless(struct wlr_output *output); #endif -- cgit v1.2.3 From 169bc9fa100afd01c25ec140e7dcae565920c6a4 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Tue, 19 Dec 2017 20:20:32 +0100 Subject: wl backend: add wlr_input_device_is_wl --- backend/wayland/wl_seat.c | 4 ++++ include/backend/wayland.h | 1 - include/wlr/backend/wayland.h | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletion(-) (limited to 'backend') diff --git a/backend/wayland/wl_seat.c b/backend/wayland/wl_seat.c index 0d4ebc8d..ddee268d 100644 --- a/backend/wayland/wl_seat.c +++ b/backend/wayland/wl_seat.c @@ -203,6 +203,10 @@ static struct wlr_input_device_impl input_device_impl = { .destroy = input_device_destroy }; +bool wlr_input_device_is_wl(struct wlr_input_device *dev) { + return dev->impl == &input_device_impl; +} + static struct wlr_input_device *allocate_device(struct wlr_wl_backend *backend, enum wlr_input_device_type type) { struct wlr_wl_input_device *wlr_wl_dev; diff --git a/include/backend/wayland.h b/include/backend/wayland.h index 5d30745e..e14e000c 100644 --- a/include/backend/wayland.h +++ b/include/backend/wayland.h @@ -8,7 +8,6 @@ #include #include #include -#include #include struct wlr_wl_backend { diff --git a/include/wlr/backend/wayland.h b/include/wlr/backend/wayland.h index bed03f51..b10ffee3 100644 --- a/include/wlr/backend/wayland.h +++ b/include/wlr/backend/wayland.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -26,6 +27,11 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *backend); */ bool wlr_backend_is_wl(struct wlr_backend *backend); +/** + * True if the given input device is a wlr_wl_input_device. + */ +bool wlr_input_device_is_wl(struct wlr_input_device *device); + /** * True if the given output is a wlr_wl_backend_output. */ -- cgit v1.2.3 From fcd7062542bec6f9ab247dbc63c6eead457006bf Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Tue, 19 Dec 2017 20:40:36 +0100 Subject: x11 backend: add wlr_input_device_is_x11 --- backend/x11/backend.c | 9 +++++++-- include/backend/x11.h | 1 - include/wlr/backend/x11.h | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'backend') diff --git a/backend/x11/backend.c b/backend/x11/backend.c index 0d0eaa5b..d2690342 100644 --- a/backend/x11/backend.c +++ b/backend/x11/backend.c @@ -25,6 +25,7 @@ static struct wlr_backend_impl backend_impl; static struct wlr_output_impl output_impl; +static struct wlr_input_device_impl input_device_impl = { 0 }; static uint32_t xcb_button_to_wl(uint32_t button) { switch (button) { @@ -328,12 +329,12 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display, } wlr_input_device_init(&x11->keyboard_dev, WLR_INPUT_DEVICE_KEYBOARD, - NULL, "X11 keyboard", 0, 0); + &input_device_impl, "X11 keyboard", 0, 0); wlr_keyboard_init(&x11->keyboard, NULL); x11->keyboard_dev.keyboard = &x11->keyboard; wlr_input_device_init(&x11->pointer_dev, WLR_INPUT_DEVICE_POINTER, - NULL, "X11 pointer", 0, 0); + &input_device_impl, "X11 pointer", 0, 0); wlr_pointer_init(&x11->pointer, NULL); x11->pointer_dev.pointer = &x11->pointer; @@ -405,3 +406,7 @@ static struct wlr_output_impl output_impl = { bool wlr_output_is_x11(struct wlr_output *wlr_output) { return wlr_output->impl == &output_impl; } + +bool wlr_input_device_is_x11(struct wlr_input_device *wlr_dev) { + return wlr_dev->impl == &input_device_impl; +} diff --git a/include/backend/x11.h b/include/backend/x11.h index b845a41a..b342cd4d 100644 --- a/include/backend/x11.h +++ b/include/backend/x11.h @@ -6,7 +6,6 @@ #include #include #include -#include struct wlr_x11_backend; diff --git a/include/wlr/backend/x11.h b/include/wlr/backend/x11.h index 667bfd15..b22d7f68 100644 --- a/include/wlr/backend/x11.h +++ b/include/wlr/backend/x11.h @@ -4,12 +4,14 @@ #include #include #include +#include #include struct wlr_backend *wlr_x11_backend_create(struct wl_display *display, const char *x11_display); bool wlr_backend_is_x11(struct wlr_backend *backend); +bool wlr_input_device_is_x11(struct wlr_input_device *device); bool wlr_output_is_x11(struct wlr_output *output); #endif -- cgit v1.2.3