summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qevent.cpp15
-rw-r--r--src/gui/kernel/qguiapplication.cpp80
-rw-r--r--src/gui/kernel/qguiapplication.h1
-rw-r--r--src/gui/kernel/qkeysequence_p.h1
-rw-r--r--src/gui/kernel/qopenglcontext.cpp12
-rw-r--r--src/gui/kernel/qopenglcontext.h2
-rw-r--r--src/gui/kernel/qplatformdialoghelper.cpp42
-rw-r--r--src/gui/kernel/qplatformdialoghelper.h19
-rw-r--r--src/gui/kernel/qplatformintegration.cpp31
-rw-r--r--src/gui/kernel/qplatformintegration.h9
-rw-r--r--src/gui/kernel/qplatformsystemtrayicon_qpa.cpp2
-rw-r--r--src/gui/kernel/qplatformtheme.cpp28
-rw-r--r--src/gui/kernel/qplatformwindow.cpp25
-rw-r--r--src/gui/kernel/qstylehints.cpp3
-rw-r--r--src/gui/kernel/qsurfaceformat.cpp4
-rw-r--r--src/gui/kernel/qwindow.cpp24
-rw-r--r--src/gui/kernel/qwindow_p.h2
-rw-r--r--src/gui/kernel/qwindowsysteminterface.cpp7
-rw-r--r--src/gui/kernel/qwindowsysteminterface.h2
-rw-r--r--src/gui/kernel/qwindowsysteminterface_p.h5
20 files changed, 242 insertions, 72 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 816419d155..ae63b8bc32 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -118,7 +118,7 @@ QInputEvent::~QInputEvent()
Returns the keyboard modifier flags that existed immediately
before the event occurred.
- \sa QApplication::keyboardModifiers()
+ \sa QGuiApplication::keyboardModifiers()
*/
/*! \fn void QInputEvent::setModifiers(Qt::KeyboardModifiers modifiers)
@@ -331,7 +331,7 @@ Qt::MouseEventSource QMouseEvent::source() const
Returns the position of the mouse cursor as a QPointF, relative to the
screen that received the event.
- \sa x(), y(), pos(), localPos(), screenPos()
+ \sa x(), y(), pos(), localPos(), windowPos()
*/
/*!
@@ -1023,7 +1023,7 @@ QKeyEvent::~QKeyEvent()
confuse it by pressing both \uicontrol{Shift} keys simultaneously and
releasing one of them, for example.
- \sa QApplication::keyboardModifiers()
+ \sa QGuiApplication::keyboardModifiers()
*/
Qt::KeyboardModifiers QKeyEvent::modifiers() const
@@ -1375,7 +1375,7 @@ QResizeEvent::~QResizeEvent()
signal when they are deleted.
If the last top-level window is closed, the
- QApplication::lastWindowClosed() signal is emitted.
+ QGuiApplication::lastWindowClosed() signal is emitted.
The isAccepted() function returns \c true if the event's receiver has
agreed to close the widget; call accept() to agree to close the
@@ -1384,7 +1384,7 @@ QResizeEvent::~QResizeEvent()
\sa QWidget::close(), QWidget::hide(), QObject::destroyed(),
QCoreApplication::exec(), QCoreApplication::quit(),
- QApplication::lastWindowClosed()
+ QGuiApplication::lastWindowClosed()
*/
/*!
@@ -2694,9 +2694,8 @@ QDragEnterEvent::~QDragEnterEvent()
is within its boundaries, if it accepts
\l{QWidget::setAcceptDrops()}{drop events} and \l
{QWidget::dragEnterEvent()}{enter events}. The widget should
- examine the event to see what kind of data it
- \l{QDragMoveEvent::provides()}{provides}, and call the accept()
- function to accept the drop if appropriate.
+ examine the event to see what kind of \l{mimeData()}{data} it
+ provides, and call the accept() function to accept the drop if appropriate.
The rectangle supplied by the answerRect() function can be used to restrict
drops to certain parts of the widget. For example, we can check whether the
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index db655bd2ad..9f95f2c234 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -1672,41 +1672,36 @@ void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyE
QWindow *window = e->window.data();
modifier_buttons = e->modifiers;
if (e->nullWindow
-#ifdef Q_OS_ANDROID
- || (e->keyType == QEvent::KeyRelease && e->key == Qt::Key_Back) || e->key == Qt::Key_Menu
+#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
+ || e->key == Qt::Key_Back || e->key == Qt::Key_Menu
#endif
) {
window = QGuiApplication::focusWindow();
}
- if (!window
-#ifdef Q_OS_ANDROID
- && e->keyType != QEvent::KeyRelease && e->key != Qt::Key_Back
-#endif
- ) {
- return;
- }
- if (window && window->d_func()->blockedByModalWindow) {
- // a modal window is blocking this window, don't allow key events through
- return;
- }
QKeyEvent ev(e->keyType, e->key, e->modifiers,
e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers,
e->unicode, e->repeat, e->repeatCount);
ev.setTimestamp(e->timestamp);
-#ifdef Q_OS_ANDROID
- if (e->keyType == QEvent::KeyRelease && e->key == Qt::Key_Back) {
- if (!window) {
+ // only deliver key events when we have a window, and no modal window is blocking this window
+
+ if (window && !window->d_func()->blockedByModalWindow)
+ QGuiApplication::sendSpontaneousEvent(window, &ev);
+#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
+ else
+ ev.setAccepted(false);
+
+ static bool backKeyPressAccepted = false;
+ if (e->keyType == QEvent::KeyPress) {
+ backKeyPressAccepted = e->key == Qt::Key_Back && ev.isAccepted();
+ } else if (e->keyType == QEvent::KeyRelease && e->key == Qt::Key_Back && !backKeyPressAccepted && !ev.isAccepted()) {
+ if (!window)
qApp->quit();
- } else {
- QGuiApplication::sendEvent(window, &ev);
- if (!ev.isAccepted() && e->key == Qt::Key_Back)
- QWindowSystemInterface::handleCloseEvent(window);
- }
- } else
+ else
+ QWindowSystemInterface::handleCloseEvent(window);
+ }
#endif
- QGuiApplication::sendSpontaneousEvent(window, &ev);
}
void QGuiApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e)
@@ -1834,33 +1829,33 @@ void QGuiApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePr
return;
QRect newRect = e->newGeometry;
- QRect cr = window->d_func()->geometry;
+ QRect oldRect = e->oldGeometry.isNull() ? window->d_func()->geometry : e->oldGeometry;
- bool isResize = cr.size() != newRect.size();
- bool isMove = cr.topLeft() != newRect.topLeft();
+ bool isResize = oldRect.size() != newRect.size();
+ bool isMove = oldRect.topLeft() != newRect.topLeft();
window->d_func()->geometry = newRect;
if (isResize || window->d_func()->resizeEventPending) {
- QResizeEvent e(newRect.size(), cr.size());
+ QResizeEvent e(newRect.size(), oldRect.size());
QGuiApplication::sendSpontaneousEvent(window, &e);
window->d_func()->resizeEventPending = false;
- if (cr.width() != newRect.width())
+ if (oldRect.width() != newRect.width())
window->widthChanged(newRect.width());
- if (cr.height() != newRect.height())
+ if (oldRect.height() != newRect.height())
window->heightChanged(newRect.height());
}
if (isMove) {
//### frame geometry
- QMoveEvent e(newRect.topLeft(), cr.topLeft());
+ QMoveEvent e(newRect.topLeft(), oldRect.topLeft());
QGuiApplication::sendSpontaneousEvent(window, &e);
- if (cr.x() != newRect.x())
+ if (oldRect.x() != newRect.x())
window->xChanged(newRect.x());
- if (cr.y() != newRect.y())
+ if (oldRect.y() != newRect.y())
window->yChanged(newRect.y());
}
}
@@ -2813,6 +2808,27 @@ bool QGuiApplication::isSavingSession() const
return d->is_saving_session;
}
+/*!
+ \since 5.2
+
+ Function that can be used to sync Qt state with the Window Systems state.
+
+ This function will first empty Qts events by calling QCoreApplication::processEvents(),
+ then the platform plugin will sync up with the windowsystem, and finally Qts events
+ will be delived by another call to QCoreApplication::processEvents();
+
+ This function is timeconsuming and its use is discouraged.
+*/
+void QGuiApplication::sync()
+{
+ QCoreApplication::processEvents();
+ if (QGuiApplicationPrivate::platform_integration
+ && QGuiApplicationPrivate::platform_integration->hasCapability(QPlatformIntegration::SyncState)) {
+ QGuiApplicationPrivate::platform_integration->sync();
+ QCoreApplication::processEvents();
+ }
+}
+
void QGuiApplicationPrivate::commitData()
{
Q_Q(QGuiApplication);
diff --git a/src/gui/kernel/qguiapplication.h b/src/gui/kernel/qguiapplication.h
index bd42f18418..0089d48fa6 100644
--- a/src/gui/kernel/qguiapplication.h
+++ b/src/gui/kernel/qguiapplication.h
@@ -155,6 +155,7 @@ public:
bool isSavingSession() const;
#endif
+ static void sync();
Q_SIGNALS:
void fontDatabaseChanged();
void screenAdded(QScreen *screen);
diff --git a/src/gui/kernel/qkeysequence_p.h b/src/gui/kernel/qkeysequence_p.h
index eac0d4b0a6..3751660500 100644
--- a/src/gui/kernel/qkeysequence_p.h
+++ b/src/gui/kernel/qkeysequence_p.h
@@ -69,6 +69,7 @@ struct Q_AUTOTEST_EXPORT QKeyBinding
class Q_AUTOTEST_EXPORT QKeySequencePrivate
{
public:
+ enum { MaxKeyCount = 4 }; // used in QKeySequenceEdit
inline QKeySequencePrivate() : ref(1)
{
key[0] = key[1] = key[2] = key[3] = 0;
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp
index ab782fac34..39dd2a2dfa 100644
--- a/src/gui/kernel/qopenglcontext.cpp
+++ b/src/gui/kernel/qopenglcontext.cpp
@@ -56,9 +56,7 @@
#include <private/qopenglextensions_p.h>
#include <private/qopenglversionfunctionsfactory_p.h>
-#if !defined(QT_OPENGL_ES_2)
#include <private/qopengltexturehelper_p.h>
-#endif
#include <QDebug>
@@ -274,7 +272,7 @@ QMutex QOpenGLContextPrivate::makeCurrentTrackerMutex;
or OpenGL ES 1.x.
For more information about the OpenGL API, refer to the official
- \l{OpenGL documentation}.
+ \l{http://www.opengl.org}{OpenGL documentation}.
For an example of how to use QOpenGLContext see the
\l{OpenGL Window Example}{OpenGL Window} example.
@@ -527,10 +525,8 @@ void QOpenGLContext::destroy()
d->versionFunctions.clear();
qDeleteAll(d->versionFunctionsBackend);
d->versionFunctionsBackend.clear();
-#if !defined(QT_OPENGL_ES_2)
delete d->textureFunctions;
d->textureFunctions = 0;
-#endif
}
/*!
@@ -591,6 +587,8 @@ QOpenGLFunctions *QOpenGLContext::functions() const
/*!
\fn T *QOpenGLContext::versionFunctions() const
+ \overload versionFunctions()
+
Returns a pointer to an object that provides access to all functions for
the version and profile of this context. Before using any of the functions
they must be initialized by calling QAbstractOpenGLFunctions::initializeOpenGLFunctions().
@@ -640,8 +638,6 @@ QOpenGLFunctions *QOpenGLContext::functions() const
Usually one would use the template version of this function to automatically
have the result cast to the correct type.
-
- \sa T *QOpenGLContext::versionFunctions()
*/
QAbstractOpenGLFunctions *QOpenGLContext::versionFunctions(const QOpenGLVersionProfile &versionProfile) const
{
@@ -984,7 +980,6 @@ void QOpenGLContext::removeFunctionsBackend(const QOpenGLVersionStatus &v)
d->versionFunctionsBackend.remove(v);
}
-#if !defined(QT_OPENGL_ES_2)
/*!
\internal
*/
@@ -1002,7 +997,6 @@ void QOpenGLContext::setTextureFunctions(QOpenGLTextureHelper* textureFuncs)
Q_D(QOpenGLContext);
d->textureFunctions = textureFuncs;
}
-#endif
/*!
\class QOpenGLContextGroup
diff --git a/src/gui/kernel/qopenglcontext.h b/src/gui/kernel/qopenglcontext.h
index 9756be30df..ce34a2d5a5 100644
--- a/src/gui/kernel/qopenglcontext.h
+++ b/src/gui/kernel/qopenglcontext.h
@@ -221,10 +221,8 @@ private:
QOpenGLVersionFunctionsBackend *backend);
void removeFunctionsBackend(const QOpenGLVersionStatus &v);
-#if !defined(QT_OPENGL_ES_2)
QOpenGLTextureHelper* textureFunctions() const;
void setTextureFunctions(QOpenGLTextureHelper* textureFuncs);
-#endif
void destroy();
};
diff --git a/src/gui/kernel/qplatformdialoghelper.cpp b/src/gui/kernel/qplatformdialoghelper.cpp
index fe5db27117..5ddd718e69 100644
--- a/src/gui/kernel/qplatformdialoghelper.cpp
+++ b/src/gui/kernel/qplatformdialoghelper.cpp
@@ -693,6 +693,48 @@ QMessageDialogOptions::StandardButtons QMessageDialogOptions::standardButtons()
return d->buttons;
}
+QMessageDialogOptions::ButtonRole QMessageDialogOptions::buttonRole(QMessageDialogOptions::StandardButton button)
+{
+ switch (button) {
+ case Ok:
+ case Save:
+ case Open:
+ case SaveAll:
+ case Retry:
+ case Ignore:
+ return AcceptRole;
+
+ case Cancel:
+ case Close:
+ case Abort:
+ return RejectRole;
+
+ case Discard:
+ return DestructiveRole;
+
+ case Help:
+ return HelpRole;
+
+ case Apply:
+ return ApplyRole;
+
+ case Yes:
+ case YesToAll:
+ return YesRole;
+
+ case No:
+ case NoToAll:
+ return NoRole;
+
+ case RestoreDefaults:
+ case Reset:
+ return ResetRole;
+
+ default:
+ break;
+ }
+ return InvalidRole;
+}
/*!
\class QPlatformMessageDialogHelper
diff --git a/src/gui/kernel/qplatformdialoghelper.h b/src/gui/kernel/qplatformdialoghelper.h
index ad818c8644..9eeb0a6da4 100644
--- a/src/gui/kernel/qplatformdialoghelper.h
+++ b/src/gui/kernel/qplatformdialoghelper.h
@@ -361,6 +361,21 @@ public:
Q_DECLARE_FLAGS(StandardButtons, StandardButton)
+ enum ButtonRole {
+ InvalidRole = -1,
+ AcceptRole,
+ RejectRole,
+ DestructiveRole,
+ ActionRole,
+ HelpRole,
+ YesRole,
+ NoRole,
+ ResetRole,
+ ApplyRole,
+
+ NRoles
+ };
+
QMessageDialogOptions();
QMessageDialogOptions(const QMessageDialogOptions &rhs);
QMessageDialogOptions &operator=(const QMessageDialogOptions &rhs);
@@ -386,6 +401,8 @@ public:
void setStandardButtons(StandardButtons buttons);
StandardButtons standardButtons() const;
+ static ButtonRole buttonRole(StandardButton button);
+
private:
QSharedDataPointer<QMessageDialogOptionsPrivate> d;
};
@@ -400,7 +417,7 @@ public:
void setOptions(const QSharedPointer<QMessageDialogOptions> &options);
Q_SIGNALS:
- void clicked(QMessageDialogOptions::StandardButton button);
+ void clicked(QMessageDialogOptions::StandardButton button, QMessageDialogOptions::ButtonRole role);
private:
QSharedPointer<QMessageDialogOptions> m_options;
diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp
index 49ac7836cb..26aaf931b3 100644
--- a/src/gui/kernel/qplatformintegration.cpp
+++ b/src/gui/kernel/qplatformintegration.cpp
@@ -343,6 +343,8 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const
return QPlatformTheme::defaultThemeHint(QPlatformTheme::StartDragTime);
case ShowIsFullScreen:
return false;
+ case ShowIsMaximized:
+ return false;
case PasswordMaskDelay:
return QPlatformTheme::defaultThemeHint(QPlatformTheme::PasswordMaskDelay);
case PasswordMaskCharacter:
@@ -362,6 +364,20 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const
return 0;
}
+Qt::WindowState QPlatformIntegration::defaultWindowState(Qt::WindowFlags flags) const
+{
+ // Leave popup-windows as is
+ if (flags & Qt::Popup & ~Qt::Window)
+ return Qt::WindowNoState;
+
+ if (styleHint(QPlatformIntegration::ShowIsFullScreen).toBool())
+ return Qt::WindowFullScreen;
+ else if (styleHint(QPlatformIntegration::ShowIsMaximized).toBool())
+ return Qt::WindowMaximized;
+
+ return Qt::WindowNoState;
+}
+
Qt::KeyboardModifiers QPlatformIntegration::queryKeyboardModifiers() const
{
return QGuiApplication::keyboardModifiers();
@@ -435,4 +451,19 @@ QPlatformSessionManager *QPlatformIntegration::createPlatformSessionManager(cons
}
#endif
+/*!
+ \since 5.2
+
+ Function to sync the platform integrations state with the window system.
+
+ This is often implemented as a roundtrip from the platformintegration to the window system.
+
+ This function should not call QWindowSystemInterface::flushWindowSystemEvents() or
+ QCoreApplication::processEvents()
+*/
+void QPlatformIntegration::sync()
+{
+
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h
index d3189f8641..580fc15233 100644
--- a/src/gui/kernel/qplatformintegration.h
+++ b/src/gui/kernel/qplatformintegration.h
@@ -94,7 +94,8 @@ public:
ForeignWindows,
NonFullScreenWindows,
NativeWidgets,
- WindowManagement
+ WindowManagement,
+ SyncState
};
virtual ~QPlatformIntegration() { }
@@ -146,10 +147,12 @@ public:
UseRtlExtensions,
SynthesizeMouseFromTouchEvents,
PasswordMaskCharacter,
- SetFocusOnTouchRelease
+ SetFocusOnTouchRelease,
+ ShowIsMaximized
};
virtual QVariant styleHint(StyleHint hint) const;
+ virtual Qt::WindowState defaultWindowState(Qt::WindowFlags) const;
virtual Qt::KeyboardModifiers queryKeyboardModifiers() const;
virtual QList<int> possibleKeys(const QKeyEvent *) const;
@@ -162,6 +165,8 @@ public:
#ifndef QT_NO_SESSIONMANAGER
virtual QPlatformSessionManager *createPlatformSessionManager(const QString &id, const QString &key) const;
#endif
+
+ virtual void sync();
protected:
void screenAdded(QPlatformScreen *screen);
};
diff --git a/src/gui/kernel/qplatformsystemtrayicon_qpa.cpp b/src/gui/kernel/qplatformsystemtrayicon_qpa.cpp
index 5d7ff7864d..c4cec40a10 100644
--- a/src/gui/kernel/qplatformsystemtrayicon_qpa.cpp
+++ b/src/gui/kernel/qplatformsystemtrayicon_qpa.cpp
@@ -130,7 +130,7 @@ QPlatformSystemTrayIcon::~QPlatformSystemTrayIcon()
const QIcon &icon, MessageIcon iconType, int secs)
Shows a balloon message for the entry with the given \a title, message \a msg and \a icon for
the time specified in \a secs. \a iconType is used as a hint for the implementing platform.
- \sa QSystemTrayIcon::showMessage
+ \sa QSystemTrayIcon::showMessage()
*/
/*!
diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp
index 562df1c913..1844232efe 100644
--- a/src/gui/kernel/qplatformtheme.cpp
+++ b/src/gui/kernel/qplatformtheme.cpp
@@ -50,6 +50,7 @@
#include <qtextformat.h>
#include <private/qiconloader_p.h>
#include <private/qguiapplication_p.h>
+#include <qpa/qplatformintegration.h>
QT_BEGIN_NAMESPACE
@@ -399,7 +400,32 @@ QPixmap QPlatformTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &
QVariant QPlatformTheme::themeHint(ThemeHint hint) const
{
- return QPlatformTheme::defaultThemeHint(hint);
+ // For theme hints which mirror platform integration style hints, query
+ // the platform integration. The base QPlatformIntegration::styleHint()
+ // function will in turn query QPlatformTheme::defaultThemeHint() if there
+ // is no custom value.
+ switch (hint) {
+ case QPlatformTheme::CursorFlashTime:
+ return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::CursorFlashTime);
+ case QPlatformTheme::KeyboardInputInterval:
+ return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::KeyboardInputInterval);
+ case QPlatformTheme::KeyboardAutoRepeatRate:
+ return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::KeyboardAutoRepeatRate);
+ case QPlatformTheme::MouseDoubleClickInterval:
+ return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::MouseDoubleClickInterval);
+ case QPlatformTheme::StartDragDistance:
+ return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::StartDragDistance);
+ case QPlatformTheme::StartDragTime:
+ return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::StartDragTime);
+ case QPlatformTheme::StartDragVelocity:
+ return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::StartDragVelocity);
+ case QPlatformTheme::PasswordMaskDelay:
+ return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::PasswordMaskDelay);
+ case QPlatformTheme::PasswordMaskCharacter:
+ return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::PasswordMaskCharacter);
+ default:
+ return QPlatformTheme::defaultThemeHint(hint);
+ }
}
QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp
index 1f9183db44..954d47f18c 100644
--- a/src/gui/kernel/qplatformwindow.cpp
+++ b/src/gui/kernel/qplatformwindow.cpp
@@ -487,6 +487,27 @@ bool QPlatformWindow::isAlertState() const
return false;
}
+// Return the effective screen for the initial geometry of a window. In a
+// multimonitor-setup, try to find the right screen by checking the transient
+// parent or the mouse cursor for parentless windows (cf QTBUG-34204,
+// QDialog::adjustPosition()).
+static inline const QScreen *effectiveScreen(const QWindow *window)
+{
+ if (!window)
+ return QGuiApplication::primaryScreen();
+ const QScreen *screen = window->screen();
+ if (!screen)
+ return QGuiApplication::primaryScreen();
+ const QList<QScreen *> siblings = screen->virtualSiblings();
+ if (siblings.size() > 1) {
+ const QPoint referencePoint = window->transientParent() ? window->transientParent()->geometry().center() : QCursor::pos();
+ foreach (const QScreen *sibling, siblings)
+ if (sibling->geometry().contains(referencePoint))
+ return sibling;
+ }
+ return screen;
+}
+
/*!
Helper function to get initial geometry on windowing systems which do not
do smart positioning and also do not provide a means of centering a
@@ -511,8 +532,8 @@ QRect QPlatformWindow::initialGeometry(const QWindow *w,
}
if (w->isTopLevel() && qt_window_private(const_cast<QWindow*>(w))->positionAutomatic
&& w->type() != Qt::Popup) {
- if (const QPlatformScreen *platformScreen = QPlatformScreen::platformScreenForWindow(w)) {
- const QRect availableGeometry = platformScreen->availableGeometry();
+ if (const QScreen *screen = effectiveScreen(w)) {
+ const QRect availableGeometry = screen->availableGeometry();
// Center unless the geometry ( + unknown window frame) is too large for the screen).
if (rect.height() < (availableGeometry.height() * 8) / 9
&& rect.width() < (availableGeometry.width() * 8) / 9) {
diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp
index 7899e2540b..8d751d8615 100644
--- a/src/gui/kernel/qstylehints.cpp
+++ b/src/gui/kernel/qstylehints.cpp
@@ -270,6 +270,9 @@ int QStyleHints::cursorFlashTime() const
Returns \c true if the platform defaults to windows being fullscreen,
otherwise \c false.
+ \note The platform may still choose to show certain windows non-fullscreen,
+ such as popups or dialogs. This method only returns the default behavior.
+
\sa QWindow::show()
*/
bool QStyleHints::showIsFullScreen() const
diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp
index b8fe55adc0..2b6cb2d949 100644
--- a/src/gui/kernel/qsurfaceformat.cpp
+++ b/src/gui/kernel/qsurfaceformat.cpp
@@ -468,7 +468,7 @@ bool QSurfaceFormat::hasAlpha() const
/*!
Set the preferred stencil buffer size to \a size bits.
- \sa stencilBufferSize(), setStencil(), stencil()
+ \sa stencilBufferSize()
*/
void QSurfaceFormat::setStencilBufferSize(int size)
{
@@ -481,7 +481,7 @@ void QSurfaceFormat::setStencilBufferSize(int size)
/*!
Returns the stencil buffer size in bits.
- \sa stencil(), setStencil(), setStencilBufferSize()
+ \sa setStencilBufferSize()
*/
int QSurfaceFormat::stencilBufferSize() const
{
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 13218fa178..2e1d8f9976 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -367,6 +367,10 @@ void QWindowPrivate::setScreen(QScreen *newScreen, bool recreate)
}
}
+void QWindowPrivate::clearFocusObject()
+{
+}
+
/*!
Sets the \a surfaceType of the window.
@@ -982,8 +986,13 @@ Qt::ScreenOrientation QWindow::contentOrientation() const
qreal QWindow::devicePixelRatio() const
{
Q_D(const QWindow);
+
+ // If there is no platform window, do the second best thing and
+ // return the app global devicePixelRatio. This is the highest
+ // devicePixelRatio found on the system screens, and will be
+ // correct for single-display systems (a very common case).
if (!d->platformWindow)
- return 1.0;
+ return qApp->devicePixelRatio();
return d->platformWindow->devicePixelRatio();
}
@@ -1642,17 +1651,18 @@ QObject *QWindow::focusObject() const
/*!
Shows the window.
- This equivalent to calling showFullScreen() or showNormal(), depending
- on whether the platform defaults to windows being fullscreen or not, and
- whether the window is a popup.
+ This is equivalent to calling showFullScreen(), showMaximized(), or showNormal(),
+ depending on the platform's default behavior for the window type and flags.
- \sa showFullScreen(), showNormal(), hide(), QStyleHints::showIsFullScreen(), flags()
+ \sa showFullScreen(), showMaximized(), showNormal(), hide(), QStyleHints::showIsFullScreen(), flags()
*/
void QWindow::show()
{
- bool isPopup = d_func()->windowFlags & Qt::Popup & ~Qt::Window;
- if (!isPopup && qApp->styleHints()->showIsFullScreen())
+ Qt::WindowState defaultState = QGuiApplicationPrivate::platformIntegration()->defaultWindowState(d_func()->windowFlags);
+ if (defaultState == Qt::WindowFullScreen)
showFullScreen();
+ else if (defaultState == Qt::WindowMaximized)
+ showMaximized();
else
showNormal();
}
diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h
index f43c1ea8ec..8d8fca3ce6 100644
--- a/src/gui/kernel/qwindow_p.h
+++ b/src/gui/kernel/qwindow_p.h
@@ -129,6 +129,8 @@ public:
void setScreen(QScreen *newScreen, bool recreate);
+ virtual void clearFocusObject();
+
QWindow::SurfaceType surfaceType;
Qt::WindowFlags windowFlags;
QWindow *parentWindow;
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
index 07717bb63d..49ff8bcb0d 100644
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -141,9 +141,12 @@ void QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationState
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
}
-void QWindowSystemInterface::handleGeometryChange(QWindow *tlw, const QRect &newRect)
+/*!
+ If \a oldRect is null, Qt will use the previously reported geometry instead.
+ */
+void QWindowSystemInterface::handleGeometryChange(QWindow *tlw, const QRect &newRect, const QRect &oldRect)
{
- QWindowSystemInterfacePrivate::GeometryChangeEvent *e = new QWindowSystemInterfacePrivate::GeometryChangeEvent(tlw,newRect);
+ QWindowSystemInterfacePrivate::GeometryChangeEvent *e = new QWindowSystemInterfacePrivate::GeometryChangeEvent(tlw,newRect, oldRect);
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
}
diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h
index 0c3494a46d..71feb1bcb7 100644
--- a/src/gui/kernel/qwindowsysteminterface.h
+++ b/src/gui/kernel/qwindowsysteminterface.h
@@ -138,7 +138,7 @@ public:
static void handleTouchCancelEvent(QWindow *w, QTouchDevice *device, Qt::KeyboardModifiers mods = Qt::NoModifier);
static void handleTouchCancelEvent(QWindow *w, ulong timestamp, QTouchDevice *device, Qt::KeyboardModifiers mods = Qt::NoModifier);
- static void handleGeometryChange(QWindow *w, const QRect &newRect);
+ static void handleGeometryChange(QWindow *w, const QRect &newRect, const QRect &oldRect = QRect());
static void handleCloseEvent(QWindow *w, bool *accepted = 0);
static void handleEnterEvent(QWindow *w, const QPointF &local = QPointF(), const QPointF& global = QPointF());
static void handleLeaveEvent(QWindow *w);
diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h
index f0398ffc51..367b0ac11d 100644
--- a/src/gui/kernel/qwindowsysteminterface_p.h
+++ b/src/gui/kernel/qwindowsysteminterface_p.h
@@ -117,11 +117,12 @@ public:
class GeometryChangeEvent : public WindowSystemEvent {
public:
- GeometryChangeEvent(QWindow *tlw, const QRect &newGeometry)
- : WindowSystemEvent(GeometryChange), tlw(tlw), newGeometry(newGeometry)
+ GeometryChangeEvent(QWindow *tlw, const QRect &newGeometry, const QRect &oldGeometry)
+ : WindowSystemEvent(GeometryChange), tlw(tlw), newGeometry(newGeometry), oldGeometry(oldGeometry)
{ }
QPointer<QWindow> tlw;
QRect newGeometry;
+ QRect oldGeometry;
};
class EnterEvent : public WindowSystemEvent {