Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sway pointer is blurry compared to other clients when using fractional scaling. #4927

Closed
kchibisov opened this issue Jan 18, 2020 · 11 comments · Fixed by swaywm/wlroots#2107
Closed

Comments

@kchibisov
Copy link
Contributor

Sway's pointer is blurry when using fractional scaling in comparison to other clients(e.g. output * scale 1.5). By sway pointer I mean the pointer for window resize/swaybg/window drag (swaynag is fine!).

blurry version over swaybg
blurry

crisp version over swaynag
good

It's really hard to capture on a screenshot, but a blurry cursor is a bit larger, so I guess scaling wasn't applied to it?

sway version: sway version 1.2-9d827ef4 (Jan 18 2020, branch 'HEAD')

@kchibisov kchibisov changed the title Sway pointer is blurry compared to other clients using fractional scaling. Sway pointer is blurry compared to other clients when using fractional scaling. Jan 18, 2020
@emersion
Copy link
Member

There's some logic to load icons with a size of base_size * ceil(scale), maybe it's not working as intended.

@kchibisov
Copy link
Contributor Author

kchibisov commented Jan 19, 2020

I couldn't find this logic tbh in both sway/wlroots, maybe it's just not yet implemented?

Edit: I'm talking about the logic presented in your snippet, the cursor scale seems like it's using the output->scale in wlroots without any ceil, etc. So you basically loading a bit larger images for cursor with DPR 1(?), right now.

@emersion
Copy link
Member

@ChrisLane
Copy link

ChrisLane commented Apr 9, 2020

In a very similar vein, I've found that with fractional scaling my mouse pointer becomes perhaps twice the size when I hover over swaybg and is normal when it is over any other window.
Perhaps this has the same cause.

@kchibisov
Copy link
Contributor Author

There's some logic to load icons with a size of base_size * ceil(scale), maybe it's not working as intended.

https://github.com/swaywm/wlroots/blob/master/types/wlr_xcursor_manager.c#L49

I've completely forgot about this issue, but as you can see you're not doing ceil(scale) as it was said, you're just using fractional value right away. So that's why I've said, since I don't see ceil part.

I couldn't find this logic tbh in both sway/wlroots, maybe it's just not yet implemented?

So the current logic is to just multiply from what I can see, but the correct could be to ceil and do some other handling related to pointer surfaces, etc, later on, since your scale factor is fractional on output IIRC.

emersion added a commit to emersion/wlroots that referenced this issue Apr 10, 2020
The scaling factor was being implicitly cast to an int.

Closes: swaywm/sway#4927
@emersion
Copy link
Member

Can you try swaywm/wlroots#2107?

ddevault pushed a commit to swaywm/wlroots that referenced this issue Apr 10, 2020
The scaling factor was being implicitly cast to an int.

Closes: swaywm/sway#4927
@kchibisov
Copy link
Contributor Author

Can you try swaywm/wlroots#2107?

It seems to solve blurriness, but cursor size is still incorrect.

@emersion
Copy link
Member

It's still off by a bit, yeah. I think this is because not all cursor sizes are available and we always apply the output scaling factor to the cursor. We should compute a cursor scale factor depending on the requested cursor size, the effective cursor size, and the output scale. However the wlr_output cursor API doesn't let us apply a custom scale factor.

@kchibisov
Copy link
Contributor Author

The problem is that you're using fractional_scale * XCURSOR_SIZE, but clients are using ceil(fractional_scale) * XCURSOR_SIZE, so I guess cursor manager should operate in ceil(fractional_scale), instead of fractional_scale. Also sway reload from a 2 scale factor to 1.5 scale factor is broken, since cursor images are failing to reload, and sway doesn't use any cursor.

I guess the issue should be reopened with changed title, since there are still minor issues.

@ChrisLane
Copy link

I've just restarted with sway-git, swaybg-git and wlroots-git and the issue I was having with a huge cursor seems to be fixed!

@emersion
Copy link
Member

emersion commented Apr 10, 2020

The problem is that you're using fractional_scale * XCURSOR_SIZE, but clients are using ceil(fractional_scale) * XCURSOR_SIZE, so I guess cursor manager should operate in ceil(fractional_scale), instead of fractional_scale.

With fractional scaling, cleints will submit 2x buffers, Sway will scale them down. As explained above, if we pick a 2x cursor, we won't be able to scale it down to the right size with the current API.

I guess the issue should be reopened with changed title, since there are still minor issues.

Feel free to open issues for these two bugs. I'd prefer to track them in separate issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants