diff options
author | emersion <contact@emersion.fr> | 2018-10-10 19:59:04 +0200 |
---|---|---|
committer | wm4 <1387750+wm4@users.noreply.github.com> | 2019-09-21 15:43:54 +0200 |
commit | 600824494de1fd241e57836195bc67c15657b3b3 (patch) | |
tree | 53df0027824488dda4c7074c602058ed3805b37d /video/out/wayland_common.c | |
parent | 8f35b3873f5d99120ac8edec8f36d393f8a81b11 (diff) | |
download | mpv-600824494de1fd241e57836195bc67c15657b3b3.tar.bz2 mpv-600824494de1fd241e57836195bc67c15657b3b3.tar.xz |
wayland: read xcursor size from XCURSOR_SIZE env
This allows compositors to set the cursor size from user
configuration.
Diffstat (limited to 'video/out/wayland_common.c')
-rw-r--r-- | video/out/wayland_common.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index 34adac5bd1..5af8abdb19 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -15,6 +15,8 @@ * License along with mpv. If not, see <http://www.gnu.org/licenses/>. */ +#include <errno.h> +#include <limits.h> #include <poll.h> #include <unistd.h> #include <linux/input.h> @@ -51,7 +53,17 @@ static int spawn_cursor(struct vo_wayland_state *wl) else if (wl->cursor_theme) wl_cursor_theme_destroy(wl->cursor_theme); - wl->cursor_theme = wl_cursor_theme_load(NULL, 32*wl->scaling, wl->shm); + const char *size_str = getenv("XCURSOR_SIZE"); + int size = 32; + if (size_str != NULL) { + errno = 0; + char *end; + long size_long = strtol(size_str, &end, 10); + if (!*end && !errno && size_long > 0 && size_long <= INT_MAX) + size = (int)size_long; + } + + wl->cursor_theme = wl_cursor_theme_load(NULL, size*wl->scaling, wl->shm); if (!wl->cursor_theme) { MP_ERR(wl, "Unable to load cursor theme!\n"); return 1; |