summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qwindowsysteminterface.cpp
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-03-20 01:00:08 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2019-03-20 14:09:30 +0100
commit6893919b0c4cddfbd82ebf963cc7bebde816b1b3 (patch)
tree9bfa1b57707fe609f9401c5b3bd5cd85ec1ae777 /src/gui/kernel/qwindowsysteminterface.cpp
parent3ca05b2a2e80863202bdb6a225f72debbb28b8fe (diff)
parent2bafd997ee515d3b6a6a8fb030e1265a4713713e (diff)
Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts: src/gui/kernel/qplatformintegration.cpp src/gui/kernel/qplatformintegration.h src/plugins/platforms/wasm/qwasmintegration.cpp src/plugins/platforms/xcb/qxcbconnection_screens.cpp Change-Id: I15063d42e9a1e226d9d2d2d372f75141b84c5c1b
Diffstat (limited to 'src/gui/kernel/qwindowsysteminterface.cpp')
-rw-r--r--src/gui/kernel/qwindowsysteminterface.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
index 7067ece1d8..ec6911b334 100644
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -780,6 +780,72 @@ QT_DEFINE_QPA_EVENT_HANDLER(void, handleTouchCancelEvent, QWindow *window, ulong
QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e);
}
+/*!
+ Should be called by the implementation whenever a new screen is added.
+
+ The first screen added will be the primary screen, used for default-created
+ windows, GL contexts, and other resources unless otherwise specified.
+
+ This adds the screen to QGuiApplication::screens(), and emits the
+ QGuiApplication::screenAdded() signal.
+
+ The screen should be deleted by calling QWindowSystemInterface::handleScreenRemoved().
+*/
+void QWindowSystemInterface::handleScreenAdded(QPlatformScreen *ps, bool isPrimary)
+{
+ QScreen *screen = new QScreen(ps);
+
+ if (isPrimary)
+ QGuiApplicationPrivate::screen_list.prepend(screen);
+ else
+ QGuiApplicationPrivate::screen_list.append(screen);
+
+ QGuiApplicationPrivate::resetCachedDevicePixelRatio();
+
+ emit qGuiApp->screenAdded(screen);
+
+ if (isPrimary)
+ emit qGuiApp->primaryScreenChanged(screen);
+}
+
+/*!
+ Should be called by the implementation whenever a screen is removed.
+
+ This removes the screen from QGuiApplication::screens(), and deletes it.
+
+ Failing to call this and manually deleting the QPlatformScreen instead may
+ lead to a crash due to a pure virtual call.
+*/
+void QWindowSystemInterface::handleScreenRemoved(QPlatformScreen *platformScreen)
+{
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
+ QGuiApplicationPrivate::platformIntegration()->removeScreen(platformScreen->screen());
+QT_WARNING_POP
+
+ // Important to keep this order since the QSceen doesn't own the platform screen
+ delete platformScreen->screen();
+ delete platformScreen;
+}
+
+/*!
+ Should be called whenever the primary screen changes.
+
+ When the screen specified as primary changes, this method will notify
+ QGuiApplication and emit the QGuiApplication::primaryScreenChanged signal.
+ */
+void QWindowSystemInterface::handlePrimaryScreenChanged(QPlatformScreen *newPrimary)
+{
+ QScreen *newPrimaryScreen = newPrimary->screen();
+ int indexOfScreen = QGuiApplicationPrivate::screen_list.indexOf(newPrimaryScreen);
+ Q_ASSERT(indexOfScreen >= 0);
+ if (indexOfScreen == 0)
+ return;
+
+ QGuiApplicationPrivate::screen_list.swapItemsAt(0, indexOfScreen);
+ emit qGuiApp->primaryScreenChanged(newPrimaryScreen);
+}
+
void QWindowSystemInterface::handleScreenOrientationChange(QScreen *screen, Qt::ScreenOrientation orientation)
{
QWindowSystemInterfacePrivate::ScreenOrientationEvent *e =