mirror of
https://github.com/glfw/glfw.git
synced 2024-11-10 00:51:47 +00:00
Wayland: Clean up cursor theme loading
This commit is contained in:
parent
71be34a6c3
commit
6987294df9
@ -337,35 +337,32 @@ static void createKeyTables(void)
|
|||||||
|
|
||||||
static GLFWbool loadCursorTheme(void)
|
static GLFWbool loadCursorTheme(void)
|
||||||
{
|
{
|
||||||
const char* cursorTheme;
|
int cursorSize = 32;
|
||||||
const char* cursorSizeStr;
|
|
||||||
char* cursorSizeEnd;
|
|
||||||
long cursorSizeLong;
|
|
||||||
int cursorSize;
|
|
||||||
|
|
||||||
cursorTheme = getenv("XCURSOR_THEME");
|
const char* sizeString = getenv("XCURSOR_SIZE");
|
||||||
cursorSizeStr = getenv("XCURSOR_SIZE");
|
if (sizeString)
|
||||||
cursorSize = 32;
|
|
||||||
if (cursorSizeStr)
|
|
||||||
{
|
{
|
||||||
errno = 0;
|
errno = 0;
|
||||||
cursorSizeLong = strtol(cursorSizeStr, &cursorSizeEnd, 10);
|
const long cursorSizeLong = strtol(sizeString, NULL, 10);
|
||||||
if (!*cursorSizeEnd && !errno && cursorSizeLong > 0 && cursorSizeLong <= INT_MAX)
|
if (errno == 0 && cursorSizeLong > 0 && cursorSizeLong < INT_MAX)
|
||||||
cursorSize = (int) cursorSizeLong;
|
cursorSize = (int) cursorSizeLong;
|
||||||
}
|
}
|
||||||
_glfw.wl.cursorTheme =
|
|
||||||
wl_cursor_theme_load(cursorTheme, cursorSize, _glfw.wl.shm);
|
const char* themeName = getenv("XCURSOR_THEME");
|
||||||
|
|
||||||
|
_glfw.wl.cursorTheme = wl_cursor_theme_load(themeName, cursorSize, _glfw.wl.shm);
|
||||||
if (!_glfw.wl.cursorTheme)
|
if (!_glfw.wl.cursorTheme)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"Wayland: Failed to load default cursor theme");
|
"Wayland: Failed to load default cursor theme");
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this happens to be NULL, we just fallback to the scale=1 version.
|
// If this happens to be NULL, we just fallback to the scale=1 version.
|
||||||
_glfw.wl.cursorThemeHiDPI =
|
_glfw.wl.cursorThemeHiDPI =
|
||||||
wl_cursor_theme_load(cursorTheme, 2 * cursorSize, _glfw.wl.shm);
|
wl_cursor_theme_load(themeName, cursorSize * 2, _glfw.wl.shm);
|
||||||
_glfw.wl.cursorSurface =
|
|
||||||
wl_compositor_create_surface(_glfw.wl.compositor);
|
_glfw.wl.cursorSurface = wl_compositor_create_surface(_glfw.wl.compositor);
|
||||||
_glfw.wl.cursorTimerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
|
_glfw.wl.cursorTimerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user