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.
This commit is contained in:
Kovid Goyal 2018-10-11 13:39:44 +05:30
parent 6c4aeeeadd
commit b4afbe47b3
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

14
glfw/wl_init.c vendored
View File

@ -29,6 +29,8 @@
#include "backend_utils.h"
#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <linux/input.h>
#include <stdio.h>
#include <stdlib.h>
@ -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,