diff options
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 13 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication_p.h | 1 | ||||
-rw-r--r-- | src/gui/kernel/qkeysequence.cpp | 32 | ||||
-rw-r--r-- | src/gui/kernel/qpalette.cpp | 4 | ||||
-rw-r--r-- | src/gui/kernel/qplatformwindow.cpp | 3 | ||||
-rw-r--r-- | src/gui/kernel/qwindow.cpp | 43 | ||||
-rw-r--r-- | src/gui/kernel/qwindow.h | 1 | ||||
-rw-r--r-- | src/gui/kernel/qwindow_p.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface.cpp | 7 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface.h | 1 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface_p.h | 13 |
11 files changed, 83 insertions, 37 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 3c79e62e75..2a1d7e3bcc 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1285,6 +1285,9 @@ void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePriv case QWindowSystemInterfacePrivate::WindowStateChanged: QGuiApplicationPrivate::processWindowStateChangedEvent(static_cast<QWindowSystemInterfacePrivate::WindowStateChangedEvent *>(e)); break; + case QWindowSystemInterfacePrivate::WindowScreenChanged: + QGuiApplicationPrivate::processWindowScreenChangedEvent(static_cast<QWindowSystemInterfacePrivate::WindowScreenChangedEvent *>(e)); + break; case QWindowSystemInterfacePrivate::ApplicationStateChanged: QGuiApplicationPrivate::processApplicationStateChangedEvent(static_cast<QWindowSystemInterfacePrivate::ApplicationStateChangedEvent *>(e)); break; @@ -1655,6 +1658,16 @@ void QGuiApplicationPrivate::processWindowStateChangedEvent(QWindowSystemInterfa } } +void QGuiApplicationPrivate::processWindowScreenChangedEvent(QWindowSystemInterfacePrivate::WindowScreenChangedEvent *wse) +{ + if (QWindow *window = wse->window.data()) { + if (QScreen *screen = wse->screen.data()) + window->d_func()->setScreen(screen, false /* recreate */); + else // Fall back to default behavior, and try to find some appropriate screen + window->setScreen(0); + } +} + void QGuiApplicationPrivate::processApplicationStateChangedEvent(QWindowSystemInterfacePrivate::ApplicationStateChangedEvent *e) { if (e->newState == applicationState) diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 376890ef47..cd8dfff103 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -126,6 +126,7 @@ public: static void processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e); static void processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *e); + static void processWindowScreenChangedEvent(QWindowSystemInterfacePrivate::WindowScreenChangedEvent *e); static void processApplicationStateChangedEvent(QWindowSystemInterfacePrivate::ApplicationStateChangedEvent *e); diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index a0255f610a..af3a46c675 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -55,14 +55,14 @@ #endif #include "qvariant.h" -#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) +#if defined(Q_OS_MACX) #include <QtCore/private/qcore_mac_p.h> #include <Carbon/Carbon.h> #endif QT_BEGIN_NAMESPACE -#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) +#if defined(Q_OS_MACX) static bool qt_sequence_no_mnemonics = true; struct MacSpecialKey { int key; @@ -975,7 +975,7 @@ QKeySequence::QKeySequence(const QKeySequence& keysequence) d->ref.ref(); } -#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) +#if defined(Q_OS_MACX) static inline int maybeSwapShortcut(int shortcut) { if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) { @@ -1007,7 +1007,7 @@ QList<QKeySequence> QKeySequence::keyBindings(StandardKey key) QKeyBinding keyBinding = QKeySequencePrivate::keyBindings[i]; if (keyBinding.standardKey == key && (keyBinding.platform & platform)) { uint shortcut = -#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) +#if defined(Q_OS_MACX) maybeSwapShortcut(QKeySequencePrivate::keyBindings[i].shortcut); #else QKeySequencePrivate::keyBindings[i].shortcut; @@ -1209,7 +1209,7 @@ int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::Sequence if (nativeText) { gmodifs = globalModifs(); if (gmodifs->isEmpty()) { -#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) +#if defined(Q_OS_MACX) const bool dontSwap = qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta); if (dontSwap) *gmodifs << QModifKeyName(Qt::META, QChar(kCommandUnicode)); @@ -1226,7 +1226,7 @@ int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::Sequence << QModifKeyName(Qt::SHIFT, QLatin1String("shift+")) << QModifKeyName(Qt::ALT, QLatin1String("alt+")) << QModifKeyName(Qt::META, QLatin1String("meta+")) - << QModifKeyName(Qt::KeypadModifier, QLatin1String("numpad+")); + << QModifKeyName(Qt::KeypadModifier, QLatin1String("num+")); } } else { gmodifs = globalPortableModifs(); @@ -1235,7 +1235,7 @@ int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::Sequence << QModifKeyName(Qt::SHIFT, QLatin1String("shift+")) << QModifKeyName(Qt::ALT, QLatin1String("alt+")) << QModifKeyName(Qt::META, QLatin1String("meta+")) - << QModifKeyName(Qt::KeypadModifier, QLatin1String("numpad+")); + << QModifKeyName(Qt::KeypadModifier, QLatin1String("num+")); } } if (!gmodifs) return ret; @@ -1247,12 +1247,12 @@ int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::Sequence << QModifKeyName(Qt::SHIFT, QCoreApplication::translate("QShortcut", "Shift").toLower().append(QLatin1Char('+'))) << QModifKeyName(Qt::ALT, QCoreApplication::translate("QShortcut", "Alt").toLower().append(QLatin1Char('+'))) << QModifKeyName(Qt::META, QCoreApplication::translate("QShortcut", "Meta").toLower().append(QLatin1Char('+'))) - << QModifKeyName(Qt::KeypadModifier, QCoreApplication::translate("QShortcut", "Numpad").toLower().append(QLatin1Char('+'))); + << QModifKeyName(Qt::KeypadModifier, QCoreApplication::translate("QShortcut", "Num").toLower().append(QLatin1Char('+'))); } modifs += *gmodifs; // Test non-translated ones last QString sl = accel; -#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) +#if defined(Q_OS_MACX) for (int i = 0; i < modifs.size(); ++i) { const QModifKeyName &mkf = modifs.at(i); if (sl.contains(mkf.name)) { @@ -1304,7 +1304,7 @@ int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::Sequence int fnum = 0; if (accel.length() == 1) { -#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) +#if defined(Q_OS_MACX) int qtKey = qtkeyForMacSymbol(accel[0]); if (qtKey != -1) { ret |= qtKey; @@ -1383,7 +1383,7 @@ QString QKeySequencePrivate::encodeString(int key, QKeySequence::SequenceFormat if (key == -1 || key == Qt::Key_unknown) return s; -#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) +#if defined(Q_OS_MACX) if (nativeText) { // On Mac OS X the order (by default) is Meta, Alt, Shift, Control. // If the AA_MacDontSwapCtrlAndMeta is enabled, then the order @@ -1421,9 +1421,9 @@ QString QKeySequencePrivate::encodeString(int key, QKeySequence::SequenceFormat addKey(s, nativeText ? QCoreApplication::translate("QShortcut", "Alt") : QString::fromLatin1("Alt"), format); if ((key & Qt::SHIFT) == Qt::SHIFT) addKey(s, nativeText ? QCoreApplication::translate("QShortcut", "Shift") : QString::fromLatin1("Shift"), format); - if ((key & Qt::KeypadModifier) == Qt::KeypadModifier) - addKey(s, nativeText ? QCoreApplication::translate("QShortcut", "Numpad") : QString::fromLatin1("Numpad"), format); } + if ((key & Qt::KeypadModifier) == Qt::KeypadModifier) + addKey(s, nativeText ? QCoreApplication::translate("QShortcut", "Num") : QString::fromLatin1("Num"), format); key &= ~(Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier | Qt::KeypadModifier); @@ -1441,7 +1441,7 @@ QString QKeySequencePrivate::encodeString(int key, QKeySequence::SequenceFormat : QString::fromLatin1("F%1").arg(key - Qt::Key_F1 + 1); } else if (key) { int i=0; -#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) +#if defined(Q_OS_MACX) if (nativeText) { QChar ch = qt_macSymbolForQtKey(key); if (!ch.isNull()) @@ -1451,7 +1451,7 @@ QString QKeySequencePrivate::encodeString(int key, QKeySequence::SequenceFormat } else #endif { -#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) +#if defined(Q_OS_MACX) NonSymbol: #endif while (keyname[i].name) { @@ -1477,7 +1477,7 @@ NonSymbol: } } -#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) +#if defined(Q_OS_MACX) if (nativeText) s += p; else diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp index df3d4dfef0..b266d31c5c 100644 --- a/src/gui/kernel/qpalette.cpp +++ b/src/gui/kernel/qpalette.cpp @@ -1120,12 +1120,14 @@ Q_GUI_EXPORT QPalette qt_fusionPalette() fusionPalette.setBrush(QPalette::HighlightedText, hightlightedText); fusionPalette.setBrush(QPalette::Disabled, QPalette::Text, disabledText); + fusionPalette.setBrush(QPalette::Disabled, QPalette::WindowText, disabledText); + fusionPalette.setBrush(QPalette::Disabled, QPalette::ButtonText, disabledText); fusionPalette.setBrush(QPalette::Disabled, QPalette::Base, disabledBase); fusionPalette.setBrush(QPalette::Disabled, QPalette::Dark, darkDisabled); fusionPalette.setBrush(QPalette::Disabled, QPalette::Shadow, disabledShadow); fusionPalette.setBrush(QPalette::Active, QPalette::Highlight, QColor(48, 140, 198)); - fusionPalette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(145, 141, 126)); + fusionPalette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(48, 140, 198)); fusionPalette.setBrush(QPalette::Disabled, QPalette::Highlight, QColor(145, 141, 126)); return fusionPalette; } diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index 1e8ac60cca..d23cfde172 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -425,8 +425,7 @@ bool QPlatformWindow::startSystemResize(const QPoint &pos, Qt::Corner corner) void QPlatformWindow::setFrameStrutEventsEnabled(bool enabled) { - if (enabled) - qWarning("This plugin does not support frame strut events."); + Q_UNUSED(enabled) // Do not warn as widgets enable it by default causing warnings with XCB. } /*! diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 0dd85f2d56..eff057c4cb 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -345,6 +345,25 @@ void QWindowPrivate::updateVisibility() emit q->visibilityChanged(visibility); } +void QWindowPrivate::setScreen(QScreen *newScreen, bool recreate) +{ + Q_Q(QWindow); + if (newScreen != q->screen()) { + const bool shouldRecreate = recreate && platformWindow != 0; + if (shouldRecreate) + q->destroy(); + if (screen) + q->disconnect(screen, SIGNAL(destroyed(QObject*)), q, SLOT(screenDestroyed(QObject*))); + screen = newScreen; + if (newScreen) { + q->connect(screen, SIGNAL(destroyed(QObject*)), q, SLOT(screenDestroyed(QObject*))); + if (shouldRecreate) + q->create(); + } + emit q->screenChanged(newScreen); + } +} + /*! Sets the \a surfaceType of the window. @@ -1384,6 +1403,7 @@ void QWindow::setFramePosition(const QPoint &point) if (d->platformWindow) { d->platformWindow->setGeometry(QRect(point, size())); } else { + d->positionAutomatic = false; d->geometry.moveTopLeft(point); } } @@ -1568,20 +1588,7 @@ void QWindow::setScreen(QScreen *newScreen) Q_D(QWindow); if (!newScreen) newScreen = QGuiApplication::primaryScreen(); - if (newScreen != screen()) { - 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 (newScreen) { - connect(d->screen, SIGNAL(destroyed(QObject*)), this, SLOT(screenDestroyed(QObject*))); - if (wasCreated) - create(); - } - emit screenChanged(newScreen); - } + d->setScreen(newScreen, true /* recreate */); } void QWindow::screenDestroyed(QObject *object) @@ -1896,9 +1903,11 @@ bool QWindow::event(QEvent *ev) case QEvent::Close: { Q_D(QWindow); bool wasVisible = isVisible(); - destroy(); - if (wasVisible) - d->maybeQuitOnLastWindowClosed(); + if (ev->isAccepted()) { + destroy(); + if (wasVisible) + d->maybeQuitOnLastWindowClosed(); + } break; } case QEvent::Expose: diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h index 79f90f2c62..efdfd497a6 100644 --- a/src/gui/kernel/qwindow.h +++ b/src/gui/kernel/qwindow.h @@ -330,6 +330,7 @@ protected: virtual void showEvent(QShowEvent *); virtual void hideEvent(QHideEvent *); + // TODO Qt 6 - add closeEvent virtual handler virtual bool event(QEvent *); virtual void keyPressEvent(QKeyEvent *); diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h index ea2cb722ab..f43c1ea8ec 100644 --- a/src/gui/kernel/qwindow_p.h +++ b/src/gui/kernel/qwindow_p.h @@ -127,6 +127,8 @@ public: void updateVisibility(); void _q_clearAlert(); + void setScreen(QScreen *newScreen, bool recreate); + QWindow::SurfaceType surfaceType; Qt::WindowFlags windowFlags; QWindow *parentWindow; diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 7dc1e7f7e5..6fc63fe96c 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -126,6 +126,13 @@ void QWindowSystemInterface::handleWindowStateChanged(QWindow *tlw, Qt::WindowSt QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); } +void QWindowSystemInterface::handleWindowScreenChanged(QWindow *tlw, QScreen *screen) +{ + QWindowSystemInterfacePrivate::WindowScreenChangedEvent *e = + new QWindowSystemInterfacePrivate::WindowScreenChangedEvent(tlw, screen); + QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); +} + void QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationState newState) { Q_ASSERT(QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ApplicationState)); diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index 521c2a4941..b0327701bb 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -138,6 +138,7 @@ public: static void handleWindowActivated(QWindow *w, Qt::FocusReason r = Qt::OtherFocusReason); static void handleWindowStateChanged(QWindow *w, Qt::WindowState newState); + static void handleWindowScreenChanged(QWindow *w, QScreen *newScreen); static void handleApplicationStateChanged(Qt::ApplicationState newState); diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h index a6ea15c5f2..c4968f8ca6 100644 --- a/src/gui/kernel/qwindowsysteminterface_p.h +++ b/src/gui/kernel/qwindowsysteminterface_p.h @@ -91,7 +91,8 @@ public: PlatformPanel = UserInputEvent | 0x17, ContextMenu = UserInputEvent | 0x18, ApplicationStateChanged = 0x19, - FlushEvents = 0x20 + FlushEvents = 0x20, + WindowScreenChanged = 0x21 }; class WindowSystemEvent { @@ -158,6 +159,16 @@ public: Qt::WindowState newState; }; + class WindowScreenChangedEvent : public WindowSystemEvent { + public: + WindowScreenChangedEvent(QWindow *w, QScreen *s) + : WindowSystemEvent(WindowScreenChanged), window(w), screen(s) + { } + + QPointer<QWindow> window; + QPointer<QScreen> screen; + }; + class ApplicationStateChangedEvent : public WindowSystemEvent { public: ApplicationStateChangedEvent(Qt::ApplicationState newState) |