diff options
Diffstat (limited to 'src/platformsupport')
9 files changed, 193 insertions, 153 deletions
diff --git a/src/platformsupport/edid/qedidparser.cpp b/src/platformsupport/edid/qedidparser.cpp index 06c8852825..6bf1f1db96 100644 --- a/src/platformsupport/edid/qedidparser.cpp +++ b/src/platformsupport/edid/qedidparser.cpp @@ -42,8 +42,6 @@ #include "qedidparser_p.h" #include "qedidvendortable_p.h" -#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) - #define EDID_DESCRIPTOR_ALPHANUMERIC_STRING 0xfe #define EDID_DESCRIPTOR_PRODUCT_NAME 0xfc #define EDID_DESCRIPTOR_SERIAL_NUMBER 0xff @@ -139,9 +137,9 @@ bool QEdidParser::parse(const QByteArray &blob) manufacturer = m_vendorCache.value(pnpIdString); if (manufacturer.isEmpty()) { // Find the manufacturer from the vendor lookup table - for (size_t i = 0; i < ARRAY_LENGTH(q_edidVendorTable); i++) { - if (strncmp(q_edidVendorTable[i].id, pnpId, 3) == 0) { - manufacturer = QString::fromUtf8(q_edidVendorTable[i].name); + for (const auto &vendor : q_edidVendorTable) { + if (strncmp(vendor.id, pnpId, 3) == 0) { + manufacturer = QString::fromUtf8(vendor.name); break; } } diff --git a/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp b/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp index 6011941982..8c6cc8fbc1 100644 --- a/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp +++ b/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp @@ -1110,16 +1110,32 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, glyph_buffer.reset(new uchar[glyph_buffer_size]); if (slot->bitmap.pixel_mode == FT_PIXEL_MODE_MONO) { - Q_ASSERT(format == Format_Mono); uchar *src = slot->bitmap.buffer; uchar *dst = glyph_buffer.data(); int h = slot->bitmap.rows; - - int bytes = ((info.width + 7) & ~7) >> 3; - while (h--) { - memcpy (dst, src, bytes); - dst += pitch; - src += slot->bitmap.pitch; + // Some fonts return bitmaps even when we requested something else: + if (format == Format_Mono) { + int bytes = ((info.width + 7) & ~7) >> 3; + while (h--) { + memcpy (dst, src, bytes); + dst += pitch; + src += slot->bitmap.pitch; + } + } else if (format == Format_A8) { + while (h--) { + for (int x = 0; x < int{info.width}; x++) + dst[x] = ((src[x >> 3] & (0x80 >> (x & 7))) ? 0xff : 0x00); + dst += pitch; + src += slot->bitmap.pitch; + } + } else { + while (h--) { + uint *dd = reinterpret_cast<uint *>(dst); + for (int x = 0; x < int{info.width}; x++) + dd[x] = ((src[x >> 3] & (0x80 >> (x & 7))) ? 0xffffffff : 0x00000000); + dst += pitch; + src += slot->bitmap.pitch; + } } } else if (slot->bitmap.pixel_mode == 7 /*FT_PIXEL_MODE_BGRA*/) { Q_ASSERT(format == Format_ARGB); diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index 047773d8e3..4887a501ba 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -48,6 +48,8 @@ #import <UIKit/UIFont.h> #endif +#include <QtCore/qelapsedtimer.h> + #include "qcoretextfontdatabase_p.h" #include "qfontengine_coretext_p.h" #if QT_CONFIG(settings) @@ -100,20 +102,6 @@ static const char *languageForWritingSystem[] = { }; enum { LanguageCount = sizeof(languageForWritingSystem) / sizeof(const char *) }; -#ifdef Q_OS_OSX -static NSInteger languageMapSort(id obj1, id obj2, void *context) -{ - NSArray<NSString *> *map1 = reinterpret_cast<NSArray<NSString *> *>(obj1); - NSArray<NSString *> *map2 = reinterpret_cast<NSArray<NSString *> *>(obj2); - NSArray<NSString *> *languages = reinterpret_cast<NSArray<NSString *> *>(context); - - NSString *lang1 = [map1 objectAtIndex:0]; - NSString *lang2 = [map2 objectAtIndex:0]; - - return [languages indexOfObject:lang1] - [languages indexOfObject:lang2]; -} -#endif - QCoreTextFontDatabase::QCoreTextFontDatabase() : m_hasPopulatedAliases(false) { @@ -127,39 +115,77 @@ QCoreTextFontDatabase::~QCoreTextFontDatabase() void QCoreTextFontDatabase::populateFontDatabase() { + qCDebug(lcQpaFonts) << "Populating font database..."; + QElapsedTimer elapsed; + if (lcQpaFonts().isDebugEnabled()) + elapsed.start(); + QCFType<CFArrayRef> familyNames = CTFontManagerCopyAvailableFontFamilyNames(); for (NSString *familyName in familyNames.as<const NSArray *>()) QPlatformFontDatabase::registerFontFamily(QString::fromNSString(familyName)); + qCDebug(lcQpaFonts) << "Populating available families took" << elapsed.restart() << "ms"; + // Force creating the theme fonts to get the descriptors in m_systemFontDescriptors if (m_themeFonts.isEmpty()) (void)themeFonts(); + qCDebug(lcQpaFonts) << "Resolving theme fonts took" << elapsed.restart() << "ms"; + Q_FOREACH (CTFontDescriptorRef fontDesc, m_systemFontDescriptors) populateFromDescriptor(fontDesc); + qCDebug(lcQpaFonts) << "Populating system descriptors took" << elapsed.restart() << "ms"; + Q_ASSERT(!m_hasPopulatedAliases); } -bool QCoreTextFontDatabase::populateFamilyAliases() +bool QCoreTextFontDatabase::populateFamilyAliases(const QString &missingFamily) { #if defined(Q_OS_MACOS) if (m_hasPopulatedAliases) return false; + // There's no API to go from a localized family name to its non-localized + // name, so we have to resort to enumerating all the available fonts and + // doing a reverse lookup. + + qCDebug(lcQpaFonts) << "Populating family aliases..."; + QElapsedTimer elapsed; + elapsed.start(); + + QString nonLocalizedMatch; QCFType<CFArrayRef> familyNames = CTFontManagerCopyAvailableFontFamilyNames(); + NSFontManager *fontManager = NSFontManager.sharedFontManager; 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)); + QString nonLocalizedFamily = QString::fromNSString(familyName); + QString localizedFamily = QString::fromNSString(localizedFamilyName); + QPlatformFontDatabase::registerAliasToFontFamily(nonLocalizedFamily, localizedFamily); + if (localizedFamily == missingFamily) + nonLocalizedMatch = nonLocalizedFamily; } } m_hasPopulatedAliases = true; + + if (lcQpaFonts().isWarningEnabled()) { + QString warningMessage; + QDebug msg(&warningMessage); + + msg << "Populating font family aliases took" << elapsed.restart() << "ms."; + if (!nonLocalizedMatch.isNull()) + msg << "Replace uses of" << missingFamily << "with its non-localized name" << nonLocalizedMatch; + else + msg << "Replace uses of missing font family" << missingFamily << "with one that exists"; + msg << "to avoid this cost."; + + qCWarning(lcQpaFonts) << qPrintable(warningMessage); + } + return true; #else + Q_UNUSED(missingFamily); return false; #endif } @@ -173,7 +199,7 @@ void QCoreTextFontDatabase::populateFamily(const QString &familyName) // A single family might match several different fonts with different styles eg. QCFType<CFArrayRef> matchingFonts = (CFArrayRef) CTFontDescriptorCreateMatchingFontDescriptors(nameOnlyDescriptor, 0); if (!matchingFonts) { - qWarning() << "QCoreTextFontDatabase: Found no matching fonts for family" << familyName; + qCWarning(lcQpaFonts) << "QCoreTextFontDatabase: Found no matching fonts for family" << familyName; return; } @@ -406,142 +432,116 @@ template class QCoreTextFontDatabaseEngineFactory<QCoreTextFontEngine>; template class QCoreTextFontDatabaseEngineFactory<QFontEngineFT>; #endif -QFont::StyleHint styleHintFromNSString(NSString *style) +QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family) { - if ([style isEqual: @"sans-serif"]) - return QFont::SansSerif; - else if ([style isEqual: @"monospace"]) - return QFont::Monospace; - else if ([style isEqual: @"cursive"]) - return QFont::Cursive; - else if ([style isEqual: @"serif"]) - return QFont::Serif; - else if ([style isEqual: @"fantasy"]) - return QFont::Fantasy; - else // if ([style isEqual: @"default"]) - return QFont::AnyStyle; -} + if (family.isEmpty()) + return QStringList(); -#ifdef Q_OS_OSX -static QString familyNameFromPostScriptName(NSString *psName) -{ - QCFType<CTFontDescriptorRef> fontDescriptor = (CTFontDescriptorRef) CTFontDescriptorCreateWithNameAndSize((CFStringRef)psName, 12.0); - QCFString familyName = (CFStringRef) CTFontDescriptorCopyAttribute(fontDescriptor, kCTFontFamilyNameAttribute); - QString name = QString::fromCFString(familyName); - if (name.isEmpty()) - qWarning() << "QCoreTextFontDatabase: Failed to resolve family name for PostScript name " << QString::fromCFString((CFStringRef)psName); + auto attributes = @{ id(kCTFontFamilyNameAttribute): family.toNSString() }; + QCFType<CTFontDescriptorRef> fontDescriptor = CTFontDescriptorCreateWithAttributes(CFDictionaryRef(attributes)); + if (!fontDescriptor) { + qCWarning(lcQpaFonts) << "Failed to create fallback font descriptor for" << family; + return QStringList(); + } - return name; -} -#endif + QCFType<CTFontRef> font = CTFontCreateWithFontDescriptor(fontDescriptor, 12.0, 0); + if (!font) { + qCWarning(lcQpaFonts) << "Failed to create fallback font for" << family; + return QStringList(); + } -static void addExtraFallbacks(QStringList *fallbackList) -{ -#if defined(Q_OS_MACOS) - // Since we are only returning a list of default fonts for the current language, we do not - // cover all unicode completely. This was especially an issue for some of the common script - // symbols such as mathematical symbols, currency or geometric shapes. To minimize the risk - // of missing glyphs, we add Arial Unicode MS as a final fail safe, since this covers most - // of Unicode 2.1. - if (!fallbackList->contains(QStringLiteral("Arial Unicode MS"))) - fallbackList->append(QStringLiteral("Arial Unicode MS")); - // Since some symbols (specifically Braille) are not in Arial Unicode MS, we - // add Apple Symbols to cover those too. - if (!fallbackList->contains(QStringLiteral("Apple Symbols"))) - fallbackList->append(QStringLiteral("Apple Symbols")); -#else - Q_UNUSED(fallbackList) -#endif + QCFType<CFArrayRef> cascadeList = CFArrayRef(CTFontCopyDefaultCascadeListForLanguages(font, + (CFArrayRef)[NSUserDefaults.standardUserDefaults stringArrayForKey:@"AppleLanguages"])); + if (!cascadeList) { + qCWarning(lcQpaFonts) << "Failed to create fallback cascade list for" << family; + return QStringList(); + } + + QStringList fallbackList; + const int numCascades = CFArrayGetCount(cascadeList); + for (int i = 0; i < numCascades; ++i) { + CTFontDescriptorRef fontFallback = CTFontDescriptorRef(CFArrayGetValueAtIndex(cascadeList, i)); + QCFString fallbackFamilyName = CFStringRef(CTFontDescriptorCopyAttribute(fontFallback, kCTFontFamilyNameAttribute)); + fallbackList.append(QString::fromCFString(fallbackFamilyName)); + } + + return fallbackList; } QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const { Q_UNUSED(style); - Q_UNUSED(script); QMacAutoReleasePool pool; - static QHash<QString, QStringList> fallbackLists; - - if (!family.isEmpty()) { - QCFType<CFMutableDictionaryRef> attributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - CFDictionaryAddValue(attributes, kCTFontFamilyNameAttribute, QCFString(family)); - if (QCFType<CTFontDescriptorRef> fontDescriptor = CTFontDescriptorCreateWithAttributes(attributes)) { - if (QCFType<CTFontRef> font = CTFontCreateWithFontDescriptor(fontDescriptor, 12.0, 0)) { - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSArray *languages = [defaults stringArrayForKey: @"AppleLanguages"]; - - QCFType<CFArrayRef> cascadeList = (CFArrayRef) CTFontCopyDefaultCascadeListForLanguages(font, (CFArrayRef) languages); - if (cascadeList) { - QStringList fallbackList; - const int numCascades = CFArrayGetCount(cascadeList); - for (int i = 0; i < numCascades; ++i) { - CTFontDescriptorRef fontFallback = (CTFontDescriptorRef) CFArrayGetValueAtIndex(cascadeList, i); - QCFString fallbackFamilyName = (CFStringRef) CTFontDescriptorCopyAttribute(fontFallback, kCTFontFamilyNameAttribute); - fallbackList.append(QString::fromCFString(fallbackFamilyName)); - } - - addExtraFallbacks(&fallbackList); - extern QStringList qt_sort_families_by_writing_system(QChar::Script, const QStringList &); - fallbackList = qt_sort_families_by_writing_system(script, fallbackList); - - return fallbackList; + QStringList fallbackList = fallbacksForFamily(family); + + if (fallbackList.isEmpty()) { + // We were not able to find a fallback for the specific family, + // or the family was empty, so we fall back to the style hint. + QString styleFamily = [styleHint]{ + switch (styleHint) { + case QFont::SansSerif: return QStringLiteral("Helvetica"); + case QFont::Serif: return QStringLiteral("Times New Roman"); + case QFont::Monospace: return QStringLiteral("Menlo"); +#ifdef Q_OS_MACOS + case QFont::Cursive: return QStringLiteral("Apple Chancery"); +#endif + case QFont::Fantasy: return QStringLiteral("Zapfino"); + case QFont::TypeWriter: return QStringLiteral("American Typewriter"); + case QFont::AnyStyle: Q_FALLTHROUGH(); + case QFont::System: { + QCFType<CTFontRef> font = CTFontCreateUIFontForLanguage(kCTFontUIFontSystem, 12.0, NULL); + return static_cast<QString>(QCFString(CTFontCopyFullName(font))); } + default: return QString(); // No matching font on this platform } + }(); + if (!styleFamily.isEmpty()) { + fallbackList = fallbacksForFamily(styleFamily); + if (!fallbackList.contains(styleFamily)) + fallbackList.prepend(styleFamily); } } - // We were not able to find a fallback for the specific family, - // so we fall back to the stylehint. - - static const QString styleLookupKey = QString::fromLatin1(".QFontStyleHint_%1"); - - static bool didPopulateStyleFallbacks = false; - if (!didPopulateStyleFallbacks) { -#if defined(Q_OS_MACX) - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSArray<NSString *> *languages = [defaults stringArrayForKey:@"AppleLanguages"]; - - NSDictionary<NSString *, id> *fallbackDict = [NSDictionary<NSString *, id> dictionaryWithContentsOfFile:@"/System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreText.framework/Resources/DefaultFontFallbacks.plist"]; - - for (NSString *style in [fallbackDict allKeys]) { - NSArray *list = [fallbackDict valueForKey:style]; - QFont::StyleHint fallbackStyleHint = styleHintFromNSString(style); - QStringList fallbackList; - for (id item in list) { - // sort the array based on system language preferences - if ([item isKindOfClass:[NSArray class]]) { - NSArray *langs = [reinterpret_cast<NSArray *>(item) - sortedArrayUsingFunction:languageMapSort context:languages]; - for (NSArray<NSString *> *map in langs) - fallbackList.append(familyNameFromPostScriptName([map objectAtIndex:1])); - } - else if ([item isKindOfClass: [NSString class]]) - fallbackList.append(familyNameFromPostScriptName(item)); - } + if (fallbackList.isEmpty()) + return fallbackList; - fallbackList.append(QLatin1String("Apple Color Emoji")); + // .Apple Symbols Fallback will be at the beginning of the list and we will + // detect that this has glyphs for Arabic and other writing systems. + // Since it is a symbol font, it should be the last resort, so that + // the proper fonts for these writing systems are preferred. + int symbolIndex = fallbackList.indexOf(QLatin1String(".Apple Symbols Fallback")); + if (symbolIndex >= 0) + fallbackList.move(symbolIndex, fallbackList.size() - 1); - addExtraFallbacks(&fallbackList); - fallbackLists[styleLookupKey.arg(fallbackStyleHint)] = fallbackList; - } -#else - QStringList staticFallbackList; - staticFallbackList << QString::fromLatin1("Helvetica,Apple Color Emoji,Geeza Pro,Arial Hebrew,Thonburi,Kailasa" - "Hiragino Kaku Gothic ProN,.Heiti J,Apple SD Gothic Neo,.Heiti K,Heiti SC,Heiti TC" - "Bangla Sangam MN,Devanagari Sangam MN,Gujarati Sangam MN,Gurmukhi MN,Kannada Sangam MN" - "Malayalam Sangam MN,Oriya Sangam MN,Sinhala Sangam MN,Tamil Sangam MN,Telugu Sangam MN" - "Euphemia UCAS,.PhoneFallback").split(QLatin1String(",")); - - for (int i = QFont::Helvetica; i <= QFont::Fantasy; ++i) - fallbackLists[styleLookupKey.arg(i)] = staticFallbackList; +#if defined(Q_OS_MACOS) + // Since we are only returning a list of default fonts for the current language, we do not + // cover all Unicode completely. This was especially an issue for some of the common script + // symbols such as mathematical symbols, currency or geometric shapes. To minimize the risk + // of missing glyphs, we add Arial Unicode MS as a final fail safe, since this covers most + // of Unicode 2.1. + if (!fallbackList.contains(QStringLiteral("Arial Unicode MS"))) + fallbackList.append(QStringLiteral("Arial Unicode MS")); + // Since some symbols (specifically Braille) are not in Arial Unicode MS, we + // add Apple Symbols to cover those too. + if (!fallbackList.contains(QStringLiteral("Apple Symbols"))) + fallbackList.append(QStringLiteral("Apple Symbols")); #endif - didPopulateStyleFallbacks = true; + // Since iOS 13, the cascade list may contain meta-fonts which have not been + // populated to the database, such as ".AppleJapaneseFont". It is important that we + // include this in the fallback list, in order to get fallback support for all + // languages + for (const QString &fallback : fallbackList) { + if (!QPlatformFontDatabase::isFamilyPopulated(fallback)) + const_cast<QCoreTextFontDatabase *>(this)->populateFamily(fallback); } - Q_ASSERT(!fallbackLists.isEmpty()); - return fallbackLists[styleLookupKey.arg(styleHint)]; + extern QStringList qt_sort_families_by_writing_system(QChar::Script, const QStringList &); + fallbackList = qt_sort_families_by_writing_system(script, fallbackList); + + return fallbackList; } QStringList QCoreTextFontDatabase::addApplicationFont(const QByteArray &fontData, const QString &fileName) diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h index 05f6ed641c..69ff454d1e 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h @@ -71,7 +71,7 @@ public: QCoreTextFontDatabase(); ~QCoreTextFontDatabase(); void populateFontDatabase() override; - bool populateFamilyAliases() override; + bool populateFamilyAliases(const QString &missingFamily) override; void populateFamily(const QString &familyName) override; void invalidate() override; @@ -92,6 +92,7 @@ protected: private: void populateFromDescriptor(CTFontDescriptorRef font, const QString &familyName = QString()); + static QStringList fallbacksForFamily(const QString &family); mutable QString defaultFontName; diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp index 737d85d5c3..c51db59e1f 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp +++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Copyright (C) 2016 Jolla Ltd, author: <gunnar.sletta@jollamobile.com> ** Contact: https://www.qt.io/licensing/ ** @@ -69,6 +69,7 @@ extern "C" { QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY(qLcEvdevTouch, "qt.qpa.input") +Q_LOGGING_CATEGORY(qLcEvents, "qt.qpa.input.events") /* android (and perhaps some other linux-derived stuff) don't define everything * in linux/input.h, so we'll need to do that ourselves. @@ -77,7 +78,7 @@ Q_LOGGING_CATEGORY(qLcEvdevTouch, "qt.qpa.input") #define ABS_MT_TOUCH_MAJOR 0x30 /* Major axis of touching ellipse */ #endif #ifndef ABS_MT_POSITION_X -#define ABS_MT_POSITION_X 0x35 /* Center X ellipse position */ +#define ABS_MT_POSITION_X 0x35 /* Center X ellipse position */ #endif #ifndef ABS_MT_POSITION_Y #define ABS_MT_POSITION_Y 0x36 /* Center Y ellipse position */ @@ -91,6 +92,9 @@ Q_LOGGING_CATEGORY(qLcEvdevTouch, "qt.qpa.input") #ifndef ABS_MT_TRACKING_ID #define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */ #endif +#ifndef ABS_MT_PRESSURE +#define ABS_MT_PRESSURE 0x3a +#endif #ifndef SYN_MT_REPORT #define SYN_MT_REPORT 2 #endif @@ -535,7 +539,10 @@ void QEvdevTouchScreenData::processInputEvent(input_event *data) m_currentData.state = Qt::TouchPointReleased; if (m_typeB) m_contacts[m_currentSlot].maj = m_currentData.maj; - } else if (data->code == ABS_PRESSURE) { + } else if (data->code == ABS_PRESSURE || data->code == ABS_MT_PRESSURE) { + if (Q_UNLIKELY(qLcEvents().isDebugEnabled())) + qCDebug(qLcEvents, "EV_ABS code 0x%x: pressure %d; bounding to [%d,%d]", + data->code, data->value, hw_pressure_min, hw_pressure_max); m_currentData.pressure = qBound(hw_pressure_min, data->value, hw_pressure_max); if (m_typeB || m_singleTouch) m_contacts[m_currentSlot].pressure = m_currentData.pressure; @@ -574,6 +581,7 @@ void QEvdevTouchScreenData::processInputEvent(input_event *data) m_lastTouchPoints = m_touchPoints; m_touchPoints.clear(); Qt::TouchPointStates combinedStates; + bool hasPressure = false; for (auto i = m_contacts.begin(), end = m_contacts.end(); i != end; /*erasing*/) { auto it = i++; @@ -604,6 +612,9 @@ void QEvdevTouchScreenData::processInputEvent(input_event *data) continue; } + if (contact.pressure) + hasPressure = true; + addTouchPoint(contact, &combinedStates); } @@ -648,7 +659,7 @@ void QEvdevTouchScreenData::processInputEvent(input_event *data) m_contacts.clear(); - if (!m_touchPoints.isEmpty() && combinedStates != Qt::TouchPointStationary) + if (!m_touchPoints.isEmpty() && (hasPressure || combinedStates != Qt::TouchPointStationary)) reportPoints(); } @@ -774,6 +785,9 @@ void QEvdevTouchScreenData::reportPoints() tp.pressure = tp.state == Qt::TouchPointReleased ? 0 : 1; else tp.pressure = (tp.pressure - hw_pressure_min) / qreal(hw_pressure_max - hw_pressure_min); + + if (Q_UNLIKELY(qLcEvents().isDebugEnabled())) + qCDebug(qLcEvents) << "reporting" << tp; } // Let qguiapp pick the target window. diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp index b280f27fac..bf2df93d11 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp +++ b/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp @@ -98,8 +98,8 @@ void QEvdevTouchManager::addDevice(const QString &deviceNode) qCDebug(qLcEvdevTouch, "evdevtouch: Adding device at %ls", qUtf16Printable(deviceNode)); auto handler = qt_make_unique<QEvdevTouchScreenHandlerThread>(deviceNode, m_spec); if (handler) { - m_activeDevices.add(deviceNode, std::move(handler)); connect(handler.get(), &QEvdevTouchScreenHandlerThread::touchDeviceRegistered, this, &QEvdevTouchManager::updateInputDeviceCount); + m_activeDevices.add(deviceNode, std::move(handler)); } else { qWarning("evdevtouch: Failed to open touch device %ls", qUtf16Printable(deviceNode)); } diff --git a/src/platformsupport/input/tslib/qtslib.cpp b/src/platformsupport/input/tslib/qtslib.cpp index df57147af6..e105f5ea98 100644 --- a/src/platformsupport/input/tslib/qtslib.cpp +++ b/src/platformsupport/input/tslib/qtslib.cpp @@ -68,7 +68,9 @@ QTsLibMouseHandler::QTsLibMouseHandler(const QString &key, return; } +#ifdef TSLIB_VERSION_EVENTPATH /* also introduced in 1.15 */ qCDebug(qLcTsLib) << "tslib device is" << ts_get_eventpath(m_dev); +#endif m_notify = new QSocketNotifier(ts_fd(m_dev), QSocketNotifier::Read, this); connect(m_notify, &QSocketNotifier::activated, this, &QTsLibMouseHandler::readMouseData); } diff --git a/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/src/platformsupport/kmsconvenience/qkmsdevice.cpp index d9d76c1146..06d1251a65 100644 --- a/src/platformsupport/kmsconvenience/qkmsdevice.cpp +++ b/src/platformsupport/kmsconvenience/qkmsdevice.cpp @@ -355,10 +355,14 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, } qCDebug(qLcKmsDebug) << "Physical size is" << physSize << "mm" << "for output" << connectorName; - const QByteArray formatStr = userConnectorConfig.value(QStringLiteral("format"), QStringLiteral("xrgb8888")) + const QByteArray formatStr = userConnectorConfig.value(QStringLiteral("format"), QString()) .toByteArray().toLower(); uint32_t drmFormat; - if (formatStr == "xrgb8888") { + bool drmFormatExplicit = true; + if (formatStr.isEmpty()) { + drmFormat = DRM_FORMAT_XRGB8888; + drmFormatExplicit = false; + } else if (formatStr == "xrgb8888") { drmFormat = DRM_FORMAT_XRGB8888; } else if (formatStr == "xbgr8888") { drmFormat = DRM_FORMAT_XBGR8888; @@ -381,7 +385,10 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, } else { qWarning("Invalid pixel format \"%s\" for output %s", formatStr.constData(), connectorName.constData()); drmFormat = DRM_FORMAT_XRGB8888; + drmFormatExplicit = false; } + qCDebug(qLcKmsDebug) << "Format is" << Qt::hex << drmFormat << Qt::dec << "requested_by_user =" << drmFormatExplicit + << "for output" << connectorName; const QString cloneSource = userConnectorConfig.value(QStringLiteral("clones")).toString(); if (!cloneSource.isEmpty()) @@ -427,6 +434,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, output.forced_plane_id = 0; output.forced_plane_set = false; output.drm_format = drmFormat; + output.drm_format_requested_by_user = drmFormatExplicit; output.clone_source = cloneSource; output.size = framebufferSize; diff --git a/src/platformsupport/kmsconvenience/qkmsdevice_p.h b/src/platformsupport/kmsconvenience/qkmsdevice_p.h index 77070c293d..b1150e2875 100644 --- a/src/platformsupport/kmsconvenience/qkmsdevice_p.h +++ b/src/platformsupport/kmsconvenience/qkmsdevice_p.h @@ -202,6 +202,7 @@ struct QKmsOutput uint32_t forced_plane_id = 0; bool forced_plane_set = false; uint32_t drm_format = DRM_FORMAT_XRGB8888; + bool drm_format_requested_by_user = false; QString clone_source; QVector<QKmsPlane> available_planes; struct QKmsPlane *eglfs_plane = nullptr; |