~eliasnaur/gio-patches

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
5 3

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

Details
Message ID
<20220623211621.1172-1-christopher.waldon.dev@gmail.com>
DKIM signature
pass
Download raw message
Patch: +2 -1
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

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

Details
Message ID
<20220623211621.1172-2-christopher.waldon.dev@gmail.com>
In-Reply-To
<20220623211621.1172-1-christopher.waldon.dev@gmail.com> (view parent)
DKIM signature
pass
Download raw message
Patch: +10 -1
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] build success

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CKXU5XZRKQ1J.7VMR9S7LOXSN@cirno>
In-Reply-To
<20220623211621.1172-2-christopher.waldon.dev@gmail.com> (view parent)
DKIM signature
missing
Download raw message
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]: 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
Details
Message ID
<CKZVTSMJQPCM.2MUI4II2B4QVR@themachine>
In-Reply-To
<20220623211621.1172-1-christopher.waldon.dev@gmail.com> (view parent)
DKIM signature
pass
Download raw message
Thanks, merged.

Elias

Re: [PATCH gio 2/2] app: [Wayland] respect XCURSOR_* environment variables

Details
Message ID
<CAMAFT9WuBjyFgKrNQonqCFg8ZU-GJ9WB-tA1OkR9ebL-k3Cpiw@mail.gmail.com>
In-Reply-To
<20220623211621.1172-2-christopher.waldon.dev@gmail.com> (view parent)
DKIM signature
pass
Download raw message
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.

> +       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")
> --

Re: [PATCH gio 2/2] app: [Wayland] respect XCURSOR_* environment variables

Details
Message ID
<CAFcc3FQM0Lr2NxxizEB4nYwXm4incONbrR8PSjxtM57f041zpA@mail.gmail.com>
In-Reply-To
<CAMAFT9WuBjyFgKrNQonqCFg8ZU-GJ9WB-tA1OkR9ebL-k3Cpiw@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
> > -       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.

Thanks! Sorry for missing that.
Reply to thread Export thread (mbox)