aboutsummaryrefslogtreecommitdiff
path: root/backend/x11
diff options
context:
space:
mode:
authorIlia Mirkin <imirkin@alum.mit.edu>2021-02-06 16:15:46 -0500
committerSimon Ser <contact@emersion.fr>2021-03-09 22:27:07 +0100
commit10dbb00f5ffe0f598e52e0e839a5f145822d03d7 (patch)
treeac8b06ed3073a5cf5811d3dc623b8a455ccc3049 /backend/x11
parent7dffe9339bf8a92a556098d86712c4c38ac95226 (diff)
backend/x11: clamp hotspot to texture bounds
When a new texture is set, the hotspot may actually belong to the previous texture and be out of bounds. Rather than incur X errors for these, clamp the hotspot to be inside of the texture. This fixes weston examples updating their cursors (e.g. weston-eventdemo).
Diffstat (limited to 'backend/x11')
-rw-r--r--backend/x11/output.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/backend/x11/output.c b/backend/x11/output.c
index 788be957..ef2d1c13 100644
--- a/backend/x11/output.c
+++ b/backend/x11/output.c
@@ -477,6 +477,19 @@ static bool output_set_cursor(struct wlr_output *wlr_output,
if (texture != NULL) {
width = texture->width * wlr_output->scale / scale;
height = texture->height * wlr_output->scale / scale;
+
+ if (hotspot_x < 0) {
+ hotspot_x = 0;
+ }
+ if ((uint32_t)hotspot_x > texture->width) {
+ hotspot_x = texture->width;
+ }
+ if (hotspot_y < 0) {
+ hotspot_y = 0;
+ }
+ if ((uint32_t)hotspot_y > texture->height) {
+ hotspot_y = texture->height;
+ }
}
struct wlr_box hotspot = { .x = hotspot_x, .y = hotspot_y };