mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 04:45:58 +01:00
xcursor: support XDG Base Directory Specification
This patch adds ~/.local/share/icons to the search path, so user-specific themes can be loaded through the API provided by libwayland-cursor. Use this PR as reference: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/112
This commit is contained in:
parent
f330759ba4
commit
2dd121235e
1 changed files with 38 additions and 13 deletions
|
@ -622,18 +622,43 @@ XcursorFileLoadImages (FILE *file, int size)
|
||||||
#define XCURSORPATH "~/.local/share/icons:~/.icons:/usr/share/icons:/usr/share/pixmaps:~/.cursors:/usr/share/cursors/xorg-x11:"ICONDIR
|
#define XCURSORPATH "~/.local/share/icons:~/.icons:/usr/share/icons:/usr/share/pixmaps:~/.cursors:/usr/share/cursors/xorg-x11:"ICONDIR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char *
|
#define XDG_DATA_HOME_FALLBACK "~/.local/share"
|
||||||
|
#define CURSORDIR "/icons"
|
||||||
|
|
||||||
|
/** Get search path for cursor themes
|
||||||
|
*
|
||||||
|
* This function builds the list of directories to look for cursor
|
||||||
|
* themes in. The format is PATH-like: directories are separated by
|
||||||
|
* colons.
|
||||||
|
*
|
||||||
|
* The memory block returned by this function is allocated on the heap
|
||||||
|
* and must be freed by the caller.
|
||||||
|
*/
|
||||||
|
static char *
|
||||||
XcursorLibraryPath (void)
|
XcursorLibraryPath (void)
|
||||||
{
|
{
|
||||||
static const char *path;
|
const char *env_var;
|
||||||
|
char *path = NULL;
|
||||||
|
int pathlen = 0;
|
||||||
|
|
||||||
if (!path)
|
env_var = getenv("XCURSOR_PATH");
|
||||||
{
|
if (env_var) {
|
||||||
path = getenv ("XCURSOR_PATH");
|
path = strdup(env_var);
|
||||||
if (!path)
|
}
|
||||||
path = XCURSORPATH;
|
else {
|
||||||
}
|
env_var = getenv("XDG_DATA_HOME");
|
||||||
return path;
|
if (env_var) {
|
||||||
|
pathlen = strlen(env_var) +
|
||||||
|
strlen(CURSORDIR ":" XCURSORPATH) + 1;
|
||||||
|
path = malloc(pathlen);
|
||||||
|
snprintf(path, pathlen, "%s%s", env_var,
|
||||||
|
CURSORDIR ":" XCURSORPATH);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
path = strdup(XDG_DATA_HOME_FALLBACK ":" XCURSORPATH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -866,14 +891,13 @@ xcursor_load_theme(const char *theme, int size,
|
||||||
{
|
{
|
||||||
char *full, *dir;
|
char *full, *dir;
|
||||||
char *inherits = NULL;
|
char *inherits = NULL;
|
||||||
|
char *xcursor_path = NULL;
|
||||||
const char *path, *i;
|
const char *path, *i;
|
||||||
|
|
||||||
if (!theme)
|
if (!theme)
|
||||||
theme = "default";
|
theme = "default";
|
||||||
|
xcursor_path = XcursorLibraryPath();
|
||||||
for (path = XcursorLibraryPath();
|
for (path = xcursor_path; path; path = _XcursorNextPath(path)) {
|
||||||
path;
|
|
||||||
path = _XcursorNextPath(path)) {
|
|
||||||
dir = _XcursorBuildThemeDir(path, theme);
|
dir = _XcursorBuildThemeDir(path, theme);
|
||||||
if (!dir)
|
if (!dir)
|
||||||
continue;
|
continue;
|
||||||
|
@ -902,4 +926,5 @@ xcursor_load_theme(const char *theme, int size,
|
||||||
|
|
||||||
if (inherits)
|
if (inherits)
|
||||||
free(inherits);
|
free(inherits);
|
||||||
|
free(xcursor_path);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue