diff options
Diffstat (limited to 'src/platformsupport')
30 files changed, 309 insertions, 213 deletions
diff --git a/src/platformsupport/eglconvenience/qeglconvenience.cpp b/src/platformsupport/eglconvenience/qeglconvenience.cpp index 5ee4773b70..5303d37cee 100644 --- a/src/platformsupport/eglconvenience/qeglconvenience.cpp +++ b/src/platformsupport/eglconvenience/qeglconvenience.cpp @@ -281,11 +281,11 @@ EGLConfig QEglConfigChooser::chooseConfig() } configureAttributes.append(EGL_NONE); - EGLConfig cfg = 0; + EGLConfig cfg = nullptr; do { // Get the number of matching configurations for this set of properties. EGLint matching = 0; - if (!eglChooseConfig(display(), configureAttributes.constData(), 0, 0, &matching) || !matching) + if (!eglChooseConfig(display(), configureAttributes.constData(), nullptr, 0, &matching) || !matching) continue; // Fetch all of the matching configurations and find the @@ -450,7 +450,7 @@ static struct AttrInfo attrs[] = { {EGL_BIND_TO_TEXTURE_RGBA, "EGL_BIND_TO_TEXTURE_RGBA"}, {EGL_MIN_SWAP_INTERVAL, "EGL_MIN_SWAP_INTERVAL"}, {EGL_MAX_SWAP_INTERVAL, "EGL_MAX_SWAP_INTERVAL"}, - {-1, 0}}; + {-1, nullptr}}; void q_printEglConfig(EGLDisplay display, EGLConfig config) { diff --git a/src/platformsupport/eglconvenience/qeglpbuffer_p.h b/src/platformsupport/eglconvenience/qeglpbuffer_p.h index 8ad2eb7248..a137d0d328 100644 --- a/src/platformsupport/eglconvenience/qeglpbuffer_p.h +++ b/src/platformsupport/eglconvenience/qeglpbuffer_p.h @@ -60,7 +60,7 @@ class QEGLPbuffer : public QPlatformOffscreenSurface { public: QEGLPbuffer(EGLDisplay display, const QSurfaceFormat &format, QOffscreenSurface *offscreenSurface, - QEGLPlatformContext::Flags flags = nullptr); + QEGLPlatformContext::Flags flags = { }); ~QEGLPbuffer(); QSurfaceFormat format() const override { return m_format; } diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp index 94def16748..63cf771f32 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp +++ b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp @@ -137,7 +137,7 @@ void QEGLPlatformContext::init(const QSurfaceFormat &format, QPlatformOpenGLCont m_format = q_glFormatFromConfig(m_eglDisplay, m_eglConfig, format); // m_format now has the renderableType() resolved (it cannot be Default anymore) // but does not yet contain version, profile, options. - m_shareContext = share ? static_cast<QEGLPlatformContext *>(share)->m_eglContext : 0; + m_shareContext = share ? static_cast<QEGLPlatformContext *>(share)->m_eglContext : nullptr; QVector<EGLint> contextAttrs; contextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); @@ -194,8 +194,8 @@ void QEGLPlatformContext::init(const QSurfaceFormat &format, QPlatformOpenGLCont eglBindAPI(m_api); m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, m_shareContext, contextAttrs.constData()); if (m_eglContext == EGL_NO_CONTEXT && m_shareContext != EGL_NO_CONTEXT) { - m_shareContext = 0; - m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, 0, contextAttrs.constData()); + m_shareContext = nullptr; + m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, nullptr, contextAttrs.constData()); } if (m_eglContext == EGL_NO_CONTEXT) { @@ -218,7 +218,7 @@ void QEGLPlatformContext::adopt(const QVariant &nativeHandle, QPlatformOpenGLCon qWarning("QEGLPlatformContext: Requires a QEGLNativeContext"); return; } - QEGLNativeContext handle = nativeHandle.value<QEGLNativeContext>(); + QEGLNativeContext handle = qvariant_cast<QEGLNativeContext>(nativeHandle); EGLContext context = handle.context(); if (!context) { qWarning("QEGLPlatformContext: No EGLContext given"); @@ -262,7 +262,7 @@ void QEGLPlatformContext::adopt(const QVariant &nativeHandle, QPlatformOpenGLCon } m_eglContext = context; - m_shareContext = share ? static_cast<QEGLPlatformContext *>(share)->m_eglContext : 0; + m_shareContext = share ? static_cast<QEGLPlatformContext *>(share)->m_eglContext : nullptr; updateFormatFromGL(); } @@ -326,7 +326,7 @@ void QEGLPlatformContext::updateFormatFromGL() EGLBoolean ok = eglMakeCurrent(m_eglDisplay, tempSurface, tempSurface, m_eglContext); if (!ok) { EGLConfig config = q_configFromGLFormat(m_eglDisplay, m_format, false, EGL_PBUFFER_BIT); - tempContext = eglCreateContext(m_eglDisplay, config, 0, m_contextAttrs.constData()); + tempContext = eglCreateContext(m_eglDisplay, config, nullptr, m_contextAttrs.constData()); if (tempContext != EGL_NO_CONTEXT) ok = eglMakeCurrent(m_eglDisplay, tempSurface, tempSurface, tempContext); } diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext_p.h b/src/platformsupport/eglconvenience/qeglplatformcontext_p.h index ed77c57df5..f0388cd29c 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcontext_p.h +++ b/src/platformsupport/eglconvenience/qeglplatformcontext_p.h @@ -69,7 +69,7 @@ public: QEGLPlatformContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display, EGLConfig *config = nullptr, const QVariant &nativeHandle = QVariant(), - Flags flags = nullptr); + Flags flags = { }); ~QEGLPlatformContext(); void initialize() override; diff --git a/src/platformsupport/eventdispatchers/qwindowsguieventdispatcher.cpp b/src/platformsupport/eventdispatchers/qwindowsguieventdispatcher.cpp index a37547f513..20cfb5155e 100644 --- a/src/platformsupport/eventdispatchers/qwindowsguieventdispatcher.cpp +++ b/src/platformsupport/eventdispatchers/qwindowsguieventdispatcher.cpp @@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE */ QWindowsGuiEventDispatcher::QWindowsGuiEventDispatcher(QObject *parent) : - QEventDispatcherWin32(parent), m_flags(0) + QEventDispatcherWin32(parent) { setObjectName(QStringLiteral("QWindowsGuiEventDispatcher")); createInternalHwnd(); // QTBUG-40881: Do not delay registering timers, etc. for QtMfc. diff --git a/src/platformsupport/fbconvenience/qfbscreen.cpp b/src/platformsupport/fbconvenience/qfbscreen.cpp index c42fd879f8..76984dfe5c 100644 --- a/src/platformsupport/fbconvenience/qfbscreen.cpp +++ b/src/platformsupport/fbconvenience/qfbscreen.cpp @@ -255,7 +255,7 @@ QFbWindow *QFbScreen::windowForId(WId wid) const QFbScreen::Flags QFbScreen::flags() const { - return 0; + return { }; } QT_END_NAMESPACE diff --git a/src/platformsupport/fbconvenience/qfbvthandler.cpp b/src/platformsupport/fbconvenience/qfbvthandler.cpp index 7bb9e28ac2..8aab0bada4 100644 --- a/src/platformsupport/fbconvenience/qfbvthandler.cpp +++ b/src/platformsupport/fbconvenience/qfbvthandler.cpp @@ -70,6 +70,10 @@ QT_BEGIN_NAMESPACE #ifdef VTH_ENABLED static void setTTYCursor(bool enable) { + static bool ignore = qEnvironmentVariableIntValue("QT_QPA_PRESERVE_CONSOLE_STATE"); + if (ignore) + return; + const char * const devs[] = { "/dev/tty0", "/dev/tty", "/dev/console", 0 }; int fd = -1; for (const char * const *dev = devs; *dev; ++dev) { diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp index 48b5a74a9e..7af5490963 100644 --- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp +++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp @@ -360,7 +360,7 @@ Q_STATIC_ASSERT(sizeof(capabilityForWritingSystem) / sizeof(*capabilityForWritin static const char *getFcFamilyForStyleHint(const QFont::StyleHint style) { - const char *stylehint = 0; + const char *stylehint = nullptr; switch (style) { case QFont::SansSerif: stylehint = "sans-serif"; @@ -394,7 +394,7 @@ static void populateFromPattern(FcPattern *pattern) { QString familyName; QString familyNameLang; - FcChar8 *value = 0; + FcChar8 *value = nullptr; int weight_value; int slant_value; int spacing_value; @@ -417,7 +417,7 @@ static void populateFromPattern(FcPattern *pattern) slant_value = FC_SLANT_ROMAN; weight_value = FC_WEIGHT_REGULAR; spacing_value = FC_PROPORTIONAL; - file_value = 0; + file_value = nullptr; indexValue = 0; scalable = FcTrue; @@ -431,20 +431,20 @@ static void populateFromPattern(FcPattern *pattern) if (FcPatternGetInteger(pattern, FC_SPACING, 0, &spacing_value) != FcResultMatch) spacing_value = FC_PROPORTIONAL; if (FcPatternGetString(pattern, FC_FILE, 0, &file_value) != FcResultMatch) - file_value = 0; + file_value = nullptr; if (FcPatternGetInteger(pattern, FC_INDEX, 0, &indexValue) != FcResultMatch) indexValue = 0; if (FcPatternGetBool(pattern, FC_SCALABLE, 0, &scalable) != FcResultMatch) scalable = FcTrue; if (FcPatternGetString(pattern, FC_FOUNDRY, 0, &foundry_value) != FcResultMatch) - foundry_value = 0; + foundry_value = nullptr; if (FcPatternGetString(pattern, FC_STYLE, 0, &style_value) != FcResultMatch) - style_value = 0; + style_value = nullptr; if (FcPatternGetBool(pattern,FC_ANTIALIAS,0,&antialias) != FcResultMatch) antialias = true; QSupportedWritingSystems writingSystems; - FcLangSet *langset = 0; + FcLangSet *langset = nullptr; FcResult res = FcPatternGetLangSet(pattern, FC_LANG, 0, &langset); if (res == FcResultMatch) { bool hasLang = false; @@ -461,7 +461,7 @@ static void populateFromPattern(FcPattern *pattern) if (*capabilityForWritingSystem[j] && requiresOpenType(j)) { if (cap == nullptr) capRes = FcPatternGetString(pattern, FC_CAPABILITY, 0, &cap); - if (capRes == FcResultMatch && strstr(reinterpret_cast<const char *>(cap), capabilityForWritingSystem[j]) == 0) + if (capRes == FcResultMatch && strstr(reinterpret_cast<const char *>(cap), capabilityForWritingSystem[j]) == nullptr) continue; } #endif @@ -546,14 +546,14 @@ void QFontconfigDatabase::populateFontDatabase() #if FC_VERSION >= 20297 FC_CAPABILITY, #endif - (const char *)0 + (const char *)nullptr }; const char **p = properties; while (*p) { FcObjectSetAdd(os, *p); ++p; } - fonts = FcFontList(0, pattern, os); + fonts = FcFontList(nullptr, pattern, os); FcObjectSetDestroy(os); FcPatternDestroy(pattern); } @@ -572,7 +572,7 @@ void QFontconfigDatabase::populateFontDatabase() { "Serif", "serif", false }, { "Sans Serif", "sans-serif", false }, { "Monospace", "monospace", true }, - { 0, 0, false } + { nullptr, nullptr, false } }; const FcDefaultFont *f = defaults; // aliases only make sense for 'common', not for any of the specials @@ -581,9 +581,9 @@ void QFontconfigDatabase::populateFontDatabase() while (f->qtname) { QString familyQtName = QString::fromLatin1(f->qtname); - registerFont(familyQtName,QString(),QString(),QFont::Normal,QFont::StyleNormal,QFont::Unstretched,true,true,0,f->fixed,ws,0); - registerFont(familyQtName,QString(),QString(),QFont::Normal,QFont::StyleItalic,QFont::Unstretched,true,true,0,f->fixed,ws,0); - registerFont(familyQtName,QString(),QString(),QFont::Normal,QFont::StyleOblique,QFont::Unstretched,true,true,0,f->fixed,ws,0); + registerFont(familyQtName,QString(),QString(),QFont::Normal,QFont::StyleNormal,QFont::Unstretched,true,true,0,f->fixed,ws,nullptr); + registerFont(familyQtName,QString(),QString(),QFont::Normal,QFont::StyleItalic,QFont::Unstretched,true,true,0,f->fixed,ws,nullptr); + registerFont(familyQtName,QString(),QString(),QFont::Normal,QFont::StyleOblique,QFont::Unstretched,true,true,0,f->fixed,ws,nullptr); ++f; } @@ -599,7 +599,7 @@ void QFontconfigDatabase::populateFontDatabase() void QFontconfigDatabase::invalidate() { // Clear app fonts. - FcConfigAppFontClear(0); + FcConfigAppFontClear(nullptr); } QFontEngineMulti *QFontconfigDatabase::fontEngineMulti(QFontEngine *fontEngine, QChar::Script script) @@ -691,7 +691,7 @@ QFontEngine::SubpixelAntialiasingType subpixelTypeFromMatch(FcPattern *match, bo QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, void *usrPtr) { if (!usrPtr) - return 0; + return nullptr; FontFile *fontfile = static_cast<FontFile *> (usrPtr); QFontEngine::FaceId fid; @@ -706,7 +706,7 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, void *usrPtr) if (!engine->init(fid, engine->antialias, engine->defaultFormat) || engine->invalid()) { delete engine; - engine = 0; + engine = nullptr; } return engine; @@ -715,8 +715,8 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, void *usrPtr) QFontEngine *QFontconfigDatabase::fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) { QFontEngineFT *engine = static_cast<QFontEngineFT*>(QFreeTypeFontDatabase::fontEngine(fontData, pixelSize, hintingPreference)); - if (engine == 0) - return 0; + if (engine == nullptr) + return nullptr; setupFontEngine(engine, engine->fontDef); @@ -757,7 +757,7 @@ QStringList QFontconfigDatabase::fallbacksForFamily(const QString &family, QFont // while a Japanese font should be used for that if LANG=ja) FcPattern *dummy = FcPatternCreate(); FcDefaultSubstitute(dummy); - FcChar8 *lang = 0; + FcChar8 *lang = nullptr; FcResult res = FcPatternGetString(dummy, FC_LANG, 0, &lang); if (res == FcResultMatch) FcPatternAddString(pattern, FC_LANG, lang); @@ -770,11 +770,11 @@ QStringList QFontconfigDatabase::fallbacksForFamily(const QString &family, QFont FcPatternAddWeak(pattern, FC_FAMILY, value, FcTrue); } - FcConfigSubstitute(0, pattern, FcMatchPattern); + FcConfigSubstitute(nullptr, pattern, FcMatchPattern); FcDefaultSubstitute(pattern); FcResult result = FcResultMatch; - FcFontSet *fontSet = FcFontSort(0,pattern,FcFalse,0,&result); + FcFontSet *fontSet = FcFontSort(nullptr,pattern,FcFalse,nullptr,&result); FcPatternDestroy(pattern); if (fontSet) { @@ -782,7 +782,7 @@ QStringList QFontconfigDatabase::fallbacksForFamily(const QString &family, QFont duplicates.reserve(fontSet->nfont + 1); duplicates.insert(family.toCaseFolded()); for (int i = 0; i < fontSet->nfont; i++) { - FcChar8 *value = 0; + FcChar8 *value = nullptr; if (FcPatternGetString(fontSet->fonts[i], FC_FAMILY, 0, &value) != FcResultMatch) continue; // capitalize(value); @@ -811,7 +811,7 @@ static FcPattern *queryFont(const FcChar8 *file, const QByteArray &data, int id, FT_Library lib = qt_getFreetype(); - FcPattern *pattern = 0; + FcPattern *pattern = nullptr; FT_Face face; if (!FT_New_Memory_Face(lib, (const FT_Byte *)data.constData(), data.size(), id, &face)) { @@ -830,16 +830,16 @@ QStringList QFontconfigDatabase::addApplicationFont(const QByteArray &fontData, { QStringList families; - FcFontSet *set = FcConfigGetFonts(0, FcSetApplication); + FcFontSet *set = FcConfigGetFonts(nullptr, FcSetApplication); if (!set) { - FcConfigAppFontAddFile(0, (const FcChar8 *)":/non-existent"); - set = FcConfigGetFonts(0, FcSetApplication); // try again + FcConfigAppFontAddFile(nullptr, (const FcChar8 *)":/non-existent"); + set = FcConfigGetFonts(nullptr, FcSetApplication); // try again if (!set) return families; } int id = 0; - FcBlanks *blanks = FcConfigGetBlanks(0); + FcBlanks *blanks = FcConfigGetBlanks(nullptr); int count = 0; FcPattern *pattern; @@ -849,7 +849,7 @@ QStringList QFontconfigDatabase::addApplicationFont(const QByteArray &fontData, if (!pattern) return families; - FcChar8 *fam = 0; + FcChar8 *fam = nullptr; if (FcPatternGetString(pattern, FC_FAMILY, 0, &fam) == FcResultMatch) { QString family = QString::fromUtf8(reinterpret_cast<const char *>(fam)); families << family; @@ -877,10 +877,10 @@ QString QFontconfigDatabase::resolveFontFamilyAlias(const QString &family) const const QByteArray cs = family.toUtf8(); FcPatternAddString(pattern, FC_FAMILY, (const FcChar8 *) cs.constData()); } - FcConfigSubstitute(0, pattern, FcMatchPattern); + FcConfigSubstitute(nullptr, pattern, FcMatchPattern); FcDefaultSubstitute(pattern); - FcChar8 *familyAfterSubstitution = 0; + FcChar8 *familyAfterSubstitution = nullptr; FcPatternGetString(pattern, FC_FAMILY, 0, &familyAfterSubstitution); resolved = QString::fromUtf8((const char *) familyAfterSubstitution); FcPatternDestroy(pattern); @@ -895,7 +895,7 @@ QFont QFontconfigDatabase::defaultFont() const // or https://bugs.freedesktop.org/show_bug.cgi?id=35482 is fixed FcPattern *dummy = FcPatternCreate(); FcDefaultSubstitute(dummy); - FcChar8 *lang = 0; + FcChar8 *lang = nullptr; FcResult res = FcPatternGetString(dummy, FC_LANG, 0, &lang); FcPattern *pattern = FcPatternCreate(); @@ -904,10 +904,10 @@ QFont QFontconfigDatabase::defaultFont() const // certain FC_LANG based custom rules may happen in FcConfigSubstitute() FcPatternAddString(pattern, FC_LANG, lang); } - FcConfigSubstitute(0, pattern, FcMatchPattern); + FcConfigSubstitute(nullptr, pattern, FcMatchPattern); FcDefaultSubstitute(pattern); - FcChar8 *familyAfterSubstitution = 0; + FcChar8 *familyAfterSubstitution = nullptr; FcPatternGetString(pattern, FC_FAMILY, 0, &familyAfterSubstitution); QString resolved = QString::fromUtf8((const char *) familyAfterSubstitution); FcPatternDestroy(pattern); @@ -964,10 +964,10 @@ void QFontconfigDatabase::setupFontEngine(QFontEngineFT *engine, const QFontDef FcResult result; - FcConfigSubstitute(0, pattern, FcMatchPattern); + FcConfigSubstitute(nullptr, pattern, FcMatchPattern); FcDefaultSubstitute(pattern); - FcPattern *match = FcFontMatch(0, pattern, &result); + FcPattern *match = FcFontMatch(nullptr, pattern, &result); if (match) { engine->setDefaultHintStyle(defaultHintStyleFromMatch((QFont::HintingPreference)fontDef.hintingPreference, match, useXftConf)); diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig.cpp index 2fbcb6216e..cbf0793d75 100644 --- a/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig.cpp +++ b/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig.cpp @@ -60,7 +60,7 @@ bool QFontEngineMultiFontConfig::shouldLoadFontEngineForCharacter(int at, uint u { bool charSetHasChar = true; FcPattern *matchPattern = getMatchPatternForFallback(at - 1); - if (matchPattern != 0) { + if (matchPattern != nullptr) { FcCharSet *charSet; FcPatternGetCharSet(matchPattern, FC_CHARSET, 0, &charSet); charSetHasChar = FcCharSetHasChar(charSet, ucs4); @@ -85,7 +85,7 @@ FcPattern * QFontEngineMultiFontConfig::getMatchPatternForFallback(int fallBackI value.u.s = reinterpret_cast<const FcChar8 *>(cs.data()); FcPatternAdd(requestPattern, FC_FAMILY, value, true); FcResult result; - ret = FcFontMatch(0, requestPattern, &result); + ret = FcFontMatch(nullptr, requestPattern, &result); cachedMatchPatterns.insert(fallBackIndex, ret); FcPatternDestroy(requestPattern); return ret; diff --git a/src/platformsupport/fontdatabases/fontdatabases.pro b/src/platformsupport/fontdatabases/fontdatabases.pro index f2bac9ab94..c3985ed398 100644 --- a/src/platformsupport/fontdatabases/fontdatabases.pro +++ b/src/platformsupport/fontdatabases/fontdatabases.pro @@ -17,9 +17,10 @@ qtConfig(freetype) { unix { include($$PWD/genericunix/genericunix.pri) - qtConfig(fontconfig) { - include($$PWD/fontconfig/fontconfig.pri) - } +} + +qtConfig(fontconfig) { + include($$PWD/fontconfig/fontconfig.pri) } win32:!winrt { diff --git a/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp b/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp index 10f17f0258..ca78063f08 100644 --- a/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp +++ b/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp @@ -121,7 +121,7 @@ class QtFreetypeData { public: QtFreetypeData() - : library(0) + : library(nullptr) { } ~QtFreetypeData(); @@ -135,7 +135,7 @@ QtFreetypeData::~QtFreetypeData() iter.value()->cleanup(); faces.clear(); FT_Done_FreeType(library); - library = 0; + library = nullptr; } Q_GLOBAL_STATIC(QThreadStorage<QtFreetypeData *>, theFreetypeData) @@ -215,7 +215,7 @@ QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id, const QByteArray &fontData) { if (face_id.filename.isEmpty() && fontData.isEmpty()) - return 0; + return nullptr; QtFreetypeData *freetypeData = qt_getFreetypeData(); @@ -238,7 +238,7 @@ QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id, } else if (!QFileInfo(fileName).isNativePath()) { QFile file(fileName); if (!file.open(QIODevice::ReadOnly)) { - return 0; + return nullptr; } newFreetype->fontData = file.readAll(); } @@ -247,10 +247,10 @@ QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id, } if (!newFreetype->fontData.isEmpty()) { if (FT_New_Memory_Face(freetypeData->library, (const FT_Byte *)newFreetype->fontData.constData(), newFreetype->fontData.size(), face_id.index, &face)) { - return 0; + return nullptr; } } else if (FT_New_Face(freetypeData->library, face_id.filename, face_id.index, &face)) { - return 0; + return nullptr; } newFreetype->face = face; @@ -261,8 +261,8 @@ QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id, newFreetype->matrix.yy = 0x10000; newFreetype->matrix.xy = 0; newFreetype->matrix.yx = 0; - newFreetype->unicode_map = 0; - newFreetype->symbol_map = 0; + newFreetype->unicode_map = nullptr; + newFreetype->symbol_map = nullptr; memset(newFreetype->cmapCache, 0, sizeof(newFreetype->cmapCache)); @@ -307,7 +307,7 @@ void QFreetypeFace::cleanup() { hbFace.reset(); FT_Done_Face(face); - face = 0; + face = nullptr; } void QFreetypeFace::release(const QFontEngine::FaceId &face_id) @@ -324,7 +324,7 @@ void QFreetypeFace::release(const QFontEngine::FaceId &face_id) if (freetypeData->faces.isEmpty()) { FT_Done_FreeType(freetypeData->library); - freetypeData->library = 0; + freetypeData->library = nullptr; } } @@ -659,7 +659,7 @@ QFontEngineFT *QFontEngineFT::create(const QByteArray &fontData, qreal pixelSize QFontEngineFTRawData *fe = new QFontEngineFTRawData(fontDef); if (!fe->initFromData(fontData)) { delete fe; - return 0; + return nullptr; } fe->updateFamilyNameAndStyle(); @@ -682,7 +682,7 @@ QFontEngineFT::QFontEngineFT(const QFontDef &fd) embolden = false; obliquen = false; antialias = true; - freetype = 0; + freetype = nullptr; default_load_flags = FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH; default_hint_style = ftInitialDefaultHintStyle; subpixelType = Subpixel_None; @@ -729,7 +729,7 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format, face_id = faceId; - symbol = freetype->symbol_map != 0; + symbol = freetype->symbol_map != nullptr; PS_FontInfoRec psrec; // don't assume that type1 fonts are symbol fonts by default if (FT_Get_PS_Font_Info(freetype->face, &psrec) == FT_Err_Ok) { @@ -744,12 +744,12 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format, bool fake_oblique = (fontDef.style != QFont::StyleNormal) && !(face->style_flags & FT_STYLE_FLAG_ITALIC); if (fake_oblique) obliquen = true; - FT_Set_Transform(face, &matrix, 0); + FT_Set_Transform(face, &matrix, nullptr); freetype->matrix = matrix; // fake bold if ((fontDef.weight >= QFont::Bold) && !(face->style_flags & FT_STYLE_FLAG_BOLD) && !FT_IS_FIXED_WIDTH(face)) { if (const TT_OS2 *os2 = reinterpret_cast<const TT_OS2 *>(FT_Get_Sfnt_Table(face, ft_sfnt_os2))) { - if (os2->usWeightClass < 750) + if (os2->usWeightClass < 700) embolden = true; } } @@ -953,7 +953,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, format = defaultFormat != Format_None ? defaultFormat : Format_Mono; Q_ASSERT(format != Format_None); - Glyph *g = set ? set->getGlyph(glyph, subPixelPosition) : 0; + Glyph *g = set ? set->getGlyph(glyph, subPixelPosition) : nullptr; if (g && g->format == format && (fetchMetricsOnly || g->data)) return g; @@ -1051,10 +1051,10 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, // If any of the metrics are too large to fit, don't cache them if (areMetricsTooLarge(info)) - return 0; + return nullptr; g = new Glyph; - g->data = 0; + g->data = nullptr; g->linearAdvance = info.linearAdvance; g->width = info.width; g->height = info.height; @@ -1176,12 +1176,12 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, convertRGBToARGB_V(slot->bitmap.buffer, (uint *)glyph_buffer.data(), info.width, info.height, slot->bitmap.pitch, subpixelType != Subpixel_VRGB); } else { qWarning("QFontEngine: Glyph rendered in unknown pixel_mode=%d", slot->bitmap.pixel_mode); - return 0; + return nullptr; } if (!g) { g = new Glyph; - g->data = 0; + g->data = nullptr; } g->linearAdvance = info.linearAdvance; @@ -1385,7 +1385,7 @@ QFontEngineFT::QGlyphSet *QFontEngineFT::TransformedGlyphSets::findSet(const QTr gs->clear(); gs->transformationMatrix = m; gs->outline_drawing = fontDef.pixelSize * fontDef.pixelSize * qAbs(matrix.determinant()) > QT_MAX_CACHED_GLYPH_SIZE * QT_MAX_CACHED_GLYPH_SIZE; - Q_ASSERT(gs != 0); + Q_ASSERT(gs != nullptr); return gs; } @@ -1416,7 +1416,7 @@ QFontEngineFT::QGlyphSet *QFontEngineFT::loadGlyphSet(const QTransform &matrix) void QFontEngineFT::getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics) { FT_Face face = lockFace(Unscaled); - FT_Set_Transform(face, 0, 0); + FT_Set_Transform(face, nullptr, nullptr); FT_Load_Glyph(face, glyph, FT_LOAD_NO_BITMAP); int left = face->glyph->metrics.horiBearingX; @@ -1439,7 +1439,7 @@ void QFontEngineFT::getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_me else QFreetypeFace::addGlyphToPath(face, face->glyph, p, path, face->units_per_EM << 6, face->units_per_EM << 6); - FT_Set_Transform(face, &freetype->matrix, 0); + FT_Set_Transform(face, &freetype->matrix, nullptr); unlockFace(); } @@ -1637,10 +1637,10 @@ glyph_metrics_t QFontEngineFT::scaledBitmapMetrics(const glyph_metrics_t &m, con void QFontEngineFT::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlags flags) const { - FT_Face face = 0; + FT_Face face = nullptr; bool design = shouldUseDesignMetrics(flags); for (int i = 0; i < glyphs->numGlyphs; i++) { - Glyph *g = cacheEnabled ? defaultGlyphSet.getGlyph(glyphs->glyphs[i]) : 0; + Glyph *g = cacheEnabled ? defaultGlyphSet.getGlyph(glyphs->glyphs[i]) : nullptr; // Since we are passing Format_None to loadGlyph, use same default format logic as loadGlyph GlyphFormat acceptableFormat = (defaultFormat != Format_None) ? defaultFormat : Format_Mono; if (g && g->format == acceptableFormat) { @@ -1648,7 +1648,7 @@ void QFontEngineFT::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlag } else { if (!face) face = lockFace(); - g = loadGlyph(cacheEnabled ? &defaultGlyphSet : 0, glyphs->glyphs[i], 0, Format_None, true); + g = loadGlyph(cacheEnabled ? &defaultGlyphSet : nullptr, glyphs->glyphs[i], 0, Format_None, true); if (g) glyphs->advances[i] = design ? QFixed::fromFixed(g->linearAdvance) : QFixed(g->advance); else @@ -1672,7 +1672,7 @@ void QFontEngineFT::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlag glyph_metrics_t QFontEngineFT::boundingBox(const QGlyphLayout &glyphs) { - FT_Face face = 0; + FT_Face face = nullptr; glyph_metrics_t overall; // initialize with line height, we get the same behaviour on all platforms @@ -1687,11 +1687,11 @@ glyph_metrics_t QFontEngineFT::boundingBox(const QGlyphLayout &glyphs) QFixed ymax = 0; QFixed xmax = 0; for (int i = 0; i < glyphs.numGlyphs; i++) { - Glyph *g = cacheEnabled ? defaultGlyphSet.getGlyph(glyphs.glyphs[i]) : 0; + Glyph *g = cacheEnabled ? defaultGlyphSet.getGlyph(glyphs.glyphs[i]) : nullptr; if (!g) { if (!face) face = lockFace(); - g = loadGlyph(cacheEnabled ? &defaultGlyphSet : 0, glyphs.glyphs[i], 0, Format_None, true); + g = loadGlyph(cacheEnabled ? &defaultGlyphSet : nullptr, glyphs.glyphs[i], 0, Format_None, true); } if (g) { QFixed x = overall.xoff + glyphs.offsets[i].x + g->x; @@ -1731,12 +1731,12 @@ glyph_metrics_t QFontEngineFT::boundingBox(const QGlyphLayout &glyphs) glyph_metrics_t QFontEngineFT::boundingBox(glyph_t glyph) { - FT_Face face = 0; + FT_Face face = nullptr; glyph_metrics_t overall; - Glyph *g = cacheEnabled ? defaultGlyphSet.getGlyph(glyph) : 0; + Glyph *g = cacheEnabled ? defaultGlyphSet.getGlyph(glyph) : nullptr; if (!g) { face = lockFace(); - g = loadGlyph(cacheEnabled ? &defaultGlyphSet : 0, glyph, 0, Format_None, true); + g = loadGlyph(cacheEnabled ? &defaultGlyphSet : nullptr, glyph, 0, Format_None, true); } if (g) { overall.x = g->x; @@ -1869,10 +1869,10 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyphFor(glyph_t g, bool disableOutlineDrawing) { QGlyphSet *glyphSet = loadGlyphSet(t); - if (glyphSet != 0 && glyphSet->outline_drawing && !disableOutlineDrawing && !fetchBoundingBox) - return 0; + if (glyphSet != nullptr && glyphSet->outline_drawing && !disableOutlineDrawing && !fetchBoundingBox) + return nullptr; - Glyph *glyph = glyphSet != 0 ? glyphSet->getGlyph(g, subPixelPosition) : 0; + Glyph *glyph = glyphSet != nullptr ? glyphSet->getGlyph(g, subPixelPosition) : nullptr; if (!glyph || glyph->format != format || (!fetchBoundingBox && !glyph->data)) { QScopedValueRollback<HintStyle> saved_default_hint_style(default_hint_style); if (t.type() >= QTransform::TxScale && !is2dRotation(t)) @@ -1880,7 +1880,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyphFor(glyph_t g, lockFace(); FT_Matrix m = this->matrix; - FT_Matrix ftMatrix = glyphSet != 0 ? glyphSet->transformationMatrix : QTransformToFTMatrix(t); + FT_Matrix ftMatrix = glyphSet != nullptr ? glyphSet->transformationMatrix : QTransformToFTMatrix(t); FT_Matrix_Multiply(&ftMatrix, &m); freetype->matrix = m; glyph = loadGlyph(glyphSet, g, subPixelPosition, format, false, disableOutlineDrawing); @@ -1993,7 +1993,7 @@ FT_Face QFontEngineFT::lockFace(Scaling scale) const freetype->matrix.xy != matrix.xy || freetype->matrix.yx != matrix.yx) { freetype->matrix = matrix; - FT_Set_Transform(face, &freetype->matrix, 0); + FT_Set_Transform(face, &freetype->matrix, nullptr); } return face; @@ -2032,7 +2032,7 @@ void QFontEngineFT::QGlyphSet::clear() for (int i = 0; i < 256; ++i) { if (fast_glyph_data[i]) { delete fast_glyph_data[i]; - fast_glyph_data[i] = 0; + fast_glyph_data[i] = nullptr; } } fast_glyph_count = 0; @@ -2046,7 +2046,7 @@ void QFontEngineFT::QGlyphSet::removeGlyphFromCache(glyph_t index, QFixed subPix if (useFastGlyphData(index, subPixelPosition)) { if (fast_glyph_data[index]) { delete fast_glyph_data[index]; - fast_glyph_data[index] = 0; + fast_glyph_data[index] = nullptr; if (fast_glyph_count > 0) --fast_glyph_count; } @@ -2071,7 +2071,7 @@ int QFontEngineFT::getPointInOutline(glyph_t glyph, int flags, quint32 point, QF lockFace(); bool hsubpixel = true; int vfactor = 1; - int load_flags = loadFlags(0, Format_A8, flags, hsubpixel, vfactor); + int load_flags = loadFlags(nullptr, Format_A8, flags, hsubpixel, vfactor); int result = freetype->getPointInOutline(glyph, load_flags, point, xpos, ypos, nPoints); unlockFace(); return result; @@ -2106,7 +2106,7 @@ QFontEngine *QFontEngineFT::cloneWithSize(qreal pixelSize) const QFontEngineFT *fe = new QFontEngineFT(fontDef); if (!fe->initFromFontEngine(this)) { delete fe; - return 0; + return nullptr; } else { return fe; } diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index daa3dc94ea..894919a1c8 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -374,17 +374,6 @@ QFontEngine *QCoreTextFontDatabaseEngineFactory<QCoreTextFontEngine>::fontEngine QCFType<CTFontDescriptorRef> descriptor = QCFType<CTFontDescriptorRef>::constructFromGet( static_cast<CTFontDescriptorRef>(usrPtr)); - // CoreText will sometimes invalidate information in font descriptors that refer - // to system fonts in certain function calls or application states. While the descriptor - // looks the same from the outside, some internal plumbing is different, causing the results - // of creating CTFonts from those descriptors unreliable. The work-around for this - // is to copy the attributes of those descriptors each time we make a new CTFont - // from them instead of referring to the original, as that may trigger the CoreText bug. - if (m_systemFontDescriptors.contains(descriptor)) { - QCFType<CFDictionaryRef> attributes = CTFontDescriptorCopyAttributes(descriptor); - descriptor = CTFontDescriptorCreateWithAttributes(attributes); - } - // Since we do not pass in the destination DPI to CoreText when making // the font, we need to pass in a point size which is scaled to include // the DPI. The default DPI for the screen is 72, thus the scale factor diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm index 072dd1a28a..30c80ebd86 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm @@ -471,7 +471,7 @@ void QCoreTextFontEngine::draw(CGContextRef ctx, qreal x, qreal y, const QTextIt const qreal firstY = positions[0].y.toReal(); for (int i = 0; i < glyphs.size(); ++i) { cgPositions[i].x = positions[i].x.toReal() - firstX; - cgPositions[i].y = positions[i].y.toReal() - firstY; + cgPositions[i].y = firstY - positions[i].y.toReal(); cgGlyphs[i] = glyphs[i]; } diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp index 011476cf13..36a94724c1 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp @@ -1069,18 +1069,16 @@ static bool addFontToDatabase(QString familyName, QString subFamilyName; QString subFamilyStyle; - if (ttf) { - // Look-up names registered in the font - QFontNames canonicalNames = qt_getCanonicalFontNames(logFont); - if (qt_localizedName(familyName) && !canonicalNames.name.isEmpty()) - englishName = canonicalNames.name; - if (!canonicalNames.preferredName.isEmpty()) { - subFamilyName = familyName; - subFamilyStyle = styleName; - faceName = familyName; // Remember the original name for later lookups - familyName = canonicalNames.preferredName; - styleName = canonicalNames.preferredStyle; - } + // Look-up names registered in the font + QFontNames canonicalNames = qt_getCanonicalFontNames(logFont); + if (qt_localizedName(familyName) && !canonicalNames.name.isEmpty()) + englishName = canonicalNames.name; + if (!canonicalNames.preferredName.isEmpty()) { + subFamilyName = familyName; + subFamilyStyle = styleName; + faceName = familyName; // Remember the original name for later lookups + familyName = canonicalNames.preferredName; + styleName = canonicalNames.preferredStyle; } QSupportedWritingSystems writingSystems; diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp index a6b7fcf31e..5c2742d295 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp @@ -215,17 +215,15 @@ static bool addFontToDatabase(QString familyName, QString subFamilyName; QString subFamilyStyle; - if (ttf) { - // Look-up names registered in the font - QFontNames canonicalNames = qt_getCanonicalFontNames(logFont); - if (qt_localizedName(familyName) && !canonicalNames.name.isEmpty()) - englishName = canonicalNames.name; - if (!canonicalNames.preferredName.isEmpty()) { - subFamilyName = familyName; - subFamilyStyle = styleName; - familyName = canonicalNames.preferredName; - styleName = canonicalNames.preferredStyle; - } + // Look-up names registered in the font + QFontNames canonicalNames = qt_getCanonicalFontNames(logFont); + if (qt_localizedName(familyName) && !canonicalNames.name.isEmpty()) + englishName = canonicalNames.name; + if (!canonicalNames.preferredName.isEmpty()) { + subFamilyName = familyName; + subFamilyStyle = styleName; + familyName = canonicalNames.preferredName; + styleName = canonicalNames.preferredStyle; } QSupportedWritingSystems writingSystems; diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp index e796c18e79..5c999f455e 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp @@ -62,6 +62,9 @@ QT_BEGIN_NAMESPACE +// Clang does not consider __declspec(nothrow) as nothrow +QT_WARNING_DISABLE_CLANG("-Wmicrosoft-exception-spec") + // Convert from design units to logical pixels #define DESIGN_TO_LOGICAL(DESIGN_UNIT_VALUE) \ QFixed::fromReal((qreal(DESIGN_UNIT_VALUE) / qreal(m_unitsPerEm)) * fontDef.pixelSize) @@ -458,7 +461,7 @@ bool QWindowsFontEngineDirectWrite::stringToCMap(const QChar *str, int len, QGly glyphs->numGlyphs = actualLength; if (!(flags & GlyphIndicesOnly)) - recalcAdvances(glyphs, 0); + recalcAdvances(glyphs, {}); return true; } @@ -1012,8 +1015,8 @@ glyph_metrics_t QWindowsFontEngineDirectWrite::alphaMapBoundingBox(glyph_t glyph int margin = glyphMargin(QFontEngine::Format_A32); - return glyph_metrics_t(rect.left, - rect.top, + return glyph_metrics_t(rect.left - margin, + rect.top - margin, rect.right - rect.left + margin * 2, rect.bottom - rect.top + margin * 2, bbox.xoff, bbox.yoff); diff --git a/src/platformsupport/glxconvenience/qglxconvenience.cpp b/src/platformsupport/glxconvenience/qglxconvenience.cpp index 81bccb1c25..5387214e8c 100644 --- a/src/platformsupport/glxconvenience/qglxconvenience.cpp +++ b/src/platformsupport/glxconvenience/qglxconvenience.cpp @@ -193,7 +193,7 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , QSurfaceFormat format { QXcbSoftwareOpenGLEnforcer softwareOpenGLEnforcer; - GLXFBConfig config = 0; + GLXFBConfig config = nullptr; do { const QVector<int> spec = qglx_buildSpec(format, drawableBit, flags); @@ -273,7 +273,7 @@ XVisualInfo *qglx_findVisualInfo(Display *display, int screen, QSurfaceFormat *f { Q_ASSERT(format); - XVisualInfo *visualInfo = 0; + XVisualInfo *visualInfo = nullptr; GLXFBConfig config = qglx_findConfig(display, screen, *format, false, drawableBit, flags); if (config) diff --git a/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp b/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp index 6a53ad2088..a729eeb851 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp +++ b/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp @@ -99,8 +99,7 @@ std::unique_ptr<QEvdevMouseHandler> QEvdevMouseHandler::create(const QString &de } QEvdevMouseHandler::QEvdevMouseHandler(const QString &device, int fd, bool abs, bool compression, int jitterLimit) - : m_device(device), m_fd(fd), m_notify(0), m_x(0), m_y(0), m_prevx(0), m_prevy(0), - m_abs(abs), m_compression(compression), m_buttons(0), m_prevInvalid(true) + : m_device(device), m_fd(fd), m_abs(abs), m_compression(compression) { setObjectName(QLatin1String("Evdev Mouse Handler")); diff --git a/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h b/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h index 727f1a02f9..93314e885f 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h +++ b/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h @@ -84,16 +84,16 @@ private: QString m_device; int m_fd; - QSocketNotifier *m_notify; - int m_x, m_y; - int m_prevx, m_prevy; + QSocketNotifier *m_notify = nullptr; + int m_x = 0, m_y = 0; + int m_prevx = 0, m_prevy = 0; bool m_abs; bool m_compression; Qt::MouseButtons m_buttons; Qt::MouseButton m_button; QEvent::Type m_eventType; int m_jitterLimitSquared; - bool m_prevInvalid; + bool m_prevInvalid = true; int m_hardwareWidth; int m_hardwareHeight; qreal m_hardwareScalerY; diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp index c51db59e1f..78728ef4ce 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp +++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp @@ -113,16 +113,13 @@ public: QList<QWindowSystemInterface::TouchPoint> m_lastTouchPoints; struct Contact { - int trackingId; - int x; - int y; - int maj; - int pressure; - Qt::TouchPointState state; + int trackingId = -1; + int x = 0; + int y = 0; + int maj = -1; + int pressure = 0; + Qt::TouchPointState state = Qt::TouchPointPressed; QTouchEvent::TouchPoint::InfoFlags flags; - Contact() : trackingId(-1), - x(0), y(0), maj(-1), pressure(0), - state(Qt::TouchPointPressed), flags(0) { } }; QHash<int, Contact> m_contacts; // The key is a tracking id for type A, slot number for type B. QHash<int, Contact> m_lastContacts; diff --git a/src/platformsupport/input/integrityhid/qintegrityhidmanager.h b/src/platformsupport/input/integrityhid/qintegrityhidmanager.h index 36d7587457..fde5fd7dbb 100644 --- a/src/platformsupport/input/integrityhid/qintegrityhidmanager.h +++ b/src/platformsupport/input/integrityhid/qintegrityhidmanager.h @@ -52,7 +52,7 @@ class QIntegrityHIDManager : public QThread { Q_OBJECT public: - QIntegrityHIDManager(const QString &key, const QString &specification, QObject *parent = 0); + QIntegrityHIDManager(const QString &key, const QString &specification, QObject *parent = nullptr); ~QIntegrityHIDManager(); void run(void); diff --git a/src/platformsupport/input/libinput/qlibinputtouch.cpp b/src/platformsupport/input/libinput/qlibinputtouch.cpp index a65bc91c39..446218e4b3 100644 --- a/src/platformsupport/input/libinput/qlibinputtouch.cpp +++ b/src/platformsupport/input/libinput/qlibinputtouch.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include "qlibinputtouch_p.h" +#include "qtouchoutputmapping_p.h" #include <libinput.h> #include <QtGui/QGuiApplication> #include <QtGui/QScreen> @@ -45,6 +46,8 @@ QT_BEGIN_NAMESPACE +Q_DECLARE_LOGGING_CATEGORY(qLcLibInput) + QWindowSystemInterface::TouchPoint *QLibInputTouch::DeviceState::point(int32_t slot) { const int id = qMax(0, slot); @@ -62,12 +65,23 @@ QLibInputTouch::DeviceState *QLibInputTouch::deviceState(libinput_event_touch *e return &m_devState[dev]; } -static inline QPointF getPos(libinput_event_touch *e) +QPointF QLibInputTouch::getPos(libinput_event_touch *e) { - // TODO Map to correct screen using QTouchOutputMapping. - // Perhaps investigate libinput_device_get_output_name as well. - // For now just use the primary screen. + DeviceState *state = deviceState(e); QScreen *screen = QGuiApplication::primaryScreen(); + if (!state->m_screenName.isEmpty()) { + if (!m_screen) { + const QList<QScreen *> screens = QGuiApplication::screens(); + for (QScreen *s : screens) { + if (s->name() == state->m_screenName) { + m_screen = s; + break; + } + } + } + if (m_screen) + screen = m_screen; + } const QRect geom = QHighDpi::toNativePixels(screen->geometry(), screen); const double x = libinput_event_touch_get_x_transformed(e, geom.width()); const double y = libinput_event_touch_get_y_transformed(e, geom.height()); @@ -76,9 +90,25 @@ static inline QPointF getPos(libinput_event_touch *e) void QLibInputTouch::registerDevice(libinput_device *dev) { + struct udev_device *udev_device; + udev_device = libinput_device_get_udev_device(dev); + QString devNode = QString::fromUtf8(udev_device_get_devnode(udev_device)); + QString devName = QString::fromUtf8(libinput_device_get_name(dev)); + + qCDebug(qLcLibInput, "libinput: registerDevice %s - %s", + qPrintable(devNode), qPrintable(devName)); + + QTouchOutputMapping mapping; + if (mapping.load()) { + m_devState[dev].m_screenName = mapping.screenNameForDeviceNode(devNode); + if (!m_devState[dev].m_screenName.isEmpty()) + qCDebug(qLcLibInput, "libinput: Mapping device %s to screen %s", + qPrintable(devNode), qPrintable(m_devState[dev].m_screenName)); + } + QTouchDevice *&td = m_devState[dev].m_touchDevice; td = new QTouchDevice; - td->setName(QString::fromUtf8(libinput_device_get_name(dev))); + td->setName(devName); td->setType(QTouchDevice::TouchScreen); td->setCapabilities(QTouchDevice::Position | QTouchDevice::Area); QWindowSystemInterface::registerTouchDevice(td); @@ -113,16 +143,16 @@ void QLibInputTouch::processTouchMotion(libinput_event_touch *e) DeviceState *state = deviceState(e); QWindowSystemInterface::TouchPoint *tp = state->point(slot); if (tp) { + Qt::TouchPointState tmpState = Qt::TouchPointMoved; const QPointF p = getPos(e); - if (tp->area.center() != p) { + if (tp->area.center() == p) + tmpState = Qt::TouchPointStationary; + else tp->area.moveCenter(p); - // 'down' may be followed by 'motion' within the same "frame". - // Handle this by compressing and keeping the Pressed state until the 'frame'. - if (tp->state != Qt::TouchPointPressed) - tp->state = Qt::TouchPointMoved; - } else { - tp->state = Qt::TouchPointStationary; - } + // 'down' may be followed by 'motion' within the same "frame". + // Handle this by compressing and keeping the Pressed state until the 'frame'. + if (tp->state != Qt::TouchPointPressed && tp->state != Qt::TouchPointReleased) + tp->state = tmpState; } else { qWarning("Inconsistent touch state (got 'motion' without 'down')"); } @@ -136,7 +166,7 @@ void QLibInputTouch::processTouchUp(libinput_event_touch *e) if (tp) { tp->state = Qt::TouchPointReleased; // There may not be a Frame event after the last Up. Work this around. - Qt::TouchPointStates s = 0; + Qt::TouchPointStates s; for (int i = 0; i < state->m_points.count(); ++i) s |= state->m_points.at(i).state; if (s == Qt::TouchPointReleased) diff --git a/src/platformsupport/input/libinput/qlibinputtouch_p.h b/src/platformsupport/input/libinput/qlibinputtouch_p.h index 51304e6a21..2682b83b26 100644 --- a/src/platformsupport/input/libinput/qlibinputtouch_p.h +++ b/src/platformsupport/input/libinput/qlibinputtouch_p.h @@ -42,6 +42,7 @@ #include <QtCore/QHash> #include <QtCore/QList> +#include <QtCore/QPointer> #include <qpa/qwindowsysteminterface.h> // @@ -60,6 +61,7 @@ struct libinput_device; QT_BEGIN_NAMESPACE +class QScreen; class QLibInputTouch { public: @@ -73,15 +75,18 @@ public: private: struct DeviceState { - DeviceState() : m_touchDevice(nullptr) { } + DeviceState() : m_touchDevice(nullptr), m_screenName() { } QWindowSystemInterface::TouchPoint *point(int32_t slot); QList<QWindowSystemInterface::TouchPoint> m_points; QTouchDevice *m_touchDevice; + QString m_screenName; }; DeviceState *deviceState(libinput_event_touch *e); + QPointF getPos(libinput_event_touch *e); QHash<libinput_device *, DeviceState> m_devState; + mutable QPointer<QScreen> m_screen; }; QT_END_NAMESPACE diff --git a/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/src/platformsupport/kmsconvenience/qkmsdevice.cpp index 06d1251a65..8cd7f9b368 100644 --- a/src/platformsupport/kmsconvenience/qkmsdevice.cpp +++ b/src/platformsupport/kmsconvenience/qkmsdevice.cpp @@ -176,6 +176,15 @@ static bool parseModeline(const QByteArray &text, drmModeModeInfoPtr mode) return true; } +static inline void assignPlane(QKmsOutput *output, QKmsPlane *plane) +{ + if (output->eglfs_plane) + output->eglfs_plane->activeCrtcId = 0; + + plane->activeCrtcId = output->crtc_id; + output->eglfs_plane = plane; +} + QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, drmModeConnectorPtr connector, ScreenInfo *vinfo) @@ -253,7 +262,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, // Get the current mode on the current crtc drmModeModeInfo crtc_mode; memset(&crtc_mode, 0, sizeof crtc_mode); - if (drmModeEncoderPtr encoder = drmModeGetEncoder(m_dri_fd, connector->connector_id)) { + if (drmModeEncoderPtr encoder = drmModeGetEncoder(m_dri_fd, connector->encoder_id)) { drmModeCrtcPtr crtc = drmModeGetCrtc(m_dri_fd, encoder->crtc_id); drmModeFreeEncoder(encoder); @@ -449,13 +458,16 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, #endif QString planeListStr; - for (const QKmsPlane &plane : qAsConst(m_planes)) { + for (QKmsPlane &plane : m_planes) { if (plane.possibleCrtcs & (1 << output.crtc_index)) { output.available_planes.append(plane); planeListStr.append(QString::number(plane.id)); planeListStr.append(QLatin1Char(' ')); - if (plane.type == QKmsPlane::PrimaryPlane) - output.eglfs_plane = (QKmsPlane*)&plane; + + // Choose the first primary plane that is not already assigned to + // another screen's associated crtc. + if (!output.eglfs_plane && plane.type == QKmsPlane::PrimaryPlane && !plane.activeCrtcId) + assignPlane(&output, &plane); } } qCDebug(qLcKmsDebug, "Output %s can use %d planes: %s", @@ -477,9 +489,11 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, qCDebug(qLcKmsDebug, "Forcing plane index %d, plane id %u (belongs to crtc id %u)", idx, plane->plane_id, plane->crtc_id); - for (const QKmsPlane &kmsplane : qAsConst(m_planes)) { - if (kmsplane.id == output.forced_plane_id) - output.eglfs_plane = (QKmsPlane*)&kmsplane; + for (QKmsPlane &kmsplane : m_planes) { + if (kmsplane.id == output.forced_plane_id) { + assignPlane(&output, &kmsplane); + break; + } } drmModeFreePlane(plane); @@ -490,8 +504,37 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, } } - if (output.eglfs_plane) - qCDebug(qLcKmsDebug, "Output eglfs plane is: %d", output.eglfs_plane->id); + // A more useful version: allows specifying "crtc_id,plane_id:crtc_id,plane_id:..." + // in order to allow overriding the plane used for a given crtc. + if (qEnvironmentVariableIsSet("QT_QPA_EGLFS_KMS_PLANES_FOR_CRTCS")) { + const QString val = qEnvironmentVariable("QT_QPA_EGLFS_KMS_PLANES_FOR_CRTCS"); + qCDebug(qLcKmsDebug, "crtc_id:plane_id override list: %s", qPrintable(val)); + const QStringList crtcPlanePairs = val.split(QLatin1Char(':')); + for (const QString &crtcPlanePair : crtcPlanePairs) { + const QStringList values = crtcPlanePair.split(QLatin1Char(',')); + if (values.count() == 2 && uint(values[0].toInt()) == output.crtc_id) { + uint planeId = values[1].toInt(); + for (QKmsPlane &kmsplane : m_planes) { + if (kmsplane.id == planeId) { + assignPlane(&output, &kmsplane); + break; + } + } + } + } + } + + if (output.eglfs_plane) { + qCDebug(qLcKmsDebug, "Chose plane %u for output %s (crtc id %u) (may not be applicable)", + output.eglfs_plane->id, connectorName.constData(), output.crtc_id); + } + +#if QT_CONFIG(drm_atomic) + if (hasAtomicSupport() && !output.eglfs_plane) { + qCDebug(qLcKmsDebug, "No plane associated with output %s (crtc id %u) and atomic modesetting is enabled. This is bad.", + connectorName.constData(), output.crtc_id); + } +#endif m_crtc_allocator |= (1 << output.crtc_index); @@ -538,10 +581,6 @@ QKmsDevice::QKmsDevice(QKmsScreenConfig *screenConfig, const QString &path) , m_path(path) , m_dri_fd(-1) , m_has_atomic_support(false) -#if QT_CONFIG(drm_atomic) - , m_atomic_request(nullptr) - , m_previous_request(nullptr) -#endif , m_crtc_allocator(0) { if (m_path.isEmpty()) { @@ -557,7 +596,7 @@ QKmsDevice::QKmsDevice(QKmsScreenConfig *screenConfig, const QString &path) QKmsDevice::~QKmsDevice() { #if QT_CONFIG(drm_atomic) - atomicReset(); + threadLocalAtomicReset(); #endif } @@ -834,7 +873,7 @@ void QKmsDevice::discoverPlanes() plane.type = QKmsPlane::Type(value); } else if (!strcmp(prop->name, "rotation")) { plane.initialRotation = QKmsPlane::Rotations(int(value)); - plane.availableRotations = 0; + plane.availableRotations = { }; if (propTypeIs(prop, DRM_MODE_PROP_BITMASK)) { for (int i = 0; i < prop->count_enums; ++i) plane.availableRotations |= QKmsPlane::Rotation(1 << prop->enums[i].value); @@ -897,39 +936,51 @@ bool QKmsDevice::hasAtomicSupport() } #if QT_CONFIG(drm_atomic) -drmModeAtomicReq * QKmsDevice::atomic_request() +drmModeAtomicReq *QKmsDevice::threadLocalAtomicRequest() { - if (!m_atomic_request && m_has_atomic_support) - m_atomic_request = drmModeAtomicAlloc(); + if (!m_has_atomic_support) + return nullptr; + + AtomicReqs &a(m_atomicReqs.localData()); + if (!a.request) + a.request = drmModeAtomicAlloc(); - return m_atomic_request; + return a.request; } -bool QKmsDevice::atomicCommit(void *user_data) +bool QKmsDevice::threadLocalAtomicCommit(void *user_data) { - if (m_atomic_request) { - int ret = drmModeAtomicCommit(m_dri_fd, m_atomic_request, - DRM_MODE_ATOMIC_NONBLOCK | DRM_MODE_PAGE_FLIP_EVENT | DRM_MODE_ATOMIC_ALLOW_MODESET, user_data); + if (!m_has_atomic_support) + return false; - if (ret) { - qWarning("Failed to commit atomic request (code=%d)", ret); - return false; - } + AtomicReqs &a(m_atomicReqs.localData()); + if (!a.request) + return false; - m_previous_request = m_atomic_request; - m_atomic_request = nullptr; + int ret = drmModeAtomicCommit(m_dri_fd, a.request, + DRM_MODE_ATOMIC_NONBLOCK | DRM_MODE_PAGE_FLIP_EVENT | DRM_MODE_ATOMIC_ALLOW_MODESET, + user_data); - return true; + if (ret) { + qWarning("Failed to commit atomic request (code=%d)", ret); + return false; } - return false; + a.previous_request = a.request; + a.request = nullptr; + + return true; } -void QKmsDevice::atomicReset() +void QKmsDevice::threadLocalAtomicReset() { - if (m_previous_request) { - drmModeAtomicFree(m_previous_request); - m_previous_request = nullptr; + if (!m_has_atomic_support) + return; + + AtomicReqs &a(m_atomicReqs.localData()); + if (a.previous_request) { + drmModeAtomicFree(a.previous_request); + a.previous_request = nullptr; } } #endif diff --git a/src/platformsupport/kmsconvenience/qkmsdevice_p.h b/src/platformsupport/kmsconvenience/qkmsdevice_p.h index b1150e2875..55a590cfce 100644 --- a/src/platformsupport/kmsconvenience/qkmsdevice_p.h +++ b/src/platformsupport/kmsconvenience/qkmsdevice_p.h @@ -57,6 +57,7 @@ #include <qpa/qplatformscreen.h> #include <QtCore/QMap> #include <QtCore/QVariant> +#include <QtCore/QThreadStorage> #include <xf86drm.h> #include <xf86drmMode.h> @@ -179,6 +180,8 @@ struct QKmsPlane uint32_t crtcheightPropertyId = 0; uint32_t zposPropertyId = 0; uint32_t blendOpPropertyId = 0; + + uint32_t activeCrtcId = 0; }; Q_DECLARE_OPERATORS_FOR_FLAGS(QKmsPlane::Rotations) @@ -239,10 +242,9 @@ public: bool hasAtomicSupport(); #if QT_CONFIG(drm_atomic) - bool atomicCommit(void *user_data); - void atomicReset(); - - drmModeAtomicReq *atomic_request(); + drmModeAtomicReq *threadLocalAtomicRequest(); + bool threadLocalAtomicCommit(void *user_data); + void threadLocalAtomicReset(); #endif void createScreens(); @@ -282,8 +284,11 @@ protected: bool m_has_atomic_support; #if QT_CONFIG(drm_atomic) - drmModeAtomicReq *m_atomic_request; - drmModeAtomicReq *m_previous_request; + struct AtomicReqs { + drmModeAtomicReq *request = nullptr; + drmModeAtomicReq *previous_request = nullptr; + }; + QThreadStorage<AtomicReqs> m_atomicReqs; #endif quint32 m_crtc_allocator; diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp index 8a825f8284..0f34e1a4ca 100644 --- a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp +++ b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp @@ -958,7 +958,7 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event) textRemoved = textEvent->textRemoved(); changePosition = textEvent->changePosition(); cursorPosition = textEvent->cursorPosition(); - } else if (event->type() == QAccessible::TextInserted) { + } else if (event->type() == QAccessible::TextUpdated) { QAccessibleTextUpdateEvent *textEvent = static_cast<QAccessibleTextUpdateEvent*>(event); textInserted = textEvent->textInserted(); textRemoved = textEvent->textRemoved(); @@ -2230,7 +2230,7 @@ bool AtSpiAdaptor::valueInterface(QAccessibleInterface *interface, const QString return false; if (function == QLatin1String("SetCurrentValue")) { - QDBusVariant v = message.arguments().at(2).value<QDBusVariant>(); + QDBusVariant v = qvariant_cast<QDBusVariant>(message.arguments().at(2)); double value = v.variant().toDouble(); //Temporary fix //See https://bugzilla.gnome.org/show_bug.cgi?id=652596 diff --git a/src/platformsupport/platformsupport.pro b/src/platformsupport/platformsupport.pro index 0b2dd8974b..4b41b29c12 100644 --- a/src/platformsupport/platformsupport.pro +++ b/src/platformsupport/platformsupport.pro @@ -11,7 +11,7 @@ SUBDIRS = \ qtConfig(freetype)|darwin|win32: \ SUBDIRS += fontdatabases -qtConfig(evdev)|qtConfig(tslib)|qtConfig(libinput)|qtConfig(integrityhid) { +qtConfig(evdev)|qtConfig(tslib)|qtConfig(libinput)|qtConfig(integrityhid)|qtConfig(xkbcommon) { SUBDIRS += input input.depends += devicediscovery } diff --git a/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenutypes.cpp b/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenutypes.cpp index a3c9746869..6fadea5d28 100644 --- a/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenutypes.cpp +++ b/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenutypes.cpp @@ -154,7 +154,7 @@ const QDBusArgument &operator>>(const QDBusArgument &arg, QDBusMenuLayoutItem &i while (!arg.atEnd()) { QDBusVariant dbusVariant; arg >> dbusVariant; - QDBusArgument childArgument = dbusVariant.variant().value<QDBusArgument>(); + QDBusArgument childArgument = qvariant_cast<QDBusArgument>(dbusVariant.variant()); QDBusMenuLayoutItem child; childArgument >> child; diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h b/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h index c0da9d8370..f6acf00f39 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h @@ -109,7 +109,7 @@ public: QVariant themeHint(ThemeHint hint) const override; QIcon fileIcon(const QFileInfo &fileInfo, - QPlatformTheme::IconOptions iconOptions = nullptr) const override; + QPlatformTheme::IconOptions iconOptions = { }) const override; const QPalette *palette(Palette type = SystemPalette) const override; @@ -134,7 +134,7 @@ public: QGnomeTheme(); QVariant themeHint(ThemeHint hint) const override; QIcon fileIcon(const QFileInfo &fileInfo, - QPlatformTheme::IconOptions = nullptr) const override; + QPlatformTheme::IconOptions = { }) const override; const QFont *font(Font type) const override; QString standardButtonText(int button) const override; diff --git a/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance.cpp b/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance.cpp index 68340a3173..6f6ba58319 100644 --- a/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance.cpp +++ b/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance.cpp @@ -214,6 +214,22 @@ void QBasicPlatformVulkanInstance::initInstance(QVulkanInstance *instance, const for (const QByteArray &ext : extraExts) m_enabledExtensions.append(ext); + QByteArray envExts = qgetenv("QT_VULKAN_INSTANCE_EXTENSIONS"); + if (!envExts.isEmpty()) { + QByteArrayList envExtList = envExts.split(';'); + for (auto ext : m_enabledExtensions) + envExtList.removeAll(ext); + m_enabledExtensions.append(envExtList); + } + + QByteArray envLayers = qgetenv("QT_VULKAN_INSTANCE_LAYERS"); + if (!envLayers.isEmpty()) { + QByteArrayList envLayerList = envLayers.split(';'); + for (auto ext : m_enabledLayers) + envLayerList.removeAll(ext); + m_enabledLayers.append(envLayerList); + } + // No clever stuff with QSet and friends: the order for layers matters // and the user-provided order must be kept. for (int i = 0; i < m_enabledLayers.count(); ++i) { |