From c173a5071906867de9da26ee8f49224b23c2ef1d Mon Sep 17 00:00:00 2001
From: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Date: Thu, 18 Jun 2015 16:58:01 +0200
Subject: [PATCH] Remove QT_DEVICE_PIXEL_RATIO support from xcb

It will be reintroduced as a cross-platform feature.

Task-number: QTBUG-46615
Change-Id: Ia6d03275018b2a25ebed438fe51f15e491f1c3ff
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
---
 src/plugins/platforms/xcb/qxcbbackingstore.cpp   |  45 ++----
 src/plugins/platforms/xcb/qxcbconnection_xi2.cpp |  16 +-
 src/plugins/platforms/xcb/qxcbcursor.cpp         |   5 +-
 src/plugins/platforms/xcb/qxcbdrag.cpp           |  14 +-
 src/plugins/platforms/xcb/qxcbdrag.h             |   1 +
 src/plugins/platforms/xcb/qxcbscreen.cpp         |  81 ++--------
 src/plugins/platforms/xcb/qxcbscreen.h           |   9 --
 src/plugins/platforms/xcb/qxcbwindow.cpp         | 189 +++++------------------
 src/plugins/platforms/xcb/qxcbwindow.h           |   6 -
 9 files changed, 74 insertions(+), 292 deletions(-)

