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/plugins/platforms/xcb/qxcbdrag.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/plugins') 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 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/plugins') 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 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/plugins') 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 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/plugins') 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/plugins') 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 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/plugins') 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/plugins') 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 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/plugins') 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 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/plugins') 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/plugins') 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 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/plugins') 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 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/plugins') 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