summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authoraavit <qt_aavit@ovi.com>2012-08-17 14:15:36 +0200
committerQt by Nokia <qt-info@nokia.com>2012-08-18 10:55:47 +0200
commit94ac17c2ccbe3b3f3671848afda9430be214f8d5 (patch)
tree2de3e6785846238c76ec35f0b75e0c0c78b579d0 /src/plugins
parentf6c58d242aa6c75d735ce9484c1f1acac3444ba6 (diff)
Clean up QScreen::grabWindow()
Handle 0 WId parameter as meaning "desktop window"/whole screen. Also, re-add the default values for the grab area, both for convenience and compatibility with QPixmap::grabWindow() in Qt4. Update the screenshot example so it doesn't comlain about usage of deprecated QPixmap::grabWindow(). Change-Id: I2ad229113ddb8ded0388f2ebc0e8c703c6657f1f Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/windows/qwindowsscreen.cpp2
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.cpp10
2 files changed, 9 insertions, 3 deletions
diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp
index bb2dd579ee..231327e580 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.cpp
+++ b/src/plugins/platforms/windows/qwindowsscreen.cpp
@@ -183,6 +183,8 @@ Q_GUI_EXPORT QPixmap qt_pixmapFromWinHBITMAP(HBITMAP bitmap, int hbitmapFormat =
QPixmap QWindowsScreen::grabWindow(WId window, int x, int y, int width, int height) const
{
+ // TODO: handle window==0, i.e. grab whole screen
+
if (QWindowsContext::verboseIntegration)
qDebug() << __FUNCTION__ << window << x << y << width << height;
RECT r;
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp
index 0b362c5256..d92004b1ac 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.cpp
+++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
@@ -277,6 +277,13 @@ QPixmap QXcbScreen::grabWindow(WId window, int x, int y, int width, int height)
if (width == 0 || height == 0)
return QPixmap();
+ // TODO: handle multiple screens
+ QXcbScreen *screen = const_cast<QXcbScreen *>(this);
+ xcb_window_t root = screen->root();
+
+ if (window == 0)
+ window = root;
+
xcb_get_geometry_cookie_t geometry_cookie = xcb_get_geometry_unchecked(xcb_connection(), window);
xcb_get_geometry_reply_t *reply =
@@ -291,9 +298,6 @@ QPixmap QXcbScreen::grabWindow(WId window, int x, int y, int width, int height)
if (height < 0)
height = reply->height - y;
- // TODO: handle multiple screens
- QXcbScreen *screen = const_cast<QXcbScreen *>(this);
- xcb_window_t root = screen->root();
geometry_cookie = xcb_get_geometry_unchecked(xcb_connection(), root);
xcb_get_geometry_reply_t *root_reply =
xcb_get_geometry_reply(xcb_connection(), geometry_cookie, NULL);