libqt5-qtbase/X11-devicePixelRatio-screen-mapping-fix.patch
Dominique Leuenberger 7169baff88 Accepting request 286573 from KDE:Qt5
- Added patches from upstream:
  Fix-Meta-shortcuts-on-XCB.patch (qtbug#43572),
  Fix-detection-of-GCC5.patch,
  Fix-physical-DPI-and-size-for-rotated-screens-on-X11.patch
  (qtbug#43688), Fix-typo-in-Qt5CoreMacroscmake.patch,
  Make-sure-theres-a-scene-before-using-it.patch (qtbug#44509),
  Multi-screen-DPI-support-for-X11.patch (qtbug#43713),
  QSystemTrayIcon-handle-submenus-correctly.patch,
  Update-mouse-buttons-from-MotionNotify-events.patch
  (qtbug#32609, qtbug#35065, qtbug#43776, qtbug#44166, qtbug#44231),
  X11-devicePixelRatio-screen-mapping-fix.patch (qtbug#43713) and
  xcb-Dont-return-0-from-QXcbKeyboard-possibleKeys.patch
  (qtcreatorbug#9589)

OBS-URL: https://build.opensuse.org/request/show/286573
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/libqt5-qtbase?expand=0&rev=37
2015-02-20 11:43:00 +00:00

128 lines
4.8 KiB
Diff

From: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Date: Wed, 07 Jan 2015 14:44:12 +0000
Subject: X11 devicePixelRatio screen mapping fix
X-Git-Url: http://quickgit.kde.org/?p=qt%2Fqtbase.git&a=commitdiff&h=075ae987c48ce732e6a22c1eba71023fa0ea1775
---
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>
---
--- a/src/plugins/platforms/xcb/qxcbscreen.cpp
+++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
@@ -77,8 +77,10 @@
// virtual size is known (probably back-calculated from DPI and resolution)
if (m_sizeMillimeters.isEmpty())
m_sizeMillimeters = m_virtualSizeMillimeters;
- if (m_geometry.isEmpty())
+ if (m_geometry.isEmpty()) {
m_geometry = QRect(QPoint(), m_virtualSize/dpr);
+ m_nativeGeometry = QRect(QPoint(), m_virtualSize);
+ }
if (m_availableGeometry.isEmpty())
m_availableGeometry = m_geometry;
@@ -461,6 +463,7 @@
m_devicePixelRatio = qRound(dpi/96);
const int dpr = int(devicePixelRatio()); // we may override m_devicePixelRatio
m_geometry = QRect(xGeometry.topLeft()/dpr, xGeometry.size()/dpr);
+ m_nativeGeometry = QRect(xGeometry.topLeft(), xGeometry.size());
m_availableGeometry = QRect(xAvailableGeometry.topLeft()/dpr, xAvailableGeometry.size()/dpr);
QWindowSystemInterface::handleScreenGeometryChange(QPlatformScreen::screen(), m_geometry, m_availableGeometry);
--- a/src/plugins/platforms/xcb/qxcbscreen.h
+++ b/src/plugins/platforms/xcb/qxcbscreen.h
@@ -62,6 +62,7 @@
QWindow *topLevelAt(const QPoint &point) const;
QRect geometry() const { return m_geometry; }
+ QRect nativeGeometry() const { return m_nativeGeometry; }
QRect availableGeometry() const {return m_availableGeometry;}
int depth() const { return m_screen->root_depth; }
QImage::Format format() const;
@@ -114,6 +115,7 @@
QSizeF m_outputSizeMillimeters;
QSizeF m_sizeMillimeters;
QRect m_geometry;
+ QRect m_nativeGeometry;
QRect m_availableGeometry;
QSize m_virtualSize;
QSizeF m_virtualSizeMillimeters;
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -1831,6 +1831,23 @@
}
}
+// 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 @@
}
}
- 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;
--- a/src/plugins/platforms/xcb/qxcbwindow.h
+++ b/src/plugins/platforms/xcb/qxcbwindow.h
@@ -154,6 +154,8 @@
qreal devicePixelRatio() const;
+ QPlatformScreen *screenForNativeGeometry(const QRect &newGeometry) const;
+
public Q_SLOTS:
void updateSyncRequestCounter();