WillPower3309 / swayfx

SwayFX: Sway, but with eye candy!
MIT License
1.29k stars 48 forks source link

Rounded corners of shadows and borders do not align when output scale is not 1 #131

Closed Ant01n3 closed 1 year ago

Ant01n3 commented 1 year ago

Hello,

First, thank you for this project that adds exactly what is missing in Sway.

I think there may be a bug in the way shadows are rendered when the output scale is not 1 for rounded corners.

For a output with scale 1 the rounded corners of borders and shadows perfectly align. When scale is 1.5 or 2 for example, the rounded corners are scaled for the borders but it seems they are not for the shadows. This can be seen as a little gap between the shadow and the border.

It is not really a bug as swayfx still works perfectly, but I guess this is not the expected behavior.

Version: 0.2-474bfb46 (Mar 20 2023, branch 'master')

Configuration:

corner_radius 5
smart_corner_radius on
smart_gaps on
smart_borders off
shadows on
shadows_on_csd on 
shadow_blur_radius 20
shadow_color #000000FF
gaps inner 10
default_border pixel 2

Here is an example for an output with scale 1.5:

ScreenShot_17s_03m_17h_20_03_2023

WillPower3309 commented 1 year ago

Thanks for raising the issue! Should be an easy fix :) will take a look this evening

ErikReider commented 1 year ago

Thanks for raising the issue! Should be an easy fix :) will take a look this evening

We should just need to multiply the radii by the scale here right?: https://github.com/WillPower3309/swayfx/blob/7d5d7a3022eb17835cea7af7290b1a5d2fe4b03a/sway/desktop/fx_renderer.c#L700

WillPower3309 commented 1 year ago

Thanks for raising the issue! Should be an easy fix :) will take a look this evening

We should just need to multiply the radii by the scale here right?:

https://github.com/WillPower3309/swayfx/blob/7d5d7a3022eb17835cea7af7290b1a5d2fe4b03a/sway/desktop/fx_renderer.c#L700

Basically, this is what I'd assume the issue is too. I'd like to keep scaling handled in render.c though, however if I update the render_box_shadow function to scale the corner_radius, the issue remains. Tricky.

WillPower3309 commented 1 year ago

fixed by 3f00052

Ant01n3 commented 1 year ago

Running this version for a few hours without problems. Nice blur + nice corners + nice shadows ! Very good work 👏👏 Thank you !