winit icon indicating copy to clipboard operation
winit copied to clipboard

wayland: Add support for fractional scaling

Open mahkoh opened this issue 3 years ago • 14 comments

  • [x] Added an entry to CHANGELOG.md if knowledge of this change could be valuable to users
  • [x] Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • [ ] Created or updated an example program if it would help users understand this functionality
  • [x] Updated feature matrix, if new features were added or implemented

Depends on https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/143

mahkoh avatar Jul 09 '22 14:07 mahkoh

PS: I've noticed that winit never destroys any wayland surfaces. I've kept it that way with the new objects I've added.

mahkoh avatar Jul 09 '22 14:07 mahkoh

@mahkoh winit should destroy the surface via sctk iirc, unless sctk changed that?

I don't see anything wrong in destroying those, but there might be a reason why it's that way.

In general, unless the protocol will be accepted there won't be any action on that PR.

kchibisov avatar Jul 09 '22 14:07 kchibisov

@mahkoh winit should destroy the surface via sctk iirc, unless sctk changed that?

I don't believe this applies to the wl_surface itself.

mahkoh avatar Jul 09 '22 14:07 mahkoh

I don't believe this applies to the wl_surface itself.

Ah, I think it doesn't destroy it in the Window, since it's basically a handle, yeah, should do that, would you send a patch against master or I should do so?

kchibisov avatar Jul 09 '22 15:07 kchibisov

Please go ahead. I'll add destructor calls for the new objects I've added in this PR.

mahkoh avatar Jul 09 '22 15:07 mahkoh

@mahkoh it's being dropped here https://github.com/Smithay/client-toolkit/blob/f03c4b7dea89648dbcba43de80eb14687e0e9da8/src/shell/xdg.rs#L139, so no need for winit to drop it explicitly as well.

kchibisov avatar Jul 09 '22 17:07 kchibisov

self.surface refers to an xdg_surface not to a wl_surface.

mahkoh avatar Jul 09 '22 17:07 mahkoh

Hm, you're right. I've confused the place, but as well as the surface that is being dropped by sctk, since the one it's dropping is invisible one for decorations. So yeah, we should drop this surface in winit.

kchibisov avatar Jul 09 '22 17:07 kchibisov

Keep in mind that the wl_surface must be destroyed after the xdg_surface. Otherwise a protocol error occurs.

mahkoh avatar Jul 09 '22 17:07 mahkoh

@mahkoh In general I have a question, how that will work with client side decorations winit is drawing and sctk frame integrations? I think they should be aware of that change somehow?

kchibisov avatar Jul 14 '22 19:07 kchibisov

They continue to be rendered at integer scales (usually the fractional scale rounded up.) In my tests I did not see any problems with that.

mahkoh avatar Jul 14 '22 19:07 mahkoh

I mean, they should likely scale font if they do font rendering to account for that? That's not the with default sctk decorations, but it's the case with adwaita frame.

In general I'd not take any action further here, unless the protocol get merged and sctk get a release...

kchibisov avatar Jul 14 '22 19:07 kchibisov

I mean, they should likely scale font if they do font rendering to account for that?

Yes, they scale the font at the next integer scale.

https://user-images.githubusercontent.com/1882250/179069105-e78bbdfa-7d93-4c0b-bf9b-c9af3ede5515.mp4

In general I'd not take any action further here, unless the protocol get merged and sctk get a release...

This has nothing to do with sctk. It provides a strict improvement for the content of the window while leaving the frame unchanged.

mahkoh avatar Jul 14 '22 19:07 mahkoh

There will be at least one breaking change in the protocol: The scale type has been changed from fixed to uint with a denominator of 120. I will try to adapt this PR soon.

mahkoh avatar Aug 04 '22 05:08 mahkoh

@mahkoh I'd assume stabilization is soon™

kchibisov avatar Nov 12 '22 14:11 kchibisov

Incidentally working on rebasing this right now.

mahkoh avatar Nov 12 '22 14:11 mahkoh

The protocol has been accepted.

mahkoh avatar Nov 23 '22 19:11 mahkoh

@mahkoh I'd wait until the sway merges their stuff wrt fractional scaling so I'd have easier time testing it. Given that implementation isn't in wlroots yet it may take some time, but we're not in the rush anyway.

For now just schedule it for winit 0.28.

kchibisov avatar Nov 26 '22 01:11 kchibisov

Updated with the final protocol text. The SDL implementation has been merged: https://github.com/libsdl-org/SDL/pull/5906

What is the timeline for 0.28?

mahkoh avatar Nov 30 '22 10:11 mahkoh

Added the missing destroy calls for the add-on objects. See https://github.com/rust-windowing/winit/pull/2369#issuecomment-1179556061

mahkoh avatar Nov 30 '22 10:11 mahkoh

What is the timeline for 0.28?

There's no timeline.

I'd basically wait for sway to get fractional scaling, if it won't and we'll be doing 0.28 I'll go back to it.

kchibisov avatar Nov 30 '22 11:11 kchibisov

I'd basically wait for sway to get fractional scaling, if it won't and we'll be doing 0.28 I'll go back to it.

Note that KDE/kwin has already merged the implementation of fractional scaling and it would be available since the next release (5.27). I hope we can get it in soon.

oxalica avatar Jan 14 '23 08:01 oxalica

@mahkoh I could finish this PR myself given that everything is more of a codestyle rant. Just let me know (though I'd push anyway in-before release).

kchibisov avatar Jan 19 '23 08:01 kchibisov

Sorry I'm busy with work at the moment. If you could finish it that would be great.

mahkoh avatar Jan 19 '23 08:01 mahkoh

Applied.

Thanks.

kchibisov avatar Jan 19 '23 21:01 kchibisov