diff --git a/effects/screenshot/screenshot.cpp b/effects/screenshot/screenshot.cpp index d91ef46ad0..b01bacd553 100644 --- a/effects/screenshot/screenshot.cpp +++ b/effects/screenshot/screenshot.cpp @@ -225,6 +225,7 @@ void ScreenShotEffect::sendReplyImage(const QImage &img) m_scheduledGeometry = QRect(); m_multipleOutputsImage = QImage(); m_multipleOutputsRendered = QRegion(); + m_captureCursor = false; } QString ScreenShotEffect::saveTempImage(const QImage &img) @@ -271,7 +272,7 @@ void ScreenShotEffect::screenshotForWindow(qulonglong winid, int mask) } } -QString ScreenShotEffect::screenshotFullscreen() +QString ScreenShotEffect::screenshotFullscreen(bool captureCursor) { if (!calledFromDBus()) { return QString(); @@ -284,11 +285,12 @@ QString ScreenShotEffect::screenshotFullscreen() m_replyMessage = message(); setDelayedReply(true); m_scheduledGeometry = effects->virtualScreenGeometry(); + m_captureCursor = captureCursor; effects->addRepaintFull(); return QString(); } -QString ScreenShotEffect::screenshotScreen(int screen) +QString ScreenShotEffect::screenshotScreen(int screen, bool captureCursor) { if (!calledFromDBus()) { return QString(); @@ -302,6 +304,7 @@ QString ScreenShotEffect::screenshotScreen(int screen) sendErrorReply(QDBusError::Failed, "Invalid screen requested"); return QString(); } + m_captureCursor = captureCursor; m_replyConnection = connection(); m_replyMessage = message(); setDelayedReply(true); @@ -309,7 +312,7 @@ QString ScreenShotEffect::screenshotScreen(int screen) return QString(); } -QString ScreenShotEffect::screenshotArea(int x, int y, int width, int height) +QString ScreenShotEffect::screenshotArea(int x, int y, int width, int height, bool captureCursor) { if (!calledFromDBus()) { return QString(); @@ -324,6 +327,7 @@ QString ScreenShotEffect::screenshotArea(int x, int y, int width, int height) sendErrorReply(QDBusError::Failed, "Invalid area requested"); return QString(); } + m_captureCursor = captureCursor; m_replyConnection = connection(); m_replyMessage = message(); setDelayedReply(true); @@ -365,6 +369,10 @@ QImage ScreenShotEffect::blitScreenshot(const QRect &geometry) } #endif + if (m_captureCursor) { + grabPointerImage(img, geometry.x(), geometry.y()); + } + return img; } diff --git a/effects/screenshot/screenshot.h b/effects/screenshot/screenshot.h index 8e4fa57a6c..4f43c86842 100644 --- a/effects/screenshot/screenshot.h +++ b/effects/screenshot/screenshot.h @@ -58,16 +58,18 @@ public Q_SLOTS: /** * Saves a screenshot of all screen into a file and returns the path to the file. * Functionality requires hardware support, if not available a null string is returned. + * @param captureCursor Whether to include the cursor in the image * @returns Path to stored screenshot, or null string in failure case. **/ - Q_SCRIPTABLE QString screenshotFullscreen(); + Q_SCRIPTABLE QString screenshotFullscreen(bool captureCursor = false); /** * Saves a screenshot of the screen identified by @p screen into a file and returns the path to the file. * Functionality requires hardware support, if not available a null string is returned. * @param screen Number of screen as numbered by QDesktopWidget + * @param captureCursor Whether to include the cursor in the image * @returns Path to stored screenshot, or null string in failure case. **/ - Q_SCRIPTABLE QString screenshotScreen(int screen); + Q_SCRIPTABLE QString screenshotScreen(int screen, bool captureCursor = false); /** * Saves a screenshot of the selected geometry into a file and returns the path to the file. * Functionality requires hardware support, if not available a null string is returned. @@ -75,9 +77,10 @@ public Q_SLOTS: * @param y Left upper y coord of region * @param width Width of the region to screenshot * @param height Height of the region to screenshot + * @param captureCursor Whether to include the cursor in the image * @returns Path to stored screenshot, or null string in failure case. **/ - Q_SCRIPTABLE QString screenshotArea(int x, int y, int width, int height); + Q_SCRIPTABLE QString screenshotArea(int x, int y, int width, int height, bool captureCursor = false); Q_SIGNALS: Q_SCRIPTABLE void screenshotCreated(qulonglong handle); @@ -98,6 +101,7 @@ private: QRect m_cachedOutputGeometry; QImage m_multipleOutputsImage; QRegion m_multipleOutputsRendered; + bool m_captureCursor = false; }; } // namespace