diff options
author | Liang Qi <liang.qi@qt.io> | 2017-05-07 13:07:34 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-05-07 13:08:18 +0200 |
commit | d1ea4813458b383e66ce4df69d1833b8b6a279c4 (patch) | |
tree | 3bdc16da993e5de56b669e6774fb0748075ddd90 /src/platformsupport | |
parent | 1c87d4e1a1d0e1972f6dc85e55ea9be8a42797ba (diff) | |
parent | 0b1ec78c2d4871afcc89d5b046926b88f0819a7c (diff) |
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
src/network/access/qnetworkreply.cpp
tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp
Change-Id: Iadf766269454087e69fb216fc3857d85b0ddfaad
Diffstat (limited to 'src/platformsupport')
9 files changed, 81 insertions, 33 deletions
diff --git a/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp b/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp index 4c8a82470b..dc4785071f 100644 --- a/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp +++ b/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp @@ -46,8 +46,6 @@ #include <glib.h> #include "private/qguiapplication_p.h" -#include <qdebug.h> - QT_BEGIN_NAMESPACE struct GUserEventSource @@ -56,12 +54,15 @@ struct GUserEventSource QPAEventDispatcherGlib *q; }; -static gboolean userEventSourcePrepare(GSource *s, gint *timeout) +static gboolean userEventSourcePrepare(GSource *source, gint *timeout) { - Q_UNUSED(s) Q_UNUSED(timeout) - - return QWindowSystemInterface::windowSystemEventsQueued() > 0; + GUserEventSource *userEventSource = reinterpret_cast<GUserEventSource *>(source); + QPAEventDispatcherGlib *dispatcher = userEventSource->q; + if (dispatcher->m_flags & QEventLoop::ExcludeUserInputEvents) + return QWindowSystemInterface::nonUserInputEventsQueued(); + else + return QWindowSystemInterface::windowSystemEventsQueued() > 0; } static gboolean userEventSourceCheck(GSource *source) diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index d89a81be6b..7694bfd6bb 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -113,6 +113,7 @@ static NSInteger languageMapSort(id obj1, id obj2, void *context) #endif QCoreTextFontDatabase::QCoreTextFontDatabase() + : m_hasPopulatedAliases(false) { #ifdef Q_OS_MACX QSettings appleSettings(QLatin1String("apple.com")); @@ -200,18 +201,8 @@ static CFArrayRef availableFamilyNames() void QCoreTextFontDatabase::populateFontDatabase() { QCFType<CFArrayRef> familyNames = availableFamilyNames(); - const int numberOfFamilies = CFArrayGetCount(familyNames); - for (int i = 0; i < numberOfFamilies; ++i) { - CFStringRef familyNameRef = (CFStringRef) CFArrayGetValueAtIndex(familyNames, i); - QString familyName = QString::fromCFString(familyNameRef); - QPlatformFontDatabase::registerFontFamily(familyName); - -#if defined(Q_OS_OSX) - QString localizedFamilyName = QString::fromNSString([[NSFontManager sharedFontManager] localizedNameForFamily:(NSString*)familyNameRef face:nil]); - if (familyName != localizedFamilyName) - QPlatformFontDatabase::registerAliasToFontFamily(familyName, localizedFamilyName); -#endif - } + for (NSString *familyName in familyNames.as<const NSArray *>()) + QPlatformFontDatabase::registerFontFamily(QString::fromNSString(familyName)); // Force creating the theme fonts to get the descriptors in m_systemFontDescriptors if (m_themeFonts.isEmpty()) @@ -219,6 +210,31 @@ void QCoreTextFontDatabase::populateFontDatabase() Q_FOREACH (CTFontDescriptorRef fontDesc, m_systemFontDescriptors) populateFromDescriptor(fontDesc); + + Q_ASSERT(!m_hasPopulatedAliases); +} + +bool QCoreTextFontDatabase::populateFamilyAliases() +{ +#if defined(Q_OS_MACOS) + if (m_hasPopulatedAliases) + return false; + + QCFType<CFArrayRef> familyNames = availableFamilyNames(); + for (NSString *familyName in familyNames.as<const NSArray *>()) { + NSFontManager *fontManager = [NSFontManager sharedFontManager]; + NSString *localizedFamilyName = [fontManager localizedNameForFamily:familyName face:nil]; + if (![localizedFamilyName isEqual:familyName]) { + QPlatformFontDatabase::registerAliasToFontFamily( + QString::fromNSString(familyName), + QString::fromNSString(localizedFamilyName)); + } + } + m_hasPopulatedAliases = true; + return true; +#else + return false; +#endif } void QCoreTextFontDatabase::populateFamily(const QString &familyName) @@ -239,6 +255,11 @@ void QCoreTextFontDatabase::populateFamily(const QString &familyName) populateFromDescriptor(CTFontDescriptorRef(CFArrayGetValueAtIndex(matchingFonts, i)), familyName); } +void QCoreTextFontDatabase::invalidate() +{ + m_hasPopulatedAliases = false; +} + struct FontDescription { QCFString familyName; QCFString styleName; diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h index 9c2a4cf1ca..2b4c4e3ceb 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h @@ -71,7 +71,9 @@ public: QCoreTextFontDatabase(); ~QCoreTextFontDatabase(); void populateFontDatabase() Q_DECL_OVERRIDE; + bool populateFamilyAliases() override; void populateFamily(const QString &familyName) Q_DECL_OVERRIDE; + void invalidate() override; QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const Q_DECL_OVERRIDE; QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName) Q_DECL_OVERRIDE; @@ -92,6 +94,7 @@ private: mutable QSet<CTFontDescriptorRef> m_systemFontDescriptors; mutable QHash<QPlatformTheme::Font, QFont *> m_themeFonts; + bool m_hasPopulatedAliases; }; // Split out into separate template class so that the compiler doesn't have diff --git a/src/platformsupport/graphics/qrasterbackingstore.cpp b/src/platformsupport/graphics/qrasterbackingstore.cpp index 2f7074403c..b8d393844c 100644 --- a/src/platformsupport/graphics/qrasterbackingstore.cpp +++ b/src/platformsupport/graphics/qrasterbackingstore.cpp @@ -60,7 +60,10 @@ void QRasterBackingStore::resize(const QSize &size, const QRegion &staticContent { Q_UNUSED(staticContents); - qreal nativeWindowDevicePixelRatio = window()->handle()->devicePixelRatio(); + // We can't guarantee that we have a platform-window at this point, so we have + // to pull out the DPR using QWindow and its QScreen fallback, and then remove + // the Qt scaling factor. + qreal nativeWindowDevicePixelRatio = window()->devicePixelRatio() / QHighDpiScaling::factor(window()); QSize effectiveBufferSize = size * nativeWindowDevicePixelRatio; if (m_image.size() == effectiveBufferSize) diff --git a/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/src/platformsupport/services/genericunix/qgenericunixservices.cpp index 01d988fdbe..cdb5d33859 100644 --- a/src/platformsupport/services/genericunix/qgenericunixservices.cpp +++ b/src/platformsupport/services/genericunix/qgenericunixservices.cpp @@ -40,12 +40,14 @@ #include "qgenericunixservices_p.h" #include <QtGui/private/qtguiglobal_p.h> -#include <QtCore/QStandardPaths> +#include <QtCore/QDebug> +#include <QtCore/QFile> #if QT_CONFIG(process) # include <QtCore/QProcess> #endif +#include <QtCore/QSettings> +#include <QtCore/QStandardPaths> #include <QtCore/QUrl> -#include <QtCore/QDebug> #include <stdlib.h> @@ -68,11 +70,29 @@ static inline QByteArray detectDesktopEnvironment() return QByteArrayLiteral("GNOME"); // Fallback to checking $DESKTOP_SESSION (unreliable) - const QByteArray desktopSession = qgetenv("DESKTOP_SESSION"); + QByteArray desktopSession = qgetenv("DESKTOP_SESSION"); + + // This can be a path in /usr/share/xsessions + int slash = desktopSession.lastIndexOf('/'); + if (slash != -1) { +#ifndef QT_NO_SETTINGS + QSettings desktopFile(QFile::decodeName(desktopSession + ".desktop"), QSettings::IniFormat); + desktopFile.beginGroup(QStringLiteral("Desktop Entry")); + QByteArray desktopName = desktopFile.value(QStringLiteral("DesktopNames")).toByteArray(); + if (!desktopName.isEmpty()) + return desktopName; +#endif + + // try decoding just the basename + desktopSession = desktopSession.mid(slash + 1); + } + if (desktopSession == "gnome") return QByteArrayLiteral("GNOME"); - if (desktopSession == "xfce") + else if (desktopSession == "xfce") return QByteArrayLiteral("XFCE"); + else if (desktopSession == "kde") + return QByteArrayLiteral("KDE"); return QByteArrayLiteral("UNKNOWN"); } @@ -168,12 +188,14 @@ QByteArray QGenericUnixServices::desktopEnvironment() const bool QGenericUnixServices::openUrl(const QUrl &url) { + Q_UNUSED(url) qWarning("openUrl() not supported on this platform"); return false; } bool QGenericUnixServices::openDocument(const QUrl &url) { + Q_UNUSED(url) qWarning("openDocument() not supported on this platform"); return false; } diff --git a/src/platformsupport/themes/genericunix/dbusmenu/qdbusplatformmenu.cpp b/src/platformsupport/themes/genericunix/dbusmenu/qdbusplatformmenu.cpp index e3b1c6c37d..51c690d43a 100644 --- a/src/platformsupport/themes/genericunix/dbusmenu/qdbusplatformmenu.cpp +++ b/src/platformsupport/themes/genericunix/dbusmenu/qdbusplatformmenu.cpp @@ -58,8 +58,8 @@ QDBusPlatformMenuItem::QDBusPlatformMenuItem() , m_isSeparator(false) , m_isCheckable(false) , m_isChecked(false) - , m_dbusID(nextDBusID++) , m_hasExclusiveGroup(false) + , m_dbusID(nextDBusID++) { menuItemsByID.insert(m_dbusID, this); } @@ -164,7 +164,6 @@ QList<const QDBusPlatformMenuItem *> QDBusPlatformMenuItem::byIds(const QList<in QDBusPlatformMenu::QDBusPlatformMenu() : m_isEnabled(true) , m_isVisible(true) - , m_isSeparator(false) , m_revision(1) , m_containingMenuItem(Q_NULLPTR) { diff --git a/src/platformsupport/themes/genericunix/dbusmenu/qdbusplatformmenu_p.h b/src/platformsupport/themes/genericunix/dbusmenu/qdbusplatformmenu_p.h index 668195a794..5458e2fdd5 100644 --- a/src/platformsupport/themes/genericunix/dbusmenu/qdbusplatformmenu_p.h +++ b/src/platformsupport/themes/genericunix/dbusmenu/qdbusplatformmenu_p.h @@ -120,9 +120,9 @@ private: bool m_isSeparator : 1; bool m_isCheckable : 1; bool m_isChecked : 1; - int m_dbusID : 16; bool m_hasExclusiveGroup : 1; - int m_reserved : 6; + short /*unused*/ : 6; + short m_dbusID : 16; QKeySequence m_shortcut; }; @@ -177,7 +177,6 @@ private: QIcon m_icon; bool m_isEnabled; bool m_isVisible; - bool m_isSeparator; uint m_revision; QHash<quintptr, QDBusPlatformMenuItem *> m_itemsByTag; QList<QDBusPlatformMenuItem *> m_items; diff --git a/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon_p.h b/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon_p.h index ff1a7ae532..4c9bc8f7e3 100644 --- a/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon_p.h +++ b/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon_p.h @@ -159,8 +159,6 @@ private: QTemporaryFile *m_tempAttentionIcon; QString m_attentionIconName; QTimer m_attentionTimer; - bool m_isRequestingAttention; - bool m_hasMenu; bool m_registered; }; diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp index 93c7b0871c..30efa12124 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp @@ -816,11 +816,13 @@ QStringList QGenericUnixTheme::themeNames() result.push_back(QStringLiteral("gtk3")); // fallback to the generic Gnome theme if loading the GTK3 theme fails result.push_back(QLatin1String(QGnomeTheme::name)); + } else { + // unknown, but lowercase the name (our standard practice) and + // remove any "x-" prefix + QString s = QString::fromLatin1(desktopName.toLower()); + result.push_back(s.startsWith(QLatin1String("x-")) ? s.mid(2) : s); } } - const QString session = QString::fromLocal8Bit(qgetenv("DESKTOP_SESSION")); - if (!session.isEmpty() && session != QLatin1String("default") && !result.contains(session)) - result.push_back(session); } // desktopSettingsAware result.append(QLatin1String(QGenericUnixTheme::name)); return result; |