Summary: | Window recording gives incorrect resolution with display scaling, in both spectacle and obs-studio | ||
---|---|---|---|
Product: | [Plasma] kwin | Reporter: | Oxalica <oxalicc> |
Component: | screencasting | Assignee: | KWin default assignee <kwin-bugs-null> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | nate, oxalicc, xaver.hugl |
Priority: | NOR | ||
Version: | 6.2.4 | ||
Target Milestone: | --- | ||
Platform: | NixOS | ||
OS: | Linux | ||
Latest Commit: | https://invent.kde.org/plasma/kwin/-/commit/4048d208f72b74f2393e6f129a1802ae447f228b | Version Fixed In: | 6.2.5 |
Sentry Crash Report: |
Description
Oxalica
2024-12-16 19:33:46 UTC
After some debugging, I made it work with the following patch on top of kwin v6.2.4. With it, both spectacle and obs-studio record the non-scaled correct resolution and the content looks clear. I hope it helps, but I'm not sure if it's ideal and it's not applicable on kwin master due to some non-trivial code change. ``` diff --git a/src/plugins/screencast/windowscreencastsource.cpp b/src/plugins/screencast/windowscreencastsource.cpp index f2a1432e4d..2b2c6ed36d 100644 --- a/src/plugins/screencast/windowscreencastsource.cpp +++ b/src/plugins/screencast/windowscreencastsource.cpp @@ -49,12 +49,12 @@ quint32 WindowScreenCastSource::drmFormat() const QSize WindowScreenCastSource::textureSize() const { - return m_window->clientGeometry().size().toSize(); + return m_window->clientGeometry().size().toSize() * devicePixelRatio(); } qreal WindowScreenCastSource::devicePixelRatio() const { - return 1.0; + return m_window->preferredBufferScale(); } void WindowScreenCastSource::render(QImage *target) -- ``` You can make that work on git master by replacing preferredBufferScale() with targetScale(). Would you like to make a merge request with that change? (In reply to Zamundaaa from comment #2) > You can make that work on git master by replacing preferredBufferScale() > with targetScale(). Would you like to make a merge request with that change? Thanks for the advice, but I don't have a kwin dev&test environment. I'm currently hot-patching kwin's Nix package in my production system. The master branch contains many dependency changes (kdecoration3 and all its dependents) which are incompatible with build scripts from released version. I'm unfamiliar with fixing it. If it's more convenient for you to test the 2-line-change, feel free to adopt it in upstream. Thanks! A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/6906 Git commit b6e6000d9729f740f9a17cf4d4517703a8da09fa by Xaver Hugl. Committed on 17/12/2024 at 13:29. Pushed by zamundaaa into branch 'master'. plugins/screencast: take scaling into account for window sources Otherwise the textures will be too small, and the result blurry M +2 -2 src/plugins/screencast/windowscreencastsource.cpp https://invent.kde.org/plasma/kwin/-/commit/b6e6000d9729f740f9a17cf4d4517703a8da09fa Git commit 4048d208f72b74f2393e6f129a1802ae447f228b by Xaver Hugl. Committed on 17/12/2024 at 15:18. Pushed by zamundaaa into branch 'Plasma/6.2'. plugins/screencast: take scaling into account for window sources Otherwise the textures will be too small, and the result blurry (cherry picked from commit b6e6000d9729f740f9a17cf4d4517703a8da09fa) Co-authored-by: Xaver Hugl <xaver.hugl@gmail.com> M +2 -2 src/plugins/screencast/windowscreencastsource.cpp https://invent.kde.org/plasma/kwin/-/commit/4048d208f72b74f2393e6f129a1802ae447f228b |