summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qclipboard.cpp6
-rw-r--r--src/gui/kernel/qcursor.cpp6
-rw-r--r--src/gui/kernel/qdnd.cpp2
-rw-r--r--src/gui/kernel/qdrag.cpp2
-rw-r--r--src/gui/kernel/qevent.cpp2
-rw-r--r--src/gui/kernel/qgenericplugin.cpp2
-rw-r--r--src/gui/kernel/qguiapplication.cpp81
-rw-r--r--src/gui/kernel/qhighdpiscaling.cpp2
-rw-r--r--src/gui/kernel/qinputdevicemanager.cpp2
-rw-r--r--src/gui/kernel/qinternalmimedata.cpp2
-rw-r--r--src/gui/kernel/qkeymapper.cpp2
-rw-r--r--src/gui/kernel/qkeysequence.cpp6
-rw-r--r--src/gui/kernel/qoffscreensurface.cpp2
-rw-r--r--src/gui/kernel/qopenglcontext.cpp3
-rw-r--r--src/gui/kernel/qpaintdevicewindow.cpp2
-rw-r--r--src/gui/kernel/qpalette.cpp7
-rw-r--r--src/gui/kernel/qplatformdialoghelper.cpp2
-rw-r--r--src/gui/kernel/qplatformgraphicsbuffer.cpp2
-rw-r--r--src/gui/kernel/qplatforminputcontext.cpp2
-rw-r--r--src/gui/kernel/qplatforminputcontextplugin.cpp2
-rw-r--r--src/gui/kernel/qplatformintegrationplugin.cpp2
-rw-r--r--src/gui/kernel/qplatformmenu.cpp2
-rw-r--r--src/gui/kernel/qplatformnativeinterface.cpp2
-rw-r--r--src/gui/kernel/qplatformscreen.cpp2
-rw-r--r--src/gui/kernel/qplatformsharedgraphicscache.cpp2
-rw-r--r--src/gui/kernel/qplatformtheme.cpp22
-rw-r--r--src/gui/kernel/qplatformthemeplugin.cpp2
-rw-r--r--src/gui/kernel/qplatformwindow.cpp39
-rw-r--r--src/gui/kernel/qrasterwindow.cpp2
-rw-r--r--src/gui/kernel/qscreen.cpp14
-rw-r--r--src/gui/kernel/qsessionmanager.cpp2
-rw-r--r--src/gui/kernel/qshapedpixmapdndwindow.cpp2
-rw-r--r--src/gui/kernel/qstylehints.cpp2
-rw-r--r--src/gui/kernel/qsurface.cpp2
-rw-r--r--src/gui/kernel/qsurfaceformat.cpp2
-rw-r--r--src/gui/kernel/qtestsupport_gui.cpp24
-rw-r--r--src/gui/kernel/qwindow.cpp31
37 files changed, 207 insertions, 84 deletions
diff --git a/src/gui/kernel/qclipboard.cpp b/src/gui/kernel/qclipboard.cpp
index db22ef2486..7158d96c86 100644
--- a/src/gui/kernel/qclipboard.cpp
+++ b/src/gui/kernel/qclipboard.cpp
@@ -150,6 +150,10 @@ QT_BEGIN_NAMESPACE
\endlist
+ \section1 Notes for Android Users
+
+ On Android only these mime types are supported: text/plain, text/html, and text/uri-list.
+
\sa QGuiApplication
*/
@@ -610,4 +614,6 @@ void QClipboard::emitChanged(Mode mode)
QT_END_NAMESPACE
+#include "moc_qclipboard.cpp"
+
#endif // QT_NO_CLIPBOARD
diff --git a/src/gui/kernel/qcursor.cpp b/src/gui/kernel/qcursor.cpp
index 1efa28a5af..455088241c 100644
--- a/src/gui/kernel/qcursor.cpp
+++ b/src/gui/kernel/qcursor.cpp
@@ -251,7 +251,8 @@ void QCursor::setPos(QScreen *screen, int x, int y)
{
if (screen) {
if (QPlatformCursor *cursor = screen->handle()->cursor()) {
- const QPoint devicePos = QHighDpi::toNativePixels(QPoint(x, y), screen);
+ const QPoint pos(x, y);
+ const QPoint devicePos = QHighDpi::toNativePixels(pos, screen->virtualSiblingAt(pos));
// Need to check, since some X servers generate null mouse move
// events, causing looping in applications which call setPos() on
// every mouse move event.
@@ -529,8 +530,7 @@ bool operator==(const QCursor &lhs, const QCursor &rhs) noexcept
*/
/*!
- Returns the cursor shape identifier. The return value is one of
- the \l Qt::CursorShape enum values (cast to an int).
+ Returns the cursor shape identifier.
\sa setShape()
*/
diff --git a/src/gui/kernel/qdnd.cpp b/src/gui/kernel/qdnd.cpp
index fe766c900e..ecf8b3f4ce 100644
--- a/src/gui/kernel/qdnd.cpp
+++ b/src/gui/kernel/qdnd.cpp
@@ -123,3 +123,5 @@ Qt::DropAction QDragManager::drag(QDrag *o)
}
QT_END_NAMESPACE
+
+#include "moc_qdnd_p.cpp"
diff --git a/src/gui/kernel/qdrag.cpp b/src/gui/kernel/qdrag.cpp
index 3712eace15..ee4b816e72 100644
--- a/src/gui/kernel/qdrag.cpp
+++ b/src/gui/kernel/qdrag.cpp
@@ -423,3 +423,5 @@ void QDrag::cancel()
*/
QT_END_NAMESPACE
+
+#include "moc_qdrag.cpp"
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index a6da24e4b2..542f3e3217 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -5320,3 +5320,5 @@ uint qHash(QPointingDeviceUniqueId key, uint seed) noexcept
}
QT_END_NAMESPACE
+
+#include "moc_qevent.cpp"
diff --git a/src/gui/kernel/qgenericplugin.cpp b/src/gui/kernel/qgenericplugin.cpp
index a53b60b008..7ecdc72d97 100644
--- a/src/gui/kernel/qgenericplugin.cpp
+++ b/src/gui/kernel/qgenericplugin.cpp
@@ -94,3 +94,5 @@ QGenericPlugin::~QGenericPlugin()
*/
QT_END_NAMESPACE
+
+#include "moc_qgenericplugin.cpp"
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 239a78313c..c7ff2a6dac 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -61,7 +61,7 @@
#include <QtCore/private/qlocking_p.h>
#include <QtCore/qdir.h>
#include <QtCore/qlibraryinfo.h>
-#include <QtCore/qnumeric.h>
+#include <QtCore/private/qnumeric_p.h>
#include <QtDebug>
#ifndef QT_NO_ACCESSIBILITY
#include "qaccessible.h"
@@ -140,7 +140,7 @@ Q_GUI_EXPORT bool qt_is_gui_used = true;
Qt::MouseButtons QGuiApplicationPrivate::mouse_buttons = Qt::NoButton;
Qt::KeyboardModifiers QGuiApplicationPrivate::modifier_buttons = Qt::NoModifier;
-QPointF QGuiApplicationPrivate::lastCursorPosition(qInf(), qInf());
+QPointF QGuiApplicationPrivate::lastCursorPosition(qt_inf(), qt_inf());
QWindow *QGuiApplicationPrivate::currentMouseWindow = nullptr;
@@ -201,7 +201,7 @@ static bool force_reverse = false;
QGuiApplicationPrivate *QGuiApplicationPrivate::self = nullptr;
QTouchDevice *QGuiApplicationPrivate::m_fakeTouchDevice = nullptr;
-int QGuiApplicationPrivate::m_fakeMouseSourcePointId = 0;
+int QGuiApplicationPrivate::m_fakeMouseSourcePointId = -1;
#ifndef QT_NO_CLIPBOARD
QClipboard *QGuiApplicationPrivate::qt_clipboard = nullptr;
@@ -1316,7 +1316,10 @@ static void init_platform(const QString &pluginNamesWithArguments, const QString
}
#endif
- fontSmoothingGamma = QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::FontSmoothingGamma).toReal();
+ const auto platformIntegration = QGuiApplicationPrivate::platformIntegration();
+ fontSmoothingGamma = platformIntegration->styleHint(QPlatformIntegration::FontSmoothingGamma).toReal();
+ QCoreApplication::setAttribute(Qt::AA_DontShowShortcutsInContextMenus,
+ !platformIntegration->styleHint(QPlatformIntegration::ShowShortcutsInContextMenus).toBool());
}
static void init_plugins(const QList<QByteArray> &pluginList)
@@ -1382,11 +1385,11 @@ void QGuiApplicationPrivate::addQtOptions(QList<QCommandLineOption> *options)
QGuiApplication::tr("ID of the X11 Visual to use."), QStringLiteral("id")));
// Not using the "QStringList names" solution for those aliases, because it makes the first column too wide
options->append(QCommandLineOption(QStringLiteral("geometry"),
- QGuiApplication::tr("Alias for --windowgeometry."), QStringLiteral("geometry")));
+ QGuiApplication::tr("Alias for --qwindowgeometry."), QStringLiteral("geometry")));
options->append(QCommandLineOption(QStringLiteral("icon"),
- QGuiApplication::tr("Alias for --windowicon."), QStringLiteral("icon")));
+ QGuiApplication::tr("Alias for --qwindowicon."), QStringLiteral("icon")));
options->append(QCommandLineOption(QStringLiteral("title"),
- QGuiApplication::tr("Alias for --windowtitle."), QStringLiteral("title")));
+ QGuiApplication::tr("Alias for --qwindowtitle."), QStringLiteral("title")));
}
}
#endif // QT_CONFIG(commandlineparser)
@@ -2131,6 +2134,11 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
bool mouseMove = false;
bool mousePress = false;
+ if (qIsNaN(e->globalPos.x()) || qIsNaN(e->globalPos.y())) {
+ qWarning("QGuiApplicationPrivate::processMouseEvent: Got NaN in mouse position");
+ return;
+ }
+
if (e->enhancedMouseEvent()) {
type = e->buttonType;
button = e->button;
@@ -2151,7 +2159,7 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
processMouseEvent(e); // the original mouse event
return;
}
- if (mouseMove && !positionChanged) {
+ if (type == QEvent::MouseMove && !positionChanged) {
// On Windows, and possibly other platforms, a touchpad can send a mouse move
// that does not change position, between a press and a release. This may
// confuse applications, so we always filter out these mouse events for
@@ -3052,32 +3060,32 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
if (!e->synthetic() && !touchEvent.isAccepted() && qApp->testAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents)) {
// exclude devices which generate their own mouse events
if (!(touchEvent.device()->capabilities() & QTouchDevice::MouseEmulation)) {
-
- if (eventType == QEvent::TouchEnd)
- self->synthesizedMousePoints.clear();
-
const QList<QTouchEvent::TouchPoint> &touchPoints = touchEvent.touchPoints();
- if (eventType == QEvent::TouchBegin)
+ QEvent::Type mouseEventType = QEvent::MouseMove;
+ Qt::MouseButton button = Qt::NoButton;
+ Qt::MouseButtons buttons = Qt::LeftButton;
+ if (eventType == QEvent::TouchBegin || m_fakeMouseSourcePointId < 0)
m_fakeMouseSourcePointId = touchPoints.first().id();
-
- const QEvent::Type mouseType = [&]() {
- switch (eventType) {
- case QEvent::TouchBegin: return QEvent::MouseButtonPress;
- case QEvent::TouchUpdate: return QEvent::MouseMove;
- case QEvent::TouchEnd: return QEvent::MouseButtonRelease;
- default: Q_UNREACHABLE();
- }
- }();
-
- Qt::MouseButton button = mouseType == QEvent::MouseMove ? Qt::NoButton : Qt::LeftButton;
- Qt::MouseButtons buttons = mouseType == QEvent::MouseButtonRelease ? Qt::NoButton : Qt::LeftButton;
-
- for (int i = 0; i < touchPoints.count(); ++i) {
- const QTouchEvent::TouchPoint &touchPoint = touchPoints.at(i);
+ for (const auto &touchPoint : touchPoints) {
if (touchPoint.id() == m_fakeMouseSourcePointId) {
- if (eventType != QEvent::TouchEnd)
+ switch (touchPoint.state()) {
+ case Qt::TouchPointPressed:
+ mouseEventType = QEvent::MouseButtonPress;
+ button = Qt::LeftButton;
+ break;
+ case Qt::TouchPointReleased:
+ mouseEventType = QEvent::MouseButtonRelease;
+ button = Qt::LeftButton;
+ buttons = Qt::NoButton;
+ m_fakeMouseSourcePointId = -1;
+ break;
+ default:
+ break;
+ }
+ if (touchPoint.state() != Qt::TouchPointReleased) {
self->synthesizedMousePoints.insert(w, SynthesizedMouseData(
touchPoint.pos(), touchPoint.screenPos(), w));
+ }
// All touch events that are not accepted by the application will be translated to
// left mouse button events instead (see AA_SynthesizeMouseForUnhandledTouchEvents docs).
QWindowSystemInterfacePrivate::MouseEvent fake(w, e->timestamp,
@@ -3086,13 +3094,15 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
buttons,
e->modifiers,
button,
- mouseType,
+ mouseEventType,
Qt::MouseEventSynthesizedByQt);
fake.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic;
processMouseEvent(&fake);
break;
}
}
+ if (eventType == QEvent::TouchEnd)
+ self->synthesizedMousePoints.clear();
}
}
}
@@ -3162,13 +3172,14 @@ void QGuiApplicationPrivate::processScreenGeometryChange(QWindowSystemInterfaceP
bool availableGeometryChanged = e->availableGeometry != s->d_func()->availableGeometry;
s->d_func()->availableGeometry = e->availableGeometry;
- if (geometryChanged) {
- Qt::ScreenOrientation primaryOrientation = s->primaryOrientation();
+ const Qt::ScreenOrientation primaryOrientation = s->primaryOrientation();
+ if (geometryChanged)
s->d_func()->updatePrimaryOrientation();
- emit s->geometryChanged(s->geometry());
+ s->d_func()->emitGeometryChangeSignals(geometryChanged, availableGeometryChanged);
+
+ if (geometryChanged) {
emit s->physicalSizeChanged(s->physicalSize());
- emit s->physicalDotsPerInchChanged(s->physicalDotsPerInch());
emit s->logicalDotsPerInchChanged(s->logicalDotsPerInch());
if (s->primaryOrientation() != primaryOrientation)
@@ -3178,8 +3189,6 @@ void QGuiApplicationPrivate::processScreenGeometryChange(QWindowSystemInterfaceP
updateFilteredScreenOrientation(s);
}
- s->d_func()->emitGeometryChangeSignals(geometryChanged, availableGeometryChanged);
-
resetCachedDevicePixelRatio();
}
diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp
index 9bbf2773a9..85ff58c14c 100644
--- a/src/gui/kernel/qhighdpiscaling.cpp
+++ b/src/gui/kernel/qhighdpiscaling.cpp
@@ -726,3 +726,5 @@ QHighDpiScaling::ScaleAndOrigin QHighDpiScaling::scaleAndOrigin(const QWindow *w
#endif //QT_NO_HIGHDPISCALING
QT_END_NAMESPACE
+
+#include "moc_qhighdpiscaling_p.cpp"
diff --git a/src/gui/kernel/qinputdevicemanager.cpp b/src/gui/kernel/qinputdevicemanager.cpp
index 11442407e1..13e32a08f9 100644
--- a/src/gui/kernel/qinputdevicemanager.cpp
+++ b/src/gui/kernel/qinputdevicemanager.cpp
@@ -116,3 +116,5 @@ void QInputDeviceManager::setKeyboardModifiers(Qt::KeyboardModifiers mods)
}
QT_END_NAMESPACE
+
+#include "moc_qinputdevicemanager_p.cpp"
diff --git a/src/gui/kernel/qinternalmimedata.cpp b/src/gui/kernel/qinternalmimedata.cpp
index d5cdc743ee..a2b47879cc 100644
--- a/src/gui/kernel/qinternalmimedata.cpp
+++ b/src/gui/kernel/qinternalmimedata.cpp
@@ -233,3 +233,5 @@ QByteArray QInternalMimeData::renderDataHelper(const QString &mimeType, const QM
}
QT_END_NAMESPACE
+
+#include "moc_qinternalmimedata_p.cpp"
diff --git a/src/gui/kernel/qkeymapper.cpp b/src/gui/kernel/qkeymapper.cpp
index 274574f561..38180105e0 100644
--- a/src/gui/kernel/qkeymapper.cpp
+++ b/src/gui/kernel/qkeymapper.cpp
@@ -147,3 +147,5 @@ QList<int> QKeyMapperPrivate::possibleKeys(QKeyEvent *e)
}
QT_END_NAMESPACE
+
+#include "moc_qkeymapper_p.cpp"
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
index a75b8ef920..56cd2d02bc 100644
--- a/src/gui/kernel/qkeysequence.cpp
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -73,8 +73,7 @@ static const int kControlUnicode = 0x2303;
static const int kOptionUnicode = 0x2325;
static const int kCommandUnicode = 0x2318;
-static const int NumEntries = 21;
-static const MacSpecialKey entries[NumEntries] = {
+static const MacSpecialKey entries[] = {
{ Qt::Key_Escape, 0x238B },
{ Qt::Key_Tab, 0x21E5 },
{ Qt::Key_Backtab, 0x21E4 },
@@ -96,6 +95,7 @@ static const MacSpecialKey entries[NumEntries] = {
{ Qt::Key_Alt, kOptionUnicode },
{ Qt::Key_CapsLock, 0x21EA },
};
+static const int NumEntries = sizeof entries / sizeof *entries;
static bool operator<(const MacSpecialKey &entry, int key)
{
@@ -1693,3 +1693,5 @@ QDebug operator<<(QDebug dbg, const QKeySequence &p)
*/
QT_END_NAMESPACE
+
+#include "moc_qkeysequence.cpp"
diff --git a/src/gui/kernel/qoffscreensurface.cpp b/src/gui/kernel/qoffscreensurface.cpp
index c74fe0b3a1..ae7bc33291 100644
--- a/src/gui/kernel/qoffscreensurface.cpp
+++ b/src/gui/kernel/qoffscreensurface.cpp
@@ -435,3 +435,5 @@ QPlatformSurface *QOffscreenSurface::surfaceHandle() const
}
QT_END_NAMESPACE
+
+#include "moc_qoffscreensurface.cpp"
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp
index 927e9cb94a..2291bfe70f 100644
--- a/src/gui/kernel/qopenglcontext.cpp
+++ b/src/gui/kernel/qopenglcontext.cpp
@@ -1031,7 +1031,8 @@ bool QOpenGLContext::makeCurrent(QSurface *surface)
|| qstrcmp(rendererString, "GC800 core") == 0
|| qstrcmp(rendererString, "GC1000 core") == 0
|| strstr(rendererString, "GC2000") != nullptr
- || qstrcmp(rendererString, "Immersion.16") == 0;
+ || qstrcmp(rendererString, "Immersion.16") == 0
+ || qstrncmp(rendererString, "Apple Mx", 7) == 0;
}
needsWorkaroundSet = true;
}
diff --git a/src/gui/kernel/qpaintdevicewindow.cpp b/src/gui/kernel/qpaintdevicewindow.cpp
index 4f45fc5fde..0ba52cc7ab 100644
--- a/src/gui/kernel/qpaintdevicewindow.cpp
+++ b/src/gui/kernel/qpaintdevicewindow.cpp
@@ -223,3 +223,5 @@ QPaintEngine *QPaintDeviceWindow::paintEngine() const
}
QT_END_NAMESPACE
+
+#include "moc_qpaintdevicewindow.cpp"
diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp
index 397c50f3dc..a192b7aef4 100644
--- a/src/gui/kernel/qpalette.cpp
+++ b/src/gui/kernel/qpalette.cpp
@@ -531,7 +531,10 @@ static void qt_palette_from_color(QPalette &pal, const QColor &button)
*/
/*!
- Constructs a palette object that uses the application's default palette.
+ Constructs an empty palette object with no color roles set.
+
+ When used as the palette of a QWidget the colors are resolved
+ as described by QWidget::setPalette().
\sa QApplication::setPalette(), QApplication::palette()
*/
@@ -1231,3 +1234,5 @@ QDebug operator<<(QDebug dbg, const QPalette &p)
#endif
QT_END_NAMESPACE
+
+#include "moc_qpalette.cpp"
diff --git a/src/gui/kernel/qplatformdialoghelper.cpp b/src/gui/kernel/qplatformdialoghelper.cpp
index 33cd004234..4ca5421bc1 100644
--- a/src/gui/kernel/qplatformdialoghelper.cpp
+++ b/src/gui/kernel/qplatformdialoghelper.cpp
@@ -1012,3 +1012,5 @@ void QPlatformMessageDialogHelper::setOptions(const QSharedPointer<QMessageDialo
}
QT_END_NAMESPACE
+
+#include "moc_qplatformdialoghelper.cpp"
diff --git a/src/gui/kernel/qplatformgraphicsbuffer.cpp b/src/gui/kernel/qplatformgraphicsbuffer.cpp
index 73ec033e19..371fd543be 100644
--- a/src/gui/kernel/qplatformgraphicsbuffer.cpp
+++ b/src/gui/kernel/qplatformgraphicsbuffer.cpp
@@ -274,3 +274,5 @@ QPlatformGraphicsBuffer::Origin QPlatformGraphicsBuffer::origin() const
*/
QT_END_NAMESPACE
+
+#include "moc_qplatformgraphicsbuffer.cpp"
diff --git a/src/gui/kernel/qplatforminputcontext.cpp b/src/gui/kernel/qplatforminputcontext.cpp
index 9771e6ba11..5b6b2d11d8 100644
--- a/src/gui/kernel/qplatforminputcontext.cpp
+++ b/src/gui/kernel/qplatforminputcontext.cpp
@@ -298,3 +298,5 @@ void QPlatformInputContext::setSelectionOnFocusObject(const QPointF &anchorPos,
}
QT_END_NAMESPACE
+
+#include "moc_qplatforminputcontext.cpp"
diff --git a/src/gui/kernel/qplatforminputcontextplugin.cpp b/src/gui/kernel/qplatforminputcontextplugin.cpp
index 53d56dbb48..48be855743 100644
--- a/src/gui/kernel/qplatforminputcontextplugin.cpp
+++ b/src/gui/kernel/qplatforminputcontextplugin.cpp
@@ -51,3 +51,5 @@ QPlatformInputContextPlugin::~QPlatformInputContextPlugin()
}
QT_END_NAMESPACE
+
+#include "moc_qplatforminputcontextplugin_p.cpp"
diff --git a/src/gui/kernel/qplatformintegrationplugin.cpp b/src/gui/kernel/qplatformintegrationplugin.cpp
index b100eacbb5..fd4abcd791 100644
--- a/src/gui/kernel/qplatformintegrationplugin.cpp
+++ b/src/gui/kernel/qplatformintegrationplugin.cpp
@@ -65,3 +65,5 @@ QPlatformIntegration *QPlatformIntegrationPlugin::create(const QString &key, con
}
QT_END_NAMESPACE
+
+#include "moc_qplatformintegrationplugin.cpp"
diff --git a/src/gui/kernel/qplatformmenu.cpp b/src/gui/kernel/qplatformmenu.cpp
index 0d76f2039d..5d7b3c1bab 100644
--- a/src/gui/kernel/qplatformmenu.cpp
+++ b/src/gui/kernel/qplatformmenu.cpp
@@ -92,3 +92,5 @@ QPlatformMenu *QPlatformMenuBar::createMenu() const
}
QT_END_NAMESPACE
+
+#include "moc_qplatformmenu.cpp"
diff --git a/src/gui/kernel/qplatformnativeinterface.cpp b/src/gui/kernel/qplatformnativeinterface.cpp
index 8c9e73fbc2..560ff24dfd 100644
--- a/src/gui/kernel/qplatformnativeinterface.cpp
+++ b/src/gui/kernel/qplatformnativeinterface.cpp
@@ -175,3 +175,5 @@ void QPlatformNativeInterface::setWindowProperty(QPlatformWindow *window, const
}
QT_END_NAMESPACE
+
+#include "moc_qplatformnativeinterface.cpp"
diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp
index 7c1e2158b1..952bcd7073 100644
--- a/src/gui/kernel/qplatformscreen.cpp
+++ b/src/gui/kernel/qplatformscreen.cpp
@@ -189,6 +189,8 @@ QDpi QPlatformScreen::logicalDpi() const
QSizeF ps = physicalSize();
QSize s = geometry().size();
+ if (qFuzzyIsNull(ps.width()) || qFuzzyIsNull(ps.height()))
+ return QDpi(96, 96);
return QDpi(25.4 * s.width() / ps.width(),
25.4 * s.height() / ps.height());
}
diff --git a/src/gui/kernel/qplatformsharedgraphicscache.cpp b/src/gui/kernel/qplatformsharedgraphicscache.cpp
index f6c4e3309e..f5e86c341d 100644
--- a/src/gui/kernel/qplatformsharedgraphicscache.cpp
+++ b/src/gui/kernel/qplatformsharedgraphicscache.cpp
@@ -292,3 +292,5 @@ QT_BEGIN_NAMESPACE
*/
QT_END_NAMESPACE
+
+#include "moc_qplatformsharedgraphicscache.cpp"
diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp
index 71521c0339..a11388fdb6 100644
--- a/src/gui/kernel/qplatformtheme.cpp
+++ b/src/gui/kernel/qplatformtheme.cpp
@@ -748,7 +748,20 @@ QString QPlatformTheme::defaultStandardButtonText(int button)
QString QPlatformTheme::removeMnemonics(const QString &original)
{
- QString returnText(original.size(), 0);
+ const auto mnemonicInParentheses = [](QStringView text) {
+ /* Format of mnemonics to remove is /\(&[^&]\)/ but accept full-width
+ forms of ( and ) as equivalent, for cross-platform compatibility with
+ MS (and consequent behavior of translators, see QTBUG-110829).
+ */
+ Q_ASSERT(text.size() == 4); // Caller's responsibility.
+ const QChar wideOpen(0xff08), wideClose(0xff09), ampersand(QLatin1Char('&'));
+ if (!text.startsWith(QLatin1Char('(')) && !text.startsWith(wideOpen))
+ return false;
+ if (text[1] != ampersand || text[2] == ampersand)
+ return false;
+ return text.endsWith(QLatin1Char(')')) || text.endsWith(wideClose);
+ };
+ QString returnText(original.size(), QLatin1Char('\0'));
int finalDest = 0;
int currPos = 0;
int l = original.length();
@@ -758,11 +771,8 @@ QString QPlatformTheme::removeMnemonics(const QString &original)
--l;
if (l == 0)
break;
- } else if (original.at(currPos) == QLatin1Char('(') && l >= 4 &&
- original.at(currPos + 1) == QLatin1Char('&') &&
- original.at(currPos + 2) != QLatin1Char('&') &&
- original.at(currPos + 3) == QLatin1Char(')')) {
- /* remove mnemonics its format is "\s*(&X)" */
+ } else if (l >= 4 && mnemonicInParentheses(QStringView{original}.mid(currPos, 4))) {
+ // Also strip any leading space before the mnemonic:
int n = 0;
while (finalDest > n && returnText.at(finalDest - n - 1).isSpace())
++n;
diff --git a/src/gui/kernel/qplatformthemeplugin.cpp b/src/gui/kernel/qplatformthemeplugin.cpp
index c09476bee5..59c0731e8d 100644
--- a/src/gui/kernel/qplatformthemeplugin.cpp
+++ b/src/gui/kernel/qplatformthemeplugin.cpp
@@ -60,3 +60,5 @@ QPlatformThemePlugin::~QPlatformThemePlugin()
}
QT_END_NAMESPACE
+
+#include "moc_qplatformthemeplugin.cpp"
diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp
index fc736033c2..7207ff4d7e 100644
--- a/src/gui/kernel/qplatformwindow.cpp
+++ b/src/gui/kernel/qplatformwindow.cpp
@@ -229,7 +229,7 @@ bool QPlatformWindow::isActive() const
*/
bool QPlatformWindow::isAncestorOf(const QPlatformWindow *child) const
{
- for (const QPlatformWindow *parent = child->parent(); parent; parent = child->parent()) {
+ for (const QPlatformWindow *parent = child->parent(); parent; parent = parent->parent()) {
if (parent == this)
return true;
}
@@ -664,16 +664,16 @@ void QPlatformWindow::invalidateSurface()
{
}
-static QSize fixInitialSize(QSize size, const QWindow *w,
- int defaultWidth, int defaultHeight)
+static QSize fixInitialSize(QSize size, const QWindow *w, int deviceIndependentDefaultWidth,
+ int deviceIndependentDefaultHeight)
{
if (size.width() == 0) {
const int minWidth = w->minimumWidth();
- size.setWidth(minWidth > 0 ? minWidth : defaultWidth);
+ size.setWidth(minWidth > 0 ? minWidth : deviceIndependentDefaultWidth);
}
if (size.height() == 0) {
const int minHeight = w->minimumHeight();
- size.setHeight(minHeight > 0 ? minHeight : defaultHeight);
+ size.setHeight(minHeight > 0 ? minHeight : deviceIndependentDefaultHeight);
}
return size;
}
@@ -686,6 +686,10 @@ static QSize fixInitialSize(QSize size, const QWindow *w,
layout new windows to optimize usage of the available desktop space.
However if the given window already has geometry which the application has
initialized, it takes priority.
+
+ \a initialGeometry has to be provided in native pixels.
+ \a defaultWidth has to be provided in device independent pixels
+ \a defaultHeight has to be provided in device independent pixels
*/
QRect QPlatformWindow::initialGeometry(const QWindow *w, const QRect &initialGeometry,
int defaultWidth, int defaultHeight,
@@ -695,9 +699,10 @@ QRect QPlatformWindow::initialGeometry(const QWindow *w, const QRect &initialGeo
*resultingScreenReturn = w->screen();
if (!w->isTopLevel()) {
const qreal factor = QHighDpiScaling::factor(w);
- const QSize size = fixInitialSize(QHighDpi::fromNative(initialGeometry.size(), factor),
- w, defaultWidth, defaultHeight);
- return QRect(initialGeometry.topLeft(), QHighDpi::toNative(size, factor));
+ const QSize deviceIndependentSize =
+ fixInitialSize(QHighDpi::fromNative(initialGeometry.size(), factor), w,
+ defaultWidth, defaultHeight);
+ return QRect(initialGeometry.topLeft(), QHighDpi::toNative(deviceIndependentSize, factor));
}
const auto *wp = qt_window_private(const_cast<QWindow*>(w));
const bool position = wp->positionAutomatic && w->type() != Qt::Popup;
@@ -711,26 +716,28 @@ QRect QPlatformWindow::initialGeometry(const QWindow *w, const QRect &initialGeo
if (resultingScreenReturn)
*resultingScreenReturn = screen;
// initialGeometry refers to window's screen
- QRect rect(QHighDpi::fromNativePixels(initialGeometry, w));
+ QRect deviceIndependentRect(QHighDpi::fromNativePixels(initialGeometry, w));
if (wp->resizeAutomatic)
- rect.setSize(fixInitialSize(rect.size(), w, defaultWidth, defaultHeight));
+ deviceIndependentRect.setSize(
+ fixInitialSize(deviceIndependentRect.size(), w, defaultWidth, defaultHeight));
if (position) {
- const QRect availableGeometry = screen->availableGeometry();
+ const QRect availableDeviceIndependentGeometry = 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) {
+ if (deviceIndependentRect.height() < (availableDeviceIndependentGeometry.height() * 8) / 9
+ && deviceIndependentRect.width()
+ < (availableDeviceIndependentGeometry.width() * 8) / 9) {
const QWindow *tp = w->transientParent();
if (tp) {
// A transient window should be centered w.r.t. its transient parent.
- rect.moveCenter(tp->geometry().center());
+ deviceIndependentRect.moveCenter(tp->geometry().center());
} else {
// Center the window on the screen. (Only applicable on platforms
// which do not provide a better way.)
- rect.moveCenter(availableGeometry.center());
+ deviceIndependentRect.moveCenter(availableDeviceIndependentGeometry.center());
}
}
}
- return QHighDpi::toNativePixels(rect, screen);
+ return QHighDpi::toNativePixels(deviceIndependentRect, screen);
}
/*!
diff --git a/src/gui/kernel/qrasterwindow.cpp b/src/gui/kernel/qrasterwindow.cpp
index 70d87347c3..c45f9a4e11 100644
--- a/src/gui/kernel/qrasterwindow.cpp
+++ b/src/gui/kernel/qrasterwindow.cpp
@@ -139,3 +139,5 @@ QPaintDevice *QRasterWindow::redirected(QPoint *) const
}
QT_END_NAMESPACE
+
+#include "moc_qrasterwindow.cpp"
diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp
index df628fcc73..990272b0c2 100644
--- a/src/gui/kernel/qscreen.cpp
+++ b/src/gui/kernel/qscreen.cpp
@@ -88,6 +88,9 @@ void QScreenPrivate::updateGeometriesWithSignals()
void QScreenPrivate::emitGeometryChangeSignals(bool geometryChanged, bool availableGeometryChanged)
{
Q_Q(QScreen);
+ if (geometryChanged)
+ emit q->geometryChanged(geometry);
+
if (availableGeometryChanged)
emit q->availableGeometryChanged(availableGeometry);
@@ -96,6 +99,9 @@ void QScreenPrivate::emitGeometryChangeSignals(bool geometryChanged, bool availa
for (QScreen* sibling : siblings)
emit sibling->virtualGeometryChanged(sibling->virtualGeometry());
}
+
+ if (geometryChanged)
+ emit q->physicalDotsPerInchChanged(q->physicalDotsPerInch());
}
void QScreenPrivate::setPlatformScreen(QPlatformScreen *screen)
@@ -112,13 +118,13 @@ void QScreenPrivate::setPlatformScreen(QPlatformScreen *screen)
if (refreshRate < 1.0)
refreshRate = 60.0;
- updatePrimaryOrientation();
+ updateHighDpi();
+
+ updatePrimaryOrientation(); // derived from the geometry
filteredOrientation = orientation;
if (filteredOrientation == Qt::PrimaryOrientation)
filteredOrientation = primaryOrientation;
-
- updateHighDpi();
}
@@ -843,3 +849,5 @@ Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QScreen *screen)
#endif // !QT_NO_DEBUG_STREAM
QT_END_NAMESPACE
+
+#include "moc_qscreen.cpp"
diff --git a/src/gui/kernel/qsessionmanager.cpp b/src/gui/kernel/qsessionmanager.cpp
index 8747e02719..e1066de451 100644
--- a/src/gui/kernel/qsessionmanager.cpp
+++ b/src/gui/kernel/qsessionmanager.cpp
@@ -423,4 +423,6 @@ void QSessionManager::requestPhase2()
QT_END_NAMESPACE
+#include "moc_qsessionmanager.cpp"
+
#endif // QT_NO_SESSIONMANAGER
diff --git a/src/gui/kernel/qshapedpixmapdndwindow.cpp b/src/gui/kernel/qshapedpixmapdndwindow.cpp
index 1a85a5e853..bb0d8e4ee7 100644
--- a/src/gui/kernel/qshapedpixmapdndwindow.cpp
+++ b/src/gui/kernel/qshapedpixmapdndwindow.cpp
@@ -112,3 +112,5 @@ void QShapedPixmapWindow::updateGeometry(const QPoint &pos)
}
QT_END_NAMESPACE
+
+#include "moc_qshapedpixmapdndwindow_p.cpp"
diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp
index 7b3c70c51b..288bdf1b3c 100644
--- a/src/gui/kernel/qstylehints.cpp
+++ b/src/gui/kernel/qstylehints.cpp
@@ -621,3 +621,5 @@ int QStyleHints::mouseQuickSelectionThreshold() const
}
QT_END_NAMESPACE
+
+#include "moc_qstylehints.cpp"
diff --git a/src/gui/kernel/qsurface.cpp b/src/gui/kernel/qsurface.cpp
index 85c576b21c..e76b618c65 100644
--- a/src/gui/kernel/qsurface.cpp
+++ b/src/gui/kernel/qsurface.cpp
@@ -160,3 +160,5 @@ QSurface::SurfaceClass QSurface::surfaceClass() const
QT_END_NAMESPACE
+#include "moc_qsurface.cpp"
+
diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp
index 6c04abc293..461f6776ce 100644
--- a/src/gui/kernel/qsurfaceformat.cpp
+++ b/src/gui/kernel/qsurfaceformat.cpp
@@ -908,3 +908,5 @@ QDebug operator<<(QDebug dbg, const QSurfaceFormat &f)
#endif
QT_END_NAMESPACE
+
+#include "moc_qsurfaceformat.cpp"
diff --git a/src/gui/kernel/qtestsupport_gui.cpp b/src/gui/kernel/qtestsupport_gui.cpp
index 79da26f2ca..5e9029dc89 100644
--- a/src/gui/kernel/qtestsupport_gui.cpp
+++ b/src/gui/kernel/qtestsupport_gui.cpp
@@ -52,9 +52,16 @@ QT_BEGIN_NAMESPACE
/*!
\since 5.0
- Waits for \a timeout milliseconds or until the \a window is active.
+ Returns \c true, if \a window is active within \a timeout milliseconds. Otherwise returns \c false.
- Returns \c true if \c window is active within \a timeout milliseconds, otherwise returns \c false.
+ The method is useful in tests that call QWindow::show() and rely on the window actually being
+ active (i.e. being visible and having focus) before proceeding.
+
+ \note The method will time out and return \c false if another window prevents \a window from
+ becoming active.
+
+ \note Since focus is an exclusive property, \a window may loose its focus to another window at
+ any time - even after the method has returned \c true.
\sa qWaitForWindowExposed(), QWindow::isActive()
*/
@@ -74,15 +81,14 @@ Q_GUI_EXPORT bool QTest::qWaitForWindowActive(QWindow *window, int timeout)
/*!
\since 5.0
- Waits for \a timeout milliseconds or until the \a window is exposed.
- Returns \c true if \c window is exposed within \a timeout milliseconds, otherwise returns \c false.
+ Returns \c true, if \a window is exposed within \a timeout milliseconds. Otherwise returns \c false.
- This is mainly useful for asynchronous systems like X11, where a window will be mapped to screen some
- time after being asked to show itself on the screen.
+ The method is useful in tests that call QWindow::show() and rely on the window actually being
+ being visible before proceeding.
- Note that a window that is mapped to screen may still not be considered exposed if the window client
- area is completely covered by other windows, or if the window is otherwise not visible. This function
- will then time out when waiting for such a window.
+ \note A window mapped to screen may still not be considered exposed, if the window client area is
+ not visible, e.g. because it is completely covered by other windows.
+ In such cases, the method will time out and return \c false.
\sa qWaitForWindowActive(), QWindow::isExposed()
*/
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index fd89e479b8..639817257e 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -458,7 +458,7 @@ void QWindowPrivate::updateSiblingPosition(SiblingPosition position)
siblings.move(currentPosition, targetPosition);
}
-inline bool QWindowPrivate::windowRecreationRequired(QScreen *newScreen) const
+bool QWindowPrivate::windowRecreationRequired(QScreen *newScreen) const
{
Q_Q(const QWindow);
const QScreen *oldScreen = q->screen();
@@ -466,7 +466,7 @@ inline bool QWindowPrivate::windowRecreationRequired(QScreen *newScreen) const
&& !(oldScreen && oldScreen->virtualSiblings().contains(newScreen));
}
-inline void QWindowPrivate::disconnectFromScreen()
+void QWindowPrivate::disconnectFromScreen()
{
if (topLevelScreen)
topLevelScreen = nullptr;
@@ -614,6 +614,13 @@ QWindow::SurfaceType QWindow::surfaceType() const
By default, the window is not visible, you must call setVisible(true), or
show() or similar to make it visible.
+ \note Hiding a window does not remove the window from the windowing system,
+ it only hides it. On windowing systems that give full screen applications a
+ dedicated desktop (such as macOS), hiding a full screen window will not remove
+ that desktop, but leave it blank. Another window from the same application
+ might be shown full screen, and will fill that desktop. Use QWindow::close to
+ completely remove a window from the windowing system.
+
\sa show()
*/
void QWindow::setVisible(bool visible)
@@ -1224,11 +1231,13 @@ bool QWindow::isExposed() const
*/
/*!
- Returns \c true if the window should appear active from a style perspective.
+ Returns \c true if the window is active.
This is the case for the window that has input focus as well as windows
that are in the same parent / transient parent chain as the focus window.
+ Typically active windows should appear active from a style perspective.
+
To get the window that currently has focus, use QGuiApplication::focusWindow().
*/
bool QWindow::isActive() const
@@ -1926,7 +1935,12 @@ void QWindow::resize(const QSize &newSize)
Q_D(QWindow);
d->positionPolicy = QWindowPrivate::WindowFrameExclusive;
if (d->platformWindow) {
- d->platformWindow->setGeometry(QHighDpi::toNativePixels(QRect(position(), newSize), this));
+ if (isTopLevel()) {
+ d->platformWindow->setGeometry(QHighDpi::toNativePixels(QRect(position(), newSize), this));
+ } else {
+ d->platformWindow->setGeometry(QRect(QHighDpi::toNativeLocalPosition(position(), this),
+ QHighDpi::toNativePixels(newSize, this)));
+ }
} else {
const QSize oldSize = d->geometry.size();
d->geometry.setSize(newSize);
@@ -2201,6 +2215,9 @@ void QWindow::showMaximized()
Equivalent to calling setWindowStates(Qt::WindowFullScreen) and then
setVisible(true).
+ See the \l{QWidget::showFullScreen()} documentation for platform-specific
+ considerations and limitations.
+
\sa setWindowStates(), setVisible()
*/
void QWindow::showFullScreen()
@@ -2705,8 +2722,7 @@ void QWindowPrivate::maybeQuitOnLastWindowClosed()
Q_Q(QWindow);
if (!q->isTopLevel())
return;
- // Attempt to close the application only if this has WA_QuitOnClose set and a non-visible parent
- bool quitOnClose = QGuiApplication::quitOnLastWindowClosed() && !q->parent();
+
QWindowList list = QGuiApplication::topLevelWindows();
bool lastWindowClosed = true;
for (int i = 0; i < list.size(); ++i) {
@@ -2718,7 +2734,8 @@ void QWindowPrivate::maybeQuitOnLastWindowClosed()
}
if (lastWindowClosed) {
QGuiApplicationPrivate::emitLastWindowClosed();
- if (quitOnClose) {
+
+ if (QGuiApplication::quitOnLastWindowClosed()) {
QCoreApplicationPrivate *applicationPrivate = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(QCoreApplication::instance()));
applicationPrivate->maybeQuit();
}