Index: b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
===================================================================
--- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp
+++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
@@ -314,14 +314,7 @@ void QXcbBackingStore::beginPaint(const
     if (!m_image)
         return;
 
-    int dpr = int(m_image->image()->devicePixelRatio());
-    const int windowDpr = int(window()->devicePixelRatio());
-    if (windowDpr != dpr) {
-        resize(window()->size(), QRegion());
-        dpr = int(m_image->image()->devicePixelRatio());
-    }
-
-    m_paintRegion = dpr == 1 ? region : QTransform::fromScale(dpr,dpr).map(region);
+    m_paintRegion = region;
     m_image->preparePaint(m_paintRegion);
 
     if (m_image->image()->hasAlphaChannel()) {
@@ -370,18 +363,10 @@ void QXcbBackingStore::flush(QWindow *wi
     if (!m_image || m_image->size().isEmpty())
         return;
 
-    const int dpr = int(window->devicePixelRatio());
-
-#ifndef QT_NO_DEBUG
-    const int imageDpr = int(m_image->image()->devicePixelRatio());
-    if (dpr != imageDpr)
-        qWarning() <<  "QXcbBackingStore::flush() wrong devicePixelRatio for backingstore image" << dpr << imageDpr;
-#endif
-
-    QSize imageSize = m_image->size() / dpr; //because we multiply with the DPR later
+    QSize imageSize = m_image->size();
 
     QRegion clipped = region;
-    clipped &= QRect(0, 0, window->width(), window->height());
+    clipped &= QRect(QPoint(), window->size());
     clipped &= QRect(0, 0, imageSize.width(), imageSize.height()).translated(-offset);
 
     QRect bounds = clipped.boundingRect();
@@ -399,8 +384,8 @@ void QXcbBackingStore::flush(QWindow *wi
 
     QVector<QRect> rects = clipped.rects();
     for (int i = 0; i < rects.size(); ++i) {
-        QRect rect = QRect(rects.at(i).topLeft() * dpr, rects.at(i).size() * dpr);
-        m_image->put(platformWindow->xcb_window(), rect.topLeft(), rect.translated(offset * dpr));
+        QRect rect = QRect(rects.at(i).topLeft(), rects.at(i).size());
+        m_image->put(platformWindow->xcb_window(), rect.topLeft(), rect.translated(offset));
     }
 
     Q_XCB_NOOP(connection());
@@ -431,9 +416,7 @@ void QXcbBackingStore::composeAndFlush(Q
 
 void QXcbBackingStore::resize(const QSize &size, const QRegion &)
 {
-    const int dpr = int(window()->devicePixelRatio());
-    const QSize xSize = size * dpr;
-    if (m_image && xSize == m_image->size() && dpr == m_image->image()->devicePixelRatio())
+    if (m_image && size == m_image->size())
         return;
     Q_XCB_NOOP(connection());
 
@@ -446,13 +429,11 @@ void QXcbBackingStore::resize(const QSiz
     QXcbWindow* win = static_cast<QXcbWindow *>(pw);
 
     delete m_image;
-    m_image = new QXcbShmImage(screen, xSize, win->depth(), win->imageFormat());
-    m_image->image()->setDevicePixelRatio(dpr);
+    m_image = new QXcbShmImage(screen, size, win->depth(), win->imageFormat());
     // Slow path for bgr888 VNC: Create an additional image, paint into that and
     // swap R and B while copying to m_image after each paint.
     if (win->imageNeedsRgbSwap()) {
-        m_rgbImage = QImage(xSize, win->imageFormat());
-        m_rgbImage.setDevicePixelRatio(dpr);
+        m_rgbImage = QImage(size, win->imageFormat());
     }
     Q_XCB_NOOP(connection());
 }
@@ -464,14 +445,12 @@ bool QXcbBackingStore::scroll(const QReg
     if (!m_image || m_image->image()->isNull())
         return false;
 
-    const int dpr = int(m_image->image()->devicePixelRatio());
-    QRegion xArea = dpr == 1 ? area : QTransform::fromScale(dpr,dpr).map(area);
     m_image->preparePaint(area);
 
-    QPoint delta(dx * dpr, dy * dpr);
-    const QVector<QRect> xRects = xArea.rects();
-    for (int i = 0; i < xRects.size(); ++i)
-        qt_scrollRectInImage(*m_image->image(), xRects.at(i), delta);
+    QPoint delta(dx, dy);
+    const QVector<QRect> rects = area.rects();
+    for (int i = 0; i < rects.size(); ++i)
+        qt_scrollRectInImage(*m_image->image(), rects.at(i), delta);
     return true;
 }
 
Index: b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
===================================================================
--- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
@@ -562,10 +562,8 @@ void QXcbConnection::xi2ProcessTouch(voi
     }
     QWindowSystemInterface::TouchPoint &touchPoint = dev->touchPoints[xiDeviceEvent->detail];
     QXcbScreen* screen = platformWindow->xcbScreen();
-    QPointF pos = screen->mapFromNative(QPointF(fixed1616ToReal(xiDeviceEvent->root_x),
-                                                fixed1616ToReal(xiDeviceEvent->root_y)));
-    qreal x = pos.x();
-    qreal y = pos.y();
+    qreal x = fixed1616ToReal(xiDeviceEvent->root_x);
+    qreal y = fixed1616ToReal(xiDeviceEvent->root_y);
     qreal nx = -1.0, ny = -1.0, d = 0.0;
     for (int i = 0; i < dev->xiDeviceInfo->num_classes; ++i) {
         XIAnyClassInfo *classinfo = dev->xiDeviceInfo->classes[i];
@@ -872,9 +870,8 @@ void QXcbConnection::xi2HandleScrollEven
                 }
             }
             if (!angleDelta.isNull()) {
-                const int dpr = int(platformWindow->devicePixelRatio());
-                QPoint local(fixed1616ToReal(xiDeviceEvent->event_x)/dpr, fixed1616ToReal(xiDeviceEvent->event_y)/dpr);
-                QPoint global(fixed1616ToReal(xiDeviceEvent->root_x)/dpr, fixed1616ToReal(xiDeviceEvent->root_y)/dpr);
+                QPoint local(fixed1616ToReal(xiDeviceEvent->event_x), fixed1616ToReal(xiDeviceEvent->event_y));
+                QPoint global(fixed1616ToReal(xiDeviceEvent->root_x), fixed1616ToReal(xiDeviceEvent->root_y));
                 Qt::KeyboardModifiers modifiers = keyboard()->translateModifiers(xiDeviceEvent->mods.effective_mods);
                 if (modifiers & Qt::AltModifier) {
                     std::swap(angleDelta.rx(), angleDelta.ry());
@@ -900,9 +897,8 @@ void QXcbConnection::xi2HandleScrollEven
                     angleDelta.setX(-120);
             }
             if (!angleDelta.isNull()) {
-                const int dpr = int(platformWindow->devicePixelRatio());
-                QPoint local(fixed1616ToReal(xiDeviceEvent->event_x)/dpr, fixed1616ToReal(xiDeviceEvent->event_y)/dpr);
-                QPoint global(fixed1616ToReal(xiDeviceEvent->root_x)/dpr, fixed1616ToReal(xiDeviceEvent->root_y)/dpr);
+                QPoint local(fixed1616ToReal(xiDeviceEvent->event_x), fixed1616ToReal(xiDeviceEvent->event_y));
+                QPoint global(fixed1616ToReal(xiDeviceEvent->root_x), fixed1616ToReal(xiDeviceEvent->root_y));
                 Qt::KeyboardModifiers modifiers = keyboard()->translateModifiers(xiDeviceEvent->mods.effective_mods);
                 if (modifiers & Qt::AltModifier)
                     std::swap(angleDelta.rx(), angleDelta.ry());
Index: b/src/plugins/platforms/xcb/qxcbcursor.cpp
===================================================================
--- a/src/plugins/platforms/xcb/qxcbcursor.cpp
+++ b/src/plugins/platforms/xcb/qxcbcursor.cpp
@@ -637,15 +637,14 @@ QPoint QXcbCursor::pos() const
 {
     QPoint p;
     queryPointer(connection(), 0, &p);
-    return m_screen->mapFromNative(p);
+    return p;
 }
 
 void QXcbCursor::setPos(const QPoint &pos)
 {
-    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, xPos.x(), xPos.y());
+    xcb_warp_pointer(xcb_connection(), XCB_NONE, root, 0, 0, 0, 0, pos.x(), pos.y());
     xcb_flush(xcb_connection());
 }
 
Index: b/src/plugins/platforms/xcb/qxcbdrag.cpp
===================================================================
--- a/src/plugins/platforms/xcb/qxcbdrag.cpp
+++ b/src/plugins/platforms/xcb/qxcbdrag.cpp
@@ -76,7 +76,6 @@ static inline xcb_window_t xcb_window(QW
     return static_cast<QXcbWindow *>(w->handle())->xcb_window();
 }
 
-
 static xcb_window_t xdndProxy(QXcbConnection *c, xcb_window_t w)
 {
     xcb_window_t proxy = XCB_NONE;
@@ -303,7 +302,6 @@ void QXcbDrag::move(const QMouseEvent *m
     // We do not know which window that was at this point, so we just use the device pixel ratio
     // of the QGuiApplication. This will break once we support screens with different DPR. Fixing
     // this properly requires some redesign of the drag and drop architecture.
-    static const int dpr = int(qApp->devicePixelRatio());
     QBasicDrag::move(me);
     QPoint globalPos = me->globalPos();
 
@@ -318,6 +316,7 @@ void QXcbDrag::move(const QMouseEvent *m
             break;
         }
     }
+
     if (screen != current_screen) {
         // ### need to recreate the shaped pixmap window?
 //    int screen = QCursor::x11Screen();
@@ -340,7 +339,7 @@ void QXcbDrag::move(const QMouseEvent *m
 //    qt_xdnd_current_screen = screen;
     xcb_window_t rootwin = current_screen->root();
     xcb_translate_coordinates_reply_t *translate =
-            ::translateCoordinates(connection(), rootwin, rootwin, globalPos.x() * dpr, globalPos.y() * dpr);
+            ::translateCoordinates(connection(), rootwin, rootwin, globalPos.x(), globalPos.y());
     if (!translate)
         return;
 
@@ -463,7 +462,7 @@ void QXcbDrag::move(const QMouseEvent *m
         move.type = atom(QXcbAtom::XdndPosition);
         move.data.data32[0] = connection()->clipboard()->owner();
         move.data.data32[1] = 0; // flags
-        move.data.data32[2] = (globalPos.x() * dpr << 16) + globalPos.y() * dpr;
+        move.data.data32[2] = (globalPos.x() << 16) + globalPos.y();
         move.data.data32[3] = connection()->time();
         move.data.data32[4] = toXdndAction(defaultAction(currentDrag()->supportedActions(), QGuiApplication::keyboardModifiers()));
         DEBUG() << "sending Xdnd position source=" << move.data.data32[0] << "target=" << move.window;
@@ -709,9 +708,6 @@ void QXcbDrag::handle_xdnd_position(QWin
     QPoint p((e->data.data32[2] & 0xffff0000) >> 16, e->data.data32[2] & 0x0000ffff);
     Q_ASSERT(w);
     QRect geometry = w->geometry();
-    const int dpr = int(w->handle()->devicePixelRatio());
-
-    p /= dpr;
     p -= geometry.topLeft();
 
     if (!w || (w->type() == Qt::Desktop))
@@ -830,12 +826,10 @@ void QXcbDrag::handle_xdnd_status(const
         updateCursor(Qt::IgnoreAction);
     }
 
-    static const int dpr = int(qApp->devicePixelRatio());
-
     if ((event->data.data32[1] & 2) == 0) {
         QPoint p((event->data.data32[2] & 0xffff0000) >> 16, event->data.data32[2] & 0x0000ffff);
         QSize s((event->data.data32[3] & 0xffff0000) >> 16, event->data.data32[3] & 0x0000ffff);
-        source_sameanswer = QRect(p / dpr, s / dpr);
+        source_sameanswer = QRect(p, s);
     } else {
         source_sameanswer = QRect();
     }
Index: b/src/plugins/platforms/xcb/qxcbdrag.h
===================================================================
--- a/src/plugins/platforms/xcb/qxcbdrag.h
+++ b/src/plugins/platforms/xcb/qxcbdrag.h
@@ -55,6 +55,7 @@ QT_BEGIN_NAMESPACE
 
 class QMouseEvent;
 class QWindow;
+class QPlatformWindow;
 class QXcbConnection;
 class QXcbWindow;
 class QXcbDropData;
Index: b/src/plugins/platforms/xcb/qxcbscreen.cpp
===================================================================
--- a/src/plugins/platforms/xcb/qxcbscreen.cpp
+++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
@@ -86,7 +86,6 @@ QXcbScreen::QXcbScreen(QXcbConnection *c
     , m_orientation(Qt::PrimaryOrientation)
     , m_refreshRate(60)
     , m_forcedDpi(-1)
-    , m_devicePixelRatio(1)
     , m_hintStyle(QFontEngine::HintStyle(-1))
     , m_noFontHinting(false)
     , m_subpixelType(QFontEngine::SubpixelAntialiasingType(-1))
@@ -107,9 +106,8 @@ QXcbScreen::QXcbScreen(QXcbConnection *c
         updateGeometry(output ? output->timestamp : 0);
     }
 
-    const int dpr = int(devicePixelRatio());
     if (m_geometry.isEmpty()) {
-        m_geometry = QRect(QPoint(), m_virtualSize/dpr);
+        m_geometry = QRect(QPoint(), m_virtualSize);
         m_nativeGeometry = QRect(QPoint(), m_virtualSize);
     }
     if (m_availableGeometry.isEmpty())
@@ -117,12 +115,6 @@ QXcbScreen::QXcbScreen(QXcbConnection *c
 
     readXResources();
 
-    // disable font hinting when we do UI scaling
-    static bool dpr_scaling_enabled = (qgetenv("QT_DEVICE_PIXEL_RATIO").toInt() > 1
-                           || qgetenv("QT_DEVICE_PIXEL_RATIO").toLower() == "auto");
-    if (dpr_scaling_enabled)
-        m_noFontHinting = true;
-
     QScopedPointer<xcb_get_window_attributes_reply_t, QScopedPointerPodDeleter> rootAttribs(
         xcb_get_window_attributes_reply(xcb_connection(),
             xcb_get_window_attributes_unchecked(xcb_connection(), screen()->root), NULL));
@@ -201,9 +193,8 @@ QWindow *QXcbScreen::topLevelAt(const QP
 {
     xcb_window_t root = screen()->root;
 
-    int dpr = int(devicePixelRatio());
-    int x = p.x() / dpr;
-    int y = p.y() / dpr;
+    int x = p.x();
+    int y = p.y();
 
     xcb_window_t parent = root;
     xcb_window_t child = root;
@@ -237,43 +228,6 @@ QWindow *QXcbScreen::topLevelAt(const QP
     return 0;
 }
 
-
-QPoint QXcbScreen::mapToNative(const QPoint &pos) const
-{
-    const int dpr = int(devicePixelRatio());
-    return (pos - m_geometry.topLeft()) * dpr + m_nativeGeometry.topLeft();
-}
-
-QPoint QXcbScreen::mapFromNative(const QPoint &pos) const
-{
-    const int dpr = int(devicePixelRatio());
-    return (pos - m_nativeGeometry.topLeft()) / dpr + m_geometry.topLeft();
-}
-
-QPointF QXcbScreen::mapToNative(const QPointF &pos) const
-{
-    const int dpr = int(devicePixelRatio());
-    return (pos - m_geometry.topLeft()) * dpr + m_nativeGeometry.topLeft();
-}
-
-QPointF QXcbScreen::mapFromNative(const QPointF &pos) const
-{
-    const int dpr = int(devicePixelRatio());
-    return (pos - m_nativeGeometry.topLeft()) / dpr + m_geometry.topLeft();
-}
-
-QRect QXcbScreen::mapToNative(const QRect &rect) const
-{
-    const int dpr = int(devicePixelRatio());
-    return QRect(mapToNative(rect.topLeft()), rect.size() * dpr);
-}
-
-QRect QXcbScreen::mapFromNative(const QRect &rect) const
-{
-    const int dpr = int(devicePixelRatio());
-    return QRect(mapFromNative(rect.topLeft()), rect.size() / dpr);
-}
-
 void QXcbScreen::windowShown(QXcbWindow *window)
 {
     // Freedesktop.org Startup Notification
@@ -335,29 +289,17 @@ QDpi QXcbScreen::virtualDpi() const
                 Q_MM_PER_INCH * m_virtualSize.height() / m_virtualSizeMillimeters.height());
 }
 
+
 QDpi QXcbScreen::logicalDpi() const
 {
     static const int overrideDpi = qEnvironmentVariableIntValue("QT_FONT_DPI");
     if (overrideDpi)
         return QDpi(overrideDpi, overrideDpi);
 
-    int primaryDpr = int(connection()->screens().at(0)->devicePixelRatio());
-    if (m_forcedDpi > 0)
-        return QDpi(m_forcedDpi/primaryDpr, m_forcedDpi/primaryDpr);
-    QDpi vDpi = virtualDpi();
-    return QDpi(vDpi.first/primaryDpr, vDpi.second/primaryDpr);
-}
-
-
-qreal QXcbScreen::devicePixelRatio() const
-{
-    static int override_dpr = qEnvironmentVariableIntValue("QT_DEVICE_PIXEL_RATIO");
-    static bool auto_dpr = qgetenv("QT_DEVICE_PIXEL_RATIO").toLower() == "auto";
-    if (override_dpr > 0)
-        return override_dpr;
-    if (auto_dpr)
-        return m_devicePixelRatio;
-    return 1.0;
+    if (m_forcedDpi > 0) {
+        return QDpi(m_forcedDpi, m_forcedDpi);
+    }
+    return virtualDpi();
 }
 
 QPlatformCursor *QXcbScreen::cursor() const
@@ -515,12 +457,9 @@ void QXcbScreen::updateGeometry(const QR
     }
     free(workArea);
 
-    qreal dpi = xGeometry.width() / physicalSize().width() * qreal(25.4);
-    m_devicePixelRatio = qRound(dpi/96);
-    const int dpr = int(devicePixelRatio()); // we may override m_devicePixelRatio
-    m_geometry = QRect(xGeometry.topLeft(), xGeometry.size()/dpr);
+    m_geometry = QRect(xGeometry.topLeft(), xGeometry.size());
     m_nativeGeometry = QRect(xGeometry.topLeft(), xGeometry.size());
-    m_availableGeometry = QRect(mapFromNative(xAvailableGeometry.topLeft()), xAvailableGeometry.size()/dpr);
+    m_availableGeometry = QRect(xAvailableGeometry.topLeft(), xAvailableGeometry.size());
     QWindowSystemInterface::handleScreenGeometryChange(QPlatformScreen::screen(), m_geometry, m_availableGeometry);
 }
 
Index: b/src/plugins/platforms/xcb/qxcbscreen.h
===================================================================
--- a/src/plugins/platforms/xcb/qxcbscreen.h
+++ b/src/plugins/platforms/xcb/qxcbscreen.h
@@ -96,7 +96,6 @@ public:
     QSizeF physicalVirtualSize() const { return m_virtualSizeMillimeters; }
     QDpi virtualDpi() const;
     QDpi logicalDpi() const Q_DECL_OVERRIDE;
-    qreal devicePixelRatio() const Q_DECL_OVERRIDE;
     QPlatformCursor *cursor() const Q_DECL_OVERRIDE;
     qreal refreshRate() const Q_DECL_OVERRIDE { return m_refreshRate; }
     Qt::ScreenOrientation orientation() const Q_DECL_OVERRIDE { return m_orientation; }
@@ -139,13 +138,6 @@ public:
 
     QXcbXSettings *xSettings() const;
 
-    QPoint mapToNative(const QPoint &pos) const;
-    QPoint mapFromNative(const QPoint &pos) const;
-    QPointF mapToNative(const QPointF &pos) const;
-    QPointF mapFromNative(const QPointF &pos) const;
-    QRect mapToNative(const QRect &rect) const;
-    QRect mapFromNative(const QRect &rect) const;
-
 private:
     static bool xResource(const QByteArray &identifier,
                           const QByteArray &expectedIdentifier,
@@ -176,7 +168,6 @@ private:
     QXcbCursor *m_cursor;
     int m_refreshRate;
     int m_forcedDpi;
-    int m_devicePixelRatio;
     QFontEngine::HintStyle m_hintStyle;
     bool m_noFontHinting;
     QFontEngine::SubpixelAntialiasingType m_subpixelType;
Index: b/src/plugins/platforms/xcb/qxcbwindow.cpp
===================================================================
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -139,81 +139,11 @@ enum QX11EmbedMessageType {
 
 const quint32 XEMBED_VERSION = 0;
 
-static inline QRect mapLocalGeometryToNative(const QRect &qtRect, int dpr)
-{
-    return QRect(qtRect.x() * dpr, qtRect.y() * dpr, qtRect.width() * dpr, qtRect.height() * dpr);
-}
-
-// When mapping expose events to Qt rects: round top/left towards the origin and
-// bottom/right away from the origin, making sure that we cover the whole widget
-
-static inline QPoint dpr_floor(const QPoint &p, int dpr)
-{
-    return QPoint(p.x()/dpr, p.y()/dpr);
-}
-
-static inline QPoint dpr_ceil(const QPoint &p, int dpr)
-{
-    return QPoint((p.x() + dpr - 1) / dpr, (p.y() + dpr - 1) / dpr);
-}
-
-static inline QSize dpr_ceil(const QSize &s, int dpr)
-{
-    return QSize((s.width() + dpr - 1) / dpr, (s.height() + dpr - 1) / dpr);
-}
-
-static inline QRect mapExposeFromNative(const QRect &xRect, int dpr)
-{
-    return QRect(dpr_floor(xRect.topLeft(), dpr), dpr_ceil(xRect.bottomRight(), dpr));
-}
-
-static inline QRect mapLocalGeometryFromNative(const QRect &xRect, int dpr)
-{
-    return QRect(xRect.topLeft() / dpr, dpr_ceil(xRect.size(), dpr));
-}
-
 QXcbScreen *QXcbWindow::parentScreen()
 {
     return parent() ? static_cast<QXcbWindow*>(parent())->parentScreen() : m_xcbScreen;
 }
 
-QPoint QXcbWindow::mapToNative(const QPoint &pos, const QXcbScreen *screen) const
-{
-    if (!screen)
-        return pos;
-    if (parent())
-        return pos * int(screen->devicePixelRatio());
-    else
-        return screen->mapToNative(pos);
-}
-QPoint QXcbWindow::mapFromNative(const QPoint &pos, const QXcbScreen *screen) const
-{
-    if (!screen)
-        return pos;
-    if (parent())
-        return pos / int(screen->devicePixelRatio());
-    else
-        return screen->mapFromNative(pos);
-}
-QRect QXcbWindow::mapToNative(const QRect &rect, const QXcbScreen *screen) const
-{
-    if (!screen)
-        return rect;
-    if (parent())
-        return mapLocalGeometryToNative(rect, int(screen->devicePixelRatio()));
-    else
-        return screen->mapToNative(rect);
-}
-QRect QXcbWindow::mapFromNative(const QRect &rect, const QXcbScreen *screen) const
-{
-    if (!screen)
-        return rect;
-    if (parent())
-        return mapLocalGeometryFromNative(rect, int(screen->devicePixelRatio()));
-    else
-        return screen->mapFromNative(rect);
-}
-
 // Returns \c true if we should set WM_TRANSIENT_FOR on \a w
 static inline bool isTransient(const QWindow *w)
 {
@@ -433,12 +363,10 @@ void QXcbWindow::create()
     if (platformScreen != currentScreen)
         QWindowSystemInterface::handleWindowScreenChanged(window(), platformScreen->QPlatformScreen::screen());
 
-    const int dpr = int(devicePixelRatio());
-
     QSize minimumSize = window()->minimumSize();
     if (rect.width() > 0 || rect.height() > 0) {
-        rect.setWidth(qBound(1, rect.width(), XCOORD_MAX/dpr));
-        rect.setHeight(qBound(1, rect.height(), XCOORD_MAX/dpr));
+        rect.setWidth(qBound(1, rect.width(), XCOORD_MAX));
+        rect.setHeight(qBound(1, rect.height(), XCOORD_MAX));
     } else if (minimumSize.width() > 0 || minimumSize.height() > 0) {
         rect.setSize(minimumSize);
     } else {
@@ -487,9 +415,7 @@ void QXcbWindow::create()
 
             m_visualId = visualInfo->visualid;
 
-            const QRect xRect = mapToNative(rect, platformScreen);
-
-            m_window = XCreateWindow(DISPLAY_FROM_XCB(this), xcb_parent_id, xRect.x(), xRect.y(), xRect.width(), xRect.height(),
+            m_window = XCreateWindow(DISPLAY_FROM_XCB(this), xcb_parent_id, rect.x(), rect.y(), rect.width(), rect.height(),
                                       0, visualInfo->depth, InputOutput, visualInfo->visual,
                                       CWBackPixel|CWBorderPixel|CWColormap, &a);
 
@@ -545,16 +471,14 @@ void QXcbWindow::create()
         }
 
         m_imageFormat = imageFormatForVisual(m_depth, visual->red_mask, visual->blue_mask, &m_imageRgbSwap);
-        const QRect xRect = mapToNative(rect, platformScreen);
-
         Q_XCB_CALL(xcb_create_window(xcb_connection(),
                                      m_depth,
                                      m_window,                        // window id
                                      xcb_parent_id,                   // parent window id
-                                     xRect.x(),
-                                     xRect.y(),
-                                     xRect.width(),
-                                     xRect.height(),
+                                     rect.x(),
+                                     rect.y(),
+                                     rect.width(),
+                                     rect.height(),
                                      0,                               // border width
                                      XCB_WINDOW_CLASS_INPUT_OUTPUT,   // window class
                                      m_visualId,                      // visual
@@ -729,8 +653,7 @@ void QXcbWindow::setGeometry(const QRect
         newScreen = currentScreen;
 
     m_xcbScreen = newScreen;
-    const QRect xRect = mapToNative(rect, newScreen);
-    const QRect wmGeometry = windowToWmGeometry(xRect);
+    const QRect wmGeometry = windowToWmGeometry(rect);
 
     if (newScreen != currentScreen)
         QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
@@ -1616,8 +1539,7 @@ void QXcbWindow::propagateSizeHints()
     xcb_size_hints_t hints;
     memset(&hints, 0, sizeof(hints));
 
-    const int dpr = int(devicePixelRatio());
-    const QRect xRect = windowToWmGeometry(mapToNative(geometry(), xcbScreen()));
+    const QRect xRect = windowToWmGeometry(geometry());
 
     QWindow *win = window();
 
@@ -1627,10 +1549,10 @@ void QXcbWindow::propagateSizeHints()
         xcb_size_hints_set_size(&hints, true, xRect.width(), xRect.height());
     xcb_size_hints_set_win_gravity(&hints, m_gravity);
 
-    QSize minimumSize = win->minimumSize() * dpr;
-    QSize maximumSize = win->maximumSize() * dpr;
-    QSize baseSize = win->baseSize() * dpr;
-    QSize sizeIncrement = win->sizeIncrement() * dpr;
+    QSize minimumSize = window()->minimumSize();
+    QSize maximumSize = window()->maximumSize();
+    QSize baseSize = window()->baseSize();
+    QSize sizeIncrement = window()->sizeIncrement();
 
     if (minimumSize.width() > 0 || minimumSize.height() > 0)
         xcb_size_hints_set_min_size(&hints,
@@ -1887,10 +1809,9 @@ void QXcbWindow::setWmWindowRole(const Q
 class ExposeCompressor
 {
 public:
-    ExposeCompressor(xcb_window_t window, QRegion *region, int devicePixelRatio)
+    ExposeCompressor(xcb_window_t window, QRegion *region)
         : m_window(window)
         , m_region(region)
-        , m_dpr(devicePixelRatio)
         , m_pending(true)
     {
     }
@@ -1906,7 +1827,7 @@ public:
             return false;
         if (expose->count == 0)
             m_pending = false;
-        *m_region |= mapExposeFromNative(QRect(expose->x, expose->y, expose->width, expose->height), m_dpr);
+        *m_region |= QRect(expose->x, expose->y, expose->width, expose->height);
         return true;
     }
 
@@ -1918,7 +1839,6 @@ public:
 private:
     xcb_window_t m_window;
     QRegion *m_region;
-    int m_dpr;
     bool m_pending;
 };
 
@@ -1932,16 +1852,14 @@ bool QXcbWindow::handleGenericEvent(xcb_
 
 void QXcbWindow::handleExposeEvent(const xcb_expose_event_t *event)
 {
-    const int dpr = int(devicePixelRatio());
-    QRect x_rect(event->x, event->y, event->width, event->height);
-    QRect rect = mapExposeFromNative(x_rect, dpr);
+    QRect rect(event->x, event->y, event->width, event->height);
 
     if (m_exposeRegion.isEmpty())
         m_exposeRegion = rect;
     else
         m_exposeRegion |= rect;
 
-    ExposeCompressor compressor(m_window, &m_exposeRegion, dpr);
+    ExposeCompressor compressor(m_window, &m_exposeRegion);
     xcb_generic_event_t *filter = 0;
     do {
         filter = connection()->checkEvent(compressor);
@@ -2019,26 +1937,6 @@ void QXcbWindow::handleClientMessageEven
     }
 }
 
-// Temporary workaround for bug in QPlatformScreen::screenForGeometry
-// we need the native geometries to detect our screen, but that's not
-// available in cross-platform code. Will be fixed properly when highDPI
-// support is refactored to expose the native coordinate system.
-
-QXcbScreen *QXcbWindow::screenForNativeGeometry(const QRect &newGeometry) const
-{
-    QXcbScreen *currentScreen = xcbScreen();
-    if (!currentScreen && QGuiApplication::primaryScreen())
-        currentScreen = static_cast<QXcbScreen*>(QGuiApplication::primaryScreen()->handle());
-    if (currentScreen && !parent() && !currentScreen->nativeGeometry().intersects(newGeometry)) {
-        Q_FOREACH (QPlatformScreen* screen, currentScreen->virtualSiblings()) {
-            QXcbScreen *xcbScreen = static_cast<QXcbScreen*>(screen);
-            if (xcbScreen->nativeGeometry().intersects(newGeometry))
-                return xcbScreen;
-        }
-    }
-    return currentScreen;
-}
-
 void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t *event)
 {
     bool fromSendEvent = (event->response_type & 0x80);
@@ -2055,19 +1953,18 @@ void QXcbWindow::handleConfigureNotifyEv
         }
     }
 
-    const QRect nativeRect = QRect(pos, QSize(event->width, event->height));
-    QXcbScreen *newScreen = parent() ? parentScreen() : screenForNativeGeometry(nativeRect);
+    const QRect rect = QRect(pos, QSize(event->width, event->height));
+    QPlatformScreen *newScreen = parent() ? parent()->screen() : screenForGeometry(rect);
 
     QXcbScreen *currentScreen = m_xcbScreen;
-    m_xcbScreen = newScreen;
+    m_xcbScreen = static_cast<QXcbScreen*>(newScreen);
     if (!newScreen)
         return;
-    const QRect rect = mapFromNative(nativeRect, newScreen);
 
     QPlatformWindow::setGeometry(rect);
     QWindowSystemInterface::handleGeometryChange(window(), rect);
     if (newScreen != currentScreen)
-        QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+        QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->screen());
 
     m_configureNotifyPending = false;
 
@@ -2100,11 +1997,10 @@ QPoint QXcbWindow::mapToGlobal(const QPo
     if (!m_embedded)
         return pos;
 
-    const int dpr = int(devicePixelRatio());
     QPoint ret;
     xcb_translate_coordinates_cookie_t cookie =
         xcb_translate_coordinates(xcb_connection(), xcb_window(), xcbScreen()->root(),
-                                  pos.x() * dpr, pos.y() * dpr);
+                                  pos.x(), pos.y());
     xcb_translate_coordinates_reply_t *reply =
         xcb_translate_coordinates_reply(xcb_connection(), cookie, NULL);
     if (reply) {
@@ -2113,7 +2009,7 @@ QPoint QXcbWindow::mapToGlobal(const QPo
         free(reply);
     }
 
-    return mapFromNative(ret, xcbScreen());
+    return ret;
 }
 
 QPoint QXcbWindow::mapFromGlobal(const QPoint &pos) const
@@ -2121,17 +2017,15 @@ QPoint QXcbWindow::mapFromGlobal(const Q
     if (!m_embedded)
         return pos;
 
-    const int dpr = int(devicePixelRatio());
     QPoint ret;
-    QPoint xPos = mapToNative(pos, xcbScreen());
     xcb_translate_coordinates_cookie_t cookie =
         xcb_translate_coordinates(xcb_connection(), xcbScreen()->root(), xcb_window(),
-                                  xPos.x(), xPos.y());
+                                  pos.x(), pos.y());
     xcb_translate_coordinates_reply_t *reply =
         xcb_translate_coordinates_reply(xcb_connection(), cookie, NULL);
     if (reply) {
-        ret.setX(reply->dst_x / dpr);
-        ret.setY(reply->dst_y / dpr);
+        ret.setX(reply->dst_x);
+        ret.setY(reply->dst_y);
         free(reply);
     }
 
@@ -2147,7 +2041,7 @@ void QXcbWindow::handleMapNotifyEvent(co
         if (m_configureNotifyPending)
             m_deferredExpose = true;
         else
-            QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size() * int(devicePixelRatio())));
+            QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size()));
     }
 }
 
@@ -2179,9 +2073,8 @@ void QXcbWindow::handleButtonPressEvent(
             sendXEmbedMessage(container->xcb_window(), XEMBED_REQUEST_FOCUS);
         }
     }
-    const int dpr = int(devicePixelRatio());
-    QPoint local(event_x / dpr, event_y / dpr);
-    QPoint global = xcbScreen()->mapFromNative(QPoint(root_x, root_y));
+    QPoint local(event_x, event_y);
+    QPoint global(root_x, root_y);
 
     if (isWheel) {
         if (!connection()->isAtLeastXI21()) {
@@ -2203,9 +2096,8 @@ void QXcbWindow::handleButtonPressEvent(
 void QXcbWindow::handleButtonReleaseEvent(int event_x, int event_y, int root_x, int root_y,
                                           int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp)
 {
-    const int dpr = int(devicePixelRatio());
-    QPoint local(event_x / dpr, event_y / dpr);
-    QPoint global = xcbScreen()->mapFromNative(QPoint(root_x, root_y));
+    QPoint local(event_x, event_y);
+    QPoint global(root_x, root_y);
 
     if (detail >= 4 && detail <= 7) {
         // mouse wheel, handled in handleButtonPressEvent()
@@ -2218,11 +2110,8 @@ void QXcbWindow::handleButtonReleaseEven
 void QXcbWindow::handleMotionNotifyEvent(int event_x, int event_y, int root_x, int root_y,
                                          Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp)
 {
-    if (!xcbScreen())
-        return;
-    const int dpr = int(devicePixelRatio());
-    QPoint local(event_x / dpr, event_y / dpr);
-    QPoint global = xcbScreen()->mapFromNative(QPoint(root_x, root_y));
+    QPoint local(event_x, event_y);
+    QPoint global(root_x, root_y);
     handleMouseEvent(timestamp, local, global, modifiers);
 }
 
@@ -2350,11 +2239,10 @@ void QXcbWindow::handleEnterNotifyEvent(
     if (ignoreEnterEvent(event))
         return;
 
-    const int dpr = int(devicePixelRatio());
-    const QPoint local(event->event_x/dpr, event->event_y/dpr);
+    const QPoint local(event->event_x, event->event_y);
     if (!xcbScreen())
         return;
-    QPoint global = xcbScreen()->mapFromNative(QPoint(event->root_x, event->root_y));
+    QPoint global = QPoint(event->root_x, event->root_y);
     QWindowSystemInterface::handleEnterEvent(window(), local, global);
 }
 
@@ -2370,11 +2258,10 @@ void QXcbWindow::handleLeaveNotifyEvent(
     QXcbWindow *enterWindow = enter ? connection()->platformWindowFromId(enter->event) : 0;
 
     if (enterWindow) {
-        const int dpr = int(devicePixelRatio());
-        QPoint local(enter->event_x/dpr, enter->event_y/dpr);
+        QPoint local(enter->event_x, enter->event_y);
         if (!xcbScreen())
             return;
-        QPoint global = xcbScreen()->mapFromNative(QPoint(event->root_x, event->root_y));
+        QPoint global = QPoint(event->root_x, event->root_y);
 
         QWindowSystemInterface::handleEnterLeaveEvent(enterWindow->window(), window(), local, global);
     } else {
@@ -2553,7 +2440,7 @@ bool QXcbWindow::startSystemResize(const
     xev.type = moveResize;
     xev.window = xcb_window();
     xev.format = 32;
-    const QPoint globalPos = mapToNative(window()->mapToGlobal(pos), xcbScreen());
+    const QPoint globalPos = window()->mapToGlobal(pos);
     xev.data.data32[0] = globalPos.x();
     xev.data.data32[1] = globalPos.y();
     const bool bottom = corner == Qt::BottomRightCorner || corner == Qt::BottomLeftCorner;
@@ -2679,10 +2566,9 @@ void QXcbWindow::setMask(const QRegion &
         xcb_shape_mask(connection()->xcb_connection(), XCB_SHAPE_SO_SET,
                        XCB_SHAPE_SK_BOUNDING, xcb_window(), 0, 0, XCB_NONE);
     } else {
-        const int dpr = devicePixelRatio();
         QVector<xcb_rectangle_t> rects;
         foreach (const QRect &r, region.rects())
-            rects.push_back(qRectToXCBRectangle(mapLocalGeometryToNative(r, dpr)));
+            rects.push_back(qRectToXCBRectangle(r));
         xcb_shape_rectangles(connection()->xcb_connection(), XCB_SHAPE_SO_SET,
                              XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
                              xcb_window(), 0, 0, rects.size(), &rects[0]);
@@ -2720,11 +2606,6 @@ void QXcbWindow::postSyncWindowRequest()
     }
 }
 
-qreal QXcbWindow::devicePixelRatio() const
-{
-    return xcbScreen() ? xcbScreen()->devicePixelRatio() : 1.0;
-}
-
 QXcbScreen *QXcbWindow::xcbScreen() const
 {
     return static_cast<QXcbScreen *>(screen());
Index: b/src/plugins/platforms/xcb/qxcbwindow.h
===================================================================
--- a/src/plugins/platforms/xcb/qxcbwindow.h
+++ b/src/plugins/platforms/xcb/qxcbwindow.h
@@ -154,8 +154,6 @@ public:
     void postSyncWindowRequest();
     void clearSyncWindowRequest() { m_pendingSyncRequest = 0; }
 
-    qreal devicePixelRatio() const Q_DECL_OVERRIDE;
-
     QXcbScreen *xcbScreen() const;
 
     virtual void create();
@@ -171,10 +169,6 @@ protected:
     virtual void *createVisual() { return Q_NULLPTR; }
     virtual bool supportsSyncProtocol() { return !window()->supportsOpenGL(); }
 
-    QPoint mapToNative(const QPoint &pos, const QXcbScreen *screen) const;
-    QPoint mapFromNative(const QPoint &pos, const QXcbScreen *screen) const;
-    QRect mapToNative(const QRect &rect, const QXcbScreen *screen) const;
-    QRect mapFromNative(const QRect &rect, const QXcbScreen *screen) const;
     QXcbScreen *parentScreen();
 
     void changeNetWmState(bool set, xcb_atom_t one, xcb_atom_t two = 0);
