danyspin97 / wpaperd

Modern wallpaper daemon for Wayland
GNU General Public License v3.0
332 stars 26 forks source link

image is rotated upside down on a 90-degree rotated display #80

Closed rufiorogue closed 4 months ago

rufiorogue commented 4 months ago

Hey, thanks for this project!

Please check if this might be a bug in your recent commit 00664246b32e8e8affe405a56cc04512d0255487 "fix(renderer): Fix proportions on rotated displays" One of my monitors is physically rorated 90 degrees clock-wise and according to wlr-randr it is rotated 90 degrees (Transform: 90). Thus my logic is to make wallpaper look straight you have to rotate the image 90 degrees ccw, giving you a rotation matrix

0 -1
1 0

however in the code below the rotation matrix for Transform::_90 is actually -90 ccw rotation.

fn projection_matrix(transform: Transform) -> [f32; 4] {
    println!("HERE");
    match transform {
        Transform::Normal => {
            [
                1.0, 0.0,
                0.0, 1.0,
            ]
        }
        Transform::_90 => {
            [
                0.0, 1.0,
                -1.0, 0.0,
            ]
        }
danyspin97 commented 4 months ago

Hello @roovio and thank you for the issue!

The current matrices work fine for sway, wpaperd displays the wallpaper in the correct way. I am assuming that you are using Hyprland, because there the matrices creates funny wallpapers. The thing is that in hyprland, the same matrix for Normal works for all rotations (except for the flipped ones, where you need to add some -1.0 in place of 1.0). Can you please confirm that you are using hyprland?

I am going to escalate the issue to both sway and hyprland, hopefully we'll be able to fix this inconsistency.

rufiorogue commented 4 months ago

no, actually I'm on sway git. FYI my output conf for relevant monitor:

output "DP-2" {
    mode  1920x1080@60.0Hz
    pos 2560 0
    transform 270
    scale 1.0
    scale_filter nearest
    adaptive_sync off
    dpms on
}
rufiorogue commented 4 months ago

For me the patch below fixes the rotation. BTW I verified that specifically Transform::_90 match gets chosen in my case, despite "transform 270" in the config (i've tested by putting all zeros in Transform::270 and it still works, while changing Transform::90 affects the image). So go figure.

diff --git a/daemon/src/render/renderer.rs b/daemon/src/render/renderer.rs
index bab95e8..6aafaac 100644
--- a/daemon/src/render/renderer.rs
+++ b/daemon/src/render/renderer.rs
@@ -508,8 +508,8 @@ fn projection_matrix(transform: Transform) -> [f32; 4] {
         }
         Transform::_90 => {
             [
-                0.0, 1.0,
-                -1.0, 0.0,
+                0.0, -1.0,
+                1.0, 0.0,
             ]
         }
         Transform::_180 => {
@@ -520,8 +520,8 @@ fn projection_matrix(transform: Transform) -> [f32; 4] {
         }
         Transform::_270 => {
             [
-                0.0, -1.0,
-                1.0, 0.0,
+                0.0, 1.0,
+                -1.0, 0.0,
             ]
         }
         Transform::Flipped => {
danyspin97 commented 4 months ago

Interesting, then sway-git behaves differently than latest tagged sway and from hyprland...

The current matrices work on sway 1.9 for me, while the following work on Hyprland 0.41.2:

        Transform::_90 => {
            [
                -1.0, 0.0,
                 0.0, 1.0,
            ]
        }

Also, I just noticed that you swapped 90 degrees with 270, making it work. I suspect in your case it's a sway bug sending the wrong transform to wpaperd. Can you please run wpaperd with WAYLAND_DEBUG=client and share the log?

vyivel commented 4 months ago

Sway uses clockwise transforms for configuration while Wayland uses counterclockwise transforms, so they get converted. Also, latest tagged Sway doesn't send wl_surface.preferred_buffer_transform.

rufiorogue commented 4 months ago

Can you please run wpaperd with WAYLAND_DEBUG=client and share the log

log is without my changes above. wpaperd.log

sway-git 1.10.r7365.5233a0b-1 wlroots-git 0.18.0.r7108.67b88e46-1

danyspin97 commented 4 months ago

Thank you, @roovio and @vyivel !

I just tested wpaperd on sway-git and I get the same output as yours. I have pushed your fix to main branch :)

carbolymer commented 3 months ago

@danyspin97 any plans to cut a release soon? I'm affected by this on hyprland 0.42.