From 78ad8f208d8dbe3575194bb9b97d4e42efdc32d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Szczygie=C5=82?= Date: Mon, 15 Feb 2016 20:50:16 +0100 Subject: xcb: Fix drag and drop between xcb screens Set the proper screen before creating a shaped pixmap window in QBasicDrag::startDrag(). Grab mouse again when D&D window is recreated. Task-number: QTBUG-51215 Change-Id: I5cb47d3b11672b56d17b32072d84a722bdcdcd9a Reviewed-by: Friedemann Kleint Reviewed-by: Shawn Rutledge --- src/gui/kernel/qsimpledrag.cpp | 5 +++-- src/gui/kernel/qsimpledrag_p.h | 3 +++ src/plugins/platforms/xcb/qxcbdrag.cpp | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp index 9f38c9b78a..00589d2303 100644 --- a/src/gui/kernel/qsimpledrag.cpp +++ b/src/gui/kernel/qsimpledrag.cpp @@ -88,7 +88,8 @@ static QWindow* topLevelAt(const QPoint &pos) QBasicDrag::QBasicDrag() : m_restoreCursor(false), m_eventLoop(0), m_executed_drop_action(Qt::IgnoreAction), m_can_drop(false), - m_drag(0), m_drag_icon_window(0), m_useCompositing(true) + m_drag(0), m_drag_icon_window(0), m_useCompositing(true), + m_screen(Q_NULLPTR) { } @@ -211,7 +212,7 @@ void QBasicDrag::startDrag() pos = QPoint(); } #endif - recreateShapedPixmapWindow(Q_NULLPTR, pos); + recreateShapedPixmapWindow(m_screen, pos); enableEventFilter(); } diff --git a/src/gui/kernel/qsimpledrag_p.h b/src/gui/kernel/qsimpledrag_p.h index 055136c436..b208c8ccc9 100644 --- a/src/gui/kernel/qsimpledrag_p.h +++ b/src/gui/kernel/qsimpledrag_p.h @@ -90,6 +90,8 @@ protected: bool useCompositing() const { return m_useCompositing; } void setUseCompositing(bool on) { m_useCompositing = on; } + void setScreen(QScreen *screen) { m_screen = screen; } + Qt::DropAction executedDropAction() const { return m_executed_drop_action; } void setExecutedDropAction(Qt::DropAction da) { m_executed_drop_action = da; } @@ -108,6 +110,7 @@ private: QDrag *m_drag; QShapedPixmapWindow *m_drag_icon_window; bool m_useCompositing; + QScreen *m_screen; }; class Q_GUI_EXPORT QSimpleDrag : public QBasicDrag diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp index 9296a6d141..aa6445d2da 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.cpp +++ b/src/plugins/platforms/xcb/qxcbdrag.cpp @@ -193,6 +193,7 @@ void QXcbDrag::startDrag() XCB_ATOM_ATOM, 32, drag_types.size(), (const void *)drag_types.constData()); setUseCompositing(current_virtual_desktop->compositingActive()); + setScreen(current_virtual_desktop->screens().constFirst()->screen()); QBasicDrag::startDrag(); if (connection()->mouseGrabber() == Q_NULLPTR) shapedPixmapWindow()->setMouseGrabEnabled(true); @@ -322,6 +323,9 @@ void QXcbDrag::move(const QPoint &globalPos) if (virtualDesktop != current_virtual_desktop) { setUseCompositing(virtualDesktop->compositingActive()); recreateShapedPixmapWindow(static_cast(screen)->screen(), deviceIndependentPos); + if (connection()->mouseGrabber() == Q_NULLPTR) + shapedPixmapWindow()->setMouseGrabEnabled(true); + current_virtual_desktop = virtualDesktop; } else { QBasicDrag::moveShapedPixmapWindow(deviceIndependentPos); -- cgit v1.2.3 From bb8f01c6018ff4a0e575b5b128fee76b7fe4cbfb Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 17 Feb 2016 16:07:46 +0100 Subject: QRasterPaintEngine::penChanged(): Assert on painter state. Task-number: QTBUG-48823 Task-number: QTCREATORBUG-14888 Change-Id: I043a777da6b4e3dfdc58770fb136240a57707cb7 Reviewed-by: Tim Jenssen --- src/gui/painting/qpaintengine_raster.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 9d981dcc2c..f70bef72d8 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -683,6 +683,7 @@ void QRasterPaintEngine::penChanged() qDebug() << "QRasterPaintEngine::penChanged():" << state()->pen; #endif QRasterPaintEngineState *s = state(); + Q_ASSERT(s); s->strokeFlags |= DirtyPen; s->dirty |= DirtyPen; } @@ -2194,6 +2195,7 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe Q_D(QRasterPaintEngine); QRasterPaintEngineState *s = state(); + Q_ASSERT(s); int sr_l = qFloor(sr.left()); int sr_r = qCeil(sr.right()) - 1; int sr_t = qFloor(sr.top()); @@ -2431,6 +2433,7 @@ void QRasterPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, #endif Q_D(QRasterPaintEngine); QRasterPaintEngineState *s = state(); + Q_ASSERT(s); QImage image; -- cgit v1.2.3 From 8917cdf13b67350d2533335bb06f170b0289bfae Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 18 Feb 2016 13:07:07 +0100 Subject: Windows QPA/font code: Fix warnings as shown by Qt Creator's Clang based code model. Introduce C++ casts and add some conversions. Where possible, increase const-correctness. Task-number: QTBUG-50804 Change-Id: Idd73730ae83b837c065c8c80f500d5336570f228 Reviewed-by: Joerg Bornemann --- .../platforms/windows/qwindowsfontdatabase.cpp | 20 ++-- .../platforms/windows/qwindowsfontengine.cpp | 106 +++++++++++---------- 2 files changed, 66 insertions(+), 60 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp index 1adf4115c9..322ba0ec27 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp @@ -269,10 +269,10 @@ namespace { quint16 nameIds[requiredRecordCount] = { 1, 2, 3, 4, 6 }; int sizeOfHeader = sizeof(NameTable) + sizeof(NameRecord) * requiredRecordCount; - int newFamilyNameSize = newFamilyName.size() * sizeof(quint16); + int newFamilyNameSize = newFamilyName.size() * int(sizeof(quint16)); const QString regularString = QString::fromLatin1("Regular"); - int regularStringSize = regularString.size() * sizeof(quint16); + int regularStringSize = regularString.size() * int(sizeof(quint16)); // Align table size of table to 32 bits (pad with 0) int fullSize = ((sizeOfHeader + newFamilyNameSize + regularStringSize) & ~3) + 4; @@ -792,7 +792,7 @@ static QString getEnglishName(const uchar *table, quint32 bytes) length /= 2; i18n_name.resize(length); - QChar *uc = (QChar *) i18n_name.unicode(); + QChar *uc = const_cast(i18n_name.unicode()); const unsigned char *string = table + string_offset + offset; for (int i = 0; i < length; ++i) uc[i] = getUShort(string + 2*i); @@ -800,10 +800,10 @@ static QString getEnglishName(const uchar *table, quint32 bytes) // Apple Roman i18n_name.resize(length); - QChar *uc = (QChar *) i18n_name.unicode(); + QChar *uc = const_cast(i18n_name.unicode()); const unsigned char *string = table + string_offset + offset; for (int i = 0; i < length; ++i) - uc[i] = QLatin1Char(string[i]); + uc[i] = QLatin1Char(char(string[i])); } } } @@ -1154,8 +1154,9 @@ QT_WARNING_POP DWORD count = 0; QByteArray newFontData = font.data(); - HANDLE fontHandle = AddFontMemResourceEx((void *)newFontData.constData(), newFontData.size(), 0, - &count); + HANDLE fontHandle = + AddFontMemResourceEx(const_cast(newFontData.constData()), + DWORD(newFontData.size()), 0, &count); if (count == 0 && fontHandle != 0) { RemoveFontMemResourceEx(fontHandle); fontHandle = 0; @@ -1373,8 +1374,9 @@ QStringList QWindowsFontDatabase::addApplicationFont(const QByteArray &fontData, return families; DWORD dummy = 0; - font.handle = AddFontMemResourceEx((void *)fontData.constData(), fontData.size(), 0, - &dummy); + font.handle = + AddFontMemResourceEx(const_cast(fontData.constData()), + DWORD(fontData.size()), 0, &dummy); if (font.handle == 0) return QStringList(); diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp index 00f9ecea60..cda8386ca0 100644 --- a/src/plugins/platforms/windows/qwindowsfontengine.cpp +++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp @@ -159,6 +159,12 @@ bool QWindowsFontEngine::hasEbdtTable() const return GetFontData(hdc, MAKE_TAG('E', 'B', 'D', 'T'), 0, 0, 0) != GDI_ERROR; } +static inline QString stringFromOutLineTextMetric(const OUTLINETEXTMETRIC *otm, PSTR offset) +{ + const uchar *p = reinterpret_cast(otm) + quintptr(offset); + return QString::fromWCharArray(reinterpret_cast(p)); +} + void QWindowsFontEngine::getCMap() { ttf = (bool)(tm.tmPitchAndFamily & TMPF_TRUETYPE) || hasCMapTable(); @@ -182,11 +188,12 @@ void QWindowsFontEngine::getCMap() _faceId.index = 0; if(cmap) { OUTLINETEXTMETRIC *otm = getOutlineTextMetric(hdc); - designToDevice = QFixed((int)otm->otmEMSquare)/QFixed::fromReal(fontDef.pixelSize); - unitsPerEm = otm->otmEMSquare; - x_height = (int)otm->otmsXHeight; - loadKerningPairs(QFixed((int)otm->otmEMSquare)/int(otm->otmTextMetrics.tmHeight)); - _faceId.filename = QFile::encodeName(QString::fromWCharArray((wchar_t *)((char *)otm + (quintptr)otm->otmpFullName))); + unitsPerEm = int(otm->otmEMSquare); + const QFixed unitsPerEmF(unitsPerEm); + designToDevice = unitsPerEmF / QFixed::fromReal(fontDef.pixelSize); + x_height = int(otm->otmsXHeight); + loadKerningPairs(unitsPerEmF / int(otm->otmTextMetrics.tmHeight)); + _faceId.filename = QFile::encodeName(stringFromOutLineTextMetric(otm, otm->otmpFullName)); lineWidth = otm->otmsUnderscoreSize; fsType = otm->otmfsType; free(otm); @@ -387,9 +394,9 @@ void QWindowsFontEngine::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::Shape for(int i = 0; i < glyphs->numGlyphs; i++) { unsigned int glyph = glyphs->glyphs[i]; if(int(glyph) >= designAdvancesSize) { - int newSize = (glyph + 256) >> 8 << 8; - designAdvances = q_check_ptr((QFixed *)realloc(designAdvances, - newSize*sizeof(QFixed))); + const int newSize = int(glyph + 256) >> 8 << 8; + designAdvances = reinterpret_cast(realloc(designAdvances, size_t(newSize) * sizeof(QFixed))); + Q_CHECK_PTR(designAdvances); for(int i = designAdvancesSize; i < newSize; ++i) designAdvances[i] = -1000000; designAdvancesSize = newSize; @@ -411,9 +418,9 @@ void QWindowsFontEngine::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::Shape unsigned int glyph = glyphs->glyphs[i]; if (glyph >= widthCacheSize) { - int newSize = (glyph + 256) >> 8 << 8; - widthCache = q_check_ptr((unsigned char *)realloc(widthCache, - newSize*sizeof(QFixed))); + const uint newSize = (glyph + 256) >> 8 << 8; + widthCache = reinterpret_cast(realloc(widthCache, newSize * sizeof(QFixed))); + Q_CHECK_PTR(widthCache); memset(widthCache + widthCacheSize, 0, newSize - widthCacheSize); widthCacheSize = newSize; } @@ -433,7 +440,7 @@ void QWindowsFontEngine::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::Shape ++chrLen; } SIZE size = {0, 0}; - GetTextExtentPoint32(hdc, (wchar_t *)ch, chrLen, &size); + GetTextExtentPoint32(hdc, reinterpret_cast(ch), chrLen, &size); width = size.cx; } else { calculateTTFGlyphWidth(hdc, glyph, width); @@ -441,7 +448,7 @@ void QWindowsFontEngine::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::Shape glyphs->advances[i] = width; // if glyph's within cache range, store it for later if (width > 0 && width < 0x100) - widthCache[glyph] = width; + widthCache[glyph] = uchar(width); } } @@ -482,10 +489,10 @@ bool QWindowsFontEngine::getOutlineMetrics(glyph_t glyph, const QTransform &t, g // results provided when transforming via MAT2 does not // match the glyphs that are drawn using a WorldTransform XFORM xform; - xform.eM11 = t.m11(); - xform.eM12 = t.m12(); - xform.eM21 = t.m21(); - xform.eM22 = t.m22(); + xform.eM11 = FLOAT(t.m11()); + xform.eM12 = FLOAT(t.m12()); + xform.eM21 = FLOAT(t.m21()); + xform.eM22 = FLOAT(t.m22()); xform.eDx = 0; xform.eDy = 0; SetGraphicsMode(hdc, GM_ADVANCED); @@ -507,7 +514,8 @@ bool QWindowsFontEngine::getOutlineMetrics(glyph_t glyph, const QTransform &t, g if (res != GDI_ERROR) { *metrics = glyph_metrics_t(gm.gmptGlyphOrigin.x, -gm.gmptGlyphOrigin.y, - (int)gm.gmBlackBoxX, (int)gm.gmBlackBoxY, gm.gmCellIncX, gm.gmCellIncY); + int(gm.gmBlackBoxX), int(gm.gmBlackBoxY), + gm.gmCellIncX, gm.gmCellIncY); return true; } else { return false; @@ -526,7 +534,7 @@ glyph_metrics_t QWindowsFontEngine::boundingBox(glyph_t glyph, const QTransform if (!ttf && !success) { // Bitmap fonts - wchar_t ch = glyph; + wchar_t ch = wchar_t(glyph); ABCFLOAT abc; GetCharABCWidthsFloat(hdc, ch, ch, &abc); int width = qRound(abc.abcfB); @@ -791,7 +799,7 @@ static bool addGlyphToPath(glyph_t glyph, const QFixedPoint &position, HDC hdc, return false; // #### obey scale *metric = glyph_metrics_t(gMetric.gmptGlyphOrigin.x, -gMetric.gmptGlyphOrigin.y, - (int)gMetric.gmBlackBoxX, (int)gMetric.gmBlackBoxY, + int(gMetric.gmBlackBoxX), int(gMetric.gmBlackBoxY), gMetric.gmCellIncX, gMetric.gmCellIncY); } #endif @@ -801,17 +809,15 @@ static bool addGlyphToPath(glyph_t glyph, const QFixedPoint &position, HDC hdc, if (ttf) glyphFormat |= GGO_GLYPH_INDEX; - int bufferSize = GDI_ERROR; - bufferSize = GetGlyphOutline(hdc, glyph, glyphFormat, &gMetric, 0, 0, &mat); - if ((DWORD)bufferSize == GDI_ERROR) { + const DWORD bufferSize = GetGlyphOutline(hdc, glyph, glyphFormat, &gMetric, 0, 0, &mat); + if (bufferSize == GDI_ERROR) return false; - } - void *dataBuffer = new char[bufferSize]; + char *dataBuffer = new char[bufferSize]; DWORD ret = GDI_ERROR; ret = GetGlyphOutline(hdc, glyph, glyphFormat, &gMetric, bufferSize, dataBuffer, &mat); if (ret == GDI_ERROR) { - delete [](char *)dataBuffer; + delete [] dataBuffer; return false; } @@ -824,20 +830,18 @@ static bool addGlyphToPath(glyph_t glyph, const QFixedPoint &position, HDC hdc, } #endif - int offset = 0; - int headerOffset = 0; - TTPOLYGONHEADER *ttph = 0; + DWORD offset = 0; + DWORD headerOffset = 0; QPointF oset = position.toPointF(); while (headerOffset < bufferSize) { - ttph = (TTPOLYGONHEADER*)((char *)dataBuffer + headerOffset); + const TTPOLYGONHEADER *ttph = reinterpret_cast(dataBuffer + headerOffset); QPointF lastPoint(qt_to_qpointf(ttph->pfxStart, scale)); path->moveTo(lastPoint + oset); offset += sizeof(TTPOLYGONHEADER); - TTPOLYCURVE *curve; - while (offsetcb)) { - curve = (TTPOLYCURVE*)((char*)(dataBuffer) + offset); + while (offset < headerOffset + ttph->cb) { + const TTPOLYCURVE *curve = reinterpret_cast(dataBuffer + offset); switch (curve->wType) { case TT_PRIM_LINE: { for (int i=0; icpfx; ++i) { @@ -882,7 +886,7 @@ static bool addGlyphToPath(glyph_t glyph, const QFixedPoint &position, HDC hdc, path->closeSubpath(); headerOffset += ttph->cb; } - delete [] (char*)dataBuffer; + delete [] dataBuffer; return true; } @@ -980,15 +984,15 @@ QFontEngine::Properties QWindowsFontEngine::properties() const Properties p; p.emSquare = unitsPerEm; p.italicAngle = otm->otmItalicAngle; - p.postscriptName = QString::fromWCharArray((wchar_t *)((char *)otm + (quintptr)otm->otmpFamilyName)).toLatin1(); - p.postscriptName += QString::fromWCharArray((wchar_t *)((char *)otm + (quintptr)otm->otmpStyleName)).toLatin1(); - p.postscriptName = QFontEngine::convertToPostscriptFontFamilyName(p.postscriptName); + const QByteArray name = stringFromOutLineTextMetric(otm, otm->otmpFamilyName).toLatin1() + + stringFromOutLineTextMetric(otm, otm->otmpStyleName).toLatin1(); + p.postscriptName = QFontEngine::convertToPostscriptFontFamilyName(name); p.boundingBox = QRectF(otm->otmrcFontBox.left, -otm->otmrcFontBox.top, otm->otmrcFontBox.right - otm->otmrcFontBox.left, otm->otmrcFontBox.top - otm->otmrcFontBox.bottom); p.ascent = otm->otmAscent; p.descent = -otm->otmDescent; - p.leading = (int)otm->otmLineGap; + p.leading = int(otm->otmLineGap); p.capHeight = 0; p.lineWidth = otm->otmsUnderscoreSize; free(otm); @@ -1054,10 +1058,10 @@ QWindowsNativeImage *QWindowsFontEngine::drawGDIGlyph(HFONT font, glyph_t glyph, XFORM xform; if (has_transformation) { - xform.eM11 = t.m11(); - xform.eM12 = t.m12(); - xform.eM21 = t.m21(); - xform.eM22 = t.m22(); + xform.eM11 = FLOAT(t.m11()); + xform.eM12 = FLOAT(t.m12()); + xform.eM21 = FLOAT(t.m21()); + xform.eM22 = FLOAT(t.m22()); xform.eDx = margin; xform.eDy = margin; @@ -1067,7 +1071,7 @@ QWindowsNativeImage *QWindowsFontEngine::drawGDIGlyph(HFONT font, glyph_t glyph, SetWorldTransform(hdc, &xform); HGDIOBJ old_font = SelectObject(hdc, font); - int ggo_options = GGO_METRICS | (ttf ? GGO_GLYPH_INDEX : 0); + const UINT ggo_options = GGO_METRICS | (ttf ? GGO_GLYPH_INDEX : 0); GLYPHMETRICS tgm; MAT2 mat; memset(&mat, 0, sizeof(mat)); @@ -1081,13 +1085,13 @@ QWindowsNativeImage *QWindowsFontEngine::drawGDIGlyph(HFONT font, glyph_t glyph, SelectObject(hdc, old_font); if (result == GDI_ERROR) { - const int errorCode = GetLastError(); + const int errorCode = int(GetLastError()); qErrnoWarning(errorCode, "QWinFontEngine: unable to query transformed glyph metrics (GetGlyphOutline() failed, error %d)...", errorCode); return 0; } - iw = tgm.gmBlackBoxX; - ih = tgm.gmBlackBoxY; + iw = int(tgm.gmBlackBoxX); + ih = int(tgm.gmBlackBoxY); xform.eDx -= tgm.gmptGlyphOrigin.x; xform.eDy += tgm.gmptGlyphOrigin.y; @@ -1124,11 +1128,11 @@ QWindowsNativeImage *QWindowsFontEngine::drawGDIGlyph(HFONT font, glyph_t glyph, if (has_transformation) { SetGraphicsMode(hdc, GM_ADVANCED); SetWorldTransform(hdc, &xform); - ExtTextOut(hdc, 0, 0, options, 0, (LPCWSTR) &glyph, 1, 0); + ExtTextOut(hdc, 0, 0, options, 0, reinterpret_cast(&glyph), 1, 0); } else #endif // !Q_OS_WINCE { - ExtTextOut(hdc, -gx + margin, -gy + margin, options, 0, (LPCWSTR) &glyph, 1, 0); + ExtTextOut(hdc, -gx + margin, -gy + margin, options, 0, reinterpret_cast(&glyph), 1, 0); } SelectObject(hdc, old_font); @@ -1159,7 +1163,7 @@ QImage QWindowsFontEngine::alphaMapForGlyph(glyph_t glyph, const QTransform &xfo QImage::Format mask_format = QWindowsNativeImage::systemFormat(); mask_format = QImage::Format_RGB32; - QWindowsNativeImage *mask = drawGDIGlyph(font, glyph, 0, xform, mask_format); + const QWindowsNativeImage *mask = drawGDIGlyph(font, glyph, 0, xform, mask_format); if (mask == 0) { if (m_fontEngineData->clearTypeEnabled) DeleteObject(font); @@ -1206,11 +1210,11 @@ QImage QWindowsFontEngine::alphaRGBMapForGlyph(glyph_t glyph, QFixed, const QTra UINT contrast; SystemParametersInfo(SPI_GETFONTSMOOTHINGCONTRAST, 0, &contrast, 0); - SystemParametersInfo(SPI_SETFONTSMOOTHINGCONTRAST, 0, (void *) 1000, 0); + SystemParametersInfo(SPI_SETFONTSMOOTHINGCONTRAST, 0, reinterpret_cast(quintptr(1000)), 0); int margin = glyphMargin(QFontEngine::Format_A32); QWindowsNativeImage *mask = drawGDIGlyph(font, glyph, margin, t, QImage::Format_RGB32); - SystemParametersInfo(SPI_SETFONTSMOOTHINGCONTRAST, 0, (void *) quintptr(contrast), 0); + SystemParametersInfo(SPI_SETFONTSMOOTHINGCONTRAST, 0, reinterpret_cast(quintptr(contrast)), 0); if (mask == 0) return QImage(); -- cgit v1.2.3 From 67ced1d9c443011f1d1e332be2ed1abb2ef22456 Mon Sep 17 00:00:00 2001 From: Paolo Angelelli Date: Thu, 11 Feb 2016 13:54:19 +0100 Subject: OpenGL: Fix for incorrect GL enum in getter QOpenGLShaderProgram::defaultInnerTessellationLevels() uses the wrong GL enum. This patch fixes it. Change-Id: I2d7ebfad27f7b36d3047d80bfacba65c43c68165 Reviewed-by: Sean Harmer --- src/gui/opengl/qopenglshaderprogram.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/opengl/qopenglshaderprogram.cpp b/src/gui/opengl/qopenglshaderprogram.cpp index 9714aa4bec..d567800fbd 100644 --- a/src/gui/opengl/qopenglshaderprogram.cpp +++ b/src/gui/opengl/qopenglshaderprogram.cpp @@ -3386,7 +3386,7 @@ QVector QOpenGLShaderProgram::defaultInnerTessellationLevels() const #if defined(QT_OPENGL_4) Q_D(const QOpenGLShaderProgram); if (d->tessellationFuncs) - d->tessellationFuncs->glGetFloatv(GL_PATCH_DEFAULT_OUTER_LEVEL, tessLevels.data()); + d->tessellationFuncs->glGetFloatv(GL_PATCH_DEFAULT_INNER_LEVEL, tessLevels.data()); #endif return tessLevels; } -- cgit v1.2.3 From fef629cd9191bb73f22c5efb6f943e6b672953c1 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 5 Feb 2016 13:25:13 +0100 Subject: Disable unneeded ligatures when letter spacing is set For writing systems where glyph substitutions are purely cosmetic, we should disable them when letter spacing is set, otherwise we get ligatures where the spacing is not applied. To avoid changing Harfbuzz-NG upstream, we detect this case when fetching the GSUB table and return an empty blob instead. Task-number: QTBUG-44393 Change-Id: Ie5f6b2d795d7fecbba0ece3941fb70ba7f04c395 Reviewed-by: Lars Knoll Reviewed-by: Simon Hausmann --- src/gui/text/qharfbuzzng.cpp | 15 ++++++++++++++- src/gui/text/qharfbuzzng_p.h | 3 +++ src/gui/text/qtextengine.cpp | 19 ++++++++++++++++--- src/gui/text/qtextengine_p.h | 8 +++++++- 4 files changed, 40 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gui/text/qharfbuzzng.cpp b/src/gui/text/qharfbuzzng.cpp index b2edfc00a0..6437465da8 100644 --- a/src/gui/text/qharfbuzzng.cpp +++ b/src/gui/text/qharfbuzzng.cpp @@ -573,17 +573,27 @@ _hb_qt_font_get_glyph_from_name(hb_font_t * /*font*/, void * /*font_data*/, static hb_user_data_key_t _useDesignMetricsKey; +static hb_user_data_key_t _ignoreGSUB; void hb_qt_font_set_use_design_metrics(hb_font_t *font, uint value) { hb_font_set_user_data(font, &_useDesignMetricsKey, (void *)quintptr(value), NULL, true); } +void hb_qt_face_set_ignore_gsub(hb_face_t *face, uint value) +{ + hb_face_set_user_data(face, &_ignoreGSUB, (void *)quintptr(value), NULL, true); +} + uint hb_qt_font_get_use_design_metrics(hb_font_t *font) { return quintptr(hb_font_get_user_data(font, &_useDesignMetricsKey)); } +uint hb_qt_face_get_ignore_gsub(hb_face_t *face) +{ + return quintptr(hb_face_get_user_data(face, &_ignoreGSUB)); +} struct _hb_qt_font_funcs_t { _hb_qt_font_funcs_t() @@ -618,11 +628,14 @@ hb_font_funcs_t *hb_qt_get_font_funcs() static hb_blob_t * -_hb_qt_reference_table(hb_face_t * /*face*/, hb_tag_t tag, void *user_data) +_hb_qt_reference_table(hb_face_t *face, hb_tag_t tag, void *user_data) { QFontEngine::FaceData *data = static_cast(user_data); Q_ASSERT(data); + if (hb_qt_face_get_ignore_gsub(face) && tag == HB_TAG('G','S','U','B')) + return hb_blob_get_empty(); + qt_get_font_table_func_t get_font_table = data->get_font_table; Q_ASSERT(get_font_table); diff --git a/src/gui/text/qharfbuzzng_p.h b/src/gui/text/qharfbuzzng_p.h index d5e11e6264..8beadbc72c 100644 --- a/src/gui/text/qharfbuzzng_p.h +++ b/src/gui/text/qharfbuzzng_p.h @@ -72,6 +72,9 @@ Q_GUI_EXPORT hb_font_t *hb_qt_font_get_for_engine(QFontEngine *fe); Q_GUI_EXPORT void hb_qt_font_set_use_design_metrics(hb_font_t *font, uint value); Q_GUI_EXPORT uint hb_qt_font_get_use_design_metrics(hb_font_t *font); +Q_GUI_EXPORT void hb_qt_face_set_ignore_gsub(hb_face_t *font, uint value); +Q_GUI_EXPORT uint hb_qt_face_get_ignore_gsub(hb_face_t *font); + QT_END_NAMESPACE #endif // QHARFBUZZNG_P_H diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 1c924175e2..7dc8e8fadb 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1059,7 +1059,7 @@ void QTextEngine::shapeText(int item) const #ifdef QT_ENABLE_HARFBUZZ_NG if (Q_LIKELY(qt_useHarfbuzzNG())) - si.num_glyphs = shapeTextWithHarfbuzzNG(si, string, itemLength, fontEngine, itemBoundaries, kerningEnabled); + si.num_glyphs = shapeTextWithHarfbuzzNG(si, string, itemLength, fontEngine, itemBoundaries, kerningEnabled, letterSpacing != 0); else #endif si.num_glyphs = shapeTextWithHarfbuzz(si, string, itemLength, fontEngine, itemBoundaries, kerningEnabled); @@ -1121,7 +1121,13 @@ QT_BEGIN_INCLUDE_NAMESPACE QT_END_INCLUDE_NAMESPACE -int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *string, int itemLength, QFontEngine *fontEngine, const QVector &itemBoundaries, bool kerningEnabled) const +int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, + const ushort *string, + int itemLength, + QFontEngine *fontEngine, + const QVector &itemBoundaries, + bool kerningEnabled, + bool hasLetterSpacing) const { uint glyphs_shaped = 0; @@ -1135,7 +1141,8 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *st hb_segment_properties_t props = HB_SEGMENT_PROPERTIES_DEFAULT; props.direction = si.analysis.bidiLevel % 2 ? HB_DIRECTION_RTL : HB_DIRECTION_LTR; - props.script = hb_qt_script_to_script(QChar::Script(si.analysis.script)); + QChar::Script script = QChar::Script(si.analysis.script); + props.script = hb_qt_script_to_script(script); // ### props.language = hb_language_get_default_for_script(props.script); for (int k = 0; k < itemBoundaries.size(); k += 3) { @@ -1168,6 +1175,12 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *st Q_ASSERT(hb_font); hb_qt_font_set_use_design_metrics(hb_font, option.useDesignMetrics() ? uint(QFontEngine::DesignMetrics) : 0); // ### + bool scriptRequiresOpenType = ((script >= QChar::Script_Syriac && script <= QChar::Script_Sinhala) + || script == QChar::Script_Khmer || script == QChar::Script_Nko); + hb_face_t *hb_face = hb_font_get_face(hb_font); + Q_ASSERT(hb_face); + hb_qt_face_set_ignore_gsub(hb_face, hasLetterSpacing && !scriptRequiresOpenType); + const hb_feature_t features[1] = { { HB_TAG('k','e','r','n'), !!kerningEnabled, 0, uint(-1) } }; diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index 39c228fd52..7e507bba2d 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -643,7 +643,13 @@ private: void addRequiredBoundaries() const; void shapeText(int item) const; #ifdef QT_ENABLE_HARFBUZZ_NG - int shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *string, int itemLength, QFontEngine *fontEngine, const QVector &itemBoundaries, bool kerningEnabled) const; + int shapeTextWithHarfbuzzNG(const QScriptItem &si, + const ushort *string, + int itemLength, + QFontEngine *fontEngine, + const QVector &itemBoundaries, + bool kerningEnabled, + bool hasLetterSpacing) const; #endif int shapeTextWithHarfbuzz(const QScriptItem &si, const ushort *string, int itemLength, QFontEngine *fontEngine, const QVector &itemBoundaries, bool kerningEnabled) const; -- cgit v1.2.3 From 342c909b340cb1bfbb95480fc79dcea21a470c83 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 3 Feb 2016 13:53:44 +0100 Subject: Qt Quick: Fix selection when mixing line breaks and line wraps The enabler for finding selection ranges in Qt Quick had two bugs which caused some selected text to disappear. Specifically, this was the case for selected text where a line contained both an explicit break and a break due to line wrapping. First of all, the glyphsEnd that is passed into glyphRunsWithInfo() is expected to be inclusive, since we are actually searching for its index in the log cluster array. We would in certain cases not find the glyph at all in the log clusters, thus the glyph run would be set to overlap with any glyph run coming after it in the same item. Second of all, we need to start searching at the correct position in the log clusters when searching for the correct rangeStart, since rangeStart is initialized with textPosition. Otherwise, we would in some cases never reach the start of the range, and rangeStart would be set to textPosition + textLength, which is the end of the range. Task-number: QTBUG-49596 Change-Id: I436ba3f1c7414d4f5044d9b70aa04c60b01755e4 Reviewed-by: Simon Hausmann --- src/gui/text/qtextlayout.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 9e2a23a7f7..bc9c452ff7 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -2141,6 +2141,7 @@ static QGlyphRun glyphRunWithInfo(QFontEngine *fontEngine, QGlyphRunPrivate *d = QGlyphRunPrivate::get(glyphRun); int rangeStart = textPosition; + logClusters += textPosition; while (*logClusters != glyphsStart && rangeStart < textPosition + textLength) { ++logClusters; ++rangeStart; @@ -2325,16 +2326,16 @@ QList QTextLine::glyphRuns(int from, int length) const if (mainFontEngine->type() == QFontEngine::Multi) { QFontEngineMulti *multiFontEngine = static_cast(mainFontEngine); - int end = rtl ? glyphLayout.numGlyphs : 0; - int start = rtl ? end : 0; - int which = glyphLayout.glyphs[rtl ? start - 1 : end] >> 24; - for (; (rtl && start > 0) || (!rtl && end < glyphLayout.numGlyphs); + int start = rtl ? glyphLayout.numGlyphs : 0; + int end = start - 1; + int which = glyphLayout.glyphs[rtl ? start - 1 : end + 1] >> 24; + for (; (rtl && start > 0) || (!rtl && end < glyphLayout.numGlyphs - 1); rtl ? --start : ++end) { - const int e = glyphLayout.glyphs[rtl ? start - 1 : end] >> 24; + const int e = glyphLayout.glyphs[rtl ? start - 1 : end + 1] >> 24; if (e == which) continue; - QGlyphLayout subLayout = glyphLayout.mid(start, end - start); + QGlyphLayout subLayout = glyphLayout.mid(start, end - start + 1); multiFontEngine->ensureEngineAt(which); QGlyphRun::GlyphRunFlags subFlags = flags; @@ -2358,13 +2359,13 @@ QList QTextLine::glyphRuns(int from, int length) const } if (rtl) - end = start; + end = start - 1; else - start = end; + start = end + 1; which = e; } - QGlyphLayout subLayout = glyphLayout.mid(start, end - start); + QGlyphLayout subLayout = glyphLayout.mid(start, end - start + 1); multiFontEngine->ensureEngineAt(which); QGlyphRun::GlyphRunFlags subFlags = flags; -- cgit v1.2.3 From b20548f9999d8c111268f3f2287c0801c6c5cbb0 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 18 Feb 2016 13:13:49 +0100 Subject: Windows QPA: Fix warnings as shown by Qt Creator's Clang based code model. Code except font, accessibility and file qwindowswindow.cpp. Task-number: QTBUG-50804 Change-Id: I40848264f9fa16eea00cf70d7be009c484c49e92 Reviewed-by: Oliver Wolff --- .../platforms/windows/qwindowsbackingstore.cpp | 4 +- .../platforms/windows/qwindowsclipboard.cpp | 4 +- src/plugins/platforms/windows/qwindowscontext.cpp | 46 +++---- src/plugins/platforms/windows/qwindowscursor.cpp | 6 +- src/plugins/platforms/windows/qwindowsdrag.cpp | 4 +- .../platforms/windows/qwindowseglcontext.cpp | 12 +- .../platforms/windows/qwindowsglcontext.cpp | 6 +- .../platforms/windows/qwindowsinputcontext.cpp | 25 ++-- .../platforms/windows/qwindowsintegration.cpp | 4 +- .../platforms/windows/qwindowskeymapper.cpp | 66 ++++----- src/plugins/platforms/windows/qwindowsmime.cpp | 152 ++++++++++----------- .../platforms/windows/qwindowsmousehandler.cpp | 20 +-- .../platforms/windows/qwindowsnativeimage.cpp | 8 +- src/plugins/platforms/windows/qwindowsole.cpp | 12 +- src/plugins/platforms/windows/qwindowsole.h | 2 +- .../platforms/windows/qwindowsopengltester.cpp | 15 +- .../platforms/windows/qwindowsopengltester.h | 8 +- src/plugins/platforms/windows/qwindowsscreen.cpp | 6 +- src/plugins/platforms/windows/qwindowsservices.cpp | 10 +- .../platforms/windows/qwindowstabletsupport.cpp | 2 +- .../platforms/windows/qwindowstabletsupport.h | 2 +- src/plugins/platforms/windows/qwindowstheme.cpp | 11 +- 22 files changed, 214 insertions(+), 211 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowsbackingstore.cpp b/src/plugins/platforms/windows/qwindowsbackingstore.cpp index af9d2a5969..a518c0bb83 100644 --- a/src/plugins/platforms/windows/qwindowsbackingstore.cpp +++ b/src/plugins/platforms/windows/qwindowsbackingstore.cpp @@ -93,7 +93,7 @@ void QWindowsBackingStore::flush(QWindow *window, const QRegion ®ion, SIZE size = {r.width(), r.height()}; POINT ptDst = {r.x(), r.y()}; POINT ptSrc = {0, 0}; - BLENDFUNCTION blend = {AC_SRC_OVER, 0, (BYTE)(255.0 * rw->opacity()), AC_SRC_ALPHA}; + BLENDFUNCTION blend = {AC_SRC_OVER, 0, BYTE(qRound(255.0 * rw->opacity())), AC_SRC_ALPHA}; if (QWindowsContext::user32dll.updateLayeredWindowIndirect) { RECT dirty = {dirtyRect.x(), dirtyRect.y(), dirtyRect.x() + dirtyRect.width(), dirtyRect.y() + dirtyRect.height()}; @@ -119,7 +119,7 @@ void QWindowsBackingStore::flush(QWindow *window, const QRegion ®ion, m_image->hdc(), br.x() + offset.x(), br.y() + offset.y(), SRCCOPY)) { const DWORD lastError = GetLastError(); // QTBUG-35926, QTBUG-29716: may fail after lock screen. if (lastError != ERROR_SUCCESS && lastError != ERROR_INVALID_HANDLE) - qErrnoWarning(lastError, "%s: BitBlt failed", __FUNCTION__); + qErrnoWarning(int(lastError), "%s: BitBlt failed", __FUNCTION__); } rw->releaseDC(); #ifndef Q_OS_WINCE diff --git a/src/plugins/platforms/windows/qwindowsclipboard.cpp b/src/plugins/platforms/windows/qwindowsclipboard.cpp index 8b0be5d916..930f901523 100644 --- a/src/plugins/platforms/windows/qwindowsclipboard.cpp +++ b/src/plugins/platforms/windows/qwindowsclipboard.cpp @@ -259,9 +259,9 @@ bool QWindowsClipboard::clipboardViewerWndProc(HWND hwnd, UINT message, WPARAM w switch (message) { case WM_CHANGECBCHAIN: { - const HWND toBeRemoved = (HWND)wParam; + const HWND toBeRemoved = reinterpret_cast(wParam); if (toBeRemoved == m_nextClipboardViewer) { - m_nextClipboardViewer = (HWND)lParam; + m_nextClipboardViewer = reinterpret_cast(lParam); } else { propagateClipboardMessage(message, wParam, lParam); } diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 6ff6875c49..09c2f7df2e 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -101,10 +101,10 @@ static inline bool useRTL_Extensions(QSysInfo::WinVersion ver) if ((ver & QSysInfo::WV_NT_based) && (ver >= QSysInfo::WV_VISTA)) { // Since the IsValidLanguageGroup/IsValidLocale functions always return true on // Vista, check the Keyboard Layouts for enabling RTL. - if (const UINT nLayouts = GetKeyboardLayoutList(0, 0)) { + if (const int nLayouts = GetKeyboardLayoutList(0, 0)) { QScopedArrayPointer lpList(new HKL[nLayouts]); GetKeyboardLayoutList(nLayouts, lpList.data()); - for (UINT i = 0; i < nLayouts; ++i) { + for (int i = 0; i < nLayouts; ++i) { switch (PRIMARYLANGID((quintptr)lpList[i])) { case LANG_ARABIC: case LANG_HEBREW: @@ -540,15 +540,15 @@ QString QWindowsContext::registerWindowClass(QString cname, // add an instance-specific ID, the address of the window proc. static int classExists = -1; - const HINSTANCE appInstance = (HINSTANCE)GetModuleHandle(0); + const HINSTANCE appInstance = static_cast(GetModuleHandle(0)); if (classExists == -1) { WNDCLASS wcinfo; - classExists = GetClassInfo(appInstance, (wchar_t*)cname.utf16(), &wcinfo); + classExists = GetClassInfo(appInstance, reinterpret_cast(cname.utf16()), &wcinfo); classExists = classExists && wcinfo.lpfnWndProc != proc; } if (classExists) - cname += QString::number((quintptr)proc); + cname += QString::number(reinterpret_cast(proc)); if (d->m_registeredWindowClassNames.contains(cname)) // already registered in our list return cname; @@ -568,13 +568,13 @@ QString QWindowsContext::registerWindowClass(QString cname, #ifndef Q_OS_WINCE wc.hbrBackground = brush; if (icon) { - wc.hIcon = (HICON)LoadImage(appInstance, L"IDI_ICON1", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE); + wc.hIcon = static_cast(LoadImage(appInstance, L"IDI_ICON1", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE)); if (wc.hIcon) { int sw = GetSystemMetrics(SM_CXSMICON); int sh = GetSystemMetrics(SM_CYSMICON); - wc.hIconSm = (HICON)LoadImage(appInstance, L"IDI_ICON1", IMAGE_ICON, sw, sh, 0); + wc.hIconSm = static_cast(LoadImage(appInstance, L"IDI_ICON1", IMAGE_ICON, sw, sh, 0)); } else { - wc.hIcon = (HICON)LoadImage(0, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED); + wc.hIcon = static_cast(LoadImage(0, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED)); wc.hIconSm = 0; } } else { @@ -590,7 +590,7 @@ QString QWindowsContext::registerWindowClass(QString cname, #endif wc.lpszMenuName = 0; - wc.lpszClassName = (wchar_t*)cname.utf16(); + wc.lpszClassName = reinterpret_cast(cname.utf16()); #ifndef Q_OS_WINCE ATOM atom = RegisterClassEx(&wc); #else @@ -610,10 +610,10 @@ QString QWindowsContext::registerWindowClass(QString cname, void QWindowsContext::unregisterWindowClasses() { - const HINSTANCE appInstance = (HINSTANCE)GetModuleHandle(0); + const HINSTANCE appInstance = static_cast(GetModuleHandle(0)); foreach (const QString &name, d->m_registeredWindowClassNames) { - if (!UnregisterClass((wchar_t*)name.utf16(), appInstance) && QWindowsContext::verbose) + if (!UnregisterClass(reinterpret_cast(name.utf16()), appInstance) && QWindowsContext::verbose) qErrnoWarning("UnregisterClass failed for '%s'", qPrintable(name)); } d->m_registeredWindowClassNames.clear(); @@ -629,11 +629,11 @@ QString QWindowsContext::windowsErrorMessage(unsigned long errorCode) QString rc = QString::fromLatin1("#%1: ").arg(errorCode); ushort *lpMsgBuf; - const int len = FormatMessage( + const DWORD len = FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, errorCode, 0, (LPTSTR)&lpMsgBuf, 0, NULL); + NULL, errorCode, 0, reinterpret_cast(&lpMsgBuf), 0, NULL); if (len) { - rc = QString::fromUtf16(lpMsgBuf, len); + rc = QString::fromUtf16(lpMsgBuf, int(len)); LocalFree(lpMsgBuf); } else { rc += QString::fromLatin1(""); @@ -797,11 +797,11 @@ HWND QWindowsContext::createDummyWindow(const QString &classNameIn, if (!wndProc) wndProc = DefWindowProc; QString className = registerWindowClass(classNameIn, wndProc); - return CreateWindowEx(0, (wchar_t*)className.utf16(), + return CreateWindowEx(0, reinterpret_cast(className.utf16()), windowName, style, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - HWND_MESSAGE, NULL, (HINSTANCE)GetModuleHandle(0), NULL); + HWND_MESSAGE, NULL, static_cast(GetModuleHandle(0)), NULL); } #ifndef Q_OS_WINCE @@ -812,11 +812,11 @@ static inline QString errorMessageFromComError(const _com_error &comError) { TCHAR *message = Q_NULLPTR; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, comError.Error(), MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), + NULL, DWORD(comError.Error()), MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), message, 0, NULL); if (message) { const QString result = QString::fromWCharArray(message).trimmed(); - LocalFree((HLOCAL)message); + LocalFree(static_cast(message)); return result; } if (const WORD wCode = comError.WCode()) @@ -1064,7 +1064,7 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, platformWindow->handleMoved(); return true; case QtWindows::ResizeEvent: - platformWindow->handleResized((int)wParam); + platformWindow->handleResized(static_cast(wParam)); return true; #ifndef Q_OS_WINCE // maybe available on some SDKs revisit WM_GETMINMAXINFO case QtWindows::QuerySizeHints: @@ -1203,7 +1203,7 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, sessionManager->setActive(false); sessionManager->allowsInteraction(); - bool endsession = (bool) wParam; + const bool endsession = wParam != 0; // we receive the message for each toplevel window included internal hidden ones, // but the aboutToQuit signal should be emitted only once. @@ -1270,7 +1270,7 @@ bool QWindowsContext::handleContextMenuEvent(QWindow *window, const MSG &msg) bool mouseTriggered = false; QPoint globalPos; QPoint pos; - if (msg.lParam != (int)0xffffffff) { + if (msg.lParam != int(0xffffffff)) { mouseTriggered = true; globalPos.setX(msg.pt.x); globalPos.setY(msg.pt.y); @@ -1278,8 +1278,8 @@ bool QWindowsContext::handleContextMenuEvent(QWindow *window, const MSG &msg) RECT clientRect; if (GetClientRect(msg.hwnd, &clientRect)) { - if (pos.x() < (int)clientRect.left || pos.x() >= (int)clientRect.right || - pos.y() < (int)clientRect.top || pos.y() >= (int)clientRect.bottom) + if (pos.x() < clientRect.left || pos.x() >= clientRect.right || + pos.y() < clientRect.top || pos.y() >= clientRect.bottom) { // This is the case that user has right clicked in the window's caption, // We should call DefWindowProc() to display a default shortcut menu diff --git a/src/plugins/platforms/windows/qwindowscursor.cpp b/src/plugins/platforms/windows/qwindowscursor.cpp index 9f65f73a81..cda741c226 100644 --- a/src/plugins/platforms/windows/qwindowscursor.cpp +++ b/src/plugins/platforms/windows/qwindowscursor.cpp @@ -113,8 +113,8 @@ HCURSOR QWindowsCursor::createPixmapCursor(QPixmap pixmap, const QPoint &hotSpot ICONINFO ii; ii.fIcon = 0; - ii.xHotspot = hotSpot.x(); - ii.yHotspot = hotSpot.y(); + ii.xHotspot = DWORD(hotSpot.x()); + ii.yHotspot = DWORD(hotSpot.y()); ii.hbmMask = im; ii.hbmColor = ic; @@ -571,7 +571,7 @@ HCURSOR QWindowsCursor::createCursorFromShape(Qt::CursorShape cursorShape, const for (const QWindowsStandardCursorMapping *s = standardCursors; s < sEnd; ++s) { if (s->shape == cursorShape) { #ifndef Q_OS_WINCE - return (HCURSOR)LoadImage(0, s->resource, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE | LR_SHARED); + return static_cast(LoadImage(0, s->resource, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE | LR_SHARED)); #else return LoadCursor(0, s->resource); #endif diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp index 18e67ff1a3..150e135604 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.cpp +++ b/src/plugins/platforms/windows/qwindowsdrag.cpp @@ -641,7 +641,7 @@ QWindowsOleDropTarget::Drop(LPDATAOBJECT pDataObj, DWORD grfKeyState, m_chosenEffect = DROPEFFECT_COPY; HGLOBAL hData = GlobalAlloc(0, sizeof(DWORD)); if (hData) { - DWORD *moveEffect = (DWORD *)GlobalLock(hData);; + DWORD *moveEffect = reinterpret_cast(GlobalLock(hData)); *moveEffect = DROPEFFECT_MOVE; GlobalUnlock(hData); STGMEDIUM medium; @@ -649,7 +649,7 @@ QWindowsOleDropTarget::Drop(LPDATAOBJECT pDataObj, DWORD grfKeyState, medium.tymed = TYMED_HGLOBAL; medium.hGlobal = hData; FORMATETC format; - format.cfFormat = RegisterClipboardFormat(CFSTR_PERFORMEDDROPEFFECT); + format.cfFormat = CLIPFORMAT(RegisterClipboardFormat(CFSTR_PERFORMEDDROPEFFECT)); format.tymed = TYMED_HGLOBAL; format.ptd = 0; format.dwAspect = 1; diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp index 5983741711..787a072a7a 100644 --- a/src/plugins/platforms/windows/qwindowseglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp @@ -187,9 +187,9 @@ bool QWindowsLibGLESv2::init() qCDebug(lcQpaGl) << "Qt: Using OpenGL ES 2.0 from" << dllName; #if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC) - m_lib = ::LoadLibraryW((const wchar_t *) QString::fromLatin1(dllName).utf16()); + m_lib = ::LoadLibraryW(reinterpret_cast(QString::fromLatin1(dllName).utf16())); if (!m_lib) { - qErrnoWarning(::GetLastError(), "Failed to load %s", dllName); + qErrnoWarning(int(GetLastError()), "Failed to load %s", dllName); return false; } #endif // !QT_STATIC @@ -395,7 +395,7 @@ QWindowsEGLStaticContext *QWindowsEGLStaticContext::create(QWindowsOpenGLTester: Q_UNUSED(preferredType) #endif if (display == EGL_NO_DISPLAY) - display = libEGL.eglGetDisplay((EGLNativeDisplayType)dc); + display = libEGL.eglGetDisplay(dc); if (!display) { qWarning("%s: Could not obtain EGL display", __FUNCTION__); return 0; @@ -427,8 +427,8 @@ QWindowsOpenGLContext *QWindowsEGLStaticContext::createContext(QOpenGLContext *c void *QWindowsEGLStaticContext::createWindowSurface(void *nativeWindow, void *nativeConfig, int *err) { *err = 0; - EGLSurface surface = libEGL.eglCreateWindowSurface(m_display, (EGLConfig) nativeConfig, - (EGLNativeWindowType) nativeWindow, 0); + EGLSurface surface = libEGL.eglCreateWindowSurface(m_display, nativeConfig, + static_cast(nativeWindow), 0); if (surface == EGL_NO_SURFACE) { *err = libEGL.eglGetError(); qWarning("%s: Could not create the EGL window surface: 0x%x", __FUNCTION__, *err); @@ -439,7 +439,7 @@ void *QWindowsEGLStaticContext::createWindowSurface(void *nativeWindow, void *na void QWindowsEGLStaticContext::destroyWindowSurface(void *nativeSurface) { - libEGL.eglDestroySurface(m_display, (EGLSurface) nativeSurface); + libEGL.eglDestroySurface(m_display, nativeSurface); } QSurfaceFormat QWindowsEGLStaticContext::formatFromConfig(EGLDisplay display, EGLConfig config, diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp index 8d33e2f0db..2eaae6b726 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp @@ -1011,7 +1011,7 @@ QOpenGLStaticContext::QOpenGLStaticContext() : QByteArray QOpenGLStaticContext::getGlString(unsigned int which) { if (const GLubyte *s = opengl32.glGetString(which)) - return QByteArray((const char*)s); + return QByteArray(reinterpret_cast(s)); return QByteArray(); } @@ -1238,7 +1238,7 @@ bool QWindowsGLContext::updateObtainedParams(HDC hdc, int *obtainedSwapInterval) bool hasRobustness = false; if (m_obtainedFormat.majorVersion() < 3) { - const char *exts = (const char *) QOpenGLStaticContext::opengl32.glGetString(GL_EXTENSIONS); + const char *exts = reinterpret_cast(QOpenGLStaticContext::opengl32.glGetString(GL_EXTENSIONS)); hasRobustness = exts && strstr(exts, "GL_ARB_robustness"); } else { typedef const GLubyte * (APIENTRY *glGetStringi_t)(GLenum, GLuint); @@ -1247,7 +1247,7 @@ bool QWindowsGLContext::updateObtainedParams(HDC hdc, int *obtainedSwapInterval) GLint n = 0; QOpenGLStaticContext::opengl32.glGetIntegerv(GL_NUM_EXTENSIONS, &n); for (GLint i = 0; i < n; ++i) { - const char *p = (const char *) glGetStringi(GL_EXTENSIONS, i); + const char *p = reinterpret_cast(glGetStringi(GL_EXTENSIONS, i)); if (p && !strcmp(p, "GL_ARB_robustness")) { hasRobustness = true; break; diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp index 56b5561756..d3299db460 100644 --- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp @@ -319,7 +319,9 @@ void QWindowsInputContext::invokeAction(QInputMethod::Action action, int cursorP // position. const HIMC himc = ImmGetContext(m_compositionContext.hwnd); const HWND imeWindow = ImmGetDefaultIMEWnd(m_compositionContext.hwnd); - SendMessage(imeWindow, m_WM_MSIME_MOUSE, MAKELONG(MAKEWORD(MK_LBUTTON, cursorPosition == 0 ? 2 : 1), cursorPosition), (LPARAM)himc); + const WPARAM mouseOperationCode = + MAKELONG(MAKEWORD(MK_LBUTTON, cursorPosition == 0 ? 2 : 1), cursorPosition); + SendMessage(imeWindow, m_WM_MSIME_MOUSE, mouseOperationCode, LPARAM(himc)); ImmReleaseContext(m_compositionContext.hwnd, himc); } @@ -328,7 +330,7 @@ static inline QString getCompositionString(HIMC himc, DWORD dwIndex) enum { bufferSize = 256 }; wchar_t buffer[bufferSize]; const int length = ImmGetCompositionString(himc, dwIndex, buffer, bufferSize * sizeof(wchar_t)); - return QString::fromWCharArray(buffer, length / sizeof(wchar_t)); + return QString::fromWCharArray(buffer, size_t(length) / sizeof(wchar_t)); } // Determine the converted string range as pair of start/length to be selected. @@ -559,9 +561,8 @@ bool QWindowsInputContext::handleIME_Request(WPARAM wParam, if (size < 0) return false; *result = size; - return true; } - break; + return true; case IMR_CONFIRMRECONVERTSTRING: return true; default: @@ -572,7 +573,7 @@ bool QWindowsInputContext::handleIME_Request(WPARAM wParam, void QWindowsInputContext::handleInputLanguageChanged(WPARAM wparam, LPARAM lparam) { - const LCID newLanguageId = languageIdFromLocaleId(lparam); + const LCID newLanguageId = languageIdFromLocaleId(WORD(lparam)); if (newLanguageId == m_languageId) return; const LCID oldLanguageId = m_languageId; @@ -606,13 +607,13 @@ int QWindowsInputContext::reconvertString(RECONVERTSTRING *reconv) if (!surroundingTextV.isValid()) return -1; const QString surroundingText = surroundingTextV.toString(); - const DWORD memSize = sizeof(RECONVERTSTRING) - + (surroundingText.length() + 1) * sizeof(ushort); + const int memSize = int(sizeof(RECONVERTSTRING)) + + (surroundingText.length() + 1) * int(sizeof(ushort)); qCDebug(lcQpaInputMethods) << __FUNCTION__ << " reconv=" << reconv << " surroundingText=" << surroundingText << " size=" << memSize; // If memory is not allocated, return the required size. if (!reconv) - return surroundingText.isEmpty() ? -1 : int(memSize); + return surroundingText.isEmpty() ? -1 : memSize; const QVariant posV = QInputMethod::queryFocusObject(Qt::ImCursorPosition, QVariant()); const int pos = posV.isValid() ? posV.toInt() : 0; @@ -631,13 +632,13 @@ int QWindowsInputContext::reconvertString(RECONVERTSTRING *reconv) QInputMethodEvent selectEvent(QString(), attributes); QCoreApplication::sendEvent(fo, &selectEvent); - reconv->dwSize = memSize; + reconv->dwSize = DWORD(memSize); reconv->dwVersion = 0; - reconv->dwStrLen = surroundingText.size(); + reconv->dwStrLen = DWORD(surroundingText.size()); reconv->dwStrOffset = sizeof(RECONVERTSTRING); - reconv->dwCompStrLen = endPos - startPos; // TCHAR count. - reconv->dwCompStrOffset = startPos * sizeof(ushort); // byte count. + reconv->dwCompStrLen = DWORD(endPos - startPos); // TCHAR count. + reconv->dwCompStrOffset = DWORD(startPos) * sizeof(ushort); // byte count. reconv->dwTargetStrLen = reconv->dwCompStrLen; reconv->dwTargetStrOffset = reconv->dwCompStrOffset; ushort *pastReconv = reinterpret_cast(reconv + 1); diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index bd2014b8f2..27ec258f37 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -514,8 +514,8 @@ QVariant QWindowsIntegration::styleHint(QPlatformIntegration::StyleHint hint) co case QPlatformIntegration::FontSmoothingGamma: return QVariant(QWindowsFontDatabase::fontSmoothingGamma()); case QPlatformIntegration::MouseDoubleClickInterval: - if (const int ms = GetDoubleClickTime()) - return QVariant(ms); + if (const UINT ms = GetDoubleClickTime()) + return QVariant(int(ms)); break; case QPlatformIntegration::UseRtlExtensions: return QVariant(d->m_context.useRTLExtensions()); diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index b7e7867404..5790341dbf 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -541,7 +541,7 @@ Q_STATIC_ASSERT((NumMods == KeyboardLayoutItem::NumQtKeys)); /** Remap return or action key to select key for windows mobile. */ -inline int winceKeyBend(int keyCode) +inline quint32 winceKeyBend(quint32 keyCode) { return KeyTbl[keyCode]; } @@ -575,10 +575,10 @@ QT_END_INCLUDE_NAMESPACE #endif // Q_OS_WINCE // Translate a VK into a Qt key code, or unicode character -static inline int toKeyOrUnicode(int vk, int scancode, unsigned char *kbdBuffer, bool *isDeadkey = 0) +static inline quint32 toKeyOrUnicode(quint32 vk, quint32 scancode, unsigned char *kbdBuffer, bool *isDeadkey = 0) { Q_ASSERT(vk > 0 && vk < 256); - int code = 0; + quint32 code = 0; QChar unicodeBuffer[5]; int res = ToUnicode(vk, scancode, kbdBuffer, reinterpret_cast(unicodeBuffer), 5, 0); // When Ctrl modifier is used ToUnicode does not return correct values. In order to assign the @@ -632,13 +632,13 @@ void QWindowsKeyMapper::changeKeyboard() /* MAKELCID()'s first argument is a WORD, and GetKeyboardLayout() * returns a DWORD. */ - LCID newLCID = MAKELCID((quintptr)GetKeyboardLayout(0), SORT_DEFAULT); + LCID newLCID = MAKELCID(quintptr(GetKeyboardLayout(0)), SORT_DEFAULT); // keyboardInputLocale = qt_localeFromLCID(newLCID); bool bidi = false; wchar_t LCIDFontSig[16]; if (GetLocaleInfo(newLCID, LOCALE_FONTSIGNATURE, LCIDFontSig, sizeof(LCIDFontSig) / sizeof(wchar_t)) - && (LCIDFontSig[7] & (wchar_t)0x0800)) + && (LCIDFontSig[7] & wchar_t(0x0800))) bidi = true; keyboardInputDirection = bidi ? Qt::RightToLeft : Qt::LeftToRight; @@ -662,7 +662,7 @@ void QWindowsKeyMapper::updateKeyMap(const MSG &msg) unsigned char kbdBuffer[256]; // Will hold the complete keyboard state GetKeyboardState(kbdBuffer); const quint32 scancode = (msg.lParam >> 16) & scancodeBitmask; - updatePossibleKeyCodes(kbdBuffer, scancode, msg.wParam); + updatePossibleKeyCodes(kbdBuffer, scancode, quint32(msg.wParam)); } // Fills keyLayout for that vk_key. Values are all characters one can type using that key @@ -721,7 +721,7 @@ void QWindowsKeyMapper::updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32 keyLayout[vk_key].qtKey[7] = toKeyOrUnicode(vk_key, scancode, buffer, &isDeadKey); keyLayout[vk_key].deadkeys |= isDeadKey ? 0x80 : 0; // Add a fall back key for layouts which don't do composition and show non-latin1 characters - int fallbackKey = winceKeyBend(vk_key); + quint32 fallbackKey = winceKeyBend(vk_key); if (!fallbackKey || fallbackKey == Qt::Key_unknown) { fallbackKey = 0; if (vk_key != keyLayout[vk_key].qtKey[0] && vk_key < 0x5B && vk_key > 0x2F) @@ -762,7 +762,7 @@ void QWindowsKeyMapper::updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32 static inline QString messageKeyText(const MSG &msg) { - const QChar ch = QChar((ushort)msg.wParam); + const QChar ch = QChar(ushort(msg.wParam)); return ch.isNull() ? QString() : QString(ch); } @@ -807,7 +807,7 @@ static void showSystemMenu(QWindow* w) topLevelHwnd, 0); if (ret) - qWindowsWndProc(topLevelHwnd, WM_SYSCOMMAND, ret, 0); + qWindowsWndProc(topLevelHwnd, WM_SYSCOMMAND, WPARAM(ret), 0); } static inline void sendExtendedPressRelease(QWindow *w, int k, @@ -871,7 +871,7 @@ bool QWindowsKeyMapper::translateMultimediaKeyEventInternal(QWindow *window, con if (cmd < 0 || cmd > 52) return false; - const int qtKey = CmdTbl[cmd]; + const int qtKey = int(CmdTbl[cmd]); sendExtendedPressRelease(receiver, qtKey, Qt::KeyboardModifier(state), 0, 0, 0); // QTBUG-43343: Make sure to return false if Qt does not handle the key, otherwise, // the keys are not passed to the active media player. @@ -885,10 +885,10 @@ bool QWindowsKeyMapper::translateMultimediaKeyEventInternal(QWindow *window, con bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &msg, bool /* grab */) { - const int msgType = msg.message; + const UINT msgType = msg.message; const quint32 scancode = (msg.lParam >> 16) & scancodeBitmask; - quint32 vk_key = msg.wParam; + quint32 vk_key = quint32(msg.wParam); quint32 nModifiers = 0; QWindow *receiver = m_keyGrabber ? m_keyGrabber : window; @@ -949,13 +949,13 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms if (dirStatus == VK_LSHIFT && ((msg.wParam == VK_SHIFT && GetKeyState(VK_LCONTROL)) || (msg.wParam == VK_CONTROL && GetKeyState(VK_LSHIFT)))) { - sendExtendedPressRelease(receiver, Qt::Key_Direction_L, 0, scancode, msg.wParam, nModifiers, QString(), false); + sendExtendedPressRelease(receiver, Qt::Key_Direction_L, 0, scancode, vk_key, nModifiers, QString(), false); result = true; dirStatus = 0; } else if (dirStatus == VK_RSHIFT && ( (msg.wParam == VK_SHIFT && GetKeyState(VK_RCONTROL)) || (msg.wParam == VK_CONTROL && GetKeyState(VK_RSHIFT)))) { - sendExtendedPressRelease(receiver, Qt::Key_Direction_R, 0, scancode, msg.wParam, nModifiers, QString(), false); + sendExtendedPressRelease(receiver, Qt::Key_Direction_R, 0, scancode, vk_key, nModifiers, QString(), false); result = true; dirStatus = 0; } else { @@ -1030,7 +1030,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms || (msg.wParam >= VK_OEM_PLUS && msg.wParam <= VK_OEM_3)) ? 0 : int(Qt::KeypadModifier); default: - if ((uint)msg.lParam == 0x004c0001 || (uint)msg.lParam == 0xc04c0001) + if (uint(msg.lParam) == 0x004c0001 || uint(msg.lParam) == 0xc04c0001) state |= Qt::KeypadModifier; break; } @@ -1042,6 +1042,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms case Qt::Key_Slash: case Qt::Key_NumLock: state |= Qt::KeypadModifier; + break; default: break; } @@ -1051,13 +1052,13 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms if (msgType == WM_KEYDOWN || msgType == WM_IME_KEYDOWN || msgType == WM_SYSKEYDOWN) { // Get the last record of this key press, so we can validate the current state // The record is not removed from the list - KeyRecord *rec = key_recorder.findKey(msg.wParam, false); + KeyRecord *rec = key_recorder.findKey(int(msg.wParam), false); // If rec's state doesn't match the current state, something has changed behind our back // (Consumed by modal widget is one possibility) So, remove the record from the list // This will stop the auto-repeat of the key, should a modifier change, for example if (rec && rec->state != state) { - key_recorder.findKey(msg.wParam, true); + key_recorder.findKey(int(msg.wParam), true); rec = 0; } @@ -1070,11 +1071,11 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms QChar uch; if (PeekMessage(&wm_char, 0, charType, charType, PM_REMOVE)) { // Found a ?_CHAR - uch = QChar((ushort)wm_char.wParam); + uch = QChar(ushort(wm_char.wParam)); if (msgType == WM_SYSKEYDOWN && uch.isLetter() && (msg.lParam & KF_ALTDOWN)) uch = uch.toLower(); // (See doc of WM_SYSCHAR) Alt-letter if (!code && !uch.row()) - code = asciiToKeycode(uch.cell(), state); + code = asciiToKeycode(char(uch.cell()), state); } // Special handling for the WM_IME_KEYDOWN message. Microsoft IME (Korean) will not @@ -1085,7 +1086,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms const QWindowsInputContext *windowsInputContext = qobject_cast(QWindowsIntegration::instance()->inputContext()); if (!(windowsInputContext && windowsInputContext->isComposing())) - vk_key = ImmGetVirtualKey((HWND)window->winId()); + vk_key = ImmGetVirtualKey(reinterpret_cast(window->winId())); BYTE keyState[256]; wchar_t newKey[3] = {0}; GetKeyboardState(keyState); @@ -1105,14 +1106,14 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms uch = QChar(QLatin1Char(0x7f)); // Windows doesn't know this one. } else { if (msgType != WM_SYSKEYDOWN || !code) { - UINT map = MapVirtualKey(msg.wParam, 2); + UINT map = MapVirtualKey(UINT(msg.wParam), 2); // If the high bit of the return value is set, it's a deadkey if (!(map & 0x80000000)) - uch = QChar((ushort)map); + uch = QChar(ushort(map)); } } if (!code && !uch.row()) - code = asciiToKeycode(uch.cell(), state); + code = asciiToKeycode(char(uch.cell()), state); } // Special handling of global Windows hotkeys @@ -1141,9 +1142,9 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms if (rec) { if (code < Qt::Key_Shift || code > Qt::Key_ScrollLock) { QWindowSystemInterface::handleExtendedKeyEvent(receiver, QEvent::KeyRelease, code, - Qt::KeyboardModifier(state), scancode, msg.wParam, nModifiers, rec->text, true); + Qt::KeyboardModifier(state), scancode, quint32(msg.wParam), nModifiers, rec->text, true); QWindowSystemInterface::handleExtendedKeyEvent(receiver, QEvent::KeyPress, code, - Qt::KeyboardModifier(state), scancode, msg.wParam, nModifiers, rec->text, true); + Qt::KeyboardModifier(state), scancode, quint32(msg.wParam), nModifiers, rec->text, true); result = true; } } @@ -1151,7 +1152,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms // and store the key data into our records. else { const QString text = uch.isNull() ? QString() : QString(uch); - const char a = uch.row() ? 0 : uch.cell(); + const char a = uch.row() ? char(0) : char(uch.cell()); const Qt::KeyboardModifiers modifiers(state); #ifndef QT_NO_SHORTCUT // Is Qt interested in the context menu key? @@ -1160,9 +1161,9 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms return false; } #endif // !QT_NO_SHORTCUT - key_recorder.storeKey(msg.wParam, a, state, text); + key_recorder.storeKey(int(msg.wParam), a, state, text); QWindowSystemInterface::handleExtendedKeyEvent(receiver, QEvent::KeyPress, code, - modifiers, scancode, msg.wParam, nModifiers, text, false); + modifiers, scancode, quint32(msg.wParam), nModifiers, text, false); result =true; bool store = true; #ifndef Q_OS_WINCE @@ -1181,7 +1182,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms } #endif // !Q_OS_WINCE if (!store) - key_recorder.findKey(msg.wParam, true); + key_recorder.findKey(int(msg.wParam), true); } } @@ -1191,7 +1192,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms // The key may not be in our records if, for example, the down event was handled by // win32 natively, or our window gets focus while a key is already press, but now gets // the key release event. - KeyRecord* rec = key_recorder.findKey(msg.wParam, true); + const KeyRecord *rec = key_recorder.findKey(int(msg.wParam), true); if (!rec && !(code == Qt::Key_Shift || code == Qt::Key_Control || code == Qt::Key_Meta @@ -1199,13 +1200,14 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms // Someone ate the key down event } else { if (!code) - code = asciiToKeycode(rec->ascii ? rec->ascii : msg.wParam, state); + code = asciiToKeycode(rec->ascii ? char(rec->ascii) : char(msg.wParam), state); // Map SHIFT + Tab to SHIFT + BackTab, QShortcutMap knows about this translation if (code == Qt::Key_Tab && (state & Qt::ShiftModifier) == Qt::ShiftModifier) code = Qt::Key_Backtab; QWindowSystemInterface::handleExtendedKeyEvent(receiver, QEvent::KeyRelease, code, - Qt::KeyboardModifier(state), scancode, msg.wParam, nModifiers, + Qt::KeyboardModifier(state), scancode, quint32(msg.wParam), + nModifiers, (rec ? rec->text : QString()), false); result = true; #ifndef Q_OS_WINCE diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp index a8264b55c0..de18426484 100644 --- a/src/plugins/platforms/windows/qwindowsmime.cpp +++ b/src/plugins/platforms/windows/qwindowsmime.cpp @@ -150,7 +150,7 @@ static bool qt_write_dibv5(QDataStream &s, QImage image) bi.bV5Planes = 1; bi.bV5BitCount = 32; bi.bV5Compression = BI_BITFIELDS; - bi.bV5SizeImage = bpl_bmp*image.height(); + bi.bV5SizeImage = DWORD(bpl_bmp * image.height()); bi.bV5XPelsPerMeter = 0; bi.bV5YPelsPerMeter = 0; bi.bV5ClrUsed = 0; @@ -170,30 +170,29 @@ static bool qt_write_dibv5(QDataStream &s, QImage image) image = image.convertToFormat(QImage::Format_ARGB32); uchar *buf = new uchar[bpl_bmp]; - uchar *b; - memset(buf, 0, bpl_bmp); + memset(buf, 0, size_t(bpl_bmp)); for (int y=image.height()-1; y>=0; y--) { // write the image bits const QRgb *p = reinterpret_cast(image.constScanLine(y)); const QRgb *end = p + image.width(); - b = buf; + uchar *b = buf; while (p < end) { int alpha = qAlpha(*p); if (alpha) { - *b++ = qBlue(*p); - *b++ = qGreen(*p); - *b++ = qRed(*p); + *b++ = uchar(qBlue(*p)); + *b++ = uchar(qGreen(*p)); + *b++ = uchar(qRed(*p)); } else { //white for fully transparent pixels. *b++ = 0xff; *b++ = 0xff; *b++ = 0xff; } - *b++ = alpha; + *b++ = uchar(alpha); p++; } - d->write((char*)buf, bpl_bmp); + d->write(reinterpret_cast(buf), bpl_bmp); if (s.status() != QDataStream::Ok) { delete[] buf; return false; @@ -221,25 +220,22 @@ static bool qt_read_dibv5(QDataStream &s, QImage &image) if (d->atEnd()) return false; - d->read((char *)&bi, sizeof(bi)); // read BITMAPV5HEADER header + d->read(reinterpret_cast(&bi), sizeof(bi)); // read BITMAPV5HEADER header if (s.status() != QDataStream::Ok) return false; - int nbits = bi.bV5BitCount; - int comp = bi.bV5Compression; - if (nbits != 32 || bi.bV5Planes != 1 || comp != BMP_BITFIELDS) + const int nbits = bi.bV5BitCount; + if (nbits != 32 || bi.bV5Planes != 1 || bi.bV5Compression != BMP_BITFIELDS) return false; //Unsupported DIBV5 format - int w = bi.bV5Width, h = bi.bV5Height; - int red_mask = bi.bV5RedMask; - int green_mask = bi.bV5GreenMask; - int blue_mask = bi.bV5BlueMask; - int alpha_mask = bi.bV5AlphaMask; - int red_shift = 0; - int green_shift = 0; - int blue_shift = 0; - int alpha_shift = 0; - QImage::Format format = QImage::Format_ARGB32; + const int w = bi.bV5Width; + int h = bi.bV5Height; + const int red_mask = int(bi.bV5RedMask); + const int green_mask = int(bi.bV5GreenMask); + const int blue_mask = int(bi.bV5BlueMask); + const int alpha_mask = int(bi.bV5AlphaMask); + + const QImage::Format format = QImage::Format_ARGB32; if (bi.bV5Height < 0) h = -h; // support images with negative height @@ -251,30 +247,25 @@ static bool qt_read_dibv5(QDataStream &s, QImage &image) image.setDotsPerMeterX(bi.bV5XPelsPerMeter); image.setDotsPerMeterY(bi.bV5YPelsPerMeter); - red_shift = calc_shift(red_mask); - green_shift = calc_shift(green_mask); - blue_shift = calc_shift(blue_mask); - if (alpha_mask) { - alpha_shift = calc_shift(alpha_mask); - } + const int red_shift = calc_shift(red_mask); + const int green_shift = calc_shift(green_mask); + const int blue_shift = calc_shift(blue_mask); + const int alpha_shift = alpha_mask ? calc_shift(alpha_mask) : 0u; - int bpl = image.bytesPerLine(); + const int bpl = image.bytesPerLine(); uchar *data = image.bits(); - QRgb *p; - QRgb *end; + uchar *buf24 = new uchar[bpl]; - int bpl24 = ((w*nbits+31)/32)*4; - uchar *b; - unsigned int c; + const int bpl24 = ((w * nbits + 31) / 32) * 4; while (--h >= 0) { - p = (QRgb *)(data + h*bpl); - end = p + w; - if (d->read((char *)buf24,bpl24) != bpl24) + QRgb *p = reinterpret_cast(data + h * bpl); + QRgb *end = p + w; + if (d->read(reinterpret_cast(buf24), bpl24) != bpl24) break; - b = buf24; + const uchar *b = buf24; while (p < end) { - c = *b | (*(b+1))<<8 | (*(b+2))<<16 | (*(b+3))<<24; + const int c = *b | (*(b + 1)) << 8 | (*(b + 2)) << 16 | (*(b + 3)) << 24; *p++ = qRgba(((c & red_mask) >> red_shift) , ((c & green_mask) >> green_shift), ((c & blue_mask) >> blue_shift), @@ -289,9 +280,9 @@ static bool qt_read_dibv5(QDataStream &s, QImage &image) uchar *buf = new uchar[bpl]; h = -bi.bV5Height; for (int y = 0; y < h/2; ++y) { - memcpy(buf, data + y*bpl, bpl); - memcpy(data + y*bpl, data + (h-y-1)*bpl, bpl); - memcpy(data + (h-y-1)*bpl, buf, bpl); + memcpy(buf, data + y * bpl, size_t(bpl)); + memcpy(data + y*bpl, data + (h - y -1) * bpl, size_t(bpl)); + memcpy(data + (h - y -1 ) * bpl, buf, size_t(bpl)); } delete [] buf; } @@ -309,7 +300,7 @@ static int getCf(const FORMATETC &formatetc) static FORMATETC setCf(int cf) { FORMATETC formatetc; - formatetc.cfFormat = cf; + formatetc.cfFormat = CLIPFORMAT(cf); formatetc.dwAspect = DVASPECT_CONTENT; formatetc.lindex = -1; formatetc.ptd = NULL; @@ -319,12 +310,12 @@ static FORMATETC setCf(int cf) static bool setData(const QByteArray &data, STGMEDIUM *pmedium) { - HGLOBAL hData = GlobalAlloc(0, data.size()); + HGLOBAL hData = GlobalAlloc(0, SIZE_T(data.size())); if (!hData) return false; void *out = GlobalLock(hData); - memcpy(out, data.data(), data.size()); + memcpy(out, data.data(), size_t(data.size())); GlobalUnlock(hData); pmedium->tymed = TYMED_HGLOBAL; pmedium->hGlobal = hData; @@ -339,8 +330,8 @@ static QByteArray getData(int cf, IDataObject *pDataObj, int lindex = -1) formatetc.lindex = lindex; STGMEDIUM s; if (pDataObj->GetData(&formatetc, &s) == S_OK) { - DWORD * val = (DWORD*)GlobalLock(s.hGlobal); - data = QByteArray::fromRawData((char*)val, GlobalSize(s.hGlobal)); + const void *val = GlobalLock(s.hGlobal); + data = QByteArray::fromRawData(reinterpret_cast(val), int(GlobalSize(s.hGlobal))); data.detach(); GlobalUnlock(s.hGlobal); ReleaseStgMedium(&s); @@ -356,7 +347,7 @@ static QByteArray getData(int cf, IDataObject *pDataObj, int lindex = -1) while(SUCCEEDED(hr)){ hr = s.pstm->Read(szBuffer, sizeof(szBuffer), &actualRead); if (SUCCEEDED(hr) && actualRead > 0) { - data += QByteArray::fromRawData(szBuffer, actualRead); + data += QByteArray::fromRawData(szBuffer, int(actualRead)); } if (actualRead != sizeof(szBuffer)) break; @@ -508,11 +499,11 @@ QWindowsMime::~QWindowsMime() */ int QWindowsMime::registerMimeType(const QString &mime) { - int f = RegisterClipboardFormat(reinterpret_cast (mime.utf16())); + const UINT f = RegisterClipboardFormat(reinterpret_cast (mime.utf16())); if (!f) qErrnoWarning("QWindowsMime::registerMimeType: Failed to register clipboard format"); - return f; + return int(f); } /*! @@ -655,9 +646,9 @@ bool QWindowsMimeText::convertFromMime(const FORMATETC &formatetc, const QMimeDa ++u; } res.truncate(ri); - const int byteLength = res.length() * sizeof(ushort); + const int byteLength = res.length() * int(sizeof(ushort)); QByteArray r(byteLength + 2, '\0'); - memcpy(r.data(), res.unicode(), byteLength); + memcpy(r.data(), res.unicode(), size_t(byteLength)); r[byteLength] = 0; r[byteLength+1] = 0; return setData(r, pmedium); @@ -700,17 +691,17 @@ QVariant QWindowsMimeText::convertToMime(const QString &mime, LPDATAOBJECT pData QString str; QByteArray data = getData(CF_UNICODETEXT, pDataObj); if (!data.isEmpty()) { - str = QString::fromWCharArray((const wchar_t *)data.data()); + str = QString::fromWCharArray(reinterpret_cast(data.constData())); str.replace(QStringLiteral("\r\n"), QStringLiteral("\n")); } else { data = getData(CF_TEXT, pDataObj); if (!data.isEmpty()) { const char* d = data.data(); - const int s = qstrlen(d); + const unsigned s = qstrlen(d); QByteArray r(data.size()+1, '\0'); char* o = r.data(); int j=0; - for (int i=0; i(result.data()); d->pFiles = sizeof(DROPFILES); GetCursorPos(&d->pt); // try d->fNC = true; - char* files = ((char*)d) + d->pFiles; + char *files = (reinterpret_cast(d)) + d->pFiles; d->fWide = true; - wchar_t* f = (wchar_t*)files; + wchar_t *f = reinterpret_cast(files); for (int i=0; i(url.utf16()), + url.length() * int(sizeof(ushort))); } result.append('\0'); result.append('\0'); @@ -854,9 +846,9 @@ QVariant QWindowsMimeURI::convertToMime(const QString &mimeType, LPDATAOBJECT pD if (data.isEmpty()) return QVariant(); - LPDROPFILES hdrop = (LPDROPFILES)data.data(); + const DROPFILES *hdrop = reinterpret_cast(data.constData()); if (hdrop->fWide) { - const wchar_t* filesw = (const wchar_t *)(data.data() + hdrop->pFiles); + const wchar_t *filesw = reinterpret_cast(data.constData() + hdrop->pFiles); int i = 0; while (filesw[i]) { QString fileurl = QString::fromWCharArray(filesw + i); @@ -864,7 +856,7 @@ QVariant QWindowsMimeURI::convertToMime(const QString &mimeType, LPDATAOBJECT pD i += fileurl.length()+1; } } else { - const char* files = (const char *)data.data() + hdrop->pFiles; + const char* files = reinterpret_cast(data.constData() + hdrop->pFiles); int i=0; while (files[i]) { urls += QUrl::fromLocalFile(QString::fromLocal8Bit(files+i)); @@ -880,7 +872,7 @@ QVariant QWindowsMimeURI::convertToMime(const QString &mimeType, LPDATAOBJECT pD QByteArray data = getData(CF_INETURL_W, pDataObj); if (data.isEmpty()) return QVariant(); - return QUrl(QString::fromWCharArray((const wchar_t *)data.constData())); + return QUrl(QString::fromWCharArray(reinterpret_cast(data.constData()))); } else if (canGetData(CF_INETURL, pDataObj)) { QByteArray data = getData(CF_INETURL, pDataObj); if (data.isEmpty()) @@ -1008,14 +1000,14 @@ bool QWindowsMimeHtml::convertFromMime(const FORMATETC &formatetc, const QMimeDa result += ""; // set the correct number for EndHTML - QByteArray pos = QString::number(result.size()).toLatin1(); - memcpy((char *)(result.data() + 53 - pos.length()), pos.constData(), pos.length()); + QByteArray pos = QByteArray::number(result.size()); + memcpy(reinterpret_cast(result.data() + 53 - pos.length()), pos.constData(), size_t(pos.length())); // set correct numbers for StartFragment and EndFragment - pos = QString::number(result.indexOf("") + 20).toLatin1(); - memcpy((char *)(result.data() + 79 - pos.length()), pos.constData(), pos.length()); - pos = QString::number(result.indexOf("")).toLatin1(); - memcpy((char *)(result.data() + 103 - pos.length()), pos.constData(), pos.length()); + pos = QByteArray::number(result.indexOf("") + 20); + memcpy(reinterpret_cast(result.data() + 79 - pos.length()), pos.constData(), size_t(pos.length())); + pos = QByteArray::number(result.indexOf("")); + memcpy(reinterpret_cast(result.data() + 103 - pos.length()), pos.constData(), size_t(pos.length())); return setData(result, pmedium); } @@ -1243,9 +1235,9 @@ bool QBuiltInMimes::convertFromMime(const FORMATETC &formatetc, const QMimeData ++u; } res.truncate(ri); - const int byteLength = res.length() * sizeof(ushort); + const int byteLength = res.length() * int(sizeof(ushort)); QByteArray r(byteLength + 2, '\0'); - memcpy(r.data(), res.unicode(), byteLength); + memcpy(r.data(), res.unicode(), size_t(byteLength)); r[byteLength] = 0; r[byteLength+1] = 0; data = r; @@ -1282,7 +1274,7 @@ QVariant QBuiltInMimes::convertToMime(const QString &mimeType, IDataObject *pDat qCDebug(lcQpaMime) << __FUNCTION__; if (mimeType == QLatin1String("text/html") && preferredType == QVariant::String) { // text/html is in wide chars on windows (compatible with Mozilla) - val = QString::fromWCharArray((const wchar_t *)data.data()); + val = QString::fromWCharArray(reinterpret_cast(data.constData())); } else { val = data; // it should be enough to return the data and let QMimeData do the rest. } @@ -1422,8 +1414,8 @@ bool QLastResortMimes::canConvertToMime(const QString &mimeType, IDataObject *pD if (isCustomMimeType(mimeType)) { // MSDN documentation for QueryGetData says only -1 is supported, so ignore lindex here. QString clipFormat = customMimeType(mimeType); - int cf = RegisterClipboardFormat(reinterpret_cast (clipFormat.utf16())); - return canGetData(cf, pDataObj); + const UINT cf = RegisterClipboardFormat(reinterpret_cast (clipFormat.utf16())); + return canGetData(int(cf), pDataObj); } else if (formats.keys(mimeType).isEmpty()) { // if it is not in there then register it and see if we can get it int cf = QWindowsMime::registerMimeType(mimeType); @@ -1443,8 +1435,8 @@ QVariant QLastResortMimes::convertToMime(const QString &mimeType, IDataObject *p if (isCustomMimeType(mimeType)) { int lindex; QString clipFormat = customMimeType(mimeType, &lindex); - int cf = RegisterClipboardFormat(reinterpret_cast (clipFormat.utf16())); - data = getData(cf, pDataObj, lindex); + const UINT cf = RegisterClipboardFormat(reinterpret_cast (clipFormat.utf16())); + data = getData(int(cf), pDataObj, lindex); } else if (formats.keys(mimeType).isEmpty()) { int cf = QWindowsMime::registerMimeType(mimeType); data = getData(cf, pDataObj); @@ -1593,7 +1585,7 @@ void QWindowsMimeConverter::ensureInitialized() const QString QWindowsMimeConverter::clipboardFormatName(int cf) { wchar_t buf[256] = {0}; - return GetClipboardFormatName(cf, buf, 255) + return GetClipboardFormatName(UINT(cf), buf, 255) ? QString::fromWCharArray(buf) : QString(); } diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index e26010b5c4..32f8285954 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -203,7 +203,7 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, // Check for events synthesized from touch. Lower 7 bits are touch/pen index, bit 8 indicates touch. // However, when tablet support is active, extraInfo is a packet serial number. This is not a problem // since we do not want to ignore mouse events coming from a tablet. - const quint64 extraInfo = GetMessageExtraInfo(); + const quint64 extraInfo = quint64(GetMessageExtraInfo()); if ((extraInfo & signatureMask) == miWpSignature) { if (extraInfo & 0x80) { // Bit 7 indicates touch event, else tablet pen. source = Qt::MouseEventSynthesizedBySystem; @@ -243,7 +243,7 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, } QWindowsWindow *platformWindow = static_cast(window->handle()); - const Qt::MouseButtons buttons = keyStateToMouseButtons((int)msg.wParam); + const Qt::MouseButtons buttons = keyStateToMouseButtons(int(msg.wParam)); // If the window was recently resized via mouse doubleclick on the frame or title bar, // we don't get WM_LBUTTONDOWN or WM_LBUTTONDBLCLK for the second click, @@ -418,13 +418,13 @@ static void redirectWheelEvent(QWindow *window, const QPoint &globalPos, int del bool QWindowsMouseHandler::translateMouseWheelEvent(QWindow *window, HWND, MSG msg, LRESULT *) { - const Qt::KeyboardModifiers mods = keyStateToModifiers((int)msg.wParam); + const Qt::KeyboardModifiers mods = keyStateToModifiers(int(msg.wParam)); int delta; if (msg.message == WM_MOUSEWHEEL || msg.message == WM_MOUSEHWHEEL) - delta = (short) HIWORD (msg.wParam); + delta = HIWORD (msg.wParam); else - delta = (int) msg.wParam; + delta = int(msg.wParam); Qt::Orientation orientation = (msg.message == WM_MOUSEHWHEEL || (mods & Qt::AltModifier)) ? @@ -495,15 +495,17 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND, return true; const QRect screenGeometry = screen->geometry(); - const int winTouchPointCount = msg.wParam; + const int winTouchPointCount = int(msg.wParam); QScopedArrayPointer winTouchInputs(new TOUCHINPUT[winTouchPointCount]); - memset(winTouchInputs.data(), 0, sizeof(TOUCHINPUT) * winTouchPointCount); + memset(winTouchInputs.data(), 0, sizeof(TOUCHINPUT) * size_t(winTouchPointCount)); QTouchPointList touchPoints; touchPoints.reserve(winTouchPointCount); Qt::TouchPointStates allStates = 0; - QWindowsContext::user32dll.getTouchInputInfo((HANDLE) msg.lParam, msg.wParam, winTouchInputs.data(), sizeof(TOUCHINPUT)); + QWindowsContext::user32dll.getTouchInputInfo(reinterpret_cast(msg.lParam), + UINT(msg.wParam), + winTouchInputs.data(), sizeof(TOUCHINPUT)); for (int i = 0; i < winTouchPointCount; ++i) { const TOUCHINPUT &winTouchInput = winTouchInputs[i]; int id = m_touchInputIDToTouchPointID.value(winTouchInput.dwID, -1); @@ -544,7 +546,7 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND, touchPoints.append(touchPoint); } - QWindowsContext::user32dll.closeTouchInputHandle((HANDLE) msg.lParam); + QWindowsContext::user32dll.closeTouchInputHandle(reinterpret_cast(msg.lParam)); // all touch points released, forget the ids we've seen, they may not be reused if (allStates == Qt::TouchPointReleased) diff --git a/src/plugins/platforms/windows/qwindowsnativeimage.cpp b/src/plugins/platforms/windows/qwindowsnativeimage.cpp index 66e64e64b4..3cdfc9f56e 100644 --- a/src/plugins/platforms/windows/qwindowsnativeimage.cpp +++ b/src/plugins/platforms/windows/qwindowsnativeimage.cpp @@ -93,13 +93,13 @@ static inline HBITMAP createDIB(HDC hdc, int width, int height, bmi.blueMask = 0; } - void *bits = 0; + uchar *bits = Q_NULLPTR; HBITMAP bitmap = CreateDIBSection(hdc, reinterpret_cast(&bmi), - DIB_RGB_COLORS, &bits, 0, 0); + DIB_RGB_COLORS, reinterpret_cast(&bits), 0, 0); if (!bitmap || !bits) qFatal("%s: CreateDIBSection failed.", __FUNCTION__); - *bitsIn = (uchar*)bits; + *bitsIn = bits; return bitmap; } @@ -112,7 +112,7 @@ QWindowsNativeImage::QWindowsNativeImage(int width, int height, if (width != 0 && height != 0) { uchar *bits; m_bitmap = createDIB(m_hdc, width, height, format, &bits); - m_null_bitmap = (HBITMAP)SelectObject(m_hdc, m_bitmap); + m_null_bitmap = static_cast(SelectObject(m_hdc, m_bitmap)); m_image = QImage(bits, width, height, format); Q_ASSERT(m_image.paintEngine()->type() == QPaintEngine::Raster); static_cast(m_image.paintEngine())->setDC(m_hdc); diff --git a/src/plugins/platforms/windows/qwindowsole.cpp b/src/plugins/platforms/windows/qwindowsole.cpp index e480c1ebcf..4521f66edd 100644 --- a/src/plugins/platforms/windows/qwindowsole.cpp +++ b/src/plugins/platforms/windows/qwindowsole.cpp @@ -215,7 +215,7 @@ QWindowsOleDataObject::EnumFormatEtc(DWORD dwDirection, LPENUMFORMATETC FAR* ppe fmtetcs = mc.allFormatsForMime(data); } else { FORMATETC formatetc; - formatetc.cfFormat = CF_PERFORMEDDROPEFFECT; + formatetc.cfFormat = CLIPFORMAT(CF_PERFORMEDDROPEFFECT); formatetc.dwAspect = DVASPECT_CONTENT; formatetc.lindex = -1; formatetc.ptd = NULL; @@ -269,7 +269,7 @@ QWindowsOleEnumFmtEtc::QWindowsOleEnumFmtEtc(const QVector &fmtetcs) m_lpfmtetcs.reserve(fmtetcs.count()); for (int idx = 0; idx < fmtetcs.count(); ++idx) { LPFORMATETC destetc = new FORMATETC(); - if (copyFormatEtc(destetc, (LPFORMATETC)&(fmtetcs.at(idx)))) { + if (copyFormatEtc(destetc, &(fmtetcs.at(idx)))) { m_lpfmtetcs.append(destetc); } else { m_isNull = true; @@ -363,14 +363,14 @@ QWindowsOleEnumFmtEtc::Next(ULONG celt, LPFORMATETC rgelt, ULONG FAR* pceltFetch nOffset = m_nIndex + i; if (nOffset < ULONG(m_lpfmtetcs.count())) { - copyFormatEtc((LPFORMATETC)&(rgelt[i]), m_lpfmtetcs.at(nOffset)); + copyFormatEtc(rgelt + i, m_lpfmtetcs.at(int(nOffset))); i++; } else { break; } } - m_nIndex += (WORD)i; + m_nIndex += i; if (pceltFetched != NULL) *pceltFetched = i; @@ -397,7 +397,7 @@ QWindowsOleEnumFmtEtc::Skip(ULONG celt) } } - m_nIndex += (WORD)i; + m_nIndex += i; if (i != celt) return ResultFromScode(S_FALSE); @@ -431,7 +431,7 @@ QWindowsOleEnumFmtEtc::Clone(LPENUMFORMATETC FAR* newEnum) return NOERROR; } -bool QWindowsOleEnumFmtEtc::copyFormatEtc(LPFORMATETC dest, LPFORMATETC src) const +bool QWindowsOleEnumFmtEtc::copyFormatEtc(LPFORMATETC dest, const FORMATETC *src) const { if (dest == NULL || src == NULL) return false; diff --git a/src/plugins/platforms/windows/qwindowsole.h b/src/plugins/platforms/windows/qwindowsole.h index 09f6114e2d..bbafa98a0b 100644 --- a/src/plugins/platforms/windows/qwindowsole.h +++ b/src/plugins/platforms/windows/qwindowsole.h @@ -103,7 +103,7 @@ public: STDMETHOD(Clone)(LPENUMFORMATETC FAR* newEnum); private: - bool copyFormatEtc(LPFORMATETC dest, LPFORMATETC src) const; + bool copyFormatEtc(LPFORMATETC dest, const FORMATETC *src) const; ULONG m_dwRefs; ULONG m_nIndex; diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp index fcbe488f93..438aa8752a 100644 --- a/src/plugins/platforms/windows/qwindowsopengltester.cpp +++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp @@ -75,10 +75,10 @@ GpuDescription GpuDescription::detect() const HRESULT hr = direct3D9->GetAdapterIdentifier(0, 0, &adapterIdentifier); direct3D9->Release(); if (SUCCEEDED(hr)) { - result.vendorId = int(adapterIdentifier.VendorId); - result.deviceId = int(adapterIdentifier.DeviceId); - result.revision = int(adapterIdentifier.Revision); - result.subSysId = int(adapterIdentifier.SubSysId); + result.vendorId = adapterIdentifier.VendorId; + result.deviceId = adapterIdentifier.DeviceId; + result.revision = adapterIdentifier.Revision; + result.subSysId = adapterIdentifier.SubSysId; QVector version(4, 0); version[0] = HIWORD(adapterIdentifier.DriverVersion.HighPart); // Product version[1] = LOWORD(adapterIdentifier.DriverVersion.HighPart); // Version @@ -329,10 +329,10 @@ bool QWindowsOpenGLTester::testDesktopGL() WNDCLASS wclass; wclass.cbClsExtra = 0; wclass.cbWndExtra = 0; - wclass.hInstance = (HINSTANCE) GetModuleHandle(0); + wclass.hInstance = static_cast(GetModuleHandle(0)); wclass.hIcon = 0; wclass.hCursor = 0; - wclass.hbrBackground = (HBRUSH) (COLOR_BACKGROUND); + wclass.hbrBackground = HBRUSH(COLOR_BACKGROUND); wclass.lpszMenuName = 0; wclass.lpfnWndProc = DefWindowProc; wclass.lpszClassName = className; @@ -371,8 +371,7 @@ bool QWindowsOpenGLTester::testDesktopGL() typedef const GLubyte * (APIENTRY * GetString_t)(GLenum name); GetString_t GetString = reinterpret_cast(::GetProcAddress(lib, "glGetString")); if (GetString) { - const char *versionStr = (const char *) GetString(GL_VERSION); - if (versionStr) { + if (const char *versionStr = reinterpret_cast(GetString(GL_VERSION))) { const QByteArray version(versionStr); const int majorDot = version.indexOf('.'); if (majorDot != -1) { diff --git a/src/plugins/platforms/windows/qwindowsopengltester.h b/src/plugins/platforms/windows/qwindowsopengltester.h index 0fad3d960e..0f1a78daaa 100644 --- a/src/plugins/platforms/windows/qwindowsopengltester.h +++ b/src/plugins/platforms/windows/qwindowsopengltester.h @@ -51,10 +51,10 @@ struct GpuDescription QString toString() const; QVariant toVariant() const; - int vendorId; - int deviceId; - int revision; - int subSysId; + uint vendorId; + uint deviceId; + uint revision; + uint subSysId; QVersionNumber driverVersion; QByteArray driverName; QByteArray description; diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index bfcf96ebe7..5accbe87e1 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -152,7 +152,7 @@ BOOL QT_WIN_CALLBACK monitorEnumCallback(HMONITOR hMonitor, HDC, LPRECT, LPARAM static inline WindowsScreenDataList monitorData() { WindowsScreenDataList result; - EnumDisplayMonitors(0, 0, monitorEnumCallback, (LPARAM)&result); + EnumDisplayMonitors(0, 0, monitorEnumCallback, reinterpret_cast(&result)); return result; } @@ -200,7 +200,7 @@ Q_GUI_EXPORT QPixmap qt_pixmapFromWinHBITMAP(HBITMAP bitmap, int hbitmapFormat = QPixmap QWindowsScreen::grabWindow(WId window, int x, int y, int width, int height) const { RECT r; - HWND hwnd = window ? (HWND)window : GetDesktopWindow(); + HWND hwnd = window ? reinterpret_cast(window) : GetDesktopWindow(); GetClientRect(hwnd, &r); if (width < 0) width = r.right - r.left; @@ -434,7 +434,7 @@ QWindowsScreenManager::QWindowsScreenManager() : bool QWindowsScreenManager::handleDisplayChange(WPARAM wParam, LPARAM lParam) { - const int newDepth = (int)wParam; + const int newDepth = int(wParam); const WORD newHorizontalResolution = LOWORD(lParam); const WORD newVerticalResolution = HIWORD(lParam); if (newDepth != m_lastDepth || newHorizontalResolution != m_lastHorizontalResolution diff --git a/src/plugins/platforms/windows/qwindowsservices.cpp b/src/plugins/platforms/windows/qwindowsservices.cpp index cc697ba7e4..ae63ac46ae 100644 --- a/src/plugins/platforms/windows/qwindowsservices.cpp +++ b/src/plugins/platforms/windows/qwindowsservices.cpp @@ -53,7 +53,10 @@ static inline bool shellExecute(const QUrl &url) #ifndef Q_OS_WINCE const QString nativeFilePath = url.isLocalFile() ? QDir::toNativeSeparators(url.toLocalFile()) : url.toString(QUrl::FullyEncoded); - const quintptr result = (quintptr)ShellExecute(0, 0, (wchar_t*)nativeFilePath.utf16(), 0, 0, SW_SHOWNORMAL); + const quintptr result = + reinterpret_cast(ShellExecute(0, 0, + reinterpret_cast(nativeFilePath.utf16()), + 0, 0, SW_SHOWNORMAL)); // ShellExecute returns a value greater than 32 if successful if (result <= 32) { qWarning("ShellExecute '%s' failed (error %s).", qPrintable(url.toString()), qPrintable(QString::number(result))); @@ -91,7 +94,7 @@ static inline QString mailCommand() if (debug) qDebug() << __FUNCTION__ << "keyName=" << keyName; command[0] = 0; - if (!RegOpenKeyExW(HKEY_CLASSES_ROOT, (const wchar_t*)keyName.utf16(), 0, KEY_READ, &handle)) { + if (!RegOpenKeyExW(HKEY_CLASSES_ROOT, reinterpret_cast(keyName.utf16()), 0, KEY_READ, &handle)) { DWORD bufferSize = BufferSize; RegQueryValueEx(handle, L"", 0, 0, reinterpret_cast(command), &bufferSize); RegCloseKey(handle); @@ -134,7 +137,8 @@ static inline bool launchMail(const QUrl &url) STARTUPINFO si; ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); - if (!CreateProcess(NULL, (wchar_t*)command.utf16(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { + if (!CreateProcess(NULL, reinterpret_cast(const_cast(command.utf16())), + NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { qErrnoWarning("Unable to launch '%s'", qPrintable(command)); return false; } diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp b/src/plugins/platforms/windows/qwindowstabletsupport.cpp index b27811df9e..222551a86f 100644 --- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp +++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp @@ -316,7 +316,7 @@ QDebug operator<<(QDebug d, const QWindowsTabletDeviceData &t) } #endif // !QT_NO_DEBUG_STREAM -QWindowsTabletDeviceData QWindowsTabletSupport::tabletInit(const quint64 uniqueId, const UINT cursorType) const +QWindowsTabletDeviceData QWindowsTabletSupport::tabletInit(qint64 uniqueId, UINT cursorType) const { QWindowsTabletDeviceData result; result.uniqueId = uniqueId; diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.h b/src/plugins/platforms/windows/qwindowstabletsupport.h index a6d2771206..6e0d92df53 100644 --- a/src/plugins/platforms/windows/qwindowstabletsupport.h +++ b/src/plugins/platforms/windows/qwindowstabletsupport.h @@ -123,7 +123,7 @@ public: private: unsigned options() const; - QWindowsTabletDeviceData tabletInit(const quint64 uniqueId, const UINT cursorType) const; + QWindowsTabletDeviceData tabletInit(qint64 uniqueId, UINT cursorType) const; static QWindowsWinTab32DLL m_winTab32DLL; const HWND m_window; diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 5bbe923fe7..887a217b06 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -456,7 +456,9 @@ static QPixmap loadIconFromShell32(int resourceId, QSizeF size) HMODULE hmod = QSystemLibrary::load(L"shell32"); #endif if (hmod) { - HICON iconHandle = (HICON)LoadImage(hmod, MAKEINTRESOURCE(resourceId), IMAGE_ICON, size.width(), size.height(), 0); + HICON iconHandle = + static_cast(LoadImage(hmod, MAKEINTRESOURCE(resourceId), + IMAGE_ICON, int(size.width()), int(size.height()), 0)); if (iconHandle) { QPixmap iconpixmap = qt_pixmapFromWinHICON(iconHandle); DestroyIcon(iconHandle); @@ -557,7 +559,7 @@ QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) con if (sp == FileLinkIcon || sp == DirLinkIcon || sp == DirLinkOpenIcon) { QPainter painter(&pixmap); QPixmap link = loadIconFromShell32(30, pixmapSize); - painter.drawPixmap(0, 0, pixmapSize.width(), pixmapSize.height(), link); + painter.drawPixmap(0, 0, int(pixmapSize.width()), int(pixmapSize.height()), link); } pixmap.setDevicePixelRatio(scaleFactor); return pixmap; @@ -632,7 +634,8 @@ static QPixmap pixmapFromShellImageList(int iImageList, const SHFILEINFO &info) return result; IImageList *imageList = 0; - HRESULT hr = QWindowsContext::shell32dll.sHGetImageList(iImageList, iID_IImageList, (void **)&imageList); + HRESULT hr = QWindowsContext::shell32dll.sHGetImageList(iImageList, iID_IImageList, + reinterpret_cast(&imageList)); if (hr != S_OK) return result; HICON hIcon; @@ -664,7 +667,7 @@ QPixmap QWindowsTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &s QPixmap pixmap; const QString filePath = QDir::toNativeSeparators(fileInfo.filePath()); - const int width = size.width(); + const int width = int(size.width()); const int iconSize = width > 16 ? SHGFI_LARGEICON : SHGFI_SMALLICON; const int requestedImageListSize = #ifdef USE_IIMAGELIST -- cgit v1.2.3 From 7906255ef2412168dc94768ec7f73ee41b159804 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 11 Feb 2016 13:17:04 +0100 Subject: doc: Clean up old references to QApplication for GUI application Since Qt 5.0, there's been a separation between QGuiApplication for generic GUI applications, and QApplication for applications using Qt Widgets. The docs in QCoreApplication has not reflected this, however, and was still recommending QApplication for any GUI app. Change-Id: I7b2b166170d1e20755889767cda3d555fbbc666a Reviewed-by: Martin Smith Reviewed-by: Nico Vertriest --- src/corelib/kernel/qcoreapplication.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 48d70f2747..6dcd0ed5b4 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -617,7 +617,8 @@ void QCoreApplicationPrivate::initLocale() This class is used by non-GUI applications to provide their event loop. For non-GUI application that uses Qt, there should be exactly one QCoreApplication object. For GUI applications, see - QApplication. + QGuiApplication. For applications that use the Qt Widgets module, + see QApplication. QCoreApplication contains the main event loop, where all events from the operating system (e.g., timer and network events) and @@ -631,10 +632,10 @@ void QCoreApplicationPrivate::initLocale() operations can call processEvents() to keep the application responsive. - In general, we recommend that you create a QCoreApplication or a - QApplication object in your \c main() function as early as - possible. exec() will not return until the event loop exits; e.g., - when quit() is called. + In general, we recommend that you create a QCoreApplication, + QGuiApplication or a QApplication object in your \c main() + function as early as possible. exec() will not return until + the event loop exits; e.g., when quit() is called. Several static convenience functions are also provided. The QCoreApplication object is available from instance(). Events can @@ -676,8 +677,8 @@ void QCoreApplicationPrivate::initLocale() instance, when converting between data types such as floats and strings, since the notation may differ between locales. To get around this problem, call the POSIX function \c{setlocale(LC_NUMERIC,"C")} - right after initializing QApplication or QCoreApplication to reset - the locale that is used for number formatting to "C"-locale. + right after initializing QApplication, QGuiApplication or QCoreApplication + to reset the locale that is used for number formatting to "C"-locale. \sa QGuiApplication, QAbstractEventDispatcher, QEventLoop, {Semaphores Example}, {Wait Conditions Example} @@ -687,7 +688,7 @@ void QCoreApplicationPrivate::initLocale() \fn static QCoreApplication *QCoreApplication::instance() Returns a pointer to the application's QCoreApplication (or - QApplication) instance. + QGuiApplication/QApplication) instance. If no instance has been allocated, \c null is returned. */ @@ -1868,7 +1869,7 @@ void QCoreApplication::quit() Installing or removing a QTranslator, or changing an installed QTranslator generates a \l{QEvent::LanguageChange}{LanguageChange} event for the - QCoreApplication instance. A QApplication instance will propagate the event + QCoreApplication instance. A QGuiApplication instance will propagate the event to all toplevel windows, where a reimplementation of changeEvent can re-translate the user interface by passing user-visible strings via the tr() function to the respective property setters. User-interface classes -- cgit v1.2.3 From aa85ebc266ea7415a883094ea735f549552ff5ac Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Mon, 15 Feb 2016 15:07:53 +0200 Subject: Android: Fix immersive mode The activity exits immersive mode when displaying a dialog. To fix the problem we must use onWindowFocusChanged to update updateFullScreen every time when we've gotten the focus. Task-number: QTBUG-38759 Change-Id: I9f11a82dba484dbec6daba7cbf116f16fe2ba372 Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../src/org/qtproject/qt5/android/QtActivityDelegate.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java index ac77de0bab..4cce86e8bb 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java @@ -92,6 +92,7 @@ public class QtActivityDelegate private Method m_super_onConfigurationChanged = null; private Method m_super_onActivityResult = null; private Method m_super_dispatchGenericMotionEvent = null; + private Method m_super_onWindowFocusChanged = null; private static final String NATIVE_LIBRARIES_KEY = "native.libraries"; private static final String BUNDLED_LIBRARIES_KEY = "bundled.libraries"; @@ -520,6 +521,7 @@ public class QtActivityDelegate m_super_onKeyUp = m_activity.getClass().getMethod("super_onKeyUp", Integer.TYPE, KeyEvent.class); m_super_onConfigurationChanged = m_activity.getClass().getMethod("super_onConfigurationChanged", Configuration.class); m_super_onActivityResult = m_activity.getClass().getMethod("super_onActivityResult", Integer.TYPE, Integer.TYPE, Intent.class); + m_super_onWindowFocusChanged = m_activity.getClass().getMethod("super_onWindowFocusChanged", Boolean.TYPE); if (Build.VERSION.SDK_INT >= 12) { try { m_super_dispatchGenericMotionEvent = m_activity.getClass().getMethod("super_dispatchGenericMotionEvent", MotionEvent.class); @@ -943,6 +945,16 @@ public class QtActivityDelegate } } + public void onWindowFocusChanged(boolean hasFocus) { + try { + m_super_onWindowFocusChanged.invoke(m_activity, hasFocus); + } catch (Exception e) { + e.printStackTrace(); + } + if (hasFocus) + updateFullScreen(); + } + public void onConfigurationChanged(Configuration configuration) { try { -- cgit v1.2.3 From 7cd23a7d5f5b7b10c0e317afcf8bc49020a42e53 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Thu, 18 Feb 2016 18:12:57 +0300 Subject: xcb: Properly initialize available geometry when XRandR is missing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Take an intersection of the screen geometry and the work area. Change-Id: Ia61d090ac103cb4d13d656ec09037f642b255a79 Reviewed-by: Błażej Szczygieł Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbscreen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index f3d381b99e..0ef7166b90 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -208,7 +208,7 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, QXcbVirtualDesktop *virtualDe m_geometry = QRect(QPoint(), m_virtualSize); if (m_availableGeometry.isEmpty()) - m_availableGeometry = m_geometry; + m_availableGeometry = m_geometry & m_virtualDesktop->workArea(); readXResources(); -- cgit v1.2.3 From 3f4eba746d23550be19dc4edafe193fa5ce0d3d4 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 18 Feb 2016 14:05:39 +0100 Subject: xcb: properly initialize size in millimeters if XRandR is not supported MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QXcbScreen did not set the m_sizeMillimeters if the xcb connection does not support XRandR. This caused physicalSize() to return an invalid QSize. This change fixes a regression compared to Qt 5.4 discovered by a broken unit test for KWin on KDE's CI system, which uses Xvfb and by that no XRandR support. Task-number: QTBUG-49885 Change-Id: Ie472a194ba410f0748ccfda8aa467727fafa10a3 Reviewed-by: Błażej Szczygieł Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbscreen.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 0ef7166b90..28b1753712 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -210,6 +210,9 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, QXcbVirtualDesktop *virtualDe if (m_availableGeometry.isEmpty()) m_availableGeometry = m_geometry & m_virtualDesktop->workArea(); + if (m_sizeMillimeters.isEmpty()) + m_sizeMillimeters = m_virtualSizeMillimeters; + readXResources(); QScopedPointer rootAttribs( -- cgit v1.2.3 From 13034e67c0fa1a5ae1899dcb62869da42d84626f Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 30 Jun 2015 22:01:17 +0200 Subject: Make public headers compile with -Wzero-as-null-pointer-constant ... or similar. This amends previous commits that converted the majority of cases. Task-number: QTBUG-45291 Change-Id: I219cdeddca7063a56efeb4fee0e5bb2cbdc7732b Reviewed-by: Lars Knoll Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/arch/qatomic_cxx11.h | 8 ++++---- src/gui/image/qimage.h | 2 +- src/gui/kernel/qevent.h | 2 +- src/gui/opengl/qopenglextrafunctions.h | 2 +- src/gui/painting/qpen.h | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/corelib/arch/qatomic_cxx11.h b/src/corelib/arch/qatomic_cxx11.h index 4136e09ce2..baa3d65faf 100644 --- a/src/corelib/arch/qatomic_cxx11.h +++ b/src/corelib/arch/qatomic_cxx11.h @@ -144,7 +144,7 @@ template struct QAtomicOps static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; } template - static bool testAndSetRelaxed(std::atomic &_q_value, T expectedValue, T newValue, T *currentValue = 0) Q_DECL_NOTHROW + static bool testAndSetRelaxed(std::atomic &_q_value, T expectedValue, T newValue, T *currentValue = Q_NULLPTR) Q_DECL_NOTHROW { bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_relaxed); if (currentValue) @@ -153,7 +153,7 @@ template struct QAtomicOps } template - static bool testAndSetAcquire(std::atomic &_q_value, T expectedValue, T newValue, T *currentValue = 0) Q_DECL_NOTHROW + static bool testAndSetAcquire(std::atomic &_q_value, T expectedValue, T newValue, T *currentValue = Q_NULLPTR) Q_DECL_NOTHROW { bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_acquire); if (currentValue) @@ -162,7 +162,7 @@ template struct QAtomicOps } template - static bool testAndSetRelease(std::atomic &_q_value, T expectedValue, T newValue, T *currentValue = 0) Q_DECL_NOTHROW + static bool testAndSetRelease(std::atomic &_q_value, T expectedValue, T newValue, T *currentValue = Q_NULLPTR) Q_DECL_NOTHROW { bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_release); if (currentValue) @@ -171,7 +171,7 @@ template struct QAtomicOps } template - static bool testAndSetOrdered(std::atomic &_q_value, T expectedValue, T newValue, T *currentValue = 0) Q_DECL_NOTHROW + static bool testAndSetOrdered(std::atomic &_q_value, T expectedValue, T newValue, T *currentValue = Q_NULLPTR) Q_DECL_NOTHROW { bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_acq_rel); if (currentValue) diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 888c7beb32..d05044c44b 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -138,7 +138,7 @@ public: QImage(const QImage &); #ifdef Q_COMPILER_RVALUE_REFS inline QImage(QImage &&other) Q_DECL_NOEXCEPT - : QPaintDevice(), d(0) + : QPaintDevice(), d(Q_NULLPTR) { qSwap(d, other.d); } #endif ~QImage(); diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index b90fce97e0..ed2deda9a0 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -795,7 +795,7 @@ public: TouchPoint(const TouchPoint &other); #ifdef Q_COMPILER_RVALUE_REFS TouchPoint(TouchPoint &&other) Q_DECL_NOEXCEPT - : d(0) + : d(Q_NULLPTR) { qSwap(d, other.d); } TouchPoint &operator=(TouchPoint &&other) Q_DECL_NOEXCEPT { qSwap(d, other.d); return *this; } diff --git a/src/gui/opengl/qopenglextrafunctions.h b/src/gui/opengl/qopenglextrafunctions.h index 6558284bd0..c53c3efba7 100644 --- a/src/gui/opengl/qopenglextrafunctions.h +++ b/src/gui/opengl/qopenglextrafunctions.h @@ -404,7 +404,7 @@ public: void glVertexBindingDivisor(GLuint bindingindex, GLuint divisor); private: - static bool isInitialized(const QOpenGLExtraFunctionsPrivate *d) { return d != 0; } + static bool isInitialized(const QOpenGLExtraFunctionsPrivate *d) { return d != Q_NULLPTR; } }; class QOpenGLExtraFunctionsPrivate : public QOpenGLFunctionsPrivate diff --git a/src/gui/painting/qpen.h b/src/gui/painting/qpen.h index 6ce50ae1d0..bfa1553c68 100644 --- a/src/gui/painting/qpen.h +++ b/src/gui/painting/qpen.h @@ -65,7 +65,7 @@ public: QPen &operator=(const QPen &pen) Q_DECL_NOTHROW; #ifdef Q_COMPILER_RVALUE_REFS QPen(QPen &&other) Q_DECL_NOTHROW - : d(other.d) { other.d = 0; } + : d(other.d) { other.d = Q_NULLPTR; } QPen &operator=(QPen &&other) Q_DECL_NOTHROW { qSwap(d, other.d); return *this; } #endif -- cgit v1.2.3 From 9868d8af8316c01f28255110c28e11344ea6f7a5 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 18 Feb 2016 14:06:02 +0100 Subject: xcb: include Fix trouble compiling with gcc 4.4.7 on Centos 6 Change-Id: Id81bd570e896507a07388257c4f75f80b4b468fd Reviewed-by: Friedemann Kleint --- src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index 969b6deed0..81cdaa56c5 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -38,6 +38,7 @@ #include "qtouchdevice.h" #include #include +#include #ifdef XCB_USE_XINPUT2 -- cgit v1.2.3 From 1ffce57157c7a6ce7fb9d58776ee1dacd2ded61b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 19 Feb 2016 15:43:37 +0100 Subject: Windows DirectWrite: Improve error messages for font engine creation. Fix up debug operator for QFontDef, add one for LOGFONT and output both should creation fail. Task-number: QTBUG-51260 Change-Id: I5cbcd392edd811c6b9470ddbb095d41a9185d208 Reviewed-by: Joerg Bornemann --- .../platforms/windows/qwindowsfontdatabase.cpp | 31 +++++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp index 322ba0ec27..05e5af418a 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp @@ -634,11 +634,24 @@ QDebug operator<<(QDebug d, const QFontDef &def) { QDebugStateSaver saver(d); d.nospace(); - d << "Family=" << def.family << " Stylename=" << def.styleName - << " pointsize=" << def.pointSize << " pixelsize=" << def.pixelSize - << " styleHint=" << def.styleHint << " weight=" << def.weight - << " stretch=" << def.stretch << " hintingPreference=" - << def.hintingPreference; + d.noquote(); + d << "QFontDef(Family=\"" << def.family << '"'; + if (!def.styleName.isEmpty()) + d << ", stylename=" << def.styleName; + d << ", pointsize=" << def.pointSize << ", pixelsize=" << def.pixelSize + << ", styleHint=" << def.styleHint << ", weight=" << def.weight + << ", stretch=" << def.stretch << ", hintingPreference=" + << def.hintingPreference << ')'; + return d; +} + +QDebug operator<<(QDebug d, const LOGFONT &lf) +{ + QDebugStateSaver saver(d); + d.nospace(); + d.noquote(); + d << "LOGFONT(\"" << QString::fromWCharArray(lf.lfFaceName) + << "\", lfWidth=" << lf.lfWidth << ", lfHeight=" << lf.lfHeight << ')'; return d; } #endif // !QT_NO_DEBUG_STREAM @@ -1752,12 +1765,16 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request, IDWriteFont *directWriteFont = 0; HRESULT hr = data->directWriteGdiInterop->CreateFontFromLOGFONT(&lf, &directWriteFont); if (FAILED(hr)) { - qErrnoWarning("%s: CreateFontFromLOGFONT failed", __FUNCTION__); + const QString errorString = qt_error_string(int(GetLastError())); + qWarning().noquote().nospace() << "DirectWrite: CreateFontFromLOGFONT() failed (" + << errorString << ") for " << request << ' ' << lf << " dpi=" << dpi; } else { IDWriteFontFace *directWriteFontFace = NULL; hr = directWriteFont->CreateFontFace(&directWriteFontFace); if (FAILED(hr)) { - qErrnoWarning("%s: CreateFontFace failed", __FUNCTION__); + const QString errorString = qt_error_string(int(GetLastError())); + qWarning().noquote() << "DirectWrite: CreateFontFace() failed (" + << errorString << ") for " << request << ' ' << lf << " dpi=" << dpi; } else { QWindowsFontEngineDirectWrite *fedw = new QWindowsFontEngineDirectWrite(directWriteFontFace, request.pixelSize, -- cgit v1.2.3 From b6bc41f9dfe2223f9f3abd9cde848c669d29d152 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 17 Feb 2016 15:06:41 -0800 Subject: QMenu: Add delegate related notes to OS X-only API Change-Id: I88bb4fdb2c11da0602e4c9f6637bbdeaa715aba0 Reviewed-by: Jake Petroules --- src/widgets/widgets/qmenu_mac.mm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/widgets/qmenu_mac.mm b/src/widgets/widgets/qmenu_mac.mm index 5322a8f3f5..184e4d7bb1 100644 --- a/src/widgets/widgets/qmenu_mac.mm +++ b/src/widgets/widgets/qmenu_mac.mm @@ -67,8 +67,11 @@ inline QPlatformNativeInterface::NativeResourceForIntegrationFunction resolvePla \since 5.2 Returns the native NSMenu for this menu. Available on OS X only. + + \note Qt sets the delegate on the native menu. If you need to set your own + delegate, make sure you save the original one and forward any calls to it. */ -NSMenu* QMenu::toNSMenu() +NSMenu *QMenu::toNSMenu() { // Call into the cocoa platform plugin: qMenuToNSMenu(platformMenu()) QPlatformNativeInterface::NativeResourceForIntegrationFunction function = resolvePlatformFunction("qmenutonsmenu"); @@ -133,8 +136,11 @@ void QMenuPrivate::moveWidgetToPlatformItem(QWidget *widget, QPlatformMenuItem* \since 5.2 Returns the native NSMenu for this menu bar. Available on OS X only. + + \note Qt may set the delegate on the native menu bar. If you need to set your + own delegate, make sure you save the original one and forward any calls to it. */ -NSMenu* QMenuBar::toNSMenu() +NSMenu *QMenuBar::toNSMenu() { // Call into the cocoa platform plugin: qMenuBarToNSMenu(platformMenuBar()) QPlatformNativeInterface::NativeResourceForIntegrationFunction function = resolvePlatformFunction("qmenubartonsmenu"); -- cgit v1.2.3 From 41706400f605524a5a9953714aa0cfbf811dba7e Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 17 Feb 2016 16:35:03 -0800 Subject: QCocoaMenuItem: Use the right Objective C class forwarding macros Change-Id: Icdde469e6854c250d44c88fc79b7615647f0783a Reviewed-by: Jake Petroules --- src/plugins/platforms/cocoa/qcocoamenuitem.h | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.h b/src/plugins/platforms/cocoa/qcocoamenuitem.h index 289f38fd18..1cd15e686c 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.h +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.h @@ -40,17 +40,10 @@ //#define QT_COCOA_ENABLE_MENU_DEBUG -#ifdef __OBJC__ -#define QT_FORWARD_DECLARE_OBJC_CLASS(__KLASS__) @class __KLASS__ -#else -#define QT_FORWARD_DECLARE_OBJC_CLASS(__KLASS__) typedef struct objc_object __KLASS__ -#endif - -QT_FORWARD_DECLARE_OBJC_CLASS(NSMenuItem); -QT_FORWARD_DECLARE_OBJC_CLASS(NSMenu); -QT_FORWARD_DECLARE_OBJC_CLASS(NSObject); -QT_FORWARD_DECLARE_OBJC_CLASS(NSView); - +Q_FORWARD_DECLARE_OBJC_CLASS(NSMenuItem); +Q_FORWARD_DECLARE_OBJC_CLASS(NSMenu); +Q_FORWARD_DECLARE_OBJC_CLASS(NSObject); +Q_FORWARD_DECLARE_OBJC_CLASS(NSView); QT_BEGIN_NAMESPACE -- cgit v1.2.3 From 8ce7441892b1e089a1836334f5f71130930d28eb Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 3 Feb 2016 16:10:33 +0100 Subject: QFontEngineFT: Fix Clang warning about using uninitialized variables. gui/text/qfontengine_ft.cpp(1743,5) : warning: variable 'bytesPerLine' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized] gui/text/qfontengine_ft.cpp(1743,5) : warning: variable 'format' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized] The default branch is marked Q_UNREACHABLE, but apparently Clang does not recognize it. Task-number: QTBUG-50804 Change-Id: Idfce8cb2b9a481dd67a18d9952b920ad4f71e0f4 Reviewed-by: Konstantin Ritt --- src/gui/text/qfontengine_ft.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index de5bec6f93..0a0e174343 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -1719,8 +1719,8 @@ static inline QImage alphaMapFromGlyphData(QFontEngineFT::Glyph *glyph, QFontEng if (glyph == Q_NULLPTR) return QImage(); - QImage::Format format; - int bytesPerLine; + QImage::Format format = QImage::Format_Invalid; + int bytesPerLine = -1; switch (glyphFormat) { case QFontEngine::Format_Mono: format = QImage::Format_Mono; -- cgit v1.2.3 From b8f89d8ef3f695746a8a48084d8ea710eb508d3d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 22 Feb 2016 16:23:39 +0100 Subject: Windows QPA: Use window flags stored in QWindowsWindow for frame geometry. Querying the flags of the QWindow fails when inside QWindowsWindow::setWindowFlags() since the new flags do not take effect. Task-number: QTBUG-40578 Task-number: QTBUG-51224 Change-Id: Ida8c23b64ddfde34ebc0af95c84954e666865240 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowswindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 2ff71d827b..cb733ed5bd 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1914,7 +1914,7 @@ QMargins QWindowsWindow::frameMargins() const // Always skip calculating style-dependent margins for windows claimed to be frameless. // This allows users to remove the margins by handling WM_NCCALCSIZE with WS_THICKFRAME set // to ensure Areo snap still works (QTBUG-40578). - m_data.frame = window()->flags() & Qt::FramelessWindowHint + m_data.frame = m_data.flags & Qt::FramelessWindowHint ? QMargins(0, 0, 0, 0) : QWindowsGeometryHint::frame(style(), exStyle()); clearFlag(FrameDirty); -- cgit v1.2.3 From 20a29fbfe834c108517a23db359827d067246ecd Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 11 Feb 2016 09:48:06 +0100 Subject: Windows QPA: Send synthesized expose events when window shrinks. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix the condition to check for plain move events and gain in one dimension in which case Windows will send events. Task-number: QTBUG-51038 Change-Id: I60433657f37275ee302f745291e79e465d52064d Reviewed-by: Błażej Szczygieł Reviewed-by: Shawn Rutledge --- src/plugins/platforms/windows/qwindowswindow.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index cb733ed5bd..e2f5885047 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1467,7 +1467,9 @@ void QWindowsWindow::handleGeometryChange() // QTBUG-32121: OpenGL/normal windows (with exception of ANGLE) do not receive // expose events when shrinking, synthesize. if (!testFlag(OpenGL_ES2) && isExposed() - && !(m_data.geometry.width() >= previousGeometry.width() || m_data.geometry.height() >= previousGeometry.height())) { + && m_data.geometry.size() != previousGeometry.size() // Exclude plain move + // One dimension grew -> Windows will send expose, no need to synthesize. + && !(m_data.geometry.width() > previousGeometry.width() || m_data.geometry.height() > previousGeometry.height())) { fireExpose(QRect(QPoint(0, 0), m_data.geometry.size()), true); } if (previousGeometry.topLeft() != m_data.geometry.topLeft()) { -- cgit v1.2.3 From 57ecd5aeeb1f609206933be66b92fcdf703703d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Szczygie=C5=82?= Date: Thu, 21 Jan 2016 13:19:37 +0100 Subject: QtWidgets: Proper delivery of enter/leave event to context menus First-level context menu grabs the mouse, so all mouse events are delivered to it. This menu passes the mouse events to submenus. Any platform delivers mouse enter/leave event differently when window is grabbed. This patch unifies event delivery to context menus - it can block some unwanted events and it emulates fake events if necessary. This patch can reduce duplicated events and can provide proper enter or leave event to additional widgets in the context menu. It can also prevent submenu from unwanted close on Windows and X11. Added autotest. Task-number: QTBUG-45565 Task-number: QTBUG-45893 Task-number: QTBUG-47515 Change-Id: I7dd476d0be23afa34e947e54aef235012d173dcf Reviewed-by: Shawn Rutledge --- src/widgets/kernel/qwidgetwindow.cpp | 54 ++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index 0de0fe21f2..b2a2ecc3b9 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -313,6 +313,14 @@ QPointer qt_last_mouse_receiver = 0; void QWidgetWindow::handleEnterLeaveEvent(QEvent *event) { +#if !defined(Q_OS_OSX) && !defined(Q_OS_IOS) // Cocoa tracks popups + // Ignore all enter/leave events from QPA if we are not on the first-level context menu. + // This prevents duplicated events on most platforms. Fake events will be delivered in + // QWidgetWindow::handleMouseEvent(QMouseEvent *). Make an exception whether the widget + // is already under mouse - let the mouse leave. + if (QApplicationPrivate::inPopupMode() && m_widget != QApplication::activePopupWidget() && !m_widget->underMouse()) + return; +#endif if (event->type() == QEvent::Leave) { QWidget *enter = 0; // Check from window system event queue if the next queued enter targets a window @@ -407,14 +415,13 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event) QEvent::MouseButtonRelease : QEvent::MouseButtonPress; if (qApp->d_func()->inPopupMode()) { QWidget *activePopupWidget = qApp->activePopupWidget(); - QWidget *popup = activePopupWidget; QPoint mapped = event->pos(); - if (popup != m_widget) - mapped = popup->mapFromGlobal(event->globalPos()); + if (activePopupWidget != m_widget) + mapped = activePopupWidget->mapFromGlobal(event->globalPos()); bool releaseAfter = false; - QWidget *popupChild = popup->childAt(mapped); + QWidget *popupChild = activePopupWidget->childAt(mapped); - if (popup != qt_popup_down) { + if (activePopupWidget != qt_popup_down) { qt_button_down = 0; qt_popup_down = 0; } @@ -423,7 +430,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event) case QEvent::MouseButtonPress: case QEvent::MouseButtonDblClick: qt_button_down = popupChild; - qt_popup_down = popup; + qt_popup_down = activePopupWidget; break; case QEvent::MouseButtonRelease: releaseAfter = true; @@ -434,18 +441,41 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event) int oldOpenPopupCount = openPopupCount; - if (popup->isEnabled()) { + if (activePopupWidget->isEnabled()) { // deliver event qt_replay_popup_mouse_event = false; - QWidget *receiver = popup; + QWidget *receiver = activePopupWidget; QPoint widgetPos = mapped; if (qt_button_down) receiver = qt_button_down; else if (popupChild) receiver = popupChild; - if (receiver != popup) + if (receiver != activePopupWidget) widgetPos = receiver->mapFromGlobal(event->globalPos()); - QWidget *alien = m_widget->childAt(m_widget->mapFromGlobal(event->globalPos())); + QWidget *alien = receiver; + +#if !defined(Q_OS_OSX) && !defined(Q_OS_IOS) // Cocoa tracks popups + const bool reallyUnderMouse = activePopupWidget->rect().contains(mapped); + const bool underMouse = activePopupWidget->underMouse(); + if (activePopupWidget != m_widget || (!underMouse && qt_button_down)) { + // If active popup menu is not the first-level popup menu then we must emulate enter/leave events, + // because first-level popup menu grabs the mouse and enter/leave events are delivered only to it + // by QPA. Make an exception for first-level popup menu when the mouse button is pressed on widget. + if (underMouse != reallyUnderMouse) { + if (reallyUnderMouse) { + QApplicationPrivate::dispatchEnterLeave(receiver, Q_NULLPTR, event->screenPos()); + qt_last_mouse_receiver = receiver; + } else { + QApplicationPrivate::dispatchEnterLeave(Q_NULLPTR, qt_last_mouse_receiver, event->screenPos()); + qt_last_mouse_receiver = receiver; + receiver = activePopupWidget; + } + } + } else if (!reallyUnderMouse) { + alien = Q_NULLPTR; + } +#endif + QMouseEvent e(event->type(), widgetPos, event->windowPos(), event->screenPos(), event->button(), event->buttons(), event->modifiers(), event->source()); e.setTimestamp(event->timestamp()); @@ -457,7 +487,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event) case QEvent::MouseButtonPress: case QEvent::MouseButtonDblClick: case QEvent::MouseButtonRelease: - popup->close(); + activePopupWidget->close(); break; default: break; @@ -503,7 +533,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event) } else if (event->type() == contextMenuTrigger && event->button() == Qt::RightButton && (openPopupCount == oldOpenPopupCount)) { - QWidget *popupEvent = popup; + QWidget *popupEvent = activePopupWidget; if (qt_button_down) popupEvent = qt_button_down; else if(popupChild) -- cgit v1.2.3 From 63b5f5cb98fe19af5bf20d4f581723cb91a46dcb Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 22 Feb 2016 16:17:10 +0100 Subject: Disable ligatures using existing mechanism in HB, not workaround This is a partial revert of fef629cd9191bb73f22c5efb6f943e6b672953c1. When doing the original fix, I didn't realize that there was a mechanism for disabling specific OpenType features in Harfbuzz. This commit reverts the hack to disable GSUB completely and disables the ligature features instead. Task-number: QTBUG-44393 Change-Id: I30f0080eb3897f37219df7f2d50843f3a4556e13 Reviewed-by: Konstantin Ritt --- src/gui/text/qharfbuzzng.cpp | 15 +-------------- src/gui/text/qharfbuzzng_p.h | 3 --- src/gui/text/qtextengine.cpp | 19 +++++++++++-------- 3 files changed, 12 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/gui/text/qharfbuzzng.cpp b/src/gui/text/qharfbuzzng.cpp index 6437465da8..b2edfc00a0 100644 --- a/src/gui/text/qharfbuzzng.cpp +++ b/src/gui/text/qharfbuzzng.cpp @@ -573,27 +573,17 @@ _hb_qt_font_get_glyph_from_name(hb_font_t * /*font*/, void * /*font_data*/, static hb_user_data_key_t _useDesignMetricsKey; -static hb_user_data_key_t _ignoreGSUB; void hb_qt_font_set_use_design_metrics(hb_font_t *font, uint value) { hb_font_set_user_data(font, &_useDesignMetricsKey, (void *)quintptr(value), NULL, true); } -void hb_qt_face_set_ignore_gsub(hb_face_t *face, uint value) -{ - hb_face_set_user_data(face, &_ignoreGSUB, (void *)quintptr(value), NULL, true); -} - uint hb_qt_font_get_use_design_metrics(hb_font_t *font) { return quintptr(hb_font_get_user_data(font, &_useDesignMetricsKey)); } -uint hb_qt_face_get_ignore_gsub(hb_face_t *face) -{ - return quintptr(hb_face_get_user_data(face, &_ignoreGSUB)); -} struct _hb_qt_font_funcs_t { _hb_qt_font_funcs_t() @@ -628,14 +618,11 @@ hb_font_funcs_t *hb_qt_get_font_funcs() static hb_blob_t * -_hb_qt_reference_table(hb_face_t *face, hb_tag_t tag, void *user_data) +_hb_qt_reference_table(hb_face_t * /*face*/, hb_tag_t tag, void *user_data) { QFontEngine::FaceData *data = static_cast(user_data); Q_ASSERT(data); - if (hb_qt_face_get_ignore_gsub(face) && tag == HB_TAG('G','S','U','B')) - return hb_blob_get_empty(); - qt_get_font_table_func_t get_font_table = data->get_font_table; Q_ASSERT(get_font_table); diff --git a/src/gui/text/qharfbuzzng_p.h b/src/gui/text/qharfbuzzng_p.h index 8beadbc72c..d5e11e6264 100644 --- a/src/gui/text/qharfbuzzng_p.h +++ b/src/gui/text/qharfbuzzng_p.h @@ -72,9 +72,6 @@ Q_GUI_EXPORT hb_font_t *hb_qt_font_get_for_engine(QFontEngine *fe); Q_GUI_EXPORT void hb_qt_font_set_use_design_metrics(hb_font_t *font, uint value); Q_GUI_EXPORT uint hb_qt_font_get_use_design_metrics(hb_font_t *font); -Q_GUI_EXPORT void hb_qt_face_set_ignore_gsub(hb_face_t *font, uint value); -Q_GUI_EXPORT uint hb_qt_face_get_ignore_gsub(hb_face_t *font); - QT_END_NAMESPACE #endif // QHARFBUZZNG_P_H diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 7dc8e8fadb..c545240c57 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1175,16 +1175,19 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, Q_ASSERT(hb_font); hb_qt_font_set_use_design_metrics(hb_font, option.useDesignMetrics() ? uint(QFontEngine::DesignMetrics) : 0); // ### + // Ligatures are incompatible with custom letter spacing, so when a letter spacing is set, + // we disable them for writing systems where they are purely cosmetic. bool scriptRequiresOpenType = ((script >= QChar::Script_Syriac && script <= QChar::Script_Sinhala) || script == QChar::Script_Khmer || script == QChar::Script_Nko); - hb_face_t *hb_face = hb_font_get_face(hb_font); - Q_ASSERT(hb_face); - hb_qt_face_set_ignore_gsub(hb_face, hasLetterSpacing && !scriptRequiresOpenType); - - const hb_feature_t features[1] = { - { HB_TAG('k','e','r','n'), !!kerningEnabled, 0, uint(-1) } - }; - const int num_features = 1; + + bool dontLigate = hasLetterSpacing && !scriptRequiresOpenType; + const hb_feature_t features[5] = { + { HB_TAG('k','e','r','n'), !!kerningEnabled, 0, uint(-1) }, + { HB_TAG('l','i','g','a'), !dontLigate, 0, uint(-1) }, + { HB_TAG('c','l','i','g'), !dontLigate, 0, uint(-1) }, + { HB_TAG('d','l','i','g'), !dontLigate, 0, uint(-1) }, + { HB_TAG('h','l','i','g'), !dontLigate, 0, uint(-1) } }; + const int num_features = dontLigate ? 5 : 1; const char *const *shaper_list = Q_NULLPTR; #if defined(Q_OS_DARWIN) -- cgit v1.2.3 From 7091be1b7999d93fe2126042161dcd1d8fd20026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Szczygie=C5=82?= Date: Tue, 19 Jan 2016 22:32:52 +0100 Subject: xcb: Deliver mouse enter event to window when closing modal window When a modal window is closed and the mouse is not under the modal window - find a proper window and send a fake enter event. Added auto test for checking enter event on window when modal window is closed. Task-number: QTBUG-35109 Change-Id: I370b52d386503820ac9de21e6d05fd019ca456ec Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbwindow.cpp | 48 ++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 46b7b70f80..7eae2d92ab 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -50,6 +50,7 @@ #include "qxcbsystemtraytracker.h" #include +#include #include @@ -261,6 +262,26 @@ static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s) } #endif // XCB_USE_XLIB +// TODO move this into a utility function in QWindow or QGuiApplication +static QWindow *childWindowAt(QWindow *win, const QPoint &p) +{ + foreach (QObject *obj, win->children()) { + if (obj->isWindowType()) { + QWindow *childWin = static_cast(obj); + if (childWin->isVisible()) { + if (QWindow *recurse = childWindowAt(childWin, p)) + return recurse; + } + } + } + if (!win->isTopLevel() + && !(win->flags() & Qt::WindowTransparentForInput) + && win->geometry().contains(win->parent()->mapFromGlobal(p))) { + return win; + } + return Q_NULLPTR; +} + static const char *wm_window_type_property_id = "_q_xcb_wm_window_type"; QXcbWindow::QXcbWindow(QWindow *window) @@ -855,6 +876,33 @@ void QXcbWindow::hide() connection()->setMouseGrabber(Q_NULLPTR); m_mapped = false; + + // Hiding a modal window doesn't send an enter event to its transient parent when the + // mouse is already over the parent window, so the enter event must be emulated. + if (window()->isModal()) { + // Get the cursor position at modal window screen + const QPoint nativePos = xcbScreen()->cursor()->pos(); + const QPoint cursorPos = QHighDpi::fromNativePixels(nativePos, xcbScreen()->screenForPosition(nativePos)->screen()); + + // Find the top level window at cursor position. + // Don't use QGuiApplication::topLevelAt(): search only the virtual siblings of this window's screen + QWindow *enterWindow = Q_NULLPTR; + foreach (QPlatformScreen *screen, xcbScreen()->virtualSiblings()) { + if (screen->geometry().contains(cursorPos)) { + const QPoint devicePosition = QHighDpi::toNativePixels(cursorPos, screen->screen()); + enterWindow = screen->topLevelAt(devicePosition); + break; + } + } + + if (enterWindow && enterWindow != window()) { + // Find the child window at cursor position, otherwise use the top level window + if (QWindow *childWindow = childWindowAt(enterWindow, cursorPos)) + enterWindow = childWindow; + const QPoint localPos = enterWindow->mapFromGlobal(cursorPos); + QWindowSystemInterface::handleEnterEvent(enterWindow, localPos, cursorPos); + } + } } static QWindow *tlWindow(QWindow *window) -- cgit v1.2.3 From 544bbcbcdabdd012cbcce484196053a0b9f37104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Szczygie=C5=82?= Date: Tue, 9 Feb 2016 15:51:05 +0100 Subject: QtWidgets: Always deliver the wheel event to submenus When mouse events are delivered using XInput2 then the wheel event is missing on submenus, because XInput2 delivers the wheel event only to the root menu. Task-number: QTBUG-50996 Change-Id: I757c0b5e3aea4606d2e45dfc8180c263e02167ca Reviewed-by: Shawn Rutledge --- src/widgets/kernel/qwidgetwindow.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index b2a2ecc3b9..15c28d0913 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -747,13 +747,24 @@ void QWidgetWindow::handleWheelEvent(QWheelEvent *event) if (QApplicationPrivate::instance()->modalState() && !qt_try_modal(m_widget, event->type())) return; + QWidget *rootWidget = m_widget; + QPoint pos = event->pos(); + + // Use proper popup window for wheel event. Some QPA sends the wheel + // event to the root menu, so redirect it to the proper popup window. + QWidget *activePopupWidget = QApplication::activePopupWidget(); + if (activePopupWidget && activePopupWidget != m_widget) { + rootWidget = activePopupWidget; + pos = rootWidget->mapFromGlobal(event->globalPos()); + } + // which child should have it? - QWidget *widget = m_widget->childAt(event->pos()); + QWidget *widget = rootWidget->childAt(pos); if (!widget) - widget = m_widget; + widget = rootWidget; - QPoint mapped = widget->mapFrom(m_widget, event->pos()); + QPoint mapped = widget->mapFrom(rootWidget, pos); QWheelEvent translated(mapped, event->globalPos(), event->pixelDelta(), event->angleDelta(), event->delta(), event->orientation(), event->buttons(), event->modifiers(), event->phase(), event->source()); QGuiApplication::sendSpontaneousEvent(widget, &translated); -- cgit v1.2.3 From d8e65d5756c937fc3d9be3e5c30b31914a437393 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 22 Feb 2016 15:07:21 +0100 Subject: Fix font dialog with missing font family and pixel sizes Two related errors: When a non-existent font was set on the font dialog, the GTK native font dialog would just pick a default one. Also, if the font size was specified with pixel size, we would request -1 as the point size from Pango. The fix for both is to resolve the font before applying it to the font dialog, and set the actually resolved family, as well as point size. Note that if the point size is explicitly set, then we pass this to the font dialog, since the one returned by QFontInfo will always be calculated based on the (rounded) pixel size, so it will usually not match the request. This fixes tst_qfontdialog::setFont(). [ChangeLog][GTK2][Dialogs] Fixed requesting a font from font dialog with a non-existent family name and/or pixel size. Task-number: QTBUG-51148 Change-Id: Id9c783407778546b0cf3f9c3ab19f124e76c878e Reviewed-by: Shawn Rutledge Reviewed-by: J-P Nurmi --- src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp b/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp index 857f373759..f0a54ec92f 100644 --- a/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp +++ b/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp @@ -517,8 +517,8 @@ void QGtk2FontDialogHelper::hide() static QString qt_fontToString(const QFont &font) { PangoFontDescription *desc = pango_font_description_new(); - pango_font_description_set_size(desc, font.pointSizeF() * PANGO_SCALE); - pango_font_description_set_family(desc, font.family().toUtf8()); + pango_font_description_set_size(desc, (font.pointSizeF() > 0.0 ? font.pointSizeF() : QFontInfo(font).pointSizeF()) * PANGO_SCALE); + pango_font_description_set_family(desc, QFontInfo(font).family().toUtf8()); int weight = font.weight(); if (weight >= QFont::Black) -- cgit v1.2.3