summaryrefslogtreecommitdiffstats
path: root/tests/manual/qscreen/main.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2015-06-03 10:23:56 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-06-03 10:23:56 +0200
commite2f66f921594b7be4af4a058c959557489e86879 (patch)
treecc44931708b57bd5a761906797c7dee0360d1d6b /tests/manual/qscreen/main.cpp
parent933bf178aab88ab5df8a68cbf02611d6d8744b1b (diff)
parent754efa57d89c62d1796e01b407e9222e67450f52 (diff)
Merge remote-tracking branch 'origin/5.5' into dev
Conflicts: src/corelib/global/qnamespace.qdoc src/corelib/io/qwindowspipereader.cpp src/corelib/io/qwindowspipereader_p.h src/corelib/statemachine/qstatemachine.cpp src/corelib/statemachine/qstatemachine_p.h src/plugins/platforms/xcb/qxcbconnection.h tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp tests/auto/tools/qmake/tst_qmake.cpp tests/manual/touch/main.cpp Change-Id: I917d694890e79ee3da7d65134b5b085e23e0dd62
Diffstat (limited to 'tests/manual/qscreen/main.cpp')
-rw-r--r--tests/manual/qscreen/main.cpp23
1 files changed, 11 insertions, 12 deletions
diff --git a/tests/manual/qscreen/main.cpp b/tests/manual/qscreen/main.cpp
index ef9c2efe19..8ed9cebfb4 100644
--- a/tests/manual/qscreen/main.cpp
+++ b/tests/manual/qscreen/main.cpp
@@ -44,6 +44,7 @@
#include <QAction>
#include <QStatusBar>
#include <QLineEdit>
+#include <QDesktopWidget>
class ScreenPropertyWatcher : public PropertyWatcher
{
@@ -156,19 +157,17 @@ void screenAdded(QScreen* screen)
(screen->virtualSiblings().isEmpty() ? "none" : qPrintable(screen->virtualSiblings().first()->name())));
ScreenWatcherMainWindow *w = new ScreenWatcherMainWindow(screen);
- // This doesn't work. If the multiple screens are part of
- // a virtual desktop (i.e. they are virtual siblings), then
- // setScreen has no effect, and we need the code below to
- // change the window geometry. If on the other hand the
- // screens are really separate, so that windows are not
- // portable between them, XCreateWindow needs to have not just
- // a different root Window but also a different Display, in order to
- // put the window on the other screen. That would require a
- // different QXcbConnection. So this setScreen call doesn't seem useful.
- //w->windowHandle()->setScreen(screen);
-
- // But this works as long as the screens are all virtual siblings
+ // Set the screen via QDesktopWidget. This corresponds to setScreen() for the underlying
+ // QWindow. This is essential when having separate X screens since the the positioning below is
+ // not sufficient to get the windows show up on the desired screen.
+ QList<QScreen *> screens = QGuiApplication::screens();
+ int screenNumber = screens.indexOf(screen);
+ Q_ASSERT(screenNumber >= 0);
+ w->setParent(qApp->desktop()->screen(screenNumber));
+
w->show();
+
+ // Position the windows so that they end up at the center of the corresponding screen.
QRect geom = w->geometry();
geom.setSize(w->sizeHint());
if (geom.height() > screen->geometry().height())