Fix incorrect cursor size on Wayland with the RIVER compositor

Use XCURSOR_THEME & XCURSOR_SIZE environment variables for Wayland.
While this isn't an official part of the spec, many Wayland compositors
& applications use these variables.
This commit is contained in:
Campbell Barton 2023-03-22 11:09:11 +11:00
parent dd0d572935
commit cf82e5fe57

View file

@ -4275,8 +4275,26 @@ static void gwl_seat_capability_pointer_enable(GWL_Seat *seat)
seat->cursor.visible = true;
seat->cursor.wl_buffer = nullptr;
if (!get_cursor_settings(seat->cursor.theme_name, seat->cursor.theme_size)) {
seat->cursor.theme_name = std::string();
/* Use environment variables, falling back to defaults.
* These environment variables are used by enough WAYLAND applications
* that it makes sense to check them (see `Xcursor` man page). */
const char *env;
env = getenv("XCURSOR_THEME");
seat->cursor.theme_name = std::string(env ? env : "");
env = getenv("XCURSOR_SIZE");
seat->cursor.theme_size = default_cursor_size;
if (env && (*env != '\0')) {
char *env_end = nullptr;
/* While clamping is not needed on the WAYLAND side,
* GHOST's internal logic may get confused by negative values, so ensure it's at least 1. */
const long value = strtol(env, &env_end, 10);
if ((*env_end == '\0') && (value > 0)) {
seat->cursor.theme_size = int(value);
}
}
}
wl_pointer_add_listener(seat->wl_pointer, &pointer_listener, seat);