Merge remote-tracking branch 'origin/5.6' into 5.7

Conflicts:
	src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
	src/plugins/platforms/windows/qwindowsfontengine.cpp
	src/plugins/platforms/windows/qwindowsnativeimage.cpp
	tests/auto/gui/kernel/qwindow/BLACKLIST
	tests/auto/gui/kernel/qwindow/tst_qwindow.cpp

Change-Id: I649b32b260ce0ed2d6a5089021daa0d6a8db85f7
This commit is contained in:
Liang Qi 2016-02-24 13:28:17 +01:00
commit 1fadc7292b
62 changed files with 862 additions and 421 deletions

View File

@ -161,3 +161,7 @@ Cpp.ignoredirectives += \
QT_WARNING_DISABLE_MSVC \ QT_WARNING_DISABLE_MSVC \
Q_ATTRIBUTE_FORMAT_PRINTF \ Q_ATTRIBUTE_FORMAT_PRINTF \
Q_MV_IOS Q_MV_IOS
# Qt 6: Remove
falsehoods += \
"QT_VERSION >= QT_VERSION_CHECK\\(6,0,0\\)"

View File

@ -14,6 +14,9 @@ load(qt_build_paths)
TEMPLATE = lib TEMPLATE = lib
CONFIG -= qt CONFIG -= qt
CONFIG -= warning_clean # Don't presume 3rd party code to be clean
load(qt_common)
contains(QT_CONFIG, debug_and_release): CONFIG += debug_and_release contains(QT_CONFIG, debug_and_release): CONFIG += debug_and_release
contains(QT_CONFIG, build_all): CONFIG += build_all contains(QT_CONFIG, build_all): CONFIG += build_all

View File

@ -116,7 +116,6 @@ lib_bundle {
QMAKE_BUNDLE_EXTENSION = .framework QMAKE_BUNDLE_EXTENSION = .framework
QMAKE_INFO_PLIST = $$QMAKESPEC/Info.plist.lib QMAKE_INFO_PLIST = $$QMAKESPEC/Info.plist.lib
} }
CONFIG -= qt_install_headers #no need to install these as well
!debug_and_release|!build_all|CONFIG(release, debug|release) { !debug_and_release|!build_all|CONFIG(release, debug|release) {
FRAMEWORK_HEADERS.version = Versions FRAMEWORK_HEADERS.version = Versions
FRAMEWORK_HEADERS.files = $$SYNCQT.HEADER_FILES $$SYNCQT.HEADER_CLASSES FRAMEWORK_HEADERS.files = $$SYNCQT.HEADER_FILES $$SYNCQT.HEADER_CLASSES

View File

@ -99,6 +99,7 @@ git_build: \
else: \ else: \
INC_PATH = $$MODULE_BASE_INDIR INC_PATH = $$MODULE_BASE_INDIR
include($$INC_PATH/include/$$MODULE_INCNAME/headers.pri, "", true) include($$INC_PATH/include/$$MODULE_INCNAME/headers.pri, "", true)
!lib_bundle: \ # Headers are embedded into the bundle, so don't install them separately.
CONFIG += qt_install_headers CONFIG += qt_install_headers
alien_syncqt: return() alien_syncqt: return()

View File

@ -31,6 +31,7 @@ QMAKE_CFLAGS_DEPS = -M
QMAKE_CFLAGS_WARN_ON = -Wall -Wextra QMAKE_CFLAGS_WARN_ON = -Wall -Wextra
QMAKE_CFLAGS_WARN_OFF = -w QMAKE_CFLAGS_WARN_OFF = -w
QMAKE_CFLAGS_RELEASE = -O2 QMAKE_CFLAGS_RELEASE = -O2
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO = -O2 -g
QMAKE_CFLAGS_DEBUG = -g QMAKE_CFLAGS_DEBUG = -g
QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses
QMAKE_CFLAGS_SPLIT_SECTIONS = -ffunction-sections QMAKE_CFLAGS_SPLIT_SECTIONS = -ffunction-sections

View File

@ -98,19 +98,6 @@ struct ProjectBuilderSubDirs {
bool bool
ProjectBuilderMakefileGenerator::writeSubDirs(QTextStream &t) ProjectBuilderMakefileGenerator::writeSubDirs(QTextStream &t)
{ {
if(project->isActiveConfig("generate_pbxbuild_makefile")) {
QString mkwrap = fileFixify(pbx_dir + Option::dir_sep + ".." + Option::dir_sep + project->first("MAKEFILE"),
FileFixifyToIndir);
QFile mkwrapf(mkwrap);
if(mkwrapf.open(QIODevice::WriteOnly | QIODevice::Text)) {
debug_msg(1, "pbuilder: Creating file: %s", mkwrap.toLatin1().constData());
QTextStream mkwrapt(&mkwrapf);
writingUnixMakefileGenerator = true;
UnixMakefileGenerator::writeSubDirs(mkwrapt);
writingUnixMakefileGenerator = false;
}
}
//HEADER //HEADER
const int pbVersion = pbuilderVersion(); const int pbVersion = pbuilderVersion();
t << "// !$*UTF8*$!\n" t << "// !$*UTF8*$!\n"
@ -1664,32 +1651,6 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
<< "\t" << writeSettings("rootObject", keyFor("QMAKE_PBX_ROOT")) << ";\n" << "\t" << writeSettings("rootObject", keyFor("QMAKE_PBX_ROOT")) << ";\n"
<< "}\n"; << "}\n";
if(project->isActiveConfig("generate_pbxbuild_makefile")) {
QString mkwrap = Option::output_dir + project->first("/MAKEFILE");
QFile mkwrapf(mkwrap);
if(mkwrapf.open(QIODevice::WriteOnly | QIODevice::Text)) {
writingUnixMakefileGenerator = true;
debug_msg(1, "pbuilder: Creating file: %s", mkwrap.toLatin1().constData());
QTextStream mkwrapt(&mkwrapf);
writeHeader(mkwrapt);
const char cleans[] = "preprocess_clean ";
const QString cmd = escapeFilePath(project->first("QMAKE_ORIG_TARGET") + projectSuffix() + "/") + " && " + pbxbuild();
mkwrapt << "#This is a makefile wrapper for PROJECT BUILDER\n"
<< "all:\n\t"
<< "cd " << cmd << "\n"
<< "install: all\n\t"
<< "cd " << cmd << " install\n"
<< "distclean clean: preprocess_clean\n\t"
<< "cd " << cmd << " clean\n"
<< (!did_preprocess ? cleans : "") << ":\n";
if(did_preprocess)
mkwrapt << cleans << ":\n\t"
<< "make -f "
<< pbx_dir << Option::dir_sep << "qt_preprocess.mak $@\n";
writingUnixMakefileGenerator = false;
}
}
// Scheme // Scheme
{ {
QString xcodeSpecDir = project->first("QMAKE_XCODE_SPECDIR").toQString(); QString xcodeSpecDir = project->first("QMAKE_XCODE_SPECDIR").toQString();

View File

@ -101,6 +101,7 @@ public class QtActivityDelegate
private Method m_super_onConfigurationChanged = null; private Method m_super_onConfigurationChanged = null;
private Method m_super_onActivityResult = null; private Method m_super_onActivityResult = null;
private Method m_super_dispatchGenericMotionEvent = 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 NATIVE_LIBRARIES_KEY = "native.libraries";
private static final String BUNDLED_LIBRARIES_KEY = "bundled.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_onKeyUp = m_activity.getClass().getMethod("super_onKeyUp", Integer.TYPE, KeyEvent.class);
m_super_onConfigurationChanged = m_activity.getClass().getMethod("super_onConfigurationChanged", Configuration.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_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); m_super_dispatchGenericMotionEvent = m_activity.getClass().getMethod("super_dispatchGenericMotionEvent", MotionEvent.class);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -917,6 +919,16 @@ public class QtActivityDelegate
new QtAccessibilityDelegate(m_activity, m_layout, this); 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) public void onConfigurationChanged(Configuration configuration)
{ {
try { try {

View File

@ -151,7 +151,7 @@ template <typename X> struct QAtomicOps
static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; } static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; }
template <typename T> 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); bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_relaxed);
if (currentValue) if (currentValue)
@ -160,7 +160,7 @@ template <typename X> struct QAtomicOps
} }
template <typename T> 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); bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_acquire);
if (currentValue) if (currentValue)
@ -169,7 +169,7 @@ template <typename X> struct QAtomicOps
} }
template <typename T> 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); bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_release);
if (currentValue) if (currentValue)
@ -178,7 +178,7 @@ template <typename X> struct QAtomicOps
} }
template <typename T> 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); bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_acq_rel);
if (currentValue) if (currentValue)

View File

@ -588,7 +588,8 @@ void QCoreApplicationPrivate::initLocale()
This class is used by non-GUI applications to provide their event This class is used by non-GUI applications to provide their event
loop. For non-GUI application that uses Qt, there should be exactly loop. For non-GUI application that uses Qt, there should be exactly
one QCoreApplication object. For GUI applications, see 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 QCoreApplication contains the main event loop, where all events
from the operating system (e.g., timer and network events) and 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 operations can call processEvents() to keep the application
responsive. responsive.
In general, we recommend that you create a QCoreApplication or a In general, we recommend that you create a QCoreApplication,
QApplication object in your \c main() function as early as QGuiApplication or a QApplication object in your \c main()
possible. exec() will not return until the event loop exits; e.g., function as early as possible. exec() will not return until
when quit() is called. the event loop exits; e.g., when quit() is called.
Several static convenience functions are also provided. The Several static convenience functions are also provided. The
QCoreApplication object is available from instance(). Events can 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 instance, when converting between data types such as floats and
strings, since the notation may differ between locales. To get strings, since the notation may differ between locales. To get
around this problem, call the POSIX function \c{setlocale(LC_NUMERIC,"C")} around this problem, call the POSIX function \c{setlocale(LC_NUMERIC,"C")}
right after initializing QApplication or QCoreApplication to reset right after initializing QApplication, QGuiApplication or QCoreApplication
the locale that is used for number formatting to "C"-locale. to reset the locale that is used for number formatting to "C"-locale.
\sa QGuiApplication, QAbstractEventDispatcher, QEventLoop, \sa QGuiApplication, QAbstractEventDispatcher, QEventLoop,
{Semaphores Example}, {Wait Conditions Example} {Semaphores Example}, {Wait Conditions Example}
@ -658,7 +659,7 @@ void QCoreApplicationPrivate::initLocale()
\fn static QCoreApplication *QCoreApplication::instance() \fn static QCoreApplication *QCoreApplication::instance()
Returns a pointer to the application's QCoreApplication (or Returns a pointer to the application's QCoreApplication (or
QApplication) instance. QGuiApplication/QApplication) instance.
If no instance has been allocated, \c null is returned. 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 Installing or removing a QTranslator, or changing an installed QTranslator
generates a \l{QEvent::LanguageChange}{LanguageChange} event for the 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 to all toplevel windows, where a reimplementation of changeEvent can
re-translate the user interface by passing user-visible strings via the re-translate the user interface by passing user-visible strings via the
tr() function to the respective property setters. User-interface classes tr() function to the respective property setters. User-interface classes

View File

@ -144,7 +144,7 @@ public:
QImage(const QImage &); QImage(const QImage &);
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
inline QImage(QImage &&other) Q_DECL_NOEXCEPT inline QImage(QImage &&other) Q_DECL_NOEXCEPT
: QPaintDevice(), d(0) : QPaintDevice(), d(Q_NULLPTR)
{ qSwap(d, other.d); } { qSwap(d, other.d); }
#endif #endif
~QImage(); ~QImage();

View File

@ -800,7 +800,7 @@ public:
TouchPoint(const TouchPoint &other); TouchPoint(const TouchPoint &other);
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
TouchPoint(TouchPoint &&other) Q_DECL_NOEXCEPT TouchPoint(TouchPoint &&other) Q_DECL_NOEXCEPT
: d(0) : d(Q_NULLPTR)
{ qSwap(d, other.d); } { qSwap(d, other.d); }
TouchPoint &operator=(TouchPoint &&other) Q_DECL_NOEXCEPT TouchPoint &operator=(TouchPoint &&other) Q_DECL_NOEXCEPT
{ qSwap(d, other.d); return *this; } { qSwap(d, other.d); return *this; }

View File

@ -94,7 +94,8 @@ static QWindow* topLevelAt(const QPoint &pos)
QBasicDrag::QBasicDrag() : QBasicDrag::QBasicDrag() :
m_restoreCursor(false), m_eventLoop(0), m_restoreCursor(false), m_eventLoop(0),
m_executed_drop_action(Qt::IgnoreAction), m_can_drop(false), 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(); pos = QPoint();
} }
#endif #endif
recreateShapedPixmapWindow(Q_NULLPTR, pos); recreateShapedPixmapWindow(m_screen, pos);
enableEventFilter(); enableEventFilter();
} }

View File

@ -97,6 +97,8 @@ protected:
bool useCompositing() const { return m_useCompositing; } bool useCompositing() const { return m_useCompositing; }
void setUseCompositing(bool on) { m_useCompositing = on; } void setUseCompositing(bool on) { m_useCompositing = on; }
void setScreen(QScreen *screen) { m_screen = screen; }
Qt::DropAction executedDropAction() const { return m_executed_drop_action; } Qt::DropAction executedDropAction() const { return m_executed_drop_action; }
void setExecutedDropAction(Qt::DropAction da) { m_executed_drop_action = da; } void setExecutedDropAction(Qt::DropAction da) { m_executed_drop_action = da; }
@ -115,6 +117,7 @@ private:
QDrag *m_drag; QDrag *m_drag;
QShapedPixmapWindow *m_drag_icon_window; QShapedPixmapWindow *m_drag_icon_window;
bool m_useCompositing; bool m_useCompositing;
QScreen *m_screen;
}; };
class Q_GUI_EXPORT QSimpleDrag : public QBasicDrag class Q_GUI_EXPORT QSimpleDrag : public QBasicDrag

View File

@ -410,7 +410,7 @@ public:
void glVertexBindingDivisor(GLuint bindingindex, GLuint divisor); void glVertexBindingDivisor(GLuint bindingindex, GLuint divisor);
private: private:
static bool isInitialized(const QOpenGLExtraFunctionsPrivate *d) { return d != 0; } static bool isInitialized(const QOpenGLExtraFunctionsPrivate *d) { return d != Q_NULLPTR; }
}; };
class QOpenGLExtraFunctionsPrivate : public QOpenGLFunctionsPrivate class QOpenGLExtraFunctionsPrivate : public QOpenGLFunctionsPrivate

View File

@ -3390,7 +3390,7 @@ QVector<float> QOpenGLShaderProgram::defaultInnerTessellationLevels() const
#if defined(QT_OPENGL_4) #if defined(QT_OPENGL_4)
Q_D(const QOpenGLShaderProgram); Q_D(const QOpenGLShaderProgram);
if (d->tessellationFuncs) if (d->tessellationFuncs)
d->tessellationFuncs->glGetFloatv(GL_PATCH_DEFAULT_OUTER_LEVEL, tessLevels.data()); d->tessellationFuncs->glGetFloatv(GL_PATCH_DEFAULT_INNER_LEVEL, tessLevels.data());
#endif #endif
return tessLevels; return tessLevels;
} }

View File

@ -689,6 +689,7 @@ void QRasterPaintEngine::penChanged()
qDebug() << "QRasterPaintEngine::penChanged():" << state()->pen; qDebug() << "QRasterPaintEngine::penChanged():" << state()->pen;
#endif #endif
QRasterPaintEngineState *s = state(); QRasterPaintEngineState *s = state();
Q_ASSERT(s);
s->strokeFlags |= DirtyPen; s->strokeFlags |= DirtyPen;
s->dirty |= DirtyPen; s->dirty |= DirtyPen;
} }
@ -2200,6 +2201,7 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe
Q_D(QRasterPaintEngine); Q_D(QRasterPaintEngine);
QRasterPaintEngineState *s = state(); QRasterPaintEngineState *s = state();
Q_ASSERT(s);
int sr_l = qFloor(sr.left()); int sr_l = qFloor(sr.left());
int sr_r = qCeil(sr.right()) - 1; int sr_r = qCeil(sr.right()) - 1;
int sr_t = qFloor(sr.top()); int sr_t = qFloor(sr.top());
@ -2437,6 +2439,7 @@ void QRasterPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap,
#endif #endif
Q_D(QRasterPaintEngine); Q_D(QRasterPaintEngine);
QRasterPaintEngineState *s = state(); QRasterPaintEngineState *s = state();
Q_ASSERT(s);
QImage image; QImage image;

View File

@ -71,7 +71,7 @@ public:
QPen &operator=(const QPen &pen) Q_DECL_NOTHROW; QPen &operator=(const QPen &pen) Q_DECL_NOTHROW;
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
QPen(QPen &&other) Q_DECL_NOTHROW 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 QPen &operator=(QPen &&other) Q_DECL_NOTHROW
{ qSwap(d, other.d); return *this; } { qSwap(d, other.d); return *this; }
#endif #endif

View File

