diff options
author | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2014-08-11 14:42:48 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2014-08-18 12:55:03 +0200 |
commit | 6efa8cd70aedf13edef9143eb57b52bd175fb748 (patch) | |
tree | 569d6fff00417948c6ca2be7880d195b79340b46 /src/plugins/platforms/xcb | |
parent | 20c14d87f248ca3d5aa42119df01105bbaaadc85 (diff) |
Support antialias and rgba Xft settings as used by GNOME and UNITY
We only parsed the hintstyle from the Xft settings. This patch adds
parsing for also subpixel style and disabling antialiasing.
Task-number: QTBUG-27106
Change-Id: Icdb88ccc10e50d76eb30a5b126bee7590e257022
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Diffstat (limited to 'src/plugins/platforms/xcb')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbnativeinterface.cpp | 9 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbnativeinterface.h | 4 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbscreen.cpp | 78 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbscreen.h | 8 |
4 files changed, 71 insertions, 28 deletions
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp index 5673d41811..a00da04c26 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp @@ -85,7 +85,8 @@ static int resourceType(const QByteArray &key) QByteArrayLiteral("appusertime"), QByteArrayLiteral("hintstyle"), QByteArrayLiteral("startupid"), QByteArrayLiteral("traywindow"), QByteArrayLiteral("gettimestamp"), QByteArrayLiteral("x11screen"), - QByteArrayLiteral("rootwindow") + QByteArrayLiteral("rootwindow"), + QByteArrayLiteral("subpixeltype"), QByteArrayLiteral("antialiasingEnabled") }; const QByteArray *end = names + sizeof(names) / sizeof(names[0]); const QByteArray *result = std::find(names, end, key); @@ -277,6 +278,12 @@ void *QXcbNativeInterface::nativeResourceForScreen(const QByteArray &resource, Q case ScreenHintStyle: result = reinterpret_cast<void *>(xcbScreen->hintStyle() + 1); break; + case ScreenSubpixelType: + result = reinterpret_cast<void *>(xcbScreen->subpixelType() + 1); + break; + case ScreenAntialiasingEnabled: + result = reinterpret_cast<void *>(xcbScreen->antialiasingEnabled() + 1); + break; case TrayWindow: if (QXcbSystemTrayTracker *s = systemTrayTracker(screen)) result = (void *)quintptr(s->trayWindow()); diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h index c63cdf0254..1cd764914a 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.h +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h @@ -73,7 +73,9 @@ public: TrayWindow, GetTimestamp, X11Screen, - RootWindow + RootWindow, + ScreenSubpixelType, + ScreenAntialiasingEnabled }; QXcbNativeInterface(); diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 85f4dfbd43..952f32d806 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -69,6 +69,8 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *scr, , m_refreshRate(60) , m_forcedDpi(-1) , m_hintStyle(QFontEngine::HintStyle(-1)) + , m_subpixelType(QFontEngine::SubpixelAntialiasingType(-1)) + , m_antialiasingEnabled(-1) , m_xSettings(0) { if (connection->hasXRandr()) @@ -547,32 +549,52 @@ QPixmap QXcbScreen::grabWindow(WId window, int x, int y, int width, int height) return result; } +static bool parseXftInt(const QByteArray& stringValue, int *value) +{ + Q_ASSERT(value != 0); + bool ok; + *value = stringValue.toInt(&ok); + return ok; +} + +static QFontEngine::HintStyle parseXftHintStyle(const QByteArray& stringValue) +{ + if (stringValue == "hintfull") + return QFontEngine::HintFull; + else if (stringValue == "hintnone") + return QFontEngine::HintNone; + else if (stringValue == "hintmedium") + return QFontEngine::HintMedium; + else if (stringValue == "hintslight") + return QFontEngine::HintLight; + + return QFontEngine::HintStyle(-1); +} + +static QFontEngine::SubpixelAntialiasingType parseXftRgba(const QByteArray& stringValue) +{ + if (stringValue == "none") + return QFontEngine::Subpixel_None; + else if (stringValue == "rgb") + return QFontEngine::Subpixel_RGB; + else if (stringValue == "bgr") + return QFontEngine::Subpixel_BGR; + else if (stringValue == "vrgb") + return QFontEngine::Subpixel_VRGB; + else if (stringValue == "vbgr") + return QFontEngine::Subpixel_VBGR; + + return QFontEngine::SubpixelAntialiasingType(-1); +} + bool QXcbScreen::xResource(const QByteArray &identifier, const QByteArray &expectedIdentifier, - int *value) + QByteArray& stringValue) { - Q_ASSERT(value != 0); if (identifier.startsWith(expectedIdentifier)) { - QByteArray stringValue = identifier.mid(expectedIdentifier.size()); - - bool ok; - *value = stringValue.toInt(&ok); - if (!ok) { - if (stringValue == "hintfull") - *value = QFontEngine::HintFull; - else if (stringValue == "hintnone") - *value = QFontEngine::HintNone; - else if (stringValue == "hintmedium") - *value = QFontEngine::HintMedium; - else if (stringValue == "hintslight") - *value = QFontEngine::HintLight; - - return *value != 0; - } - + stringValue = identifier.mid(expectedIdentifier.size()); return true; } - return false; } @@ -604,10 +626,18 @@ void QXcbScreen::readXResources() for (int i = 0; i < split.size(); ++i) { const QByteArray &r = split.at(i); int value; - if (xResource(r, "Xft.dpi:\t", &value)) - m_forcedDpi = value; - else if (xResource(r, "Xft.hintstyle:\t", &value)) - m_hintStyle = QFontEngine::HintStyle(value); + QByteArray stringValue; + if (xResource(r, "Xft.dpi:\t", stringValue)) { + if (parseXftInt(stringValue, &value)) + m_forcedDpi = value; + } else if (xResource(r, "Xft.hintstyle:\t", stringValue)) { + m_hintStyle = parseXftHintStyle(stringValue); + } else if (xResource(r, "Xft.antialias:\t", stringValue)) { + if (parseXftInt(stringValue, &value)) + m_antialiasingEnabled = value; + } else if (xResource(r, "Xft.rgba:\t", stringValue)) { + m_subpixelType = parseXftRgba(stringValue); + } } } diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h index 53ac65bb09..db72d94698 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.h +++ b/src/plugins/platforms/xcb/qxcbscreen.h @@ -104,13 +104,15 @@ public: void readXResources(); QFontEngine::HintStyle hintStyle() const { return m_hintStyle; } + QFontEngine::SubpixelAntialiasingType subpixelType() const { return m_subpixelType; } + int antialiasingEnabled() const { return m_antialiasingEnabled; } QXcbXSettings *xSettings() const; private: static bool xResource(const QByteArray &identifier, - const QByteArray &expectedIdentifier, - int *value); + const QByteArray &expectedIdentifier, + QByteArray &stringValue); void sendStartupMessage(const QByteArray &message) const; xcb_screen_t *m_screen; @@ -133,6 +135,8 @@ private: int m_refreshRate; int m_forcedDpi; QFontEngine::HintStyle m_hintStyle; + QFontEngine::SubpixelAntialiasingType m_subpixelType; + int m_antialiasingEnabled; QXcbXSettings *m_xSettings; }; |