forked from joejulian/gio
app: [Wayland] respect XCURSOR_* environment variables
This commit adds support for the commonly-used XCURSOR_THEME and XCURSOR_SIZE environment variables. Wayland lacks a protocol-level way to standardize cursor size right now, but these variables are used consistently by many applications and compositors. Many users (including me) will find that their environment is already configuring these for them, and will get consistent cursor sizing for free. I explored a lot of ways to tackle this, but it looks like nobody has ever gotten around to implementing the cursor theme protocol discussed here: https://wayland-devel.freedesktop.narkive.com/VuMSOO55/possible-wayland-extension-to-publish-mouse-pointer-size Given that it doesn't seem to be resolved anytime soon, supporting a widely-used convention to tweak these things seems reasonable to me. I say that it fixes issue 382 because it enables the user to make Gio's cursor size match the rest of their system. Fixes: https://todo.sr.ht/~eliasnaur/gio/382 Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
+11
-1
@@ -374,7 +374,17 @@ func (d *wlDisplay) createNativeWindow(options []Option) (*window, error) {
|
||||
w.destroy()
|
||||
return nil, errors.New("wayland: xdg_surface_get_toplevel failed")
|
||||
}
|
||||
w.cursor.theme = C.wl_cursor_theme_load(nil, C.int(32*w.scale), d.shm)
|
||||
cursorTheme := C.CString(os.Getenv("XCURSOR_THEME"))
|
||||
defer C.free(unsafe.Pointer(cursorTheme))
|
||||
cursorSize := 32
|
||||
if envSize, ok := os.LookupEnv("XCURSOR_SIZE"); ok && envSize != "" {
|
||||
size, err := strconv.Atoi(envSize)
|
||||
if err == nil {
|
||||
cursorSize = size
|
||||
}
|
||||
}
|
||||
|
||||
w.cursor.theme = C.wl_cursor_theme_load(cursorTheme, C.int(cursorSize*w.scale), d.shm)
|
||||
if w.cursor.theme == nil {
|
||||
w.destroy()
|
||||
return nil, errors.New("wayland: wl_cursor_theme_load failed")
|
||||
|
||||
Reference in New Issue
Block a user