ref: 19f4185f3967a5c00053236015da22c0da2af41d
parent: ec1fed3fe2fcc41562b5daf318ca4dce201f1c2a
author: mia soweli <inbox@tachibana-labs.org>
date: Mon Jun 10 07:38:01 EDT 2024
gui-wl: Fix clipped cursors It seems like the pixels along the bottom and right edge of the cursor are clipped off. Work around this by allocating a larger surface than needed, ensuring that the clipped pixels would have been transparent anyway.
--- a/gui-wl/wl-util.c
+++ b/gui-wl/wl-util.c
@@ -54,7 +54,7 @@
depth = 4;
screensize = wl->monx * wl->mony * depth;
- cursorsize = 16 * 16 * depth;
+ cursorsize = 32 * 32 * depth;
fd = wlcreateshm(screensize+cursorsize);
if(fd < 0)
@@ -90,7 +90,7 @@
wl_buffer_destroy(wl->cursorbuffer);
wl->screenbuffer = wl_shm_pool_create_buffer(wl->pool, 0, wl->dx, wl->dy, wl->dx*4, WL_SHM_FORMAT_XRGB8888);
- wl->cursorbuffer = wl_shm_pool_create_buffer(wl->pool, size, 16, 16, 16*4, WL_SHM_FORMAT_ARGB8888);
+ wl->cursorbuffer = wl_shm_pool_create_buffer(wl->pool, size, 32, 32, 32*4, WL_SHM_FORMAT_ARGB8888);
}
enum {
@@ -113,15 +113,15 @@
clr[i] = c->clr[j]<<8 | c->clr[j+1];
set[i] = c->set[j]<<8 | c->set[j+1];
}
- for(i=0; i < 16; i++){
- for(j = 0; j < 16; j++){
- pos = i*16 + j;
+ for(i=0; i < 32; i++){
+ for(j = 0; j < 32; j++){
+ pos = i*32 + j;
mask = (1<<16) >> j;
buf[pos] = Transparent;
- if(clr[i] & mask)
+ if(i < 16 && clr[i] & mask)
buf[pos] = White;
- if(set[i] & mask)
+ if(i < 16 && set[i] & mask)
buf[pos] = Black;
}
}
@@ -128,7 +128,7 @@
if(wl->cursorsurface == nil)
wl->cursorsurface = wl_compositor_create_surface(wl->compositor);
wl_surface_attach(wl->cursorsurface, wl->cursorbuffer, 0, 0);
- wl_surface_damage(wl->cursorsurface, 0, 0, 16, 16);
+ wl_surface_damage(wl->cursorsurface, 0, 0, 32, 32);
wl_surface_commit(wl->cursorsurface);
wl_pointer_set_cursor(wl->pointer, wl->pointerserial, wl->cursorsurface, -c->offset.x, -c->offset.y);
}