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

wayland: add wp-fractional-scale-v1 support #10943

Merged
merged 2 commits into from Jan 24, 2023

Conversation

Dudemanguy
Copy link
Member

@Dudemanguy Dudemanguy commented Nov 28, 2022

Currently depends on wayland-protocols from master. Presumably they'll cut a new release soon though since this is a pretty major feature. Now depends on wayland-protocols 1.31.

Tested this on sway/wlroots with https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3511 and swaywm/sway#6929 (with the later rebased/cherry-picked locally). Seems to work as desired and fortunately it's not nearly as invasive into mpv's geometry handling as I initially feared.

This does sort of change the semantics of how mpv on wayland handles HiDPI but it's actually more inline with other platforms now. Basically, the window is always scaled by the extra scale factor. Previously, it was always shown as the exact pixel size with no extra scaling.

Eventually, I'd like to eliminate the old buffer_scale codepath and logic completely because the fractional scale protocol is simply better in every way, but that will have to wait for the future so for now we have to juggle these three different cases (fractional scale, regular wayland integer scaling, and no scaling at all).

TODO:

  • Fix autofit/geometry options
  • Actually tie this to a wayland-protocols release
  • waf support
  • Document the change in scaling behavior
  • Support the --no-hidpi-window-scale option with the fractional scale method
  • More testing in general

Fixes #9443.

@Dudemanguy Dudemanguy force-pushed the wayland-fractional-scale branch 2 times, most recently from c4ed894 to ea28f04 Compare November 29, 2022 03:57
@Dudemanguy
Copy link
Member Author

Unfortunately, it's pretty trivial to trigger some "off-by-one" errors in the window dimensions in certain cases (playing around with current-window-scale) with this current approach. I think I might have to rework wl->geometry so it represents the physical not logical space.

@Dudemanguy
Copy link
Member Author

I think I might have to rework wl->geometry so it represents the physical not logical space.

This seems to do the trick.

This now depends on wayland-protocols 1.31. Seems to behave OK in the fractional-scale support case while still working the same as before without it. I'll try to rig up multi monitors later to do some more testing.

@Dudemanguy Dudemanguy force-pushed the wayland-fractional-scale branch 5 times, most recently from 9f07371 to ad2218b Compare January 15, 2023 05:47
@Dudemanguy Dudemanguy marked this pull request as ready for review January 15, 2023 05:47
@Dudemanguy Dudemanguy force-pushed the wayland-fractional-scale branch 3 times, most recently from 33c9b48 to 37e67a7 Compare January 15, 2023 06:32
@Dudemanguy
Copy link
Member Author

Dudemanguy commented Jan 15, 2023

This is going to be the greatest clusterfuck I've ever written.

Did some more testing with multimonitors on Plasma (built from an arbitrary git commit from master) as well as my rebased Sway/wlroots branch. Tweaked some things, and in general it seems to work. This is insanely complicated though (was already bad enough before), but there's really nothing I can do about it. There's so many different ways to scale now and I can't just drop the buffer_scale stuff. I pray that compositor devs can get fractional scale support quickly, so I can drop some code ASAP. btw the cursor isn't fractionally scaled (nobody better complain about this I swear).

I'm sure there's regressions, but anyways I'll think on it for a few more days before merging so people out there can actually use the thing (the next KDE release will drop soonish with this) and report breakage.

This is in preparation for fractional scaling support. Basically, redo
all the coordinates in wayland so that wl->geometry is equal exactly to
what is being put out to the screen (no extra wl->scaling multiplication
required). The wl->vdparams variable is also eliminated for simplicity.
This changes mpv's behavior on wayland with hidpi scaling but that will
be addressed in more detail with the next commit.
@Dudemanguy Dudemanguy force-pushed the wayland-fractional-scale branch 2 times, most recently from 502aff8 to cc93fb6 Compare January 23, 2023 20:31
@Dudemanguy
Copy link
Member Author

Okay, I don't think I hate this anymore after this third rewrite.

@Dudemanguy Dudemanguy force-pushed the wayland-fractional-scale branch 2 times, most recently from e1c17fd to e155e55 Compare January 23, 2023 21:33
This protocol is pretty important since it finally lets us solve the
longstanding issue of fractional scaling in wayland (no more mpv doing
rendering over the target resolution and then being scaled down). This
protocol also can completely replace the buffer_scale usage that we are
currently using for integer scaling so hopefully this can be removed
sometime in the future. Note that vo_dmabuf_wayland is omitted from the
fractional scale handling because we want the compositor to handle all
the scaling for that VO.

Fixes mpv-player#9443.
@Dudemanguy Dudemanguy merged commit 879824a into mpv-player:master Jan 24, 2023
@Dudemanguy Dudemanguy deleted the wayland-fractional-scale branch January 24, 2023 00:05
@davispuh
Copy link

Okay, I don't think I hate this anymore after this third rewrite.

Great job and well done! 🥳 and high five ✋ as I have basically just completed 3rd rewrite of some KDE Dolphin related stuff aswell 😅 just few bugs left to fix before submitting MR :)

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

Successfully merging this pull request may close these issues.

mpv detects the wrong resolutin with wayland session if the session is using fractional zoom.
2 participants