diff options
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 8 | ||||
-rw-r--r-- | src/gui/kernel/qkeysequence.cpp | 30 | ||||
-rw-r--r-- | src/gui/kernel/qkeysequence_p.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qplatformwindow.cpp | 6 | ||||
-rw-r--r-- | src/gui/kernel/qwindow.cpp | 2 |
5 files changed, 34 insertions, 14 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 65d679cdad..3fe6698955 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -235,11 +235,13 @@ static inline void clearFontUnlocked() QGuiApplicationPrivate::app_font = 0; } +// Using aggregate initialization instead of ctor so we can have a POD global static +#define Q_WINDOW_GEOMETRY_SPECIFICATION_INITIALIZER { Qt::TopLeftCorner, -1, -1, -1, -1 } + // Geometry specification for top level windows following the convention of the // -geometry command line arguments in X11 (see XParseGeometry). struct QWindowGeometrySpecification { - QWindowGeometrySpecification() : corner(Qt::TopLeftCorner), xOffset(-1), yOffset(-1), width(-1), height(-1) {} static QWindowGeometrySpecification fromArgument(const QByteArray &a); void applyTo(QWindow *window) const; @@ -276,7 +278,7 @@ static inline int nextGeometryToken(const QByteArray &a, int &pos, char *op) QWindowGeometrySpecification QWindowGeometrySpecification::fromArgument(const QByteArray &a) { - QWindowGeometrySpecification result; + QWindowGeometrySpecification result = Q_WINDOW_GEOMETRY_SPECIFICATION_INITIALIZER; int pos = 0; for (int i = 0; i < 4; ++i) { char op; @@ -333,7 +335,7 @@ void QWindowGeometrySpecification::applyTo(QWindow *window) const } } -static QWindowGeometrySpecification windowGeometrySpecification; +static QWindowGeometrySpecification windowGeometrySpecification = Q_WINDOW_GEOMETRY_SPECIFICATION_INITIALIZER; /*! \class QGuiApplication diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index 46784f59be..6bb80042ee 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -1261,7 +1261,28 @@ QString QKeySequencePrivate::encodeString(int key, QKeySequence::SequenceFormat if ((key & Qt::KeypadModifier) == Qt::KeypadModifier) addKey(s, nativeText ? QCoreApplication::translate("QShortcut", "Num") : QString::fromLatin1("Num"), format); + QString p = keyName(key, format); +#if defined(Q_OS_OSX) + if (nativeText) + s += p; + else +#endif + addKey(s, p, format); + return s; +} + +/*! + \internal + Returns the text representation of the key \a key, which can be used i.e. + when the sequence is serialized. This does not take modifiers into account + (see encodeString() for a version that does). + + This static method is used by encodeString() and by the D-Bus menu exporter. +*/ +QString QKeySequencePrivate::keyName(int key, QKeySequence::SequenceFormat format) +{ + bool nativeText = (format == QKeySequence::NativeText); key &= ~(Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier | Qt::KeypadModifier); QString p; @@ -1312,14 +1333,7 @@ NonSymbol: } } } - -#if defined(Q_OS_MACX) - if (nativeText) - s += p; - else -#endif - addKey(s, p, format); - return s; + return p; } /*! Matches the sequence with \a seq. Returns ExactMatch if diff --git a/src/gui/kernel/qkeysequence_p.h b/src/gui/kernel/qkeysequence_p.h index a03549634f..6d20f798b3 100644 --- a/src/gui/kernel/qkeysequence_p.h +++ b/src/gui/kernel/qkeysequence_p.h @@ -75,6 +75,8 @@ public: QAtomicInt ref; int key[MaxKeyCount]; static QString encodeString(int key, QKeySequence::SequenceFormat format); + // used in dbusmenu + Q_GUI_EXPORT static QString keyName(int key, QKeySequence::SequenceFormat format); static int decodeString(const QString &keyStr, QKeySequence::SequenceFormat format); }; #endif // QT_NO_SHORTCUT diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index aea029b7f5..04532e82aa 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -484,8 +484,10 @@ QPlatformScreen *QPlatformWindow::screenForGeometry(const QRect &newGeometry) co { QPlatformScreen *currentScreen = screen(); QPlatformScreen *fallback = currentScreen; - //QRect::center can return a value outside the rectangle if it's empty - const QPoint center = newGeometry.isEmpty() ? newGeometry.topLeft() : newGeometry.center(); + // QRect::center can return a value outside the rectangle if it's empty. + // Apply mapToGlobal() in case it is a foreign/embedded window. + const QPoint center = + mapToGlobal(newGeometry.isEmpty() ? newGeometry.topLeft() : newGeometry.center()); if (!parent() && currentScreen && !currentScreen->geometry().contains(center)) { Q_FOREACH (QPlatformScreen* screen, currentScreen->virtualSiblings()) { diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 21734f1619..30cbed4aa8 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -951,7 +951,7 @@ void QWindow::setMask(const QRegion ®ion) Q_D(QWindow); if (!d->platformWindow) return; - d->platformWindow->setMask(region); + d->platformWindow->setMask(QHighDpi::toNativeLocalRegion(region, this)); d->mask = region; } |