~eliasnaur/gio-patches

gio: app: [Wayland] use HiDPI cursor on HiDPI screen v1 PROPOSED

Chris Waldon: 2
 app: [Wayland] use HiDPI cursor on HiDPI screen
 app: [Wayland] respect XCURSOR_* environment variables

 2 files changed, 12 insertions(+), 2 deletions(-)
#786610 apple.yml success
#786611 freebsd.yml success
#786612 linux.yml success
#786613 openbsd.yml success
gio/patches: SUCCESS in 19m44s

[app: [Wayland] use HiDPI cursor on HiDPI screen][0] from [Chris Waldon][1]

[0]: https://lists.sr.ht/~eliasnaur/gio-patches/patches/33229
[1]: mailto:christopher.waldon.dev@gmail.com

✓ #786612 SUCCESS gio/patches/linux.yml   https://builds.sr.ht/~eliasnaur/job/786612
✓ #786613 SUCCESS gio/patches/openbsd.yml https://builds.sr.ht/~eliasnaur/job/786613
✓ #786611 SUCCESS gio/patches/freebsd.yml https://builds.sr.ht/~eliasnaur/job/786611
✓ #786610 SUCCESS gio/patches/apple.yml   https://builds.sr.ht/~eliasnaur/job/786610
Thanks. Merged with a cleanup change.

On Thu, 23 Jun 2022 at 23:16, Chris Waldon
<christopher.waldon.dev@gmail.com> wrote:
> 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>
> ---
> app/os_wayland.go | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/app/os_wayland.go b/app/os_wayland.go
> index 6ad40974..7f393e59 100644
> --- a/app/os_wayland.go
> +++ b/app/os_wayland.go
> @@ -358,7 +358,16 @@ 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"))
Added a C.free.
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~eliasnaur/gio-patches/patches/33229/mbox | git am -3
Learn more about email & git

[PATCH gio 1/2] app: [Wayland] use HiDPI cursor on HiDPI screen Export this patch

This commit scales both the loaded cursor theme and the cursor
surface appropriately so that the cursor image is not blurry on
HiDPI screens.

References: https://todo.sr.ht/~eliasnaur/gio/382
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
---
 app/os_wayland.go | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/app/os_wayland.go b/app/os_wayland.go
index aa255bd9..6ad40974 100644
--- a/app/os_wayland.go
+++ b/app/os_wayland.go
@@ -358,7 +358,7 @@ 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, 32, d.shm)
	w.cursor.theme = C.wl_cursor_theme_load(nil, C.int(32*w.scale), d.shm)
	if w.cursor.theme == nil {
		w.destroy()
		return nil, errors.New("wayland: wl_cursor_theme_load failed")
@@ -375,6 +375,7 @@ func (d *wlDisplay) createNativeWindow(options []Option) (*window, error) {
		w.destroy()
		return nil, errors.New("wayland: wl_compositor_create_surface failed")
	}
	C.wl_surface_set_buffer_scale(w.cursor.surf, C.int(w.scale))
	C.xdg_wm_base_add_listener(d.wm, &C.gio_xdg_wm_base_listener, unsafe.Pointer(w.surf))
	C.wl_surface_add_listener(w.surf, &C.gio_surface_listener, unsafe.Pointer(w.surf))
	C.xdg_surface_add_listener(w.wmSurf, &C.gio_xdg_surface_listener, unsafe.Pointer(w.surf))
-- 
2.36.1
Thanks, merged.

Elias

[PATCH gio 2/2] app: [Wayland] respect XCURSOR_* environment variables Export this patch

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>
---
 app/os_wayland.go | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/app/os_wayland.go b/app/os_wayland.go
index 6ad40974..7f393e59 100644
--- a/app/os_wayland.go
+++ b/app/os_wayland.go
@@ -358,7 +358,16 @@ 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"))
	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")
-- 
2.36.1
gio/patches: SUCCESS in 19m44s

[app: [Wayland] use HiDPI cursor on HiDPI screen][0] from [Chris Waldon][1]

[0]: https://lists.sr.ht/~eliasnaur/gio-patches/patches/33229
[1]: mailto:christopher.waldon.dev@gmail.com

✓ #786612 SUCCESS gio/patches/linux.yml   https://builds.sr.ht/~eliasnaur/job/786612
✓ #786613 SUCCESS gio/patches/openbsd.yml https://builds.sr.ht/~eliasnaur/job/786613
✓ #786611 SUCCESS gio/patches/freebsd.yml https://builds.sr.ht/~eliasnaur/job/786611
✓ #786610 SUCCESS gio/patches/apple.yml   https://builds.sr.ht/~eliasnaur/job/786610
Thanks. Merged with a cleanup change.

On Thu, 23 Jun 2022 at 23:16, Chris Waldon
<christopher.waldon.dev@gmail.com> wrote:
> 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>
> ---
> app/os_wayland.go | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/app/os_wayland.go b/app/os_wayland.go
> index 6ad40974..7f393e59 100644
> --- a/app/os_wayland.go
> +++ b/app/os_wayland.go
> @@ -358,7 +358,16 @@ 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"))
Added a C.free.