[PATCH] wayland-cursor: Respect XCURSOR_SIZE and accept default cursor size

MoD mod-oss at hush.ai
Sat Feb 23 10:21:20 PST 2013


Presently every toolkit using wayland-cursor hard-codes or has its own configuration for cursor size, and there is no scheme for coordination. Weston documents the XCURSOR_SIZE environment variable as affecting Wayland programs. This change brings that functionality into wayland-cursor so consumers can just pass 0 for size to do the right thing. The logic is duplicated in xwayland/window-manager.c, as I'm hesitant to alter semantics of X-namespaced functions without confirmation; I'm not sure of the design considerations for that part of libwayland-cursor.
---
 cursor/wayland-cursor.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/cursor/wayland-cursor.c b/cursor/wayland-cursor.c
index 25e51c2..e4a7452 100644
--- a/cursor/wayland-cursor.c
+++ b/cursor/wayland-cursor.c
@@ -324,7 +324,8 @@ load_callback(XcursorImages *images, void *data)
  *
  * \param name The name of the cursor theme to load. If %NULL, the default
  * theme will be loaded.
- * \param size Desired size of the cursor images.
+ * \param size Desired size of the cursor images. If zero, the default size
+ * will be used.
  * \param shm The compositor's shm interface.
  *
  * \return An object representing the theme that should be destroyed with
@@ -335,6 +336,7 @@ WL_EXPORT struct wl_cursor_theme *
 wl_cursor_theme_load(const char *name, int size, struct wl_shm *shm)
 {
 	struct wl_cursor_theme *theme;
+	char *v = NULL;
 
 	theme = malloc(sizeof *theme);
 	if (!theme)
@@ -344,6 +346,16 @@ wl_cursor_theme_load(const char *name, int size, struct wl_shm *shm)
 		name = "default";
 
 	theme->name = strdup(name);
+
+	if (!size)
+	{
+		v = getenv ("XCURSOR_SIZE");
+		if (v)
+			size = atoi(v);
+		if (!size)
+			size = 32;
+	}
+
 	theme->size = size;
 	theme->cursor_count = 0;
 	theme->cursors = NULL;
-- 
1.8.1.4



More information about the wayland-devel mailing list