Bug 413691 - Color picker picks color from the wrong place when monitors are configured using xrandr (using --scale, --pos and --panning parameters)
Summary: Color picker picks color from the wrong place when monitors are configured us...
Status: RESOLVED UPSTREAM
Alias: None
Product: kcolorchooser
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Manjaro Linux
: NOR normal
Target Milestone: ---
Assignee: Hugo Parente Lima
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-10-31 23:00 UTC by tamius.han
Modified: 2019-11-04 20:45 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Bug demo (video) (2.47 MB, video/mp4)
2019-10-31 23:00 UTC, tamius.han
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tamius.han 2019-10-31 23:00:09 UTC
Created attachment 123634 [details]
Bug demo (video)

SUMMARY

My left monitor has a lower PPI than my main monitor. Because Xorg does not support per-monitor PPI scaling, I'm compensating for that by running the monitor at higher-than-native resolution (details about the setup are in 'ADDITIONAL INFORMATION' section). When I try to pick a color, kcolorchooser will pick a color from some pixels away.

The issue appears to be caused when using --pos (or --panning with offset defined) parameter configuring monitor setup via xrandr in conjunction with xrandr --scale. The size of offset doesn't seem to depend on actual scale factor, but it is dependent on offset.

This issue doesn't happen when monitors are configured through settings module from the get-go.


STEPS TO REPRODUCE
1. Have at least two monitors. Run the leftmost at higher-than-native resolution by using e.g. `xrandr --scale 1.5x1.5 --panning [monitor resolution, but multiplied by 1.5]`
2. Run color picker
3. Try to pick a color

OBSERVED RESULT
Color picker picks a color from a spot that's offset to the right from the cursor

EXPECTED RESULT
Color picker picks a color from under the cursor.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma:  5.3.7-2-MANJARO
(available in About System)
KDE Plasma Version: 5.17.1
KDE Frameworks Version: 5.63.0
Qt Version: 5.13.1
kcolorchooser: 19.08.2 (not present in select)


ADDITIONAL INFORMATION

Scroll to bottom for xrandr output.


  * Hardware:

AMD Ryzen 7 2700X
nVidia 2080Ti with proprietary drivers (nvidia-430xx)


  * Extra things to note about my system
 
Since Display Settings don't support setting scale factors, I configure my monitor layout with script that runs after login:

xrandr --output DP-0 --scale 1.5x1.5 --pos 0x275 --panning 2880x1620+0+275            # left monitor
xrandr --output DP-2 --mode 5120x2160 --pos 2880x0 --panning 5120x2160+2880+0         # center monitor, primary
xrandr --output HDMI-0 --scale 1.4x1.4 --pos 8000x168 --panning 3584x1512+8000+168    # right monitor

Two of the monitors are upscaled, one is running at native resoluton. Global scale is set to 1.3, but changing that doesn't seem to affect the bug behaviour for me (I didn't do full login/logout, just restarted kcolorchooser).

The issue appears to be related to usage of the --pos/--panning parameter in xrandr when configuring monitors.



  * Testing I've done

Before I get into this, the following numbers could be off by a pixel or two.


  (0) I've tried to reproduce this issue on my laptop (single screen). Setting scale and panning via xrandr does not seem to have an effect on a single monitor setup.


  (1) Using my standard monitor setup, I've measured the offset between color picker cursor and the position it picked color. Color picking happened 864px to the right of reticle (give or take a pixel) on the non-scaled (center/DP-2) monitor (there's no vertical offset). On the right monitor (HDMI-0), the color is being picked from a spot 2401x52 to the left and bottom. On the left monitor (DP-0), the offset is 0x82 (right and down).

