Hyprland icon indicating copy to clipboard operation
Hyprland copied to clipboard

Viewporter does not work properly with layer-shell

Open MaxVerevkin opened this issue 2 years ago • 8 comments

How the client is supposed to look:

image

How it actually looks when using wp_viewport:

image

What the client does:

[wayrs]  -> [email protected](46,wl_output@12)
[wayrs]  -> [email protected]_surface(wl_surface@13)
[wayrs]  -> [email protected]_fractional_scale(wp_fractional_scale_v1@14,13)
[wayrs]  -> [email protected]_layer_surface(zwlr_layer_surface_v1@15,13,12,2,"i3bar-river")
[wayrs]  -> [email protected]_size(0,20)
[wayrs]  -> [email protected]_anchor(13)
[wayrs]  -> [email protected]_margin(0,0,5,0)
[wayrs]  -> [email protected]_exclusive_zone(25)
[wayrs]  -> [email protected]_viewport(wp_viewport@16,13)
...
[wayrs] [email protected]_scale(144)
[wayrs] [email protected](136803798)
[wayrs]  -> [email protected]_source(0,0,1919,24)
[wayrs]  -> [email protected]_destination(1599,20)
[wayrs]  -> [email protected](19,0,0)
[wayrs]  -> [email protected](0,0,2147483647,2147483647)
[wayrs]  -> [email protected]()

MaxVerevkin avatar Feb 04 '23 19:02 MaxVerevkin

huh, odd. is that i3bar-river? Can I get a reproducible example case (probably a config for i3bar-river)

vaxerski avatar Feb 04 '23 19:02 vaxerski

tested on my laptop and it works properly, but fractionalScale is not bound. Maybe you can make a branch with wp-fs-v1 so that I can test?

hyprpaper uses wp-fs-v1 and it's working fine as far as I can tell.

vaxerski avatar Feb 04 '23 19:02 vaxerski

Yes, I pushed my attempt to implement fractional scaling to https://github.com/MaxVerevkin/i3bar-river/tree/wpfs (it works in river btw (I mean the viewport part, river does not implement wp-fs)). Min config:

$ cat .config/i3bar-river/config.toml 
command = "sh -c 'echo hello_world; sleep 99999'"

MaxVerevkin avatar Feb 04 '23 20:02 MaxVerevkin

hyprpaper uses wp-fs-v1 and it's working fine as far as I can tell.

Hm...

$ WAYLAND_DEBUG=1 build/hyprpaper 2>&1 | rg viewpo
[3289227.537] [email protected](12, "wp_viewporter", 1)
[3289227.539]  -> [email protected](12, "wp_viewporter", 1, new id [unknown]@5)
[3289227.969]  -> [email protected]_viewport(new id wp_viewport@16, wl_surface@11)
[3289274.831]  -> [email protected]_destination(1919, 1079)
[3289289.401]  -> [email protected]_destination(1919, 1079)

MaxVerevkin avatar Feb 04 '23 20:02 MaxVerevkin

AFAIK with scaling you should only use the destination, as no cropping is needed. Can't say I fully understand their reasoning in the spec, though.

vaxerski avatar Feb 04 '23 21:02 vaxerski

That's weird that binding wp-fs changes the semantics of wp-vp. Might be worth opening an issue at wayland-protocols for clarification.

[3289274.831]  -> [email protected]_destination(1919, 1079)
[3289289.401]  -> [email protected]_destination(1919, 1079)

This still seems wrong because the physical size of my screen is 1920x1080, and with scale=1.2 it should be 1600x900.

Maybe offtopic, but this seems wrong to:

$ WAYLAND_DEBUG=1 build/hyprpaper 2>&1 | rg set_buffer_scale
[1813637.325]  -> [email protected]_buffer_scale(2)
[1813647.356]  -> [email protected]_buffer_scale(2)

Spec:

The wl_surface buffer scale should remain set to 1.

MaxVerevkin avatar Feb 04 '23 21:02 MaxVerevkin

possible. Do I look like I carefully read the spec? lol

mostly took a look at code from the test clients.

vaxerski avatar Feb 04 '23 21:02 vaxerski

AFAIK with scaling you should only use the destination, as no cropping is needed. Can't say I fully understand their reasoning in the spec, though.

Apparently set_source is optional in general, didn't know that.

MaxVerevkin avatar Feb 05 '23 08:02 MaxVerevkin

After https://github.com/hyprwm/Hyprland/commit/859d6b9b8a961669c814632bbc7a1a9d94556551 something different happens: image

(The top uses set_buffer_scale(2), the bottom uses viewporter)

MaxVerevkin avatar Feb 10 '23 08:02 MaxVerevkin

possible.

Hyprpaper uses wp-fs-v1 and works. See that impl.

vaxerski avatar Feb 10 '23 11:02 vaxerski

This is not even related to fractional scaling. The client may not even bind wp-fs, receive "scale=2" event, render with scale of 2 and instead of setting "buffer_scale=2" the client may use wp-vp to scale the buffer down. This is a perfectly valid use of wp-vp.

MaxVerevkin avatar Feb 10 '23 11:02 MaxVerevkin

Hyprpaper uses wp-fs-v1 and works

And it is wrong.

[3289274.831]  -> [email protected]_destination(1919, 1079)
[3289289.401]  -> [email protected]_destination(1919, 1079)

This still seems wrong because the physical size of my screen is 1920x1080, and with scale=1.2 it should be 1600x900.

MaxVerevkin avatar Feb 10 '23 12:02 MaxVerevkin

fixed in both hl and hp.

vaxerski avatar Feb 10 '23 12:02 vaxerski

Works!

MaxVerevkin avatar Feb 10 '23 13:02 MaxVerevkin