diff --git a/main.cpp b/main.cpp index caada8c..718d139 100644 --- a/main.cpp +++ b/main.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include bool verbose = false; @@ -45,7 +44,6 @@ int main(int argc, char *argv[]) { parser.addOption(v); parser.process(a); verbose = parser.isSet(v); - PlatformBackend::inst().getCursor().save("test.png", "PNG"); MainWindow w; w.show(); diff --git a/platformspecifics/mac/macbackend.cpp b/platformspecifics/mac/macbackend.cpp index af2f4e5..cdfec2a 100644 --- a/platformspecifics/mac/macbackend.cpp +++ b/platformspecifics/mac/macbackend.cpp @@ -2,5 +2,5 @@ QPixmap PlatformBackend::getCursor() { #warning "TODO: Mac backend" - return QPixmap(); + return std::tuple(QPoint(0, 0), QPixmap()); } diff --git a/platformspecifics/u32/u32backend.cpp b/platformspecifics/u32/u32backend.cpp index b190328..60e231e 100644 --- a/platformspecifics/u32/u32backend.cpp +++ b/platformspecifics/u32/u32backend.cpp @@ -4,18 +4,18 @@ #include #include -QPixmap PlatformBackend::getCursor() { +std::tuple getCursor() { CURSORINFO cursorInfo; cursorInfo.cbSize = sizeof(cursorInfo); if (GetCursorInfo(&cursorInfo)) { if (cursorInfo.flags == CURSOR_SHOWING) { ICONINFO info; // It took me 5 hours to get to here if (GetIconInfo(cursorInfo.hCursor, &info)) { - return QtWin::fromHBITMAP(info.hbmColor); + return std::tuple(QPoint(info.xHotspot, info.yHotspot), QtWin::fromHBITMAP(info.hbmColor)); } else - return QPixmap(); + return std::tuple(QPoint(0, 0), QPixmap()); } else - return QPixmap(); + return std::tuple(QPoint(0, 0), QPixmap()); } else - return QPixmap(); + return std::tuple(QPoint(0, 0), QPixmap()); } diff --git a/platformspecifics/u32/u32backend.hpp b/platformspecifics/u32/u32backend.hpp index 4d082d2..e779fc5 100644 --- a/platformspecifics/u32/u32backend.hpp +++ b/platformspecifics/u32/u32backend.hpp @@ -5,7 +5,7 @@ class PlatformBackend { public: - QPixmap getCursor(); + std::tuple getCursor(); static PlatformBackend &inst() { static PlatformBackend inst; return inst; diff --git a/platformspecifics/x11/x11backend.cpp b/platformspecifics/x11/x11backend.cpp index f347f54..2281831 100644 --- a/platformspecifics/x11/x11backend.cpp +++ b/platformspecifics/x11/x11backend.cpp @@ -6,17 +6,19 @@ #include #include -QPixmap PlatformBackend::getCursor() { +std::tuple PlatformBackend::getCursor() { xcb_connection_t *connection = QX11Info::connection(); xcb_xfixes_get_cursor_image_cookie_t cursorCookie = xcb_xfixes_get_cursor_image_unchecked(connection); QScopedPointer cursorReply(xcb_xfixes_get_cursor_image_reply(connection, cursorCookie, NULL)); if (cursorReply.isNull()) { - return QPixmap(); + return std::tuple(QPoint(0, 0), QPixmap()); } quint32 *pixels = xcb_xfixes_get_cursor_image_cursor_image(cursorReply.data()); if (!pixels) { - return QPixmap(); + return std::tuple(QPoint(0, 0), QPixmap()); } - return QPixmap::fromImage(QImage((quint8 *)pixels, cursorReply->width, cursorReply->height, QImage::Format_ARGB32_Premultiplied)); + return std::tuple(QPoint(cursorReply->xhot, cursorReply->yhot), + QPixmap::fromImage(QImage((quint8 *)pixels, cursorReply->width, cursorReply->height, + QImage::Format_ARGB32_Premultiplied))); } diff --git a/platformspecifics/x11/x11backend.hpp b/platformspecifics/x11/x11backend.hpp index ab4ed57..808ad42 100644 --- a/platformspecifics/x11/x11backend.hpp +++ b/platformspecifics/x11/x11backend.hpp @@ -5,7 +5,7 @@ class PlatformBackend { public: - QPixmap getCursor(); + std::tuple getCursor(); static PlatformBackend &inst() { static PlatformBackend inst; return inst; diff --git a/screenshotutil.cpp b/screenshotutil.cpp index b052d53..85c821e 100644 --- a/screenshotutil.cpp +++ b/screenshotutil.cpp @@ -2,11 +2,19 @@ #include #include +#include #include #include +#include QPixmap *screenshotutil::fullscreen() { - return window(0); + QPixmap *noCursor = window(0); + QScopedPointer p(noCursor); + QPixmap *withCursor = new QPixmap(noCursor->size()); + QPainter painter(withCursor); + auto cursorData = PlatformBackend::inst().getCursor(); + painter.drawPixmap(std::get<0>(cursorData), std::get<1>(cursorData)); + return withCursor; } QPixmap *screenshotutil::window(long wid) {