diff options
author | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-02-16 16:26:15 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-03-16 13:24:51 +0000 |
commit | 3acd8d9aa463ffcc7d63d5262c0a66577c38f556 (patch) | |
tree | a0cd2e3da3e6fd5eb101af35a00baba79297dc54 /src/plugins | |
parent | 8e12367a94ce1245da87b0440dc43e31e6a9b76f (diff) |
Support grabWindow() in linuxfb
Task-number: QTBUG-44465
Change-Id: Id4b0fcbcce3e005c1f147fa227ef987daac20fd5
Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp | 28 | ||||
-rw-r--r-- | src/plugins/platforms/linuxfb/qlinuxfbscreen.h | 3 |
2 files changed, 30 insertions, 1 deletions
diff --git a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp index 1c3854182f..5407fa66dc 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp +++ b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp @@ -33,6 +33,7 @@ #include "qlinuxfbscreen.h" #include <QtPlatformSupport/private/qfbcursor_p.h> +#include <QtPlatformSupport/private/qfbwindow_p.h> #include <QtCore/QRegularExpression> #include <QtGui/QPainter> @@ -421,5 +422,32 @@ QRegion QLinuxFbScreen::doRedraw() return touched; } +// grabWindow() grabs "from the screen" not from the backingstores. +// In linuxfb's case it will also include the mouse cursor. +QPixmap QLinuxFbScreen::grabWindow(WId wid, int x, int y, int width, int height) const +{ + if (!wid) { + if (width < 0) + width = mFbScreenImage.width() - x; + if (height < 0) + height = mFbScreenImage.height() - y; + return QPixmap::fromImage(mFbScreenImage).copy(x, y, width, height); + } + + QFbWindow *window = windowForId(wid); + if (window) { + const QRect geom = window->geometry(); + if (width < 0) + width = geom.width() - x; + if (height < 0) + height = geom.height() - y; + QRect rect(geom.topLeft() + QPoint(x, y), QSize(width, height)); + rect &= window->geometry(); + return QPixmap::fromImage(mFbScreenImage).copy(rect); + } + + return QPixmap(); +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/linuxfb/qlinuxfbscreen.h b/src/plugins/platforms/linuxfb/qlinuxfbscreen.h index 0cb9961599..1adce2189b 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbscreen.h +++ b/src/plugins/platforms/linuxfb/qlinuxfbscreen.h @@ -50,7 +50,8 @@ public: bool initialize(); -public slots: + QPixmap grabWindow(WId wid, int x, int y, int width, int height) const Q_DECL_OVERRIDE; + QRegion doRedraw() Q_DECL_OVERRIDE; private: |