aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
Diffstat (limited to 'backend')
-rw-r--r--backend/drm/drm.c43
-rw-r--r--backend/drm/renderer.c3
-rw-r--r--backend/libinput/keyboard.c3
-rw-r--r--backend/meson.build2
-rw-r--r--backend/wayland/output.c11
-rw-r--r--backend/wayland/wl_seat.c9
-rw-r--r--backend/x11/backend.c44
7 files changed, 86 insertions, 29 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index fc376b54..9e5346a1 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -469,7 +469,8 @@ static void wlr_drm_connector_transform(struct wlr_output *output,
}
static bool wlr_drm_connector_set_cursor(struct wlr_output *output,
- const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height) {
+ const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height,
+ int32_t hotspot_x, int32_t hotspot_y) {
struct wlr_drm_connector *conn = (struct wlr_drm_connector *)output;
struct wlr_drm_backend *drm = conn->drm;
struct wlr_drm_renderer *renderer = &drm->renderer;
@@ -534,6 +535,37 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output,
}
}
+ switch (output->transform) {
+ case WL_OUTPUT_TRANSFORM_90:
+ output->cursor.hotspot_x = hotspot_x;
+ output->cursor.hotspot_y = -plane->surf.height + hotspot_y;
+ break;
+ case WL_OUTPUT_TRANSFORM_180:
+ output->cursor.hotspot_x = plane->surf.width - hotspot_x;
+ output->cursor.hotspot_y = plane->surf.height - hotspot_y;
+ break;
+ case WL_OUTPUT_TRANSFORM_270:
+ output->cursor.hotspot_x = -plane->surf.height + hotspot_x;
+ output->cursor.hotspot_y = hotspot_y;
+ break;
+ case WL_OUTPUT_TRANSFORM_FLIPPED:
+ output->cursor.hotspot_x = plane->surf.width - hotspot_x;
+ output->cursor.hotspot_y = hotspot_y;
+ break;
+ case WL_OUTPUT_TRANSFORM_FLIPPED_90:
+ output->cursor.hotspot_x = hotspot_x;
+ output->cursor.hotspot_y = -hotspot_y;
+ break;
+ case WL_OUTPUT_TRANSFORM_FLIPPED_180:
+ output->cursor.hotspot_x = hotspot_x;
+ output->cursor.hotspot_y = plane->surf.height - hotspot_y;
+ break;
+ case WL_OUTPUT_TRANSFORM_FLIPPED_270:
+ output->cursor.hotspot_x = -plane->surf.height + hotspot_x;
+ output->cursor.hotspot_y = plane->surf.width - hotspot_y;
+ break;
+ }
+
struct gbm_bo *bo = plane->cursor_bo;
uint32_t bo_width = gbm_bo_get_width(bo);
uint32_t bo_height = gbm_bo_get_height(bo);
@@ -581,23 +613,22 @@ static bool wlr_drm_connector_move_cursor(struct wlr_output *output,
switch (output->transform) {
case WL_OUTPUT_TRANSFORM_NORMAL:
+ case WL_OUTPUT_TRANSFORM_FLIPPED:
+ case WL_OUTPUT_TRANSFORM_FLIPPED_180:
// nothing to do
break;
case WL_OUTPUT_TRANSFORM_270:
+ case WL_OUTPUT_TRANSFORM_FLIPPED_270:
tmp = x;
x = y;
y = -(tmp - width);
break;
case WL_OUTPUT_TRANSFORM_90:
+ case WL_OUTPUT_TRANSFORM_FLIPPED_90:
tmp = x;
x = -(y - height);
y = tmp;
break;
- default:
- // TODO other transformations
- wlr_log(L_ERROR, "TODO: handle surface to crtc for transformation = %d",
- output->transform);
- break;
}
return drm->iface->crtc_move_cursor(drm, conn->crtc, x, y);
diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c
index c5840436..0d338490 100644
--- a/backend/drm/renderer.c
+++ b/backend/drm/renderer.c
@@ -14,6 +14,7 @@
#include <wlr/render/gles2.h>
#include <wlr/render.h>
#include "backend/drm/drm.h"
+#include "render/glapi.h"
bool wlr_drm_renderer_init(struct wlr_drm_backend *drm,
struct wlr_drm_renderer *renderer) {
@@ -191,7 +192,7 @@ static struct wlr_texture *get_tex_for_bo(struct wlr_drm_renderer *renderer, str
EGL_NONE,
};
- tex->img = renderer->egl.eglCreateImageKHR(renderer->egl.display, EGL_NO_CONTEXT,
+ tex->img = eglCreateImageKHR(renderer->egl.display, EGL_NO_CONTEXT,
EGL_LINUX_DMA_BUF_EXT, NULL, attribs);
if (!tex->img) {
wlr_log(L_ERROR, "Failed to create EGL image: %s", egl_error());
diff --git a/backend/libinput/keyboard.c b/backend/libinput/keyboard.c
index 53c3a61b..00a7ecdf 100644
--- a/backend/libinput/keyboard.c
+++ b/backend/libinput/keyboard.c
@@ -67,5 +67,6 @@ void handle_keyboard_key(struct libinput_event *event,
wlr_event.state = WLR_KEY_PRESSED;
break;
}
- wlr_keyboard_update_state(wlr_dev->keyboard, &wlr_event);
+ wlr_event.update_state = true;
+ wlr_keyboard_notify_key(wlr_dev->keyboard, &wlr_event);
}
diff --git a/backend/meson.build b/backend/meson.build
index c5c73288..cf62a56f 100644
--- a/backend/meson.build
+++ b/backend/meson.build
@@ -38,5 +38,5 @@ lib_wlr_backend = static_library(
'wlr_backend',
backend_files,
include_directories: wlr_inc,
- dependencies: [wayland_server, egl, gbm, libinput, systemd, elogind, wlr_protos],
+ dependencies: [wayland_server, egl, gbm, libinput, systemd, elogind, wlr_render, wlr_protos],
)
diff --git a/backend/wayland/output.c b/backend/wayland/output.c
index ba04aede..062a91a1 100644
--- a/backend/wayland/output.c
+++ b/backend/wayland/output.c
@@ -53,7 +53,8 @@ static void wlr_wl_output_transform(struct wlr_output *_output,
}
static bool wlr_wl_output_set_cursor(struct wlr_output *_output,
- const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height) {
+ const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height,
+ int32_t hotspot_x, int32_t hotspot_y) {
struct wlr_wl_backend_output *output = (struct wlr_wl_backend_output *)_output;
struct wlr_wl_backend *backend = output->backend;
@@ -110,7 +111,8 @@ static bool wlr_wl_output_set_cursor(struct wlr_output *_output,
wl_surface_damage(output->cursor_surface, 0, 0, width, height);
wl_surface_commit(output->cursor_surface);
- wlr_wl_output_update_cursor(output, output->enter_serial);
+ wlr_wl_output_update_cursor(output, output->enter_serial,
+ hotspot_x, hotspot_y);
return true;
}
@@ -143,10 +145,11 @@ static void wlr_wl_output_destroy(struct wlr_output *_output) {
free(output);
}
-void wlr_wl_output_update_cursor(struct wlr_wl_backend_output *output, uint32_t serial) {
+void wlr_wl_output_update_cursor(struct wlr_wl_backend_output *output,
+ uint32_t serial, int32_t hotspot_x, int32_t hotspot_y) {
if (output->cursor_surface && output->backend->pointer && serial) {
wl_pointer_set_cursor(output->backend->pointer, serial,
- output->cursor_surface, 0, 0);
+ output->cursor_surface, hotspot_x, hotspot_y);
}
}
diff --git a/backend/wayland/wl_seat.c b/backend/wayland/wl_seat.c
index ba3feb8d..d3ff9b64 100644
--- a/backend/wayland/wl_seat.c
+++ b/backend/wayland/wl_seat.c
@@ -24,7 +24,7 @@ static void pointer_handle_enter(void *data, struct wl_pointer *wl_pointer,
assert(output);
wlr_wl_pointer->current_output = output;
wlr_wl_pointer->current_output->enter_serial = serial;
- wlr_wl_output_update_cursor(wlr_wl_pointer->current_output, serial);
+ wlr_wl_output_update_cursor(wlr_wl_pointer->current_output, serial, 0, 0);
}
static void pointer_handle_leave(void *data, struct wl_pointer *wl_pointer,
@@ -149,13 +149,16 @@ static void keyboard_handle_key(void *data, struct wl_keyboard *wl_keyboard,
wlr_event.state = state;
wlr_event.time_sec = time / 1000;
wlr_event.time_usec = time * 1000;
- wlr_keyboard_update_state(dev->keyboard, &wlr_event);
+ wlr_keyboard_notify_key(dev->keyboard, &wlr_event);
}
static void keyboard_handle_modifiers(void *data, struct wl_keyboard *wl_keyboard,
uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched,
uint32_t mods_locked, uint32_t group) {
-
+ struct wlr_input_device *dev = data;
+ assert(dev && dev->keyboard);
+ wlr_keyboard_notify_modifiers(dev->keyboard, mods_depressed, mods_latched,
+ mods_locked, group);
}
static void keyboard_handle_repeat_info(void *data, struct wl_keyboard *wl_keyboard,
diff --git a/backend/x11/backend.c b/backend/x11/backend.c
index 88c022d1..1eb5a952 100644
--- a/backend/x11/backend.c
+++ b/backend/x11/backend.c
@@ -47,29 +47,46 @@ static bool handle_x11_event(struct wlr_x11_backend *x11, xcb_generic_event_t *e
xcb_key_press_event_t *ev = (xcb_key_press_event_t *)event;
struct wlr_event_keyboard_key key = {
.time_sec = ev->time / 1000,
- .time_usec = (ev->time % 1000) * 1000,
+ .time_usec = ev->time * 1000,
.keycode = ev->detail - 8,
.state = event->response_type == XCB_KEY_PRESS ?
WLR_KEY_PRESSED : WLR_KEY_RELEASED,
+ .update_state = true,
};
- wl_signal_emit(&x11->keyboard.events.key, &key);
+ // TODO use xcb-xkb for more precise modifiers state?
+ wlr_keyboard_notify_key(&x11->keyboard, &key);
x11->time = ev->time;
break;
}
case XCB_BUTTON_PRESS:
case XCB_BUTTON_RELEASE: {
xcb_button_press_event_t *ev = (xcb_button_press_event_t *)event;
- struct wlr_event_pointer_button button = {
- .device = &x11->pointer_dev,
- .time_sec = ev->time / 1000,
- .time_usec = (ev->time % 1000) * 1000,
- .button = xcb_button_to_wl(ev->detail),
- .state = event->response_type == XCB_BUTTON_PRESS ?
- WLR_BUTTON_PRESSED : WLR_BUTTON_RELEASED,
- };
- wl_signal_emit(&x11->pointer.events.button, &button);
+ if (ev->detail == XCB_BUTTON_INDEX_4 ||
+ ev->detail == XCB_BUTTON_INDEX_5) {
+ double delta = (ev->detail == XCB_BUTTON_INDEX_4 ? -15 : 15);
+ struct wlr_event_pointer_axis axis = {
+ .device = &x11->pointer_dev,
+ .time_sec = ev->time / 1000,
+ .time_usec = ev->time * 1000,
+ .source = WLR_AXIS_SOURCE_WHEEL,
+ .orientation = WLR_AXIS_ORIENTATION_VERTICAL,
+ .delta = delta,
+ };
+ wl_signal_emit(&x11->pointer.events.axis, &axis);
+ } else {
+ struct wlr_event_pointer_button button = {
+ .device = &x11->pointer_dev,
+ .time_sec = ev->time / 1000,
+ .time_usec = ev->time * 1000,
+ .button = xcb_button_to_wl(ev->detail),
+ .state = event->response_type == XCB_BUTTON_PRESS ?
+ WLR_BUTTON_PRESSED : WLR_BUTTON_RELEASED,
+ };
+
+ wl_signal_emit(&x11->pointer.events.button, &button);
+ }
x11->time = ev->time;
break;
}
@@ -78,7 +95,7 @@ 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_sec = ev->time / 1000,
- .time_usec = (ev->time % 1000) * 1000,
+ .time_usec = ev->time * 1000,
.x_mm = ev->event_x,
.y_mm = ev->event_y,
.width_mm = output->wlr_output.width,
@@ -109,7 +126,7 @@ 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_sec = x11->time / 1000,
- .time_usec = (x11->time % 1000) * 1000,
+ .time_usec = x11->time * 1000,
.x_mm = pointer->root_x,
.y_mm = pointer->root_y,
.width_mm = output->wlr_output.width,
@@ -258,6 +275,7 @@ static bool wlr_x11_backend_start(struct wlr_backend *backend) {
xcb_map_window(x11->xcb_conn, output->win);
xcb_flush(x11->xcb_conn);
+ wlr_output_create_global(&output->wlr_output, x11->wl_display);
wl_signal_emit(&x11->backend.events.output_add, output);
wl_signal_emit(&x11->backend.events.input_add, &x11->keyboard_dev);