From 5fcd60f2560e8caf495ce67028a8da8bef27acad Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 18 May 2011 12:16:33 +0200 Subject: Fix broken drawing with large fonts using QStaticText and FreeType In FreeType, there's a fall back to QFontEngine::alphaMapForGlyph() when the fonts are very large. Since this uses a QPainterPath containing an unhinted glyph, the use of hinted metrics would sometimes lead to the glyphs being clipped because they would be positioned slightly outside the image they were painted into. When outline drawing is on, it makes sense to return unhinted metrics, since the glyphs we will actually use are unhinted. Task-number: QTBUG-19067 Reviewed-by: Jiang Jiang --- src/gui/text/qfontengine_ft.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 4dae2a3784..855eaec8c4 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -795,7 +795,7 @@ int QFontEngineFT::loadFlags(QGlyphSet *set, GlyphFormat format, int flags, if (set && set->outline_drawing) load_flags = FT_LOAD_NO_BITMAP; - if (default_hint_style == HintNone || (flags & HB_ShaperFlag_UseDesignMetrics)) + if (default_hint_style == HintNone || (flags & HB_ShaperFlag_UseDesignMetrics) || set->outline_drawing) load_flags |= FT_LOAD_NO_HINTING; else load_flags |= load_target; -- cgit v1.2.3 From b57a7e6994abdab2b7ff7c7fc19549d66dbf598f Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 6 May 2011 13:13:42 +0200 Subject: QT_USE_QSTRINGBUILDER to fix source compatibility In 4.8 we added support for using StringBuilder with QByteArray. But this is breaking source compatibility for people that used QT_USE_FAST_OPERATOR_PLUS in Qt 4.7. So we introduce a new macro Notice that QT_USE_FAST_CONCATENATION was not working without QT_USE_FAST_OPERATOR_PLUS, so we remove the checking of that macro. Reviewed-by: joao (cherry picked from commit 8447f5616be731d78081f326bb9cb3f5aa9087a4) --- src/corelib/tools/qbytearray.h | 13 ++++++------- src/corelib/tools/qstring.cpp | 10 +++------- src/corelib/tools/qstring.h | 8 +++----- src/corelib/tools/qstringbuilder.h | 4 +++- src/qbase.pri | 2 +- 5 files changed, 16 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h index 0627b4e568..df58d95131 100644 --- a/src/corelib/tools/qbytearray.h +++ b/src/corelib/tools/qbytearray.h @@ -57,9 +57,10 @@ # ifdef QT_USE_FAST_OPERATOR_PLUS # undef QT_USE_FAST_OPERATOR_PLUS # endif -# ifdef QT_USE_FAST_CONCATENATION -# undef QT_USE_FAST_CONCATENATION +# ifdef QT_USE_QSTRINGBUILDER +# undef QT_USE_QSTRINGBUILDER # endif + #endif @@ -559,8 +560,7 @@ inline bool operator>=(const QByteArray &a1, const char *a2) { return qstrcmp(a1, a2) >= 0; } inline bool operator>=(const char *a1, const QByteArray &a2) { return qstrcmp(a1, a2) >= 0; } -#ifndef QT_USE_FAST_OPERATOR_PLUS -# ifndef QT_USE_FAST_CONCATENATION +#if !defined(QT_USE_QSTRINGBUILDER) inline const QByteArray operator+(const QByteArray &a1, const QByteArray &a2) { return QByteArray(a1) += a2; } inline const QByteArray operator+(const QByteArray &a1, const char *a2) @@ -571,8 +571,7 @@ inline const QByteArray operator+(const char *a1, const QByteArray &a2) { return QByteArray(a1) += a2; } inline const QByteArray operator+(char a1, const QByteArray &a2) { return QByteArray(&a1, 1) += a2; } -# endif // QT_USE_FAST_CONCATENATION -#endif // QT_USE_FAST_OPERATOR_PLUS +#endif // QT_USE_QSTRINGBUILDER inline QBool QByteArray::contains(const char *c) const { return QBool(indexOf(c) != -1); } inline QByteArray &QByteArray::replace(char before, const char *c) @@ -615,7 +614,7 @@ QT_END_NAMESPACE QT_END_HEADER -#ifdef QT_USE_FAST_CONCATENATION +#ifdef QT_USE_QSTRINGBUILDER #include #endif diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 5493ba915b..3b3f715b9d 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -777,16 +777,12 @@ const QString::Null QString::null = { }; \snippet doc/src/snippets/qstring/stringbuilder.cpp 5 - A more global approach is to include this define: + A more global approach which is the most convenient but + not entirely source compatible, is to this define in your + .pro file: \snippet doc/src/snippets/qstring/stringbuilder.cpp 3 - and use \c{'%'} instead of \c{'+'} for string concatenation - everywhere. The third approach, which is the most convenient but - not entirely source compatible, is to include two defines: - - \snippet doc/src/snippets/qstring/stringbuilder.cpp 4 - and the \c{'+'} will automatically be performed as the \c{QStringBuilder} \c{'%'} everywhere. diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 6418a8cbd4..7c4367efde 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -1016,8 +1016,7 @@ inline int QByteArray::findRev(const QString &s, int from) const # endif // QT3_SUPPORT #endif // QT_NO_CAST_TO_ASCII -#ifndef QT_USE_FAST_OPERATOR_PLUS -# ifndef QT_USE_FAST_CONCATENATION +#if !defined(QT_USE_FAST_OPERATOR_PLUS) && !defined(QT_USE_QSTRINGBUILDER) inline const QString operator+(const QString &s1, const QString &s2) { QString t(s1); t += s2; return t; } inline const QString operator+(const QString &s1, QChar s2) @@ -1038,8 +1037,7 @@ inline QT_ASCII_CAST_WARN const QString operator+(const QByteArray &ba, const QS inline QT_ASCII_CAST_WARN const QString operator+(const QString &s, const QByteArray &ba) { QString t(s); t += QString::fromAscii(ba.constData(), qstrnlen(ba.constData(), ba.size())); return t; } # endif // QT_NO_CAST_FROM_ASCII -# endif // QT_USE_FAST_CONCATENATION -#endif // QT_USE_FAST_OPERATOR_PLUS +#endif // QT_USE_QSTRINGBUILDER #ifndef QT_NO_STL inline std::string QString::toStdString() const @@ -1288,7 +1286,7 @@ QT_END_NAMESPACE QT_END_HEADER -#ifdef QT_USE_FAST_CONCATENATION +#if defined(QT_USE_FAST_OPERATOR_PLUS) || defined(QT_USE_QSTRINGBUILDER) #include #endif diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h index 2d3475fed9..029aa0b216 100644 --- a/src/corelib/tools/qstringbuilder.h +++ b/src/corelib/tools/qstringbuilder.h @@ -410,7 +410,9 @@ operator%(const A &a, const B &b) return QStringBuilder::type, typename QConcatenable::type>(a, b); } -#ifdef QT_USE_FAST_OPERATOR_PLUS +// QT_USE_FAST_OPERATOR_PLUS was introduced in 4.7, QT_USE_QSTRINGBUILDER is to be used from 4.8 onwards +// QT_USE_FAST_OPERATOR_PLUS does not remove the normal operator+ for QByteArray +#if defined(QT_USE_FAST_OPERATOR_PLUS) || defined(QT_USE_QSTRINGBUILDER) template QStringBuilder::type, typename QConcatenable::type> operator+(const A &a, const B &b) diff --git a/src/qbase.pri b/src/qbase.pri index 03f85cf931..cf02978853 100644 --- a/src/qbase.pri +++ b/src/qbase.pri @@ -174,7 +174,7 @@ contains(QT_PRODUCT, OpenSource.*):DEFINES *= QT_OPENSOURCE DEFINES *= QT_NO_CAST_TO_ASCII QT_ASCII_CAST_WARNINGS contains(QT_CONFIG, gui-qt3support):DEFINES *= QT3_SUPPORT DEFINES *= QT_MOC_COMPAT #we don't need warnings from calling moc code in our generated code -DEFINES *= QT_USE_FAST_OPERATOR_PLUS QT_USE_FAST_CONCATENATION +DEFINES *= QT_USE_QSTRINGBUILDER TARGET = $$qtLibraryTarget($$TARGET$$QT_LIBINFIX) #do this towards the end -- cgit v1.2.3 From e8c95790d9d03678f9c0d30a7cc7c2edec6eba81 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 18 May 2011 15:31:14 +0200 Subject: Add ability to work around non-standard GLES implementations Reviewed-by: Gunnar --- src/opengl/qglshaderprogram.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index 4598bffabb..8ca95a88c9 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -362,17 +362,17 @@ QGLShader::ShaderType QGLShader::shaderType() const // The precision qualifiers are useful on OpenGL/ES systems, // but usually not present on desktop systems. Define the // keywords to empty strings on desktop systems. -#ifndef QT_OPENGL_ES +#if !defined(QT_OPENGL_ES) || defined(QT_OPENGL_FORCE_SHADER_DEFINES) #define QGL_DEFINE_QUALIFIERS 1 static const char qualifierDefines[] = "#define lowp\n" "#define mediump\n" "#define highp\n"; -#endif + +#else // The "highp" qualifier doesn't exist in fragment shaders // on all ES platforms. When it doesn't exist, use "mediump". -#ifdef QT_OPENGL_ES #define QGL_REDEFINE_HIGHP 1 static const char redefineHighp[] = "#ifndef GL_FRAGMENT_PRECISION_HIGH\n" -- cgit v1.2.3 From f4c1c2f939e1cd6e08197284edb84b202cd6749e Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 18 May 2011 15:10:40 +0200 Subject: Fall back to using paths for large fonts in drawStaticText() QStaticText had an implicit risk which meant you had to make sure the text size did not grow unreasonably large. This was intended to avoid hiding the performance impact of using QStaticText for such a purpose, but it's too inconvenient. Thus, the same fall back as in drawTextItem() has been introduced. This will also fix a bug recently introduced when we started using the FT cache to draw static text in the raster engine, since this will fail for large fonts. Task-number: QTBUG-19084, QTBUG-19370 Reviewed-by: Jiang Jiang (cherry picked from commit 0aa9b30432cec3b7f366983f451fc9a7f8f83243) --- src/gui/painting/qpaintengine_raster.cpp | 12 ++++++-- src/gui/painting/qpaintengineex.cpp | 35 ++++++++++++++++++++++ src/gui/painting/qpaintengineex_p.h | 2 +- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 33 +++++++++++++------- 4 files changed, 68 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index f0bc0d6027..4f8af488a1 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -3029,8 +3029,16 @@ void QRasterPaintEngine::drawStaticTextItem(QStaticTextItem *textItem) ensurePen(); ensureState(); - drawCachedGlyphs(textItem->numGlyphs, textItem->glyphs, textItem->glyphPositions, - textItem->fontEngine()); + QRasterPaintEngineState *s = state(); + + QFontEngine *fontEngine = textItem->fontEngine(); + const qreal pixelSize = fontEngine->fontDef.pixelSize; + if (pixelSize * pixelSize * qAbs(s->matrix.determinant()) < 64 * 64) { + drawCachedGlyphs(textItem->numGlyphs, textItem->glyphs, textItem->glyphPositions, + fontEngine); + } else { + QPaintEngineEx::drawStaticTextItem(textItem); + } } /*! diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index bbdf76f0c0..304e5fc486 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -44,6 +44,8 @@ #include "qstroker_p.h" #include "qbezier_p.h" #include +#include +#include #include #include @@ -1057,5 +1059,38 @@ Q_GUI_EXPORT QPainterPath qt_painterPathFromVectorPath(const QVectorPath &path) return p; } +void QPaintEngineEx::drawStaticTextItem(QStaticTextItem *staticTextItem) +{ + QPainterPath path; +#ifndef Q_WS_MAC + path.setFillRule(Qt::WindingFill); +#endif + + if (staticTextItem->numGlyphs == 0) + return; + + QFontEngine *fontEngine = staticTextItem->fontEngine(); + fontEngine->addGlyphsToPath(staticTextItem->glyphs, staticTextItem->glyphPositions, + staticTextItem->numGlyphs, &path, 0); + if (!path.isEmpty()) { + QPainterState *s = state(); + QPainter::RenderHints oldHints = s->renderHints; + bool changedHints = false; + if (bool(oldHints & QPainter::TextAntialiasing) + && !bool(fontEngine->fontDef.styleStrategy & QFont::NoAntialias) + && !bool(oldHints & QPainter::Antialiasing)) { + s->renderHints |= QPainter::Antialiasing; + renderHintsChanged(); + changedHints = true; + } + + fill(qtVectorPathForPath(path), staticTextItem->color); + + if (changedHints) { + s->renderHints = oldHints; + renderHintsChanged(); + } + } +} QT_END_NAMESPACE diff --git a/src/gui/painting/qpaintengineex_p.h b/src/gui/painting/qpaintengineex_p.h index d12c602372..7d57eee43d 100644 --- a/src/gui/painting/qpaintengineex_p.h +++ b/src/gui/painting/qpaintengineex_p.h @@ -202,7 +202,7 @@ public: virtual void updateState(const QPaintEngineState &state); - virtual void drawStaticTextItem(QStaticTextItem *) = 0; + virtual void drawStaticTextItem(QStaticTextItem *); virtual void setState(QPainterState *s); inline QPainterState *state() { return static_cast(QPaintEngine::state); } diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 38bd58d91c..3cf8faa086 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1436,19 +1436,30 @@ void QGL2PaintEngineEx::drawStaticTextItem(QStaticTextItem *textItem) ensureActive(); - QFontEngineGlyphCache::Type glyphType = textItem->fontEngine()->glyphFormat >= 0 - ? QFontEngineGlyphCache::Type(textItem->fontEngine()->glyphFormat) - : d->glyphCacheType; - if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) { - if (d->device->alphaRequested() || state()->matrix.type() > QTransform::TxTranslate - || (state()->composition_mode != QPainter::CompositionMode_Source - && state()->composition_mode != QPainter::CompositionMode_SourceOver)) - { - glyphType = QFontEngineGlyphCache::Raster_A8; + QPainterState *s = state(); + float det = s->matrix.determinant(); + + // don't try to cache huge fonts or vastly transformed fonts + QFontEngine *fontEngine = textItem->fontEngine(); + const qreal pixelSize = fontEngine->fontDef.pixelSize; + if (pixelSize * pixelSize * qAbs(det) < QT_MAX_CACHED_GLYPH_SIZE * QT_MAX_CACHED_GLYPH_SIZE || + det < 0.25f || det > 4.f) { + QFontEngineGlyphCache::Type glyphType = fontEngine->glyphFormat >= 0 + ? QFontEngineGlyphCache::Type(textItem->fontEngine()->glyphFormat) + : d->glyphCacheType; + if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) { + if (d->device->alphaRequested() || s->matrix.type() > QTransform::TxTranslate + || (s->composition_mode != QPainter::CompositionMode_Source + && s->composition_mode != QPainter::CompositionMode_SourceOver)) + { + glyphType = QFontEngineGlyphCache::Raster_A8; + } } - } - d->drawCachedGlyphs(glyphType, textItem); + d->drawCachedGlyphs(glyphType, textItem); + } else { + QPaintEngineEx::drawStaticTextItem(textItem); + } } bool QGL2PaintEngineEx::drawTexture(const QRectF &dest, GLuint textureId, const QSize &size, const QRectF &src) -- cgit v1.2.3 From b9ee8487e944ceab211d7c5b77ba477e8d638933 Mon Sep 17 00:00:00 2001 From: Eckhart Koppen Date: Wed, 18 May 2011 17:35:04 +0300 Subject: Enable configuration for Xcb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The xcb platform plugin can now be enabled using -xcb at configuration time. A configuration time compilation check will be added at a later point. Reviewed-by: Samuel Rødal --- src/plugins/platforms/platforms.pro | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/platforms.pro b/src/plugins/platforms/platforms.pro index 57015e7924..492569796f 100644 --- a/src/plugins/platforms/platforms.pro +++ b/src/plugins/platforms/platforms.pro @@ -6,3 +6,6 @@ contains(QT_CONFIG, wayland) { SUBDIRS += wayland } +contains(QT_CONFIG, xcb) { + SUBDIRS += xcb +} -- cgit v1.2.3 From 449b8a93170ecc19f2f438b160d0bc4122999401 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 18 May 2011 14:39:44 +0200 Subject: QUiLoader, QAbstractFormBuilder: Introduce errorString(). Introduce errorString() to be able to obtain load errors in Qt Designer. Remove automatic Qt 3 form conversion from Qt Designer (since uic3 no longer exists) and move all form load error checking logic including language check into QAbstractFormBuilder. Make language accessible in FormBuilderExtra in case Jambi is revived. Reviewed-by: hjk --- src/uitools/quiloader.cpp | 15 ++++++++++++++- src/uitools/quiloader.h | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/uitools/quiloader.cpp b/src/uitools/quiloader.cpp index 7f39b557ea..457c7ccd13 100644 --- a/src/uitools/quiloader.cpp +++ b/src/uitools/quiloader.cpp @@ -653,7 +653,7 @@ QUiLoader::~QUiLoader() Loads a form from the given \a device and creates a new widget with the given \a parentWidget to hold its contents. - \sa createWidget() + \sa createWidget(), errorString() */ QWidget *QUiLoader::load(QIODevice *device, QWidget *parentWidget) { @@ -936,6 +936,19 @@ bool QUiLoader::isTranslationEnabled() const return d->builder.trEnabled; } +/*! + Returns a human-readable description of the last error occurred in load(). + + \since 5.0 + \sa load() +*/ + +QString QUiLoader::errorString() const +{ + Q_D(const QUiLoader); + return d->builder.errorString(); +} + QT_END_NAMESPACE #include "quiloader.moc" diff --git a/src/uitools/quiloader.h b/src/uitools/quiloader.h index 214342ef83..0c21a276ee 100644 --- a/src/uitools/quiloader.h +++ b/src/uitools/quiloader.h @@ -90,6 +90,8 @@ public: void setTranslationEnabled(bool enabled); bool isTranslationEnabled() const; + QString errorString() const; + private: QScopedPointer d_ptr; Q_DECLARE_PRIVATE(QUiLoader) -- cgit v1.2.3 From 105513a888436ad98e0d85155ea3c09f59a83411 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 19 May 2011 08:34:52 +0200 Subject: Always call XInitThreads. Any Qt application that embeds a QSGView needs to call this because of the threaded renderer. Today applications that use threaded GL silently fail. In a few weeks time, the refactor branch will be merged, which will obsolete this change, so it is a temporary measure to get tests and examples running. --- src/gui/kernel/qapplication_x11.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index 20542ea328..d1f9eb1b8a 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -1740,8 +1740,8 @@ void qt_init(QApplicationPrivate *priv, int, } else { // Qt controls everything (default) - if (QApplication::testAttribute(Qt::AA_X11InitThreads)) - XInitThreads(); + // With the threaded QML renderer, we always need this. + XInitThreads(); // Set application name and class char *app_class = 0; -- cgit v1.2.3 From 4ec4d78711ca08d0dc948bf669a203603a4aaa6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 19 May 2011 10:45:50 +0200 Subject: Fixed compile of qdrawhelper_neon.cpp. We need to use the quad-word intrinsic and reinterpret the cast to a signed int vector. Reviewed-by: Kim Motoyoshi Kalland (cherry picked from commit d2d7aef223a3bad368c6b7c7f7f4617f4acf323c) --- src/gui/painting/qdrawhelper_neon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/painting/qdrawhelper_neon.cpp b/src/gui/painting/qdrawhelper_neon.cpp index e673dd9861..a098e82e19 100644 --- a/src/gui/painting/qdrawhelper_neon.cpp +++ b/src/gui/painting/qdrawhelper_neon.cpp @@ -986,7 +986,7 @@ public: static inline Int32x4 v_toInt(Float32x4 x) { return vcvtq_s32_f32(x); } - static inline Int32x4 v_greaterOrEqual(Float32x4 a, Float32x4 b) { return vcge_f32(a, b); } + static inline Int32x4 v_greaterOrEqual(Float32x4 a, Float32x4 b) { return vreinterpretq_s32_u32(vcgeq_f32(a, b)); } }; const uint * QT_FASTCALL qt_fetch_radial_gradient_neon(uint *buffer, const Operator *op, const QSpanData *data, -- cgit v1.2.3 From 0377b7f96de5b12ab38e0ebd3068c6d17347f39d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 6 May 2011 15:23:43 +0200 Subject: Remove warning from QColor::setNamedColor(). This warning is pointless as the user can anyway check if the color is valid after making the call by calling isValid(). Using isValidColor() could be used but it has a big performance overhead as validation then needs to be done twice. Task-number: QTBUG-19098 Reviewed-by: Erik Verbruggen (cherry picked from commit a423ff5474b89028eeca95b254f5184311c8223b) --- src/gui/painting/qcolor.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index ff6c24ee9e..cd87d215c2 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -532,8 +532,7 @@ QString QColor::name() const void QColor::setNamedColor(const QString &name) { - if (!setColorFromString(name)) - qWarning("QColor::setNamedColor: Unknown color name '%s'", name.toLatin1().constData()); + setColorFromString(name); } /*! -- cgit v1.2.3 From a98ebc599ab7c99a6431d0420d3f0d238f37f6b1 Mon Sep 17 00:00:00 2001 From: Lasse Holmstedt Date: Thu, 19 May 2011 13:55:12 +0200 Subject: Wayland: send surface id + process id pairs to compositor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This enables doing window/process management since we can now actually map the process we've launched to a window. Reviewed-by: Samuel Rødal (cherry picked from commit 457c33d9fd308542c9290fd60bf86960f9251255) --- src/plugins/platforms/wayland/qwaylanddisplay.cpp | 15 ++++ src/plugins/platforms/wayland/qwaylanddisplay.h | 11 +++ src/plugins/platforms/wayland/qwaylandwindow.cpp | 10 ++- src/plugins/platforms/wayland/wayland.pro | 2 + .../qwaylandwindowmanager-client-protocol.h | 82 +++++++++++++++++++++ .../qwaylandwindowmanagerintegration.cpp | 84 ++++++++++++++++++++++ .../qwaylandwindowmanagerintegration.h | 69 ++++++++++++++++++ .../wayland-windowmanager-protocol.c | 36 ++++++++++ .../windowmanager_integration.pri | 16 +++++ 9 files changed, 324 insertions(+), 1 deletion(-) create mode 100644 src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanager-client-protocol.h create mode 100644 src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp create mode 100644 src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.h create mode 100644 src/plugins/platforms/wayland/windowmanager_integration/wayland-windowmanager-protocol.c create mode 100644 src/plugins/platforms/wayland/windowmanager_integration/windowmanager_integration.pri (limited to 'src') diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index 974453d39d..9011f5799a 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -51,6 +51,10 @@ #include "gl_integration/qwaylandglintegration.h" #endif +#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT +#include "windowmanager_integration/qwaylandwindowmanagerintegration.h" +#endif + #include #include #include @@ -97,6 +101,13 @@ QWaylandGLIntegration * QWaylandDisplay::eglIntegration() } #endif +#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT +QWaylandWindowManagerIntegration *QWaylandDisplay::windowManagerIntegration() +{ + return mWindowManagerIntegration; +} +#endif + void QWaylandDisplay::shellHandleConfigure(void *data, struct wl_shell *shell, uint32_t time, uint32_t edges, struct wl_surface *surface, @@ -136,6 +147,10 @@ QWaylandDisplay::QWaylandDisplay(void) mEglIntegration->initialize(); #endif +#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT + mWindowManagerIntegration = QWaylandWindowManagerIntegration::createIntegration(this); +#endif + connect(QAbstractEventDispatcher::instance(), SIGNAL(aboutToBlock()), this, SLOT(flushRequests())); mFd = wl_display_get_fd(mDisplay, sourceUpdate, this); diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.h b/src/plugins/platforms/wayland/qwaylanddisplay.h index 0658956dc3..626636038d 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.h +++ b/src/plugins/platforms/wayland/qwaylanddisplay.h @@ -55,6 +55,8 @@ class QWaylandBuffer; class QPlatformScreen; class QWaylandScreen; class QWaylandGLIntegration; +class QWaylandWindowManagerIntegration; + class QWaylandDisplay : public QObject { Q_OBJECT @@ -74,6 +76,11 @@ public: #ifdef QT_WAYLAND_GL_SUPPORT QWaylandGLIntegration *eglIntegration(); #endif + +#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT + QWaylandWindowManagerIntegration *windowManagerIntegration(); +#endif + void setCursor(QWaylandBuffer *buffer, int32_t x, int32_t y); void syncCallback(wl_display_sync_func_t func, void *data); @@ -124,6 +131,10 @@ private: QWaylandGLIntegration *mEglIntegration; #endif +#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT + QWaylandWindowManagerIntegration *mWindowManagerIntegration; +#endif + static void shellHandleConfigure(void *data, struct wl_shell *shell, uint32_t time, uint32_t edges, struct wl_surface *surface, diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index 53f2f483e9..d2a7647fc0 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -46,6 +46,11 @@ #include "qwaylandinputdevice.h" #include "qwaylandscreen.h" +#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT +#include "windowmanager_integration/qwaylandwindowmanagerintegration.h" +#endif + +#include #include #include @@ -60,6 +65,10 @@ QWaylandWindow::QWaylandWindow(QWidget *window) static WId id = 1; mWindowId = id++; +#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT + mDisplay->windowManagerIntegration()->mapClientToProcess(qApp->applicationPid()); +#endif + mSurface = mDisplay->createSurface(this); } @@ -120,7 +129,6 @@ void QWaylandWindow::attach(QWaylandBuffer *buffer) } } - void QWaylandWindow::damage(const QRegion ®ion) { //We have to do sync stuff before calling damage, or we might diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro index 48734ec99d..3f5a69cf75 100644 --- a/src/plugins/platforms/wayland/wayland.pro +++ b/src/plugins/platforms/wayland/wayland.pro @@ -40,8 +40,10 @@ QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_WAYLAND INCLUDEPATH += $$PWD include ($$PWD/gl_integration/gl_integration.pri) +include ($$PWD/windowmanager_integration/windowmanager_integration.pri) include (../fontdatabases/genericunix/genericunix.pri) target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target + diff --git a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanager-client-protocol.h b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanager-client-protocol.h new file mode 100644 index 0000000000..ec776c5f87 --- /dev/null +++ b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanager-client-protocol.h @@ -0,0 +1,82 @@ +/* + * Copyright © 2010 Kristian Høgsberg + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + + +#ifndef WAYLAND_WINDOWMANAGER_CLIENT_PROTOCOL_H +#define WAYLAND_WINDOWMANAGER_CLIENT_PROTOCOL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include "wayland-util.h" + +struct wl_client; + +struct wl_windowmanager; + +extern const struct wl_interface wl_windowmanager_interface; + +#define WL_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS 0 + +static inline struct wl_windowmanager * +wl_windowmanager_create(struct wl_display *display, uint32_t id, uint32_t /*version*/) +{ + // ### does not run without latest wayland. must be enabled later + //wl_display_bind(display, id, "wl_windowmanager", version); + + return (struct wl_windowmanager *) + wl_proxy_create_for_id(display, &wl_windowmanager_interface, id); +} + +static inline void +wl_windowmanager_set_user_data(struct wl_windowmanager *wl_windowmanager, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) wl_windowmanager, user_data); +} + +static inline void * +wl_windowmanager_get_user_data(struct wl_windowmanager *wl_windowmanager) +{ + return wl_proxy_get_user_data((struct wl_proxy *) wl_windowmanager); +} + +static inline void +wl_windowmanager_destroy(struct wl_windowmanager *wl_windowmanager) +{ + wl_proxy_destroy((struct wl_proxy *) wl_windowmanager); +} + +static inline void +wl_windowmanager_map_client_to_process(struct wl_windowmanager *wl_windowmanager, uint32_t processid) +{ + wl_proxy_marshal((struct wl_proxy *) wl_windowmanager, + WL_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS, processid); +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp new file mode 100644 index 0000000000..8a8e5a9992 --- /dev/null +++ b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandwindowmanagerintegration.h" +#include "qwaylandwindowmanager-client-protocol.h" + +#include + +QWaylandWindowManagerIntegration *QWaylandWindowManagerIntegration::createIntegration(QWaylandDisplay *waylandDisplay) +{ + return new QWaylandWindowManagerIntegration(waylandDisplay); +} + +QWaylandWindowManagerIntegration::QWaylandWindowManagerIntegration(QWaylandDisplay *waylandDisplay) + : mWaylandDisplay(waylandDisplay) + , mWaylandWindowManager(0) +{ + wl_display_add_global_listener(mWaylandDisplay->wl_display(), + QWaylandWindowManagerIntegration::wlHandleListenerGlobal, + this); +} + +QWaylandWindowManagerIntegration::~QWaylandWindowManagerIntegration() +{ + +} + +struct wl_windowmanager *QWaylandWindowManagerIntegration::windowManager() const +{ + return mWaylandWindowManager; +} + +void QWaylandWindowManagerIntegration::wlHandleListenerGlobal(wl_display *display, uint32_t id, const char *interface, + uint32_t version, void *data) +{ + if (strcmp(interface, "wl_windowmanager") == 0) { + QWaylandWindowManagerIntegration *integration = static_cast(data); + integration->mWaylandWindowManager = wl_windowmanager_create(display,id, version); + } +} + +void QWaylandWindowManagerIntegration::mapClientToProcess(long long processId) +{ + wl_windowmanager_map_client_to_process(mWaylandWindowManager, (uint32_t) processId); +} + diff --git a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.h b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.h new file mode 100644 index 0000000000..01a7bdd960 --- /dev/null +++ b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDWINDOWMANAGERINTEGRATION_H +#define QWAYLANDWINDOWMANAGERINTEGRATION_H + +#include +#include "wayland-client.h" +#include "qwaylanddisplay.h" + +class QWaylandWindowManagerIntegration +{ +public: + explicit QWaylandWindowManagerIntegration(QWaylandDisplay *waylandDisplay); + virtual ~QWaylandWindowManagerIntegration(); + static QWaylandWindowManagerIntegration *createIntegration(QWaylandDisplay *waylandDisplay); + struct wl_windowmanager *windowManager() const; + + void mapSurfaceToProcess(struct wl_surface *surface, long long processId); + void mapClientToProcess(long long processId); + +private: + static void wlHandleListenerGlobal(wl_display *display, uint32_t id, + const char *interface, uint32_t version, void *data); + +private: + QWaylandDisplay *mWaylandDisplay; + struct wl_windowmanager *mWaylandWindowManager; +}; + +#endif // QWAYLANDWINDOWMANAGERINTEGRATION_H diff --git a/src/plugins/platforms/wayland/windowmanager_integration/wayland-windowmanager-protocol.c b/src/plugins/platforms/wayland/windowmanager_integration/wayland-windowmanager-protocol.c new file mode 100644 index 0000000000..48049d8571 --- /dev/null +++ b/src/plugins/platforms/wayland/windowmanager_integration/wayland-windowmanager-protocol.c @@ -0,0 +1,36 @@ +/* + * Copyright © 2010 Kristian Høgsberg + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + + +#include +#include +#include "wayland-util.h" + +static const struct wl_message wl_windowmanager_requests[] = { + { "map_client_to_process", "u", NULL }, +}; + +WL_EXPORT const struct wl_interface wl_windowmanager_interface = { + "wl_windowmanager", 1, + ARRAY_LENGTH(wl_windowmanager_requests), wl_windowmanager_requests, + 0, NULL, +}; diff --git a/src/plugins/platforms/wayland/windowmanager_integration/windowmanager_integration.pri b/src/plugins/platforms/wayland/windowmanager_integration/windowmanager_integration.pri new file mode 100644 index 0000000000..a28218272d --- /dev/null +++ b/src/plugins/platforms/wayland/windowmanager_integration/windowmanager_integration.pri @@ -0,0 +1,16 @@ +DEFINES += QT_WAYLAND_WINDOWMANAGER_SUPPORT + +contains(DEFINES, QT_WAYLAND_WINDOWMANAGER_SUPPORT) { + + HEADERS += \ + $$PWD/qwaylandwindowmanager-client-protocol.h \ + $$PWD/qwaylandwindowmanagerintegration.h + + SOURCES += \ + $$PWD/qwaylandwindowmanagerintegration.cpp \ + $$PWD/wayland-windowmanager-protocol.c + +} + + + -- cgit v1.2.3 From 611837baec6a32f8c4d88c34f5b96cce15bf3120 Mon Sep 17 00:00:00 2001 From: Lasse Holmstedt Date: Thu, 19 May 2011 16:30:44 +0200 Subject: Don't crash if windowmanager is not initialized This can happen if there is e.g. no wayland server. Reviewed-by: sroedal (cherry picked from commit aea5e35f57d061b133d2fa613d10f5e0118f5706) --- .../windowmanager_integration/qwaylandwindowmanagerintegration.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp index 8a8e5a9992..b93e6d2f70 100644 --- a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp +++ b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp @@ -79,6 +79,7 @@ void QWaylandWindowManagerIntegration::wlHandleListenerGlobal(wl_display *displa void QWaylandWindowManagerIntegration::mapClientToProcess(long long processId) { - wl_windowmanager_map_client_to_process(mWaylandWindowManager, (uint32_t) processId); + if (mWaylandWindowManager) + wl_windowmanager_map_client_to_process(mWaylandWindowManager, (uint32_t) processId); } -- cgit v1.2.3 From 852e9766ed9f77f21228535390009ee304e505ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 19 May 2011 14:58:18 +0200 Subject: Compile fixes for Xlib plugin. (cherry picked from commit 4af11f2c6666c55657569f946c33816f33711225) --- src/plugins/platforms/xlib/qxlibscreen.cpp | 6 +++--- src/plugins/platforms/xlib/qxlibstatic.cpp | 4 ---- src/plugins/platforms/xlib/qxlibstatic.h | 1 + src/plugins/platforms/xlib/qxlibwindow.cpp | 17 +++++++++-------- 4 files changed, 13 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/xlib/qxlibscreen.cpp b/src/plugins/platforms/xlib/qxlibscreen.cpp index 7c8a367373..920116a614 100644 --- a/src/plugins/platforms/xlib/qxlibscreen.cpp +++ b/src/plugins/platforms/xlib/qxlibscreen.cpp @@ -41,6 +41,8 @@ #include "qxlibscreen.h" +#include + #include "qxlibcursor.h" #include "qxlibwindow.h" #include "qxlibkeyboard.h" @@ -54,8 +56,6 @@ #include -#include - QT_BEGIN_NAMESPACE static int (*original_x_errhandler)(Display *dpy, XErrorEvent *); @@ -201,7 +201,7 @@ QXlibScreen::QXlibScreen() #ifndef DONT_USE_MIT_SHM - Status MIT_SHM_extension_supported = XShmQueryExtension (mDisplay->nativeDisplay()); + int MIT_SHM_extension_supported = XShmQueryExtension (mDisplay->nativeDisplay()); Q_ASSERT(MIT_SHM_extension_supported == True); #endif original_x_errhandler = XSetErrorHandler(qt_x_errhandler); diff --git a/src/plugins/platforms/xlib/qxlibstatic.cpp b/src/plugins/platforms/xlib/qxlibstatic.cpp index 61177812d5..7b562ea50d 100644 --- a/src/plugins/platforms/xlib/qxlibstatic.cpp +++ b/src/plugins/platforms/xlib/qxlibstatic.cpp @@ -51,10 +51,6 @@ #include -#ifndef QT_NO_XFIXES -#include -#endif // QT_NO_XFIXES - static const char * x11_atomnames = { // window-manager <-> client protocols "WM_PROTOCOLS\0" diff --git a/src/plugins/platforms/xlib/qxlibstatic.h b/src/plugins/platforms/xlib/qxlibstatic.h index 8517de0bc2..fec2a16cdf 100644 --- a/src/plugins/platforms/xlib/qxlibstatic.h +++ b/src/plugins/platforms/xlib/qxlibstatic.h @@ -135,6 +135,7 @@ typedef char *XPointer; #endif #ifndef QT_NO_XFIXES +#include typedef Bool (*PtrXFixesQueryExtension)(Display *, int *, int *); typedef Status (*PtrXFixesQueryVersion)(Display *, int *, int *); typedef void (*PtrXFixesSetCursorName)(Display *dpy, Cursor cursor, const char *name); diff --git a/src/plugins/platforms/xlib/qxlibwindow.cpp b/src/plugins/platforms/xlib/qxlibwindow.cpp index 9a05fc620d..90bcc0d9d5 100644 --- a/src/plugins/platforms/xlib/qxlibwindow.cpp +++ b/src/plugins/platforms/xlib/qxlibwindow.cpp @@ -47,14 +47,6 @@ #include "qxlibstatic.h" #include "qxlibdisplay.h" -#include -#include -#include -#include - -#include -#include - #if !defined(QT_NO_OPENGL) #if !defined(QT_OPENGL_ES_2) #include "qglxintegration.h" @@ -66,6 +58,15 @@ #endif //QT_OPENGL_ES_2 #endif //QT_NO_OPENGL + +#include +#include +#include +#include + +#include +#include + //#define MYX11_DEBUG QT_BEGIN_NAMESPACE -- cgit v1.2.3 From 463e31fd58de7d1bc1330ba664dd518b9266bc5e Mon Sep 17 00:00:00 2001 From: Janusz Lewandowski Date: Thu, 19 May 2011 16:21:39 +0200 Subject: Lighthouse minimal: Add support for transparency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge-request: 1231 Reviewed-by: Samuel Rødal (cherry picked from commit c15b41056e60abdbb4d835e27a360f01be618a4f) --- src/plugins/platforms/minimal/qminimalintegration.cpp | 4 ++-- src/plugins/platforms/minimal/qminimalintegration.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/minimal/qminimalintegration.cpp b/src/plugins/platforms/minimal/qminimalintegration.cpp index 3a545e4e5c..44a4eb6adc 100644 --- a/src/plugins/platforms/minimal/qminimalintegration.cpp +++ b/src/plugins/platforms/minimal/qminimalintegration.cpp @@ -50,8 +50,8 @@ QMinimalIntegration::QMinimalIntegration() QMinimalScreen *mPrimaryScreen = new QMinimalScreen(); mPrimaryScreen->mGeometry = QRect(0, 0, 240, 320); - mPrimaryScreen->mDepth = 16; - mPrimaryScreen->mFormat = QImage::Format_RGB16; + mPrimaryScreen->mDepth = 32; + mPrimaryScreen->mFormat = QImage::Format_ARGB32_Premultiplied; mScreens.append(mPrimaryScreen); } diff --git a/src/plugins/platforms/minimal/qminimalintegration.h b/src/plugins/platforms/minimal/qminimalintegration.h index 5f93443b8c..993d364c1b 100644 --- a/src/plugins/platforms/minimal/qminimalintegration.h +++ b/src/plugins/platforms/minimal/qminimalintegration.h @@ -51,7 +51,7 @@ class QMinimalScreen : public QPlatformScreen { public: QMinimalScreen() - : mDepth(16), mFormat(QImage::Format_RGB16) {} + : mDepth(32), mFormat(QImage::Format_ARGB32_Premultiplied) {} QRect geometry() const { return mGeometry; } int depth() const { return mDepth; } -- cgit v1.2.3 From dd43611b970909e74465023180b754e6d48add93 Mon Sep 17 00:00:00 2001 From: Janusz Lewandowski Date: Thu, 19 May 2011 16:21:40 +0200 Subject: Lighthouse xcb and xlib: Add support for transparency of GLX windows. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge-request: 1231 Reviewed-by: Samuel Rødal (cherry picked from commit a3b627e1c5ce03a2500ab35c64729b1995639dcc) --- .../platforms/glxconvenience/glxconvenience.pri | 8 ++++++ .../platforms/glxconvenience/qglxconvenience.cpp | 30 ++++++++++++++++------ .../qwaylandxcompositeglxcontext.cpp | 4 ++- src/plugins/platforms/xcb/qxcbwindow.cpp | 8 +++++- src/plugins/platforms/xcb/qxcbwindow.h | 6 +++++ src/plugins/platforms/xcb/qxcbwindowsurface.cpp | 11 ++++---- src/plugins/platforms/xlib/qxlibintegration.cpp | 2 +- src/plugins/platforms/xlib/qxlibwindow.cpp | 13 ++++++++-- src/plugins/platforms/xlib/qxlibwindow.h | 8 ++++++ src/plugins/platforms/xlib/qxlibwindowsurface.cpp | 13 +++++----- 10 files changed, 78 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/glxconvenience/glxconvenience.pri b/src/plugins/platforms/glxconvenience/glxconvenience.pri index d6c992229e..b4d43a30b5 100644 --- a/src/plugins/platforms/glxconvenience/glxconvenience.pri +++ b/src/plugins/platforms/glxconvenience/glxconvenience.pri @@ -5,3 +5,11 @@ HEADERS += \ SOURCES += \ $$PWD/qglxconvenience.cpp + +CONFIG += xrender + +xrender { + LIBS += -lXrender +} else { + DEFINES += QT_NO_XRENDER +} diff --git a/src/plugins/platforms/glxconvenience/qglxconvenience.cpp b/src/plugins/platforms/glxconvenience/qglxconvenience.cpp index 7cee3e2ea1..eb0f6a6604 100644 --- a/src/plugins/platforms/glxconvenience/qglxconvenience.cpp +++ b/src/plugins/platforms/glxconvenience/qglxconvenience.cpp @@ -43,6 +43,10 @@ #include +#ifndef QT_NO_XRENDER +#include +#endif + enum { XFocusOut = FocusOut, XFocusIn = FocusIn, @@ -84,14 +88,15 @@ QVector qglx_buildSpec(const QPlatformWindowFormat &format, int drawableBit spec[i++] = GLX_ALPHA_SIZE; spec[i++] = (format.alphaBufferSize() == -1) ? 1 : format.alphaBufferSize(); } - spec[i++] = GLX_ACCUM_RED_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); - spec[i++] = GLX_ACCUM_GREEN_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); - spec[i++] = GLX_ACCUM_BLUE_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); + if (format.accum()) { + spec[i++] = GLX_ACCUM_RED_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); + spec[i++] = GLX_ACCUM_GREEN_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); + spec[i++] = GLX_ACCUM_BLUE_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); - if (format.alpha()) { - spec[i++] = GLX_ACCUM_ALPHA_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); + if (format.alpha()) { + spec[i++] = GLX_ACCUM_ALPHA_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); + } } - } else { spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_COLOR_INDEX_BIT; //I'm really not sure if this works.... spec[i++] = GLX_BUFFER_SIZE; spec[i++] = 8; @@ -136,8 +141,17 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , const QPlatformWindow if (reducedFormat.alpha()) { int alphaSize; glXGetFBConfigAttrib(display,configs[i],GLX_ALPHA_SIZE,&alphaSize); - if (alphaSize > 0) - break; + if (alphaSize > 0) { + XVisualInfo *visual = glXGetVisualFromFBConfig(display, chosenConfig); +#if !defined(QT_NO_XRENDER) + XRenderPictFormat *pictFormat = XRenderFindVisualFormat(display, visual->visual); + if (pictFormat->direct.alphaMask > 0) + break; +#else + if (visual->depth == 32) + break; +#endif + } } else { break; // Just choose the first in the list if there's no alpha requested } diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp index caf51170a6..baf0fa3432 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp @@ -132,10 +132,12 @@ void QWaylandXCompositeGLXContext::geometryChanged() Colormap cmap = XCreateColormap(mGlxIntegration->xDisplay(),mGlxIntegration->rootWindow(),visualInfo->visual,AllocNone); XSetWindowAttributes a; + a.background_pixel = WhitePixel(mGlxIntegration->xDisplay(), mGlxIntegration->screen()); + a.border_pixel = BlackPixel(mGlxIntegration->xDisplay(), mGlxIntegration->screen()); a.colormap = cmap; mXWindow = XCreateWindow(mGlxIntegration->xDisplay(), mGlxIntegration->rootWindow(),0, 0, size.width(), size.height(), 0, visualInfo->depth, InputOutput, visualInfo->visual, - CWColormap, &a); + CWBackPixel|CWBorderPixel|CWColormap, &a); XCompositeRedirectWindow(mGlxIntegration->xDisplay(), mXWindow, CompositeRedirectManual); XMapWindow(mGlxIntegration->xDisplay(), mXWindow); diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 0456638ab9..3365c22c39 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -131,13 +131,17 @@ QXcbWindow::QXcbWindow(QWidget *tlw) visualInfo = XGetVisualInfo(DISPLAY_FROM_XCB(this), VisualIDMask, &visualInfoTemplate, &matchingCount); #endif //XCB_USE_GLX if (visualInfo) { + m_depth = visualInfo->depth; + m_format = (m_depth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32; Colormap cmap = XCreateColormap(DISPLAY_FROM_XCB(this), m_screen->root(), visualInfo->visual, AllocNone); XSetWindowAttributes a; + a.background_pixel = WhitePixel(DISPLAY_FROM_XCB(this), m_screen->screenNumber()); + a.border_pixel = BlackPixel(DISPLAY_FROM_XCB(this), m_screen->screenNumber()); a.colormap = cmap; m_window = XCreateWindow(DISPLAY_FROM_XCB(this), m_screen->root(), tlw->x(), tlw->y(), tlw->width(), tlw->height(), 0, visualInfo->depth, InputOutput, visualInfo->visual, - CWColormap, &a); + CWBackPixel|CWBorderPixel|CWColormap, &a); printf("created GL window: %d\n", m_window); } else { @@ -147,6 +151,8 @@ QXcbWindow::QXcbWindow(QWidget *tlw) #endif //defined(XCB_USE_GLX) || defined(XCB_USE_EGL) { m_window = xcb_generate_id(xcb_connection()); + m_depth = m_screen->screen()->root_depth; + m_format = (m_depth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32; Q_XCB_CALL(xcb_create_window(xcb_connection(), XCB_COPY_FROM_PARENT, // depth -- same as root diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index e049837253..20b464061a 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -44,6 +44,7 @@ #include #include +#include #include #include @@ -74,6 +75,8 @@ public: QPlatformGLContext *glContext() const; xcb_window_t window() const { return m_window; } + uint depth() const { return m_depth; } + QImage::Format format() const { return m_format; } void handleExposeEvent(const xcb_expose_event_t *event); void handleClientMessageEvent(const xcb_client_message_event_t *event); @@ -99,6 +102,9 @@ private: xcb_window_t m_window; QPlatformGLContext *m_context; + uint m_depth; + QImage::Format m_format; + xcb_sync_int64_t m_syncValue; xcb_sync_counter_t m_syncCounter; diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp index 718f09383c..38c01f9cfd 100644 --- a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp +++ b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp @@ -58,7 +58,7 @@ class QXcbShmImage : public QXcbObject { public: - QXcbShmImage(QXcbScreen *connection, const QSize &size); + QXcbShmImage(QXcbScreen *connection, const QSize &size, uint depth, QImage::Format format); ~QXcbShmImage() { destroy(); } QImage *image() { return &m_qimage; } @@ -81,7 +81,7 @@ private: QRegion m_dirty; }; -QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size) +QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size, uint depth, QImage::Format format) : QXcbObject(screen->connection()) , m_gc(0) , m_gc_window(0) @@ -91,7 +91,7 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size) size.width(), size.height(), XCB_IMAGE_FORMAT_Z_PIXMAP, - screen->depth(), + depth, 0, ~0, 0); @@ -111,7 +111,7 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size) if (shmctl(m_shm_info.shmid, IPC_RMID, 0) == -1) qWarning() << "QXcbWindowSurface: Error while marking the shared memory segment to be destroyed"; - m_qimage = QImage( (uchar*) m_xcb_image->data, m_xcb_image->width, m_xcb_image->height, m_xcb_image->stride, screen->format()); + m_qimage = QImage( (uchar*) m_xcb_image->data, m_xcb_image->width, m_xcb_image->height, m_xcb_image->stride, format); } void QXcbShmImage::destroy() @@ -232,9 +232,10 @@ void QXcbWindowSurface::resize(const QSize &size) QWindowSurface::resize(size); QXcbScreen *screen = static_cast(QPlatformScreen::platformScreenForWidget(window())); + QXcbWindow* win = static_cast(window()->platformWindow()); delete m_image; - m_image = new QXcbShmImage(screen, size); + m_image = new QXcbShmImage(screen, size, win->depth(), win->format()); Q_XCB_NOOP(connection()); m_syncingResize = true; diff --git a/src/plugins/platforms/xlib/qxlibintegration.cpp b/src/plugins/platforms/xlib/qxlibintegration.cpp index 78f907abd2..b0c8bc9560 100644 --- a/src/plugins/platforms/xlib/qxlibintegration.cpp +++ b/src/plugins/platforms/xlib/qxlibintegration.cpp @@ -150,7 +150,7 @@ bool QXlibIntegration::hasOpenGL() const { #if !defined(QT_NO_OPENGL) #if !defined(QT_OPENGL_ES_2) - QXlibScreen *screen = static_cast(mScreens.at(0)); + QXlibScreen *screen = static_cast(mScreens.at(0)); return glXQueryExtension(screen->display()->nativeDisplay(), 0, 0) != 0; #else static bool eglHasbeenInitialized = false; diff --git a/src/plugins/platforms/xlib/qxlibwindow.cpp b/src/plugins/platforms/xlib/qxlibwindow.cpp index 90bcc0d9d5..4efcb1101c 100644 --- a/src/plugins/platforms/xlib/qxlibwindow.cpp +++ b/src/plugins/platforms/xlib/qxlibwindow.cpp @@ -102,18 +102,27 @@ QXlibWindow::QXlibWindow(QWidget *window) visualInfo = XGetVisualInfo(mScreen->display()->nativeDisplay(), VisualIDMask, &visualInfoTemplate, &matchingCount); #endif //!defined(QT_OPENGL_ES_2) if (visualInfo) { - Colormap cmap = XCreateColormap(mScreen->display()->nativeDisplay(),mScreen->rootWindow(),visualInfo->visual,AllocNone); + mDepth = visualInfo->depth; + mFormat = (mDepth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32; + mVisual = visualInfo->visual; + Colormap cmap = XCreateColormap(mScreen->display()->nativeDisplay(), mScreen->rootWindow(), visualInfo->visual, AllocNone); XSetWindowAttributes a; + a.background_pixel = WhitePixel(mScreen->display()->nativeDisplay(), mScreen->xScreenNumber()); + a.border_pixel = BlackPixel(mScreen->display()->nativeDisplay(), mScreen->xScreenNumber()); a.colormap = cmap; x_window = XCreateWindow(mScreen->display()->nativeDisplay(), mScreen->rootWindow(),x, y, w, h, 0, visualInfo->depth, InputOutput, visualInfo->visual, - CWColormap, &a); + CWBackPixel|CWBorderPixel|CWColormap, &a); } else { qFatal("no window!"); } #endif //!defined(QT_NO_OPENGL) } else { + mDepth = mScreen->depth(); + mFormat = (mDepth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32; + mVisual = mScreen->defaultVisual(); + x_window = XCreateSimpleWindow(mScreen->display()->nativeDisplay(), mScreen->rootWindow(), x, y, w, h, 0 /*border_width*/, mScreen->blackPixel(), mScreen->whitePixel()); diff --git a/src/plugins/platforms/xlib/qxlibwindow.h b/src/plugins/platforms/xlib/qxlibwindow.h index 08694a5026..2d11224c23 100644 --- a/src/plugins/platforms/xlib/qxlibwindow.h +++ b/src/plugins/platforms/xlib/qxlibwindow.h @@ -122,6 +122,10 @@ public: Window xWindow() const; GC graphicsContext() const; + inline uint depth() const { return mDepth; } + QImage::Format format() const { return mFormat; } + Visual* visual() const { return mVisual; } + protected: QVector getNetWmState() const; void setMWMHints(const QXlibMWMHints &mwmhints); @@ -135,6 +139,10 @@ private: Window x_window; GC gc; + uint mDepth; + QImage::Format mFormat; + Visual* mVisual; + GC createGC(); QPlatformGLContext *mGLContext; diff --git a/src/plugins/platforms/xlib/qxlibwindowsurface.cpp b/src/plugins/platforms/xlib/qxlibwindowsurface.cpp index 513f10dc6a..78fe387bb8 100644 --- a/src/plugins/platforms/xlib/qxlibwindowsurface.cpp +++ b/src/plugins/platforms/xlib/qxlibwindowsurface.cpp @@ -80,20 +80,19 @@ void QXlibShmImageInfo::destroy() void QXlibWindowSurface::resizeShmImage(int width, int height) { + QXlibScreen *screen = QXlibScreen::testLiteScreenForWidget(window()); + QXlibWindow *win = static_cast(window()->platformWindow()); #ifdef DONT_USE_MIT_SHM - shm_img = QImage(width, height, QImage::Format_RGB32); + shm_img = QImage(width, height, win->format()); #else - QXlibScreen *screen = QXlibScreen::testLiteScreenForWidget(window()); if (image_info) image_info->destroy(); else image_info = new QXlibShmImageInfo(screen->display()->nativeDisplay()); - Visual *visual = screen->defaultVisual(); - - XImage *image = XShmCreateImage (screen->display()->nativeDisplay(), visual, 24, ZPixmap, 0, + XImage *image = XShmCreateImage (screen->display()->nativeDisplay(), win->visual(), win->depth(), ZPixmap, 0, &image_info->shminfo, width, height); @@ -160,11 +159,11 @@ void QXlibWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPo #ifdef DONT_USE_MIT_SHM // just convert the image every time... if (!shm_img.isNull()) { - Visual *visual = DefaultVisual(screen->display(), screen->xScreenNumber()); + QXlibWindow *win = static_cast(window()->platformWindow()); QImage image = shm_img; //img.convertToFormat( - XImage *xi = XCreateImage(screen->display(), visual, 24, ZPixmap, + XImage *xi = XCreateImage(screen->display(), win->visual(), win->depth(), ZPixmap, 0, (char *) image.scanLine(0), image.width(), image.height(), 32, image.bytesPerLine()); -- cgit v1.2.3 From 3d34c9b78ee96b20c5b99358fa574ce057e9ef47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 19 May 2011 16:18:21 +0200 Subject: Full translucent background support in xcb and xlib backend. Make sure to pick an alpha visual also for non-GL surface types, and to ask for alpha in the window format if the WA_TranslucentBackground attribute is set. Reviewed-by: Janusz Lewandowski (cherry picked from commit 6241e39cff9311c943430ff2f31236b13618f2ac) --- src/gui/kernel/qwidget_qpa.cpp | 11 +++++++++-- src/opengl/qgl_qpa.cpp | 2 ++ src/opengl/qwindowsurface_gl.cpp | 18 +++++++++++++----- src/plugins/platforms/xcb/qxcbwindow.cpp | 3 ++- src/plugins/platforms/xcb/qxcbwindowsurface.cpp | 11 +++++++++++ src/plugins/platforms/xlib/qxlibwindow.cpp | 8 +++++--- src/plugins/platforms/xlib/qxlibwindowsurface.cpp | 14 +++++++++++++- 7 files changed, 55 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qwidget_qpa.cpp b/src/gui/kernel/qwidget_qpa.cpp index 001810e0f4..960073c054 100644 --- a/src/gui/kernel/qwidget_qpa.cpp +++ b/src/gui/kernel/qwidget_qpa.cpp @@ -731,12 +731,19 @@ QPlatformWindowFormat QWidget::platformWindowFormat() const { Q_D(const QWidget); + QPlatformWindowFormat format; + QTLWExtra *extra = d->maybeTopData(); if (extra){ - return extra->platformWindowFormat; + format = extra->platformWindowFormat; } else { - return QPlatformWindowFormat::defaultFormat(); + format = QPlatformWindowFormat::defaultFormat(); } + + if (testAttribute(Qt::WA_TranslucentBackground)) + format.setAlpha(true); + + return format; } void QWidgetPrivate::createSysExtra() diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index 994344c6eb..9da650f98d 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -150,6 +150,8 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) if (shareContext) { winFormat.setSharedContext(shareContext->d_func()->platformContext); } + if (widget->testAttribute(Qt::WA_TranslucentBackground)) + winFormat.setAlpha(true); winFormat.setWindowApi(QPlatformWindowFormat::OpenGL); winFormat.setWindowSurface(false); widget->setPlatformWindowFormat(winFormat); diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 49b3dc2dae..ff5744678d 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -542,19 +542,27 @@ void QGLWindowSurface::beginPaint(const QRegion &) d_ptr->did_paint = true; updateGeometry(); - if (!context()) - return; - int clearFlags = 0; - if (context()->d_func()->workaround_needsFullClearOnEveryFrame) + QGLContext *ctx = reinterpret_cast(window()->d_func()->extraData()->glContext); + + if (!ctx) + return; + + if (ctx->d_func()->workaround_needsFullClearOnEveryFrame) clearFlags = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT; - else if (context()->format().alpha()) + else if (ctx->format().alpha()) clearFlags = GL_COLOR_BUFFER_BIT; if (clearFlags) { + if (d_ptr->fbo) + d_ptr->fbo->bind(); + glClearColor(0.0, 0.0, 0.0, 0.0); glClear(clearFlags); + + if (d_ptr->fbo) + d_ptr->fbo->release(); } } diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 3365c22c39..0dd29eb8b2 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -113,7 +113,8 @@ QXcbWindow::QXcbWindow(QWidget *tlw) #if defined(XCB_USE_GLX) || defined(XCB_USE_EGL) if (tlw->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL - && QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) + && QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL) + || tlw->platformWindowFormat().alpha()) { #if defined(XCB_USE_GLX) XVisualInfo *visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(m_screen),m_screen->screenNumber(), tlw->platformWindowFormat()); diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp index 38c01f9cfd..88a54dc316 100644 --- a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp +++ b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp @@ -54,6 +54,7 @@ #include #include +#include class QXcbShmImage : public QXcbObject { @@ -189,6 +190,16 @@ QPaintDevice *QXcbWindowSurface::paintDevice() void QXcbWindowSurface::beginPaint(const QRegion ®ion) { m_image->preparePaint(region); + + if (m_image->image()->hasAlphaChannel()) { + QPainter p(m_image->image()); + p.setCompositionMode(QPainter::CompositionMode_Source); + const QVector rects = region.rects(); + const QColor blank = Qt::transparent; + for (QVector::const_iterator it = rects.begin(); it != rects.end(); ++it) { + p.fillRect(*it, blank); + } + } } void QXcbWindowSurface::endPaint(const QRegion &) diff --git a/src/plugins/platforms/xlib/qxlibwindow.cpp b/src/plugins/platforms/xlib/qxlibwindow.cpp index 4efcb1101c..50ea7b58e4 100644 --- a/src/plugins/platforms/xlib/qxlibwindow.cpp +++ b/src/plugins/platforms/xlib/qxlibwindow.cpp @@ -81,9 +81,10 @@ QXlibWindow::QXlibWindow(QWidget *window) int w = window->width(); int h = window->height(); - if(window->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL - && QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL) ) { #if !defined(QT_NO_OPENGL) + if(window->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL + && QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL) + || window->platformWindowFormat().alpha()) { #if !defined(QT_OPENGL_ES_2) XVisualInfo *visualInfo = qglx_findVisualInfo(mScreen->display()->nativeDisplay(),mScreen->xScreenNumber(),window->platformWindowFormat()); #else @@ -117,8 +118,9 @@ QXlibWindow::QXlibWindow(QWidget *window) } else { qFatal("no window!"); } + } else #endif //!defined(QT_NO_OPENGL) - } else { + { mDepth = mScreen->depth(); mFormat = (mDepth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32; mVisual = mScreen->defaultVisual(); diff --git a/src/plugins/platforms/xlib/qxlibwindowsurface.cpp b/src/plugins/platforms/xlib/qxlibwindowsurface.cpp index 78fe387bb8..a917f452e8 100644 --- a/src/plugins/platforms/xlib/qxlibwindowsurface.cpp +++ b/src/plugins/platforms/xlib/qxlibwindowsurface.cpp @@ -49,6 +49,8 @@ #include "qxlibscreen.h" #include "qxlibdisplay.h" +#include "qpainter.h" + # include # include # include @@ -108,7 +110,7 @@ void QXlibWindowSurface::resizeShmImage(int width, int height) Q_ASSERT(shm_attach_status == True); - shm_img = QImage( (uchar*) image->data, image->width, image->height, image->bytes_per_line, QImage::Format_RGB32 ); + shm_img = QImage( (uchar*) image->data, image->width, image->height, image->bytes_per_line, win->format() ); #endif painted = false; } @@ -213,6 +215,16 @@ void QXlibWindowSurface::beginPaint(const QRegion ®ion) { Q_UNUSED(region); resizeBuffer(size()); + + if (shm_img.hasAlphaChannel()) { + QPainter p(&shm_img); + p.setCompositionMode(QPainter::CompositionMode_Source); + const QVector rects = region.rects(); + const QColor blank = Qt::transparent; + for (QVector::const_iterator it = rects.begin(); it != rects.end(); ++it) { + p.fillRect(*it, blank); + } + } } void QXlibWindowSurface::endPaint(const QRegion ®ion) -- cgit v1.2.3 From 5a19d52ae7498ef331520c2878128079d3723032 Mon Sep 17 00:00:00 2001 From: Martin Petersson Date: Fri, 6 May 2011 13:00:53 +0200 Subject: Make QHostAddress.toString() follow RFC-5952 for IPv6 address format. Task-number: QTBUG-18426 Reviewed-by: Peter Hartmann (cherry picked from commit ebc134db484eee31491836b619aad1ee86e3070e) --- src/network/kernel/qhostaddress.cpp | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index ae7d7a1486..4e7c286d80 100644 --- a/src/network/kernel/qhostaddress.cpp +++ b/src/network/kernel/qhostaddress.cpp @@ -720,7 +720,8 @@ Q_IPV6ADDR QHostAddress::toIPv6Address() const Returns the address as a string. For example, if the address is the IPv4 address 127.0.0.1, the - returned string is "127.0.0.1". + returned string is "127.0.0.1". For IPv6 the string format will + follow the RFC5952 recommendation. \sa toIPv4Address() */ @@ -741,8 +742,32 @@ QString QHostAddress::toString() const ugle[i] = (quint16(d->a6[2*i]) << 8) | quint16(d->a6[2*i+1]); } QString s; - s.sprintf("%X:%X:%X:%X:%X:%X:%X:%X", - ugle[0], ugle[1], ugle[2], ugle[3], ugle[4], ugle[5], ugle[6], ugle[7]); + QString temp; + bool zeroDetected = false; + bool zeroShortened = false; + for (int i = 0; i < 8; i++) { + if ((ugle[i] != 0) || zeroShortened) { + temp.sprintf("%X", ugle[i]); + s.append(temp); + if (zeroDetected) + zeroShortened = true; + } else { + if (!zeroDetected) { + if (i<7 && (ugle[i+1] == 0)) { + s.append(QLatin1Char(':')); + zeroDetected = true; + } else { + temp.sprintf("%X", ugle[i]); + s.append(temp); + if (i<7) + s.append(QLatin1Char(':')); + } + } + } + if (i<7 && ((ugle[i] != 0) || zeroShortened || (i==0 && zeroDetected))) + s.append(QLatin1Char(':')); + } + if (!d->scopeId.isEmpty()) s.append(QLatin1Char('%') + d->scopeId); return s; -- cgit v1.2.3 From 0ebe0414d23c15cb21ebf212bb8b82d66b68c73b Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Wed, 11 May 2011 16:51:28 +1000 Subject: Fix incorrect hardware address on systems without getifaddrs() On unix systems for which QT_NO_GETIFADDRS is defined, the way that the hardware address field is extracted from the result of a call to qt_safe_ioctl() is incorrect. The address of the ifreq.ifr_addr struct is taken rather than the appropriate member within that struct, sa_data, resulting in a memory offset and subsequently the hardware address has garbage in the first two of six fields. This commit modifies the code to pass the sa_data member instead of the address of the struct as a whole. Task-number: QTBUG-19165 Merge-request: 2614 Reviewed-by: Martin Petersson (cherry picked from commit 004ad12669ef696eeba70fd57d1eb0c67c806d1d) --- src/network/kernel/qnetworkinterface_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/network/kernel/qnetworkinterface_unix.cpp b/src/network/kernel/qnetworkinterface_unix.cpp index 6098bdeee0..7f251a782b 100644 --- a/src/network/kernel/qnetworkinterface_unix.cpp +++ b/src/network/kernel/qnetworkinterface_unix.cpp @@ -219,7 +219,7 @@ static QNetworkInterfacePrivate *findInterface(int socket, QList= 0) { - uchar *addr = (uchar *)&req.ifr_addr; + uchar *addr = (uchar *)req.ifr_addr.sa_data; iface->hardwareAddress = iface->makeHwAddress(6, addr); } #endif -- cgit v1.2.3 From 4f2138ecfbdc58e5cb5b0c7d762197ef69752957 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 16 May 2011 14:04:31 +0200 Subject: Fix inconsistency between Qt and ICU in Shift-JIS codec with regards to ASCII range Qt's Shift-JIS codec maps the characters 0x5c and 0x7e to unicode yen (0x5a) and unicode overline (0x203e). ICU and (as it turns out) Symbian's native Shift-JIS codec preserve 0x5c and 0x7e when converting to Unicode. Qt's behaviour creates a problem when loading japanese web sites that are encoded in Shift-JIS. When they reference external JavaScript files, those tend to inherit the current page encoding (unless the character set is explicitly specified). Consequently JavaScript tends to contain regular expressions (as a built-in feature of the language), which in turn uses backslashes for escape sequences. Therefore it is crucial that the encodings used to decode the script preserve the ASCII range, i.e. do not convert 0x5c (ascii backslash) to something else. This patch corrects the behaviour of Qt's Shift-JIS codec to leave all characters < 0x80 unaltered in the process of conversion to and from Unicode. Task: QTBUG-19335 Reviewed-by: Lars Knoll (cherry picked from commit 8e321cd869da7ff1cf0168da41aa0246b44867cc) --- src/plugins/codecs/jp/qsjiscodec.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/codecs/jp/qsjiscodec.cpp b/src/plugins/codecs/jp/qsjiscodec.cpp index 49190d310f..3ea5300d51 100644 --- a/src/plugins/codecs/jp/qsjiscodec.cpp +++ b/src/plugins/codecs/jp/qsjiscodec.cpp @@ -155,7 +155,9 @@ QString QSjisCodec::convertToUnicode(const char* chars, int len, ConverterState uchar ch = chars[i]; switch (nbuf) { case 0: - if (ch < 0x80 || IsKana(ch)) { + if (ch < 0x80) { + result += QValidChar(ch); + } else if (IsKana(ch)) { // JIS X 0201 Latin or JIS X 0201 Kana u = conv->jisx0201ToUnicode(ch); result += QValidChar(u); -- cgit v1.2.3