Bug 455394

Summary: Adjacent monitors' positioning can be off by one pixel, causing unintentional overlaps that trigger other issues
Product: [Applications] systemsettings Reporter: Riccardo Robecchi <sephiroth_pk>
Component: kcm_kscreenAssignee: kscreen-bugs-null <kscreen-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: culinaryelation, daniel-other+kdebug, dar13.dev, declan, felim, fn1701, hoffmann_lorenz, kirill.bogdanenko, linus.kardell, mikeoosting, nate, phrasky, plasma-bugs, postix, sitter, skierpage, thiago, w01dnick, xaver.hugl
Priority: VHI Keywords: regression
Version: 5.25.0   
Target Milestone: ---   
Platform: Neon   
OS: Linux   
Latest Commit: Version Fixed In: 5.27.5
Sentry Crash Report:
Attachments: White edge of central screen appearing on left monitor

Description Riccardo Robecchi 2022-06-16 10:51:11 UTC
SUMMARY
I have a dual-screen setup: my laptop is connected to an external monitor through a docking station. The displays are arranged vertically both physically and in configuration and have the same resolution (1920 x 1080). I have noticed, however, that screenshots of the whole visible area have a resolution of 1921 x 2160 and, when looking closely, this is because the top display is shifted to the left by one pixel (or the bottom one is shifted to the right). This is despite the KCM reporting the alignment as perfect.

STEPS TO REPRODUCE
1. Attach a second monitor
2. Arrange it vertically in the KCM so that it is perfectly aligned to the bottom one

OBSERVED RESULT
The alignment is off by one pixel.

EXPECTED RESULT
The alignment is perfect.

SOFTWARE/OS VERSIONS
Linux: KDE neon
KDE Plasma Version: 5.25.0
KDE Frameworks Version: 5.95.0
Qt Version: 5.15.4

ADDITIONAL INFORMATION
Comment 1 Nate Graham 2022-11-09 20:42:13 UTC
*** Bug 438155 has been marked as a duplicate of this bug. ***
Comment 2 Nate Graham 2022-11-09 20:42:18 UTC
*** Bug 423939 has been marked as a duplicate of this bug. ***
Comment 3 Nate Graham 2022-11-09 20:45:24 UTC
*** Bug 425192 has been marked as a duplicate of this bug. ***
Comment 4 Bug Janitor Service 2022-11-10 08:37:07 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kscreen/-/merge_requests/153
Comment 5 Alexander Volkov 2022-11-10 14:47:05 UTC
Git commit 6faf4d6b89e826db00198e270675e966ec09d0d0 by Alexander Volkov.
Committed on 10/11/2022 at 08:34.
Pushed by volkov into branch 'master'.

Fix right to right snapping

target.right() is calculated as target.x() + target.width() - 1, so
1 needs to be added to the x coordinate of a snapped rect.

This is done in snapToBottom(), but was forgotten in snapToRight().
Amend 6309d33f092e60a96ce38b32cb295a3e54347cb9.

M  +1    -1    kcm/output_model.cpp

https://invent.kde.org/plasma/kscreen/commit/6faf4d6b89e826db00198e270675e966ec09d0d0
Comment 6 Nate Graham 2022-11-10 14:50:06 UTC
Git commit fab815b0564ea08202b5bd3429f580c6c5a742d3 by Nate Graham, on behalf of Alexander Volkov.
Committed on 10/11/2022 at 14:49.
Pushed by ngraham into branch 'Plasma/5.26'.

Fix right to right snapping

target.right() is calculated as target.x() + target.width() - 1, so
1 needs to be added to the x coordinate of a snapped rect.

This is done in snapToBottom(), but was forgotten in snapToRight().
Amend 6309d33f092e60a96ce38b32cb295a3e54347cb9.


(cherry picked from commit 6faf4d6b89e826db00198e270675e966ec09d0d0)

M  +1    -1    kcm/output_model.cpp

https://invent.kde.org/plasma/kscreen/commit/fab815b0564ea08202b5bd3429f580c6c5a742d3
Comment 7 Nate Graham 2022-11-10 21:27:43 UTC
*** Bug 418459 has been marked as a duplicate of this bug. ***
Comment 8 Nate Graham 2022-11-10 22:35:13 UTC
*** Bug 436460 has been marked as a duplicate of this bug. ***
Comment 9 Nate Graham 2022-11-12 14:32:49 UTC
*** Bug 424265 has been marked as a duplicate of this bug. ***
Comment 10 Nate Graham 2022-11-12 15:05:41 UTC
*** Bug 454578 has been marked as a duplicate of this bug. ***
Comment 11 Nate Graham 2022-11-13 16:09:40 UTC
*** Bug 420465 has been marked as a duplicate of this bug. ***
Comment 12 Nate Graham 2022-11-21 21:09:58 UTC
*** Bug 423939 has been marked as a duplicate of this bug. ***
Comment 13 Thiago Macieira 2023-03-09 16:01:43 UTC
I've just seen this again in 5.27.2
Comment 14 Thiago Macieira 2023-03-09 16:03:19 UTC
As kscreen set them:

Screen 0: minimum 320 x 200, current 7679 x 2400, maximum 16384 x 16384
eDP-1 connected primary 3840x2400+0+0 (normal left inverted right x axis y axis) 288mm x 180mm
   3840x2400     59.99*+  48.00  
DP-3-2 connected 3840x2160+3839+0 (normal left inverted right x axis y axis) 597mm x 336mm
   3840x2160     29.98* 

