aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/drm/legacy.c2
-rw-r--r--backend/libinput/events.c2
-rw-r--r--backend/libinput/pointer.c5
-rw-r--r--backend/libinput/tablet_tool.c5
-rw-r--r--backend/libinput/touch.c10
-rw-r--r--backend/meson.build1
-rw-r--r--backend/wayland/wl_seat.c16
-rw-r--r--backend/x11/backend.c50
-rw-r--r--examples/multi-pointer.c3
-rw-r--r--examples/pointer.c16
-rw-r--r--examples/support/shared.c12
-rw-r--r--examples/support/shared.h8
-rw-r--r--examples/tablet.c27
-rw-r--r--examples/touch.c16
-rw-r--r--include/backend/x11.h6
-rw-r--r--include/wlr/types/wlr_cursor.h6
-rw-r--r--include/wlr/types/wlr_input_device.h2
-rw-r--r--include/wlr/types/wlr_pointer.h4
-rw-r--r--include/wlr/types/wlr_tablet_tool.h12
-rw-r--r--include/wlr/types/wlr_touch.h8
-rw-r--r--meson.build55
-rw-r--r--rootston/cursor.c21
-rw-r--r--types/wlr_cursor.c18
23 files changed, 180 insertions, 125 deletions
diff --git a/backend/drm/legacy.c b/backend/drm/legacy.c
index 88a01b89..7c45ae21 100644
--- a/backend/drm/legacy.c
+++ b/backend/drm/legacy.c
@@ -47,7 +47,7 @@ bool legacy_crtc_set_cursor(struct wlr_drm_backend *drm,
if (drmModeSetCursor(drm->fd, crtc->id, gbm_bo_get_handle(bo).u32,
plane->surf.width, plane->surf.height)) {
- wlr_log_errno(L_ERROR, "Failed to set hardware cursor");
+ wlr_log_errno(L_DEBUG, "Failed to set hardware cursor");
return false;
}
diff --git a/backend/libinput/events.c b/backend/libinput/events.c
index d92de830..da7b2be4 100644
--- a/backend/libinput/events.c
+++ b/backend/libinput/events.c
@@ -46,6 +46,8 @@ static struct wlr_input_device *allocate_device(
return NULL;
}
struct wlr_input_device *wlr_dev = &wlr_libinput_dev->wlr_input_device;
+ libinput_device_get_size(libinput_dev,
+ &wlr_dev->width_mm, &wlr_dev->height_mm);
wl_list_insert(wlr_devices, &wlr_dev->link);
wlr_libinput_dev->handle = libinput_dev;
libinput_device_ref(libinput_dev);
diff --git a/backend/libinput/pointer.c b/backend/libinput/pointer.c
index 8a31d312..9ccda634 100644
--- a/backend/libinput/pointer.c
+++ b/backend/libinput/pointer.c
@@ -53,9 +53,8 @@ void handle_pointer_motion_abs(struct libinput_event *event,
wlr_event.device = wlr_dev;
wlr_event.time_msec =
usec_to_msec(libinput_event_pointer_get_time_usec(pevent));
- wlr_event.x_mm = libinput_event_pointer_get_absolute_x(pevent);
- wlr_event.y_mm = libinput_event_pointer_get_absolute_y(pevent);
- libinput_device_get_size(libinput_dev, &wlr_event.width_mm, &wlr_event.height_mm);
+ wlr_event.x = libinput_event_pointer_get_absolute_x_transformed(pevent, 1);
+ wlr_event.y = libinput_event_pointer_get_absolute_y_transformed(pevent, 1);
wlr_signal_emit_safe(&wlr_dev->pointer->events.motion_absolute, &wlr_event);
}
diff --git a/backend/libinput/tablet_tool.c b/backend/libinput/tablet_tool.c
index 27cf7c81..815c4daf 100644
--- a/backend/libinput/tablet_tool.c
+++ b/backend/libinput/tablet_tool.c
@@ -34,14 +34,13 @@ void handle_tablet_tool_axis(struct libinput_event *event,
wlr_event.device = wlr_dev;
wlr_event.time_msec =
usec_to_msec(libinput_event_tablet_tool_get_time_usec(tevent));
- libinput_device_get_size(libinput_dev, &wlr_event.width_mm, &wlr_event.height_mm);
if (libinput_event_tablet_tool_x_has_changed(tevent)) {
wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_X;
- wlr_event.x_mm = libinput_event_tablet_tool_get_x(tevent);
+ wlr_event.x = libinput_event_tablet_tool_get_x_transformed(tevent, 1);
}
if (libinput_event_tablet_tool_y_has_changed(tevent)) {
wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_Y;
- wlr_event.y_mm = libinput_event_tablet_tool_get_y(tevent);
+ wlr_event.y = libinput_event_tablet_tool_get_y_transformed(tevent, 1);
}
if (libinput_event_tablet_tool_pressure_has_changed(tevent)) {
wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_PRESSURE;
diff --git a/backend/libinput/touch.c b/backend/libinput/touch.c
index 2b87f9cd..419c11ea 100644
--- a/backend/libinput/touch.c
+++ b/backend/libinput/touch.c
@@ -35,9 +35,8 @@ void handle_touch_down(struct libinput_event *event,
wlr_event.time_msec =
usec_to_msec(libinput_event_touch_get_time_usec(tevent));
wlr_event.touch_id = libinput_event_touch_get_slot(tevent);
- wlr_event.x_mm = libinput_event_touch_get_x(tevent);
- wlr_event.y_mm = libinput_event_touch_get_y(tevent);
- libinput_device_get_size(libinput_dev, &wlr_event.width_mm, &wlr_event.height_mm);
+ wlr_event.x = libinput_event_touch_get_x_transformed(tevent, 1);
+ wlr_event.y = libinput_event_touch_get_y_transformed(tevent, 1);
wlr_signal_emit_safe(&wlr_dev->touch->events.down, &wlr_event);
}
@@ -74,9 +73,8 @@ void handle_touch_motion(struct libinput_event *event,
wlr_event.time_msec =
usec_to_msec(libinput_event_touch_get_time_usec(tevent));
wlr_event.touch_id = libinput_event_touch_get_slot(tevent);
- wlr_event.x_mm = libinput_event_touch_get_x(tevent);
- wlr_event.y_mm = libinput_event_touch_get_y(tevent);
- libinput_device_get_size(libinput_dev, &wlr_event.width_mm, &wlr_event.height_mm);
+ wlr_event.x = libinput_event_touch_get_x_transformed(tevent, 1);
+ wlr_event.y = libinput_event_touch_get_y_transformed(tevent, 1);
wlr_signal_emit_safe(&wlr_dev->touch->events.motion, &wlr_event);
}
diff --git a/backend/meson.build b/backend/meson.build
index a74ea024..df12d703 100644
--- a/backend/meson.build
+++ b/backend/meson.build
@@ -51,6 +51,7 @@ endif
if conf_data.get('WLR_HAS_X11_BACKEND', false)
backend_files += files('x11/backend.c')
+ backend_deps += xcb_xkb
endif
if conf_data.get('WLR_HAS_ELOGIND', false)
diff --git a/backend/wayland/wl_seat.c b/backend/wayland/wl_seat.c
index 6ca59130..a5821311 100644
--- a/backend/wayland/wl_seat.c
+++ b/backend/wayland/wl_seat.c
@@ -64,6 +64,9 @@ static void pointer_handle_motion(void *data, struct wl_pointer *wl_pointer,
wl_egl_window_get_attached_size(wlr_wl_pointer->current_output->egl_window,
&width, &height);
+ int owidth, oheight;
+ wlr_output_effective_resolution(wlr_output, &owidth, &oheight);
+
struct wlr_box box = {
.x = wl_fixed_to_int(surface_x),
.y = wl_fixed_to_int(surface_y),
@@ -80,10 +83,15 @@ static void pointer_handle_motion(void *data, struct wl_pointer *wl_pointer,
struct wlr_event_pointer_motion_absolute wlr_event;
wlr_event.device = dev;
wlr_event.time_msec = time;
- wlr_event.width_mm = layout_box.width;
- wlr_event.height_mm = layout_box.height;
- wlr_event.x_mm = transformed.x + wlr_output->lx - layout_box.x;
- wlr_event.y_mm = transformed.y + wlr_output->ly - layout_box.y;
+
+ double tx = transformed.x / (double)owidth;
+ double ty = transformed.y / (double)oheight;
+ double ox = wlr_output->lx / (double)layout_box.width;
+ double oy = wlr_output->ly / (double)layout_box.height;
+
+ wlr_event.x = tx * ((double)owidth / layout_box.width) + ox;
+ wlr_event.y = ty * ((double)oheight / layout_box.height) + oy;
+
wlr_signal_emit_safe(&dev->pointer->events.motion_absolute, &wlr_event);
}
diff --git a/backend/x11/backend.c b/backend/x11/backend.c
index 36d72d9e..8abc5d84 100644
--- a/backend/x11/backend.c
+++ b/backend/x11/backend.c
@@ -7,6 +7,7 @@
#include <wayland-server.h>
#include <wlr/backend/interface.h>
#include <wlr/backend/x11.h>
+#include <wlr/config.h>
#include <wlr/interfaces/wlr_input_device.h>
#include <wlr/interfaces/wlr_keyboard.h>
#include <wlr/interfaces/wlr_output.h>
@@ -21,6 +22,9 @@
#elif __FreeBSD__
#include <dev/evdev/input-event-codes.h>
#endif
+#ifdef WLR_HAS_XCB_XKB
+#include <xcb/xkb.h>
+#endif
#include "backend/x11.h"
#include "util/signal.h"
@@ -108,10 +112,8 @@ static bool handle_x11_event(struct wlr_x11_backend *x11, xcb_generic_event_t *e
struct wlr_event_pointer_motion_absolute abs = {
.device = &x11->pointer_dev,
.time_msec = ev->time,
- .x_mm = ev->event_x,
- .y_mm = ev->event_y,
- .width_mm = output->wlr_output.width,
- .height_mm = output->wlr_output.height,
+ .x = (double)ev->event_x / output->wlr_output.width,
+ .y = (double)ev->event_y / output->wlr_output.height,
};
wlr_signal_emit_safe(&x11->pointer.events.motion_absolute, &abs);
@@ -136,10 +138,8 @@ static bool handle_x11_event(struct wlr_x11_backend *x11, xcb_generic_event_t *e
struct wlr_event_pointer_motion_absolute abs = {
.device = &x11->pointer_dev,
.time_msec = x11->time,
- .x_mm = pointer->root_x,
- .y_mm = pointer->root_y,
- .width_mm = output->wlr_output.width,
- .height_mm = output->wlr_output.height,
+ .x = (double)pointer->root_x / output->wlr_output.width,
+ .y = (double)pointer->root_y / output->wlr_output.height,
};
wlr_signal_emit_safe(&x11->pointer.events.motion_absolute, &abs);
@@ -157,6 +157,14 @@ static bool handle_x11_event(struct wlr_x11_backend *x11, xcb_generic_event_t *e
break;
}
default:
+#ifdef WLR_HAS_XCB_XKB
+ if (x11->xkb_supported && event->response_type == x11->xkb_base_event) {
+ xcb_xkb_state_notify_event_t *ev =
+ (xcb_xkb_state_notify_event_t *)event;
+ wlr_keyboard_notify_modifiers(&x11->keyboard, ev->baseMods,
+ ev->latchedMods, ev->lockedMods, ev->lockedGroup);
+ }
+#endif
break;
}
@@ -282,6 +290,32 @@ static bool wlr_x11_backend_start(struct wlr_backend *backend) {
strlen(title), title);
}
+#ifdef WLR_HAS_XCB_XKB
+ const xcb_query_extension_reply_t *reply =
+ xcb_get_extension_data(x11->xcb_conn, &xcb_xkb_id);
+ if (reply != NULL && reply->present) {
+ x11->xkb_base_event = reply->first_event;
+ x11->xkb_base_error = reply->first_error;
+
+ xcb_xkb_use_extension_cookie_t cookie = xcb_xkb_use_extension(
+ x11->xcb_conn, XCB_XKB_MAJOR_VERSION, XCB_XKB_MINOR_VERSION);
+ xcb_xkb_use_extension_reply_t *reply =
+ xcb_xkb_use_extension_reply(x11->xcb_conn, cookie, NULL);
+ if (reply != NULL && reply->supported) {
+ x11->xkb_supported = true;
+
+ xcb_xkb_select_events(x11->xcb_conn,
+ XCB_XKB_ID_USE_CORE_KBD,
+ XCB_XKB_EVENT_TYPE_STATE_NOTIFY,
+ 0,
+ XCB_XKB_EVENT_TYPE_STATE_NOTIFY,
+ 0,
+ 0,
+ 0);
+ }
+ }
+#endif
+
xcb_map_window(x11->xcb_conn, output->win);
xcb_flush(x11->xcb_conn);
wlr_output_update_enabled(&output->wlr_output, true);
diff --git a/examples/multi-pointer.c b/examples/multi-pointer.c
index 1f869f50..46f0e78f 100644
--- a/examples/multi-pointer.c
+++ b/examples/multi-pointer.c
@@ -118,8 +118,7 @@ static void handle_cursor_motion_absolute(struct wl_listener *listener,
struct sample_cursor *cursor =
wl_container_of(listener, cursor, cursor_motion_absolute);
struct wlr_event_pointer_motion_absolute *event = data;
- wlr_cursor_warp_absolute(cursor->cursor, event->device,
- event->x_mm / event->width_mm, event->y_mm / event->height_mm);
+ wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, event->y);
}
static void handle_input_add(struct compositor_state *state,
diff --git a/examples/pointer.c b/examples/pointer.c
index 9794e6e5..aaaad841 100644
--- a/examples/pointer.c
+++ b/examples/pointer.c
@@ -154,8 +154,8 @@ static void handle_cursor_motion_absolute(struct wl_listener *listener,
wl_container_of(listener, sample, cursor_motion_absolute);
struct wlr_event_pointer_motion_absolute *event = data;
- sample->cur_x = event->x_mm;
- sample->cur_y = event->y_mm;
+ sample->cur_x = event->x;
+ sample->cur_y = event->y;
wlr_cursor_warp_absolute(sample->cursor, event->device, sample->cur_x,
sample->cur_y);
@@ -217,8 +217,8 @@ static void handle_touch_down(struct wl_listener *listener, void *data) {
struct wlr_event_touch_down *event = data;
struct touch_point *point = calloc(1, sizeof(struct touch_point));
point->touch_id = event->touch_id;
- point->x = event->x_mm / event->width_mm;
- point->y = event->y_mm / event->height_mm;
+ point->x = event->x;
+ point->y = event->y;
wl_list_insert(&sample->touch_points, &point->link);
warp_to_touch(sample, event->device);
@@ -232,8 +232,8 @@ static void handle_touch_motion(struct wl_listener *listener, void *data) {
struct touch_point *point;
wl_list_for_each(point, &sample->touch_points, link) {
if (point->touch_id == event->touch_id) {
- point->x = event->x_mm / event->width_mm;
- point->y = event->y_mm / event->height_mm;
+ point->x = event->x;
+ point->y = event->y;
break;
}
}
@@ -251,8 +251,8 @@ static void handle_tablet_tool_axis(struct wl_listener *listener, void *data) {
struct wlr_event_tablet_tool_axis *event = data;
if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X) &&
(event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) {
- wlr_cursor_warp_absolute(sample->cursor, event->device,
- event->x_mm / event->width_mm, event->y_mm / event->height_mm);
+ wlr_cursor_warp_absolute(sample->cursor,
+ event->device, event->x, event->y);
}
}
diff --git a/examples/support/shared.c b/examples/support/shared.c
index e6233206..02b324f5 100644
--- a/examples/support/shared.c
+++ b/examples/support/shared.c
@@ -108,8 +108,8 @@ static void pointer_motion_absolute_notify(struct wl_listener *listener, void *d
struct wlr_event_pointer_motion_absolute *event = data;
struct pointer_state *pstate = wl_container_of(listener, pstate, motion_absolute);
if (pstate->compositor->pointer_motion_absolute_cb) {
- pstate->compositor->pointer_motion_absolute_cb(pstate,
- event->x_mm, event->y_mm);
+ pstate->compositor->pointer_motion_absolute_cb(
+ pstate, event->x, event->y);
}
}
@@ -167,8 +167,8 @@ static void touch_down_notify(struct wl_listener *listener, void *data) {
struct wlr_event_touch_down *event = data;
struct touch_state *tstate = wl_container_of(listener, tstate, down);
if (tstate->compositor->touch_down_cb) {
- tstate->compositor->touch_down_cb(tstate, event->touch_id,
- event->x_mm, event->y_mm, event->width_mm, event->height_mm);
+ tstate->compositor->touch_down_cb(tstate,
+ event->touch_id, event->x, event->y);
}
}
@@ -176,8 +176,8 @@ static void touch_motion_notify(struct wl_listener *listener, void *data) {
struct wlr_event_touch_motion *event = data;
struct touch_state *tstate = wl_container_of(listener, tstate, motion);
if (tstate->compositor->touch_motion_cb) {
- tstate->compositor->touch_motion_cb(tstate, event->touch_id,
- event->x_mm, event->y_mm, event->width_mm, event->height_mm);
+ tstate->compositor->touch_motion_cb(tstate,
+ event->touch_id, event->x, event->y);
}
}
diff --git a/examples/support/shared.h b/examples/support/shared.h
index d00e75b3..2079a9ef 100644
--- a/examples/support/shared.h
+++ b/examples/support/shared.h
@@ -102,10 +102,10 @@ struct compositor_state {
enum wlr_axis_source source,
enum wlr_axis_orientation orientation,
double delta);
- void (*touch_down_cb)(struct touch_state *s, int32_t touch_id,
- double x, double y, double width, double height);
- void (*touch_motion_cb)(struct touch_state *s, int32_t touch_id,
- double x, double y, double width, double height);
+ void (*touch_down_cb)(struct touch_state *s,
+ int32_t touch_id, double x, double y);
+ void (*touch_motion_cb)(struct touch_state *s,
+ int32_t touch_id, double x, double y);
void (*touch_up_cb)(struct touch_state *s, int32_t touch_id);
void (*touch_cancel_cb)(struct touch_state *s, int32_t touch_id);
void (*tool_axis_cb)(struct tablet_tool_state *s,
diff --git a/examples/tablet.c b/examples/tablet.c
index 9379fac3..be428f86 100644
--- a/examples/tablet.c
+++ b/examples/tablet.c
@@ -28,7 +28,7 @@ struct sample_state {
bool proximity, tap, button;
double distance;
double pressure;
- double x_mm, y_mm;
+ double x, y;
double x_tilt, y_tilt;
double width_mm, height_mm;
double ring;
@@ -69,8 +69,8 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
if (sample->proximity) {
struct wlr_box box = {
- .x = sample->x_mm * scale - 8 * (sample->pressure + 1) + left,
- .y = sample->y_mm * scale - 8 * (sample->pressure + 1) + top,
+ .x = (sample->x * pad_width) - 8 * (sample->pressure + 1) + left,
+ .y = (sample->y * pad_height) - 8 * (sample->pressure + 1) + top,
.width = 16 * (sample->pressure + 1),
.height = 16 * (sample->pressure + 1),
};
@@ -94,13 +94,11 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
static void handle_tool_axis(struct tablet_tool_state *tstate,
struct wlr_event_tablet_tool_axis *event) {
struct sample_state *sample = tstate->compositor->data;
- sample->width_mm = event->width_mm;
- sample->height_mm = event->height_mm;
if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X)) {
- sample->x_mm = event->x_mm;
+ sample->x = event->x;
}
if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) {
- sample->y_mm = event->y_mm;
+ sample->y = event->y;
}
if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_DISTANCE)) {
sample->distance = event->distance;
@@ -164,13 +162,24 @@ static void handle_pad_ring(struct tablet_pad_state *pstate,
}
}
+static void handle_input_add(struct compositor_state *cstate,
+ struct wlr_input_device *inputdev) {
+ struct sample_state *sample = cstate->data;
+ if (inputdev->type == WLR_INPUT_DEVICE_TABLET_TOOL) {
+ sample->width_mm = inputdev->width_mm == 0 ?
+ 20 : inputdev->width_mm;
+ sample->height_mm = inputdev->height_mm == 0 ?
+ 10 : inputdev->height_mm;
+ }
+}
+
int main(int argc, char *argv[]) {
wlr_log_init(L_DEBUG, NULL);
struct sample_state state = {
.tool_color = { 1, 1, 1, 1 },
.pad_color = { 0.5, 0.5, 0.5, 1.0 }
};
- struct compositor_state compositor = { 0,
+ struct compositor_state compositor = {
.data = &state,
.output_frame_cb = handle_output_frame,
.tool_axis_cb = handle_tool_axis,
@@ -178,6 +187,8 @@ int main(int argc, char *argv[]) {
.tool_button_cb = handle_tool_button,
.pad_button_cb = handle_pad_button,
.pad_ring_cb = handle_pad_ring,
+ .input_add_cb = handle_input_add,
+ 0
};
compositor_init(&compositor);
diff --git a/examples/touch.c b/examples/touch.c
index 7639165c..e9dcf29c 100644
--- a/examples/touch.c
+++ b/examples/touch.c
@@ -60,13 +60,13 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
wlr_output_swap_buffers(wlr_output, NULL, NULL);
}
-static void handle_touch_down(struct touch_state *tstate, int32_t touch_id,
- double x, double y, double width, double height) {
+static void handle_touch_down(struct touch_state *tstate,
+ int32_t touch_id, double x, double y) {
struct sample_state *sample = tstate->compositor->data;
struct touch_point *point = calloc(1, sizeof(struct touch_point));
point->touch_id = touch_id;
- point->x = x / width;
- point->y = y / height;
+ point->x = x;
+ point->y = y;
wl_list_insert(&sample->touch_points, &point->link);
}
@@ -81,14 +81,14 @@ static void handle_touch_up(struct touch_state *tstate, int32_t touch_id) {
}
}
-static void handle_touch_motion(struct touch_state *tstate, int32_t touch_id,
- double x, double y, double width, double height) {
+static void handle_touch_motion(struct touch_state *tstate,
+ int32_t touch_id, double x, double y) {
struct sample_state *sample = tstate->compositor->data;
struct touch_point *point;
wl_list_for_each(point, &sample->touch_points, link) {
if (point->touch_id == touch_id) {
- point->x = x / width;
- point->y = y / height;
+ point->x = x;
+ point->y = y;
break;
}
}
diff --git a/include/backend/x11.h b/include/backend/x11.h
index 840509bf..72710f6c 100644
--- a/include/backend/x11.h
+++ b/include/backend/x11.h
@@ -48,6 +48,12 @@ struct wlr_x11_backend {
// The time we last received an event
xcb_timestamp_t time;
+#ifdef WLR_HAS_XCB_XKB
+ bool xkb_supported;
+ uint8_t xkb_base_event;
+ uint8_t xkb_base_error;
+#endif
+
struct wl_listener display_destroy;
};
diff --git a/include/wlr/types/wlr_cursor.h b/include/wlr/types/wlr_cursor.h
index 70dca9f7..0883f3ca 100644
--- a/include/wlr/types/wlr_cursor.h
+++ b/include/wlr/types/wlr_cursor.h
@@ -73,7 +73,7 @@ bool wlr_cursor_warp(struct wlr_cursor *cur, struct wlr_input_device *dev,
double x, double y);
void wlr_cursor_warp_absolute(struct wlr_cursor *cur,
- struct wlr_input_device *dev, double x_mm, double y_mm);
+ struct wlr_input_device *dev, double x, double y);
/**
* Move the cursor in the direction of the given x and y coordinates.
@@ -155,7 +155,7 @@ void wlr_cursor_map_input_to_region(struct wlr_cursor *cur,
* Convert absolute coordinates to layout coordinates for the device.
*/
bool wlr_cursor_absolute_to_layout_coords(struct wlr_cursor *cur,
- struct wlr_input_device *device, double x_mm, double y_mm,
- double width_mm, double height_mm, double *lx, double *ly);
+ struct wlr_input_device *device, double x, double y,
+ double *lx, double *ly);
#endif
diff --git a/include/wlr/types/wlr_input_device.h b/include/wlr/types/wlr_input_device.h
index 6d8e3631..d65172c1 100644
--- a/include/wlr/types/wlr_input_device.h
+++ b/include/wlr/types/wlr_input_device.h
@@ -29,6 +29,8 @@ struct wlr_input_device {
enum wlr_input_device_type type;
int vendor, product;
char *name;
+ // Or 0 if not applicable to this device
+ double width_mm, height_mm;
/* wlr_input_device.type determines which of these is valid */
union {
diff --git a/include/wlr/types/wlr_pointer.h b/include/wlr/types/wlr_pointer.h
index e7ac9b46..a8969b9e 100644
--- a/include/wlr/types/wlr_pointer.h
+++ b/include/wlr/types/wlr_pointer.h
@@ -29,8 +29,8 @@ struct wlr_event_pointer_motion {
struct wlr_event_pointer_motion_absolute {
struct wlr_input_device *device;
uint32_t time_msec;
- double x_mm, y_mm;
- double width_mm, height_mm;
+ // From 0..1
+ double x, y;
};
struct wlr_event_pointer_button {
diff --git a/include/wlr/types/wlr_tablet_tool.h b/include/wlr/types/wlr_tablet_tool.h
index 59e49ef8..22bf2649 100644
--- a/include/wlr/types/wlr_tablet_tool.h
+++ b/include/wlr/types/wlr_tablet_tool.h
@@ -36,8 +36,8 @@ struct wlr_event_tablet_tool_axis {
struct wlr_input_device *device;
uint32_t time_msec;
uint32_t updated_axes;
- double x_mm, y_mm;
- double width_mm, height_mm;
+ // From 0..1
+ double x, y;
double pressure;
double distance;
double tilt_x, tilt_y;
@@ -54,8 +54,8 @@ enum wlr_tablet_tool_proximity_state {
struct wlr_event_tablet_tool_proximity {
struct wlr_input_device *device;
uint32_t time_msec;
- double x_mm, y_mm;
- double width_mm, height_mm;
+ // From 0..1
+ double x, y;
enum wlr_tablet_tool_proximity_state state;
};
@@ -67,8 +67,8 @@ enum wlr_tablet_tool_tip_state {
struct wlr_event_tablet_tool_tip {
struct wlr_input_device *device;
uint32_t time_msec;
- double x_mm, y_mm;
- double width_mm, height_mm;
+ // From 0..1
+ double x, y;
enum wlr_tablet_tool_tip_state state;
};
diff --git a/include/wlr/types/wlr_touch.h b/include/wlr/types/wlr_touch.h
index 8ea293eb..70070f84 100644
--- a/include/wlr/types/wlr_touch.h
+++ b/include/wlr/types/wlr_touch.h
@@ -23,8 +23,8 @@ struct wlr_event_touch_down {
struct wlr_input_device *device;
uint32_t time_msec;
int32_t touch_id;
- double x_mm, y_mm;
- double width_mm, height_mm;
+ // From 0..1
+ double x, y;
};
struct wlr_event_touch_up {
@@ -37,8 +37,8 @@ struct wlr_event_touch_motion {
struct wlr_input_device *device;
uint32_t time_msec;
int32_t touch_id;
- double x_mm, y_mm;
- double width_mm, height_mm;
+ // From 0..1
+ double x, y;
};
struct wlr_event_touch_cancel {
diff --git a/meson.build b/meson.build
index 7740b416..04c93817 100644
--- a/meson.build
+++ b/meson.build
@@ -82,35 +82,40 @@ if elogind.found() and get_option('enable_elogind') != 'false'
endif
if get_option('enable_x11_backend') or get_option('enable_xwayland')
- xcb = dependency('xcb')
- xcb_composite = dependency('xcb-composite')
- xcb_xfixes = dependency('xcb-xfixes')
- xcb_image = dependency('xcb-image')
- xcb_render = dependency('xcb-render')
- x11_xcb = dependency('x11-xcb')
-
- xcb_icccm = dependency('xcb-icccm', required: false)
- xcb_errors = dependency('xcb-errors', required: get_option('enable_xcb_errors') == 'true')
-
- if xcb_icccm.found()
- conf_data.set('WLR_HAS_XCB_ICCCM', true)
- endif
-
- if xcb_errors.found() and get_option('enable_xcb_errors') != 'false'
- conf_data.set('WLR_HAS_XCB_ERRORS', true)
- endif
-
- wlr_deps += [
- xcb,
- xcb_composite,
- x11_xcb,
- ]
+ xcb = dependency('xcb')
+ xcb_composite = dependency('xcb-composite')
+ xcb_xfixes = dependency('xcb-xfixes')
+ xcb_image = dependency('xcb-image')
+ xcb_render = dependency('xcb-render')
+ x11_xcb = dependency('x11-xcb')
+
+ xcb_icccm = dependency('xcb-icccm', required: false)
+ xcb_xkb = dependency('xcb-xkb', required: false)
+ xcb_errors = dependency('xcb-errors', required: get_option('enable_xcb_errors') == 'true')
+
+ if xcb_icccm.found()
+ conf_data.set('WLR_HAS_XCB_ICCCM', true)
+ endif
+
+ if xcb_xkb.found()
+ conf_data.set('WLR_HAS_XCB_XKB', true)
+ endif
+
+ if xcb_errors.found() and get_option('enable_xcb_errors') != 'false'
+ conf_data.set('WLR_HAS_XCB_ERRORS', true)
+ endif
+
+ wlr_deps += [
+ xcb,
+ xcb_composite,
+ x11_xcb,
+ ]
else
- add_project_arguments('-DMESA_EGL_NO_X11_HEADERS', language: 'c')
+ add_project_arguments('-DMESA_EGL_NO_X11_HEADERS', language: 'c')
endif
if get_option('enable_x11_backend')
- conf_data.set('WLR_HAS_X11_BACKEND', true)
+ conf_data.set('WLR_HAS_X11_BACKEND', true)
endif
if get_option('enable_xwayland')
diff --git a/rootston/cursor.c b/rootston/cursor.c
index 52439dff..a5953e4a 100644
--- a/rootston/cursor.c
+++ b/rootston/cursor.c
@@ -288,8 +288,8 @@ void roots_cursor_handle_motion(struct roots_cursor *cursor,
void roots_cursor_handle_motion_absolute(struct roots_cursor *cursor,
struct wlr_event_pointer_motion_absolute *event) {
- wlr_cursor_warp_absolute(cursor->cursor, event->device,
- event->x_mm / event->width_mm, event->y_mm / event->height_mm);
+ wlr_cursor_warp_absolute(cursor->cursor,
+ event->device, event->x, event->y);
roots_cursor_update_position(cursor, event->time_msec);
}
@@ -310,10 +310,8 @@ void roots_cursor_handle_touch_down(struct roots_cursor *cursor,
struct roots_desktop *desktop = cursor->seat->input->server->desktop;
struct wlr_surface *surface = NULL;
double lx, ly;
- bool result =
- wlr_cursor_absolute_to_layout_coords(cursor->cursor,
- event->device, event->x_mm, event->y_mm, event->width_mm,
- event->height_mm, &lx, &ly);
+ bool result = wlr_cursor_absolute_to_layout_coords(cursor->cursor,
+ event->device, event->x, event->y, &lx, &ly);
if (!result) {
return;
}
@@ -365,8 +363,7 @@ void roots_cursor_handle_touch_motion(struct roots_cursor *cursor,
double lx, ly;
bool result =
wlr_cursor_absolute_to_layout_coords(cursor->cursor,
- event->device, event->x_mm, event->y_mm, event->width_mm,
- event->height_mm, &lx, &ly);
+ event->device, event->x, event->y, &lx, &ly);
if (!result) {
return;
}
@@ -395,15 +392,13 @@ void roots_cursor_handle_tool_axis(struct roots_cursor *cursor,
if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X) &&
(event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) {
wlr_cursor_warp_absolute(cursor->cursor, event->device,
- event->x_mm / event->width_mm, event->y_mm / event->height_mm);
+ event->x, event->y);
roots_cursor_update_position(cursor, event->time_msec);
} else if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X)) {
- wlr_cursor_warp_absolute(cursor->cursor, event->device,
- event->x_mm / event->width_mm, -1);
+ wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, -1);
roots_cursor_update_position(cursor, event->time_msec);
} else if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) {
- wlr_cursor_warp_absolute(cursor->cursor, event->device,
- -1, event->y_mm / event->height_mm);
+ wlr_cursor_warp_absolute(cursor->cursor, event->device, -1, event->y);
roots_cursor_update_position(cursor, event->time_msec);
}
}
diff --git a/types/wlr_cursor.c b/types/wlr_cursor.c
index 20acebf1..5142513b 100644
--- a/types/wlr_cursor.c
+++ b/types/wlr_cursor.c
@@ -254,7 +254,7 @@ bool wlr_cursor_warp(struct wlr_cursor *cur, struct wlr_input_device *dev,
}
void wlr_cursor_warp_absolute(struct wlr_cursor *cur,
- struct wlr_input_device *dev, double x_mm, double y_mm) {
+ struct wlr_input_device *dev, double x, double y) {
assert(cur->state->layout);
struct wlr_box *mapping = get_mapping(cur, dev);
@@ -262,8 +262,8 @@ void wlr_cursor_warp_absolute(struct wlr_cursor *cur,
mapping = wlr_output_layout_get_box(cur->state->layout, NULL);
}
- double x = x_mm > 0 ? mapping->width * x_mm + mapping->x : cur->x;
- double y = y_mm > 0 ? mapping->height * y_mm + mapping->y : cur->y;
+ x = x > 0 ? mapping->width * x + mapping->x : cur->x;
+ y = y > 0 ? mapping->height * y + mapping->y : cur->y;
wlr_cursor_warp_unchecked(cur, x, y);
}
@@ -640,19 +640,15 @@ void wlr_cursor_map_input_to_region(struct wlr_cursor *cur,
}
bool wlr_cursor_absolute_to_layout_coords(struct wlr_cursor *cur,
- struct wlr_input_device *device, double x_mm, double y_mm,
- double width_mm, double height_mm, double *lx, double *ly) {
- if (width_mm <= 0 || height_mm <= 0) {
- return false;
- }
-
+ struct wlr_input_device *device, double x, double y,
+ double *lx, double *ly) {
struct wlr_box *mapping = get_mapping(cur, device);
if (!mapping) {
mapping = wlr_output_layout_get_box(cur->state->layout, NULL);
}
- *lx = x_mm > 0 ? mapping->width * (x_mm / width_mm) + mapping->x : cur->x;
- *ly = y_mm > 0 ? mapping->height * (y_mm / height_mm) + mapping->y : cur->y;
+ *lx = x > 0 ? mapping->width * x + mapping->x : cur->x;
+ *ly = y > 0 ? mapping->height * y + mapping->y : cur->y;
return true;
}