Make the screen size calculation work for Win too

Fixes #9
This commit is contained in:
ArsenArsen 2017-07-05 16:51:02 +02:00
parent 698d123815
commit e609a1a9a5

View File

@ -21,17 +21,18 @@ QPixmap screenshotutil::fullscreen(bool cursor) {
painter.begin(&image); painter.begin(&image);
} else { } else {
#endif #endif
int height = qAbs(smallestCoordinate.y()), width = qAbs(smallestCoordinate.x()); // qute abs int height = 0, width = 0;
int ox = smallestCoordinate.x() * -1, oy = smallestCoordinate.y() * -1;
for (QScreen *screen : QApplication::screens()) { for (QScreen *screen : QApplication::screens()) {
QRect geo = screen->geometry(); QRect geo = screen->geometry();
width = qMax(geo.left() + geo.width(), width); width = qMax(ox + geo.left() + geo.width(), width);
height = qMax(geo.top() + geo.height(), height); height = qMax(oy + geo.top() + geo.height(), height); // qute abs
} }
image = QPixmap(width, height); image = QPixmap(width, height);
image.fill(Qt::transparent); image.fill(Qt::transparent);
width = 0; width = 0;
painter.begin(&image); painter.begin(&image);
painter.translate(qAbs(smallestCoordinate.x()), qAbs(smallestCoordinate.y())); painter.translate(ox, oy);
for (QScreen *screen : QApplication::screens()) { for (QScreen *screen : QApplication::screens()) {
QPixmap currentScreen = window(0, screen); QPixmap currentScreen = window(0, screen);