commit 2f66cea79eeaedc586f57faa0c1af32094863695
parent 6d8f36c22ff7dbeac1e114545a3f4655c486c132
Author: Michael Forney <mforney@mforney.org>
Date: Sun, 25 Nov 2018 22:31:36 -0800
drm: Query cursor size from driver
Diffstat:
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/libswc/drm.c b/libswc/drm.c
@@ -252,6 +252,7 @@ bind_drm(struct wl_client *client, void *data, uint32_t version, uint32_t id)
bool
drm_initialize(void)
{
+ uint64_t val;
char primary[128];
if (!find_primary_drm_device(primary, sizeof(primary))) {
@@ -265,6 +266,12 @@ drm_initialize(void)
ERROR("Could not open DRM device at %s\n", primary);
goto error0;
}
+ if (drmGetCap(swc.drm->fd, DRM_CAP_CURSOR_WIDTH, &val) < 0)
+ val = 64;
+ swc.drm->cursor_w = val;
+ if (drmGetCap(swc.drm->fd, DRM_CAP_CURSOR_HEIGHT, &val) < 0)
+ val = 64;
+ swc.drm->cursor_h = val;
drm.path = drmGetRenderDeviceNameFromFd(swc.drm->fd);
if (!drm.path) {
diff --git a/libswc/drm.h b/libswc/drm.h
@@ -12,6 +12,7 @@ struct drm_handler {
struct swc_drm {
int fd;
+ uint32_t cursor_w, cursor_h;
struct wld_context *context;
struct wld_renderer *renderer;
};
diff --git a/libswc/pointer.c b/libswc/pointer.c
@@ -91,7 +91,7 @@ attach(struct view *view, struct wld_buffer *buffer)
return 0;
wld_set_target_buffer(swc.shm->renderer, pointer->cursor.buffer);
- wld_fill_rectangle(swc.shm->renderer, 0x00000000, 0, 0, 64, 64);
+ wld_fill_rectangle(swc.shm->renderer, 0x00000000, 0, 0, pointer->cursor.buffer->width, pointer->cursor.buffer->height);
if (buffer)
wld_copy_rectangle(swc.shm->renderer, buffer, 0, 0, 0, 0, buffer->width, buffer->height);
@@ -234,7 +234,7 @@ pointer_initialize(struct pointer *pointer)
view_initialize(&pointer->cursor.view, &view_impl);
pointer->cursor.surface = NULL;
pointer->cursor.destroy_listener.notify = &handle_cursor_surface_destroy;
- pointer->cursor.buffer = wld_create_buffer(swc.drm->context, 64, 64, WLD_FORMAT_ARGB8888, WLD_FLAG_MAP);
+ pointer->cursor.buffer = wld_create_buffer(swc.drm->context, swc.drm->cursor_w, swc.drm->cursor_h, WLD_FORMAT_ARGB8888, WLD_FLAG_MAP);
pointer->cursor.internal_buffer = NULL;
if (!pointer->cursor.buffer)