summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb/qxcbwindow.cpp
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@theqtcompany.com>2015-01-07 15:44:12 +0100
committerPaul Olav Tvete <paul.tvete@theqtcompany.com>2015-01-12 09:48:11 +0100
commit075ae987c48ce732e6a22c1eba71023fa0ea1775 (patch)
tree2012048dc9e6bb3ad41f59fe039e564b03ee3ca6 /src/plugins/platforms/xcb/qxcbwindow.cpp
parent3ba1b989a6c7e22e8f0b92c59c5bbb52cdcab638 (diff)
X11 devicePixelRatio screen mapping fix
Fix screen detection and window geometry when screens have different displayPixelRatios. We must use the native coordinate system to figure out which screen a window belongs to. Also, when a window moves to a screen with a different devicePixelRatio, we must recalculate the Qt geometry. Task-number: QTBUG-43713 Change-Id: I93063e37354ff88f3c8a13320b76dfb272e43a9c Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbwindow.cpp')
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index e1ccc3f086..590e296f61 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -1831,6 +1831,23 @@ void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *even
}
}
+// Temporary workaround for bug in QPlatformScreen::screenForNativeGeometry
+// 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.
+
+QPlatformScreen *QXcbWindow::screenForNativeGeometry(const QRect &newGeometry) const
+{
+ QXcbScreen *currentScreen = static_cast<QXcbScreen*>(screen());
+ if (!parent() && !currentScreen->nativeGeometry().intersects(newGeometry)) {
+ Q_FOREACH (QPlatformScreen* screen, currentScreen->virtualSiblings()) {
+ if (static_cast<QXcbScreen*>(screen)->nativeGeometry().intersects(newGeometry))
+ return screen;
+ }
+ }
+ return currentScreen;
+}
+
void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t *event)
{
bool fromSendEvent = (event->response_type & 0x80);
@@ -1847,15 +1864,23 @@ void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t *
}
}
- QRect rect = mapFromNative(QRect(pos, QSize(event->width, event->height)), int(devicePixelRatio()));
+ const int dpr = devicePixelRatio();
+ const QRect nativeRect = QRect(pos, QSize(event->width, event->height));
+ const QRect rect = mapFromNative(nativeRect, dpr);
QPlatformWindow::setGeometry(rect);
QWindowSystemInterface::handleGeometryChange(window(), rect);
- QPlatformScreen *newScreen = screenForGeometry(rect);
+ QPlatformScreen *newScreen = screenForNativeGeometry(nativeRect);
if (newScreen != m_screen) {
m_screen = static_cast<QXcbScreen*>(newScreen);
QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->screen());
+ int newDpr = devicePixelRatio();
+ if (newDpr != dpr) {
+ QRect newRect = mapFromNative(nativeRect, newDpr);
+ QPlatformWindow::setGeometry(newRect);
+ QWindowSystemInterface::handleGeometryChange(window(), newRect);
+ }
}
m_configureNotifyPending = false;