@ -1725,8 +1725,8 @@ static inline QImage alphaMapFromGlyphData(QFontEngineFT::Glyph *glyph, QFontEng
if (glyph == Q_NULLPTR) if (glyph == Q_NULLPTR)
return QImage(); return QImage();
QImage::Format format; QImage::Format format = QImage::Format_Invalid;
int bytesPerLine; int bytesPerLine = -1;
switch (glyphFormat) { switch (glyphFormat) {
case QFontEngine::Format_Mono: case QFontEngine::Format_Mono:
format = QImage::Format_Mono; format = QImage::Format_Mono;

View File

@ -1065,7 +1065,7 @@ void QTextEngine::shapeText(int item) const
#ifdef QT_ENABLE_HARFBUZZ_NG #ifdef QT_ENABLE_HARFBUZZ_NG
if (Q_LIKELY(qt_useHarfbuzzNG())) 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 else
#endif #endif
si.num_glyphs = shapeTextWithHarfbuzz(si, string, itemLength, fontEngine, itemBoundaries, kerningEnabled); si.num_glyphs = shapeTextWithHarfbuzz(si, string, itemLength, fontEngine, itemBoundaries, kerningEnabled);
@ -1127,7 +1127,13 @@ QT_BEGIN_INCLUDE_NAMESPACE
QT_END_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; 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; hb_segment_properties_t props = HB_SEGMENT_PROPERTIES_DEFAULT;
props.direction = si.analysis.bidiLevel % 2 ? HB_DIRECTION_RTL : HB_DIRECTION_LTR; 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); // ### props.language = hb_language_get_default_for_script(props.script);
for (int k = 0; k < itemBoundaries.size(); k += 3) { 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); Q_ASSERT(hb_font);
hb_qt_font_set_use_design_metrics(hb_font, option.useDesignMetrics() ? uint(QFontEngine::DesignMetrics) : 0); // ### hb_qt_font_set_use_design_metrics(hb_font, option.useDesignMetrics() ? uint(QFontEngine::DesignMetrics) : 0); // ###
const hb_feature_t features[1] = { // Ligatures are incompatible with custom letter spacing, so when a letter spacing is set,
{ HB_TAG('k','e','r','n'), !!kerningEnabled, 0, uint(-1) } // we disable them for writing systems where they are purely cosmetic.
}; bool scriptRequiresOpenType = ((script >= QChar::Script_Syriac && script <= QChar::Script_Sinhala)
const int num_features = 1; || 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; const char *const *shaper_list = Q_NULLPTR;
#if defined(Q_OS_DARWIN) #if defined(Q_OS_DARWIN)

View File

@ -649,7 +649,13 @@ private:
void addRequiredBoundaries() const; void addRequiredBoundaries() const;
void shapeText(int item) const; void shapeText(int item) const;
#ifdef QT_ENABLE_HARFBUZZ_NG #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 #endif
int shapeTextWithHarfbuzz(const QScriptItem &si, const ushort *string, int itemLength, QFontEngine *fontEngine, const QVector<uint> &itemBoundaries, bool kerningEnabled) const; int shapeTextWithHarfbuzz(const QScriptItem &si, const ushort *string, int itemLength, QFontEngine *fontEngine, const QVector<uint> &itemBoundaries, bool kerningEnabled) const;

View File

@ -2147,6 +2147,7 @@ static QGlyphRun glyphRunWithInfo(QFontEngine *fontEngine,
QGlyphRunPrivate *d = QGlyphRunPrivate::get(glyphRun); QGlyphRunPrivate *d = QGlyphRunPrivate::get(glyphRun);
int rangeStart = textPosition; int rangeStart = textPosition;
logClusters += textPosition;
while (*logClusters != glyphsStart && rangeStart < textPosition + textLength) { while (*logClusters != glyphsStart && rangeStart < textPosition + textLength) {
++logClusters; ++logClusters;
++rangeStart; ++rangeStart;
@ -2331,16 +2332,16 @@ QList<QGlyphRun> QTextLine::glyphRuns(int from, int length) const
if (mainFontEngine->type() == QFontEngine::Multi) { if (mainFontEngine->type() == QFontEngine::Multi) {
QFontEngineMulti *multiFontEngine = static_cast<QFontEngineMulti *>(mainFontEngine); QFontEngineMulti *multiFontEngine = static_cast<QFontEngineMulti *>(mainFontEngine);
int end = rtl ? glyphLayout.numGlyphs : 0; int start = rtl ? glyphLayout.numGlyphs : 0;
int start = rtl ? end : 0; int end = start - 1;
int which = glyphLayout.glyphs[rtl ? start - 1 : end] >> 24; int which = glyphLayout.glyphs[rtl ? start - 1 : end + 1] >> 24;
for (; (rtl && start > 0) || (!rtl && end < glyphLayout.numGlyphs); for (; (rtl && start > 0) || (!rtl && end < glyphLayout.numGlyphs - 1);
rtl ? --start : ++end) { 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) if (e == which)
continue; continue;
QGlyphLayout subLayout = glyphLayout.mid(start, end - start); QGlyphLayout subLayout = glyphLayout.mid(start, end - start + 1);
multiFontEngine->ensureEngineAt(which); multiFontEngine->ensureEngineAt(which);
QGlyphRun::GlyphRunFlags subFlags = flags; QGlyphRun::GlyphRunFlags subFlags = flags;
@ -2364,13 +2365,13 @@ QList<QGlyphRun> QTextLine::glyphRuns(int from, int length) const
} }
if (rtl) if (rtl)
end = start; end = start - 1;
else else
start = end; start = end + 1;
which = e; which = e;
} }
QGlyphLayout subLayout = glyphLayout.mid(start, end - start); QGlyphLayout subLayout = glyphLayout.mid(start, end - start + 1);
multiFontEngine->ensureEngineAt(which); multiFontEngine->ensureEngineAt(which);
QGlyphRun::GlyphRunFlags subFlags = flags; QGlyphRun::GlyphRunFlags subFlags = flags;

View File

@ -46,17 +46,10 @@
//#define QT_COCOA_ENABLE_MENU_DEBUG //#define QT_COCOA_ENABLE_MENU_DEBUG
#ifdef __OBJC__ Q_FORWARD_DECLARE_OBJC_CLASS(NSMenuItem);
#define QT_FORWARD_DECLARE_OBJC_CLASS(__KLASS__) @class __KLASS__ Q_FORWARD_DECLARE_OBJC_CLASS(NSMenu);
#else Q_FORWARD_DECLARE_OBJC_CLASS(NSObject);
#define QT_FORWARD_DECLARE_OBJC_CLASS(__KLASS__) typedef struct objc_object __KLASS__ Q_FORWARD_DECLARE_OBJC_CLASS(NSView);
#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);
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE

View File

@ -100,7 +100,7 @@ void QWindowsBackingStore::flush(QWindow *window, const QRegion &region,
SIZE size = {r.width(), r.height()}; SIZE size = {r.width(), r.height()};
POINT ptDst = {r.x(), r.y()}; POINT ptDst = {r.x(), r.y()};
POINT ptSrc = {0, 0}; 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) { if (QWindowsContext::user32dll.updateLayeredWindowIndirect) {
RECT dirty = {dirtyRect.x(), dirtyRect.y(), RECT dirty = {dirtyRect.x(), dirtyRect.y(),
dirtyRect.x() + dirtyRect.width(), dirtyRect.y() + dirtyRect.height()}; 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)) { 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. const DWORD lastError = GetLastError(); // QTBUG-35926, QTBUG-29716: may fail after lock screen.
if (lastError != ERROR_SUCCESS && lastError != ERROR_INVALID_HANDLE) if (lastError != ERROR_SUCCESS && lastError != ERROR_INVALID_HANDLE)
qErrnoWarning(lastError, "%s: BitBlt failed", __FUNCTION__); qErrnoWarning(int(lastError), "%s: BitBlt failed", __FUNCTION__);
} }
rw->releaseDC(); rw->releaseDC();
#ifndef Q_OS_WINCE #ifndef Q_OS_WINCE

View File

@ -265,9 +265,9 @@ bool QWindowsClipboard::clipboardViewerWndProc(HWND hwnd, UINT message, WPARAM w
switch (message) { switch (message) {
case WM_CHANGECBCHAIN: { case WM_CHANGECBCHAIN: {
const HWND toBeRemoved = (HWND)wParam; const HWND toBeRemoved = reinterpret_cast<HWND>(wParam);
if (toBeRemoved == m_nextClipboardViewer) { if (toBeRemoved == m_nextClipboardViewer) {
m_nextClipboardViewer = (HWND)lParam; m_nextClipboardViewer = reinterpret_cast<HWND>(lParam);
} else { } else {
propagateClipboardMessage(message, wParam, lParam); propagateClipboardMessage(message, wParam, lParam);
} }

View File

@ -107,10 +107,10 @@ static inline bool useRTL_Extensions(QSysInfo::WinVersion ver)
if ((ver & QSysInfo::WV_NT_based) && (ver >= QSysInfo::WV_VISTA)) { if ((ver & QSysInfo::WV_NT_based) && (ver >= QSysInfo::WV_VISTA)) {
// Since the IsValidLanguageGroup/IsValidLocale functions always return true on // Since the IsValidLanguageGroup/IsValidLocale functions always return true on
// Vista, check the Keyboard Layouts for enabling RTL. // 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]); QScopedArrayPointer<HKL> lpList(new HKL[nLayouts]);
GetKeyboardLayoutList(nLayouts, lpList.data()); GetKeyboardLayoutList(nLayouts, lpList.data());
for (UINT i = 0; i < nLayouts; ++i) { for (int i = 0; i < nLayouts; ++i) {
switch (PRIMARYLANGID((quintptr)lpList[i])) { switch (PRIMARYLANGID((quintptr)lpList[i])) {
case LANG_ARABIC: case LANG_ARABIC:
case LANG_HEBREW: case LANG_HEBREW:
@ -546,15 +546,15 @@ QString QWindowsContext::registerWindowClass(QString cname,
// add an instance-specific ID, the address of the window proc. // add an instance-specific ID, the address of the window proc.
static int classExists = -1; static int classExists = -1;
const HINSTANCE appInstance = (HINSTANCE)GetModuleHandle(0); const HINSTANCE appInstance = static_cast<HINSTANCE>(GetModuleHandle(0));
if (classExists == -1) { if (classExists == -1) {
WNDCLASS wcinfo; WNDCLASS wcinfo;
classExists = GetClassInfo(appInstance, (wchar_t*)cname.utf16(), &wcinfo); classExists = GetClassInfo(appInstance, reinterpret_cast<LPCWSTR>(cname.utf16()), &wcinfo);
classExists = classExists && wcinfo.lpfnWndProc != proc; classExists = classExists && wcinfo.lpfnWndProc != proc;
} }
if (classExists) 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 if (d->m_registeredWindowClassNames.contains(cname)) // already registered in our list
return cname; return cname;
@ -574,13 +574,13 @@ QString QWindowsContext::registerWindowClass(QString cname,
#ifndef Q_OS_WINCE #ifndef Q_OS_WINCE
wc.hbrBackground = brush; wc.hbrBackground = brush;
if (icon) { 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) { if (wc.hIcon) {
int sw = GetSystemMetrics(SM_CXSMICON); int sw = GetSystemMetrics(SM_CXSMICON);
int sh = GetSystemMetrics(SM_CYSMICON); 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 { } 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; wc.hIconSm = 0;
} }
} else { } else {
@ -596,7 +596,7 @@ QString QWindowsContext::registerWindowClass(QString cname,
#endif #endif
wc.lpszMenuName = 0; wc.lpszMenuName = 0;
wc.lpszClassName = (wchar_t*)cname.utf16(); wc.lpszClassName = reinterpret_cast<LPCWSTR>(cname.utf16());
#ifndef Q_OS_WINCE #ifndef Q_OS_WINCE
ATOM atom = RegisterClassEx(&wc); ATOM atom = RegisterClassEx(&wc);
#else #else
@ -616,10 +616,10 @@ QString QWindowsContext::registerWindowClass(QString cname,
void QWindowsContext::unregisterWindowClasses() void QWindowsContext::unregisterWindowClasses()
{ {
const HINSTANCE appInstance = (HINSTANCE)GetModuleHandle(0); const HINSTANCE appInstance = static_cast<HINSTANCE>(GetModuleHandle(0));
foreach (const QString &name, d->m_registeredWindowClassNames) { 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)); qErrnoWarning("UnregisterClass failed for '%s'", qPrintable(name));
} }
d->m_registeredWindowClassNames.clear(); d->m_registeredWindowClassNames.clear();
@ -635,11 +635,11 @@ QString QWindowsContext::windowsErrorMessage(unsigned long errorCode)
QString rc = QString::fromLatin1("#%1: ").arg(errorCode); QString rc = QString::fromLatin1("#%1: ").arg(errorCode);
ushort *lpMsgBuf; ushort *lpMsgBuf;
const int len = FormatMessage( const DWORD len = FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 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) { if (len) {
rc = QString::fromUtf16(lpMsgBuf, len); rc = QString::fromUtf16(lpMsgBuf, int(len));
LocalFree(lpMsgBuf); LocalFree(lpMsgBuf);
} else { } else {
rc += QString::fromLatin1("<unknown error>"); rc += QString::fromLatin1("<unknown error>");
@ -803,11 +803,11 @@ HWND QWindowsContext::createDummyWindow(const QString &classNameIn,
if (!wndProc) if (!wndProc)
wndProc = DefWindowProc; wndProc = DefWindowProc;
QString className = registerWindowClass(classNameIn, wndProc); QString className = registerWindowClass(classNameIn, wndProc);
return CreateWindowEx(0, (wchar_t*)className.utf16(), return CreateWindowEx(0, reinterpret_cast<LPCWSTR>(className.utf16()),
windowName, style, windowName, style,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
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 #ifndef Q_OS_WINCE
@ -818,11 +818,11 @@ static inline QString errorMessageFromComError(const _com_error &comError)
{ {
TCHAR *message = Q_NULLPTR; TCHAR *message = Q_NULLPTR;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, 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); message, 0, NULL);
if (message) { if (message) {
const QString result = QString::fromWCharArray(message).trimmed(); const QString result = QString::fromWCharArray(message).trimmed();
LocalFree((HLOCAL)message); LocalFree(static_cast<HLOCAL>(message));
return result; return result;
} }
if (const WORD wCode = comError.WCode()) if (const WORD wCode = comError.WCode())
@ -1070,7 +1070,7 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
platformWindow->handleMoved(); platformWindow->handleMoved();
return true; return true;
case QtWindows::ResizeEvent: case QtWindows::ResizeEvent:
platformWindow->handleResized((int)wParam); platformWindow->handleResized(static_cast<int>(wParam));
return true; return true;
#ifndef Q_OS_WINCE // maybe available on some SDKs revisit WM_GETMINMAXINFO #ifndef Q_OS_WINCE // maybe available on some SDKs revisit WM_GETMINMAXINFO
case QtWindows::QuerySizeHints: case QtWindows::QuerySizeHints:
@ -1212,7 +1212,7 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
sessionManager->setActive(false); sessionManager->setActive(false);
sessionManager->allowsInteraction(); sessionManager->allowsInteraction();
bool endsession = (bool) wParam; const bool endsession = wParam != 0;
// we receive the message for each toplevel window included internal hidden ones, // we receive the message for each toplevel window included internal hidden ones,
// but the aboutToQuit signal should be emitted only once. // but the aboutToQuit signal should be emitted only once.
@ -1279,7 +1279,7 @@ bool QWindowsContext::handleContextMenuEvent(QWindow *window, const MSG &msg)
bool mouseTriggered = false; bool mouseTriggered = false;
QPoint globalPos; QPoint globalPos;
QPoint pos; QPoint pos;
if (msg.lParam != (int)0xffffffff) { if (msg.lParam != int(0xffffffff)) {
mouseTriggered = true; mouseTriggered = true;
globalPos.setX(msg.pt.x); globalPos.setX(msg.pt.x);
globalPos.setY(msg.pt.y); globalPos.setY(msg.pt.y);
@ -1287,8 +1287,8 @@ bool QWindowsContext::handleContextMenuEvent(QWindow *window, const MSG &msg)
RECT clientRect; RECT clientRect;
if (GetClientRect(msg.hwnd, &clientRect)) { if (GetClientRect(msg.hwnd, &clientRect)) {
if (pos.x() < (int)clientRect.left || pos.x() >= (int)clientRect.right || if (pos.x() < clientRect.left || pos.x() >= clientRect.right ||
pos.y() < (int)clientRect.top || pos.y() >= (int)clientRect.bottom) pos.y() < clientRect.top || pos.y() >= clientRect.bottom)
{ {
// This is the case that user has right clicked in the window's caption, // This is the case that user has right clicked in the window's caption,
// We should call DefWindowProc() to display a default shortcut menu // We should call DefWindowProc() to display a default shortcut menu

View File

@ -119,8 +119,8 @@ HCURSOR QWindowsCursor::createPixmapCursor(QPixmap pixmap, const QPoint &hotSpot
ICONINFO ii; ICONINFO ii;
ii.fIcon = 0; ii.fIcon = 0;
ii.xHotspot = hotSpot.x(); ii.xHotspot = DWORD(hotSpot.x());
ii.yHotspot = hotSpot.y(); ii.yHotspot = DWORD(hotSpot.y());
ii.hbmMask = im; ii.hbmMask = im;
ii.hbmColor = ic; ii.hbmColor = ic;
@ -577,7 +577,7 @@ HCURSOR QWindowsCursor::createCursorFromShape(Qt::CursorShape cursorShape, const
for (const QWindowsStandardCursorMapping *s = standardCursors; s < sEnd; ++s) { for (const QWindowsStandardCursorMapping *s = standardCursors; s < sEnd; ++s) {
if (s->shape == cursorShape) { if (s->shape == cursorShape) {
#ifndef Q_OS_WINCE #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 #else
return LoadCursor(0, s->resource); return LoadCursor(0, s->resource);
#endif #endif

View File

@ -645,7 +645,7 @@ QWindowsOleDropTarget::Drop(LPDATAOBJECT pDataObj, DWORD grfKeyState,
m_chosenEffect = DROPEFFECT_COPY; m_chosenEffect = DROPEFFECT_COPY;
HGLOBAL hData = GlobalAlloc(0, sizeof(DWORD)); HGLOBAL hData = GlobalAlloc(0, sizeof(DWORD));
if (hData) { if (hData) {
DWORD *moveEffect = (DWORD *)GlobalLock(hData);; DWORD *moveEffect = reinterpret_cast<DWORD *>(GlobalLock(hData));
*moveEffect = DROPEFFECT_MOVE; *moveEffect = DROPEFFECT_MOVE;
GlobalUnlock(hData); GlobalUnlock(hData);
STGMEDIUM medium; STGMEDIUM medium;
@ -653,7 +653,7 @@ QWindowsOleDropTarget::Drop(LPDATAOBJECT pDataObj, DWORD grfKeyState,
medium.tymed = TYMED_HGLOBAL; medium.tymed = TYMED_HGLOBAL;
medium.hGlobal = hData; medium.hGlobal = hData;
FORMATETC format; FORMATETC format;
format.cfFormat = RegisterClipboardFormat(CFSTR_PERFORMEDDROPEFFECT); format.cfFormat = CLIPFORMAT(RegisterClipboardFormat(CFSTR_PERFORMEDDROPEFFECT));
format.tymed = TYMED_HGLOBAL; format.tymed = TYMED_HGLOBAL;
format.ptd = 0; format.ptd = 0;
format.dwAspect = 1; format.dwAspect = 1;

View File

@ -193,9 +193,9 @@ bool QWindowsLibGLESv2::init()
qCDebug(lcQpaGl) << "Qt: Using OpenGL ES 2.0 from" << dllName; qCDebug(lcQpaGl) << "Qt: Using OpenGL ES 2.0 from" << dllName;
#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC) #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) { if (!m_lib) {
qErrnoWarning(::GetLastError(), "Failed to load %s", dllName); qErrnoWarning(int(GetLastError()), "Failed to load %s", dllName);
return false; return false;
} }
#endif // !QT_STATIC #endif // !QT_STATIC
@ -401,7 +401,7 @@ QWindowsEGLStaticContext *QWindowsEGLStaticContext::create(QWindowsOpenGLTester:
Q_UNUSED(preferredType) Q_UNUSED(preferredType)
#endif #endif
if (display == EGL_NO_DISPLAY) if (display == EGL_NO_DISPLAY)
display = libEGL.eglGetDisplay((EGLNativeDisplayType)dc); display = libEGL.eglGetDisplay(dc);
if (!display) { if (!display) {
qWarning("%s: Could not obtain EGL display", __FUNCTION__); qWarning("%s: Could not obtain EGL display", __FUNCTION__);
return 0; return 0;
@ -433,8 +433,8 @@ QWindowsOpenGLContext *QWindowsEGLStaticContext::createContext(QOpenGLContext *c
void *QWindowsEGLStaticContext::createWindowSurface(void *nativeWindow, void *nativeConfig, int *err) void *QWindowsEGLStaticContext::createWindowSurface(void *nativeWindow, void *nativeConfig, int *err)
{ {
*err = 0; *err = 0;
EGLSurface surface = libEGL.eglCreateWindowSurface(m_display, (EGLConfig) nativeConfig, EGLSurface surface = libEGL.eglCreateWindowSurface(m_display, nativeConfig,
(EGLNativeWindowType) nativeWindow, 0); static_cast<EGLNativeWindowType>(nativeWindow), 0);
if (surface == EGL_NO_SURFACE) { if (surface == EGL_NO_SURFACE) {
*err = libEGL.eglGetError(); *err = libEGL.eglGetError();
qWarning("%s: Could not create the EGL window surface: 0x%x", __FUNCTION__, *err); 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) void QWindowsEGLStaticContext::destroyWindowSurface(void *nativeSurface)
{ {
libEGL.eglDestroySurface(m_display, (EGLSurface) nativeSurface); libEGL.eglDestroySurface(m_display, nativeSurface);
} }
QSurfaceFormat QWindowsEGLStaticContext::formatFromConfig(EGLDisplay display, EGLConfig config, QSurfaceFormat QWindowsEGLStaticContext::formatFromConfig(EGLDisplay display, EGLConfig config,

View File

@ -276,10 +276,10 @@ namespace {
quint16 nameIds[requiredRecordCount] = { 1, 2, 3, 4, 6 }; quint16 nameIds[requiredRecordCount] = { 1, 2, 3, 4, 6 };
int sizeOfHeader = sizeof(NameTable) + sizeof(NameRecord) * requiredRecordCount; 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"); 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) // Align table size of table to 32 bits (pad with 0)
int fullSize = ((sizeOfHeader + newFamilyNameSize + regularStringSize) & ~3) + 4; int fullSize = ((sizeOfHeader + newFamilyNameSize + regularStringSize) & ~3) + 4;
@ -641,11 +641,24 @@ QDebug operator<<(QDebug d, const QFontDef &def)
{ {
QDebugStateSaver saver(d); QDebugStateSaver saver(d);
d.nospace(); d.nospace();
d << "Family=" << def.family << " Stylename=" << def.styleName d.noquote();
<< " pointsize=" << def.pointSize << " pixelsize=" << def.pixelSize d << "QFontDef(Family=\"" << def.family << '"';
<< " styleHint=" << def.styleHint << " weight=" << def.weight if (!def.styleName.isEmpty())
<< " stretch=" << def.stretch << " hintingPreference=" d << ", stylename=" << def.styleName;
<< def.hintingPreference; 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; return d;
} }
#endif // !QT_NO_DEBUG_STREAM #endif // !QT_NO_DEBUG_STREAM
@ -799,7 +812,7 @@ static QString getEnglishName(const uchar *table, quint32 bytes)
length /= 2; length /= 2;
i18n_name.resize(length); 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; const unsigned char *string = table + string_offset + offset;
for (int i = 0; i < length; ++i) for (int i = 0; i < length; ++i)
uc[i] = getUShort(string + 2*i); uc[i] = getUShort(string + 2*i);
@ -807,10 +820,10 @@ static QString getEnglishName(const uchar *table, quint32 bytes)
// Apple Roman // Apple Roman
i18n_name.resize(length); 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; const unsigned char *string = table + string_offset + offset;
for (int i = 0; i < length; ++i) 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; DWORD count = 0;
QByteArray newFontData = font.data(); QByteArray newFontData = font.data();
HANDLE fontHandle = AddFontMemResourceEx((void *)newFontData.constData(), newFontData.size(), 0, HANDLE fontHandle =
&count); AddFontMemResourceEx(const_cast<char *>(newFontData.constData()),
DWORD(newFontData.size()), 0, &count);
if (count == 0 && fontHandle != 0) { if (count == 0 && fontHandle != 0) {
RemoveFontMemResourceEx(fontHandle); RemoveFontMemResourceEx(fontHandle);
fontHandle = 0; fontHandle = 0;
@ -1380,8 +1394,9 @@ QStringList QWindowsFontDatabase::addApplicationFont(const QByteArray &fontData,
return families; return families;
DWORD dummy = 0; DWORD dummy = 0;
font.handle = AddFontMemResourceEx((void *)fontData.constData(), fontData.size(), 0, font.handle =
&dummy); AddFontMemResourceEx(const_cast<char *>(fontData.constData()),
DWORD(fontData.size()), 0, &dummy);
if (font.handle == 0) if (font.handle == 0)
return QStringList(); return QStringList();
@ -1757,12 +1772,16 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request,
IDWriteFont *directWriteFont = 0; IDWriteFont *directWriteFont = 0;
HRESULT hr = data->directWriteGdiInterop->CreateFontFromLOGFONT(&lf, &directWriteFont); HRESULT hr = data->directWriteGdiInterop->CreateFontFromLOGFONT(&lf, &directWriteFont);
if (FAILED(hr)) { 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 { } else {
IDWriteFontFace *directWriteFontFace = NULL; IDWriteFontFace *directWriteFontFace = NULL;
hr = directWriteFont->CreateFontFace(&directWriteFontFace); hr = directWriteFont->CreateFontFace(&directWriteFontFace);
if (FAILED(hr)) { 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 { } else {
QWindowsFontEngineDirectWrite *fedw = new QWindowsFontEngineDirectWrite(directWriteFontFace, QWindowsFontEngineDirectWrite *fedw = new QWindowsFontEngineDirectWrite(directWriteFontFace,
request.pixelSize, request.pixelSize,

View File

@ -166,6 +166,12 @@ bool QWindowsFontEngine::hasEbdtTable() const
return GetFontData(hdc, MAKE_TAG('E', 'B', 'D', 'T'), 0, 0, 0) != GDI_ERROR; 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() void QWindowsFontEngine::getCMap()
{ {
ttf = (bool)(tm.tmPitchAndFamily & TMPF_TRUETYPE) || hasCMapTable(); ttf = (bool)(tm.tmPitchAndFamily & TMPF_TRUETYPE) || hasCMapTable();
@ -189,11 +195,12 @@ void QWindowsFontEngine::getCMap()
_faceId.index = 0; _faceId.index = 0;
if(cmap) { if(cmap) {
OUTLINETEXTMETRIC *otm = getOutlineTextMetric(hdc); OUTLINETEXTMETRIC *otm = getOutlineTextMetric(hdc);
designToDevice = QFixed((int)otm->otmEMSquare)/QFixed::fromReal(fontDef.pixelSize); unitsPerEm = int(otm->otmEMSquare);
unitsPerEm = otm->otmEMSquare; const QFixed unitsPerEmF(unitsPerEm);
x_height = (int)otm->otmsXHeight; designToDevice = unitsPerEmF / QFixed::fromReal(fontDef.pixelSize);
x_height = int(otm->otmsXHeight);
loadKerningPairs(designToDevice); 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; lineWidth = otm->otmsUnderscoreSize;
fsType = otm->otmfsType; fsType = otm->otmfsType;
free(otm); free(otm);
@ -394,9 +401,9 @@ void QWindowsFontEngine::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::Shape
for(int i = 0; i < glyphs->numGlyphs; i++) { for(int i = 0; i < glyphs->numGlyphs; i++) {
unsigned int glyph = glyphs->glyphs[i]; unsigned int glyph = glyphs->glyphs[i];
if(int(glyph) >= designAdvancesSize) { if(int(glyph) >= designAdvancesSize) {
int newSize = (glyph + 256) >> 8 << 8; const int newSize = int(glyph + 256) >> 8 << 8;
designAdvances = q_check_ptr((QFixed *)realloc(designAdvances, designAdvances = reinterpret_cast<QFixed *>(realloc(designAdvances, size_t(newSize) * sizeof(QFixed)));
newSize*sizeof(QFixed))); Q_CHECK_PTR(designAdvances);
for(int i = designAdvancesSize; i < newSize; ++i) for(int i = designAdvancesSize; i < newSize; ++i)
designAdvances[i] = -1000000; designAdvances[i] = -1000000;
designAdvancesSize = newSize; designAdvancesSize = newSize;
@ -418,9 +425,9 @@ void QWindowsFontEngine::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::Shape
unsigned int glyph = glyphs->glyphs[i]; unsigned int glyph = glyphs->glyphs[i];
if (glyph >= widthCacheSize) { if (glyph >= widthCacheSize) {
int newSize = (glyph + 256) >> 8 << 8; const uint newSize = (glyph + 256) >> 8 << 8;
widthCache = q_check_ptr((unsigned char *)realloc(widthCache, widthCache = reinterpret_cast<unsigned char *>(realloc(widthCache, newSize * sizeof(QFixed)));
newSize*sizeof(QFixed))); Q_CHECK_PTR(widthCache);
memset(widthCache + widthCacheSize, 0, newSize - widthCacheSize); memset(widthCache + widthCacheSize, 0, newSize - widthCacheSize);
widthCacheSize = newSize; widthCacheSize = newSize;
} }
@ -440,7 +447,7 @@ void QWindowsFontEngine::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::Shape
++chrLen; ++chrLen;
} }
SIZE size = {0, 0}; SIZE size = {0, 0};
GetTextExtentPoint32(hdc, (wchar_t *)ch, chrLen, &size); GetTextExtentPoint32(hdc, reinterpret_cast<const wchar_t *>(ch), chrLen, &size);
width = size.cx; width = size.cx;
} else { } else {
calculateTTFGlyphWidth(hdc, glyph, width); calculateTTFGlyphWidth(hdc, glyph, width);
@ -448,7 +455,7 @@ void QWindowsFontEngine::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::Shape
glyphs->advances[i] = width; glyphs->advances[i] = width;
// if glyph's within cache range, store it for later // if glyph's within cache range, store it for later
if (width > 0 && width < 0x100) 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 // results provided when transforming via MAT2 does not
// match the glyphs that are drawn using a WorldTransform // match the glyphs that are drawn using a WorldTransform
XFORM xform; XFORM xform;
xform.eM11 = t.m11(); xform.eM11 = FLOAT(t.m11());
xform.eM12 = t.m12(); xform.eM12 = FLOAT(t.m12());
xform.eM21 = t.m21(); xform.eM21 = FLOAT(t.m21());
xform.eM22 = t.m22(); xform.eM22 = FLOAT(t.m22());
xform.eDx = 0; xform.eDx = 0;
xform.eDy = 0; xform.eDy = 0;
SetGraphicsMode(hdc, GM_ADVANCED); SetGraphicsMode(hdc, GM_ADVANCED);
@ -514,7 +521,8 @@ bool QWindowsFontEngine::getOutlineMetrics(glyph_t glyph, const QTransform &t, g
if (res != GDI_ERROR) { if (res != GDI_ERROR) {
*metrics = glyph_metrics_t(gm.gmptGlyphOrigin.x, -gm.gmptGlyphOrigin.y, *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; return true;
} else { } else {
return false; return false;
@ -533,7 +541,7 @@ glyph_metrics_t QWindowsFontEngine::boundingBox(glyph_t glyph, const QTransform
if (!ttf && !success) { if (!ttf && !success) {
// Bitmap fonts // Bitmap fonts
wchar_t ch = glyph; wchar_t ch = wchar_t(glyph);
ABCFLOAT abc; ABCFLOAT abc;
GetCharABCWidthsFloat(hdc, ch, ch, &abc); GetCharABCWidthsFloat(hdc, ch, ch, &abc);
int width = qRound(abc.abcfB); int width = qRound(abc.abcfB);
@ -798,7 +806,7 @@ static bool addGlyphToPath(glyph_t glyph, const QFixedPoint &position, HDC hdc,
return false; return false;
// #### obey scale // #### obey scale
*metric = glyph_metrics_t(gMetric.gmptGlyphOrigin.x, -gMetric.gmptGlyphOrigin.y, *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); gMetric.gmCellIncX, gMetric.gmCellIncY);
} }
#endif #endif
@ -808,17 +816,15 @@ static bool addGlyphToPath(glyph_t glyph, const QFixedPoint &position, HDC hdc,
if (ttf) if (ttf)
glyphFormat |= GGO_GLYPH_INDEX; glyphFormat |= GGO_GLYPH_INDEX;
int bufferSize = GDI_ERROR; const DWORD bufferSize = GetGlyphOutline(hdc, glyph, glyphFormat, &gMetric, 0, 0, &mat);
bufferSize = GetGlyphOutline(hdc, glyph, glyphFormat, &gMetric, 0, 0, &mat); if (bufferSize == GDI_ERROR)
if ((DWORD)bufferSize == GDI_ERROR) {
return false; return false;
}
void *dataBuffer = new char[bufferSize]; char *dataBuffer = new char[bufferSize];
DWORD ret = GDI_ERROR; DWORD ret = GDI_ERROR;
ret = GetGlyphOutline(hdc, glyph, glyphFormat, &gMetric, bufferSize, dataBuffer, &mat); ret = GetGlyphOutline(hdc, glyph, glyphFormat, &gMetric, bufferSize, dataBuffer, &mat);
if (ret == GDI_ERROR) { if (ret == GDI_ERROR) {
delete [](char *)dataBuffer; delete [] dataBuffer;
return false; return false;
} }
@ -831,20 +837,18 @@ static bool addGlyphToPath(glyph_t glyph, const QFixedPoint &position, HDC hdc,
} }
#endif #endif
int offset = 0; DWORD offset = 0;
int headerOffset = 0; DWORD headerOffset = 0;
TTPOLYGONHEADER *ttph = 0;
QPointF oset = position.toPointF(); QPointF oset = position.toPointF();
while (headerOffset < bufferSize) { 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)); QPointF lastPoint(qt_to_qpointf(ttph->pfxStart, scale));
path->moveTo(lastPoint + oset); path->moveTo(lastPoint + oset);
offset += sizeof(TTPOLYGONHEADER); offset += sizeof(TTPOLYGONHEADER);
TTPOLYCURVE *curve; while (offset < headerOffset + ttph->cb) {
while (offset<int(headerOffset + ttph->cb)) { const TTPOLYCURVE *curve = reinterpret_cast<const TTPOLYCURVE *>(dataBuffer + offset);
curve = (TTPOLYCURVE*)((char*)(dataBuffer) + offset);
switch (curve->wType) { switch (curve->wType) {
case TT_PRIM_LINE: { case TT_PRIM_LINE: {
for (int i=0; i<curve->cpfx; ++i) { 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(); path->closeSubpath();
headerOffset += ttph->cb; headerOffset += ttph->cb;
} }
delete [] (char*)dataBuffer; delete [] dataBuffer;
return true; return true;
} }
@ -987,15 +991,15 @@ QFontEngine::Properties QWindowsFontEngine::properties() const
Properties p; Properties p;
p.emSquare = unitsPerEm; p.emSquare = unitsPerEm;
p.italicAngle = otm->otmItalicAngle; p.italicAngle = otm->otmItalicAngle;
p.postscriptName = QString::fromWCharArray((wchar_t *)((char *)otm + (quintptr)otm->otmpFamilyName)).toLatin1(); const QByteArray name = stringFromOutLineTextMetric(otm, otm->otmpFamilyName).toLatin1()
p.postscriptName += QString::fromWCharArray((wchar_t *)((char *)otm + (quintptr)otm->otmpStyleName)).toLatin1(); + stringFromOutLineTextMetric(otm, otm->otmpStyleName).toLatin1();
p.postscriptName = QFontEngine::convertToPostscriptFontFamilyName(p.postscriptName); p.postscriptName = QFontEngine::convertToPostscriptFontFamilyName(name);
p.boundingBox = QRectF(otm->otmrcFontBox.left, -otm->otmrcFontBox.top, p.boundingBox = QRectF(otm->otmrcFontBox.left, -otm->otmrcFontBox.top,
otm->otmrcFontBox.right - otm->otmrcFontBox.left, otm->otmrcFontBox.right - otm->otmrcFontBox.left,
otm->otmrcFontBox.top - otm->otmrcFontBox.bottom); otm->otmrcFontBox.top - otm->otmrcFontBox.bottom);
p.ascent = otm->otmAscent; p.ascent = otm->otmAscent;
p.descent = -otm->otmDescent; p.descent = -otm->otmDescent;
p.leading = (int)otm->otmLineGap; p.leading = int(otm->otmLineGap);
p.capHeight = 0; p.capHeight = 0;
p.lineWidth = otm->otmsUnderscoreSize; p.lineWidth = otm->otmsUnderscoreSize;
free(otm); free(otm);
@ -1061,10 +1065,10 @@ QWindowsNativeImage *QWindowsFontEngine::drawGDIGlyph(HFONT font, glyph_t glyph,
XFORM xform; XFORM xform;
if (has_transformation) { if (has_transformation) {
xform.eM11 = t.m11(); xform.eM11 = FLOAT(t.m11());
xform.eM12 = t.m12(); xform.eM12 = FLOAT(t.m12());
xform.eM21 = t.m21(); xform.eM21 = FLOAT(t.m21());
xform.eM22 = t.m22(); xform.eM22 = FLOAT(t.m22());
xform.eDx = margin; xform.eDx = margin;
xform.eDy = margin; xform.eDy = margin;
@ -1074,7 +1078,7 @@ QWindowsNativeImage *QWindowsFontEngine::drawGDIGlyph(HFONT font, glyph_t glyph,
SetWorldTransform(hdc, &xform); SetWorldTransform(hdc, &xform);
HGDIOBJ old_font = SelectObject(hdc, font); 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; GLYPHMETRICS tgm;
MAT2 mat; MAT2 mat;
memset(&mat, 0, sizeof(mat)); memset(&mat, 0, sizeof(mat));
@ -1088,13 +1092,13 @@ QWindowsNativeImage *QWindowsFontEngine::drawGDIGlyph(HFONT font, glyph_t glyph,
SelectObject(hdc, old_font); SelectObject(hdc, old_font);
if (result == GDI_ERROR) { 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); qErrnoWarning(errorCode, "QWinFontEngine: unable to query transformed glyph metrics (GetGlyphOutline() failed, error %d)...", errorCode);
return 0; return 0;
} }
iw = tgm.gmBlackBoxX; iw = int(tgm.gmBlackBoxX);
ih = tgm.gmBlackBoxY; ih = int(tgm.gmBlackBoxY);
xform.eDx -= tgm.gmptGlyphOrigin.x; xform.eDx -= tgm.gmptGlyphOrigin.x;
xform.eDy += tgm.gmptGlyphOrigin.y; xform.eDy += tgm.gmptGlyphOrigin.y;
@ -1131,11 +1135,11 @@ QWindowsNativeImage *QWindowsFontEngine::drawGDIGlyph(HFONT font, glyph_t glyph,
if (has_transformation) { if (has_transformation) {
SetGraphicsMode(hdc, GM_ADVANCED); SetGraphicsMode(hdc, GM_ADVANCED);
SetWorldTransform(hdc, &xform); 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 } else
#endif // !Q_OS_WINCE #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); SelectObject(hdc, old_font);
@ -1166,7 +1170,7 @@ QImage QWindowsFontEngine::alphaMapForGlyph(glyph_t glyph, const QTransform &xfo
QImage::Format mask_format = QWindowsNativeImage::systemFormat(); QImage::Format mask_format = QWindowsNativeImage::systemFormat();
mask_format = QImage::Format_RGB32; 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 (mask == 0) {
if (m_fontEngineData->clearTypeEnabled) if (m_fontEngineData->clearTypeEnabled)
DeleteObject(font); DeleteObject(font);
@ -1213,11 +1217,11 @@ QImage QWindowsFontEngine::alphaRGBMapForGlyph(glyph_t glyph, QFixed, const QTra
UINT contrast; UINT contrast;
SystemParametersInfo(SPI_GETFONTSMOOTHINGCONTRAST, 0, &contrast, 0); 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); int margin = glyphMargin(QFontEngine::Format_A32);
QWindowsNativeImage *mask = drawGDIGlyph(font, glyph, margin, t, QImage::Format_RGB32); 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) if (mask == 0)
return QImage(); return QImage();

View File

@ -1017,7 +1017,7 @@ QOpenGLStaticContext::QOpenGLStaticContext() :
QByteArray QOpenGLStaticContext::getGlString(unsigned int which) QByteArray QOpenGLStaticContext::getGlString(unsigned int which)
{ {
if (const GLubyte *s = opengl32.glGetString(which)) if (const GLubyte *s = opengl32.glGetString(which))
return QByteArray((const char*)s); return QByteArray(reinterpret_cast<const char*>(s));
return QByteArray(); return QByteArray();
} }
@ -1244,7 +1244,7 @@ bool QWindowsGLContext::updateObtainedParams(HDC hdc, int *obtainedSwapInterval)
bool hasRobustness = false; bool hasRobustness = false;
if (m_obtainedFormat.majorVersion() < 3) { 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"); hasRobustness = exts && strstr(exts, "GL_ARB_robustness");
} else { } else {
typedef const GLubyte * (APIENTRY *glGetStringi_t)(GLenum, GLuint); typedef const GLubyte * (APIENTRY *glGetStringi_t)(GLenum, GLuint);
@ -1253,7 +1253,7 @@ bool QWindowsGLContext::updateObtainedParams(HDC hdc, int *obtainedSwapInterval)
GLint n = 0; GLint n = 0;
QOpenGLStaticContext::opengl32.glGetIntegerv(GL_NUM_EXTENSIONS, &n); QOpenGLStaticContext::opengl32.glGetIntegerv(GL_NUM_EXTENSIONS, &n);
for (GLint i = 0; i < n; ++i) { 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")) { if (p && !strcmp(p, "GL_ARB_robustness")) {
hasRobustness = true; hasRobustness = true;
break; break;

View File

@ -323,7 +323,9 @@ void QWindowsInputContext::invokeAction(QInputMethod::Action action, int cursorP
// position. // position.
const HIMC himc = ImmGetContext(m_compositionContext.hwnd); const HIMC himc = ImmGetContext(m_compositionContext.hwnd);
const HWND imeWindow = ImmGetDefaultIMEWnd(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); ImmReleaseContext(m_compositionContext.hwnd, himc);
} }
@ -332,7 +334,7 @@ static inline QString getCompositionString(HIMC himc, DWORD dwIndex)
enum { bufferSize = 256 }; enum { bufferSize = 256 };
wchar_t buffer[bufferSize]; wchar_t buffer[bufferSize];
const int length = ImmGetCompositionString(himc, dwIndex, buffer, bufferSize * sizeof(wchar_t)); 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. // 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) if (size < 0)
return false; return false;
*result = size; *result = size;
return true;
} }
break; return true;
case IMR_CONFIRMRECONVERTSTRING: case IMR_CONFIRMRECONVERTSTRING:
return true; return true;
default: default:
@ -576,7 +577,7 @@ bool QWindowsInputContext::handleIME_Request(WPARAM wParam,
void QWindowsInputContext::handleInputLanguageChanged(WPARAM wparam, LPARAM lparam) void QWindowsInputContext::handleInputLanguageChanged(WPARAM wparam, LPARAM lparam)
{ {
const LCID newLanguageId = languageIdFromLocaleId(lparam); const LCID newLanguageId = languageIdFromLocaleId(WORD(lparam));
if (newLanguageId == m_languageId) if (newLanguageId == m_languageId)
return; return;
const LCID oldLanguageId = m_languageId; const LCID oldLanguageId = m_languageId;
@ -610,13 +611,13 @@ int QWindowsInputContext::reconvertString(RECONVERTSTRING *reconv)
if (!surroundingTextV.isValid()) if (!surroundingTextV.isValid())
return -1; return -1;
const QString surroundingText = surroundingTextV.toString(); const QString surroundingText = surroundingTextV.toString();
const DWORD memSize = sizeof(RECONVERTSTRING) const int memSize = int(sizeof(RECONVERTSTRING))
+ (surroundingText.length() + 1) * sizeof(ushort); + (surroundingText.length() + 1) * int(sizeof(ushort));
qCDebug(lcQpaInputMethods) << __FUNCTION__ << " reconv=" << reconv qCDebug(lcQpaInputMethods) << __FUNCTION__ << " reconv=" << reconv
<< " surroundingText=" << surroundingText << " size=" << memSize; << " surroundingText=" << surroundingText << " size=" << memSize;
// If memory is not allocated, return the required size. // If memory is not allocated, return the required size.
if (!reconv) if (!reconv)
return surroundingText.isEmpty() ? -1 : int(memSize); return surroundingText.isEmpty() ? -1 : memSize;
const QVariant posV = QInputMethod::queryFocusObject(Qt::ImCursorPosition, QVariant()); const QVariant posV = QInputMethod::queryFocusObject(Qt::ImCursorPosition, QVariant());
const int pos = posV.isValid() ? posV.toInt() : 0; const int pos = posV.isValid() ? posV.toInt() : 0;
@ -635,13 +636,13 @@ int QWindowsInputContext::reconvertString(RECONVERTSTRING *reconv)
QInputMethodEvent selectEvent(QString(), attributes); QInputMethodEvent selectEvent(QString(), attributes);
QCoreApplication::sendEvent(fo, &selectEvent); QCoreApplication::sendEvent(fo, &selectEvent);
reconv->dwSize = memSize; reconv->dwSize = DWORD(memSize);
reconv->dwVersion = 0; reconv->dwVersion = 0;
reconv->dwStrLen = surroundingText.size(); reconv->dwStrLen = DWORD(surroundingText.size());
reconv->dwStrOffset = sizeof(RECONVERTSTRING); reconv->dwStrOffset = sizeof(RECONVERTSTRING);
reconv->dwCompStrLen = endPos - startPos; // TCHAR count. reconv->dwCompStrLen = DWORD(endPos - startPos); // TCHAR count.
reconv->dwCompStrOffset = startPos * sizeof(ushort); // byte count. reconv->dwCompStrOffset = DWORD(startPos) * sizeof(ushort); // byte count.
reconv->dwTargetStrLen = reconv->dwCompStrLen; reconv->dwTargetStrLen = reconv->dwCompStrLen;
reconv->dwTargetStrOffset = reconv->dwCompStrOffset; reconv->dwTargetStrOffset = reconv->dwCompStrOffset;
ushort *pastReconv = reinterpret_cast<ushort *>(reconv + 1); ushort *pastReconv = reinterpret_cast<ushort *>(reconv + 1);

View File

@ -543,8 +543,8 @@ QVariant QWindowsIntegration::styleHint(QPlatformIntegration::StyleHint hint) co
case QPlatformIntegration::FontSmoothingGamma: case QPlatformIntegration::FontSmoothingGamma:
return QVariant(QWindowsFontDatabase::fontSmoothingGamma()); return QVariant(QWindowsFontDatabase::fontSmoothingGamma());
case QPlatformIntegration::MouseDoubleClickInterval: case QPlatformIntegration::MouseDoubleClickInterval:
if (const int ms = GetDoubleClickTime()) if (const UINT ms = GetDoubleClickTime())
return QVariant(ms); return QVariant(int(ms));
break; break;
case QPlatformIntegration::UseRtlExtensions: case QPlatformIntegration::UseRtlExtensions:
return QVariant(d->m_context.useRTLExtensions()); return QVariant(d->m_context.useRTLExtensions());

View File

@ -547,7 +547,7 @@ Q_STATIC_ASSERT((NumMods == KeyboardLayoutItem::NumQtKeys));
/** /**
Remap return or action key to select key for windows mobile. Remap return or action key to select key for windows mobile.
*/ */
inline int winceKeyBend(int keyCode) inline quint32 winceKeyBend(quint32 keyCode)
{ {
return KeyTbl[keyCode]; return KeyTbl[keyCode];
} }
@ -581,10 +581,10 @@ QT_END_INCLUDE_NAMESPACE
#endif // Q_OS_WINCE #endif // Q_OS_WINCE
// Translate a VK into a Qt key code, or unicode character // 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); Q_ASSERT(vk > 0 && vk < 256);
int code = 0; quint32 code = 0;
QChar unicodeBuffer[5]; QChar unicodeBuffer[5];
int res = ToUnicode(vk, scancode, kbdBuffer, reinterpret_cast<LPWSTR>(unicodeBuffer), 5, 0); 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 // 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() /* MAKELCID()'s first argument is a WORD, and GetKeyboardLayout()
* returns a DWORD. */ * returns a DWORD. */
LCID newLCID = MAKELCID((quintptr)GetKeyboardLayout(0), SORT_DEFAULT); LCID newLCID = MAKELCID(quintptr(GetKeyboardLayout(0)), SORT_DEFAULT);
// keyboardInputLocale = qt_localeFromLCID(newLCID); // keyboardInputLocale = qt_localeFromLCID(newLCID);
bool bidi = false; bool bidi = false;
wchar_t LCIDFontSig[16]; wchar_t LCIDFontSig[16];
if (GetLocaleInfo(newLCID, LOCALE_FONTSIGNATURE, LCIDFontSig, sizeof(LCIDFontSig) / sizeof(wchar_t)) if (GetLocaleInfo(newLCID, LOCALE_FONTSIGNATURE, LCIDFontSig, sizeof(LCIDFontSig) / sizeof(wchar_t))
&& (LCIDFontSig[7] & (wchar_t)0x0800)) && (LCIDFontSig[7] & wchar_t(0x0800)))
bidi = true; bidi = true;
keyboardInputDirection = bidi ? Qt::RightToLeft : Qt::LeftToRight; 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 unsigned char kbdBuffer[256]; // Will hold the complete keyboard state
GetKeyboardState(kbdBuffer); GetKeyboardState(kbdBuffer);
const quint32 scancode = (msg.lParam >> 16) & scancodeBitmask; 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 // 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].qtKey[7] = toKeyOrUnicode(vk_key, scancode, buffer, &isDeadKey);
keyLayout[vk_key].deadkeys |= isDeadKey ? 0x80 : 0; keyLayout[vk_key].deadkeys |= isDeadKey ? 0x80 : 0;
// Add a fall back key for layouts which don't do composition and show non-latin1 characters // 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) { if (!fallbackKey || fallbackKey == Qt::Key_unknown) {
fallbackKey = 0; fallbackKey = 0;
if (vk_key != keyLayout[vk_key].qtKey[0] && vk_key < 0x5B && vk_key > 0x2F) 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) 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); return ch.isNull() ? QString() : QString(ch);
} }
@ -813,7 +813,7 @@ static void showSystemMenu(QWindow* w)
topLevelHwnd, topLevelHwnd,
0); 0);
if (ret) if (ret)
qWindowsWndProc(topLevelHwnd, WM_SYSCOMMAND, ret, 0); qWindowsWndProc(topLevelHwnd, WM_SYSCOMMAND, WPARAM(ret), 0);
} }
static inline void sendExtendedPressRelease(QWindow *w, int k, static inline void sendExtendedPressRelease(QWindow *w, int k,
@ -877,7 +877,7 @@ bool QWindowsKeyMapper::translateMultimediaKeyEventInternal(QWindow *window, con
if (cmd < 0 || cmd > 52) if (cmd < 0 || cmd > 52)
return false; return false;
const int qtKey = CmdTbl[cmd]; const int qtKey = int(CmdTbl[cmd]);
sendExtendedPressRelease(receiver, qtKey, Qt::KeyboardModifier(state), 0, 0, 0); sendExtendedPressRelease(receiver, qtKey, Qt::KeyboardModifier(state), 0, 0, 0);
// QTBUG-43343: Make sure to return false if Qt does not handle the key, otherwise, // 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. // 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 */) 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; const quint32 scancode = (msg.lParam >> 16) & scancodeBitmask;
quint32 vk_key = msg.wParam; quint32 vk_key = quint32(msg.wParam);
quint32 nModifiers = 0; quint32 nModifiers = 0;
QWindow *receiver = m_keyGrabber ? m_keyGrabber : window; QWindow *receiver = m_keyGrabber ? m_keyGrabber : window;
@ -955,13 +955,13 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
if (dirStatus == VK_LSHIFT if (dirStatus == VK_LSHIFT
&& ((msg.wParam == VK_SHIFT && GetKeyState(VK_LCONTROL)) && ((msg.wParam == VK_SHIFT && GetKeyState(VK_LCONTROL))
|| (msg.wParam == VK_CONTROL && GetKeyState(VK_LSHIFT)))) { || (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; result = true;
dirStatus = 0; dirStatus = 0;
} else if (dirStatus == VK_RSHIFT } else if (dirStatus == VK_RSHIFT
&& ( (msg.wParam == VK_SHIFT && GetKeyState(VK_RCONTROL)) && ( (msg.wParam == VK_SHIFT && GetKeyState(VK_RCONTROL))
|| (msg.wParam == VK_CONTROL && GetKeyState(VK_RSHIFT)))) { || (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; result = true;
dirStatus = 0; dirStatus = 0;
} else { } else {
@ -1036,7 +1036,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
|| (msg.wParam >= VK_OEM_PLUS && msg.wParam <= VK_OEM_3)) || (msg.wParam >= VK_OEM_PLUS && msg.wParam <= VK_OEM_3))
? 0 : int(Qt::KeypadModifier); ? 0 : int(Qt::KeypadModifier);
default: default:
if ((uint)msg.lParam == 0x004c0001 || (uint)msg.lParam == 0xc04c0001) if (uint(msg.lParam) == 0x004c0001 || uint(msg.lParam) == 0xc04c0001)
state |= Qt::KeypadModifier; state |= Qt::KeypadModifier;
break; break;
} }
@ -1048,6 +1048,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
case Qt::Key_Slash: case Qt::Key_Slash:
case Qt::Key_NumLock: case Qt::Key_NumLock:
state |= Qt::KeypadModifier; state |= Qt::KeypadModifier;
break;
default: default:
break; break;
} }
@ -1057,13 +1058,13 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
if (msgType == WM_KEYDOWN || msgType == WM_IME_KEYDOWN || msgType == WM_SYSKEYDOWN) { 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 // Get the last record of this key press, so we can validate the current state
// The record is not removed from the list // 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 // 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 // (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 // This will stop the auto-repeat of the key, should a modifier change, for example
if (rec && rec->state != state) { if (rec && rec->state != state) {
key_recorder.findKey(msg.wParam, true); key_recorder.findKey(int(msg.wParam), true);
rec = 0; rec = 0;
} }
@ -1076,11 +1077,11 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
QChar uch; QChar uch;
if (PeekMessage(&wm_char, 0, charType, charType, PM_REMOVE)) { if (PeekMessage(&wm_char, 0, charType, charType, PM_REMOVE)) {
// Found a ?_CHAR // 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)) if (msgType == WM_SYSKEYDOWN && uch.isLetter() && (msg.lParam & KF_ALTDOWN))
uch = uch.toLower(); // (See doc of WM_SYSCHAR) Alt-letter uch = uch.toLower(); // (See doc of WM_SYSCHAR) Alt-letter
if (!code && !uch.row()) 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 // 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 = const QWindowsInputContext *windowsInputContext =
qobject_cast<const QWindowsInputContext *>(QWindowsIntegration::instance()->inputContext()); qobject_cast<const QWindowsInputContext *>(QWindowsIntegration::instance()->inputContext());
if (!(windowsInputContext && windowsInputContext->isComposing())) if (!(windowsInputContext && windowsInputContext->isComposing()))
vk_key = ImmGetVirtualKey((HWND)window->winId()); vk_key = ImmGetVirtualKey(reinterpret_cast<HWND>(window->winId()));
BYTE keyState[256]; BYTE keyState[256];
wchar_t newKey[3] = {0}; wchar_t newKey[3] = {0};
GetKeyboardState(keyState); GetKeyboardState(keyState);
@ -1111,14 +1112,14 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
uch = QChar(QLatin1Char(0x7f)); // Windows doesn't know this one. uch = QChar(QLatin1Char(0x7f)); // Windows doesn't know this one.
} else { } else {
if (msgType != WM_SYSKEYDOWN || !code) { 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 the high bit of the return value is set, it's a deadkey
if (!(map & 0x80000000)) if (!(map & 0x80000000))
uch = QChar((ushort)map); uch = QChar(ushort(map));
} }
} }
if (!code && !uch.row()) if (!code && !uch.row())
code = asciiToKeycode(uch.cell(), state); code = asciiToKeycode(char(uch.cell()), state);
} }
// Special handling of global Windows hotkeys // Special handling of global Windows hotkeys
@ -1147,9 +1148,9 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
if (rec) { if (rec) {
if (code < Qt::Key_Shift || code > Qt::Key_ScrollLock) { if (code < Qt::Key_Shift || code > Qt::Key_ScrollLock) {
QWindowSystemInterface::handleExtendedKeyEvent(receiver, QEvent::KeyRelease, code, 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, 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; result = true;
} }
} }
@ -1157,7 +1158,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
// and store the key data into our records. // and store the key data into our records.
else { else {
const QString text = uch.isNull() ? QString() : QString(uch); 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); const Qt::KeyboardModifiers modifiers(state);
#ifndef QT_NO_SHORTCUT #ifndef QT_NO_SHORTCUT
// Is Qt interested in the context menu key? // Is Qt interested in the context menu key?
@ -1166,9 +1167,9 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
return false; return false;
} }
#endif // !QT_NO_SHORTCUT #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, QWindowSystemInterface::handleExtendedKeyEvent(receiver, QEvent::KeyPress, code,
modifiers, scancode, msg.wParam, nModifiers, text, false); modifiers, scancode, quint32(msg.wParam), nModifiers, text, false);
result =true; result =true;
bool store = true; bool store = true;
#ifndef Q_OS_WINCE #ifndef Q_OS_WINCE
@ -1187,7 +1188,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
} }
#endif // !Q_OS_WINCE #endif // !Q_OS_WINCE
if (!store) 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 // 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 // win32 natively, or our window gets focus while a key is already press, but now gets
// the key release event. // 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 if (!rec && !(code == Qt::Key_Shift
|| code == Qt::Key_Control || code == Qt::Key_Control
|| code == Qt::Key_Meta || code == Qt::Key_Meta
@ -1205,13 +1206,14 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
// Someone ate the key down event // Someone ate the key down event
} else { } else {
if (!code) 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 // Map SHIFT + Tab to SHIFT + BackTab, QShortcutMap knows about this translation
if (code == Qt::Key_Tab && (state & Qt::ShiftModifier) == Qt::ShiftModifier) if (code == Qt::Key_Tab && (state & Qt::ShiftModifier) == Qt::ShiftModifier)
code = Qt::Key_Backtab; code = Qt::Key_Backtab;
QWindowSystemInterface::handleExtendedKeyEvent(receiver, QEvent::KeyRelease, code, 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); (rec ? rec->text : QString()), false);
result = true; result = true;
#ifndef Q_OS_WINCE #ifndef Q_OS_WINCE

View File

@ -156,7 +156,7 @@ static bool qt_write_dibv5(QDataStream &s, QImage image)
bi.bV5Planes = 1; bi.bV5Planes = 1;
bi.bV5BitCount = 32; bi.bV5BitCount = 32;
bi.bV5Compression = BI_BITFIELDS; bi.bV5Compression = BI_BITFIELDS;
bi.bV5SizeImage = bpl_bmp*image.height(); bi.bV5SizeImage = DWORD(bpl_bmp * image.height());
bi.bV5XPelsPerMeter = 0; bi.bV5XPelsPerMeter = 0;
bi.bV5YPelsPerMeter = 0; bi.bV5YPelsPerMeter = 0;
bi.bV5ClrUsed = 0; bi.bV5ClrUsed = 0;
@ -176,30 +176,29 @@ static bool qt_write_dibv5(QDataStream &s, QImage image)
image = image.convertToFormat(QImage::Format_ARGB32); image = image.convertToFormat(QImage::Format_ARGB32);
uchar *buf = new uchar[bpl_bmp]; 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--) { for (int y=image.height()-1; y>=0; y--) {
// write the image bits // write the image bits
const QRgb *p = reinterpret_cast<const QRgb *>(image.constScanLine(y)); const QRgb *p = reinterpret_cast<const QRgb *>(image.constScanLine(y));
const QRgb *end = p + image.width(); const QRgb *end = p + image.width();
b = buf; uchar *b = buf;
while (p < end) { while (p < end) {
int alpha = qAlpha(*p); int alpha = qAlpha(*p);
if (alpha) { if (alpha) {
*b++ = qBlue(*p); *b++ = uchar(qBlue(*p));
*b++ = qGreen(*p); *b++ = uchar(qGreen(*p));
*b++ = qRed(*p); *b++ = uchar(qRed(*p));
} else { } else {
//white for fully transparent pixels. //white for fully transparent pixels.
*b++ = 0xff; *b++ = 0xff;
*b++ = 0xff; *b++ = 0xff;
*b++ = 0xff; *b++ = 0xff;
} }
*b++ = alpha; *b++ = uchar(alpha);
p++; p++;
} }
d->write((char*)buf, bpl_bmp); d->write(reinterpret_cast<const char *>(buf), bpl_bmp);
if (s.status() != QDataStream::Ok) { if (s.status() != QDataStream::Ok) {
delete[] buf; delete[] buf;
return false; return false;
@ -227,25 +226,22 @@ static bool qt_read_dibv5(QDataStream &s, QImage &image)
if (d->atEnd()) if (d->atEnd())
return false; 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) if (s.status() != QDataStream::Ok)
return false; return false;
int nbits = bi.bV5BitCount; const int nbits = bi.bV5BitCount;
int comp = bi.bV5Compression; if (nbits != 32 || bi.bV5Planes != 1 || bi.bV5Compression != BMP_BITFIELDS)
if (nbits != 32 || bi.bV5Planes != 1 || comp != BMP_BITFIELDS)
return false; //Unsupported DIBV5 format return false; //Unsupported DIBV5 format
int w = bi.bV5Width, h = bi.bV5Height; const int w = bi.bV5Width;
int red_mask = bi.bV5RedMask; int h = bi.bV5Height;
int green_mask = bi.bV5GreenMask; const int red_mask = int(bi.bV5RedMask);
int blue_mask = bi.bV5BlueMask; const int green_mask = int(bi.bV5GreenMask);
int alpha_mask = bi.bV5AlphaMask; const int blue_mask = int(bi.bV5BlueMask);
int red_shift = 0; const int alpha_mask = int(bi.bV5AlphaMask);
int green_shift = 0;
int blue_shift = 0; const QImage::Format format = QImage::Format_ARGB32;
int alpha_shift = 0;
QImage::Format format = QImage::Format_ARGB32;
if (bi.bV5Height < 0) if (bi.bV5Height < 0)
h = -h; // support images with negative height 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.setDotsPerMeterX(bi.bV5XPelsPerMeter);
image.setDotsPerMeterY(bi.bV5YPelsPerMeter); image.setDotsPerMeterY(bi.bV5YPelsPerMeter);
red_shift = calc_shift(red_mask); const int red_shift = calc_shift(red_mask);
green_shift = calc_shift(green_mask); const int green_shift = calc_shift(green_mask);
blue_shift = calc_shift(blue_mask); const int blue_shift = calc_shift(blue_mask);
if (alpha_mask) { const int alpha_shift = alpha_mask ? calc_shift(alpha_mask) : 0u;
alpha_shift = calc_shift(alpha_mask);
}
int bpl = image.bytesPerLine(); const int bpl = image.bytesPerLine();
uchar *data = image.bits(); uchar *data = image.bits();
QRgb *p;
QRgb *end;
uchar *buf24 = new uchar[bpl]; uchar *buf24 = new uchar[bpl];
int bpl24 = ((w*nbits+31)/32)*4; const int bpl24 = ((w * nbits + 31) / 32) * 4;
uchar *b;
unsigned int c;
while (--h >= 0) { while (--h >= 0) {
p = (QRgb *)(data + h*bpl); QRgb *p = reinterpret_cast<QRgb *>(data + h * bpl);
end = p + w; QRgb *end = p + w;
if (d->read((char *)buf24,bpl24) != bpl24) if (d->read(reinterpret_cast<char *>(buf24), bpl24) != bpl24)
break; break;
b = buf24; const uchar *b = buf24;
while (p < end) { 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) , *p++ = qRgba(((c & red_mask) >> red_shift) ,
((c & green_mask) >> green_shift), ((c & green_mask) >> green_shift),
((c & blue_mask) >> blue_shift), ((c & blue_mask) >> blue_shift),
@ -295,9 +286,9 @@ static bool qt_read_dibv5(QDataStream &s, QImage &image)
uchar *buf = new uchar[bpl]; uchar *buf = new uchar[bpl];
h = -bi.bV5Height; h = -bi.bV5Height;
for (int y = 0; y < h/2; ++y) { for (int y = 0; y < h/2; ++y) {
memcpy(buf, data + y*bpl, bpl); memcpy(buf, data + y * bpl, size_t(bpl));
memcpy(data + y*bpl, data + (h-y-1)*bpl, bpl); memcpy(data + y*bpl, data + (h - y -1) * bpl, size_t(bpl));
memcpy(data + (h-y-1)*bpl, buf, bpl); memcpy(data + (h - y -1 ) * bpl, buf, size_t(bpl));
} }
delete [] buf; delete [] buf;
} }
@ -315,7 +306,7 @@ static int getCf(const FORMATETC &formatetc)
static FORMATETC setCf(int cf) static FORMATETC setCf(int cf)
{ {
FORMATETC formatetc; FORMATETC formatetc;
formatetc.cfFormat = cf; formatetc.cfFormat = CLIPFORMAT(cf);
formatetc.dwAspect = DVASPECT_CONTENT; formatetc.dwAspect = DVASPECT_CONTENT;
formatetc.lindex = -1; formatetc.lindex = -1;
formatetc.ptd = NULL; formatetc.ptd = NULL;
@ -325,12 +316,12 @@ static FORMATETC setCf(int cf)
static bool setData(const QByteArray &data, STGMEDIUM *pmedium) static bool setData(const QByteArray &data, STGMEDIUM *pmedium)
{ {
HGLOBAL hData = GlobalAlloc(0, data.size()); HGLOBAL hData = GlobalAlloc(0, SIZE_T(data.size()));
if (!hData) if (!hData)
return false; return false;
void *out = GlobalLock(hData); void *out = GlobalLock(hData);
memcpy(out, data.data(), data.size()); memcpy(out, data.data(), size_t(data.size()));
GlobalUnlock(hData); GlobalUnlock(hData);
pmedium->tymed = TYMED_HGLOBAL; pmedium->tymed = TYMED_HGLOBAL;
pmedium->hGlobal = hData; pmedium->hGlobal = hData;
@ -345,8 +336,8 @@ static QByteArray getData(int cf, IDataObject *pDataObj, int lindex = -1)
formatetc.lindex = lindex; formatetc.lindex = lindex;
STGMEDIUM s; STGMEDIUM s;
if (pDataObj->GetData(&formatetc, &s) == S_OK) { if (pDataObj->GetData(&formatetc, &s) == S_OK) {
DWORD * val = (DWORD*)GlobalLock(s.hGlobal); const void *val = GlobalLock(s.hGlobal);
data = QByteArray::fromRawData((char*)val, GlobalSize(s.hGlobal)); data = QByteArray::fromRawData(reinterpret_cast<const char *>(val), int(GlobalSize(s.hGlobal)));
data.detach(); data.detach();
GlobalUnlock(s.hGlobal); GlobalUnlock(s.hGlobal);
ReleaseStgMedium(&s); ReleaseStgMedium(&s);
@ -362,7 +353,7 @@ static QByteArray getData(int cf, IDataObject *pDataObj, int lindex = -1)
while(SUCCEEDED(hr)){ while(SUCCEEDED(hr)){
hr = s.pstm->Read(szBuffer, sizeof(szBuffer), &actualRead); hr = s.pstm->Read(szBuffer, sizeof(szBuffer), &actualRead);
if (SUCCEEDED(hr) && actualRead > 0) { if (SUCCEEDED(hr) && actualRead > 0) {
data += QByteArray::fromRawData(szBuffer, actualRead); data += QByteArray::fromRawData(szBuffer, int(actualRead));
} }
if (actualRead != sizeof(szBuffer)) if (actualRead != sizeof(szBuffer))
break; break;
@ -514,11 +505,11 @@ QWindowsMime::~QWindowsMime()
*/ */
int QWindowsMime::registerMimeType(const QString &mime) 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) if (!f)
qErrnoWarning("QWindowsMime::registerMimeType: Failed to register clipboard format"); 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; ++u;
} }
res.truncate(ri); res.truncate(ri);
const int byteLength = res.length() * sizeof(ushort); const int byteLength = res.length() * int(sizeof(ushort));
QByteArray r(byteLength + 2, '\0'); QByteArray r(byteLength + 2, '\0');
memcpy(r.data(), res.unicode(), byteLength); memcpy(r.data(), res.unicode(), size_t(byteLength));
r[byteLength] = 0; r[byteLength] = 0;
r[byteLength+1] = 0; r[byteLength+1] = 0;
return setData(r, pmedium); return setData(r, pmedium);
@ -706,17 +697,17 @@ QVariant QWindowsMimeText::convertToMime(const QString &mime, LPDATAOBJECT pData
QString str; QString str;
QByteArray data = getData(CF_UNICODETEXT, pDataObj); QByteArray data = getData(CF_UNICODETEXT, pDataObj);
if (!data.isEmpty()) { 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")); str.replace(QStringLiteral("\r\n"), QStringLiteral("\n"));
} else { } else {
data = getData(CF_TEXT, pDataObj); data = getData(CF_TEXT, pDataObj);
if (!data.isEmpty()) { if (!data.isEmpty()) {
const char* d = data.data(); const char* d = data.data();
const int s = qstrlen(d); const unsigned s = qstrlen(d);
QByteArray r(data.size()+1, '\0'); QByteArray r(data.size()+1, '\0');
char* o = r.data(); char* o = r.data();
int j=0; int j=0;
for (int i=0; i<s; i++) { for (unsigned i = 0; i < s; ++i) {
char c = d[i]; char c = d[i];
if (c!='\r') if (c!='\r')
o[j++]=c; o[j++]=c;
@ -777,22 +768,22 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat
for (int i=0; i<urls.size(); i++) { for (int i=0; i<urls.size(); i++) {
QString fn = QDir::toNativeSeparators(urls.at(i).toLocalFile()); QString fn = QDir::toNativeSeparators(urls.at(i).toLocalFile());
if (!fn.isEmpty()) { if (!fn.isEmpty()) {
size += sizeof(ushort) * (fn.length() + 1); size += sizeof(ushort) * size_t(fn.length() + 1);
fileNames.append(fn); fileNames.append(fn);
} }
} }
QByteArray result(size, '\0'); QByteArray result(size, '\0');
DROPFILES* d = (DROPFILES*)result.data(); DROPFILES* d = reinterpret_cast<DROPFILES *>(result.data());
d->pFiles = sizeof(DROPFILES); d->pFiles = sizeof(DROPFILES);
GetCursorPos(&d->pt); // try GetCursorPos(&d->pt); // try
d->fNC = true; d->fNC = true;
char* files = ((char*)d) + d->pFiles; char *files = (reinterpret_cast<char*>(d)) + d->pFiles;
d->fWide = true; 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++) { 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)); memcpy(f, fileNames.at(i).utf16(), l * sizeof(ushort));
f += l; f += l;
*f++ = 0; *f++ = 0;
@ -805,7 +796,8 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat
QByteArray result; QByteArray result;
if (!urls.isEmpty()) { if (!urls.isEmpty()) {
QString url = urls.at(0).toString(); 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');
result.append('\0'); result.append('\0');
@ -860,9 +852,9 @@ QVariant QWindowsMimeURI::convertToMime(const QString &mimeType, LPDATAOBJECT pD
if (data.isEmpty()) if (data.isEmpty())
return QVariant(); return QVariant();
LPDROPFILES hdrop = (LPDROPFILES)data.data(); const DROPFILES *hdrop = reinterpret_cast<const DROPFILES *>(data.constData());
if (hdrop->fWide) { 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; int i = 0;
while (filesw[i]) { while (filesw[i]) {
QString fileurl = QString::fromWCharArray(filesw + i); QString fileurl = QString::fromWCharArray(filesw + i);
@ -870,7 +862,7 @@ QVariant QWindowsMimeURI::convertToMime(const QString &mimeType, LPDATAOBJECT pD
i += fileurl.length()+1; i += fileurl.length()+1;
} }
} else { } else {
const char* files = (const char *)data.data() + hdrop->pFiles; const char* files = reinterpret_cast<const char *>(data.constData() + hdrop->pFiles);
int i=0; int i=0;
while (files[i]) { while (files[i]) {
urls += QUrl::fromLocalFile(QString::fromLocal8Bit(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); QByteArray data = getData(CF_INETURL_W, pDataObj);
if (data.isEmpty()) if (data.isEmpty())
return QVariant(); 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)) { } else if (canGetData(CF_INETURL, pDataObj)) {
QByteArray data = getData(CF_INETURL, pDataObj); QByteArray data = getData(CF_INETURL, pDataObj);
if (data.isEmpty()) if (data.isEmpty())
@ -1014,14 +1006,14 @@ bool QWindowsMimeHtml::convertFromMime(const FORMATETC &formatetc, const QMimeDa
result += "<!--EndFragment-->"; result += "<!--EndFragment-->";
// set the correct number for EndHTML // set the correct number for EndHTML
QByteArray pos = QString::number(result.size()).toLatin1(); QByteArray pos = QByteArray::number(result.size());
memcpy((char *)(result.data() + 53 - pos.length()), pos.constData(), pos.length()); memcpy(reinterpret_cast<char *>(result.data() + 53 - pos.length()), pos.constData(), size_t(pos.length()));
// set correct numbers for StartFragment and EndFragment // set correct numbers for StartFragment and EndFragment
pos = QString::number(result.indexOf("<!--StartFragment-->") + 20).toLatin1(); pos = QByteArray::number(result.indexOf("<!--StartFragment-->") + 20);
memcpy((char *)(result.data() + 79 - pos.length()), pos.constData(), pos.length()); memcpy(reinterpret_cast<char *>(result.data() + 79 - pos.length()), pos.constData(), size_t(pos.length()));
pos = QString::number(result.indexOf("<!--EndFragment-->")).toLatin1(); pos = QByteArray::number(result.indexOf("<!--EndFragment-->"));
memcpy((char *)(result.data() + 103 - pos.length()), pos.constData(), pos.length()); memcpy(reinterpret_cast<char *>(result.data() + 103 - pos.length()), pos.constData(), size_t(pos.length()));
return setData(result, pmedium); return setData(result, pmedium);
} }
@ -1249,9 +1241,9 @@ bool QBuiltInMimes::convertFromMime(const FORMATETC &formatetc, const QMimeData
++u; ++u;
} }
res.truncate(ri); res.truncate(ri);
const int byteLength = res.length() * sizeof(ushort); const int byteLength = res.length() * int(sizeof(ushort));
QByteArray r(byteLength + 2, '\0'); QByteArray r(byteLength + 2, '\0');
memcpy(r.data(), res.unicode(), byteLength); memcpy(r.data(), res.unicode(), size_t(byteLength));
r[byteLength] = 0; r[byteLength] = 0;
r[byteLength+1] = 0; r[byteLength+1] = 0;
data = r; data = r;
@ -1288,7 +1280,7 @@ QVariant QBuiltInMimes::convertToMime(const QString &mimeType, IDataObject *pDat
qCDebug(lcQpaMime) << __FUNCTION__; qCDebug(lcQpaMime) << __FUNCTION__;
if (mimeType == QLatin1String("text/html") && preferredType == QVariant::String) { if (mimeType == QLatin1String("text/html") && preferredType == QVariant::String) {
// text/html is in wide chars on windows (compatible with Mozilla) // 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 { } else {
val = data; // it should be enough to return the data and let QMimeData do the rest. 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)) { if (isCustomMimeType(mimeType)) {
// MSDN documentation for QueryGetData says only -1 is supported, so ignore lindex here. // MSDN documentation for QueryGetData says only -1 is supported, so ignore lindex here.
QString clipFormat = customMimeType(mimeType); QString clipFormat = customMimeType(mimeType);
int cf = RegisterClipboardFormat(reinterpret_cast<const wchar_t *> (clipFormat.utf16())); const UINT cf = RegisterClipboardFormat(reinterpret_cast<const wchar_t *> (clipFormat.utf16()));
return canGetData(cf, pDataObj); return canGetData(int(cf), pDataObj);
} else if (formats.keys(mimeType).isEmpty()) { } else if (formats.keys(mimeType).isEmpty()) {
// if it is not in there then register it and see if we can get it // if it is not in there then register it and see if we can get it
int cf = QWindowsMime::registerMimeType(mimeType); int cf = QWindowsMime::registerMimeType(mimeType);
@ -1449,8 +1441,8 @@ QVariant QLastResortMimes::convertToMime(const QString &mimeType, IDataObject *p
if (isCustomMimeType(mimeType)) { if (isCustomMimeType(mimeType)) {
int lindex; int lindex;
QString clipFormat = customMimeType(mimeType, &lindex); QString clipFormat = customMimeType(mimeType, &lindex);
int cf = RegisterClipboardFormat(reinterpret_cast<const wchar_t *> (clipFormat.utf16())); const UINT cf = RegisterClipboardFormat(reinterpret_cast<const wchar_t *> (clipFormat.utf16()));
data = getData(cf, pDataObj, lindex); data = getData(int(cf), pDataObj, lindex);
} else if (formats.keys(mimeType).isEmpty()) { } else if (formats.keys(mimeType).isEmpty()) {
int cf = QWindowsMime::registerMimeType(mimeType); int cf = QWindowsMime::registerMimeType(mimeType);
data = getData(cf, pDataObj); data = getData(cf, pDataObj);
@ -1599,7 +1591,7 @@ void QWindowsMimeConverter::ensureInitialized() const
QString QWindowsMimeConverter::clipboardFormatName(int cf) QString QWindowsMimeConverter::clipboardFormatName(int cf)
{ {
wchar_t buf[256] = {0}; wchar_t buf[256] = {0};
return GetClipboardFormatName(cf, buf, 255) return GetClipboardFormatName(UINT(cf), buf, 255)
? QString::fromWCharArray(buf) : QString(); ? QString::fromWCharArray(buf) : QString();
} }

View File

@ -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. // 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 // 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. // 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 & signatureMask) == miWpSignature) {
if (extraInfo & 0x80) { // Bit 7 indicates touch event, else tablet pen. if (extraInfo & 0x80) { // Bit 7 indicates touch event, else tablet pen.
source = Qt::MouseEventSynthesizedBySystem; source = Qt::MouseEventSynthesizedBySystem;
@ -250,7 +250,7 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd,
} }
QWindowsWindow *platformWindow = static_cast<QWindowsWindow *>(window->handle()); 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, // 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, // 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, bool QWindowsMouseHandler::translateMouseWheelEvent(QWindow *window, HWND,
MSG msg, LRESULT *) MSG msg, LRESULT *)
{ {
const Qt::KeyboardModifiers mods = keyStateToModifiers((int)msg.wParam); const Qt::KeyboardModifiers mods = keyStateToModifiers(int(msg.wParam));
int delta; int delta;
if (msg.message == WM_MOUSEWHEEL || msg.message == WM_MOUSEHWHEEL) if (msg.message == WM_MOUSEWHEEL || msg.message == WM_MOUSEHWHEEL)
delta = (short) HIWORD (msg.wParam); delta = HIWORD (msg.wParam);
else else
delta = (int) msg.wParam; delta = int(msg.wParam);
Qt::Orientation orientation = (msg.message == WM_MOUSEHWHEEL Qt::Orientation orientation = (msg.message == WM_MOUSEHWHEEL
|| (mods & Qt::AltModifier)) ? || (mods & Qt::AltModifier)) ?
@ -503,15 +503,17 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
return true; return true;
const QRect screenGeometry = screen->geometry(); const QRect screenGeometry = screen->geometry();
const int winTouchPointCount = msg.wParam; const int winTouchPointCount = int(msg.wParam);
QScopedArrayPointer<TOUCHINPUT> winTouchInputs(new TOUCHINPUT[winTouchPointCount]); QScopedArrayPointer<TOUCHINPUT> winTouchInputs(new TOUCHINPUT[winTouchPointCount]);
memset(winTouchInputs.data(), 0, sizeof(TOUCHINPUT) * winTouchPointCount); memset(winTouchInputs.data(), 0, sizeof(TOUCHINPUT) * size_t(winTouchPointCount));
QTouchPointList touchPoints; QTouchPointList touchPoints;
touchPoints.reserve(winTouchPointCount); touchPoints.reserve(winTouchPointCount);
Qt::TouchPointStates allStates = 0; 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) { for (int i = 0; i < winTouchPointCount; ++i) {
const TOUCHINPUT &winTouchInput = winTouchInputs[i]; const TOUCHINPUT &winTouchInput = winTouchInputs[i];
int id = m_touchInputIDToTouchPointID.value(winTouchInput.dwID, -1); int id = m_touchInputIDToTouchPointID.value(winTouchInput.dwID, -1);
@ -552,7 +554,7 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
touchPoints.append(touchPoint); 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 // all touch points released, forget the ids we've seen, they may not be reused
if (allStates == Qt::TouchPointReleased) if (allStates == Qt::TouchPointReleased)

View File

@ -99,13 +99,13 @@ static inline HBITMAP createDIB(HDC hdc, int width, int height,
bmi.blueMask = 0; bmi.blueMask = 0;
} }
void *bits = 0; uchar *bits = Q_NULLPTR;
HBITMAP bitmap = CreateDIBSection(hdc, reinterpret_cast<BITMAPINFO *>(&bmi), 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)) if (Q_UNLIKELY(!bitmap || !bits))
qFatal("%s: CreateDIBSection failed.", __FUNCTION__); qFatal("%s: CreateDIBSection failed.", __FUNCTION__);
*bitsIn = (uchar*)bits; *bitsIn = bits;
return bitmap; return bitmap;
} }
@ -118,7 +118,7 @@ QWindowsNativeImage::QWindowsNativeImage(int width, int height,
if (width != 0 && height != 0) { if (width != 0 && height != 0) {
uchar *bits; uchar *bits;
m_bitmap = createDIB(m_hdc, width, height, format, &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); m_image = QImage(bits, width, height, format);
Q_ASSERT(m_image.paintEngine()->type() == QPaintEngine::Raster); Q_ASSERT(m_image.paintEngine()->type() == QPaintEngine::Raster);
static_cast<QRasterPaintEngine *>(m_image.paintEngine())->setDC(m_hdc); static_cast<QRasterPaintEngine *>(m_image.paintEngine())->setDC(m_hdc);

View File

@ -221,7 +221,7 @@ QWindowsOleDataObject::EnumFormatEtc(DWORD dwDirection, LPENUMFORMATETC FAR* ppe
fmtetcs = mc.allFormatsForMime(data); fmtetcs = mc.allFormatsForMime(data);
} else { } else {
FORMATETC formatetc; FORMATETC formatetc;
formatetc.cfFormat = CF_PERFORMEDDROPEFFECT; formatetc.cfFormat = CLIPFORMAT(CF_PERFORMEDDROPEFFECT);
formatetc.dwAspect = DVASPECT_CONTENT; formatetc.dwAspect = DVASPECT_CONTENT;
formatetc.lindex = -1; formatetc.lindex = -1;
formatetc.ptd = NULL; formatetc.ptd = NULL;
@ -275,7 +275,7 @@ QWindowsOleEnumFmtEtc::QWindowsOleEnumFmtEtc(const QVector<FORMATETC> &fmtetcs)
m_lpfmtetcs.reserve(fmtetcs.count()); m_lpfmtetcs.reserve(fmtetcs.count());
for (int idx = 0; idx < fmtetcs.count(); ++idx) { for (int idx = 0; idx < fmtetcs.count(); ++idx) {
LPFORMATETC destetc = new FORMATETC(); LPFORMATETC destetc = new FORMATETC();
if (copyFormatEtc(destetc, (LPFORMATETC)&(fmtetcs.at(idx)))) { if (copyFormatEtc(destetc, &(fmtetcs.at(idx)))) {
m_lpfmtetcs.append(destetc); m_lpfmtetcs.append(destetc);
} else { } else {
m_isNull = true; m_isNull = true;
@ -369,14 +369,14 @@ QWindowsOleEnumFmtEtc::Next(ULONG celt, LPFORMATETC rgelt, ULONG FAR* pceltFetch
nOffset = m_nIndex + i; nOffset = m_nIndex + i;
if (nOffset < ULONG(m_lpfmtetcs.count())) { if (nOffset < ULONG(m_lpfmtetcs.count())) {
copyFormatEtc((LPFORMATETC)&(rgelt[i]), m_lpfmtetcs.at(nOffset)); copyFormatEtc(rgelt + i, m_lpfmtetcs.at(int(nOffset)));
i++; i++;
} else { } else {
break; break;
} }
} }
m_nIndex += (WORD)i; m_nIndex += i;
if (pceltFetched != NULL) if (pceltFetched != NULL)
*pceltFetched = i; *pceltFetched = i;
@ -403,7 +403,7 @@ QWindowsOleEnumFmtEtc::Skip(ULONG celt)
} }
} }
m_nIndex += (WORD)i; m_nIndex += i;
if (i != celt) if (i != celt)
return ResultFromScode(S_FALSE); return ResultFromScode(S_FALSE);
@ -437,7 +437,7 @@ QWindowsOleEnumFmtEtc::Clone(LPENUMFORMATETC FAR* newEnum)
return NOERROR; return NOERROR;
} }
bool QWindowsOleEnumFmtEtc::copyFormatEtc(LPFORMATETC dest, LPFORMATETC src) const bool QWindowsOleEnumFmtEtc::copyFormatEtc(LPFORMATETC dest, const FORMATETC *src) const
{ {
if (dest == NULL || src == NULL) if (dest == NULL || src == NULL)
return false; return false;

View File

@ -109,7 +109,7 @@ public:
STDMETHOD(Clone)(LPENUMFORMATETC FAR* newEnum); STDMETHOD(Clone)(LPENUMFORMATETC FAR* newEnum);
private: private:
bool copyFormatEtc(LPFORMATETC dest, LPFORMATETC src) const; bool copyFormatEtc(LPFORMATETC dest, const FORMATETC *src) const;
ULONG m_dwRefs; ULONG m_dwRefs;
ULONG m_nIndex; ULONG m_nIndex;

View File

@ -81,10 +81,10 @@ GpuDescription GpuDescription::detect()
const HRESULT hr = direct3D9->GetAdapterIdentifier(0, 0, &adapterIdentifier); const HRESULT hr = direct3D9->GetAdapterIdentifier(0, 0, &adapterIdentifier);
direct3D9->Release(); direct3D9->Release();
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
result.vendorId = int(adapterIdentifier.VendorId); result.vendorId = adapterIdentifier.VendorId;
result.deviceId = int(adapterIdentifier.DeviceId); result.deviceId = adapterIdentifier.DeviceId;
result.revision = int(adapterIdentifier.Revision); result.revision = adapterIdentifier.Revision;
result.subSysId = int(adapterIdentifier.SubSysId); result.subSysId = adapterIdentifier.SubSysId;
QVector<int> version(4, 0); QVector<int> version(4, 0);
version[0] = HIWORD(adapterIdentifier.DriverVersion.HighPart); // Product version[0] = HIWORD(adapterIdentifier.DriverVersion.HighPart); // Product
version[1] = LOWORD(adapterIdentifier.DriverVersion.HighPart); // Version version[1] = LOWORD(adapterIdentifier.DriverVersion.HighPart); // Version
@ -335,10 +335,10 @@ bool QWindowsOpenGLTester::testDesktopGL()
WNDCLASS wclass; WNDCLASS wclass;
wclass.cbClsExtra = 0; wclass.cbClsExtra = 0;
wclass.cbWndExtra = 0; wclass.cbWndExtra = 0;
wclass.hInstance = (HINSTANCE) GetModuleHandle(0); wclass.hInstance = static_cast<HINSTANCE>(GetModuleHandle(0));
wclass.hIcon = 0; wclass.hIcon = 0;
wclass.hCursor = 0; wclass.hCursor = 0;
wclass.hbrBackground = (HBRUSH) (COLOR_BACKGROUND); wclass.hbrBackground = HBRUSH(COLOR_BACKGROUND);
wclass.lpszMenuName = 0; wclass.lpszMenuName = 0;
wclass.lpfnWndProc = DefWindowProc; wclass.lpfnWndProc = DefWindowProc;
wclass.lpszClassName = className; wclass.lpszClassName = className;
@ -377,8 +377,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
typedef const GLubyte * (APIENTRY * GetString_t)(GLenum name); typedef const GLubyte * (APIENTRY * GetString_t)(GLenum name);
GetString_t GetString = reinterpret_cast<GetString_t>(::GetProcAddress(lib, "glGetString")); GetString_t GetString = reinterpret_cast<GetString_t>(::GetProcAddress(lib, "glGetString"));
if (GetString) { if (GetString) {
const char *versionStr = (const char *) GetString(GL_VERSION); if (const char *versionStr = reinterpret_cast<const char *>(GetString(GL_VERSION))) {
if (versionStr) {
const QByteArray version(versionStr); const QByteArray version(versionStr);
const int majorDot = version.indexOf('.'); const int majorDot = version.indexOf('.');
if (majorDot != -1) { if (majorDot != -1) {

View File

@ -57,10 +57,10 @@ struct GpuDescription
QString toString() const; QString toString() const;
QVariant toVariant() const; QVariant toVariant() const;
int vendorId; uint vendorId;
int deviceId; uint deviceId;
int revision; uint revision;
int subSysId; uint subSysId;
QVersionNumber driverVersion; QVersionNumber driverVersion;
QByteArray driverName; QByteArray driverName;
QByteArray description; QByteArray description;

View File

@ -158,7 +158,7 @@ BOOL QT_WIN_CALLBACK monitorEnumCallback(HMONITOR hMonitor, HDC, LPRECT, LPARAM
static inline WindowsScreenDataList monitorData() static inline WindowsScreenDataList monitorData()
{ {
WindowsScreenDataList result; WindowsScreenDataList result;
EnumDisplayMonitors(0, 0, monitorEnumCallback, (LPARAM)&result); EnumDisplayMonitors(0, 0, monitorEnumCallback, reinterpret_cast<LPARAM>(&result));
return 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 QPixmap QWindowsScreen::grabWindow(WId window, int x, int y, int width, int height) const
{ {
RECT r; RECT r;
HWND hwnd = window ? (HWND)window : GetDesktopWindow(); HWND hwnd = window ? reinterpret_cast<HWND>(window) : GetDesktopWindow();
GetClientRect(hwnd, &r); GetClientRect(hwnd, &r);
if (width < 0) width = r.right - r.left; if (width < 0) width = r.right - r.left;
@ -440,7 +440,7 @@ QWindowsScreenManager::QWindowsScreenManager() :
bool QWindowsScreenManager::handleDisplayChange(WPARAM wParam, LPARAM lParam) bool QWindowsScreenManager::handleDisplayChange(WPARAM wParam, LPARAM lParam)
{ {
const int newDepth = (int)wParam; const int newDepth = int(wParam);
const WORD newHorizontalResolution = LOWORD(lParam); const WORD newHorizontalResolution = LOWORD(lParam);
const WORD newVerticalResolution = HIWORD(lParam); const WORD newVerticalResolution = HIWORD(lParam);
if (newDepth != m_lastDepth || newHorizontalResolution != m_lastHorizontalResolution if (newDepth != m_lastDepth || newHorizontalResolution != m_lastHorizontalResolution

View File

@ -59,7 +59,10 @@ static inline bool shellExecute(const QUrl &url)
#ifndef Q_OS_WINCE #ifndef Q_OS_WINCE
const QString nativeFilePath = const QString nativeFilePath =
url.isLocalFile() ? QDir::toNativeSeparators(url.toLocalFile()) : url.toString(QUrl::FullyEncoded); 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 // ShellExecute returns a value greater than 32 if successful
if (result <= 32) { if (result <= 32) {
qWarning("ShellExecute '%s' failed (error %s).", qPrintable(url.toString()), qPrintable(QString::number(result))); qWarning("ShellExecute '%s' failed (error %s).", qPrintable(url.toString()), qPrintable(QString::number(result)));
@ -97,7 +100,7 @@ static inline QString mailCommand()
if (debug) if (debug)
qDebug() << __FUNCTION__ << "keyName=" << keyName; qDebug() << __FUNCTION__ << "keyName=" << keyName;
command[0] = 0; 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; DWORD bufferSize = BufferSize;
RegQueryValueEx(handle, L"", 0, 0, reinterpret_cast<unsigned char*>(command), &bufferSize); RegQueryValueEx(handle, L"", 0, 0, reinterpret_cast<unsigned char*>(command), &bufferSize);
RegCloseKey(handle); RegCloseKey(handle);
@ -140,7 +143,8 @@ static inline bool launchMail(const QUrl &url)
STARTUPINFO si; STARTUPINFO si;
ZeroMemory(&si, sizeof(si)); ZeroMemory(&si, sizeof(si));
si.cb = 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)); qErrnoWarning("Unable to launch '%s'", qPrintable(command));
return false; return false;
} }

View File

@ -322,7 +322,7 @@ QDebug operator<<(QDebug d, const QWindowsTabletDeviceData &t)
} }
#endif // !QT_NO_DEBUG_STREAM #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; QWindowsTabletDeviceData result;
result.uniqueId = uniqueId; result.uniqueId = uniqueId;

View File

@ -129,7 +129,7 @@ public:
private: private:
unsigned options() const; unsigned options() const;
QWindowsTabletDeviceData tabletInit(const quint64 uniqueId, const UINT cursorType) const; QWindowsTabletDeviceData tabletInit(qint64 uniqueId, UINT cursorType) const;
static QWindowsWinTab32DLL m_winTab32DLL; static QWindowsWinTab32DLL m_winTab32DLL;
const HWND m_window; const HWND m_window;

View File

@ -462,7 +462,9 @@ static QPixmap loadIconFromShell32(int resourceId, QSizeF size)
HMODULE hmod = QSystemLibrary::load(L"shell32"); HMODULE hmod = QSystemLibrary::load(L"shell32");
#endif #endif
if (hmod) { 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) { if (iconHandle) {
QPixmap iconpixmap = qt_pixmapFromWinHICON(iconHandle); QPixmap iconpixmap = qt_pixmapFromWinHICON(iconHandle);
DestroyIcon(iconHandle); DestroyIcon(iconHandle);
@ -592,7 +594,7 @@ QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) con
if (sp == FileLinkIcon || sp == DirLinkIcon || sp == DirLinkOpenIcon) { if (sp == FileLinkIcon || sp == DirLinkIcon || sp == DirLinkOpenIcon) {
QPainter painter(&pixmap); QPainter painter(&pixmap);
QPixmap link = loadIconFromShell32(30, pixmapSize); 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); pixmap.setDevicePixelRatio(scaleFactor);
return pixmap; return pixmap;
@ -667,7 +669,8 @@ static QPixmap pixmapFromShellImageList(int iImageList, const SHFILEINFO &info)
return result; return result;
IImageList *imageList = 0; 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) if (hr != S_OK)
return result; return result;
HICON hIcon; HICON hIcon;
@ -699,7 +702,7 @@ QPixmap QWindowsTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &s
QPixmap pixmap; QPixmap pixmap;
const QString filePath = QDir::toNativeSeparators(fileInfo.filePath()); 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 iconSize = width > 16 ? SHGFI_LARGEICON : SHGFI_SMALLICON;
const int requestedImageListSize = const int requestedImageListSize =
#ifdef USE_IIMAGELIST #ifdef USE_IIMAGELIST

View File

@ -1585,7 +1585,9 @@ void QWindowsWindow::handleGeometryChange()
// QTBUG-32121: OpenGL/normal windows (with exception of ANGLE) do not receive // QTBUG-32121: OpenGL/normal windows (with exception of ANGLE) do not receive
// expose events when shrinking, synthesize. // expose events when shrinking, synthesize.
if (!testFlag(OpenGL_ES2) && isExposed() 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); fireExpose(QRect(QPoint(0, 0), m_data.geometry.size()), true);
} }
if (previousGeometry.topLeft() != m_data.geometry.topLeft()) { 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. // 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 // This allows users to remove the margins by handling WM_NCCALCSIZE with WS_THICKFRAME set
// to ensure Areo snap still works (QTBUG-40578). // 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) ? QMargins(0, 0, 0, 0)
: QWindowsGeometryHint::frame(style(), exStyle()); : QWindowsGeometryHint::frame(style(), exStyle());
clearFlag(FrameDirty); clearFlag(FrameDirty);

View File

@ -44,6 +44,7 @@
#include "qtouchdevice.h" #include "qtouchdevice.h"
#include <qpa/qwindowsysteminterface.h> #include <qpa/qwindowsysteminterface.h>
#include <QDebug> #include <QDebug>
#include <cmath>
#ifdef XCB_USE_XINPUT2 #ifdef XCB_USE_XINPUT2

View File

@ -199,6 +199,7 @@ void QXcbDrag::startDrag()
XCB_ATOM_ATOM, 32, drag_types.size(), (const void *)drag_types.constData()); XCB_ATOM_ATOM, 32, drag_types.size(), (const void *)drag_types.constData());
setUseCompositing(current_virtual_desktop->compositingActive()); setUseCompositing(current_virtual_desktop->compositingActive());
setScreen(current_virtual_desktop->screens().constFirst()->screen());
QBasicDrag::startDrag(); QBasicDrag::startDrag();
if (connection()->mouseGrabber() == Q_NULLPTR) if (connection()->mouseGrabber() == Q_NULLPTR)
shapedPixmapWindow()->setMouseGrabEnabled(true); shapedPixmapWindow()->setMouseGrabEnabled(true);
@ -328,6 +329,9 @@ void QXcbDrag::move(const QPoint &globalPos)
if (virtualDesktop != current_virtual_desktop) { if (virtualDesktop != current_virtual_desktop) {
setUseCompositing(virtualDesktop->compositingActive()); setUseCompositing(virtualDesktop->compositingActive());
recreateShapedPixmapWindow(static_cast<QPlatformScreen*>(screen)->screen(), deviceIndependentPos); recreateShapedPixmapWindow(static_cast<QPlatformScreen*>(screen)->screen(), deviceIndependentPos);
if (connection()->mouseGrabber() == Q_NULLPTR)
shapedPixmapWindow()->setMouseGrabEnabled(true);
current_virtual_desktop = virtualDesktop; current_virtual_desktop = virtualDesktop;
} else { } else {
QBasicDrag::moveShapedPixmapWindow(deviceIndependentPos); QBasicDrag::moveShapedPixmapWindow(deviceIndependentPos);

View File

@ -214,7 +214,10 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, QXcbVirtualDesktop *virtualDe
m_geometry = QRect(QPoint(), m_virtualSize); m_geometry = QRect(QPoint(), m_virtualSize);
if (m_availableGeometry.isEmpty()) if (m_availableGeometry.isEmpty())
m_availableGeometry = m_geometry; m_availableGeometry = m_geometry & m_virtualDesktop->workArea();
if (m_sizeMillimeters.isEmpty())
m_sizeMillimeters = m_virtualSizeMillimeters;
readXResources(); readXResources();

View File

@ -56,6 +56,7 @@
#include "qxcbsystemtraytracker.h" #include "qxcbsystemtraytracker.h"
#include <qpa/qplatformintegration.h> #include <qpa/qplatformintegration.h>
#include <qpa/qplatformcursor.h>
#include <algorithm> #include <algorithm>
@ -267,6 +268,26 @@ static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s)
} }
#endif // XCB_USE_XLIB #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"; static const char *wm_window_type_property_id = "_q_xcb_wm_window_type";
QXcbWindow::QXcbWindow(QWindow *window) QXcbWindow::QXcbWindow(QWindow *window)
@ -861,6 +882,33 @@ void QXcbWindow::hide()
connection()->setMouseGrabber(Q_NULLPTR); connection()->setMouseGrabber(Q_NULLPTR);
m_mapped = false; 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) static QWindow *tlWindow(QWindow *window)

View File

@ -506,8 +506,8 @@ void QGtk3FontDialogHelper::hide()
static QString qt_fontToString(const QFont &font) static QString qt_fontToString(const QFont &font)
{ {
PangoFontDescription *desc = pango_font_description_new(); PangoFontDescription *desc = pango_font_description_new();
pango_font_description_set_size(desc, font.pointSizeF() * PANGO_SCALE); pango_font_description_set_size(desc, (font.pointSizeF() > 0.0 ? font.pointSizeF() : QFontInfo(font).pointSizeF()) * PANGO_SCALE);
pango_font_description_set_family(desc, font.family().toUtf8()); pango_font_description_set_family(desc, QFontInfo(font).family().toUtf8());
int weight = font.weight(); int weight = font.weight();
if (weight >= QFont::Black) if (weight >= QFont::Black)

View File

@ -319,6 +319,14 @@ QPointer<QWidget> qt_last_mouse_receiver = 0;
void QWidgetWindow::handleEnterLeaveEvent(QEvent *event) 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) { if (event->type() == QEvent::Leave) {
QWidget *enter = 0; QWidget *enter = 0;
// Check from window system event queue if the next queued enter targets a window // 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; QEvent::MouseButtonRelease : QEvent::MouseButtonPress;
if (qApp->d_func()->inPopupMode()) { if (qApp->d_func()->inPopupMode()) {
QWidget *activePopupWidget = qApp->activePopupWidget(); QWidget *activePopupWidget = qApp->activePopupWidget();
QWidget *popup = activePopupWidget;
QPoint mapped = event->pos(); QPoint mapped = event->pos();
if (popup != m_widget) if (activePopupWidget != m_widget)
mapped = popup->mapFromGlobal(event->globalPos()); mapped = activePopupWidget->mapFromGlobal(event->globalPos());
bool releaseAfter = false; 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_button_down = 0;
qt_popup_down = 0; qt_popup_down = 0;
} }
@ -429,7 +436,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
case QEvent::MouseButtonPress: case QEvent::MouseButtonPress:
case QEvent::MouseButtonDblClick: case QEvent::MouseButtonDblClick:
qt_button_down = popupChild; qt_button_down = popupChild;
qt_popup_down = popup; qt_popup_down = activePopupWidget;
break; break;
case QEvent::MouseButtonRelease: case QEvent::MouseButtonRelease:
releaseAfter = true; releaseAfter = true;
@ -440,18 +447,41 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
int oldOpenPopupCount = openPopupCount; int oldOpenPopupCount = openPopupCount;
if (popup->isEnabled()) { if (activePopupWidget->isEnabled()) {
// deliver event // deliver event
qt_replay_popup_mouse_event = false; qt_replay_popup_mouse_event = false;
QWidget *receiver = popup; QWidget *receiver = activePopupWidget;
QPoint widgetPos = mapped; QPoint widgetPos = mapped;
if (qt_button_down) if (qt_button_down)
receiver = qt_button_down; receiver = qt_button_down;
else if (popupChild) else if (popupChild)
receiver = popupChild; receiver = popupChild;
if (receiver != popup) if (receiver != activePopupWidget)
widgetPos = receiver->mapFromGlobal(event->globalPos()); 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(), QMouseEvent e(event->type(), widgetPos, event->windowPos(), event->screenPos(),
event->button(), event->buttons(), event->modifiers(), event->source()); event->button(), event->buttons(), event->modifiers(), event->source());
e.setTimestamp(event->timestamp()); e.setTimestamp(event->timestamp());
@ -463,7 +493,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
case QEvent::MouseButtonPress: case QEvent::MouseButtonPress:
case QEvent::MouseButtonDblClick: case QEvent::MouseButtonDblClick:
case QEvent::MouseButtonRelease: case QEvent::MouseButtonRelease:
popup->close(); activePopupWidget->close();
break; break;
default: default:
break; break;
@ -509,7 +539,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
} else if (event->type() == contextMenuTrigger } else if (event->type() == contextMenuTrigger
&& event->button() == Qt::RightButton && event->button() == Qt::RightButton
&& (openPopupCount == oldOpenPopupCount)) { && (openPopupCount == oldOpenPopupCount)) {
QWidget *popupEvent = popup; QWidget *popupEvent = activePopupWidget;
if (qt_button_down) if (qt_button_down)
popupEvent = qt_button_down; popupEvent = qt_button_down;
else if(popupChild) else if(popupChild)
@ -727,13 +757,24 @@ void QWidgetWindow::handleWheelEvent(QWheelEvent *event)
if (QApplicationPrivate::instance()->modalState() && !qt_try_modal(m_widget, event->type())) if (QApplicationPrivate::instance()->modalState() && !qt_try_modal(m_widget, event->type()))
return; 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? // which child should have it?
QWidget *widget = m_widget->childAt(event->pos()); QWidget *widget = rootWidget->childAt(pos);
if (!widget) 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()); 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); QGuiApplication::sendSpontaneousEvent(widget, &translated);

View File

@ -73,6 +73,9 @@ inline QPlatformNativeInterface::NativeResourceForIntegrationFunction resolvePla
\since 5.2 \since 5.2
Returns the native NSMenu for this menu. Available on OS X only. 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()
{ {
@ -139,6 +142,9 @@ void QMenuPrivate::moveWidgetToPlatformItem(QWidget *widget, QPlatformMenuItem*
\since 5.2 \since 5.2
Returns the native NSMenu for this menu bar. Available on OS X only. 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()
{ {

View File

@ -8,3 +8,5 @@ ubuntu-14.04
ubuntu-14.04 ubuntu-14.04
[setVisible] [setVisible]
ubuntu-14.04 ubuntu-14.04
[modalWindowEnterEventOnHide_QTBUG35109]
ubuntu-14.04

View File

@ -92,6 +92,9 @@ private slots:
void modalWithChildWindow(); void modalWithChildWindow();
void modalWindowModallity(); void modalWindowModallity();
void modalWindowPosition(); void modalWindowPosition();
#ifndef QT_NO_CURSOR
void modalWindowEnterEventOnHide_QTBUG35109();
#endif
void windowsTransientChildren(); void windowsTransientChildren();
void requestUpdate(); void requestUpdate();
void initTestCase(); void initTestCase();
@ -868,10 +871,24 @@ public:
} }
} }
} }
bool event(QEvent *e) {
switch (e->type()) {
case QEvent::Enter:
++enterEventCount;
break;
case QEvent::Leave:
++leaveEventCount;
break;
default:
break;
}
return QWindow::event(e);
}
void resetCounters() { void resetCounters() {
mousePressedCount = mouseReleasedCount = mouseMovedCount = mouseDoubleClickedCount = 0; mousePressedCount = mouseReleasedCount = mouseMovedCount = mouseDoubleClickedCount = 0;
mouseSequenceSignature = QString(); mouseSequenceSignature = QString();
touchPressedCount = touchReleasedCount = touchMovedCount = 0; touchPressedCount = touchReleasedCount = touchMovedCount = 0;
enterEventCount = leaveEventCount = 0;
} }
InputTestWindow() { InputTestWindow() {
@ -889,6 +906,7 @@ public:
QPointF mousePressScreenPos, mouseMoveScreenPos, mousePressLocalPos; QPointF mousePressScreenPos, mouseMoveScreenPos, mousePressLocalPos;
int touchPressedCount, touchReleasedCount, touchMovedCount; int touchPressedCount, touchReleasedCount, touchMovedCount;
QEvent::Type touchEventType; QEvent::Type touchEventType;
int enterEventCount, leaveEventCount;
bool ignoreMouse, ignoreTouch; bool ignoreMouse, ignoreTouch;
@ -1884,6 +1902,181 @@ void tst_QWindow::modalWindowPosition()
QCOMPARE(window.geometry(), origGeo); QCOMPARE(window.geometry(), origGeo);
} }
#ifndef QT_NO_CURSOR
void tst_QWindow::modalWindowEnterEventOnHide_QTBUG35109()
{
if (QGuiApplication::platformName() == QLatin1String("cocoa"))
QSKIP("This test fails on OS X on CI");
const QPoint center = QGuiApplication::primaryScreen()->availableGeometry().center();
const int childOffset = 16;
const QPoint rootPos = center - QPoint(m_testWindowSize.width(),
m_testWindowSize.height())/2;
const QPoint modalPos = rootPos + QPoint(childOffset * 5,
childOffset * 5);
const QPoint cursorPos = rootPos - QPoint(80, 80);
// Test whether tlw can receive the enter event
{
QCursor::setPos(cursorPos);
QCoreApplication::processEvents();
InputTestWindow root;
root.setTitle(__FUNCTION__);
root.setGeometry(QRect(rootPos, m_testWindowSize));
root.show();
QVERIFY(QTest::qWaitForWindowExposed(&root));
root.requestActivate();
QVERIFY(QTest::qWaitForWindowActive(&root));
// Move the mouse over the root window, but not over the modal window.
QCursor::setPos(rootPos + QPoint(childOffset * 5 / 2,
childOffset * 5 / 2));
// Wait for the enter event. It must be delivered here, otherwise second
// compare can PASS because of this event even after "resetCounters()".
QTRY_COMPARE(root.enterEventCount, 1);
QTRY_COMPARE(root.leaveEventCount, 0);
QWindow modal;
modal.setTitle(QLatin1String("Modal - ") + __FUNCTION__);
modal.setTransientParent(&root);
modal.resize(m_testWindowSize/2);
modal.setFramePosition(modalPos);
modal.setModality(Qt::ApplicationModal);
modal.show();
QVERIFY(QTest::qWaitForWindowExposed(&modal));
modal.requestActivate();
QVERIFY(QTest::qWaitForWindowActive(&modal));
QCoreApplication::processEvents();
QTRY_COMPARE(root.leaveEventCount, 1);
root.resetCounters();
modal.close();
// Check for the enter event
QTRY_COMPARE(root.enterEventCount, 1);
}
// Test whether child window can receive the enter event
{
QCursor::setPos(cursorPos);
QCoreApplication::processEvents();
QWindow root;
root.setTitle(__FUNCTION__);
root.setGeometry(QRect(rootPos, m_testWindowSize));
QWindow childLvl1;
childLvl1.setParent(&root);
childLvl1.setGeometry(childOffset,
childOffset,
m_testWindowSize.width() - childOffset,
m_testWindowSize.height() - childOffset);
InputTestWindow childLvl2;
childLvl2.setParent(&childLvl1);
childLvl2.setGeometry(childOffset,
childOffset,
childLvl1.width() - childOffset,
childLvl1.height() - childOffset);
root.show();
childLvl1.show();
childLvl2.show();
QVERIFY(QTest::qWaitForWindowExposed(&root));
root.requestActivate();
QVERIFY(QTest::qWaitForWindowActive(&root));
QVERIFY(childLvl1.isVisible());
QVERIFY(childLvl2.isVisible());
// Move the mouse over the child window, but not over the modal window.
// Be sure that the value is almost left-top of second child window for
// checking proper position mapping.
QCursor::setPos(rootPos + QPoint(childOffset * 5 / 2,
childOffset * 5 / 2));
// Wait for the enter event. It must be delivered here, otherwise second
// compare can PASS because of this event even after "resetCounters()".
QTRY_COMPARE(childLvl2.enterEventCount, 1);
QTRY_COMPARE(childLvl2.leaveEventCount, 0);
QWindow modal;
modal.setTitle(QLatin1String("Modal - ") + __FUNCTION__);
modal.setTransientParent(&root);
modal.resize(m_testWindowSize/2);
modal.setFramePosition(modalPos);
modal.setModality(Qt::ApplicationModal);
modal.show();
QVERIFY(QTest::qWaitForWindowExposed(&modal));
modal.requestActivate();
QVERIFY(QTest::qWaitForWindowActive(&modal));
QCoreApplication::processEvents();
QTRY_COMPARE(childLvl2.leaveEventCount, 1);
childLvl2.resetCounters();
modal.close();
// Check for the enter event
QTRY_COMPARE(childLvl2.enterEventCount, 1);
}
// Test whether tlw can receive the enter event if mouse is over the invisible child windnow
{
QCursor::setPos(cursorPos);
QCoreApplication::processEvents();
InputTestWindow root;
root.setTitle(__FUNCTION__);
root.setGeometry(QRect(rootPos, m_testWindowSize));
QWindow child;
child.setParent(&root);
child.setGeometry(QRect(QPoint(), m_testWindowSize));
root.show();
QVERIFY(QTest::qWaitForWindowExposed(&root));
root.requestActivate();
QVERIFY(QTest::qWaitForWindowActive(&root));
QVERIFY(!child.isVisible());
// Move the mouse over the child window, but not over the modal window.
QCursor::setPos(rootPos + QPoint(childOffset * 5 / 2,
childOffset * 5 / 2));
// Wait for the enter event. It must be delivered here, otherwise second
// compare can PASS because of this event even after "resetCounters()".
QTRY_COMPARE(root.enterEventCount, 1);
QTRY_COMPARE(root.leaveEventCount, 0);
QWindow modal;
modal.setTitle(QLatin1String("Modal - ") + __FUNCTION__);
modal.setTransientParent(&root);
modal.resize(m_testWindowSize/2);
modal.setFramePosition(modalPos);
modal.setModality(Qt::ApplicationModal);
modal.show();
QVERIFY(QTest::qWaitForWindowExposed(&modal));
modal.requestActivate();
QVERIFY(QTest::qWaitForWindowActive(&modal));
QCoreApplication::processEvents();
QTRY_COMPARE(root.leaveEventCount, 1);
root.resetCounters();
modal.close();
// Check for the enter event
QTRY_COMPARE(root.enterEventCount, 1);
}
}
#endif
static bool isNativeWindowVisible(const QWindow *window) static bool isNativeWindowVisible(const QWindow *window)
{ {
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)

View File

@ -4,3 +4,4 @@ rhel-7.1
[setFont] [setFont]
ubuntu-14.04 ubuntu-14.04
redhatenterpriselinuxworkstation-6.6 redhatenterpriselinuxworkstation-6.6
rhel-7.1

View File

@ -0,0 +1,2 @@
[setSortingEnabledChild]
windows

View File

@ -4,5 +4,3 @@ QT += widgets testlib
QT += widgets-private gui-private core-private QT += widgets-private gui-private core-private
SOURCES += tst_qtreeview.cpp SOURCES += tst_qtreeview.cpp
HEADERS += ../../../../shared/fakedirmodel.h HEADERS += ../../../../shared/fakedirmodel.h
win32: CONFIG += insignificant_test

View File

@ -189,7 +189,8 @@ private slots:
void hiddenItems(); void hiddenItems();
void spanningItems(); void spanningItems();
void rowSizeHint(); void rowSizeHint();
void setSortingEnabled(); void setSortingEnabledTopLevel();
void setSortingEnabledChild();
void headerHidden(); void headerHidden();
void indentation(); void indentation();
@ -2501,9 +2502,8 @@ void tst_QTreeView::rowSizeHint()
//From task 155449 (QTreeWidget has a large width for the first section when sorting //From task 155449 (QTreeWidget has a large width for the first section when sorting
//is turned on before items are added) //is turned on before items are added)
void tst_QTreeView::setSortingEnabled()
{ void tst_QTreeView::setSortingEnabledTopLevel()
//1st the treeview is a top-level
{ {
QTreeView view; QTreeView view;
QStandardItemModel model(1,1); QStandardItemModel model(1,1);
@ -2515,7 +2515,7 @@ void tst_QTreeView::setSortingEnabled()
QCOMPARE(view.header()->sectionSize(0), size); QCOMPARE(view.header()->sectionSize(0), size);
} }
//then it is no more a top-level void tst_QTreeView::setSortingEnabledChild()
{ {
QMainWindow win; QMainWindow win;
QTreeView view; QTreeView view;
@ -2528,7 +2528,6 @@ void tst_QTreeView::setSortingEnabled()
//we test that changing the column count doesn't change the 1st column size //we test that changing the column count doesn't change the 1st column size
QCOMPARE(view.header()->sectionSize(0), size); QCOMPARE(view.header()->sectionSize(0), size);
} }
}
void tst_QTreeView::headerHidden() void tst_QTreeView::headerHidden()
{ {

View File

@ -492,9 +492,10 @@ void tst_QMdiArea::subWindowActivated2()
spy.clear(); spy.clear();
mdiArea.show(); mdiArea.show();
QVERIFY(QTest::qWaitForWindowExposed(&mdiArea)); QVERIFY(QTest::qWaitForWindowActive(&mdiArea));
QTRY_COMPARE(spy.count(), 1); QTRY_COMPARE(spy.count(), 1);
QCOMPARE(mdiArea.activeSubWindow(), activeSubWindow); QVERIFY(mdiArea.currentSubWindow());
QTRY_COMPARE(mdiArea.activeSubWindow(), activeSubWindow);
spy.clear(); spy.clear();
if (qGuiApp->styleHints()->showIsFullScreen()) if (qGuiApp->styleHints()->showIsFullScreen())

View File

@ -105,6 +105,9 @@ private slots:
void QTBUG7411_submenus_activate(); void QTBUG7411_submenus_activate();
void QTBUG30595_rtl_submenu(); void QTBUG30595_rtl_submenu();
void QTBUG20403_nested_popup_on_shortcut_trigger(); void QTBUG20403_nested_popup_on_shortcut_trigger();
#ifndef QT_NO_CURSOR
void QTBUG47515_widgetActionEnterLeave();
#endif
void QTBUG_10735_crashWithDialog(); void QTBUG_10735_crashWithDialog();
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
void QTBUG_37933_ampersands_data(); void QTBUG_37933_ampersands_data();
@ -1066,6 +1069,112 @@ void tst_QMenu::QTBUG20403_nested_popup_on_shortcut_trigger()
QVERIFY(!subsub1.isVisible()); QVERIFY(!subsub1.isVisible());
} }
class MyWidget : public QWidget
{
public:
MyWidget(QWidget *parent) :
QWidget(parent),
move(0), enter(0), leave(0)
{
setMinimumSize(100, 100);
setMouseTracking(true);
}
bool event(QEvent *e) Q_DECL_OVERRIDE
{
switch (e->type()) {
case QEvent::MouseMove:
++move;
break;
case QEvent::Enter:
++enter;
break;
case QEvent::Leave:
++leave;
break;
default:
break;
}
return QWidget::event(e);
}
int move, enter, leave;
};
#ifndef QT_NO_CURSOR
void tst_QMenu::QTBUG47515_widgetActionEnterLeave()
{
if (QGuiApplication::platformName() == QLatin1String("cocoa"))
QSKIP("This test fails on OS X on CI");
const QPoint center = QGuiApplication::primaryScreen()->availableGeometry().center();
const QPoint cursorPos = center - QPoint(100, 100);
QScopedPointer<QMenu> menu1(new QMenu("Menu1"));
QScopedPointer<QMenu> menu2(new QMenu("Menu2"));
QWidgetAction *wA1 = new QWidgetAction(menu1.data());
MyWidget *w1 = new MyWidget(menu1.data());
wA1->setDefaultWidget(w1);
QWidgetAction *wA2 = new QWidgetAction(menu2.data());
MyWidget *w2 = new MyWidget(menu2.data());
wA2->setDefaultWidget(w2);
QAction *nextMenuAct = menu1->addMenu(menu2.data());
menu1->addAction(wA1);
menu2->addAction(wA2);
// Root menu
{
QCursor::setPos(cursorPos);
QCoreApplication::processEvents();
menu1->popup(center);
QVERIFY(QTest::qWaitForWindowExposed(menu1.data()));
QCursor::setPos(w1->mapToGlobal(w1->rect().center()));
QVERIFY(w1->isVisible());
QTRY_COMPARE(w1->leave, 0);
QTRY_COMPARE(w1->enter, 1);
// Check whether leave event is not delivered on mouse move
w1->move = 0;
QCursor::setPos(w1->mapToGlobal(w1->rect().center()) + QPoint(1, 1));
QTRY_COMPARE(w1->move, 1);
QTRY_COMPARE(w1->leave, 0);
QTRY_COMPARE(w1->enter, 1);
QCursor::setPos(cursorPos);
QTRY_COMPARE(w1->leave, 1);
QTRY_COMPARE(w1->enter, 1);
}
// Submenu
{
menu1->setActiveAction(nextMenuAct);
QVERIFY(QTest::qWaitForWindowExposed(menu2.data()));
QCursor::setPos(w2->mapToGlobal(w2->rect().center()));
QVERIFY(w2->isVisible());
QTRY_COMPARE(w2->leave, 0);
QTRY_COMPARE(w2->enter, 1);
// Check whether leave event is not delivered on mouse move
w2->move = 0;
QCursor::setPos(w2->mapToGlobal(w2->rect().center()) + QPoint(1, 1));
QTRY_COMPARE(w2->move, 1);
QTRY_COMPARE(w2->leave, 0);
QTRY_COMPARE(w2->enter, 1);
QCursor::setPos(cursorPos);
QTRY_COMPARE(w2->leave, 1);
QTRY_COMPARE(w2->enter, 1);
}
}
#endif // !QT_NO_CURSOR
class MyMenu : public QMenu class MyMenu : public QMenu
{ {
Q_OBJECT Q_OBJECT