Bug 464842 - Maximized windows on one screen take one pixel on other (fractional scaling)
Summary: Maximized windows on one screen take one pixel on other (fractional scaling)
Status: RESOLVED FIXED
Alias: None
Product: KScreen
Classification: Plasma
Component: common (show other bugs)
Version: git
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: kscreen-bugs-null@kde.org
URL:
Keywords: wayland
Depends on:
Blocks:
 
Reported: 2023-01-26 07:11 UTC by Mykola Krachkovsky
Modified: 2023-12-16 05:23 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.0


Attachments
Affected 1.25 + 1.5 screen layout (19.35 KB, application/json)
2023-01-26 07:11 UTC, Mykola Krachkovsky
Details
screenshot with noticeable step between panel and extent of window (121.45 KB, image/png)
2023-01-26 07:19 UTC, Mykola Krachkovsky
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mykola Krachkovsky 2023-01-26 07:11:45 UTC
Created attachment 155655 [details]
Affected 1.25 + 1.5 screen layout

SUMMARY
With kwin_wayland 5.26.90 (bug wasn't present on kwin_wayland 5.26.5) maximized windows take also one pixel on other screen. I use fractional scaling, top-bottom screen arrangements (left-right wasn't tested). Bug reproduced with top×1.25 + bottom×1.5 and top×1 + bottom×1.5 screen layouts. One extra pixel is not kscreen problem, screens do not overlap (it is hidden by right panel on bottom screen and active maximized window on bottom screen).

STEPS TO REPRODUCE
1. Setup layout with two screens, bottom one has scaling 1.5, top could be any (reproduced at least with 1 and 1.25).
2. Maximize window on top screen (for easier noticing, contrast window and wallpaper may be used).
3. (Optional) Maximize some window on bottom screen.

OBSERVED RESULT
One pixel line overhang on on bottom screen from top max window.
With step 3 you could switch between windows and see how that extra line appears and hides.

EXPECTED RESULT
Maximized windows should not extend beyond their screen.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: openSUSE Tumbleweed 20230124 with KDE Plasma 5.27 beta
KDE Plasma Version: 5.26.90
KDE Frameworks Version: 5.102.0
Qt Version: 5.15.8+kde160

ADDITIONAL INFORMATION

This bug looks like some sort of opposite to https://bugs.kde.org/show_bug.cgi?id=459373
Unlike that bug it doesn't depend on XWayland (native Wayland clients are used) and it wasn't present before 5.27 beta.

example of affected layout (full in attachment)
`kscreen-doctor -j | jq '[.outputs[] | { name: .name, pos: .pos, size: .size, scale: .scale }]'`
```
[
  {
    "name": "eDP-1",
    "pos": {
      "x": 385,
      "y": 1152
    },
    "size": {
      "height": 1080,
      "width": 1920
    },
    "scale": 1.5
  },
  {
    "name": "DP-1",
    "pos": {
      "x": 0,
      "y": 0
    },
    "size": {
      "height": 1440,
      "width": 2560
    },
    "scale": 1.25
  }
]
```
Comment 1 Mykola Krachkovsky 2023-01-26 07:19:39 UTC
Created attachment 155656 [details]
screenshot with noticeable step between panel and extent of window
Comment 2 fanzhuyifan 2023-12-02 04:15:20 UTC
Can reproduce on latest neon unstable (wayland)
Comment 3 Bug Janitor Service 2023-12-08 23:11:45 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/libkscreen/-/merge_requests/172
Comment 4 Bug Janitor Service 2023-12-08 23:15:34 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kscreen/-/merge_requests/264
Comment 5 fanzhuyifan 2023-12-11 14:23:49 UTC
Git commit 6f797a908360de5c9654cd6cbd1dcc170b35207c by Yifan Zhu.
Committed on 10/12/2023 at 04:33.
Pushed by zamundaaa into branch 'master'.

Round up output geometry

Under fractional scaling, output screens can have non-integral sizes.
Previous code uses QSizeF::toSize(), which rounds to the nearest
integer. This sometimes results in different screens sharing one pixel
at the edge, which causes BUG 464842 and BUG 477791.

Implement Output::explicitLogicalSizeInt() and
Config::logicalSizeForOutputInt to explicitly round up non-integral
sizes, and use them in calculating output geometry.
Related: bug 477791

M  +1    -1    autotests/testscreenconfig.cpp
M  +7    -1    src/config.cpp
M  +7    -0    src/config.h
M  +7    -1    src/output.cpp
M  +11   -0    src/output.h

https://invent.kde.org/plasma/libkscreen/-/commit/6f797a908360de5c9654cd6cbd1dcc170b35207c
Comment 6 Zamundaaa 2023-12-11 14:26:24 UTC
Git commit cff5739c872393bfbfe9bca43a5763f4d9ec3e6e by Xaver Hugl, on behalf of Yifan Zhu.
Committed on 11/12/2023 at 15:23.
Pushed by zamundaaa into branch 'master'.

Round up output geometry

Under fractional scaling, output screens can have non-integral sizes.
Previous code uses QSizeF::toSize(), which rounds to the nearest
integer. This sometimes results in different screens sharing one pixel
at the edge, which causes BUG 464842 and BUG 477791.

Use the new Output::explicitLogicalSizeInt() and
Config::logicalSizeForOutputInt functions to explicitly round up
non-integral sizes.
Related: bug 477791

M  +6    -6    kcm/output_model.cpp

https://invent.kde.org/plasma/kscreen/-/commit/cff5739c872393bfbfe9bca43a5763f4d9ec3e6e