summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/kernel/qwindow.cpp')
-rw-r--r--src/gui/kernel/qwindow.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 4156fd87e6..400ed29380 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -69,6 +69,7 @@ QWindow::QWindow(QScreen *targetScreen)
//screen list is populated.
Q_ASSERT(d->screen);
+ connect(d->screen, SIGNAL(destroyed(QObject *)), this, SLOT(screenDestroyed(QObject *)));
QGuiApplicationPrivate::window_list.prepend(this);
}
@@ -674,12 +675,33 @@ void QWindow::setScreen(QScreen *newScreen)
const bool wasCreated = d->platformWindow != 0;
if (wasCreated)
destroy();
+ if (d->screen)
+ disconnect(d->screen, SIGNAL(destroyed(QObject *)), this, SLOT(screenDestroyed(QObject *)));
d->screen = newScreen;
- if (wasCreated)
- create();
+ if (newScreen) {
+ connect(d->screen, SIGNAL(destroyed(QObject *)), this, SLOT(screenDestroyed(QObject *)));
+ if (wasCreated)
+ create();
+ }
+ emit screenChanged(newScreen);
}
}
+void QWindow::screenDestroyed(QObject *object)
+{
+ Q_D(QWindow);
+ if (object == static_cast<QObject *>(d->screen))
+ setScreen(0);
+}
+
+/*!
+ \fn QWindow::screenChanged(QScreen *screen)
+
+ This signal is emitted when a window's screen changes, either
+ by being set explicitly with setScreen(), or automatically when
+ the window's screen is removed.
+*/
+
/*!
Returns the accessibility interface for the object that the window represents
\preliminary