summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qevent.cpp1
-rw-r--r--src/gui/kernel/qguiapplication.cpp10
-rw-r--r--src/gui/kernel/qguiapplication_p.h2
-rw-r--r--src/gui/kernel/qhighdpiscaling.cpp29
-rw-r--r--src/gui/kernel/qplatformcursor.cpp2
-rw-r--r--src/gui/kernel/qplatformdialoghelper.cpp22
-rw-r--r--src/gui/kernel/qplatformintegration.h3
-rw-r--r--src/gui/kernel/qplatformscreen.cpp25
-rw-r--r--src/gui/kernel/qplatformscreen.h23
-rw-r--r--src/gui/kernel/qplatformtheme.h2
-rw-r--r--src/gui/kernel/qplatformwindow.cpp9
-rw-r--r--src/gui/kernel/qplatformwindow.h6
-rw-r--r--src/gui/kernel/qsimpledrag.cpp2
-rw-r--r--src/gui/kernel/qsurfaceformat.cpp2
14 files changed, 88 insertions, 50 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 23defef50c..6ff6faf809 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -846,6 +846,7 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
/*!
Constructs a wheel event object.
+ \since 5.12
The \a pos provides the location of the mouse cursor
within the window. The position in global coordinates is specified
by \a globalPos.
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index f4a5c0e104..5869d024f0 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -1700,13 +1700,7 @@ QGuiApplicationPrivate::~QGuiApplicationPrivate()
qt_gl_set_global_share_context(0);
}
#endif
-#ifdef Q_OS_WASM
- EM_ASM(
- // unmount persistent directory as IDBFS
- // see QTBUG-70002
- FS.unmount('/home/web_user');
- );
-#endif
+
platform_integration->destroy();
delete platform_theme;
@@ -1773,7 +1767,7 @@ Qt::KeyboardModifiers QGuiApplication::keyboardModifiers()
*/
Qt::KeyboardModifiers QGuiApplication::queryKeyboardModifiers()
{
- CHECK_QAPP_INSTANCE(Qt::KeyboardModifiers(0))
+ CHECK_QAPP_INSTANCE(Qt::KeyboardModifiers{})
QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration();
return pi->queryKeyboardModifiers();
}
diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h
index 56a3be1122..9f3fa7212a 100644
--- a/src/gui/kernel/qguiapplication_p.h
+++ b/src/gui/kernel/qguiapplication_p.h
@@ -119,7 +119,7 @@ public:
static QAbstractEventDispatcher *qt_qpa_core_dispatcher()
{
if (QCoreApplication::instance())
- return QCoreApplication::instance()->d_func()->threadData->eventDispatcher.loadRelaxed();
+ return QCoreApplication::instance()->d_func()->threadData.loadRelaxed()->eventDispatcher.loadRelaxed();
else
return nullptr;
}
diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp
index 76548d5d86..fde6bb0180 100644
--- a/src/gui/kernel/qhighdpiscaling.cpp
+++ b/src/gui/kernel/qhighdpiscaling.cpp
@@ -56,6 +56,9 @@ Q_LOGGING_CATEGORY(lcScaling, "qt.scaling");
#ifndef QT_NO_HIGHDPISCALING
static const char legacyDevicePixelEnvVar[] = "QT_DEVICE_PIXEL_RATIO";
+
+// Note: QT_AUTO_SCREEN_SCALE_FACTOR is Done on X11, and should be kept
+// working as-is. It's Deprecated on all other platforms.
static const char legacyAutoScreenEnvVar[] = "QT_AUTO_SCREEN_SCALE_FACTOR";
static const char enableHighDpiScalingEnvVar[] = "QT_ENABLE_HIGHDPI_SCALING";
@@ -104,12 +107,6 @@ static inline qreal initialGlobalScaleFactor()
if (dpr > 0)
result = dpr;
}
-
- if (qEnvironmentVariableIsSet(legacyAutoScreenEnvVar)) {
- qWarning("Warning: %s is deprecated. Instead use:\n"
- " %s to enable platform plugin controlled per-screen factors.",
- legacyAutoScreenEnvVar, enableHighDpiScalingEnvVar);
- }
}
return result;
}
@@ -644,7 +641,7 @@ QPoint QHighDpiScaling::mapPositionFromGlobal(const QPoint &pos, const QPoint &w
qreal QHighDpiScaling::screenSubfactor(const QPlatformScreen *screen)
{
- qreal factor = qreal(1.0);
+ auto factor = qreal(1.0);
if (!screen)
return factor;
@@ -657,14 +654,16 @@ qreal QHighDpiScaling::screenSubfactor(const QPlatformScreen *screen)
// Check if there is a factor set on the screen object or associated
// with the screen name. These are mutually exclusive, so checking
// order is not significant.
- QVariant byIndex = screen->screen()->property(scaleFactorProperty);
- auto byNameIt = qNamedScreenScaleFactors()->constFind(screen->name());
- if (byIndex.isValid()) {
- screenPropertyUsed = true;
- factor = byIndex.toReal();
- } else if (byNameIt != qNamedScreenScaleFactors()->cend()) {
- screenPropertyUsed = true;
- factor = *byNameIt;
+ if (auto qScreen = screen->screen()) {
+ auto screenFactor = qScreen->property(scaleFactorProperty).toReal(&screenPropertyUsed);
+ if (screenPropertyUsed)
+ factor = screenFactor;
+ }
+
+ if (!screenPropertyUsed) {
+ auto byNameIt = qNamedScreenScaleFactors()->constFind(screen->name());
+ if ((screenPropertyUsed = byNameIt != qNamedScreenScaleFactors()->cend()))
+ factor = *byNameIt;
}
}
diff --git a/src/gui/kernel/qplatformcursor.cpp b/src/gui/kernel/qplatformcursor.cpp
index 49eff2ad23..34c4549443 100644
--- a/src/gui/kernel/qplatformcursor.cpp
+++ b/src/gui/kernel/qplatformcursor.cpp
@@ -103,7 +103,7 @@ QT_BEGIN_NAMESPACE
QPlatformCursor::clearOverrideCursor().
*/
-QPlatformCursor::Capabilities QPlatformCursor::m_capabilities = 0;
+QPlatformCursor::Capabilities QPlatformCursor::m_capabilities = { };
/*!
\fn QPlatformCursor::QPlatformCursor()
diff --git a/src/gui/kernel/qplatformdialoghelper.cpp b/src/gui/kernel/qplatformdialoghelper.cpp
index 4bee153489..15ac4acf91 100644
--- a/src/gui/kernel/qplatformdialoghelper.cpp
+++ b/src/gui/kernel/qplatformdialoghelper.cpp
@@ -186,7 +186,7 @@ QVariant QPlatformDialogHelper::defaultStyleHint(QPlatformDialogHelper::StyleHi
class QFontDialogOptionsPrivate : public QSharedData
{
public:
- QFontDialogOptionsPrivate() : options(0) {}
+ QFontDialogOptionsPrivate() = default;
QFontDialogOptions::FontDialogOptions options;
QString windowTitle;
@@ -328,7 +328,7 @@ Q_GLOBAL_STATIC(QColorDialogStaticData, qColorDialogStaticData)
class QColorDialogOptionsPrivate : public QSharedData
{
public:
- QColorDialogOptionsPrivate() : options(0) {}
+ QColorDialogOptionsPrivate() = default;
// Write out settings around destruction of dialogs
~QColorDialogOptionsPrivate() { qColorDialogStaticData()->writeSettings(); }
@@ -465,24 +465,16 @@ void QPlatformColorDialogHelper::setOptions(const QSharedPointer<QColorDialogOpt
class QFileDialogOptionsPrivate : public QSharedData
{
public:
- QFileDialogOptionsPrivate() : options(0),
- viewMode(QFileDialogOptions::Detail),
- fileMode(QFileDialogOptions::AnyFile),
- acceptMode(QFileDialogOptions::AcceptOpen),
- filters(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::AllDirs),
- useDefaultNameFilters(true)
- {}
-
QFileDialogOptions::FileDialogOptions options;
QString windowTitle;
- QFileDialogOptions::ViewMode viewMode;
- QFileDialogOptions::FileMode fileMode;
- QFileDialogOptions::AcceptMode acceptMode;
+ QFileDialogOptions::ViewMode viewMode = QFileDialogOptions::Detail;
+ QFileDialogOptions::FileMode fileMode = QFileDialogOptions::AnyFile;
+ QFileDialogOptions::AcceptMode acceptMode = QFileDialogOptions::AcceptOpen;
QString labels[QFileDialogOptions::DialogLabelCount];
- QDir::Filters filters;
+ QDir::Filters filters = QDir::AllEntries | QDir::NoDotAndDotDot | QDir::AllDirs;
QList<QUrl> sidebarUrls;
- bool useDefaultNameFilters;
+ bool useDefaultNameFilters = true;
QStringList nameFilters;
QStringList mimeTypeFilters;
QString defaultSuffix;
diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h
index d9f349555a..01406958e2 100644
--- a/src/gui/kernel/qplatformintegration.h
+++ b/src/gui/kernel/qplatformintegration.h
@@ -106,7 +106,8 @@ public:
ApplicationIcon,
SwitchableWidgetComposition,
TopStackedNativeChildWindows,
- OpenGLOnRasterSurface
+ OpenGLOnRasterSurface,
+ MaximizeUsingFullscreenGeometry
};
virtual ~QPlatformIntegration() { }
diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp
index f3213bf5ea..e511a6f5c4 100644
--- a/src/gui/kernel/qplatformscreen.cpp
+++ b/src/gui/kernel/qplatformscreen.cpp
@@ -410,15 +410,22 @@ void QPlatformScreen::resizeMaximizedWindows()
const QRect newGeometry = deviceIndependentGeometry();
const QRect newAvailableGeometry = QHighDpi::fromNative(availableGeometry(), QHighDpiScaling::factor(this), newGeometry.topLeft());
+ const bool supportsMaximizeUsingFullscreen = QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::MaximizeUsingFullscreenGeometry);
+
for (QWindow *w : windows()) {
// Skip non-platform windows, e.g., offscreen windows.
if (!w->handle())
continue;
- if (w->windowState() & Qt::WindowMaximized || w->geometry() == oldAvailableGeometry)
+ if (supportsMaximizeUsingFullscreen
+ && w->windowState() & Qt::WindowMaximized
+ && w->flags() & Qt::MaximizeUsingFullscreenGeometryHint) {
+ w->setGeometry(newGeometry);
+ } else if (w->windowState() & Qt::WindowMaximized || w->geometry() == oldAvailableGeometry) {
w->setGeometry(newAvailableGeometry);
- else if (w->windowState() & Qt::WindowFullScreen || w->geometry() == oldGeometry)
+ } else if (w->windowState() & Qt::WindowFullScreen || w->geometry() == oldGeometry) {
w->setGeometry(newGeometry);
+ }
}
}
@@ -609,4 +616,18 @@ int QPlatformScreen::preferredMode() const
return 0;
}
+QList<QPlatformScreen *> QPlatformPlaceholderScreen::virtualSiblings() const
+{
+ QList<QPlatformScreen *> siblings;
+
+ if (!m_virtualSibling)
+ return siblings;
+
+ for (QScreen *screen : QGuiApplication::screens()) {
+ if (screen->handle() && screen->handle() != this)
+ siblings << screen->handle();
+ }
+ return siblings;
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformscreen.h b/src/gui/kernel/qplatformscreen.h
index d7378aed51..0be7646032 100644
--- a/src/gui/kernel/qplatformscreen.h
+++ b/src/gui/kernel/qplatformscreen.h
@@ -105,6 +105,8 @@ public:
QPlatformScreen();
virtual ~QPlatformScreen();
+ virtual bool isPlaceholder() const { return false; }
+
virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const;
virtual QRect geometry() const = 0;
@@ -172,6 +174,27 @@ private:
friend class QScreenPrivate;
};
+// Qt doesn't currently support running with no platform screen
+// QPA plugins can use this class to create a fake screen
+class Q_GUI_EXPORT QPlatformPlaceholderScreen : public QPlatformScreen {
+public:
+ // virtualSibling can be passed in to make the placeholder a sibling with other screens during
+ // the transitioning phase when the real screen is about to be removed, or the first real screen
+ // is about to be added. This is useful because Qt will currently recreate (but now show!)
+ // windows when they are moved from one virtual desktop to another, so if the last monitor is
+ // unplugged, then plugged in again, windows will be hidden unless the placeholder belongs to
+ // the same virtual desktop as the other screens.
+ QPlatformPlaceholderScreen(bool virtualSibling = true) : m_virtualSibling(virtualSibling) {}
+ bool isPlaceholder() const override { return true; }
+ QRect geometry() const override { return QRect(); }
+ QRect availableGeometry() const override { return QRect(); }
+ int depth() const override { return 32; }
+ QImage::Format format() const override { return QImage::Format::Format_RGB32; }
+ QList<QPlatformScreen *> virtualSiblings() const override;
+private:
+ bool m_virtualSibling = true;
+};
+
QT_END_NAMESPACE
#endif // QPLATFORMSCREEN_H
diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h
index 7b88af954c..6ed612b785 100644
--- a/src/gui/kernel/qplatformtheme.h
+++ b/src/gui/kernel/qplatformtheme.h
@@ -311,7 +311,7 @@ public:
virtual QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const;
virtual QIcon fileIcon(const QFileInfo &fileInfo,
- QPlatformTheme::IconOptions iconOptions = nullptr) const;
+ QPlatformTheme::IconOptions iconOptions = { }) const;
virtual QIconEngine *createIconEngine(const QString &iconName) const;
#if QT_CONFIG(shortcut)
diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp
index 2a0cb1094c..65accc9f68 100644
--- a/src/gui/kernel/qplatformwindow.cpp
+++ b/src/gui/kernel/qplatformwindow.cpp
@@ -694,9 +694,12 @@ static QSize fixInitialSize(QSize size, const QWindow *w,
However if the given window already has geometry which the application has
initialized, it takes priority.
*/
-QRect QPlatformWindow::initialGeometry(const QWindow *w,
- const QRect &initialGeometry, int defaultWidth, int defaultHeight)
+QRect QPlatformWindow::initialGeometry(const QWindow *w, const QRect &initialGeometry,
+ int defaultWidth, int defaultHeight,
+ const QScreen **resultingScreenReturn)
{
+ if (resultingScreenReturn)
+ *resultingScreenReturn = w->screen();
if (!w->isTopLevel()) {
const qreal factor = QHighDpiScaling::factor(w);
const QSize size = fixInitialSize(QHighDpi::fromNative(initialGeometry.size(), factor),
@@ -712,6 +715,8 @@ QRect QPlatformWindow::initialGeometry(const QWindow *w,
: QGuiApplication::screenAt(initialGeometry.center());
if (!screen)
return initialGeometry;
+ if (resultingScreenReturn)
+ *resultingScreenReturn = screen;
// initialGeometry refers to window's screen
QRect rect(QHighDpi::fromNativePixels(initialGeometry, w));
if (wp->resizeAutomatic)
diff --git a/src/gui/kernel/qplatformwindow.h b/src/gui/kernel/qplatformwindow.h
index 4d48cc2f13..b6aeb3a86a 100644
--- a/src/gui/kernel/qplatformwindow.h
+++ b/src/gui/kernel/qplatformwindow.h
@@ -63,6 +63,7 @@ QT_BEGIN_NAMESPACE
class QPlatformScreen;
class QPlatformWindowPrivate;
+class QScreen;
class QWindow;
class QIcon;
class QRegion;
@@ -142,8 +143,9 @@ public:
virtual void invalidateSurface();
- static QRect initialGeometry(const QWindow *w,
- const QRect &initialGeometry, int defaultWidth, int defaultHeight);
+ static QRect initialGeometry(const QWindow *w, const QRect &initialGeometry,
+ int defaultWidth, int defaultHeight,
+ const QScreen **resultingScreenReturn = nullptr);
virtual void requestUpdate();
bool hasPendingUpdateRequest() const;
diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp
index d3070a3d1a..803206477c 100644
--- a/src/gui/kernel/qsimpledrag.cpp
+++ b/src/gui/kernel/qsimpledrag.cpp
@@ -393,7 +393,7 @@ void QSimpleDrag::startDrag()
static void sendDragLeave(QWindow *window)
{
- QWindowSystemInterface::handleDrag(window, nullptr, QPoint(), Qt::IgnoreAction, 0, 0);
+ QWindowSystemInterface::handleDrag(window, nullptr, QPoint(), Qt::IgnoreAction, { }, { });
}
void QSimpleDrag::cancel()
diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp
index 238886220b..571b820409 100644
--- a/src/gui/kernel/qsurfaceformat.cpp
+++ b/src/gui/kernel/qsurfaceformat.cpp
@@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE
class QSurfaceFormatPrivate
{
public:
- explicit QSurfaceFormatPrivate(QSurfaceFormat::FormatOptions _opts = 0)
+ explicit QSurfaceFormatPrivate(QSurfaceFormat::FormatOptions _opts = { })
: ref(1)
, opts(_opts)
, redBufferSize(-1)