summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java12
-rw-r--r--src/corelib/arch/qatomic_cxx11.h8
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp19
-rw-r--r--src/gui/image/qimage.h2
-rw-r--r--src/gui/kernel/qevent.h2
-rw-r--r--src/gui/kernel/qsimpledrag.cpp5
-rw-r--r--src/gui/kernel/qsimpledrag_p.h3
-rw-r--r--src/gui/opengl/qopenglextrafunctions.h2
-rw-r--r--src/gui/opengl/qopenglshaderprogram.cpp2
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp3
-rw-r--r--src/gui/painting/qpen.h2
-rw-r--r--src/gui/text/qfontengine_ft.cpp4
-rw-r--r--src/gui/text/qtextengine.cpp30
-rw-r--r--src/gui/text/qtextengine_p.h8
-rw-r--r--src/gui/text/qtextlayout.cpp19
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenuitem.h15
-rw-r--r--src/plugins/platforms/windows/qwindowsbackingstore.cpp4
-rw-r--r--src/plugins/platforms/windows/qwindowsclipboard.cpp4
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp46
-rw-r--r--src/plugins/platforms/windows/qwindowscursor.cpp6
-rw-r--r--src/plugins/platforms/windows/qwindowsdrag.cpp4
-rw-r--r--src/plugins/platforms/windows/qwindowseglcontext.cpp12
-rw-r--r--src/plugins/platforms/windows/qwindowsfontdatabase.cpp51
-rw-r--r--src/plugins/platforms/windows/qwindowsfontengine.cpp104
-rw-r--r--src/plugins/platforms/windows/qwindowsglcontext.cpp6
-rw-r--r--src/plugins/platforms/windows/qwindowsinputcontext.cpp25
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.cpp4
-rw-r--r--src/plugins/platforms/windows/qwindowskeymapper.cpp66
-rw-r--r--src/plugins/platforms/windows/qwindowsmime.cpp152
-rw-r--r--src/plugins/platforms/windows/qwindowsmousehandler.cpp20
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeimage.cpp8
-rw-r--r--src/plugins/platforms/windows/qwindowsole.cpp12
-rw-r--r--src/plugins/platforms/windows/qwindowsole.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsopengltester.cpp15
-rw-r--r--src/plugins/platforms/windows/qwindowsopengltester.h8
-rw-r--r--src/plugins/platforms/windows/qwindowsscreen.cpp6
-rw-r--r--src/plugins/platforms/windows/qwindowsservices.cpp10
-rw-r--r--src/plugins/platforms/windows/qwindowstabletsupport.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowstabletsupport.h2
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.cpp11
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp6
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection_xi2.cpp1
-rw-r--r--src/plugins/platforms/xcb/qxcbdrag.cpp4
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.cpp5
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp48
-rw-r--r--src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp4
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp71
-rw-r--r--src/widgets/widgets/qmenu_mac.mm10
48 files changed, 516 insertions, 349 deletions
diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
index c434cc24b3..66600512a0 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
@@ -101,6 +101,7 @@ public class QtActivityDelegate
private Method m_super_onConfigurationChanged = null;
private Method m_super_onActivityResult = null;
private Method m_super_dispatchGenericMotionEvent = null;
+ private Method m_super_onWindowFocusChanged = null;
private static final String NATIVE_LIBRARIES_KEY = "native.libraries";
private static final String BUNDLED_LIBRARIES_KEY = "bundled.libraries";
@@ -516,6 +517,7 @@ public class QtActivityDelegate
m_super_onKeyUp = m_activity.getClass().getMethod("super_onKeyUp", Integer.TYPE, KeyEvent.class);
m_super_onConfigurationChanged = m_activity.getClass().getMethod("super_onConfigurationChanged", Configuration.class);
m_super_onActivityResult = m_activity.getClass().getMethod("super_onActivityResult", Integer.TYPE, Integer.TYPE, Intent.class);
+ m_super_onWindowFocusChanged = m_activity.getClass().getMethod("super_onWindowFocusChanged", Boolean.TYPE);
m_super_dispatchGenericMotionEvent = m_activity.getClass().getMethod("super_dispatchGenericMotionEvent", MotionEvent.class);
} catch (Exception e) {
e.printStackTrace();
@@ -917,6 +919,16 @@ public class QtActivityDelegate
new QtAccessibilityDelegate(m_activity, m_layout, this);
}
+ public void onWindowFocusChanged(boolean hasFocus) {
+ try {
+ m_super_onWindowFocusChanged.invoke(m_activity, hasFocus);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ if (hasFocus)
+ updateFullScreen();
+ }
+
public void onConfigurationChanged(Configuration configuration)
{
try {
diff --git a/src/corelib/arch/qatomic_cxx11.h b/src/corelib/arch/qatomic_cxx11.h
index 4c9001a7cd..bb49aae4fb 100644
--- a/src/corelib/arch/qatomic_cxx11.h
+++ b/src/corelib/arch/qatomic_cxx11.h
@@ -151,7 +151,7 @@ template <typename X> struct QAtomicOps
static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; }
template <typename T>
- static bool testAndSetRelaxed(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = 0) Q_DECL_NOTHROW
+ static bool testAndSetRelaxed(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = Q_NULLPTR) Q_DECL_NOTHROW
{
bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_relaxed);
if (currentValue)
@@ -160,7 +160,7 @@ template <typename X> struct QAtomicOps
}
template <typename T>
- static bool testAndSetAcquire(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = 0) Q_DECL_NOTHROW
+ static bool testAndSetAcquire(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = Q_NULLPTR) Q_DECL_NOTHROW
{
bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_acquire);
if (currentValue)
@@ -169,7 +169,7 @@ template <typename X> struct QAtomicOps
}
template <typename T>
- static bool testAndSetRelease(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = 0) Q_DECL_NOTHROW
+ static bool testAndSetRelease(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = Q_NULLPTR) Q_DECL_NOTHROW
{
bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_release);
if (currentValue)
@@ -178,7 +178,7 @@ template <typename X> struct QAtomicOps
}
template <typename T>
- static bool testAndSetOrdered(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = 0) Q_DECL_NOTHROW
+ static bool testAndSetOrdered(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = Q_NULLPTR) Q_DECL_NOTHROW
{
bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_acq_rel);
if (currentValue)
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 42bda25be5..79a3254a39 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -588,7 +588,8 @@ void QCoreApplicationPrivate::initLocale()
This class is used by non-GUI applications to provide their event
loop. For non-GUI application that uses Qt, there should be exactly
one QCoreApplication object. For GUI applications, see
- QApplication.
+ QGuiApplication. For applications that use the Qt Widgets module,
+ see QApplication.
QCoreApplication contains the main event loop, where all events
from the operating system (e.g., timer and network events) and
@@ -602,10 +603,10 @@ void QCoreApplicationPrivate::initLocale()
operations can call processEvents() to keep the application
responsive.
- In general, we recommend that you create a QCoreApplication or a
- QApplication object in your \c main() function as early as
- possible. exec() will not return until the event loop exits; e.g.,
- when quit() is called.
+ In general, we recommend that you create a QCoreApplication,
+ QGuiApplication or a QApplication object in your \c main()
+ function as early as possible. exec() will not return until
+ the event loop exits; e.g., when quit() is called.
Several static convenience functions are also provided. The
QCoreApplication object is available from instance(). Events can
@@ -647,8 +648,8 @@ void QCoreApplicationPrivate::initLocale()
instance, when converting between data types such as floats and
strings, since the notation may differ between locales. To get
around this problem, call the POSIX function \c{setlocale(LC_NUMERIC,"C")}
- right after initializing QApplication or QCoreApplication to reset
- the locale that is used for number formatting to "C"-locale.
+ right after initializing QApplication, QGuiApplication or QCoreApplication
+ to reset the locale that is used for number formatting to "C"-locale.
\sa QGuiApplication, QAbstractEventDispatcher, QEventLoop,
{Semaphores Example}, {Wait Conditions Example}
@@ -658,7 +659,7 @@ void QCoreApplicationPrivate::initLocale()
\fn static QCoreApplication *QCoreApplication::instance()
Returns a pointer to the application's QCoreApplication (or
- QApplication) instance.
+ QGuiApplication/QApplication) instance.
If no instance has been allocated, \c null is returned.
*/
@@ -1865,7 +1866,7 @@ void QCoreApplication::quit()
Installing or removing a QTranslator, or changing an installed QTranslator
generates a \l{QEvent::LanguageChange}{LanguageChange} event for the
- QCoreApplication instance. A QApplication instance will propagate the event
+ QCoreApplication instance. A QGuiApplication instance will propagate the event
to all toplevel windows, where a reimplementation of changeEvent can
re-translate the user interface by passing user-visible strings via the
tr() function to the respective property setters. User-interface classes
diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h
index 4ccdaca94e..2aa19a8465 100644
--- a/src/gui/image/qimage.h
+++ b/src/gui/image/qimage.h
@@ -144,7 +144,7 @@ public:
QImage(const QImage &);
#ifdef Q_COMPILER_RVALUE_REFS
inline QImage(QImage &&other) Q_DECL_NOEXCEPT
- : QPaintDevice(), d(0)
+ : QPaintDevice(), d(Q_NULLPTR)
{ qSwap(d, other.d); }
#endif
~QImage();
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index c03714b22a..fadca9510b 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -800,7 +800,7 @@ public:
TouchPoint(const TouchPoint &other);
#ifdef Q_COMPILER_RVALUE_REFS
TouchPoint(TouchPoint &&other) Q_DECL_NOEXCEPT
- : d(0)
+ : d(Q_NULLPTR)
{ qSwap(d, other.d); }
TouchPoint &operator=(TouchPoint &&other) Q_DECL_NOEXCEPT
{ qSwap(d, other.d); return *this; }
diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp
index 214c656a0b..a6ce04dc34 100644
--- a/src/gui/kernel/qsimpledrag.cpp
+++ b/src/gui/kernel/qsimpledrag.cpp
@@ -94,7 +94,8 @@ static QWindow* topLevelAt(const QPoint &pos)
QBasicDrag::QBasicDrag() :
m_restoreCursor(false), m_eventLoop(0),
m_executed_drop_action(Qt::IgnoreAction), m_can_drop(false),
- m_drag(0), m_drag_icon_window(0), m_useCompositing(true)
+ m_drag(0), m_drag_icon_window(0), m_useCompositing(true),
+ m_screen(Q_NULLPTR)
{
}
@@ -225,7 +226,7 @@ void QBasicDrag::startDrag()
pos = QPoint();
}
#endif
- recreateShapedPixmapWindow(Q_NULLPTR, pos);
+ recreateShapedPixmapWindow(m_screen, pos);
enableEventFilter();
}
diff --git a/src/gui/kernel/qsimpledrag_p.h b/src/gui/kernel/qsimpledrag_p.h
index c7a40d1d03..8924b4d08f 100644
--- a/src/gui/kernel/qsimpledrag_p.h
+++ b/src/gui/kernel/qsimpledrag_p.h
@@ -97,6 +97,8 @@ protected:
bool useCompositing() const { return m_useCompositing; }
void setUseCompositing(bool on) { m_useCompositing = on; }
+ void setScreen(QScreen *screen) { m_screen = screen; }
+
Qt::DropAction executedDropAction() const { return m_executed_drop_action; }
void setExecutedDropAction(Qt::DropAction da) { m_executed_drop_action = da; }
@@ -115,6 +117,7 @@ private:
QDrag *m_drag;
QShapedPixmapWindow *m_drag_icon_window;
bool m_useCompositing;
+ QScreen *m_screen;
};
class Q_GUI_EXPORT QSimpleDrag : public QBasicDrag
diff --git a/src/gui/opengl/qopenglextrafunctions.h b/src/gui/opengl/qopenglextrafunctions.h
index 06ab749f19..d3b25fa348 100644
--- a/src/gui/opengl/qopenglextrafunctions.h
+++ b/src/gui/opengl/qopenglextrafunctions.h
@@ -410,7 +410,7 @@ public:
void glVertexBindingDivisor(GLuint bindingindex, GLuint divisor);
private:
- static bool isInitialized(const QOpenGLExtraFunctionsPrivate *d) { return d != 0; }
+ static bool isInitialized(const QOpenGLExtraFunctionsPrivate *d) { return d != Q_NULLPTR; }
};
class QOpenGLExtraFunctionsPrivate : public QOpenGLFunctionsPrivate
diff --git a/src/gui/opengl/qopenglshaderprogram.cpp b/src/gui/opengl/qopenglshaderprogram.cpp
index a32c111178..9ac020b64b 100644
--- a/src/gui/opengl/qopenglshaderprogram.cpp
+++ b/src/gui/opengl/qopenglshaderprogram.cpp
@@ -3390,7 +3390,7 @@ QVector<float> QOpenGLShaderProgram::defaultInnerTessellationLevels() const
#if defined(QT_OPENGL_4)
Q_D(const QOpenGLShaderProgram);
if (d->tessellationFuncs)
- d->tessellationFuncs->glGetFloatv(GL_PATCH_DEFAULT_OUTER_LEVEL, tessLevels.data());
+ d->tessellationFuncs->glGetFloatv(GL_PATCH_DEFAULT_INNER_LEVEL, tessLevels.data());
#endif
return tessLevels;
}
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 0df9d6873e..34b4d97758 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -689,6 +689,7 @@ void QRasterPaintEngine::penChanged()
qDebug() << "QRasterPaintEngine::penChanged():" << state()->pen;
#endif
QRasterPaintEngineState *s = state();
+ Q_ASSERT(s);
s->strokeFlags |= DirtyPen;
s->dirty |= DirtyPen;
}
@@ -2200,6 +2201,7 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe
Q_D(QRasterPaintEngine);
QRasterPaintEngineState *s = state();
+ Q_ASSERT(s);
int sr_l = qFloor(sr.left());
int sr_r = qCeil(sr.right()) - 1;
int sr_t = qFloor(sr.top());
@@ -2437,6 +2439,7 @@ void QRasterPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap,
#endif
Q_D(QRasterPaintEngine);
QRasterPaintEngineState *s = state();
+ Q_ASSERT(s);
QImage image;
diff --git a/src/gui/painting/qpen.h b/src/gui/painting/qpen.h
index f1130cbf75..7469931a48 100644
--- a/src/gui/painting/qpen.h
+++ b/src/gui/painting/qpen.h
@@ -71,7 +71,7 @@ public:
QPen &operator=(const QPen &pen) Q_DECL_NOTHROW;
#ifdef Q_COMPILER_RVALUE_REFS
QPen(QPen &&other) Q_DECL_NOTHROW
- : d(other.d) { other.d = 0; }
+ : d(other.d) { other.d = Q_NULLPTR; }
QPen &operator=(QPen &&other) Q_DECL_NOTHROW
{ qSwap(d, other.d); return *this; }
#endif
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 3b330a0fd3..779333351f 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -1725,8 +1725,8 @@ static inline QImage alphaMapFromGlyphData(QFontEngineFT::Glyph *glyph, QFontEng
if (glyph == Q_NULLPTR)
return QImage();
- QImage::Format format;
- int bytesPerLine;
+ QImage::Format format = QImage::Format_Invalid;
+ int bytesPerLine = -1;
switch (glyphFormat) {
case QFontEngine::Format_Mono:
format = QImage::Format_Mono;
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index b15fc4c047..f5df6fd60b 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1065,7 +1065,7 @@ void QTextEngine::shapeText(int item) const
#ifdef QT_ENABLE_HARFBUZZ_NG
if (Q_LIKELY(qt_useHarfbuzzNG()))
- si.num_glyphs = shapeTextWithHarfbuzzNG(si, string, itemLength, fontEngine, itemBoundaries, kerningEnabled);
+ si.num_glyphs = shapeTextWithHarfbuzzNG(si, string, itemLength, fontEngine, itemBoundaries, kerningEnabled, letterSpacing != 0);
else
#endif
si.num_glyphs = shapeTextWithHarfbuzz(si, string, itemLength, fontEngine, itemBoundaries, kerningEnabled);
@@ -1127,7 +1127,13 @@ QT_BEGIN_INCLUDE_NAMESPACE
QT_END_INCLUDE_NAMESPACE
-int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *string, int itemLength, QFontEngine *fontEngine, const QVector<uint> &itemBoundaries, bool kerningEnabled) const
+int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si,
+ const ushort *string,
+ int itemLength,
+ QFontEngine *fontEngine,
+ const QVector<uint> &itemBoundaries,
+ bool kerningEnabled,
+ bool hasLetterSpacing) const
{
uint glyphs_shaped = 0;
@@ -1141,7 +1147,8 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *st
hb_segment_properties_t props = HB_SEGMENT_PROPERTIES_DEFAULT;
props.direction = si.analysis.bidiLevel % 2 ? HB_DIRECTION_RTL : HB_DIRECTION_LTR;
- props.script = hb_qt_script_to_script(QChar::Script(si.analysis.script));
+ QChar::Script script = QChar::Script(si.analysis.script);
+ props.script = hb_qt_script_to_script(script);
// ### props.language = hb_language_get_default_for_script(props.script);
for (int k = 0; k < itemBoundaries.size(); k += 3) {
@@ -1174,10 +1181,19 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *st
Q_ASSERT(hb_font);
hb_qt_font_set_use_design_metrics(hb_font, option.useDesignMetrics() ? uint(QFontEngine::DesignMetrics) : 0); // ###
- const hb_feature_t features[1] = {
- { HB_TAG('k','e','r','n'), !!kerningEnabled, 0, uint(-1) }
- };
- const int num_features = 1;
+ // Ligatures are incompatible with custom letter spacing, so when a letter spacing is set,
+ // we disable them for writing systems where they are purely cosmetic.
+ bool scriptRequiresOpenType = ((script >= QChar::Script_Syriac && script <= QChar::Script_Sinhala)
+ || script == QChar::Script_Khmer || script == QChar::Script_Nko);
+
+ bool dontLigate = hasLetterSpacing && !scriptRequiresOpenType;
+ const hb_feature_t features[5] = {
+ { HB_TAG('k','e','r','n'), !!kerningEnabled, 0, uint(-1) },
+ { HB_TAG('l','i','g','a'), !dontLigate, 0, uint(-1) },
+ { HB_TAG('c','l','i','g'), !dontLigate, 0, uint(-1) },
+ { HB_TAG('d','l','i','g'), !dontLigate, 0, uint(-1) },
+ { HB_TAG('h','l','i','g'), !dontLigate, 0, uint(-1) } };
+ const int num_features = dontLigate ? 5 : 1;
const char *const *shaper_list = Q_NULLPTR;
#if defined(Q_OS_DARWIN)
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
index 83575af43a..ab08f2d5e5 100644
--- a/src/gui/text/qtextengine_p.h
+++ b/src/gui/text/qtextengine_p.h
@@ -649,7 +649,13 @@ private:
void addRequiredBoundaries() const;
void shapeText(int item) const;
#ifdef QT_ENABLE_HARFBUZZ_NG
- int shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *string, int itemLength, QFontEngine *fontEngine, const QVector<uint> &itemBoundaries, bool kerningEnabled) const;
+ int shapeTextWithHarfbuzzNG(const QScriptItem &si,
+ const ushort *string,
+ int itemLength,
+ QFontEngine *fontEngine,
+ const QVector<uint> &itemBoundaries,
+ bool kerningEnabled,
+ bool hasLetterSpacing) const;
#endif
int shapeTextWithHarfbuzz(const QScriptItem &si, const ushort *string, int itemLength, QFontEngine *fontEngine, const QVector<uint> &itemBoundaries, bool kerningEnabled) const;
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 9cc9cc9206..8902d52b28 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -2147,6 +2147,7 @@ static QGlyphRun glyphRunWithInfo(QFontEngine *fontEngine,
QGlyphRunPrivate *d = QGlyphRunPrivate::get(glyphRun);
int rangeStart = textPosition;
+ logClusters += textPosition;
while (*logClusters != glyphsStart && rangeStart < textPosition + textLength) {
++logClusters;
++rangeStart;
@@ -2331,16 +2332,16 @@ QList<QGlyphRun> QTextLine::glyphRuns(int from, int length) const
if (mainFontEngine->type() == QFontEngine::Multi) {
QFontEngineMulti *multiFontEngine = static_cast<QFontEngineMulti *>(mainFontEngine);
- int end = rtl ? glyphLayout.numGlyphs : 0;
- int start = rtl ? end : 0;
- int which = glyphLayout.glyphs[rtl ? start - 1 : end] >> 24;
- for (; (rtl && start > 0) || (!rtl && end < glyphLayout.numGlyphs);
+ int start = rtl ? glyphLayout.numGlyphs : 0;
+ int end = start - 1;
+ int which = glyphLayout.glyphs[rtl ? start - 1 : end + 1] >> 24;
+ for (; (rtl && start > 0) || (!rtl && end < glyphLayout.numGlyphs - 1);
rtl ? --start : ++end) {
- const int e = glyphLayout.glyphs[rtl ? start - 1 : end] >> 24;
+ const int e = glyphLayout.glyphs[rtl ? start - 1 : end + 1] >> 24;
if (e == which)
continue;
- QGlyphLayout subLayout = glyphLayout.mid(start, end - start);
+ QGlyphLayout subLayout = glyphLayout.mid(start, end - start + 1);
multiFontEngine->ensureEngineAt(which);
QGlyphRun::GlyphRunFlags subFlags = flags;
@@ -2364,13 +2365,13 @@ QList<QGlyphRun> QTextLine::glyphRuns(int from, int length) const
}
if (rtl)
- end = start;
+ end = start - 1;
else
- start = end;
+ start = end + 1;
which = e;
}
- QGlyphLayout subLayout = glyphLayout.mid(start, end - start);
+ QGlyphLayout subLayout = glyphLayout.mid(start, end - start + 1);
multiFontEngine->ensureEngineAt(which);
QGlyphRun::GlyphRunFlags subFlags = flags;
diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.h b/src/plugins/platforms/cocoa/qcocoamenuitem.h
index ba2005eabc..0d6f67959b 100644
--- a/src/plugins/platforms/cocoa/qcocoamenuitem.h
+++ b/src/plugins/platforms/cocoa/qcocoamenuitem.h
@@ -46,17 +46,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
diff --git a/src/plugins/platforms/windows/qwindowsbackingstore.cpp b/src/plugins/platforms/windows/qwindowsbackingstore.cpp
index b265054e12..7123ed826d 100644
--- a/src/plugins/platforms/windows/qwindowsbackingstore.cpp
+++ b/src/plugins/platforms/windows/qwindowsbackingstore.cpp
@@ -100,7 +100,7 @@ void QWindowsBackingStore::flush(QWindow *window, const QRegion &region,
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()};
@@ -126,7 +126,7 @@ void QWindowsBackingStore::flush(QWindow *window, const QRegion &region,
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 95e595b88e..d527e07308 100644
--- a/src/plugins/platforms/windows/qwindowsclipboard.cpp
+++ b/src/plugins/platforms/windows/qwindowsclipboard.cpp
@@ -265,9 +265,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<HWND>(wParam);
if (toBeRemoved == m_nextClipboardViewer) {
- m_nextClipboardViewer = (HWND)lParam;
+ m_nextClipboardViewer = reinterpret_cast<HWND>(lParam);
} else {
propagateClipboardMessage(message, wParam, lParam);
}
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index 8501ec6731..efeb1f5f05 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -107,10 +107,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<HKL> 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:
@@ -546,15 +546,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<HINSTANCE>(GetModuleHandle(0));
if (classExists == -1) {
WNDCLASS wcinfo;
- classExists = GetClassInfo(appInstance, (wchar_t*)cname.utf16(), &wcinfo);
+ classExists = GetClassInfo(appInstance, reinterpret_cast<LPCWSTR>(cname.utf16()), &wcinfo);
classExists = classExists && wcinfo.lpfnWndProc != proc;
}
if (classExists)
- cname += QString::number((quintptr)proc);
+ cname += QString::number(reinterpret_cast<quintptr>(proc));
if (d->m_registeredWindowClassNames.contains(cname)) // already registered in our list
return cname;
@@ -574,13 +574,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<HICON>(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<HICON>(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<HICON>(LoadImage(0, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED));
wc.hIconSm = 0;
}
} else {
@@ -596,7 +596,7 @@ QString QWindowsContext::registerWindowClass(QString cname,
#endif
wc.lpszMenuName = 0;
- wc.lpszClassName = (wchar_t*)cname.utf16();
+ wc.lpszClassName = reinterpret_cast<LPCWSTR>(cname.utf16());
#ifndef Q_OS_WINCE
ATOM atom = RegisterClassEx(&wc);
#else
@@ -616,10 +616,10 @@ QString QWindowsContext::registerWindowClass(QString cname,
void QWindowsContext::unregisterWindowClasses()
{
- const HINSTANCE appInstance = (HINSTANCE)GetModuleHandle(0);
+ const HINSTANCE appInstance = static_cast<HINSTANCE>(GetModuleHandle(0));
foreach (const QString &name, d->m_registeredWindowClassNames) {
- if (!UnregisterClass((wchar_t*)name.utf16(), appInstance) && QWindowsContext::verbose)
+ if (!UnregisterClass(reinterpret_cast<LPCWSTR>(name.utf16()), appInstance) && QWindowsContext::verbose)
qErrnoWarning("UnregisterClass failed for '%s'", qPrintable(name));
}
d->m_registeredWindowClassNames.clear();
@@ -635,11 +635,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<LPTSTR>(&lpMsgBuf), 0, NULL);
if (len) {
- rc = QString::fromUtf16(lpMsgBuf, len);
+ rc = QString::fromUtf16(lpMsgBuf, int(len));
LocalFree(lpMsgBuf);
} else {
rc += QString::fromLatin1("<unknown error>");
@@ -803,11 +803,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<LPCWSTR>(className.utf16()),
windowName, style,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
- HWND_MESSAGE, NULL, (HINSTANCE)GetModuleHandle(0), NULL);
+ HWND_MESSAGE, NULL, static_cast<HINSTANCE>(GetModuleHandle(0)), NULL);
}
#ifndef Q_OS_WINCE
@@ -818,11 +818,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<HLOCAL>(message));
return result;
}
if (const WORD wCode = comError.WCode())
@@ -1070,7 +1070,7 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
platformWindow->handleMoved();
return true;
case QtWindows::ResizeEvent:
- platformWindow->handleResized((int)wParam);
+ platformWindow->handleResized(static_cast<int>(wParam));
return true;
#ifndef Q_OS_WINCE // maybe available on some SDKs revisit WM_GETMINMAXINFO
case QtWindows::QuerySizeHints:
@@ -1212,7 +1212,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.
@@ -1279,7 +1279,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);
@@ -1287,8 +1287,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 a13fe5c40e..0eb7043bbc 100644
--- a/src/plugins/platforms/windows/qwindowscursor.cpp
+++ b/src/plugins/platforms/windows/qwindowscursor.cpp
@@ -119,8 +119,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;
@@ -577,7 +577,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<HCURSOR>(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 2c6e6b9771..246f53ef2f 100644
--- a/src/plugins/platforms/windows/qwindowsdrag.cpp
+++ b/src/plugins/platforms/windows/qwindowsdrag.cpp
@@ -645,7 +645,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<DWORD *>(GlobalLock(hData));
*moveEffect = DROPEFFECT_MOVE;
GlobalUnlock(hData);
STGMEDIUM medium;
@@ -653,7 +653,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 704f99c4ef..a11196d1d2 100644
--- a/src/plugins/platforms/windows/qwindowseglcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp
@@ -193,9 +193,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<LPCWSTR>(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
@@ -401,7 +401,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;
@@ -433,8 +433,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<EGLNativeWindowType>(nativeWindow), 0);
if (surface == EGL_NO_SURFACE) {
*err = libEGL.eglGetError();
qWarning("%s: Could not create the EGL window surface: 0x%x", __FUNCTION__, *err);
@@ -445,7 +445,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/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
index dde85f2e6a..743408949d 100644
--- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
@@ -276,10 +276,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;
@@ -641,11 +641,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
@@ -799,7 +812,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<QChar *>(i18n_name.unicode());
const unsigned char *string = table + string_offset + offset;
for (int i = 0; i < length; ++i)
uc[i] = getUShort(string + 2*i);
@@ -807,10 +820,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<QChar *>(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]));
}
}
}
@@ -1161,8 +1174,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<char *>(newFontData.constData()),
+ DWORD(newFontData.size()), 0, &count);
if (count == 0 && fontHandle != 0) {
RemoveFontMemResourceEx(fontHandle);
fontHandle = 0;
@@ -1380,8 +1394,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<char *>(fontData.constData()),
+ DWORD(fontData.size()), 0, &dummy);
if (font.handle == 0)
return QStringList();
@@ -1757,12 +1772,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,
diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp
index 160560dbda..c78412c8ec 100644
--- a/src/plugins/platforms/windows/qwindowsfontengine.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp
@@ -166,6 +166,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<const uchar *>(otm) + quintptr(offset);
+ return QString::fromWCharArray(reinterpret_cast<const wchar_t *>(p));
+}
+
void QWindowsFontEngine::getCMap()
{
ttf = (bool)(tm.tmPitchAndFamily & TMPF_TRUETYPE) || hasCMapTable();
@@ -189,11 +195,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;
+ unitsPerEm = int(otm->otmEMSquare);
+ const QFixed unitsPerEmF(unitsPerEm);
+ designToDevice = unitsPerEmF / QFixed::fromReal(fontDef.pixelSize);
+ x_height = int(otm->otmsXHeight);
loadKerningPairs(designToDevice);
- _faceId.filename = QFile::encodeName(QString::fromWCharArray((wchar_t *)((char *)otm + (quintptr)otm->otmpFullName)));
+ _faceId.filename = QFile::encodeName(stringFromOutLineTextMetric(otm, otm->otmpFullName));
lineWidth = otm->otmsUnderscoreSize;
fsType = otm->otmfsType;
free(otm);
@@ -394,9 +401,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<QFixed *>(realloc(designAdvances, size_t(newSize) * sizeof(QFixed)));
+ Q_CHECK_PTR(designAdvances);
for(int i = designAdvancesSize; i < newSize; ++i)
designAdvances[i] = -1000000;
designAdvancesSize = newSize;
@@ -418,9 +425,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<unsigned char *>(realloc(widthCache, newSize * sizeof(QFixed)));
+ Q_CHECK_PTR(widthCache);
memset(widthCache + widthCacheSize, 0, newSize - widthCacheSize);
widthCacheSize = newSize;
}
@@ -440,7 +447,7 @@ void QWindowsFontEngine::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::Shape
++chrLen;
}
SIZE size = {0, 0};
- GetTextExtentPoint32(hdc, (wchar_t *)ch, chrLen, &size);
+ GetTextExtentPoint32(hdc, reinterpret_cast<const wchar_t *>(ch), chrLen, &size);
width = size.cx;
} else {
calculateTTFGlyphWidth(hdc, glyph, width);
@@ -448,7 +455,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);
}
}
@@ -489,10 +496,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);
@@ -514,7 +521,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;
@@ -533,7 +541,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);
@@ -798,7 +806,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
@@ -808,17 +816,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;
}
@@ -831,20 +837,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<const TTPOLYGONHEADER *>(dataBuffer + headerOffset);
QPointF lastPoint(qt_to_qpointf(ttph->pfxStart, scale));
path->moveTo(lastPoint + oset);
offset += sizeof(TTPOLYGONHEADER);
- TTPOLYCURVE *curve;
- while (offset<int(headerOffset + ttph->cb)) {
- curve = (TTPOLYCURVE*)((char*)(dataBuffer) + offset);
+ while (offset < headerOffset + ttph->cb) {
+ const TTPOLYCURVE *curve = reinterpret_cast<const TTPOLYCURVE *>(dataBuffer + offset);
switch (curve->wType) {
case TT_PRIM_LINE: {
for (int i=0; i<curve->cpfx; ++i) {
@@ -889,7 +893,7 @@ static bool addGlyphToPath(glyph_t glyph, const QFixedPoint &position, HDC hdc,
path->closeSubpath();
headerOffset += ttph->cb;
}
- delete [] (char*)dataBuffer;
+ delete [] dataBuffer;
return true;
}
@@ -987,15 +991,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);
@@ -1061,10 +1065,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;
@@ -1074,7 +1078,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));
@@ -1088,13 +1092,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;
@@ -1131,11 +1135,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<LPCWSTR>(&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<LPCWSTR>(&glyph), 1, 0);
}
SelectObject(hdc, old_font);
@@ -1166,7 +1170,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);
@@ -1213,11 +1217,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<void *>(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<void *>(quintptr(contrast)), 0);
if (mask == 0)
return QImage();
diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp
index 1adce2a874..48f2e3aaef 100644
--- a/src/plugins/platforms/windows/qwindowsglcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp
@@ -1017,7 +1017,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<const char*>(s));
return QByteArray();
}
@@ -1244,7 +1244,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<const char *>(QOpenGLStaticContext::opengl32.glGetString(GL_EXTENSIONS));
hasRobustness = exts && strstr(exts, "GL_ARB_robustness");
} else {
typedef const GLubyte * (APIENTRY *glGetStringi_t)(GLenum, GLuint);
@@ -1253,7 +1253,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<const char *>(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 f1addf186d..d0c3b80707 100644
--- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp
@@ -323,7 +323,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);
}
@@ -332,7 +334,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.
@@ -563,9 +565,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:
@@ -576,7 +577,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;
@@ -610,13 +611,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;
@@ -635,13 +636,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<ushort *>(reconv + 1);
diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp
index 2904999d96..e0ebb142f5 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.cpp
+++ b/src/plugins/platforms/windows/qwindowsintegration.cpp
@@ -543,8 +543,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 6fc49c1384..48de7d56f8 100644
--- a/src/plugins/platforms/windows/qwindowskeymapper.cpp
+++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp
@@ -547,7 +547,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];
}
@@ -581,10 +581,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<LPWSTR>(unicodeBuffer), 5, 0);
// When Ctrl modifier is used ToUnicode does not return correct values. In order to assign the
@@ -638,13 +638,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;
@@ -668,7 +668,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
@@ -727,7 +727,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)
@@ -768,7 +768,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);
}
@@ -813,7 +813,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,
@@ -877,7 +877,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.
@@ -891,10 +891,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;
@@ -955,13 +955,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 {
@@ -1036,7 +1036,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;
}
@@ -1048,6 +1048,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
case Qt::Key_Slash:
case Qt::Key_NumLock:
state |= Qt::KeypadModifier;
+ break;
default:
break;
}
@@ -1057,13 +1058,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;
}
@@ -1076,11 +1077,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
@@ -1091,7 +1092,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
const QWindowsInputContext *windowsInputContext =
qobject_cast<const QWindowsInputContext *>(QWindowsIntegration::instance()->inputContext());
if (!(windowsInputContext && windowsInputContext->isComposing()))
- vk_key = ImmGetVirtualKey((HWND)window->winId());
+ vk_key = ImmGetVirtualKey(reinterpret_cast<HWND>(window->winId()));
BYTE keyState[256];
wchar_t newKey[3] = {0};
GetKeyboardState(keyState);
@@ -1111,14 +1112,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
@@ -1147,9 +1148,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;
}
}
@@ -1157,7 +1158,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?
@@ -1166,9 +1167,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
@@ -1187,7 +1188,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);
}
}
@@ -1197,7 +1198,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
@@ -1205,13 +1206,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 79f627d458..cb112446fc 100644
--- a/src/plugins/platforms/windows/qwindowsmime.cpp
+++ b/src/plugins/platforms/windows/qwindowsmime.cpp
@@ -156,7 +156,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;
@@ -176,30 +176,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<const QRgb *>(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<const char *>(buf), bpl_bmp);
if (s.status() != QDataStream::Ok) {
delete[] buf;
return false;
@@ -227,25 +226,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<char *>(&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
@@ -257,30 +253,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<QRgb *>(data + h * bpl);
+ QRgb *end = p + w;
+ if (d->read(reinterpret_cast<char *>(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),
@@ -295,9 +286,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;
}
@@ -315,7 +306,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;
@@ -325,12 +316,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;
@@ -345,8 +336,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<const char *>(val), int(GlobalSize(s.hGlobal)));
data.detach();
GlobalUnlock(s.hGlobal);
ReleaseStgMedium(&s);
@@ -362,7 +353,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;
@@ -514,11 +505,11 @@ QWindowsMime::~QWindowsMime()
*/
int QWindowsMime::registerMimeType(const QString &mime)
{
- int f = RegisterClipboardFormat(reinterpret_cast<const wchar_t *> (mime.utf16()));
+ const UINT f = RegisterClipboardFormat(reinterpret_cast<const wchar_t *> (mime.utf16()));
if (!f)
qErrnoWarning("QWindowsMime::registerMimeType: Failed to register clipboard format");
- return f;
+ return int(f);
}
/*!
@@ -661,9 +652,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);
@@ -706,17 +697,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<const wchar_t *>(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<s; i++) {
+ for (unsigned i = 0; i < s; ++i) {
char c = d[i];
if (c!='\r')
o[j++]=c;
@@ -777,22 +768,22 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat
for (int i=0; i<urls.size(); i++) {
QString fn = QDir::toNativeSeparators(urls.at(i).toLocalFile());
if (!fn.isEmpty()) {
- size += sizeof(ushort) * (fn.length() + 1);
+ size += sizeof(ushort) * size_t(fn.length() + 1);
fileNames.append(fn);
}
}
QByteArray result(size, '\0');
- DROPFILES* d = (DROPFILES*)result.data();
+ DROPFILES* d = reinterpret_cast<DROPFILES *>(result.data());
d->pFiles = sizeof(DROPFILES);
GetCursorPos(&d->pt); // try
d->fNC = true;
- char* files = ((char*)d) + d->pFiles;
+ char *files = (reinterpret_cast<char*>(d)) + d->pFiles;
d->fWide = true;
- wchar_t* f = (wchar_t*)files;
+ wchar_t *f = reinterpret_cast<wchar_t *>(files);
for (int i=0; i<fileNames.size(); i++) {
- int l = fileNames.at(i).length();
+ const size_t l = size_t(fileNames.at(i).length());
memcpy(f, fileNames.at(i).utf16(), l * sizeof(ushort));
f += l;
*f++ = 0;
@@ -805,7 +796,8 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat
QByteArray result;
if (!urls.isEmpty()) {
QString url = urls.at(0).toString();
- result = QByteArray((const char *)url.utf16(), url.length() * sizeof(ushort));
+ result = QByteArray(reinterpret_cast<const char *>(url.utf16()),
+ url.length() * int(sizeof(ushort)));
}
result.append('\0');
result.append('\0');
@@ -860,9 +852,9 @@ QVariant QWindowsMimeURI::convertToMime(const QString &mimeType, LPDATAOBJECT pD
if (data.isEmpty())
return QVariant();
- LPDROPFILES hdrop = (LPDROPFILES)data.data();
+ const DROPFILES *hdrop = reinterpret_cast<const DROPFILES *>(data.constData());
if (hdrop->fWide) {
- const wchar_t* filesw = (const wchar_t *)(data.data() + hdrop->pFiles);
+ const wchar_t *filesw = reinterpret_cast<const wchar_t *>(data.constData() + hdrop->pFiles);
int i = 0;
while (filesw[i]) {
QString fileurl = QString::fromWCharArray(filesw + i);
@@ -870,7 +862,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<const char *>(data.constData() + hdrop->pFiles);
int i=0;
while (files[i]) {
urls += QUrl::fromLocalFile(QString::fromLocal8Bit(files+i));
@@ -886,7 +878,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<const wchar_t *>(data.constData())));
} else if (canGetData(CF_INETURL, pDataObj)) {
QByteArray data = getData(CF_INETURL, pDataObj);
if (data.isEmpty())
@@ -1014,14 +1006,14 @@ bool QWindowsMimeHtml::convertFromMime(const FORMATETC &formatetc, const QMimeDa
result += "<!--EndFragment-->";
// 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<char *>(result.data() + 53 - pos.length()), pos.constData(), size_t(pos.length()));
// set correct numbers for StartFragment and EndFragment
- pos = QString::number(result.indexOf("<!--StartFragment-->") + 20).toLatin1();
- memcpy((char *)(result.data() + 79 - pos.length()), pos.constData(), pos.length());
- pos = QString::number(result.indexOf("<!--EndFragment-->")).toLatin1();
- memcpy((char *)(result.data() + 103 - pos.length()), pos.constData(), pos.length());
+ pos = QByteArray::number(result.indexOf("<!--StartFragment-->") + 20);
+ memcpy(reinterpret_cast<char *>(result.data() + 79 - pos.length()), pos.constData(), size_t(pos.length()));
+ pos = QByteArray::number(result.indexOf("<!--EndFragment-->"));
+ memcpy(reinterpret_cast<char *>(result.data() + 103 - pos.length()), pos.constData(), size_t(pos.length()));
return setData(result, pmedium);
}
@@ -1249,9 +1241,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;
@@ -1288,7 +1280,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<const wchar_t *>(data.constData()));
} else {
val = data; // it should be enough to return the data and let QMimeData do the rest.
}
@@ -1428,8 +1420,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<const wchar_t *> (clipFormat.utf16()));
- return canGetData(cf, pDataObj);
+ const UINT cf = RegisterClipboardFormat(reinterpret_cast<const wchar_t *> (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);
@@ -1449,8 +1441,8 @@ QVariant QLastResortMimes::convertToMime(const QString &mimeType, IDataObject *p
if (isCustomMimeType(mimeType)) {
int lindex;
QString clipFormat = customMimeType(mimeType, &lindex);
- int cf = RegisterClipboardFormat(reinterpret_cast<const wchar_t *> (clipFormat.utf16()));
- data = getData(cf, pDataObj, lindex);
+ const UINT cf = RegisterClipboardFormat(reinterpret_cast<const wchar_t *> (clipFormat.utf16()));
+ data = getData(int(cf), pDataObj, lindex);
} else if (formats.keys(mimeType).isEmpty()) {
int cf = QWindowsMime::registerMimeType(mimeType);
data = getData(cf, pDataObj);
@@ -1599,7 +1591,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 c8b18f3b57..5ae5ae3129 100644
--- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp
+++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
@@ -210,7 +210,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;
@@ -250,7 +250,7 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd,
}
QWindowsWindow *platformWindow = static_cast<QWindowsWindow *>(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,
@@ -426,13 +426,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)) ?
@@ -503,15 +503,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<TOUCHINPUT> 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<HANDLE>(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);
@@ -552,7 +554,7 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
touchPoints.append(touchPoint);
}
- QWindowsContext::user32dll.closeTouchInputHandle((HANDLE) msg.lParam);
+ QWindowsContext::user32dll.closeTouchInputHandle(reinterpret_cast<HANDLE>(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 72e3268405..bc8bfda32b 100644
--- a/src/plugins/platforms/windows/qwindowsnativeimage.cpp
+++ b/src/plugins/platforms/windows/qwindowsnativeimage.cpp
@@ -99,13 +99,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<BITMAPINFO *>(&bmi),
- DIB_RGB_COLORS, &bits, 0, 0);
+ DIB_RGB_COLORS, reinterpret_cast<void **>(&bits), 0, 0);
if (Q_UNLIKELY(!bitmap || !bits))
qFatal("%s: CreateDIBSection failed.", __FUNCTION__);
- *bitsIn = (uchar*)bits;
+ *bitsIn = bits;
return bitmap;
}
@@ -118,7 +118,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<HBITMAP>(SelectObject(m_hdc, m_bitmap));
m_image = QImage(bits, width, height, format);
Q_ASSERT(m_image.paintEngine()->type() == QPaintEngine::Raster);
static_cast<QRasterPaintEngine *>(m_image.paintEngine())->setDC(m_hdc);
diff --git a/src/plugins/platforms/windows/qwindowsole.cpp b/src/plugins/platforms/windows/qwindowsole.cpp
index 43325d5235..a1a8c0b499 100644
--- a/src/plugins/platforms/windows/qwindowsole.cpp
+++ b/src/plugins/platforms/windows/qwindowsole.cpp
@@ -221,7 +221,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;
@@ -275,7 +275,7 @@ QWindowsOleEnumFmtEtc::QWindowsOleEnumFmtEtc(const QVector<FORMATETC> &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;
@@ -369,14 +369,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;
@@ -403,7 +403,7 @@ QWindowsOleEnumFmtEtc::Skip(ULONG celt)
}
}
- m_nIndex += (WORD)i;
+ m_nIndex += i;
if (i != celt)
return ResultFromScode(S_FALSE);
@@ -437,7 +437,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 027a749759..009111e55c 100644
--- a/src/plugins/platforms/windows/qwindowsole.h
+++ b/src/plugins/platforms/windows/qwindowsole.h
@@ -109,7 +109,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 b0856a7441..4ca7f0e413 100644
--- a/src/plugins/platforms/windows/qwindowsopengltester.cpp
+++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp
@@ -81,10 +81,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<int> version(4, 0);
version[0] = HIWORD(adapterIdentifier.DriverVersion.HighPart); // Product
version[1] = LOWORD(adapterIdentifier.DriverVersion.HighPart); // Version
@@ -335,10 +335,10 @@ bool QWindowsOpenGLTester::testDesktopGL()
WNDCLASS wclass;
wclass.cbClsExtra = 0;
wclass.cbWndExtra = 0;
- wclass.hInstance = (HINSTANCE) GetModuleHandle(0);
+ wclass.hInstance = static_cast<HINSTANCE>(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;
@@ -377,8 +377,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
typedef const GLubyte * (APIENTRY * GetString_t)(GLenum name);
GetString_t GetString = reinterpret_cast<GetString_t>(::GetProcAddress(lib, "glGetString"));
if (GetString) {
- const char *versionStr = (const char *) GetString(GL_VERSION);
- if (versionStr) {
+ if (const char *versionStr = reinterpret_cast<const char *>(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 482a1df3d8..39e20b55d1 100644
--- a/src/plugins/platforms/windows/qwindowsopengltester.h
+++ b/src/plugins/platforms/windows/qwindowsopengltester.h
@@ -57,10 +57,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 84428c2b1f..b476c9be1d 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.cpp
+++ b/src/plugins/platforms/windows/qwindowsscreen.cpp
@@ -158,7 +158,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<LPARAM>(&result));
return result;
}
@@ -206,7 +206,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<HWND>(window) : GetDesktopWindow();
GetClientRect(hwnd, &r);
if (width < 0) width = r.right - r.left;
@@ -440,7 +440,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 2382be4e3c..3c99e3507e 100644
--- a/src/plugins/platforms/windows/qwindowsservices.cpp
+++ b/src/plugins/platforms/windows/qwindowsservices.cpp
@@ -59,7 +59,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<quintptr>(ShellExecute(0, 0,
+ reinterpret_cast<const wchar_t *>(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)));
@@ -97,7 +100,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<const wchar_t*>(keyName.utf16()), 0, KEY_READ, &handle)) {
DWORD bufferSize = BufferSize;
RegQueryValueEx(handle, L"", 0, 0, reinterpret_cast<unsigned char*>(command), &bufferSize);
RegCloseKey(handle);
@@ -140,7 +143,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<wchar_t *>(const_cast<ushort *>(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 165154345d..8db6895999 100644
--- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp
+++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp
@@ -322,7 +322,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 b0720639e0..4a24d62770 100644
--- a/src/plugins/platforms/windows/qwindowstabletsupport.h
+++ b/src/plugins/platforms/windows/qwindowstabletsupport.h
@@ -129,7 +129,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 5c283a3113..a7f00d5f6d 100644
--- a/src/plugins/platforms/windows/qwindowstheme.cpp
+++ b/src/plugins/platforms/windows/qwindowstheme.cpp
@@ -462,7 +462,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<HICON>(LoadImage(hmod, MAKEINTRESOURCE(resourceId),
+ IMAGE_ICON, int(size.width()), int(size.height()), 0));
if (iconHandle) {
QPixmap iconpixmap = qt_pixmapFromWinHICON(iconHandle);
DestroyIcon(iconHandle);
@@ -592,7 +594,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;
@@ -667,7 +669,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<void **>(&imageList));
if (hr != S_OK)
return result;
HICON hIcon;
@@ -699,7 +702,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
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index c78a2a3105..4c503a2c48 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -1585,7 +1585,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()) {
@@ -2005,7 +2007,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);
diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
index ca19c3dce8..e94433dd4b 100644
--- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
@@ -44,6 +44,7 @@
#include "qtouchdevice.h"
#include <qpa/qwindowsysteminterface.h>
#include <QDebug>
+#include <cmath>
#ifdef XCB_USE_XINPUT2
diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp
index 3983e90205..9409de2406 100644
--- a/src/plugins/platforms/xcb/qxcbdrag.cpp
+++ b/src/plugins/platforms/xcb/qxcbdrag.cpp
@@ -199,6 +199,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);
@@ -328,6 +329,9 @@ void QXcbDrag::move(const QPoint &globalPos)
if (virtualDesktop != current_virtual_desktop) {
setUseCompositing(virtualDesktop->compositingActive());
recreateShapedPixmapWindow(static_cast<QPlatformScreen*>(screen)->screen(), deviceIndependentPos);
+ if (connection()->mouseGrabber() == Q_NULLPTR)
+ shapedPixmapWindow()->setMouseGrabEnabled(true);
+
current_virtual_desktop = virtualDesktop;
} else {
QBasicDrag::moveShapedPixmapWindow(deviceIndependentPos);
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp
index 041a9992bb..339529edf1 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.cpp
+++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
@@ -214,7 +214,10 @@ 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();
+
+ if (m_sizeMillimeters.isEmpty())
+ m_sizeMillimeters = m_virtualSizeMillimeters;
readXResources();
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index 240a1dbc74..939fd5e5b4 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -56,6 +56,7 @@
#include "qxcbsystemtraytracker.h"
#include <qpa/qplatformintegration.h>
+#include <qpa/qplatformcursor.h>
#include <algorithm>
@@ -267,6 +268,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<QWindow *>(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)
@@ -861,6 +882,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)
diff --git a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp
index 4dbbadb847..a21b4d8a65 100644
--- a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp
+++ b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp
@@ -506,8 +506,8 @@ void QGtk3FontDialogHelper::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)
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index 0bc05cc3b5..90473c6642 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -319,6 +319,14 @@ QPointer<QWidget> qt_last_mouse_receiver = 0;
void QWidgetWindow::handleEnterLeaveEvent(QEvent *event)
{
+#if !defined(Q_OS_OSX) && !defined(Q_OS_IOS) // Cocoa tracks popups
+ // Ignore all enter/leave events from QPA if we are not on the first-level context menu.
+ // This prevents duplicated events on most platforms. Fake events will be delivered in
+ // QWidgetWindow::handleMouseEvent(QMouseEvent *). Make an exception whether the widget
+ // is already under mouse - let the mouse leave.
+ if (QApplicationPrivate::inPopupMode() && m_widget != QApplication::activePopupWidget() && !m_widget->underMouse())
+ return;
+#endif
if (event->type() == QEvent::Leave) {
QWidget *enter = 0;
// Check from window system event queue if the next queued enter targets a window
@@ -413,14 +421,13 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
QEvent::MouseButtonRelease : QEvent::MouseButtonPress;
if (qApp->d_func()->inPopupMode()) {
QWidget *activePopupWidget = qApp->activePopupWidget();
- QWidget *popup = activePopupWidget;
QPoint mapped = event->pos();
- if (popup != m_widget)
- mapped = popup->mapFromGlobal(event->globalPos());
+ if (activePopupWidget != m_widget)
+ mapped = activePopupWidget->mapFromGlobal(event->globalPos());
bool releaseAfter = false;
- QWidget *popupChild = popup->childAt(mapped);
+ QWidget *popupChild = activePopupWidget->childAt(mapped);
- if (popup != qt_popup_down) {
+ if (activePopupWidget != qt_popup_down) {
qt_button_down = 0;
qt_popup_down = 0;
}
@@ -429,7 +436,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
case QEvent::MouseButtonPress:
case QEvent::MouseButtonDblClick:
qt_button_down = popupChild;
- qt_popup_down = popup;
+ qt_popup_down = activePopupWidget;
break;
case QEvent::MouseButtonRelease:
releaseAfter = true;
@@ -440,18 +447,41 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
int oldOpenPopupCount = openPopupCount;
- if (popup->isEnabled()) {
+ if (activePopupWidget->isEnabled()) {
// deliver event
qt_replay_popup_mouse_event = false;
- QWidget *receiver = popup;
+ QWidget *receiver = activePopupWidget;
QPoint widgetPos = mapped;
if (qt_button_down)
receiver = qt_button_down;
else if (popupChild)
receiver = popupChild;
- if (receiver != popup)
+ if (receiver != activePopupWidget)
widgetPos = receiver->mapFromGlobal(event->globalPos());
- QWidget *alien = m_widget->childAt(m_widget->mapFromGlobal(event->globalPos()));
+ QWidget *alien = receiver;
+
+#if !defined(Q_OS_OSX) && !defined(Q_OS_IOS) // Cocoa tracks popups
+ const bool reallyUnderMouse = activePopupWidget->rect().contains(mapped);
+ const bool underMouse = activePopupWidget->underMouse();
+ if (activePopupWidget != m_widget || (!underMouse && qt_button_down)) {
+ // If active popup menu is not the first-level popup menu then we must emulate enter/leave events,
+ // because first-level popup menu grabs the mouse and enter/leave events are delivered only to it
+ // by QPA. Make an exception for first-level popup menu when the mouse button is pressed on widget.
+ if (underMouse != reallyUnderMouse) {
+ if (reallyUnderMouse) {
+ QApplicationPrivate::dispatchEnterLeave(receiver, Q_NULLPTR, event->screenPos());
+ qt_last_mouse_receiver = receiver;
+ } else {
+ QApplicationPrivate::dispatchEnterLeave(Q_NULLPTR, qt_last_mouse_receiver, event->screenPos());
+ qt_last_mouse_receiver = receiver;
+ receiver = activePopupWidget;
+ }
+ }
+ } else if (!reallyUnderMouse) {
+ alien = Q_NULLPTR;
+ }
+#endif
+
QMouseEvent e(event->type(), widgetPos, event->windowPos(), event->screenPos(),
event->button(), event->buttons(), event->modifiers(), event->source());
e.setTimestamp(event->timestamp());
@@ -463,7 +493,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
case QEvent::MouseButtonPress:
case QEvent::MouseButtonDblClick:
case QEvent::MouseButtonRelease:
- popup->close();
+ activePopupWidget->close();
break;
default:
break;
@@ -509,7 +539,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
} else if (event->type() == contextMenuTrigger
&& event->button() == Qt::RightButton
&& (openPopupCount == oldOpenPopupCount)) {
- QWidget *popupEvent = popup;
+ QWidget *popupEvent = activePopupWidget;
if (qt_button_down)
popupEvent = qt_button_down;
else if(popupChild)
@@ -727,13 +757,24 @@ void QWidgetWindow::handleWheelEvent(QWheelEvent *event)
if (QApplicationPrivate::instance()->modalState() && !qt_try_modal(m_widget, event->type()))
return;
+ QWidget *rootWidget = m_widget;
+ QPoint pos = event->pos();
+
+ // Use proper popup window for wheel event. Some QPA sends the wheel
+ // event to the root menu, so redirect it to the proper popup window.
+ QWidget *activePopupWidget = QApplication::activePopupWidget();
+ if (activePopupWidget && activePopupWidget != m_widget) {
+ rootWidget = activePopupWidget;
+ pos = rootWidget->mapFromGlobal(event->globalPos());
+ }
+
// which child should have it?
- QWidget *widget = m_widget->childAt(event->pos());
+ QWidget *widget = rootWidget->childAt(pos);
if (!widget)
- widget = m_widget;
+ widget = rootWidget;
- QPoint mapped = widget->mapFrom(m_widget, event->pos());
+ QPoint mapped = widget->mapFrom(rootWidget, pos);
QWheelEvent translated(mapped, event->globalPos(), event->pixelDelta(), event->angleDelta(), event->delta(), event->orientation(), event->buttons(), event->modifiers(), event->phase(), event->source());
QGuiApplication::sendSpontaneousEvent(widget, &translated);
diff --git a/src/widgets/widgets/qmenu_mac.mm b/src/widgets/widgets/qmenu_mac.mm
index c24779d61f..29f5913b5d 100644
--- a/src/widgets/widgets/qmenu_mac.mm
+++ b/src/widgets/widgets/qmenu_mac.mm
@@ -73,8 +73,11 @@ inline QPlatformNativeInterface::NativeResourceForIntegrationFunction resolvePla
\since 5.2
Returns the native NSMenu for this menu. Available on OS X only.
+
+ \note Qt sets the delegate on the native menu. If you need to set your own
+ delegate, make sure you save the original one and forward any calls to it.
*/
-NSMenu* QMenu::toNSMenu()
+NSMenu *QMenu::toNSMenu()
{
// Call into the cocoa platform plugin: qMenuToNSMenu(platformMenu())
QPlatformNativeInterface::NativeResourceForIntegrationFunction function = resolvePlatformFunction("qmenutonsmenu");
@@ -139,8 +142,11 @@ void QMenuPrivate::moveWidgetToPlatformItem(QWidget *widget, QPlatformMenuItem*
\since 5.2
Returns the native NSMenu for this menu bar. Available on OS X only.
+
+ \note Qt may set the delegate on the native menu bar. If you need to set your
+ own delegate, make sure you save the original one and forward any calls to it.
*/
-NSMenu* QMenuBar::toNSMenu()
+NSMenu *QMenuBar::toNSMenu()
{
// Call into the cocoa platform plugin: qMenuBarToNSMenu(platformMenuBar())
QPlatformNativeInterface::NativeResourceForIntegrationFunction function = resolvePlatformFunction("qmenubartonsmenu");