summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb/qxcbcursor.cpp
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@theqtcompany.com>2015-03-20 17:30:26 +0100
committerPaul Olav Tvete <paul.tvete@theqtcompany.com>2015-04-14 15:12:30 +0000
commit4e1b09fa8ff1a9ab42c0a29a2efe1ae7f4700d71 (patch)
tree67c75c66f6ba4b236943b254717221b959f09997 /src/plugins/platforms/xcb/qxcbcursor.cpp
parenta02c04a51b34fc780fa680383f2aee3b3f37fa51 (diff)
Keep screen geometries from overlapping
The simple mapping of dividing each position by the devicePixelRatio does not work when screens have different DPR. If the low-DPR screen above or to the left of the high-DPR screen, the geometries will overlap in the Qt coordinate system. This change introduces a new mapping where the origin of each screen does not move. This mapping is not perfect: it will have gaps between contiguous screens. However, it will keep non-overlapping screens non-overlapping in the Qt coordinate system. Since there is no longer a simple linear coordinate transform, we have to add screen-dependent mapping functions, and distinguish between local and non-local coordinates. A side benefit is that the code is now easier to read, since we remove most manual coordinate transformation. We also have to cache the screen of each window: since we send resize events before screen change events, we cannot rely on QPlatformWindow::screen() (which is set from the screen change event). Task-number: QTBUG-45076 Change-Id: Ie95a0b71ae274e02903caa102a98af2050a44129 Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbcursor.cpp')
-rw-r--r--src/plugins/platforms/xcb/qxcbcursor.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/plugins/platforms/xcb/qxcbcursor.cpp b/src/plugins/platforms/xcb/qxcbcursor.cpp
index e30cc26313..e51ab85e30 100644
--- a/src/plugins/platforms/xcb/qxcbcursor.cpp
+++ b/src/plugins/platforms/xcb/qxcbcursor.cpp
@@ -633,18 +633,17 @@ void QXcbCursor::queryPointer(QXcbConnection *c, xcb_window_t *rootWin, QPoint *
QPoint QXcbCursor::pos() const
{
- const int dpr = int(m_screen->devicePixelRatio());
QPoint p;
queryPointer(connection(), 0, &p);
- return p / dpr;
+ return m_screen->mapFromNative(p);
}
void QXcbCursor::setPos(const QPoint &pos)
{
- const int dpr = int(m_screen->devicePixelRatio());
+ const QPoint xPos = m_screen->mapToNative(pos);
xcb_window_t root = 0;
queryPointer(connection(), &root, 0);
- xcb_warp_pointer(xcb_connection(), XCB_NONE, root, 0, 0, 0, 0, pos.x()*dpr, pos.y()*dpr);
+ xcb_warp_pointer(xcb_connection(), XCB_NONE, root, 0, 0, 0, 0, xPos.x(), xPos.y());
xcb_flush(xcb_connection());
}