Skip to content

Commit c80ed93

Browse files
committed
Set device pixel ratio for grim screenshot
Grim returns a bitmap with the physical size of the screen. This needs to be scaled back to be displayed as underlay for Flameshot on screens where logical size differs from the physical size (i.e. scale is active). In order to do this, set the device pixel ratio, see <https://doc.qt.io/qt-5/qpixmap.html#setDevicePixelRatio>. Please note that this works only properly with integer scale. `QScreen::devicePixelRatio()` rounds when fractional scale is active on Wayland.
1 parent 5f30631 commit c80ed93

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/utils/screengrabber.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ void ScreenGrabber::generalGrimScreenshot(bool& ok, QPixmap& res)
3737
Process.start(program, arguments);
3838
if (Process.waitForFinished()) {
3939
res.loadFromData(Process.readAll());
40+
QScreen* currentScreen = QGuiAppCurrentScreen().currentScreen();
41+
res.setDevicePixelRatio(currentScreen->devicePixelRatio());
4042
ok = true;
4143
} else {
4244
ok = false;

0 commit comments

Comments
 (0)