https://bugs.kde.org/show_bug.cgi?id=502047

--- Comment #26 from Noah Davis <noaha...@gmail.com> ---
(In reply to Jonas Ryssel from comment #18)
> I have a strong suspicion that sometimes KWin and Spectacle disagree on the
> resolution of displays when using fractional scaling.

That could be the case. I was recently told by KWin a developer that it's
actually impossible to properly get the device pixel ratio on Wayland using Qt
or KDE APIs. Most of the time QScreen::devicePixelRatio is good enough, but
there are edge cases.

> With my setup (where the bug is present) `the display is set to 2560x2880
> with 150% scaling.
> If I take a full screen screenshot using the "current screen" option in
> spectacle, the resolution is 2561x1440.
> This suggests that spectacle (or QT or something else) thinks that the
> display is 1 pixel wider than what KWin thinks, and if I then place that
> display to the left, the displays will overlap by 1 pixel, causing the issue.

The screenshot for this case actually comes directly from KWin's screenshot
plugin without modification, so I'm not totally sure what's going on there. I
think 2560 is likely being divided by 1.5 somewhere (1706.67) and rounded
(1707), then multiplied by 1.5 by Spectacle (2560.5) and rounded again (2561).
Unfortunately there's not a lot that can be done about that since screen and
window sizes are defined in logical coordinates (physical pixel size divided by
DPR) as integers. Qt's QScreen and QWindow classes use integers for sizes and
positions, but Wayland itself even uses integers for sizes and positions in
logical coordinates. This means some precision is guaranteed to be lost.

> ---- My (unqualified) guess on what causes the issue / what to look for in
> the code ----
> I think there are two bugs which would fix this issue, and I don't know
> which one is easier to fix (probably nr. 1).
> 
> 1. There is a math issue somewhere in the code (duh!).
> In my tests the issue only seems to be present when `resolution/scaling
> factor` calculation results in the fractional part being above .5 (i.e. it
> would be rounded up), which suggests a rounding error... I have however also
> found a case where the faction is above .5 and the bug isn't present, so it
> is only a hunch.
> I guess this relates to how "weird" resolutions causes the issue. I have
> another PC setup where I couldn't reproduce the issue, but once I switched
> to a 1368x768 resolution, it became much easier to reproduce it without
> purposefully overlapping the displays.
> 
> 2. If you have overlapping displays, Spectacle seemingly takes your mouse
> offset relative to the top left corner of one display, then selects an area
> with the same offset but relative to the other display's top left corner.
> 
> Sorry for rambling ;)

Number 2 is probably what I'll end up having to do. I don't mind ramblers who
are helping :)

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to