Unbreak screen grabbing
Unbreak screen grabbing
After 39f712a2, KMag would only show small parts of the screen and its view was overlayed with black and gray areas and even image recursion. The cursor position would also not correspond to its actual position.
This is due to changing QApplication::desktop()->winId()
to the window
id of KMag, which is wrong when the whole screen should be grabbed
instead.
Using 0
for the window id is interpreted as the root window by Qt and
fixes the issue.
Test Plan:
Move cursor to the top left and top right corner of the screen. KMag should always magnify the correct area without any black bars, and the cursor position should be correctly indicated too.
Restore grabbing taskbar and multiple screens
39f712a2 also prevented KMag from showing the taskbar in a single-screen
setup as well as content on secondary screens in a multi-screen setup,
because screen()->availableGeometry()->width()
is not a suitable
replacement for QApplication::desktop()->width()
.
Qt provides a multitude of options, even when not using deprecated
functions the original commit tried to port away from:
availableGeometry()
, availableVirtualGeometry()
, virtualGeometry()
and geometry()
. To include all screens, the virtual*
variants are
needed, while on single screens the available*
variants do not include
the area covered by the taskbar. Therefore for the purpose of KMag,
which should show everything, virtualGeometry()
is the correct
function to use, switching to the more specific virtualSize()
when
applicable.
In addition, in KMagZoomView::mouseMoveEvent
we can eliminate one
extra unneeded variable inside a block, hiding the identically
functioning variable of the same name outside that block.
Test Plan:
- Taskbar shows on single screen-screen setup.
- All screens in a multi-screen setup can be magnified, gaps between screens are correctly shown with black bars.
- Cursor position is correct everywhere.
- HiDPI mode works too.
- Note 1: KMag currently only supports X11.
- Note 2: Testing was only performed with Qt5.
- Note 3: Choose "Mouse Mode", since "Window Mode" has been partially broken way back in 095196f3 already and "Screen Edge Mode" from 1884b51a as a replacement for the questionable "Screen Mode" has never been forward-ported to the Qt4 branch created before that commit.