diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2014-07-04 10:39:19 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2014-07-07 13:08:46 +0200 |
commit | 3f60bd305ad3b094356750c21e253704bbe62681 (patch) | |
tree | 27e3a6b3e686482326913a5e8ed0347049b06906 /src/gui/kernel/qplatformwindow.cpp | |
parent | 16baadab11341e671150932fd28cff466a4fc041 (diff) |
Add convenience function for checking screen changes to QPlatformWindow.
Add function returning the screen for a new geometry for geometry
change events. This ensures that the checking is done in platform
screen coordinates (which might differ from QScreen coordinates
due to high-DPI changes) and also that no screen changes are
emitted for child windows.
Change-Id: I406750f59f006f834c386d09c0c85a804014924a
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Diffstat (limited to 'src/gui/kernel/qplatformwindow.cpp')
-rw-r--r-- | src/gui/kernel/qplatformwindow.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index faaf418522..bb7b690992 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -474,6 +474,29 @@ QString QPlatformWindow::formatWindowTitle(const QString &title, const QString & } /*! + Helper function for finding the new screen for \a newGeometry in response to + a geometry changed event. Returns the new screen if the window was moved to + another virtual sibling. If the screen changes, the platform plugin should call + QWindowSystemInterface::handleWindowScreenChanged(). + \note: The current screen will always be returned for child windows since + they should never signal screen changes. + + \since 5.4 + \sa QWindowSystemInterface::handleWindowScreenChanged() +*/ +QPlatformScreen *QPlatformWindow::screenForGeometry(const QRect &newGeometry) const +{ + QPlatformScreen *currentScreen = screen(); + if (!parent() && !currentScreen->geometry().intersects(newGeometry)) { + Q_FOREACH (QPlatformScreen* screen, currentScreen->virtualSiblings()) { + if (screen->geometry().intersects(newGeometry)) + return screen; + } + } + return currentScreen; +} + +/*! Reimplement this method to set whether the window demands attention (for example, by flashing the taskbar icon) depending on \a enabled. |