aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/drm/drm.c43
-rw-r--r--backend/wayland/output.c11
-rw-r--r--backend/wayland/wl_seat.c2
-rw-r--r--examples/pointer.c3
-rw-r--r--include/backend/wayland.h3
-rw-r--r--include/wlr/interfaces/wlr_output.h3
-rw-r--r--include/wlr/types/wlr_output.h4
-rw-r--r--rootston/output.c3
-rw-r--r--types/wlr_cursor.c14
-rw-r--r--types/wlr_output.c8
10 files changed, 65 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/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..e834f8b4 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,
diff --git a/examples/pointer.c b/examples/pointer.c
index 11f67f9b..238be9b3 100644
--- a/examples/pointer.c
+++ b/examples/pointer.c
@@ -112,7 +112,8 @@ static void handle_output_add(struct output_state *ostate) {
// TODO the cursor must be set depending on which surface it is displayed
// over which should happen in the compositor.
if (!wlr_output_set_cursor(wlr_output, image->buffer,
- image->width, image->width, image->height)) {
+ image->width, image->width, image->height,
+ image->hotspot_x, image->hotspot_y)) {
wlr_log(L_DEBUG, "Failed to set hardware cursor");
return;
}
diff --git a/include/backend/wayland.h b/include/backend/wayland.h
index 752dab69..508a7f52 100644
--- a/include/backend/wayland.h
+++ b/include/backend/wayland.h
@@ -67,7 +67,8 @@ struct wlr_wl_pointer {
};
void wlr_wl_registry_poll(struct wlr_wl_backend *backend);
-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);
struct wlr_wl_backend_output *wlr_wl_output_for_surface(
struct wlr_wl_backend *backend, struct wl_surface *surface);
diff --git a/include/wlr/interfaces/wlr_output.h b/include/wlr/interfaces/wlr_output.h
index 7ed19ed9..7d2821e0 100644
--- a/include/wlr/interfaces/wlr_output.h
+++ b/include/wlr/interfaces/wlr_output.h
@@ -10,7 +10,8 @@ struct wlr_output_impl {
void (*transform)(struct wlr_output *output,
enum wl_output_transform transform);
bool (*set_cursor)(struct wlr_output *output, const uint8_t *buf,
- int32_t stride, uint32_t width, uint32_t height);
+ int32_t stride, uint32_t width, uint32_t height,
+ int32_t hotspot_x, int32_t hotspot_y);
bool (*move_cursor)(struct wlr_output *output, int x, int y);
void (*destroy)(struct wlr_output *output);
void (*make_current)(struct wlr_output *output);
diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h
index 3208acac..1fa6ad9e 100644
--- a/include/wlr/types/wlr_output.h
+++ b/include/wlr/types/wlr_output.h
@@ -45,6 +45,7 @@ struct wlr_output {
bool is_sw;
int32_t x, y;
uint32_t width, height;
+ int32_t hotspot_x, hotspot_y;
struct wlr_renderer *renderer;
struct wlr_texture *texture;
} cursor;
@@ -58,7 +59,8 @@ bool wlr_output_set_mode(struct wlr_output *output,
void wlr_output_transform(struct wlr_output *output,
enum wl_output_transform transform);
bool wlr_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);
bool wlr_output_move_cursor(struct wlr_output *output, int x, int y);
void wlr_output_destroy(struct wlr_output *output);
void wlr_output_effective_resolution(struct wlr_output *output,
diff --git a/rootston/output.c b/rootston/output.c
index d7aade3d..c6627182 100644
--- a/rootston/output.c
+++ b/rootston/output.c
@@ -145,7 +145,8 @@ void output_add_notify(struct wl_listener *listener, void *data) {
// TODO the cursor must be set depending on which surface it is displayed
// over which should happen in the compositor.
if (!wlr_output_set_cursor(wlr_output, image->buffer,
- image->width, image->width, image->height)) {
+ image->width, image->width, image->height,
+ image->hotspot_x, image->hotspot_y)) {
wlr_log(L_DEBUG, "Failed to set hardware cursor");
return;
}
diff --git a/types/wlr_cursor.c b/types/wlr_cursor.c
index 79972745..20781f0a 100644
--- a/types/wlr_cursor.c
+++ b/types/wlr_cursor.c
@@ -131,15 +131,6 @@ static struct wlr_cursor_device *get_cursor_device(struct wlr_cursor *cur,
static void wlr_cursor_warp_unchecked(struct wlr_cursor *cur,
double x, double y) {
assert(cur->state->layout);
- int hotspot_x = 0;
- int hotspot_y = 0;
-
- if (cur->state->xcursor && cur->state->xcursor->image_count > 0) {
- struct wlr_xcursor_image *image = cur->state->xcursor->images[0];
- hotspot_x = image->hotspot_x;
- hotspot_y = image->hotspot_y;
- }
-
struct wlr_output_layout_output *l_output;
wl_list_for_each(l_output, &cur->state->layout->outputs, link) {
@@ -148,8 +139,9 @@ static void wlr_cursor_warp_unchecked(struct wlr_cursor *cur,
wlr_output_layout_output_coords(cur->state->layout,
l_output->output, &output_x, &output_y);
- wlr_output_move_cursor(l_output->output, output_x - hotspot_x,
- output_y - hotspot_y);
+ wlr_output_move_cursor(l_output->output,
+ output_x - l_output->output->cursor.hotspot_x,
+ output_y - l_output->output->cursor.hotspot_y);
}
cur->x = x;
diff --git a/types/wlr_output.c b/types/wlr_output.c
index 962685b8..6149cd3c 100644
--- a/types/wlr_output.c
+++ b/types/wlr_output.c
@@ -125,9 +125,11 @@ void wlr_output_transform(struct wlr_output *output,
}
bool wlr_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) {
if (output->impl->set_cursor
- && output->impl->set_cursor(output, buf, stride, width, height)) {
+ && output->impl->set_cursor(output, buf, stride, width, height,
+ hotspot_x, hotspot_y)) {
output->cursor.is_sw = false;
return true;
}
@@ -137,6 +139,8 @@ bool wlr_output_set_cursor(struct wlr_output *output,
output->cursor.is_sw = true;
output->cursor.width = width;
output->cursor.height = height;
+ output->cursor.hotspot_x = hotspot_x;
+ output->cursor.hotspot_y = hotspot_y;
if (!output->cursor.renderer) {
/* NULL egl is okay given that we are only using pixel buffers */