aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
Diffstat (limited to 'backend')
-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
8 files changed, 66 insertions, 25 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);