diff options
author | Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> | 2016-08-22 11:30:00 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> | 2016-08-22 11:30:01 +0200 |
commit | d314819fc02139e05e16c56657898c704f7fb48f (patch) | |
tree | a61ba968233634948401c8339f9613844de1c2b5 /src/plugins/platforms/windows | |
parent | 9f888d2fde9c5413e5519e0914e9b13638760985 (diff) | |
parent | e0e9e196a72ffe5457034894eaaadc90ed0d34ef (diff) |
Merge dev into 5.8
Change-Id: I41ee7b50534b01cf042bed8bb8824ba2e5026a29
Diffstat (limited to 'src/plugins/platforms/windows')
6 files changed, 57 insertions, 25 deletions
diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp index 6f236aa588..e87064e385 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp @@ -40,6 +40,7 @@ #include "qwindowsfontdatabase.h" #include "qwindowsfontdatabase_ft.h" // for default font #include "qwindowscontext.h" +#include "qwindowsintegration.h" #include "qwindowsfontengine.h" #include "qwindowsfontenginedirectwrite.h" #include <QtCore/qt_windows.h> @@ -108,6 +109,18 @@ static void createDirectWriteFactory(IDWriteFactory **factory) *factory = static_cast<IDWriteFactory *>(result); } + +static inline bool useDirectWrite(QFont::HintingPreference hintingPreference, bool isColorFont = false) +{ + const unsigned options = QWindowsIntegration::instance()->options(); + if (Q_UNLIKELY(options & QWindowsIntegration::DontUseDirectWriteFonts)) + return false; + if (isColorFont) + return (options & QWindowsIntegration::DontUseColorFonts) == 0; + return hintingPreference == QFont::PreferNoHinting + || hintingPreference == QFont::PreferVerticalHinting + || (QHighDpiScaling::isActive() && hintingPreference == QFont::PreferDefaultHinting); +} #endif // !QT_NO_DIRECTWRITE // Helper classes for creating font engines directly from font data @@ -1200,11 +1213,7 @@ QFontEngine *QWindowsFontDatabase::fontEngine(const QByteArray &fontData, qreal QFontEngine *fontEngine = 0; #if !defined(QT_NO_DIRECTWRITE) - bool useDirectWrite = (hintingPreference == QFont::PreferNoHinting) - || (hintingPreference == QFont::PreferVerticalHinting) - || (QHighDpiScaling::isActive() && hintingPreference == QFont::PreferDefaultHinting); - - if (!useDirectWrite) + if (!useDirectWrite(hintingPreference)) #endif { GUID guid; @@ -1840,15 +1849,16 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request, if (SUCCEEDED(directWriteFontFace->QueryInterface(__uuidof(IDWriteFontFace2), reinterpret_cast<void **>(&directWriteFontFace2)))) { if (directWriteFontFace2->IsColorFont()) - isColorFont = true; + isColorFont = directWriteFontFace2->GetPaletteEntryCount() > 0; } #endif - - bool useDirectWrite = (request.hintingPreference == QFont::PreferNoHinting) - || (request.hintingPreference == QFont::PreferVerticalHinting) - || (QHighDpiScaling::isActive() && request.hintingPreference == QFont::PreferDefaultHinting) - || isColorFont; - if (useDirectWrite) { + const QFont::HintingPreference hintingPreference = + static_cast<QFont::HintingPreference>(request.hintingPreference); + const bool useDw = useDirectWrite(hintingPreference, isColorFont); + qCDebug(lcQpaFonts) << __FUNCTION__ << request.family << request.pointSize + << "pt" << "hintingPreference=" << hintingPreference << "color=" << isColorFont + << dpi << "dpi" << "useDirectWrite=" << useDw; + if (useDw) { QWindowsFontEngineDirectWrite *fedw = new QWindowsFontEngineDirectWrite(directWriteFontFace, request.pixelSize, data); diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 90aa3fef16..b9a63c7a89 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -192,6 +192,10 @@ static inline unsigned parseOptions(const QStringList ¶mList, } } else if (param == QLatin1String("gl=gdi")) { options |= QWindowsIntegration::DisableArb; + } else if (param == QLatin1String("nodirectwrite")) { + options |= QWindowsIntegration::DontUseDirectWriteFonts; + } else if (param == QLatin1String("nocolorfonts")) { + options |= QWindowsIntegration::DontUseColorFonts; } else if (param == QLatin1String("nomousefromtouch")) { options |= QWindowsIntegration::DontPassOsMouseEventsSynthesizedFromTouch; } else if (parseIntOption(param, QLatin1String("verbose"), 0, INT_MAX, &QWindowsContext::verbose) @@ -304,7 +308,7 @@ QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) cons if (window->type() == Qt::ForeignWindow) { const HWND hwnd = reinterpret_cast<HWND>(window->winId()); if (!IsWindow(hwnd)) { - qWarning("Windows QPA: Invalid foreign window ID %p."); + qWarning("Windows QPA: Invalid foreign window ID %p.", hwnd); return nullptr; } QWindowsForeignWindow *result = new QWindowsForeignWindow(window, hwnd); diff --git a/src/plugins/platforms/windows/qwindowsintegration.h b/src/plugins/platforms/windows/qwindowsintegration.h index 437253cedc..4258f908e7 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.h +++ b/src/plugins/platforms/windows/qwindowsintegration.h @@ -60,7 +60,9 @@ public: DisableArb = 0x4, NoNativeDialogs = 0x8, XpNativeDialogs = 0x10, - DontPassOsMouseEventsSynthesizedFromTouch = 0x20 // Do not pass OS-generated mouse events from touch. + DontPassOsMouseEventsSynthesizedFromTouch = 0x20, // Do not pass OS-generated mouse events from touch. + DontUseDirectWriteFonts = 0x40, + DontUseColorFonts = 0x80 }; explicit QWindowsIntegration(const QStringList ¶mList); diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index 8d6e83298e..79b5bbae41 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -43,6 +43,7 @@ #include "qwindowswindow.h" #include "qwindowsinputcontext.h" +#include <QtGui/QGuiApplication> #include <QtGui/QWindow> #include <qpa/qwindowsysteminterface.h> #include <private/qguiapplication_p.h> @@ -1048,6 +1049,21 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms if (PeekMessage(&wm_char, 0, charType, charType, PM_REMOVE)) { // Found a ?_CHAR uch = QChar(ushort(wm_char.wParam)); + if (uch.isHighSurrogate()) { + m_lastHighSurrogate = uch; + return true; + } else if (uch.isLowSurrogate() && !m_lastHighSurrogate.isNull()) { + if (QObject *focusObject = QGuiApplication::focusObject()) { + const QChar chars[2] = {m_lastHighSurrogate, uch}; + QInputMethodEvent event; + event.setCommitString(QString(chars, 2)); + QCoreApplication::sendEvent(focusObject, &event); + } + m_lastHighSurrogate = QChar(); + return true; + } else { + m_lastHighSurrogate = QChar(); + } if (msgType == WM_SYSKEYDOWN && uch.isLetter() && (msg.lParam & KF_ALTDOWN)) uch = uch.toLower(); // (See doc of WM_SYSCHAR) Alt-letter if (!code && !uch.row()) diff --git a/src/plugins/platforms/windows/qwindowskeymapper.h b/src/plugins/platforms/windows/qwindowskeymapper.h index 069f78197e..2657644780 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.h +++ b/src/plugins/platforms/windows/qwindowskeymapper.h @@ -103,6 +103,7 @@ private: void deleteLayouts(); QWindow *m_keyGrabber; + QChar m_lastHighSurrogate; static const size_t NumKeyboardLayoutItems = 256; KeyboardLayoutItem keyLayout[NumKeyboardLayoutItems]; }; diff --git a/src/plugins/platforms/windows/windows.pri b/src/plugins/platforms/windows/windows.pri index 1cadcd1954..6929f7365f 100644 --- a/src/plugins/platforms/windows/windows.pri +++ b/src/plugins/platforms/windows/windows.pri @@ -1,7 +1,7 @@ # Note: OpenGL32 must precede Gdi32 as it overwrites some functions. LIBS += -lole32 -luser32 -lwinspool -limm32 -lwinmm -loleaut32 -contains(QT_CONFIG, opengl):!contains(QT_CONFIG, opengles2):!contains(QT_CONFIG, dynamicgl): LIBS *= -lopengl32 +qtConfig(opengl):!qtConfig(opengles2):!qtConfig(dynamicgl): LIBS *= -lopengl32 mingw: LIBS *= -luuid # For the dialog helpers: @@ -9,8 +9,8 @@ LIBS += -lshlwapi -lshell32 -ladvapi32 DEFINES *= QT_NO_CAST_FROM_ASCII -contains(QT_CONFIG, directwrite) { - contains(QT_CONFIG, directwrite2): \ +qtConfig(directwrite) { + qtConfig(directwrite2): \ DEFINES *= QT_USE_DIRECTWRITE2 SOURCES += $$PWD/qwindowsfontenginedirectwrite.cpp @@ -65,18 +65,18 @@ HEADERS += \ INCLUDEPATH += $$PWD -contains(QT_CONFIG,opengl): HEADERS += $$PWD/qwindowsopenglcontext.h +qtConfig(opengl): HEADERS += $$PWD/qwindowsopenglcontext.h -contains(QT_CONFIG, opengles2) { +qtConfig(opengles2) { SOURCES += $$PWD/qwindowseglcontext.cpp HEADERS += $$PWD/qwindowseglcontext.h -} else: contains(QT_CONFIG,opengl) { +} else: qtConfig(opengl) { SOURCES += $$PWD/qwindowsglcontext.cpp HEADERS += $$PWD/qwindowsglcontext.h } # Dynamic GL needs both WGL and EGL -contains(QT_CONFIG,dynamicgl) { +qtConfig(dynamicgl) { SOURCES += $$PWD/qwindowseglcontext.cpp HEADERS += $$PWD/qwindowseglcontext.h } @@ -111,18 +111,17 @@ contains(QT_CONFIG,dynamicgl) { RESOURCES += $$PWD/openglblacklists.qrc -contains(QT_CONFIG, freetype) { +qtConfig(freetype) { HEADERS += $$PWD/qwindowsfontdatabase_ft.h SOURCES += $$PWD/qwindowsfontdatabase_ft.cpp - contains(QT_CONFIG, system-freetype) { + qtConfig(system-freetype) { include($$QT_SOURCE_TREE/src/platformsupport/fontdatabases/basic/basic.pri) } else { - DEFINES *= QT_NO_FONTCONFIG include($$QT_SOURCE_TREE/src/3rdparty/freetype_dependency.pri) } } -contains(QT_CONFIG, accessibility):include($$PWD/accessible/accessible.pri) +qtConfig(accessibility): include($$PWD/accessible/accessible.pri) DEFINES *= LIBEGL_NAME=$${LIBEGL_NAME} DEFINES *= LIBGLESV2_NAME=$${LIBGLESV2_NAME} |