Interestingly enough — and this paragraph is going to be slightly off-topic — 864px number comes up when experiencing screen shift or other kinds of similar corruption as well, e.g. it manifests itself in the spectacle screen shift bug as well (https://bugs.kde.org/show_bug.cgi?id=385885), as well as in the recent cases of UI/window corruption in just about every Qt-based video player that exists (vlc/smplayer/baka-mplayer — no bugs reported yet). Notable differences: these other bugs shift towards the left.


  (2) I've swapped locations of my monitors by running xrandr and restarting color picker. I re-arranged monitors with the following set of commands

xrandr --output DP-2 --mode 5120x2160 --pos 0x0 --panning 5120x2160+0+0              # Left, primary
xrandr --output DP-0 --scale 1.5x1.5 --pos 5120x275 --panning 2880x1620+5120+275     # center
xrandr --output HDMI-0 --scale 1.4x1.4 --pos 8000x168 --panning 3584x1512+8000+168   # right
prestart plasmashell kwin_x11     

# where 'prestart plasmashell kwin_x11' is a shorthand for: 
# killall -9 plasmashell; killall -9 kwin_x11; plasmashell & ; kwin_x11 & 

At this point it's worth noting that restarting kwin and plasmashell is important, because funny stuff starts to happen otherwise.

When the non-scaled monitor (DP-2) is in the far left position, kcolorchooser works fine — but only on DP2. It's broken on the other two monitors. On the now-center monitor (DP-2), the offset is now about 1539px to the right, 87px down (give or take a pixel). On the rightmost monitor (HDMI-0), color is being picked about 2402 px to the right and 52 px under the position of the reticle. 


  (3) Same arrangement of monitors as above, except center monitor (DP-0) is the primary one now. The offsets remain the same.


  (4) I've tried putting my main/non-scaled (DP-2) monitor to the right:

xrandr --output DP-0 --scale 1.5x1.5 --pos 0x275 --panning 2880x1620+0+275            # Left
xrandr --output HDMI-0 --scale 1.4x1.4 --pos 2280x168x  --panning 3584x1512+2880+168  # Center
xrandr --output DP-2 --mode 5120x2160 --pos 6464x0 --panning 5120x2160+6464+0         # Right, primary
prestart plasmashell kwin_x11
 
On the non-scaled monitor (DP-2), the vertical offset seems to be gone. Horizontal offset persists — color is being picked 1941 pixels to the right. Offset on HDMI-0 is now 864x52. Color picking on the DP-0 (leftmost monitor) is offset by 0x82px. 


  (5) Initial monitor loadout, but this time all monitors are aligned at the top:

xrandr --output DP-0 --scale 1.5x1.5 --pos 0x0 --panning 2880x1620+0+0            # left monitor
xrandr --output DP-2 --mode 5120x2160 --pos 2880x0 --panning 5120x2160+2880+0     # center monitor, primary
xrandr --output HDMI-0 --scale 1.4x1.4 --pos 8000x0 --panning 3584x1512+8000+0    # right monitor
prestart plasmashell kwin_x11


Horizontal offsets remain as they were in (1), vertical offsets are gone.


  (6) Unplugging the big one (DP-2), both monitors aligned at the top:

xrandr --output DP-0 --scale 1.5x1.5 --pos 0x0 --panning 2880x1620+0+0 
xrandr --output HDMI-0 --scale 1.4x1.4 --pos 2280x0 --panning 3584x1512+2880+0
prestart plasmashell kwin_x11

No offset on left display (DP-0), 864x0px offset on the right monitor (HDMI-0)


  (7) Jack up the scaling factor. Don't correct --pos and --panning.

xrandr --output DP-0 --scale 3x3 --pos 0x275 --panning 2880x1620+0+275            # left monitor
xrandr --output DP-2 --mode 5120x2160 --pos 2880x0 --panning 5120x2160+2880+0     # center monitor, primary
xrandr --output HDMI-0 --scale 3x3 --pos 8000x168 --panning 3584x1512+8000+168    # right monitor

Color picker has the same sort of offset as it had in (1), both on DP-0 and DP-3. (left/scaled and center/unscaled). This seems to indicate that usage of --scale parameter with xrandr probably isn't causing the issue on its own.


  (8) Same as (7), but we throw away --pos across the board and just increase offsets in --panning

xrandr --output DP-0 --scale 3x3 --pos 0+550                       # left monitor
xrandr --output DP-2 --mode 5120x2160 --panning 5120x2160+5760+0   # center monitor, primary
xrandr --output HDMI-0 --scale 3x3 --panning 3584x1512+8000+168    # right monitor
prestart kwin_x11 plasmashell

Vertical offset on DP-0 is now 165px (twice as much as in (1)). Horizontal offset on DP-2 is 1729 (twice as much as in (1)). 


  (9) Let's re-test case (0) on my laptop, but this time we'll only define panning

In this case, the bug doesn't happen because xrandr seems to ignore --pos parameter when there's only one monitor connected to the computer.



  * Xrandr output (desktop, normal)

Screen 0: minimum 8 x 8, current 11584 x 2160, maximum 32767 x 32767
DP-0 connected 2880x1620+0+275 (normal left inverted right x axis y axis) 477mm x 268mm
   1920x1080     60.00*+  59.94    50.00  
   1680x1050     59.95  
   1440x900      59.89  
   1280x1024     75.02    60.02  
   1280x960      60.00  
   1280x720      60.00    59.94    50.00  
   1024x768      75.03    70.07    60.00  
   800x600       75.00    72.19    60.32    56.25  
   720x576       50.00  
   720x480       59.94  
   640x480       75.00    72.81    59.94    59.93  
DP-1 disconnected (normal left inverted right x axis y axis)
HDMI-0 connected 3584x1512+8000+168 (normal left inverted right x axis y axis) 798mm x 334mm
   2560x1080     60.00*+
   1920x1080     60.00    59.94    50.00    29.97  
   1680x1050     59.95  
   1600x900      60.00  
   1280x1024     75.02    60.02  
   1280x720      60.00    59.94    50.00  
   1152x864      75.00  
   1024x768      75.03    60.00  
   800x600       75.00    60.32  
   720x576       50.00  
   720x480       59.94  
   640x480       75.00    59.94    59.93  
DP-2 connected primary 5120x2160+2880+0 (normal left inverted right x axis y axis) 800mm x 330mm
   3440x1440     59.97 +  49.99  
   5120x2160     60.00*   30.00  
   3840x2160     60.00    30.00  
   1920x1080     60.00    59.94  
   1600x900      60.00  
   1280x1024     60.02  
   1280x800      59.81  
   1280x720      60.00    59.94  
   1152x864      59.96  
   1024x768      60.00  
   800x600       60.32  
   720x480       59.94  
   640x480       59.94    59.93  
DP-3 disconnected (normal left inverted right x axis y axis)
DP-4 disconnected (normal left inverted right x axis y axis)
DP-5 disconnected (normal left inverted right x axis y axis)
USB-C-0 disconnected (normal left inverted right x axis y axis)
Comment 1 Hugo Parente Lima 2019-11-04 18:21:46 UTC
Hi,

KColorchooser is just a QColorDialog with extra buttons injected, so you must file this bust to Qt5[1], since there's not much we can do on KDE side.

Thanks!

[1] https://bugreports.qt.io/
Comment 2 Christoph Feck 2019-11-04 20:45:30 UTC
Yep, please report this issue to Qt developers.