[PATCH weston] window: allow changing cursor theme and size
Pekka Paalanen
ppaalanen at gmail.com
Mon May 14 04:01:50 PDT 2012
Toytoolkit clients will now use two new environment variables:
TOYTOOLKIT_CURSOR_THEME=theme
TOYTOOLKTI_CURSOR_SIZE=size
where 'theme' can be e.g. whiteglass if you have the basic X.Org cursor
themes installed. 'size' is a cursor size hint 4-64, by default 32.
See the Xcursor man page for how cursors are found for a theme.
Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
---
clients/window.c | 23 ++++++++++++++++++++---
1 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/clients/window.c b/clients/window.c
index e14edb0..63e57f7 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -702,16 +702,33 @@ create_cursors(struct display *display)
size_t pool_size = 0;
struct cursor *cursor;
XcursorImages **images;
+ const char *theme;
+ const char *tmpstr;
+ int cursor_size = 32;
+
+ theme = getenv("TOYTOOLKIT_CURSOR_THEME");
+
+ tmpstr = getenv("TOYTOOLKIT_CURSOR_SIZE");
+ if (tmpstr) {
+ char *end;
+ long size;
+
+ size = strtol(tmpstr, &end, 0);
+ if (end != tmpstr && *end == 0 && size > 3 && size < 65)
+ cursor_size = size;
+ }
count = ARRAY_LENGTH(cursors);
display->cursors = malloc(count * sizeof *display->cursors);
images = malloc(count * sizeof images[0]);
for (i = 0; i < count; i++) {
- images[i] = XcursorLibraryLoadImages(cursors[i], NULL, 32);
+ images[i] = XcursorLibraryLoadImages(cursors[i], theme,
+ cursor_size);
if (!images[i]) {
- fprintf(stderr, "Error loading cursor: %s\n",
- cursors[i]);
+ fprintf(stderr, "Error loading cursor '%s' "
+ "from theme '%s'\n", cursors[i],
+ theme ? theme : "default");
continue;
}
pool_size += data_length_for_cursor_images(images[i]);
--
1.7.3.4
More information about the wayland-devel
mailing list