From b4afbe47b38bec93063c3e93af64a7070cac639f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 11 Oct 2018 13:39:44 +0530 Subject: [PATCH] wayland: add support for XCURSOR_THEME and XCURSOR_SIZE These can be set by the compositor or the user to configure the xcursor theme and size. --- glfw/wl_init.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/glfw/wl_init.c b/glfw/wl_init.c index ca3904e9f..7f918f04c 100644 --- a/glfw/wl_init.c +++ b/glfw/wl_init.c @@ -29,6 +29,8 @@ #include "backend_utils.h" #include +#include +#include #include #include #include @@ -720,7 +722,17 @@ int _glfwPlatformInit(void) if (_glfw.wl.pointer && _glfw.wl.shm) { - _glfw.wl.cursorTheme = wl_cursor_theme_load(NULL, 32, _glfw.wl.shm); + const char *cursorTheme = getenv("XCURSOR_THEME"), *cursorSizeStr = getenv("XCURSOR_SIZE"); + char *cursorSizeEnd; + int cursorSize = 32; + if (cursorSizeStr) + { + errno = 0; + long cursorSizeLong = strtol(cursorSizeStr, &cursorSizeEnd, 10); + if (!*cursorSizeEnd && !errno && cursorSizeLong > 0 && cursorSizeLong <= INT_MAX) + cursorSize = (int)cursorSizeLong; + } + _glfw.wl.cursorTheme = wl_cursor_theme_load(cursorTheme, cursorSize, _glfw.wl.shm); if (!_glfw.wl.cursorTheme) { _glfwInputError(GLFW_PLATFORM_ERROR,