After xrandr --output DP-3-2 --right-of eDP-1:

Screen 0: minimum 320 x 200, current 7680 x 2400, maximum 16384 x 16384
eDP-1 connected primary 3840x2400+0+0 (normal left inverted right x axis y axis) 288mm x 180mm
   3840x2400     59.99*+  48.00  
DP-3-2 connected 3840x2160+3840+0 (normal left inverted right x axis y axis) 597mm x 336mm
   3840x2160     29.98*
Comment 15 Nate Graham 2023-03-13 17:11:13 UTC
*** Bug 467049 has been marked as a duplicate of this bug. ***
Comment 16 Harald Sitter 2023-04-18 00:39:20 UTC
Are you quite certain the config this happens with is from 5.27 (not older and incorrect from before 5.27)? I've been playing with the kcm for a while and haven't managed to get incorrect snapping out of it.
Comment 17 Thiago Macieira 2023-04-18 01:00:57 UTC
(In reply to Harald Sitter from comment #16)
> Are you quite certain the config this happens with is from 5.27 (not older
> and incorrect from before 5.27)? I've been playing with the kcm for a while
> and haven't managed to get incorrect snapping out of it.

Yes, I am quite sure.

My guess is this is related to HighDPI: at 2x, the off-by-1 gets lost in the rounding.
Comment 18 Harald Sitter 2023-04-18 01:04:45 UTC
Good thought. I'll try some more.
Comment 19 Bug Janitor Service 2023-04-18 08:38:14 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kscreen/-/merge_requests/204
Comment 20 Nate Graham 2023-04-21 14:07:05 UTC
*** Bug 464132 has been marked as a duplicate of this bug. ***
Comment 21 Nate Graham 2023-04-21 14:55:52 UTC
*** Bug 420263 has been marked as a duplicate of this bug. ***
Comment 22 postix 2023-04-22 10:00:19 UTC
*** Bug 467367 has been marked as a duplicate of this bug. ***
Comment 23 postix 2023-04-22 10:00:31 UTC
*** Bug 467776 has been marked as a duplicate of this bug. ***
Comment 24 Harald Sitter 2023-04-24 21:59:12 UTC
Git commit fb0c1657b531225b0cf18b719eee4dee952d6bf1 by Harald Sitter.
Committed on 24/04/2023 at 21:59.
Pushed by sitter into branch 'master'.

yet more QRect right() fixes

QRect::right and topRight are off by one for historical reasons. This
caused incorrect default positioning when a (new) screen gets enabled
and automatically positioned.

To solve this entire source of problems let's stop using the faulty
API and instead calculate the offsets manually. More code but
no trap doors. The original code was written as though things were
not off by one anyway.

M  +17   -12   kcm/output_model.cpp

https://invent.kde.org/plasma/kscreen/commit/fb0c1657b531225b0cf18b719eee4dee952d6bf1
Comment 25 Harald Sitter 2023-04-25 07:04:38 UTC
Git commit fee471e09bcbfcbd6f6cab05b605a0916162fa43 by Harald Sitter.
Committed on 24/04/2023 at 21:59.
Pushed by sitter into branch 'Plasma/5.27'.

yet more QRect right() fixes

QRect::right and topRight are off by one for historical reasons. This
caused incorrect default positioning when a (new) screen gets enabled
and automatically positioned.

To solve this entire source of problems let's stop using the faulty
API and instead calculate the offsets manually. More code but
no trap doors. The original code was written as though things were
not off by one anyway.


(cherry picked from commit fb0c1657b531225b0cf18b719eee4dee952d6bf1)

M  +17   -12   kcm/output_model.cpp

https://invent.kde.org/plasma/kscreen/commit/fee471e09bcbfcbd6f6cab05b605a0916162fa43
Comment 26 Félim Whiteley 2023-05-15 13:05:49 UTC
I'm still seeing this on KDE Neon, I'm on a dark theme and have the light 1 pixel highlight...thing... and I can see the Windows on my central monitor, their light pixel edge on the left screen and same on others.

Operating System: KDE neon 5.27
KDE Plasma Version: 5.27.5
KDE Frameworks Version: 5.105.0
Qt Version: 5.15.9
Kernel Version: 5.19.0-41-generic (64-bit)
Graphics Platform: X11
Processors: 12 × AMD Ryzen 5 2600X Six-Core Processor
Memory: 62.7 GiB of RAM
Graphics Processor: AMD Radeon RX 580 Series

I'll attache a zoomed in shot of the white line on edge of the right side of the left monitor.
Comment 27 Félim Whiteley 2023-05-15 13:08:37 UTC
Created attachment 158972 [details]
White edge of central screen appearing on left monitor
Comment 28 Nate Graham 2023-05-15 13:14:20 UTC
That doesn't look like a monitor overlap, it looks like the window outline of a maximized window bleeding onto adjacent screens. Which is Bug 457565.
Comment 29 Félim Whiteley 2023-05-18 09:52:07 UTC
(In reply to Nate Graham from comment #28)
> That doesn't look like a monitor overlap, it looks like the window outline
> of a maximized window bleeding onto adjacent screens. Which is Bug 457565.

It's not a fullscreen window but it is snapped to the edge of the centre one... not sure if that's different or not.
Comment 30 Nate Graham 2023-05-18 14:39:41 UTC
Same issue, yeah.
Comment 31 Nate Graham 2023-09-14 22:41:25 UTC
*** Bug 471131 has been marked as a duplicate of this bug. ***