Merge remote-tracking branch 'origin/5.4' into dev

Conflicts:
	src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro
	src/gui/image/qimage_conversions.cpp
	src/gui/opengl/qopenglextensions_p.h
	src/gui/text/qtextengine.cpp
	src/network/ssl/qsslsocket_openssl.cpp
	src/plugins/platforms/eglfs/qeglfshooks_stub.cpp
	src/plugins/platforms/eglfs/qeglfsscreen.cpp
	src/plugins/platforms/eglfs/qeglfswindow.cpp
	src/plugins/platforms/windows/qwindowsfontdatabase.cpp
	src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp
	src/plugins/platforms/windows/qwindowsnativeinterface.cpp
	src/plugins/platforms/windows/qwindowsscreen.cpp
	src/plugins/platforms/windows/qwindowswindow.cpp
	src/plugins/platforms/windows/qwindowswindow.h
	src/plugins/platforms/xcb/qxcbdrag.h
	src/widgets/itemviews/qabstractitemview.cpp
	src/widgets/kernel/qwidget.cpp
	src/widgets/util/qsystemtrayicon_p.h
	tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp

Thanks to Friedemann Kleint for resolving the qwindowsfontdatabase.cpp
conflicts.

Change-Id: I937232c30523d5121c195d947d92aec6f129b03e
This commit is contained in:
Frederik Gladhorn 2015-02-10 09:32:16 +01:00
commit fc35f71434
187 changed files with 2448 additions and 1039 deletions

View File

@ -1,6 +1,6 @@
GNU LESSER GENERAL PUBLIC LICENSE
The Qt Toolkit is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
The Qt Toolkit is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
Contact: http://www.qt-project.org/legal
You may use, distribute and copy the Qt GUI Toolkit under the terms of

View File

@ -1,6 +1,6 @@
GNU LESSER GENERAL PUBLIC LICENSE
The Qt Toolkit is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
The Qt Toolkit is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
Contact: http://www.qt-project.org/legal
You may use, distribute and copy the Qt GUI Toolkit under the terms of

View File

@ -3,7 +3,7 @@
dita.metadata.default.author = Qt Project
dita.metadata.default.permissions = all
dita.metadata.default.publisher = Qt Project
dita.metadata.default.copyryear = 2014
dita.metadata.default.copyryear = 2015
dita.metadata.default.copyrholder = Digia Plc
dita.metadata.default.audience = programmer

View File

@ -76,7 +76,7 @@ HTML.footer += \
"<div class=\"container clearfix no_discs\">\n" \
" <ul id=\"menu-footer-submenu\" class=\"right clearfix\"><li id=\"menu-item-1795\" class=\"menu-item menu-item-type-custom menu-item-object-custom menu-item-1795\"><a title=\"Sign into your account.\" href=\"https://account.qt.io/login\">Sign In</a></li>\n" \
" <li id=\"menu-item-1494\" class=\"menu-item menu-item-type-post_type menu-item-object-page menu-item-1494\"><a href=\"http://qt.io/contact-us/\">Contact us</a></li>\n" \
" <li id=\"menu-item-4472\" class=\"menu-item menu-item-type-custom menu-item-object-custom menu-item-4472\"><a href=\"http://www.digia.com\">© 2014 Digia Oyj</a></li>\n" \
" <li id=\"menu-item-4472\" class=\"menu-item menu-item-type-custom menu-item-object-custom menu-item-4472\"><a href=\"http://www.digia.com\">© 2015 Digia Oyj</a></li>\n" \
" </ul>\n" \
"</div>\n" \
"</div>\n" \

View File

@ -8,7 +8,7 @@ HTML.footer = \
"</div>\n" \
"<div class=\"footer\">\n" \
" <p>\n" \
" <acronym title=\"Copyright\">&copy;</acronym> 2014 Digia Plc and/or its\n" \
" <acronym title=\"Copyright\">&copy;</acronym> 2015 Digia Plc and/or its\n" \
" subsidiaries. Documentation contributions included herein are the copyrights of\n" \
" their respective owners.<br>" \
" The documentation provided herein is licensed under the terms of the" \

View File

@ -5,7 +5,7 @@
HTML.footer = \
" </div>\n" \
" <p class=\"copy-notice\">\n" \
" <acronym title=\"Copyright\">&copy;</acronym> 2014 Digia Plc and/or its\n" \
" <acronym title=\"Copyright\">&copy;</acronym> 2015 Digia Plc and/or its\n" \
" subsidiaries. Documentation contributions included herein are the copyrights of\n" \
" their respective owners. " \
" The documentation provided herein is licensed under the terms of the" \

View File

@ -235,3 +235,6 @@ QMAKE_LIBS_OPENGL_ES2 = -lGLESv2
!exists($$NDK_ROOT): error("You need to set the ANDROID_NDK_ROOT environment variable to point to your Android NDK.")
load(qt_config)
QMAKE_DEFAULT_LIBDIRS = $$QMAKE_LIBDIR
QMAKE_DEFAULT_INCDIRS = $$QMAKE_INCDIR

View File

@ -171,8 +171,6 @@ contains(CONFIG, plugin) {
return()
}
unix:contains(QT_CONFIG, reduce_relocations):CMAKE_ADD_FPIE_FLAGS = "true"
CMAKE_MKSPEC = $$[QMAKE_XSPEC]
CMAKE_MODULE_DEPS = $$cmakeModuleList($$sort_depends(QT.$${MODULE}.depends, QT.))

View File

@ -21,9 +21,6 @@ debug_and_release:debug_and_release_target {
TEST_TARGET_DIR = $$relative_path($$absolute_path($$DESTDIR, $$OUT_PWD), $$absolute_path($$TESTRUN_CWD, $$OUT_PWD))
}
!isEmpty(TESTRUN_CWD):!contains(TESTRUN_CWD,^\\./?): \
check.commands = cd $$shell_path($$TESTRUN_CWD) &&
# Allow for a custom test runner script
check.commands += $(TESTRUNNER)
@ -46,6 +43,10 @@ check.commands += $(TESTARGS)
# Add environment for non-installed builds
qtAddTargetEnv(check.commands, QT)
# This must happen after adding the environment.
!isEmpty(TESTRUN_CWD):!contains(TESTRUN_CWD, ^\\./?): \
check.commands = cd $$shell_path($$TESTRUN_CWD) && $$check.commands
# If the test is marked as insignificant, discard the exit code
insignificant_test:check.commands = -$${check.commands}

View File

@ -7,7 +7,12 @@ CONFIG += \
load(qt_helper_lib)
DEFINES += HAVE_OT HAVE_ATEXIT HB_NO_UNICODE_FUNCS HB_DISABLE_DEPRECATED
DEFINES += HAVE_OT HB_NO_UNICODE_FUNCS HB_DISABLE_DEPRECATED
# platform/compiler specific definitions
DEFINES += HAVE_ATEXIT
gcc: DEFINES += HAVE_INTEL_ATOMIC_PRIMITIVES
unix: DEFINES += HAVE_PTHREAD HAVE_SCHED_H HAVE_SCHED_YIELD
win32: DEFINES += HB_NO_WIN1256
INCLUDEPATH += $$PWD/include

View File

@ -66,14 +66,12 @@ list(APPEND Qt5Core_INCLUDE_DIRS ${_qt5_corelib_extra_includes})
set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${_qt5_corelib_extra_includes})
set(_qt5_corelib_extra_includes)
!!IF !isEmpty(CMAKE_ADD_FPIE_FLAGS)
# Targets using Qt need to use the POSITION_INDEPENDENT_CODE property. The
# Qt5_POSITION_INDEPENDENT_CODE variable is used in the # qt5_use_module
# macro to add it.
set(Qt5_POSITION_INDEPENDENT_CODE True)
set_property(TARGET Qt5::Core PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE \"ON\")
set(Qt5Core_EXECUTABLE_COMPILE_FLAGS \"-fPIE\")
!!ENDIF
!!IF !isEmpty(QT_NAMESPACE)
list(APPEND Qt5Core_DEFINITIONS -DQT_NAMESPACE=$$QT_NAMESPACE)

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
** Copyright (C) 2014 Intel Corporation
** Contact: http://www.qt-project.org/legal
**
@ -622,7 +622,7 @@ extern "C" void qt_core_boilerplate();
void qt_core_boilerplate()
{
printf("This is the QtCore library version " QT_BUILD_STR "\n"
"Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).\n"
"Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).\n"
"Contact: http://www.qt-project.org/legal\n"
"\n"
"Build date: %s\n"

View File

@ -83,13 +83,13 @@ static bool isPackage(const QFileSystemMetaData &data, const QFileSystemEntry &e
if (suffix.length() > 0) {
// First step: is the extension known ?
CFStringRef extensionRef = QCFString::toCFStringRef(suffix);
CFStringRef uniformTypeIdentifier = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, extensionRef, NULL);
QCFType<CFStringRef> extensionRef = QCFString::toCFStringRef(suffix);
QCFType<CFStringRef> uniformTypeIdentifier = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, extensionRef, NULL);
if (UTTypeConformsTo(uniformTypeIdentifier, kUTTypeBundle))
return true;
// Second step: check if an application knows the package type
CFStringRef path = QCFString::toCFStringRef(entry.filePath());
QCFType<CFStringRef> path = QCFString::toCFStringRef(entry.filePath());
QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(0, path, kCFURLPOSIXPathStyle, true);
UInt32 type, creator;

View File

@ -1043,9 +1043,9 @@ bool QProcessPrivate::_q_processDied()
return false;
#endif
#ifdef Q_OS_WIN
drainOutputPipes();
if (processFinishedNotifier)
processFinishedNotifier->setEnabled(false);
drainOutputPipes();
#endif
// the process may have died before it got a chance to report that it was

View File

@ -785,6 +785,7 @@ bool QProcessPrivate::waitForFinished(int msecs)
void QProcessPrivate::findExitCode()
{
DWORD theExitCode;
Q_ASSERT(pid);
if (GetExitCodeProcess(pid->hProcess, &theExitCode)) {
exitCode = theExitCode;
crashed = (exitCode == 0xf291 // our magic number, see killProcess

View File

@ -128,8 +128,11 @@ static char *q_mkdtemp(char *templateName)
QFile::ReadOwner |
QFile::WriteOwner |
QFile::ExeOwner, error);
if (error.error() != 0)
if (error.error() != 0) {
if (!QFileSystemEngine::removeDirectory(fileSystemEntry, false))
qWarning() << "Unable to remove unused directory" << templateNameStr;
continue;
}
return templateName;
}
}

View File

@ -1574,11 +1574,10 @@ QString QTextStream::readAll()
the stream contains lines longer than this, then the lines will be
split after \a maxlen characters and returned in parts.
If \a maxlen is 0, the lines can be of any length. A common value
for \a maxlen is 75.
If \a maxlen is 0, the lines can be of any length.
The returned line has no trailing end-of-line characters ("\\n"
or "\\r\\n"), so calling QString::trimmed() is unnecessary.
or "\\r\\n"), so calling QString::trimmed() can be unnecessary.
If the stream has read to the end of the file, \l {QTextStream::readLine()}{readLine()}
will return a null QString. For strings, or for devices that support it,

View File

@ -54,7 +54,13 @@ QUrl QUrl::fromCFURL(CFURLRef url)
CFURLRef QUrl::toCFURL() const
{
return CFURLCreateWithString(0, toString(FullyEncoded).toCFString(), 0);
CFURLRef url = 0;
CFStringRef str = toString(FullyEncoded).toCFString();
if (str) {
url = CFURLCreateWithString(0, str, 0);
CFRelease(str);
}
return url;
}
QUrl QUrl::fromNSURL(const NSURL *url)

View File

@ -539,7 +539,7 @@ QTimerEvent::~QTimerEvent()
\a child.
\a type can be QEvent::ChildAdded, QEvent::ChildRemoved,
QEvent::ChildPolished, or QEvent::ChildRemoved.
or QEvent::ChildPolished.
\sa child()
*/

View File

@ -3711,13 +3711,14 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i
} else if (callFunction && c->method_offset <= receiver->metaObject()->methodOffset()) {
//we compare the vtable to make sure we are not in the destructor of the object.
locker.unlock();
const int methodIndex = c->method();
if (qt_signal_spy_callback_set.slot_begin_callback != 0)
qt_signal_spy_callback_set.slot_begin_callback(receiver, c->method(), argv ? argv : empty_argv);
qt_signal_spy_callback_set.slot_begin_callback(receiver, methodIndex, argv ? argv : empty_argv);
callFunction(receiver, QMetaObject::InvokeMetaMethod, method_relative, argv ? argv : empty_argv);
if (qt_signal_spy_callback_set.slot_end_callback != 0)
qt_signal_spy_callback_set.slot_end_callback(receiver, c->method());
qt_signal_spy_callback_set.slot_end_callback(receiver, methodIndex);
locker.relock();
} else {
const int method = method_relative + c->method_offset;

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtCore module of the Qt Toolkit.
@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE
static const char boilerplate_supported_but_time_limited[] =
"\nQt %1 Evaluation License\n"
"Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).\n"
"Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).\n"
"This trial version may only be used for evaluation purposes\n"
"and will shut down after 120 minutes.\n"
"Registered to:\n"
@ -57,7 +57,7 @@ static const char boilerplate_supported_but_time_limited[] =
static const char boilerplate_supported[] =
"\nQt %1 Evaluation License\n"
"Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).\n"
"Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).\n"
"This trial version may only be used for evaluation purposes\n"
"Registered to:\n"
" Licensee: %2\n\n"

View File

@ -334,7 +334,7 @@ QDataStream &operator>>(QDataStream &stream, QLine &line)
or a null line.
The intersect() function determines the IntersectType for this
line and a given line, while the angle() function returns the
line and a given line, while the angleTo() function returns the
angle between the lines. In addition, the unitVector() function
returns a line that has the same starting point as this line, but
with a length of only 1, while the normalVector() function returns

View File

@ -56,7 +56,9 @@ struct QPair
{ first = p.first; second = p.second; return *this; }
#ifdef Q_COMPILER_RVALUE_REFS
template <typename TT1, typename TT2>
Q_DECL_CONSTEXPR QPair(QPair<TT1, TT2> &&p) : first(std::move(p.first)), second(std::move(p.second)) {}
Q_DECL_CONSTEXPR QPair(QPair<TT1, TT2> &&p)
// can't use std::move here as it's not constexpr in C++11:
: first(static_cast<TT1 &&>(p.first)), second(static_cast<TT2 &&>(p.second)) {}
template <typename TT1, typename TT2>
Q_DECL_RELAXED_CONSTEXPR QPair &operator=(QPair<TT1, TT2> &&p)
{ first = std::move(p.first); second = std::move(p.second); return *this; }

View File

@ -412,6 +412,7 @@ public:
# ifdef QT_SHAREDPOINTER_TRACK_POINTERS
internalSafetyCheckAdd(result.d, result.value);
# endif
result.enableSharedFromThis(result.data());
return result;
}
#else
@ -432,6 +433,7 @@ public:
internalSafetyCheckAdd(result.d, result.value);
# endif
result.d->setQObjectShared(result.value, true);
result.enableSharedFromThis(result.data());
return result;
}

View File

@ -64,6 +64,8 @@ QT_BEGIN_NAMESPACE
#include "qxmlstream_p.h"
enum { StreamEOF = ~0U };
/*!
\enum QXmlStreamReader::TokenType
@ -903,7 +905,7 @@ inline uint QXmlStreamReaderPrivate::filterCarriageReturn()
++readBufferPos;
return peekc;
}
if (peekc == 0) {
if (peekc == StreamEOF) {
putChar('\r');
return 0;
}
@ -912,13 +914,13 @@ inline uint QXmlStreamReaderPrivate::filterCarriageReturn()
/*!
\internal
If the end of the file is encountered, 0 is returned.
If the end of the file is encountered, ~0 is returned.
*/
inline uint QXmlStreamReaderPrivate::getChar()
{
uint c;
if (putStack.size()) {
c = atEnd ? 0 : putStack.pop();
c = atEnd ? StreamEOF : putStack.pop();
} else {
if (readBufferPos < readBuffer.size())
c = readBuffer.at(readBufferPos++).unicode();
@ -937,7 +939,7 @@ inline uint QXmlStreamReaderPrivate::peekChar()
} else if (readBufferPos < readBuffer.size()) {
c = readBuffer.at(readBufferPos).unicode();
} else {
if ((c = getChar_helper()))
if ((c = getChar_helper()) != StreamEOF)
--readBufferPos;
}
@ -961,7 +963,8 @@ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
int pos = textBuffer.size();
int oldLineNumber = lineNumber;
while (uint c = getChar()) {
uint c;
while ((c = getChar()) != StreamEOF) {
/* First, we do the validation & normalization. */
switch (c) {
case '\r':
@ -1007,9 +1010,9 @@ bool QXmlStreamReaderPrivate::scanString(const char *str, short tokenToInject, b
{
int n = 0;
while (str[n]) {
ushort c = getChar();
uint c = getChar();
if (c != ushort(str[n])) {
if (c)
if (c != StreamEOF)
putChar(c);
while (n--) {
putChar(ushort(str[n]));
@ -1137,7 +1140,7 @@ inline int QXmlStreamReaderPrivate::fastScanLiteralContent()
{
int n = 0;
uint c;
while ((c = getChar())) {
while ((c = getChar()) != StreamEOF) {
switch (ushort(c)) {
case 0xfffe:
case 0xffff:
@ -1182,8 +1185,8 @@ inline int QXmlStreamReaderPrivate::fastScanLiteralContent()
inline int QXmlStreamReaderPrivate::fastScanSpace()
{
int n = 0;
ushort c;
while ((c = getChar())) {
uint c;
while ((c = getChar()) != StreamEOF) {
switch (c) {
case '\r':
if ((c = filterCarriageReturn()) == 0)
@ -1216,7 +1219,7 @@ inline int QXmlStreamReaderPrivate::fastScanContentCharList()
{
int n = 0;
uint c;
while ((c = getChar())) {
while ((c = getChar()) != StreamEOF) {
switch (ushort(c)) {
case 0xfffe:
case 0xffff:
@ -1279,8 +1282,8 @@ inline int QXmlStreamReaderPrivate::fastScanContentCharList()
inline int QXmlStreamReaderPrivate::fastScanName(int *prefix)
{
int n = 0;
ushort c;
while ((c = getChar())) {
uint c;
while ((c = getChar()) != StreamEOF) {
switch (c) {
case '\n':
case ' ':
@ -1396,7 +1399,7 @@ inline int QXmlStreamReaderPrivate::fastScanNMTOKEN()
{
int n = 0;
uint c;
while ((c = getChar())) {
while ((c = getChar()) != StreamEOF) {
if (fastDetermineNameChar(c) == NotName) {
putChar(c);
return n;
@ -1452,7 +1455,7 @@ void QXmlStreamReaderPrivate::putReplacementInAttributeValue(const QString &s)
}
}
ushort QXmlStreamReaderPrivate::getChar_helper()
uint QXmlStreamReaderPrivate::getChar_helper()
{
const int BUFFER_SIZE = 8192;
characterOffset += readBufferPos;
@ -1476,7 +1479,7 @@ ushort QXmlStreamReaderPrivate::getChar_helper()
}
if (!nbytesread) {
atEnd = true;
return 0;
return StreamEOF;
}
#ifndef QT_NO_TEXTCODEC
@ -1484,7 +1487,7 @@ ushort QXmlStreamReaderPrivate::getChar_helper()
if (nbytesread < 4) { // the 4 is to cover 0xef 0xbb 0xbf plus
// one extra for the utf8 codec
atEnd = true;
return 0;
return StreamEOF;
}
int mib = 106; // UTF-8
@ -1517,7 +1520,7 @@ ushort QXmlStreamReaderPrivate::getChar_helper()
if(lockEncoding && decoder->hasFailure()) {
raiseWellFormedError(QXmlStream::tr("Encountered incorrectly encoded content."));
readBuffer.clear();
return 0;
return StreamEOF;
}
#else
readBuffer = QString::fromLatin1(rawReadBuffer.data(), nbytesread);
@ -1531,7 +1534,7 @@ ushort QXmlStreamReaderPrivate::getChar_helper()
}
atEnd = true;
return 0;
return StreamEOF;
}
QStringRef QXmlStreamReaderPrivate::namespaceForPrefix(const QStringRef &prefix)

View File

@ -944,7 +944,7 @@ public:
short token;
ushort token_char;
uint token_char;
uint filterCarriageReturn();
inline uint getChar();
@ -955,7 +955,7 @@ public:
void putStringLiteral(const QString &s);
void putReplacement(const QString &s);
void putReplacementInAttributeValue(const QString &s);
ushort getChar_helper();
uint getChar_helper();
bool scanUntil(const char *str, short tokenToInject = -1);
bool scanString(const char *str, short tokenToInject, bool requireSpace = true);
@ -1068,7 +1068,7 @@ bool QXmlStreamReaderPrivate::parse()
documentVersion.clear();
documentEncoding.clear();
#ifndef QT_NO_TEXTCODEC
if (decoder->hasFailure()) {
if (decoder && decoder->hasFailure()) {
raiseWellFormedError(QXmlStream::tr("Encountered incorrectly encoded content."));
readBuffer.clear();
return false;
@ -1099,8 +1099,8 @@ bool QXmlStreamReaderPrivate::parse()
if (token == -1 && - TERMINAL_COUNT != action_index[act]) {
uint cu = getChar();
token = NOTOKEN;
token_char = cu;
if (cu & 0xff0000) {
token_char = cu == ~0U ? cu : ushort(cu);
if ((cu != ~0U) && (cu & 0xff0000)) {
token = cu >> 16;
} else switch (token_char) {
case 0xfffe:
@ -1119,7 +1119,7 @@ bool QXmlStreamReaderPrivate::parse()
break;
}
// fall through
case '\0': {
case ~0U: {
token = EOF_SYMBOL;
if (!tagsDone && !inParseEntity) {
int a = t_action(act, token);

View File

@ -1026,13 +1026,13 @@ void QIcon::addFile(const QString &fileName, const QSize &size, Mode mode, State
// Check if a "@2x" file exists and add it.
static bool disable2xImageLoading = !qEnvironmentVariableIsEmpty("QT_HIGHDPI_DISABLE_2X_IMAGE_LOADING");
if (!disable2xImageLoading && qApp->devicePixelRatio() > 1.0) {
QString at2xfileName = fileName;
int dotIndex = fileName.lastIndexOf(QLatin1Char('.'));
if (dotIndex != -1) {
QString at2xfileName = fileName;
at2xfileName.insert(dotIndex, QStringLiteral("@2x"));
if (QFile::exists(at2xfileName))
d->engine->addFile(at2xfileName, size, mode, state);
}
if (dotIndex == -1) /* no dot */
dotIndex = fileName.size(); /* append */
at2xfileName.insert(dotIndex, QStringLiteral("@2x"));
if (QFile::exists(at2xfileName))
d->engine->addFile(at2xfileName, size, mode, state);
}
}

View File

@ -2733,7 +2733,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
0,
0,
0,
0,
convert_RGBA_to_ARGB_inplace,
convert_RGBA_to_ARGB_inplace,
convert_RGBA_to_ARGB_inplace,
0,
@ -2756,7 +2756,6 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
0,
0,
0,
0,
convert_RGBA_to_ARGB_inplace,
convert_RGBA_to_ARGB_PM_inplace,
0,
@ -2770,6 +2769,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
0,
0,
0,
0,
0, 0, 0, 0, 0, 0
}, // Format_RGBA8888
{
@ -2779,7 +2779,6 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
0,
0,
0,
0,
convert_RGBA_to_ARGB_inplace,
0,
0,
@ -2792,6 +2791,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
0,
0,
0,
0,
0, 0, 0, 0, 0, 0
}, // Format_RGBA8888_Premultiplied
{

View File

@ -2936,9 +2936,13 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const
itemsSet.reserve(indexes.count());
stack.reserve(indexes.count());
for (int i = 0; i < indexes.count(); ++i) {
QStandardItem *item = itemFromIndex(indexes.at(i));
itemsSet << item;
stack.push(item);
if (QStandardItem *item = itemFromIndex(indexes.at(i))) {
itemsSet << item;
stack.push(item);
} else {
qWarning() << "QStandardItemModel::mimeData: No item associated with invalid index";
return 0;
}
}
//remove duplicates childrens
@ -2972,16 +2976,11 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const
//stream everything recursively
while (!stack.isEmpty()) {
QStandardItem *item = stack.pop();
if(itemsSet.contains(item)) { //if the item is selection 'top-level', strem its position
if (itemsSet.contains(item)) //if the item is selection 'top-level', stream its position
stream << item->row() << item->column();
}
if(item) {
stream << *item << item->columnCount() << item->d_ptr->children.count();
stack += item->d_ptr->children;
} else {
QStandardItem dummy;
stream << dummy << 0 << 0;
}
stream << *item << item->columnCount() << item->d_ptr->children.count();
stack += item->d_ptr->children;
}
data->setData(format, encoded);

View File

@ -134,7 +134,8 @@ Qt::DropAction QDragManager::drag(QDrag *o)
QGuiApplicationPrivate::instance()->notifyDragStarted(o);
const Qt::DropAction result = m_platformDrag->drag(m_object);
m_object = 0;
o->deleteLater();
if (!m_platformDrag->ownsDragObject())
o->deleteLater();
return result;
}

View File

@ -2572,9 +2572,14 @@ void QGuiApplicationPrivate::reportRefreshRateChange(QWindowSystemInterfacePriva
return;
QScreen *s = e->screen.data();
s->d_func()->refreshRate = e->rate;
emit s->refreshRateChanged(s->refreshRate());
qreal rate = e->rate;
// safeguard ourselves against buggy platform behavior...
if (rate < 1.0)
rate = 60.0;
if (!qFuzzyCompare(s->d_func()->refreshRate, rate)) {
s->d_func()->refreshRate = rate;
emit s->refreshRateChanged(s->refreshRate());
}
}
void QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent *e)

View File

@ -241,6 +241,18 @@ QPixmap QPlatformDrag::defaultPixmap()
return *qt_drag_default_pixmap();
}
/*!
\since 5.4
\brief Returns bool indicating whether QPlatformDrag takes ownership
and therefore responsibility of deleting the QDrag object passed in
from QPlatformDrag::drag. This can be useful on platforms where QDrag
object has to be kept around.
*/
bool QPlatformDrag::ownsDragObject() const
{
return false;
}
#endif // QT_NO_DRAGANDDROP
QT_END_NAMESPACE

View File

@ -98,6 +98,8 @@ public:
static QPixmap defaultPixmap();
virtual bool ownsDragObject() const;
private:
QPlatformDragPrivate *d_ptr;

View File

@ -64,6 +64,9 @@ public:
availableGeometry = platformScreen->availableGeometry();
logicalDpi = platformScreen->logicalDpi();
refreshRate = platformScreen->refreshRate();
// safeguard ourselves against buggy platform behavior...
if (refreshRate < 1.0)
refreshRate = 60.0;
updatePrimaryOrientation();

View File

@ -46,11 +46,36 @@
//
#include "qopenglfunctions.h"
#include <QtCore/qlibrary.h>
QT_BEGIN_NAMESPACE
class QOpenGLExtensionsPrivate;
class QOpenGLES3Helper
{
public:
QOpenGLES3Helper();
GLvoid* (QOPENGLF_APIENTRYP MapBufferRange)(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr length, GLbitfield access);
GLboolean (QOPENGLF_APIENTRYP UnmapBuffer)(GLenum target);
void (QOPENGLF_APIENTRYP BlitFramebuffer)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
void (QOPENGLF_APIENTRYP RenderbufferStorageMultisample)(GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height);
void (QOPENGLF_APIENTRYP GenVertexArrays)(GLsizei n, GLuint *arrays);
void (QOPENGLF_APIENTRYP DeleteVertexArrays)(GLsizei n, const GLuint *arrays);
void (QOPENGLF_APIENTRYP BindVertexArray)(GLuint array);
GLboolean (QOPENGLF_APIENTRYP IsVertexArray)(GLuint array);
void (QOPENGLF_APIENTRYP TexImage3D)(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
void (QOPENGLF_APIENTRYP TexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
void (QOPENGLF_APIENTRYP CompressedTexImage3D)(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
void (QOPENGLF_APIENTRYP CompressedTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
private:
QLibrary m_gl;
};
class Q_GUI_EXPORT QOpenGLExtensions : public QOpenGLFunctions
{
Q_DECLARE_PRIVATE(QOpenGLExtensions)
@ -105,6 +130,8 @@ public:
void glDiscardFramebufferEXT (GLenum target, GLsizei numAttachments, const GLenum *attachments);
QOpenGLES3Helper *gles3Helper();
private:
static bool isInitialized(const QOpenGLFunctionsPrivate *d) { return d != 0; }
};

View File

@ -3193,65 +3193,105 @@ static void QOPENGLF_APIENTRY qopenglfResolveVertexAttribPointer(GLuint indx, GL
#endif // !QT_OPENGL_ES_2
// Functions part of the OpenGL ES 3.0+ standard need special handling. These,
// just like the 2.0 functions, are not guaranteed to be resolvable via
// eglGetProcAddress or similar. Calling them directly is, unlike the 2.0
// functions, not feasible because one may build the binaries on a GLES3-capable
// system and then deploy on a GLES2-only system that does not have these
// symbols. Until ES3 gets universally available, they have to be dlsym'ed.
Q_GLOBAL_STATIC(QOpenGLES3Helper, qgles3Helper)
QOpenGLES3Helper::QOpenGLES3Helper()
{
#ifdef Q_OS_WIN
#ifdef QT_DEBUG
m_gl.setFileName(QStringLiteral("libGLESv2"));
#else
m_gl.setFileName(QStringLiteral("libGLESv2d"));
#endif
#else
m_gl.setFileName(QStringLiteral("GLESv2"));
#endif
if (m_gl.load()) {
MapBufferRange = (GLvoid* (QOPENGLF_APIENTRYP)(GLenum, qopengl_GLintptr, qopengl_GLsizeiptr, GLbitfield)) m_gl.resolve("glMapBufferRange");
UnmapBuffer = (GLboolean (QOPENGLF_APIENTRYP)(GLenum)) m_gl.resolve("glUnmapBuffer");
BlitFramebuffer = (void (QOPENGLF_APIENTRYP)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum)) m_gl.resolve("glBlitFramebuffer");
RenderbufferStorageMultisample = (void (QOPENGLF_APIENTRYP)(GLenum, GLsizei, GLenum, GLsizei, GLsizei)) m_gl.resolve("glRenderbufferStorageMultisample");
GenVertexArrays = (void (QOPENGLF_APIENTRYP)(GLsizei, GLuint *)) m_gl.resolve("glGenVertexArrays");
DeleteVertexArrays = (void (QOPENGLF_APIENTRYP)(GLsizei, const GLuint *)) m_gl.resolve("glDeleteVertexArrays");
BindVertexArray = (void (QOPENGLF_APIENTRYP)(GLuint)) m_gl.resolve("glBindVertexArray");
IsVertexArray = (GLboolean (QOPENGLF_APIENTRYP)(GLuint)) m_gl.resolve("glIsVertexArray");
TexImage3D = (void (QOPENGLF_APIENTRYP)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *)) m_gl.resolve("glTexImage3D");
TexSubImage3D = (void (QOPENGLF_APIENTRYP)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *)) m_gl.resolve("glTexSubImage3D");
CompressedTexImage3D = (void (QOPENGLF_APIENTRYP)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *)) m_gl.resolve("glCompressedTexImage3D");
CompressedTexSubImage3D = (void (QOPENGLF_APIENTRYP)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *)) m_gl.resolve("glCompressedTexSubImage3D");
if (!MapBufferRange || !GenVertexArrays || !TexImage3D)
qFatal("OpenGL ES 3.0 entry points not found");
} else {
qFatal("Failed to load libGLESv2");
}
}
static inline bool isES3()
{
QOpenGLContext *ctx = QOpenGLContext::currentContext();
return ctx->isOpenGLES() && ctx->format().majorVersion() >= 3;
}
static GLvoid *QOPENGLF_APIENTRY qopenglfResolveMapBuffer(GLenum target, GLenum access)
{
#ifdef QT_OPENGL_ES_3
// It is possible that GL_OES_map_buffer is present, but then having to
// differentiate between glUnmapBufferOES and glUnmapBuffer causes extra
// headache. QOpenGLBuffer::map() will handle this automatically, while direct
// calls are better off with migrating to the standard glMapBufferRange.
if (QOpenGLContext::currentContext()->format().majorVersion() >= 3) {
if (isES3()) {
qWarning("QOpenGLFunctions: glMapBuffer is not available in OpenGL ES 3.0 and up. Use glMapBufferRange instead.");
return 0;
} else
#endif
RESOLVE_FUNC(GLvoid *, ResolveOES, MapBuffer)(target, access);
} else {
RESOLVE_FUNC(GLvoid *, ResolveOES, MapBuffer)(target, access);
}
}
static GLvoid *QOPENGLF_APIENTRY qopenglfResolveMapBufferRange(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr length, GLbitfield access)
{
#ifdef QT_OPENGL_ES_3
if (QOpenGLContext::currentContext()->format().majorVersion() >= 3)
return ::glMapBufferRange(target, offset, length, access);
if (isES3())
return qgles3Helper()->MapBufferRange(target, offset, length, access);
else
#endif
RESOLVE_FUNC(GLvoid *, 0, MapBufferRange)(target, offset, length, access);
RESOLVE_FUNC(GLvoid *, 0, MapBufferRange)(target, offset, length, access);
}
static GLboolean QOPENGLF_APIENTRY qopenglfResolveUnmapBuffer(GLenum target)
{
#ifdef QT_OPENGL_ES_3
if (QOpenGLContext::currentContext()->format().majorVersion() >= 3)
return ::glUnmapBuffer(target);
if (isES3())
return qgles3Helper()->UnmapBuffer(target);
else
#endif
RESOLVE_FUNC(GLboolean, ResolveOES, UnmapBuffer)(target);
RESOLVE_FUNC(GLboolean, ResolveOES, UnmapBuffer)(target);
}
static void QOPENGLF_APIENTRY qopenglfResolveBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask, GLenum filter)
{
#ifdef QT_OPENGL_ES_3
if (QOpenGLContext::currentContext()->format().majorVersion() >= 3)
::glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
if (isES3())
qgles3Helper()->BlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
else
#endif
RESOLVE_FUNC_VOID(ResolveEXT | ResolveANGLE | ResolveNV, BlitFramebuffer)
(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
RESOLVE_FUNC_VOID(ResolveEXT | ResolveANGLE | ResolveNV, BlitFramebuffer)
(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
}
static void QOPENGLF_APIENTRY qopenglfResolveRenderbufferStorageMultisample(GLenum target, GLsizei samples,
GLenum internalFormat,
GLsizei width, GLsizei height)
{
#ifdef QT_OPENGL_ES_3
if (QOpenGLContext::currentContext()->format().majorVersion() >= 3)
::glRenderbufferStorageMultisample(target, samples, internalFormat, width, height);
if (isES3())
qgles3Helper()->RenderbufferStorageMultisample(target, samples, internalFormat, width, height);
else
#endif
RESOLVE_FUNC_VOID(ResolveEXT | ResolveANGLE | ResolveNV, RenderbufferStorageMultisample)
(target, samples, internalFormat, width, height);
RESOLVE_FUNC_VOID(ResolveEXT | ResolveANGLE | ResolveNV, RenderbufferStorageMultisample)
(target, samples, internalFormat, width, height);
}
static void QOPENGLF_APIENTRY qopenglfResolveGetBufferSubData(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr size, GLvoid *data)
@ -3506,4 +3546,9 @@ QOpenGLExtensionsPrivate::QOpenGLExtensionsPrivate(QOpenGLContext *ctx)
DiscardFramebuffer = qopenglfResolveDiscardFramebuffer;
}
QOpenGLES3Helper *QOpenGLExtensions::gles3Helper()
{
return qgles3Helper();
}
QT_END_NAMESPACE

View File

@ -34,6 +34,7 @@
#include "qopengltexturehelper_p.h"
#include <QOpenGLContext>
#include <private/qopenglextensions_p.h>
QT_BEGIN_NAMESPACE
@ -247,21 +248,23 @@ QOpenGLTextureHelper::QOpenGLTextureHelper(QOpenGLContext *context)
CompressedTexImage3D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid*)>(context->getProcAddress(QByteArrayLiteral("glCompressedTexImage3DOES")));
CompressedTexSubImage3D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid*)>(context->getProcAddress(QByteArrayLiteral("glCompressedTexSubImage3DOES")));
} else {
#ifdef QT_OPENGL_ES_3
// OpenGL ES 3.0+ has glTexImage3D.
TexImage3D = ::glTexImage3D;
TexSubImage3D = ::glTexSubImage3D;
CompressedTexImage3D = ::glCompressedTexImage3D;
CompressedTexSubImage3D = ::glCompressedTexSubImage3D;
#else
// OpenGL 1.2
TexImage3D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLint , GLsizei , GLsizei , GLsizei , GLint , GLenum , GLenum , const GLvoid *)>(context->getProcAddress(QByteArrayLiteral("glTexImage3D")));
TexSubImage3D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLint , GLint , GLint , GLsizei , GLsizei , GLsizei , GLenum , GLenum , const GLvoid *)>(context->getProcAddress(QByteArrayLiteral("glTexSubImage3D")));
QOpenGLContext *ctx = QOpenGLContext::currentContext();
if (ctx->isOpenGLES() && ctx->format().majorVersion() >= 3) {
// OpenGL ES 3.0+ has glTexImage3D.
QOpenGLES3Helper *es3 = static_cast<QOpenGLExtensions *>(ctx->functions())->gles3Helper();
TexImage3D = es3->TexImage3D;
TexSubImage3D = es3->TexSubImage3D;
CompressedTexImage3D = es3->CompressedTexImage3D;
CompressedTexSubImage3D = es3->CompressedTexSubImage3D;
} else {
// OpenGL 1.2
TexImage3D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLint , GLsizei , GLsizei , GLsizei , GLint , GLenum , GLenum , const GLvoid *)>(context->getProcAddress(QByteArrayLiteral("glTexImage3D")));
TexSubImage3D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLint , GLint , GLint , GLsizei , GLsizei , GLsizei , GLenum , GLenum , const GLvoid *)>(context->getProcAddress(QByteArrayLiteral("glTexSubImage3D")));
// OpenGL 1.3
CompressedTexImage3D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLenum , GLsizei , GLsizei , GLsizei , GLint , GLsizei , const GLvoid *)>(context->getProcAddress(QByteArrayLiteral("glCompressedTexImage3D")));
CompressedTexSubImage3D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLint , GLint , GLint , GLsizei , GLsizei , GLsizei , GLenum , GLsizei , const GLvoid *)>(context->getProcAddress(QByteArrayLiteral("glCompressedTexSubImage3D")));
#endif
// OpenGL 1.3
CompressedTexImage3D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLenum , GLsizei , GLsizei , GLsizei , GLint , GLsizei , const GLvoid *)>(context->getProcAddress(QByteArrayLiteral("glCompressedTexImage3D")));
CompressedTexSubImage3D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLint , GLint , GLint , GLsizei , GLsizei , GLsizei , GLenum , GLsizei , const GLvoid *)>(context->getProcAddress(QByteArrayLiteral("glCompressedTexSubImage3D")));
}
}
#ifndef QT_OPENGL_ES_2

View File

@ -35,12 +35,12 @@
#include <QtCore/private/qobject_p.h>
#include <QtGui/qopenglcontext.h>
#include <QtGui/qopenglfunctions.h>
#include <QtGui/qoffscreensurface.h>
#include <QtGui/qopenglfunctions_3_0.h>
#include <QtGui/qopenglfunctions_3_2_core.h>
#include <private/qopenglextensions_p.h>
#include <private/qopenglvertexarrayobject_p.h>
QT_BEGIN_NAMESPACE
@ -56,16 +56,14 @@ void qtInitializeVertexArrayObjectHelper(QOpenGLVertexArrayObjectHelper *helper,
bool tryARB = true;
if (context->isOpenGLES()) {
#ifdef QT_OPENGL_ES_3
if (context->format().majorVersion() >= 3) {
helper->GenVertexArrays = ::glGenVertexArrays;
helper->DeleteVertexArrays = ::glDeleteVertexArrays;
helper->BindVertexArray = ::glBindVertexArray;
helper->IsVertexArray = ::glIsVertexArray;
QOpenGLES3Helper *es3 = static_cast<QOpenGLExtensions *>(context->functions())->gles3Helper();
helper->GenVertexArrays = es3->GenVertexArrays;
helper->DeleteVertexArrays = es3->DeleteVertexArrays;
helper->BindVertexArray = es3->BindVertexArray;
helper->IsVertexArray = es3->IsVertexArray;
tryARB = false;
} else
#endif
if (context->hasExtension(QByteArrayLiteral("GL_OES_vertex_array_object"))) {
} else if (context->hasExtension(QByteArrayLiteral("GL_OES_vertex_array_object"))) {
helper->GenVertexArrays = reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_GenVertexArrays_t>(context->getProcAddress(QByteArrayLiteral("glGenVertexArraysOES")));
helper->DeleteVertexArrays = reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_DeleteVertexArrays_t>(context->getProcAddress(QByteArrayLiteral("glDeleteVertexArraysOES")));
helper->BindVertexArray = reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_BindVertexArray_t>(context->getProcAddress(QByteArrayLiteral("glBindVertexArrayOES")));

View File

@ -13,6 +13,7 @@ HEADERS += \
painting/qdrawhelper_x86_p.h \
painting/qdrawingprimitive_sse2_p.h \
painting/qemulationpaintengine_p.h \
painting/qfixed_p.h \
painting/qgrayraster_p.h \
painting/qmatrix.h \
painting/qmemrotate_p.h \

View File

@ -56,10 +56,10 @@ private:
Q_DECL_CONSTEXPR QFixed(int val, int) : val(val) {} // 2nd int is just a dummy for disambiguation
public:
Q_DECL_CONSTEXPR QFixed() : val(0) {}
Q_DECL_CONSTEXPR QFixed(int i) : val(i<<6) {}
Q_DECL_CONSTEXPR QFixed(long i) : val(i<<6) {}
QFixed &operator=(int i) { val = (i<<6); return *this; }
QFixed &operator=(long i) { val = (i<<6); return *this; }
Q_DECL_CONSTEXPR QFixed(int i) : val(i * 64) {}
Q_DECL_CONSTEXPR QFixed(long i) : val(i * 64) {}
QFixed &operator=(int i) { val = i * 64; return *this; }
QFixed &operator=(long i) { val = i * 64; return *this; }
Q_DECL_CONSTEXPR static QFixed fromReal(qreal r) { return fromFixed((int)(r*qreal(64))); }
Q_DECL_CONSTEXPR static QFixed fromFixed(int fixed) { return QFixed(fixed,0); } // uses private ctor
@ -75,16 +75,16 @@ public:
Q_DECL_CONSTEXPR inline QFixed floor() const { return fromFixed((val) & -64); }
Q_DECL_CONSTEXPR inline QFixed ceil() const { return fromFixed((val+63) & -64); }
Q_DECL_CONSTEXPR inline QFixed operator+(int i) const { return fromFixed((val + (i<<6))); }
Q_DECL_CONSTEXPR inline QFixed operator+(int i) const { return fromFixed(val + i * 64); }
Q_DECL_CONSTEXPR inline QFixed operator+(uint i) const { return fromFixed((val + (i<<6))); }
Q_DECL_CONSTEXPR inline QFixed operator+(const QFixed &other) const { return fromFixed((val + other.val)); }
inline QFixed &operator+=(int i) { val += (i<<6); return *this; }
inline QFixed &operator+=(int i) { val += i * 64; return *this; }
inline QFixed &operator+=(uint i) { val += (i<<6); return *this; }
inline QFixed &operator+=(const QFixed &other) { val += other.val; return *this; }
Q_DECL_CONSTEXPR inline QFixed operator-(int i) const { return fromFixed((val - (i<<6))); }
Q_DECL_CONSTEXPR inline QFixed operator-(int i) const { return fromFixed(val - i * 64); }
Q_DECL_CONSTEXPR inline QFixed operator-(uint i) const { return fromFixed((val - (i<<6))); }
Q_DECL_CONSTEXPR inline QFixed operator-(const QFixed &other) const { return fromFixed((val - other.val)); }
inline QFixed &operator-=(int i) { val -= (i<<6); return *this; }
inline QFixed &operator-=(int i) { val -= i * 64; return *this; }
inline QFixed &operator-=(uint i) { val -= (i<<6); return *this; }
inline QFixed &operator-=(const QFixed &other) { val -= other.val; return *this; }
Q_DECL_CONSTEXPR inline QFixed operator-() const { return fromFixed(-val); }
@ -162,18 +162,18 @@ Q_DECL_CONSTEXPR inline QFixed operator+(uint i, const QFixed &d) { return d+i;
Q_DECL_CONSTEXPR inline QFixed operator-(uint i, const QFixed &d) { return -(d-i); }
// Q_DECL_CONSTEXPR inline QFixed operator*(qreal d, const QFixed &d2) { return d2*d; }
Q_DECL_CONSTEXPR inline bool operator==(const QFixed &f, int i) { return f.value() == (i<<6); }
Q_DECL_CONSTEXPR inline bool operator==(int i, const QFixed &f) { return f.value() == (i<<6); }
Q_DECL_CONSTEXPR inline bool operator!=(const QFixed &f, int i) { return f.value() != (i<<6); }
Q_DECL_CONSTEXPR inline bool operator!=(int i, const QFixed &f) { return f.value() != (i<<6); }
Q_DECL_CONSTEXPR inline bool operator<=(const QFixed &f, int i) { return f.value() <= (i<<6); }
Q_DECL_CONSTEXPR inline bool operator<=(int i, const QFixed &f) { return (i<<6) <= f.value(); }
Q_DECL_CONSTEXPR inline bool operator>=(const QFixed &f, int i) { return f.value() >= (i<<6); }
Q_DECL_CONSTEXPR inline bool operator>=(int i, const QFixed &f) { return (i<<6) >= f.value(); }
Q_DECL_CONSTEXPR inline bool operator<(const QFixed &f, int i) { return f.value() < (i<<6); }
Q_DECL_CONSTEXPR inline bool operator<(int i, const QFixed &f) { return (i<<6) < f.value(); }
Q_DECL_CONSTEXPR inline bool operator>(const QFixed &f, int i) { return f.value() > (i<<6); }
Q_DECL_CONSTEXPR inline bool operator>(int i, const QFixed &f) { return (i<<6) > f.value(); }
Q_DECL_CONSTEXPR inline bool operator==(const QFixed &f, int i) { return f.value() == i * 64; }
Q_DECL_CONSTEXPR inline bool operator==(int i, const QFixed &f) { return f.value() == i * 64; }
Q_DECL_CONSTEXPR inline bool operator!=(const QFixed &f, int i) { return f.value() != i * 64; }
Q_DECL_CONSTEXPR inline bool operator!=(int i, const QFixed &f) { return f.value() != i * 64; }
Q_DECL_CONSTEXPR inline bool operator<=(const QFixed &f, int i) { return f.value() <= i * 64; }
Q_DECL_CONSTEXPR inline bool operator<=(int i, const QFixed &f) { return i * 64 <= f.value(); }
Q_DECL_CONSTEXPR inline bool operator>=(const QFixed &f, int i) { return f.value() >= i * 64; }
Q_DECL_CONSTEXPR inline bool operator>=(int i, const QFixed &f) { return i * 64 >= f.value(); }
Q_DECL_CONSTEXPR inline bool operator<(const QFixed &f, int i) { return f.value() < i * 64; }
Q_DECL_CONSTEXPR inline bool operator<(int i, const QFixed &f) { return i * 64 < f.value(); }
Q_DECL_CONSTEXPR inline bool operator>(const QFixed &f, int i) { return f.value() > i * 64; }
Q_DECL_CONSTEXPR inline bool operator>(int i, const QFixed &f) { return i * 64 > f.value(); }
#ifndef QT_NO_DEBUG_STREAM
inline QDebug &operator<<(QDebug &dbg, const QFixed &f)

View File

@ -412,7 +412,7 @@ void QtFontFamily::ensurePopulated()
return;
QGuiApplicationPrivate::platformIntegration()->fontDatabase()->populateFamily(name);
Q_ASSERT(populated);
Q_ASSERT_X(populated, Q_FUNC_INFO, qPrintable(name));
}
class QFontDatabasePrivate

View File

@ -77,7 +77,12 @@ static inline bool qtransform_equals_no_translate(const QTransform &a, const QTr
// Harfbuzz helper functions
#ifdef QT_ENABLE_HARFBUZZ_NG
bool useHarfbuzzNG = qgetenv("QT_HARFBUZZ") != "old";
Q_GLOBAL_STATIC_WITH_ARGS(bool, useHarfbuzzNG,(qgetenv("QT_HARFBUZZ") != "old"))
bool qt_useHarfbuzzNG()
{
return *useHarfbuzzNG();
}
#endif
Q_STATIC_ASSERT(sizeof(HB_Glyph) == sizeof(glyph_t));
@ -282,7 +287,7 @@ void *QFontEngine::harfbuzzFont() const
{
Q_ASSERT(type() != QFontEngine::Multi);
#ifdef QT_ENABLE_HARFBUZZ_NG
if (useHarfbuzzNG)
if (qt_useHarfbuzzNG())
return hb_qt_font_get_for_engine(const_cast<QFontEngine *>(this));
#endif
if (!font_) {
@ -318,7 +323,7 @@ void *QFontEngine::harfbuzzFace() const
{
Q_ASSERT(type() != QFontEngine::Multi);
#ifdef QT_ENABLE_HARFBUZZ_NG
if (useHarfbuzzNG)
if (qt_useHarfbuzzNG())
return hb_qt_face_get_for_engine(const_cast<QFontEngine *>(this));
#endif
if (!face_) {
@ -360,7 +365,7 @@ bool QFontEngine::supportsScript(QChar::Script script) const
#endif
#ifdef QT_ENABLE_HARFBUZZ_NG
if (useHarfbuzzNG) {
if (qt_useHarfbuzzNG()) {
bool ret = false;
if (hb_face_t *face = hb_qt_face_get_for_engine(const_cast<QFontEngine *>(this))) {
hb_tag_t script_tag_1, script_tag_2;

View File

@ -910,8 +910,8 @@ QTextLayout *QTextCursorPrivate::blockLayout(QTextBlock &block) const{
select text. For selections see selectionStart(), selectionEnd(),
hasSelection(), clearSelection(), and removeSelectedText().
If the position() is at the start of a block atBlockStart()
returns \c true; and if it is at the end of a block atBlockEnd() returns
If the position() is at the start of a block, atBlockStart()
returns \c true; and if it is at the end of a block, atBlockEnd() returns
true. The format of the current character is returned by
charFormat(), and the format of the current block is returned by
blockFormat().
@ -921,9 +921,9 @@ QTextLayout *QTextCursorPrivate::blockLayout(QTextBlock &block) const{
mergeBlockFormat() functions. The 'set' functions will replace the
cursor's current character or block format, while the 'merge'
functions add the given format properties to the cursor's current
format. If the cursor has a selection the given format is applied
to the current selection. Note that when only parts of a block is
selected the block format is applied to the entire block. The text
format. If the cursor has a selection, the given format is applied
to the current selection. Note that when only a part of a block is
selected, the block format is applied to the entire block. The text
at the current character position can be turned into a list using
createList().

View File

@ -1172,7 +1172,7 @@ QString QTextDocument::toPlainText() const
/*!
Replaces the entire contents of the document with the given plain
\a text.
\a text. The undo/redo history is reset when this function is called.
\sa setHtml()
*/
@ -1190,7 +1190,8 @@ void QTextDocument::setPlainText(const QString &text)
/*!
Replaces the entire contents of the document with the given
HTML-formatted text in the \a html string.
HTML-formatted text in the \a html string. The undo/redo history
is reset when this function is called.
The HTML formatting is respected as much as possible; for example,
"<b>bold</b> text" will produce text where the first word has a font

View File

@ -938,7 +938,7 @@ void QTextEngine::shapeLine(const QScriptLine &line)
}
#ifdef QT_ENABLE_HARFBUZZ_NG
extern bool useHarfbuzzNG; // defined in qfontengine.cpp
extern bool qt_useHarfbuzzNG(); // defined in qfontengine.cpp
#endif
void QTextEngine::shapeText(int item) const
@ -1051,7 +1051,7 @@ void QTextEngine::shapeText(int item) const
}
#ifdef QT_ENABLE_HARFBUZZ_NG
if (Q_LIKELY(useHarfbuzzNG))
if (Q_LIKELY(qt_useHarfbuzzNG()))
si.num_glyphs = shapeTextWithHarfbuzzNG(si, string, itemLength, fontEngine, itemBoundaries, kerningEnabled);
else
#endif
@ -1067,7 +1067,7 @@ void QTextEngine::shapeText(int item) const
QGlyphLayout glyphs = shapedGlyphs(&si);
#ifdef QT_ENABLE_HARFBUZZ_NG
if (Q_LIKELY(useHarfbuzzNG))
if (Q_LIKELY(qt_useHarfbuzzNG()))
qt_getJustificationOpportunities(string, itemLength, si, glyphs, logClusters(&si));
#endif
@ -1234,6 +1234,15 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *st
}
#ifdef Q_OS_MAC
// CTRunGetPosition has a bug which applies matrix on 10.6, so we disable
// scaling the advances for this particular version
if (actualFontEngine->fontDef.stretch != 100
&& QSysInfo::MacintoshVersion != QSysInfo::MV_10_6) {
QFixed stretch = QFixed(actualFontEngine->fontDef.stretch) / QFixed(100);
for (uint i = 0; i < num_glyphs; ++i)
g.advances[i] *= stretch;
}
if (actualFontEngine->fontDef.styleStrategy & QFont::ForceIntegerMetrics) {
for (uint i = 0; i < num_glyphs; ++i)
g.advances[i] = g.advances[i].round();
@ -1604,7 +1613,7 @@ void QTextEngine::itemize() const
}
#ifdef QT_ENABLE_HARFBUZZ_NG
analysis = scriptAnalysis.data();
if (useHarfbuzzNG) {
if (qt_useHarfbuzzNG()) {
// ### pretend HB-old behavior for now
for (int i = 0; i < length; ++i) {
switch (analysis[i].script) {

View File

@ -1890,7 +1890,7 @@ void QTextCharFormat::setFont(const QFont &font)
If \a behavior is QTextCharFormat::FontPropertiesAll, the font property that
has not been explicitly set is treated like as it were set with default value;
If \a behavior is QTextCharFormat::FontPropertiesAll, the font property that
If \a behavior is QTextCharFormat::FontPropertiesSpecifiedOnly, the font property that
has not been explicitly set is ignored and the respective property value
remains unchanged.
@ -1928,7 +1928,7 @@ void QTextCharFormat::setFont(const QFont &font, FontPropertiesInheritanceBehavi
setFontFixedPitch(font.fixedPitch());
if (mask & QFont::CapitalizationResolved)
setFontCapitalization(font.capitalization());
if (mask & QFont::LetterSpacingResolved)
if (mask & QFont::WordSpacingResolved)
setFontWordSpacing(font.wordSpacing());
if (mask & QFont::LetterSpacingResolved) {
setFontLetterSpacingType(font.letterSpacingType());

View File

@ -934,7 +934,8 @@ void QHttpNetworkConnectionChannel::_q_encrypted()
if (!protocolHandler) {
switch (sslSocket->sslConfiguration().nextProtocolNegotiationStatus()) {
case QSslConfiguration::NextProtocolNegotiationNegotiated: {
case QSslConfiguration::NextProtocolNegotiationNegotiated: /* fall through */
case QSslConfiguration::NextProtocolNegotiationUnsupported: {
QByteArray nextProtocol = sslSocket->sslConfiguration().nextNegotiatedProtocol();
if (nextProtocol == QSslConfiguration::NextProtocolHttp1_1) {
// fall through to create a QHttpProtocolHandler
@ -956,10 +957,6 @@ void QHttpNetworkConnectionChannel::_q_encrypted()
// re-queue requests from SPDY queue to HTTP queue, if any
requeueSpdyRequests();
break;
case QSslConfiguration::NextProtocolNegotiationUnsupported:
emitFinishedWithError(QNetworkReply::SslHandshakeFailedError,
"chosen Next Protocol Negotiation value unsupported");
break;
default:
emitFinishedWithError(QNetworkReply::SslHandshakeFailedError,
"detected unknown Next Protocol Negotiation protocol");

View File

@ -353,8 +353,7 @@ void QNetworkAddressEntry::setBroadcast(const QHostAddress &newBroadcast)
Not all operating systems support reporting all features. Only the
IPv4 addresses are guaranteed to be listed by this class in all
platforms. In particular, IPv6 address listing is only supported
on Windows XP and more recent versions, Linux, MacOS X and the
BSDs.
on Windows, Linux, OS X and the BSDs.
\sa QNetworkAddressEntry
*/

View File

@ -130,10 +130,17 @@ static bool currentProcessIsService()
DWORD size = UNLEN;
if (ptrGetUserName(userName, &size)) {
SID_NAME_USE type = SidTypeUser;
DWORD dummy = MAX_PATH;
wchar_t dummyStr[MAX_PATH] = L"";
PSID psid = 0;
if (ptrLookupAccountName(NULL, userName, &psid, &dummy, dummyStr, &dummy, &type))
DWORD sidSize = 0;
DWORD domainSize = 0;
// first call is to get the correct size
bool bRet = ptrLookupAccountName(NULL, userName, NULL, &sidSize, NULL, &domainSize, &type);
if (bRet == FALSE && ERROR_INSUFFICIENT_BUFFER != GetLastError())
return false;
QVarLengthArray<BYTE, 68> buff(sidSize);
QVarLengthArray<wchar_t, MAX_PATH> domainName(domainSize);
// second call to LookupAccountNameW actually gets the SID
// both the pointer to the buffer and the pointer to the domain name should not be NULL
if (ptrLookupAccountName(NULL, userName, buff.data(), &sidSize, domainName.data(), &domainSize, &type))
return type != SidTypeUser; //returns true if the current user is not a user
}
}

View File

@ -740,8 +740,15 @@ bool QAbstractSocketPrivate::canReadNotification()
return true;
}
if ((isBuffered || socketType != QAbstractSocket::TcpSocket) && socketEngine)
socketEngine->setReadNotificationEnabled(readBufferMaxSize == 0 || readBufferMaxSize > q->bytesAvailable());
if (socketEngine) {
// turn the socket engine off if we've either:
// - got pending datagrams
// - reached the buffer size limit
if (isBuffered)
socketEngine->setReadNotificationEnabled(readBufferMaxSize == 0 || readBufferMaxSize > q->bytesAvailable());
else if (socketType != QAbstractSocket::TcpSocket)
socketEngine->setReadNotificationEnabled(!socketEngine->hasPendingDatagrams());
}
// reset the read socket notifier state if we reentered inside the
// readyRead() connected slot.

View File

@ -56,9 +56,6 @@ QT_BEGIN_NAMESPACE
waitForReadyRead(), waitForBytesWritten(), and waitForDisconnected()
which blocks until the operation is complete or the timeout expires.
\note This feature is not supported on versions of Windows earlier than
Windows XP.
\sa QLocalServer
*/

View File

@ -514,6 +514,7 @@ QSslCipher QSslConfiguration::sessionCipher() const
is set during the handshake phase.
\sa protocol(), setProtocol()
\since 5.4
*/
QSsl::SslProtocol QSslConfiguration::sessionProtocol() const
{

View File

@ -139,7 +139,13 @@ init_context:
#endif
break;
case QSsl::SslV3:
#ifndef OPENSSL_NO_SSL3_METHOD
sslContext->ctx = q_SSL_CTX_new(client ? q_SSLv3_client_method() : q_SSLv3_server_method());
#else
// SSL 3 not supported by the system, but chosen deliberately -> error
sslContext->ctx = 0;
unsupportedProtocol = true;
#endif
break;
case QSsl::SecureProtocols:
// SSLv2 and SSLv3 will be disabled by SSL options

View File

@ -1108,6 +1108,7 @@ QSslCipher QSslSocket::sessionCipher() const
is set during the handshake phase.
\sa protocol(), setProtocol()
\since 5.4
*/
QSsl::SslProtocol QSslSocket::sessionProtocol() const
{
@ -2123,6 +2124,7 @@ void QSslSocketPrivate::init()
connectionEncrypted = false;
ignoreAllSslErrors = false;
shutdown = false;
pendingClose = false;
// we don't want to clear the ignoreErrorsList, so
// that it is possible setting it before connecting

View File

@ -1616,14 +1616,20 @@ void QSslSocketBackendPrivate::continueHandshake()
}
#if OPENSSL_VERSION_NUMBER >= 0x1000100fL && !defined(OPENSSL_NO_NEXTPROTONEG)
const unsigned char *proto = 0;
unsigned int proto_len = 0;
q_SSL_get0_next_proto_negotiated(ssl, &proto, &proto_len);
if (proto_len)
configuration.nextNegotiatedProtocol = QByteArray(reinterpret_cast<const char *>(proto), proto_len);
else
configuration.nextNegotiatedProtocol.clear();
configuration.nextProtocolNegotiationStatus = sslContextPointer->npnContext().status;
if (sslContextPointer->npnContext().status == QSslConfiguration::NextProtocolNegotiationUnsupported) {
// we could not agree -> be conservative and use HTTP/1.1
configuration.nextNegotiatedProtocol = QByteArrayLiteral("http/1.1");
} else {
const unsigned char *proto = 0;
unsigned int proto_len = 0;
q_SSL_get0_next_proto_negotiated(ssl, &proto, &proto_len);
if (proto_len)
configuration.nextNegotiatedProtocol = QByteArray(reinterpret_cast<const char *>(proto), proto_len);
else
configuration.nextNegotiatedProtocol.clear();
}
#endif // OPENSSL_VERSION_NUMBER >= 0x1000100fL ...
connectionEncrypted = true;

View File

@ -287,7 +287,9 @@ DEFINEFUNC2(void, SSL_set_psk_client_callback, SSL* ssl, ssl, q_psk_client_callb
#ifndef OPENSSL_NO_SSL2
DEFINEFUNC(const SSL_METHOD *, SSLv2_client_method, DUMMYARG, DUMMYARG, return 0, return)
#endif
#ifndef OPENSSL_NO_SSL3_METHOD
DEFINEFUNC(const SSL_METHOD *, SSLv3_client_method, DUMMYARG, DUMMYARG, return 0, return)
#endif
DEFINEFUNC(const SSL_METHOD *, SSLv23_client_method, DUMMYARG, DUMMYARG, return 0, return)
DEFINEFUNC(const SSL_METHOD *, TLSv1_client_method, DUMMYARG, DUMMYARG, return 0, return)
#if OPENSSL_VERSION_NUMBER >= 0x10001000L
@ -297,7 +299,9 @@ DEFINEFUNC(const SSL_METHOD *, TLSv1_2_client_method, DUMMYARG, DUMMYARG, return
#ifndef OPENSSL_NO_SSL2
DEFINEFUNC(const SSL_METHOD *, SSLv2_server_method, DUMMYARG, DUMMYARG, return 0, return)
#endif
#ifndef OPENSSL_NO_SSL3_METHOD
DEFINEFUNC(const SSL_METHOD *, SSLv3_server_method, DUMMYARG, DUMMYARG, return 0, return)
#endif
DEFINEFUNC(const SSL_METHOD *, SSLv23_server_method, DUMMYARG, DUMMYARG, return 0, return)
DEFINEFUNC(const SSL_METHOD *, TLSv1_server_method, DUMMYARG, DUMMYARG, return 0, return)
#if OPENSSL_VERSION_NUMBER >= 0x10001000L
@ -306,11 +310,15 @@ DEFINEFUNC(const SSL_METHOD *, TLSv1_2_server_method, DUMMYARG, DUMMYARG, return
#endif
#else
DEFINEFUNC(SSL_METHOD *, SSLv2_client_method, DUMMYARG, DUMMYARG, return 0, return)
#ifndef OPENSSL_NO_SSL3_METHOD
DEFINEFUNC(SSL_METHOD *, SSLv3_client_method, DUMMYARG, DUMMYARG, return 0, return)
#endif
DEFINEFUNC(SSL_METHOD *, SSLv23_client_method, DUMMYARG, DUMMYARG, return 0, return)
DEFINEFUNC(SSL_METHOD *, TLSv1_client_method, DUMMYARG, DUMMYARG, return 0, return)
DEFINEFUNC(SSL_METHOD *, SSLv2_server_method, DUMMYARG, DUMMYARG, return 0, return)
#ifndef OPENSSL_NO_SSL3_METHOD
DEFINEFUNC(SSL_METHOD *, SSLv3_server_method, DUMMYARG, DUMMYARG, return 0, return)
#endif
DEFINEFUNC(SSL_METHOD *, SSLv23_server_method, DUMMYARG, DUMMYARG, return 0, return)
DEFINEFUNC(SSL_METHOD *, TLSv1_server_method, DUMMYARG, DUMMYARG, return 0, return)
#endif
@ -858,7 +866,9 @@ bool q_resolveOpenSslSymbols()
#ifndef OPENSSL_NO_SSL2
RESOLVEFUNC(SSLv2_client_method)
#endif
#ifndef OPENSSL_NO_SSL3_METHOD
RESOLVEFUNC(SSLv3_client_method)
#endif
RESOLVEFUNC(SSLv23_client_method)
RESOLVEFUNC(TLSv1_client_method)
#if OPENSSL_VERSION_NUMBER >= 0x10001000L
@ -868,7 +878,9 @@ bool q_resolveOpenSslSymbols()
#ifndef OPENSSL_NO_SSL2
RESOLVEFUNC(SSLv2_server_method)
#endif
#ifndef OPENSSL_NO_SSL3_METHOD
RESOLVEFUNC(SSLv3_server_method)
#endif
RESOLVEFUNC(SSLv23_server_method)
RESOLVEFUNC(TLSv1_server_method)
#if OPENSSL_VERSION_NUMBER >= 0x10001000L

View File

@ -611,9 +611,21 @@ QVariant QMacPasteboardMimeFileUri::convertToMime(const QString &mime, QList<QBy
return QVariant();
QList<QVariant> ret;
for (int i = 0; i < data.size(); ++i) {
QUrl url = QUrl::fromEncoded(data.at(i));
const QByteArray &a = data.at(i);
NSString *urlString = [[[NSString alloc] initWithBytesNoCopy:(void *)a.data() length:a.size()
encoding:NSUTF8StringEncoding freeWhenDone:NO] autorelease];
NSURL *nsurl = [NSURL URLWithString:urlString];
QUrl url;
// OS X 10.10 sends file references instead of file paths
if ([nsurl isFileReferenceURL]) {
url = QUrl::fromNSURL([nsurl filePathURL]);
} else {
url = QUrl::fromNSURL(nsurl);
}
if (url.host().toLower() == QLatin1String("localhost"))
url.setHost(QString());
url.setPath(url.path().normalized(QString::NormalizationForm_C));
ret.append(url);
}

View File

@ -45,9 +45,9 @@
// We mean it.
//
#include <QtCore/QVariant>
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformnativeinterface.h>
#include <QtCore/QVariant>
#include <EGL/egl.h>
QT_BEGIN_NAMESPACE

View File

@ -69,5 +69,30 @@ void QFbBackingStore::resize(const QSize &size, const QRegion &staticContents)
mImage = QImage(size, window()->screen()->handle()->format());
}
const QImage QFbBackingStore::image()
{
return mImage;
}
void QFbBackingStore::lock()
{
mImageMutex.lock();
}
void QFbBackingStore::unlock()
{
mImageMutex.unlock();
}
void QFbBackingStore::beginPaint(const QRegion &)
{
lock();
}
void QFbBackingStore::endPaint()
{
unlock();
}
QT_END_NAMESPACE

View File

@ -46,6 +46,7 @@
//
#include <qpa/qplatformbackingstore.h>
#include <QtCore/QMutex>
QT_BEGIN_NAMESPACE
@ -64,12 +65,19 @@ public:
virtual void resize(const QSize &size, const QRegion &region) Q_DECL_OVERRIDE;
const QImage image() { return mImage; }
const QImage image();
void lock();
void unlock();
void beginPaint(const QRegion &);
void endPaint();
protected:
friend class QFbWindow;
QImage mImage;
QMutex mImageMutex;
};
QT_END_NAMESPACE

View File

@ -37,11 +37,15 @@
#include "qfbbackingstore_p.h"
#include <QtGui/QPainter>
#include <QtCore/QCoreApplication>
#include <qpa/qwindowsysteminterface.h>
#include <QtCore/QDebug>
#include <QtCore/QElapsedTimer>
QT_BEGIN_NAMESPACE
QFbScreen::QFbScreen() : mCursor(0), mGeometry(), mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0), mCompositePainter(0), mIsUpToDate(false)
QFbScreen::QFbScreen() : mUpdatePending(false), mCursor(0), mGeometry(), mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0), mCompositePainter(0), mIsUpToDate(false)
{
}
@ -54,10 +58,17 @@ QFbScreen::~QFbScreen()
void QFbScreen::initializeCompositor()
{
mScreenImage = new QImage(mGeometry.size(), mFormat);
scheduleUpdate();
}
mRedrawTimer.setSingleShot(true);
mRedrawTimer.setInterval(0);
connect(&mRedrawTimer, SIGNAL(timeout()), this, SLOT(doRedraw()));
bool QFbScreen::event(QEvent *event)
{
if (event->type() == QEvent::UpdateRequest) {
doRedraw();
mUpdatePending = false;
return true;
}
return QObject::event(event);
}
void QFbScreen::addWindow(QFbWindow *window)
@ -146,8 +157,10 @@ void QFbScreen::setDirty(const QRect &rect)
void QFbScreen::scheduleUpdate()
{
if (!mRedrawTimer.isActive())
mRedrawTimer.start();
if (!mUpdatePending) {
mUpdatePending = true;
QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest));
}
}
void QFbScreen::setPhysicalSize(const QSize &size)
@ -246,12 +259,19 @@ QRegion QFbScreen::doRedraw()
continue;
// if (mWindowStack[layerIndex]->isMinimized())
// continue;
QRect windowRect = mWindowStack[layerIndex]->geometry().translated(-screenOffset);
QRect windowIntersect = rect.translated(-windowRect.left(),
-windowRect.top());
QFbBackingStore *backingStore = mWindowStack[layerIndex]->backingStore();
if (backingStore)
if (backingStore) {
backingStore->lock();
mCompositePainter->drawImage(rect, backingStore->image(), windowIntersect);
backingStore->unlock();
}
if (firstLayer) {
firstLayer = false;
}
@ -272,7 +292,6 @@ QRegion QFbScreen::doRedraw()
// qDebug() << "QFbScreen::doRedraw" << mWindowStack.size() << mScreenImage->size() << touchedRegion;
return touchedRegion;
}

View File

@ -94,10 +94,11 @@ protected slots:
protected:
void initializeCompositor();
bool event(QEvent *event);
QList<QFbWindow *> mWindowStack;
QRegion mRepaintRegion;
QTimer mRedrawTimer;
bool mUpdatePending;
QFbCursor *mCursor;
QRect mGeometry;

View File

@ -535,6 +535,23 @@ QFontEngine::HintStyle defaultHintStyleFromMatch(QFont::HintingPreference hintin
return QFontEngine::HintNone;
}
int hint_style = 0;
if (FcPatternGetInteger (match, FC_HINT_STYLE, 0, &hint_style) == FcResultMatch) {
switch (hint_style) {
case FC_HINT_NONE:
return QFontEngine::HintNone;
case FC_HINT_SLIGHT:
return QFontEngine::HintLight;
case FC_HINT_MEDIUM:
return QFontEngine::HintMedium;
case FC_HINT_FULL:
return QFontEngine::HintFull;
default:
Q_UNREACHABLE();
break;
}
}
if (useXftConf) {
void *hintStyleResource =
QGuiApplication::platformNativeInterface()->nativeResourceForScreen("hintstyle",
@ -544,27 +561,31 @@ QFontEngine::HintStyle defaultHintStyleFromMatch(QFont::HintingPreference hintin
return QFontEngine::HintStyle(hintStyle - 1);
}
int hint_style = 0;
if (FcPatternGetInteger (match, FC_HINT_STYLE, 0, &hint_style) == FcResultNoMatch)
hint_style = FC_HINT_FULL;
switch (hint_style) {
case FC_HINT_NONE:
return QFontEngine::HintNone;
case FC_HINT_SLIGHT:
return QFontEngine::HintLight;
case FC_HINT_MEDIUM:
return QFontEngine::HintMedium;
case FC_HINT_FULL:
return QFontEngine::HintFull;
default:
Q_UNREACHABLE();
break;
}
return QFontEngine::HintFull;
}
QFontEngine::SubpixelAntialiasingType subpixelTypeFromMatch(FcPattern *match, bool useXftConf)
{
int subpixel = FC_RGBA_UNKNOWN;
if (FcPatternGetInteger(match, FC_RGBA, 0, &subpixel) == FcResultMatch) {
switch (subpixel) {
case FC_RGBA_UNKNOWN:
case FC_RGBA_NONE:
return QFontEngine::Subpixel_None;
case FC_RGBA_RGB:
return QFontEngine::Subpixel_RGB;
case FC_RGBA_BGR:
return QFontEngine::Subpixel_BGR;
case FC_RGBA_VRGB:
return QFontEngine::Subpixel_VRGB;
case FC_RGBA_VBGR:
return QFontEngine::Subpixel_VBGR;
default:
Q_UNREACHABLE();
break;
}
}
if (useXftConf) {
void *subpixelTypeResource =
QGuiApplication::platformNativeInterface()->nativeResourceForScreen("subpixeltype",
@ -574,25 +595,6 @@ QFontEngine::SubpixelAntialiasingType subpixelTypeFromMatch(FcPattern *match, bo
return QFontEngine::SubpixelAntialiasingType(subpixelType - 1);
}
int subpixel = FC_RGBA_UNKNOWN;
FcPatternGetInteger(match, FC_RGBA, 0, &subpixel);
switch (subpixel) {
case FC_RGBA_UNKNOWN:
case FC_RGBA_NONE:
return QFontEngine::Subpixel_None;
case FC_RGBA_RGB:
return QFontEngine::Subpixel_RGB;
case FC_RGBA_BGR:
return QFontEngine::Subpixel_BGR;
case FC_RGBA_VRGB:
return QFontEngine::Subpixel_VRGB;
case FC_RGBA_VBGR:
return QFontEngine::Subpixel_VBGR;
default:
Q_UNREACHABLE();
break;
}
return QFontEngine::Subpixel_None;
}
} // namespace
@ -832,10 +834,8 @@ void QFontconfigDatabase::setupFontEngine(QFontEngineFT *engine, const QFontDef
QGuiApplication::platformNativeInterface()->nativeResourceForScreen("antialiasingEnabled",
QGuiApplication::primaryScreen());
int antialiasingEnabled = int(reinterpret_cast<qintptr>(antialiasResource));
if (antialiasingEnabled > 0) {
if (antialiasingEnabled > 0)
antialias = antialiasingEnabled - 1;
forcedAntialiasSetting = true;
}
}
QFontEngine::GlyphFormat format;

View File

@ -354,6 +354,8 @@ void QCoreTextFontDatabase::releaseHandle(void *handle)
CFRelease(CTFontDescriptorRef(handle));
}
extern CGAffineTransform qt_transform_from_fontdef(const QFontDef &fontDef);
QFontEngine *QCoreTextFontDatabase::fontEngine(const QFontDef &f, void *usrPtr)
{
qreal scaledPointSize = f.pixelSize;
@ -368,7 +370,8 @@ QFontEngine *QCoreTextFontDatabase::fontEngine(const QFontDef &f, void *usrPtr)
scaledPointSize = f.pointSize;
CTFontDescriptorRef descriptor = (CTFontDescriptorRef) usrPtr;
CTFontRef font = CTFontCreateWithFontDescriptor(descriptor, scaledPointSize, NULL);
CGAffineTransform matrix = qt_transform_from_fontdef(f);
CTFontRef font = CTFontCreateWithFontDescriptor(descriptor, scaledPointSize, &matrix);
if (font) {
QFontEngine *engine = new QCoreTextFontEngine(font, f);
engine->fontDef = f;

View File

@ -39,6 +39,8 @@
#include <QLoggingCategory>
#include <QtCore/private/qcore_unix_p.h>
#include <QtPlatformSupport/private/qdevicediscovery_p.h>
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/private/qinputdevicemanager_p_p.h>
#include <linux/input.h>
#if !defined(QT_NO_MTDEV)
@ -146,6 +148,12 @@ void QEvdevTouchScreenData::registerDevice()
m_device->setCapabilities(m_device->capabilities() | QTouchDevice::Pressure);
QWindowSystemInterface::registerTouchDevice(m_device);
// No monitoring of added/removed devices is done here, so for now just
// increase the number of touch devices.
QInputDeviceManager *imgr = QGuiApplicationPrivate::inputDeviceManager();
QInputDeviceManagerPrivate::get(imgr)->setDeviceCount(QInputDeviceManager::DeviceTypeTouch,
imgr->deviceCount(QInputDeviceManager::DeviceTypeTouch) + 1);
}
#define LONG_BITS (sizeof(long) << 3)

View File

@ -1048,6 +1048,8 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
}
break;
}
case QAccessible::SelectionAdd:
case QAccessible::SelectionRemove:
case QAccessible::Selection: {
QAccessibleInterface * iface = event->accessibleInterface();
if (!iface) {
@ -1105,7 +1107,6 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
case QAccessible::ParentChanged:
case QAccessible::DialogStart:
case QAccessible::DialogEnd:
case QAccessible::SelectionRemove:
case QAccessible::PopupMenuStart:
case QAccessible::PopupMenuEnd:
case QAccessible::SoundPlayed:
@ -1147,7 +1148,6 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
case QAccessible::TextAttributeChanged:
case QAccessible::TextColumnChanged:
case QAccessible::VisibleDataChanged:
case QAccessible::SelectionAdd:
case QAccessible::SelectionWithin:
case QAccessible::LocationChanged:
case QAccessible::HelpChanged:

View File

@ -2,7 +2,6 @@ contains(QT_CONFIG, accessibility-atspi-bridge) {
QT_FOR_PRIVATE += dbus
include(../../3rdparty/atspi2/atspi2.pri)
include(../accessibility/accessibility.pri)
INCLUDEPATH += $$PWD

View File

@ -430,7 +430,6 @@ QCoreWlanEngine::QCoreWlanEngine(QObject *parent)
QCoreWlanEngine::~QCoreWlanEngine()
{
scanThread->terminate();
scanThread->wait();
while (!foundConfigurations.isEmpty())

View File

@ -8,12 +8,7 @@ DEFINES += QT_STATICPLUGIN
load(qt_plugin)
!contains(ANDROID_PLATFORM, android-9) {
INCLUDEPATH += $$NDK_ROOT/platforms/android-9/arch-$$ANDROID_ARCHITECTURE/usr/include
LIBS += -L$$NDK_ROOT/platforms/android-9/arch-$$ANDROID_ARCHITECTURE/usr/lib -ljnigraphics -landroid
} else {
LIBS += -ljnigraphics -landroid
}
LIBS += -ljnigraphics -landroid
QT += core-private gui-private platformsupport-private
@ -54,7 +49,7 @@ SOURCES += $$PWD/androidplatformplugin.cpp \
$$PWD/qandroideventdispatcher.cpp
HEADERS += $$PWD/qandroidplatformintegration.h \
$$PWD/androidandroiddeadlockprotector.h \
$$PWD/androiddeadlockprotector.h \
$$PWD/androidjnimain.h \
$$PWD/androidjniaccessibility.h \
$$PWD/androidjniinput.h \

View File

@ -100,7 +100,9 @@ void QCocoaMenuBar::insertNativeMenu(QCocoaMenu *menu, QCocoaMenu *beforeMenu)
menu->setMenuBar(this);
syncMenu(static_cast<QPlatformMenu *>(menu));
[m_nativeMenu setSubmenu: menu->nsMenu() forItem: menu->nsMenuItem()];
if (menu->isVisible()) {
[m_nativeMenu setSubmenu: menu->nsMenu() forItem: menu->nsMenuItem()];
}
}
void QCocoaMenuBar::insertMenu(QPlatformMenu *platformMenu, QPlatformMenu *before)

View File

@ -1830,6 +1830,8 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
Qt::DropActions qtAllowed = qt_mac_mapNSDragOperations([sender draggingSourceOperationMask]);
QWindow *target = findEventTargetWindow(m_window);
if (!target)
return NSDragOperationNone;
// update these so selecting move/copy/link works
QGuiApplicationPrivate::modifier_buttons = [QNSView convertKeyModifiers: [[NSApp currentEvent] modifierFlags]];
@ -1849,6 +1851,8 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
- (void)draggingExited:(id <NSDraggingInfo>)sender
{
QWindow *target = findEventTargetWindow(m_window);
if (!target)
return;
NSPoint windowPoint = [self convertPoint: [sender draggingLocation] fromView: nil];
QPoint qt_windowPoint(windowPoint.x, windowPoint.y);
@ -1861,6 +1865,8 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
QWindow *target = findEventTargetWindow(m_window);
if (!target)
return false;
NSPoint windowPoint = [self convertPoint: [sender draggingLocation] fromView: nil];
QPoint qt_windowPoint(windowPoint.x, windowPoint.y);
@ -1886,6 +1892,8 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
Q_UNUSED(img);
Q_UNUSED(operation);
QWindow *target = findEventTargetWindow(m_window);
if (!target)
return;
// keep our state, and QGuiApplication state (buttons member) in-sync,
// or future mouse events will be processed incorrectly

View File

@ -31,16 +31,17 @@
**
****************************************************************************/
#include "qeglfscontext.h"
#include "qeglfswindow.h"
#include "qeglfshooks.h"
#include <QtPlatformSupport/private/qeglconvenience_p.h>
#include <QtPlatformSupport/private/qeglpbuffer_p.h>
#include <QtPlatformSupport/private/qeglplatformcursor_p.h>
#include <QtGui/QSurface>
#include <QtDebug>
#include <QtPlatformSupport/private/qeglplatformcursor_p.h>
#include <QtPlatformSupport/private/qeglconvenience_p.h>
#include <QtPlatformSupport/private/qeglpbuffer_p.h>
#include "qeglfswindow.h"
#include "qeglfshooks.h"
#include "qeglfscontext.h"
QT_BEGIN_NAMESPACE
QEglFSContext::QEglFSContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display,

View File

@ -31,20 +31,9 @@
**
****************************************************************************/
#include "qeglfsintegration.h"
#include "qeglfswindow.h"
#include "qeglfshooks.h"
#include "qeglfscontext.h"
#include "qeglfsoffscreenwindow.h"
#include <QtCore/qtextstream.h>
#include <QtGui/private/qguiapplication_p.h>
#include <QtPlatformSupport/private/qeglconvenience_p.h>
#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
#include <QtPlatformSupport/private/qeglpbuffer_p.h>
#include <QtPlatformHeaders/QEGLNativeContext>
#include <qpa/qplatformwindow.h>
#include <QtGui/QSurfaceFormat>
#include <QtGui/QOpenGLContext>
@ -52,6 +41,17 @@
#include <QtGui/QOffscreenSurface>
#include <qpa/qplatformcursor.h>
#include "qeglfsintegration.h"
#include "qeglfswindow.h"
#include "qeglfshooks.h"
#include "qeglfscontext.h"
#include "qeglfsoffscreenwindow.h"
#include <QtPlatformSupport/private/qeglconvenience_p.h>
#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
#include <QtPlatformSupport/private/qeglpbuffer_p.h>
#include <QtPlatformHeaders/QEGLNativeContext>
#include <EGL/egl.h>
static void initResources()

View File

@ -31,10 +31,12 @@
**
****************************************************************************/
#include <QtCore/qtextstream.h>
#include <QtGui/qpa/qplatformcursor.h>
#include "qeglfsscreen.h"
#include "qeglfswindow.h"
#include "qeglfshooks.h"
#include <QtGui/qpa/qplatformcursor.h>
QT_BEGIN_NAMESPACE

View File

@ -31,14 +31,17 @@
**
****************************************************************************/
#include "qeglfswindow.h"
#include "qeglfshooks.h"
#include <QtCore/qtextstream.h>
#include <qpa/qwindowsysteminterface.h>
#include <qpa/qplatformintegration.h>
#include <private/qguiapplication_p.h>
#include <QtGui/QOpenGLContext>
#include <QtPlatformSupport/private/qeglplatformcursor_p.h>
#include <QtPlatformSupport/private/qeglconvenience_p.h>
#include "qeglfswindow.h"
#include "qeglfshooks.h"
#include <QtDebug>
QT_BEGIN_NAMESPACE

View File

@ -31,10 +31,10 @@
**
****************************************************************************/
#include "qminimaleglwindow.h"
#include <qpa/qwindowsysteminterface.h>
#include "qminimaleglwindow.h"
QT_BEGIN_NAMESPACE
QMinimalEglWindow::QMinimalEglWindow(QWindow *w)

View File

@ -166,4 +166,8 @@ typedef TOUCHINPUT const * PCTOUCHINPUT;
#endif // if defined(Q_CC_MINGW) || !defined(TOUCHEVENTF_MOVE)
#ifndef WM_GESTURE
# define WM_GESTURE 0x0119
#endif
#endif // QTWINDOWS_ADDITIONAL_H

View File

@ -109,6 +109,7 @@ enum WindowsEventType // Simplify event types
DisplayChangedEvent = 437,
SettingChangedEvent = DisplayChangedEvent + 1,
ContextMenu = 123,
GestureEvent = 124,
UnknownEvent = 542
};
@ -247,6 +248,8 @@ inline QtWindows::WindowsEventType windowsEventType(UINT message, WPARAM wParamI
case WM_APPCOMMAND:
return QtWindows::AppCommandEvent;
#endif
case WM_GESTURE:
return QtWindows::GestureEvent;
default:
break;
}

View File

@ -430,7 +430,7 @@ void QWindowsContext::setKeyGrabber(QWindow *w)
// Window class registering code (from qapplication_win.cpp)
QString QWindowsContext::registerWindowClass(const QWindow *w, bool isGL)
QString QWindowsContext::registerWindowClass(const QWindow *w)
{
Q_ASSERT(w);
const Qt::WindowFlags flags = w->flags();
@ -438,7 +438,9 @@ QString QWindowsContext::registerWindowClass(const QWindow *w, bool isGL)
// Determine style and icon.
uint style = CS_DBLCLKS;
bool icon = true;
if (isGL || (flags & Qt::MSWindowsOwnDC))
// The following will not set CS_OWNDC for any widget window, even if it contains a
// QOpenGLWidget or QQuickWidget later on. That cannot be detected at this stage.
if (w->surfaceType() == QSurface::OpenGLSurface || (flags & Qt::MSWindowsOwnDC))
style |= CS_OWNDC;
if (!(flags & Qt::NoDropShadowWindowHint) && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)
&& (type == Qt::Popup || w->property("_q_windowsDropShadow").toBool())) {
@ -471,8 +473,6 @@ QString QWindowsContext::registerWindowClass(const QWindow *w, bool isGL)
default:
break;
}
if (isGL)
cname += QStringLiteral("GL");
if (style & CS_DROPSHADOW)
cname += QStringLiteral("DropShadow");
if (style & CS_SAVEBITS)
@ -676,7 +676,7 @@ static inline bool findPlatformWindowHelper(const POINT &screenPoint, unsigned c
const HWND child = ChildWindowFromPointEx(*hwnd, point, cwexFlags);
#else
Q_UNUSED(cwexFlags)
const HWND child = ChildWindowFromPoint(*hwnd, point);
const HWND child = WindowFromPoint(point);
#endif
if (!child || child == *hwnd)
return false;
@ -905,6 +905,8 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
return QWindowsInputContext::instance()->endComposition(hwnd);
case QtWindows::InputMethodRequest:
return QWindowsInputContext::instance()->handleIME_Request(wParam, lParam, result);
case QtWindows::GestureEvent:
return d->m_mouseHandler.translateTouchEvent(platformWindow->window(), hwnd, et, msg, result);
case QtWindows::InputMethodOpenCandidateWindowEvent:
case QtWindows::InputMethodCloseCandidateWindowEvent:
// TODO: Release/regrab mouse if a popup has mouse grab.

View File

@ -161,7 +161,7 @@ public:
int defaultDPI() const;
QString registerWindowClass(const QWindow *w, bool isGL);
QString registerWindowClass(const QWindow *w);
QString registerWindowClass(QString cname, WNDPROC proc,
unsigned style = 0, HBRUSH brush = 0,
bool icon = false);

View File

@ -64,7 +64,7 @@ QT_BEGIN_NAMESPACE
QWindowsLibEGL QWindowsEGLStaticContext::libEGL;
QWindowsLibGLESv2 QWindowsEGLStaticContext::libGLESv2;
#ifndef QT_STATIC
#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC)
#ifdef Q_CC_MINGW
static void *resolveFunc(HMODULE lib, const char *name)
@ -111,7 +111,7 @@ void *QWindowsLibEGL::resolve(const char *name)
#endif // !QT_STATIC
#ifndef QT_STATIC
#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC)
# define RESOLVE(signature, name) signature(resolve( #name ));
#else
# define RESOLVE(signature, name) signature(&::name);
@ -127,7 +127,7 @@ bool QWindowsLibEGL::init()
qCDebug(lcQpaGl) << "Qt: Using EGL from" << dllName;
#ifndef QT_STATIC
#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC)
m_lib = ::LoadLibraryW((const wchar_t *) QString::fromLatin1(dllName).utf16());
if (!m_lib) {
qErrnoWarning(::GetLastError(), "Failed to load %s", dllName);
@ -159,7 +159,7 @@ bool QWindowsLibEGL::init()
return eglGetError && eglGetDisplay && eglInitialize;
}
#ifndef QT_STATIC
#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC)
void *QWindowsLibGLESv2::resolve(const char *name)
{
void *proc = m_lib ? resolveFunc(m_lib, name) : 0;
@ -179,7 +179,7 @@ bool QWindowsLibGLESv2::init()
#endif
qCDebug(lcQpaGl) << "Qt: Using OpenGL ES 2.0 from" << dllName;
#ifndef QT_STATIC
#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC)
m_lib = ::LoadLibraryW((const wchar_t *) QString::fromLatin1(dllName).utf16());
if (!m_lib) {
qErrnoWarning(::GetLastError(), "Failed to load %s", dllName);
@ -340,7 +340,7 @@ QWindowsEGLStaticContext::QWindowsEGLStaticContext(EGLDisplay display, int versi
{
}
QWindowsEGLStaticContext *QWindowsEGLStaticContext::create()
QWindowsEGLStaticContext *QWindowsEGLStaticContext::create(QWindowsOpenGLTester::Renderers preferredType)
{
const HDC dc = QWindowsContext::instance()->displayContext();
if (!dc){
@ -358,28 +358,34 @@ QWindowsEGLStaticContext *QWindowsEGLStaticContext::create()
}
EGLDisplay display = EGL_NO_DISPLAY;
EGLint major = 0;
EGLint minor = 0;
#ifdef EGL_ANGLE_platform_angle_opengl
if (libEGL.eglGetPlatformDisplayEXT && qEnvironmentVariableIsSet("QT_ANGLE_PLATFORM")) {
if (libEGL.eglGetPlatformDisplayEXT
&& (preferredType & QWindowsOpenGLTester::AngleBackendMask)) {
const EGLint anglePlatformAttributes[][5] = {
{ EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, EGL_NONE },
{ EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE, EGL_NONE },
{ EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, EGL_PLATFORM_ANGLE_USE_WARP_ANGLE, EGL_TRUE, EGL_NONE }
};
const EGLint *attributes = 0;
const QByteArray anglePlatform = qgetenv("QT_ANGLE_PLATFORM");
if (anglePlatform == "d3d11")
if (preferredType & QWindowsOpenGLTester::AngleRendererD3d11)
attributes = anglePlatformAttributes[0];
else if (anglePlatform == "d3d9")
else if (preferredType & QWindowsOpenGLTester::AngleRendererD3d9)
attributes = anglePlatformAttributes[1];
else if (anglePlatform == "warp")
else if (preferredType & QWindowsOpenGLTester::AngleRendererD3d11Warp)
attributes = anglePlatformAttributes[2];
else
qCWarning(lcQpaGl) << "Invalid value set for QT_ANGLE_PLATFORM:" << anglePlatform;
if (attributes)
if (attributes) {
display = libEGL.eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, dc, attributes);
if (!libEGL.eglInitialize(display, &major, &minor)) {
display = EGL_NO_DISPLAY;
major = minor = 0;
}
}
}
#endif // EGL_ANGLE_platform_angle_opengl
#else // EGL_ANGLE_platform_angle_opengl
Q_UNUSED(preferredType)
#endif
if (display == EGL_NO_DISPLAY)
display = libEGL.eglGetDisplay((EGLNativeDisplayType)dc);
if (!display) {
@ -387,9 +393,7 @@ QWindowsEGLStaticContext *QWindowsEGLStaticContext::create()
return 0;
}
EGLint major;
EGLint minor;
if (!libEGL.eglInitialize(display, &major, &minor)) {
if (!major && !libEGL.eglInitialize(display, &major, &minor)) {
int err = libEGL.eglGetError();
qWarning("%s: Could not initialize EGL display: error 0x%x\n", Q_FUNC_INFO, err);
if (err == 0x3001)
@ -573,6 +577,7 @@ bool QWindowsEGLContext::makeCurrent(QPlatformSurface *surface)
QWindowsEGLStaticContext::libEGL.eglBindAPI(m_api);
QWindowsWindow *window = static_cast<QWindowsWindow *>(surface);
window->aboutToMakeCurrent();
EGLSurface eglSurface = static_cast<EGLSurface>(window->surface(m_eglConfig));
Q_ASSERT(eglSurface);

View File

@ -35,6 +35,7 @@
#define QWINDOWSEGLCONTEXT_H
#include "qwindowsopenglcontext.h"
#include "qwindowsopengltester.h"
#include <EGL/egl.h>
QT_BEGIN_NAMESPACE
@ -74,7 +75,7 @@ struct QWindowsLibEGL
__eglMustCastToProperFunctionPointerType (EGLAPIENTRY * eglGetProcAddress)(const char *procname);
private:
#ifndef QT_STATIC
#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC)
void *resolve(const char *name);
HMODULE m_lib;
#endif
@ -83,7 +84,8 @@ private:
struct QWindowsLibGLESv2
{
bool init();
#ifndef QT_STATIC
#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC)
void *moduleHandle() const { return m_lib; }
#else
void *moduleHandle() const { return Q_NULLPTR; }
@ -238,7 +240,7 @@ struct QWindowsLibGLESv2
void (APIENTRY * glDepthRangef)(GLclampf nearVal, GLclampf farVal);
private:
#ifndef QT_STATIC
#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC)
void *resolve(const char *name);
HMODULE m_lib;
#endif
@ -249,7 +251,7 @@ class QWindowsEGLStaticContext : public QWindowsStaticOpenGLContext
Q_DISABLE_COPY(QWindowsEGLStaticContext)
public:
static QWindowsEGLStaticContext *create();
static QWindowsEGLStaticContext *create(QWindowsOpenGLTester::Renderers preferredType);
~QWindowsEGLStaticContext();
EGLDisplay display() const { return m_display; }

View File

@ -932,9 +932,8 @@ static bool addFontToDatabase(const QString &familyName, uchar charSet,
}
static int QT_WIN_CALLBACK storeFont(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetric,
int type, LPARAM namesSetIn)
int type, LPARAM)
{
typedef QSet<QString> StringSet;
const QString familyName = QString::fromWCharArray(f->elfLogFont.lfFaceName);
const uchar charSet = f->elfLogFont.lfCharSet;
@ -943,79 +942,69 @@ static int QT_WIN_CALLBACK storeFont(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetr
// NEWTEXTMETRICEX is a NEWTEXTMETRIC, which according to the documentation is
// identical to a TEXTMETRIC except for the last four members, which we don't use
// anyway
if (addFontToDatabase(familyName, charSet, (TEXTMETRIC *)textmetric, &signature, type))
reinterpret_cast<StringSet *>(namesSetIn)->insert(familyName);
addFontToDatabase(familyName, charSet, (TEXTMETRIC *)textmetric, &signature, type);
// keep on enumerating
return 1;
}
static int QT_WIN_CALLBACK storeFontSub(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetric,
int type, LPARAM namesSetIn)
void QWindowsFontDatabase::populateFamily(const QString &familyName)
{
Q_UNUSED(textmetric)
Q_UNUSED(type)
qCDebug(lcQpaFonts) << familyName;
if (familyName.size() >= LF_FACESIZE) {
qCWarning(lcQpaFonts) << "Unable to enumerate family '" << familyName << '\'';
return;
}
HDC dummy = GetDC(0);
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
lf.lfCharSet = DEFAULT_CHARSET;
memcpy(lf.lfFaceName, f->elfLogFont.lfFaceName, LF_FACESIZE * sizeof(wchar_t));
familyName.toWCharArray(lf.lfFaceName);
lf.lfFaceName[familyName.size()] = 0;
lf.lfPitchAndFamily = 0;
EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont,
(LPARAM)namesSetIn, 0);
EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont, 0, 0);
ReleaseDC(0, dummy);
}
// keep on enumerating
return 1;
namespace {
// Context for enumerating system fonts, records whether the default font has been encountered,
// which is normally not enumerated by EnumFontFamiliesEx().
struct PopulateFamiliesContext
{
PopulateFamiliesContext(const QString &f) : systemDefaultFont(f), seenSystemDefaultFont(false) {}
QString systemDefaultFont;
bool seenSystemDefaultFont;
};
} // namespace
static int QT_WIN_CALLBACK populateFontFamilies(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *, int, LPARAM lparam)
{
// the "@family" fonts are just the same as "family". Ignore them.
const wchar_t *faceNameW = f->elfLogFont.lfFaceName;
if (faceNameW[0] && faceNameW[0] != L'@' && wcsncmp(faceNameW, L"WST_", 4)) {
const QString faceName = QString::fromWCharArray(faceNameW);
QPlatformFontDatabase::registerFontFamily(faceName);
PopulateFamiliesContext *context = reinterpret_cast<PopulateFamiliesContext *>(lparam);
if (!context->seenSystemDefaultFont && faceName == context->systemDefaultFont)
context->seenSystemDefaultFont = true;
}
return 1; // continue
}
void QWindowsFontDatabase::populateFontDatabase()
{
m_families.clear();
removeApplicationFonts();
populate(); // Called multiple times.
// Work around EnumFontFamiliesEx() not listing the system font, see below.
const QString sysFontFamily = QGuiApplication::font().family();
if (!m_families.contains(sysFontFamily))
populate(sysFontFamily);
}
/*!
\brief Populate font database using EnumFontFamiliesEx().
Normally, leaving the name empty should enumerate
all fonts, however, system fonts like "MS Shell Dlg 2"
are only found when specifying the name explicitly.
*/
void QWindowsFontDatabase::populate(const QString &family)
{
qCDebug(lcQpaFonts) << __FUNCTION__ << m_families.size() << family;
HDC dummy = GetDC(0);
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
lf.lfCharSet = DEFAULT_CHARSET;
if (family.size() >= LF_FACESIZE) {
qWarning("%s: Unable to enumerate family '%s'.",
__FUNCTION__, qPrintable(family));
return;
}
lf.lfFaceName[0] = 0;
lf.lfPitchAndFamily = 0;
if (family.isEmpty()) {
EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFontSub,
(LPARAM)&m_families, 0);
} else {
memcpy(lf.lfFaceName, family.utf16(), family.size() * sizeof(wchar_t));
EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont,
(LPARAM)&m_families, 0);
}
PopulateFamiliesContext context(QWindowsFontDatabase::systemDefaultFont().family());
EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)populateFontFamilies, reinterpret_cast<LPARAM>(&context), 0);
ReleaseDC(0, dummy);
// Work around EnumFontFamiliesEx() not listing the system font.
if (!context.seenSystemDefaultFont)
QPlatformFontDatabase::registerFontFamily(context.systemDefaultFont);
}
typedef QSharedPointer<QWindowsFontEngineData> QWindowsFontEngineDataPtr;
@ -1379,7 +1368,7 @@ QStringList QWindowsFontDatabase::addApplicationFont(const QByteArray &fontData,
// Fonts based on files are added via populate, as they will show up in font enumeration.
for (int j = 0; j < families.count(); ++j)
populate(families.at(j));
populateFamily(families.at(j));
}
m_applicationFonts << font;
@ -1663,7 +1652,7 @@ QStringList QWindowsFontDatabase::fallbacksForFamily(const QString &family, QFon
result.append(QWindowsFontDatabase::extraTryFontsForFamily(family));
qCDebug(lcQpaFonts) << __FUNCTION__ << family << style << styleHint
<< script << result << m_families.size();
<< script << result;
return result;
}

View File

@ -70,6 +70,7 @@ public:
~QWindowsFontDatabase();
void populateFontDatabase() Q_DECL_OVERRIDE;
void populateFamily(const QString &familyName) Q_DECL_OVERRIDE;
QFontEngineMulti *fontEngineMulti(QFontEngine *fontEngine, QChar::Script script) Q_DECL_OVERRIDE;
QFontEngine *fontEngine(const QFontDef &fontDef, void *handle) Q_DECL_OVERRIDE;
QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) Q_DECL_OVERRIDE;
@ -99,9 +100,7 @@ public:
static QString familyForStyleHint(QFont::StyleHint styleHint);
private:
void populate(const QString &family = QString());
void removeApplicationFonts();
QSet<QString> m_families;
struct WinApplicationFont {
HANDLE handle;

View File

@ -483,26 +483,6 @@ static int QT_WIN_CALLBACK storeFont(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetr
return 1;
}
static int QT_WIN_CALLBACK storeFontSub(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetric,
int type, LPARAM namesSetIn)
{
Q_UNUSED(textmetric)
Q_UNUSED(type)
HDC dummy = GetDC(0);
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
lf.lfCharSet = DEFAULT_CHARSET;
memcpy(lf.lfFaceName, f->elfLogFont.lfFaceName, LF_FACESIZE * sizeof(wchar_t));
lf.lfPitchAndFamily = 0;
EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont,
(LPARAM)namesSetIn, 0);
ReleaseDC(0, dummy);
// keep on enumerating
return 1;
}
void QWindowsFontDatabaseFT::populateFontDatabase()
{
m_families.clear();
@ -528,7 +508,6 @@ void QWindowsFontDatabaseFT::populate(const QString &family)
HDC dummy = GetDC(0);
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
lf.lfCharSet = DEFAULT_CHARSET;
if (family.size() >= LF_FACESIZE) {
qWarning("%s: Unable to enumerate family '%s'.",
@ -536,16 +515,12 @@ void QWindowsFontDatabaseFT::populate(const QString &family)
return;
}
wmemcpy(lf.lfFaceName, reinterpret_cast<const wchar_t*>(family.utf16()),
family.size() + 1);
lf.lfPitchAndFamily = 0;
if (family.isEmpty()) {
EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFontSub,
(LPARAM)&m_families, 0);
} else {
memcpy(lf.lfFaceName, family.utf16(), family.size() * sizeof(wchar_t));
EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont,
(LPARAM)&m_families, 0);
}
EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont,
(LPARAM)&m_families, 0);
ReleaseDC(0, dummy);
}

View File

@ -1305,6 +1305,7 @@ bool QWindowsGLContext::makeCurrent(QPlatformSurface *surface)
// Do we already have a DC entry for that window?
QWindowsWindow *window = static_cast<QWindowsWindow *>(surface);
window->aboutToMakeCurrent();
const HWND hwnd = window->handle();
if (const QOpenGLContextData *contextData = findByHWND(m_windowContexts, hwnd)) {
// Repeated calls to wglMakeCurrent when vsync is enabled in the driver will

View File

@ -209,7 +209,7 @@ void QWindowsInputContext::setFocusObject(QObject *object)
imeNotifyCancelComposition(m_compositionContext.hwnd);
const QWindow *window = QGuiApplication::focusWindow();
if (object && window) {
if (object && window && window->handle()) {
QWindowsWindow *platformWindow = QWindowsWindow::baseWindowOf(window);
if (inputMethodAccepted()) {
// Re-enable IME by associating default context saved on first disabling.

View File

@ -130,7 +130,6 @@ struct QWindowsIntegrationPrivate
{
explicit QWindowsIntegrationPrivate(const QStringList &paramList);
~QWindowsIntegrationPrivate();
bool ensureStaticOpenGLContext();
unsigned m_options;
QWindowsContext m_context;
@ -266,7 +265,9 @@ bool QWindowsIntegration::hasCapability(QPlatformIntegration::Capability cap) co
case OpenGL:
return true;
case ThreadedOpenGL:
return d->ensureStaticOpenGLContext() ? d->m_staticOpenGLContext->supportsThreadedOpenGL() : false;
if (const QWindowsStaticOpenGLContext *glContext = QWindowsIntegration::staticOpenGLContext())
return glContext->supportsThreadedOpenGL();
return false;
#endif // !QT_NO_OPENGL
case WindowMasks:
return true;
@ -312,11 +313,6 @@ QWindowsWindowData QWindowsIntegration::createWindowData(QWindow *window) const
QWindowSystemInterface::handleGeometryChange(window, QWindowsScaling::mapFromNative(obtained.geometry));
}
#ifndef QT_NO_OPENGL
d->ensureStaticOpenGLContext();
obtained.staticOpenGLContext = d->m_staticOpenGLContext;
#endif // QT_NO_OPENGL
return obtained;
}
@ -328,61 +324,65 @@ QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) cons
}
#ifndef QT_NO_OPENGL
static QWindowsStaticOpenGLContext *q_staticOpenGLContext = 0;
QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::doCreate()
{
#if defined(QT_OPENGL_DYNAMIC)
QWindowsOpenGLTester::Renderer requestedRenderer = QWindowsOpenGLTester::requestedRenderer();
switch (requestedRenderer) {
case QWindowsOpenGLTester::DesktopGl:
if (QWindowsStaticOpenGLContext *glCtx = QOpenGLStaticContext::create())
return glCtx;
qCWarning(lcQpaGl, "System OpenGL failed. Falling back to Software OpenGL.");
return QOpenGLStaticContext::create(true);
// If ANGLE is requested, use it, don't try anything else.
case QWindowsOpenGLTester::AngleRendererD3d9:
case QWindowsOpenGLTester::AngleRendererD3d11:
case QWindowsOpenGLTester::AngleRendererD3d11Warp:
return QWindowsEGLStaticContext::create(requestedRenderer);
case QWindowsOpenGLTester::Gles:
return QWindowsEGLStaticContext::create(QWindowsOpenGLTester::supportedGlesRenderers());
case QWindowsOpenGLTester::SoftwareRasterizer:
if (QWindowsStaticOpenGLContext *swCtx = QOpenGLStaticContext::create(true))
return swCtx;
qCWarning(lcQpaGl, "Software OpenGL failed. Falling back to system OpenGL.");
if (QWindowsOpenGLTester::supportedRenderers() & QWindowsOpenGLTester::DesktopGl)
return QOpenGLStaticContext::create();
return Q_NULLPTR;
default:
break;
}
const QWindowsOpenGLTester::Renderers supportedRenderers = QWindowsOpenGLTester::supportedRenderers();
if (supportedRenderers & QWindowsOpenGLTester::DesktopGl) {
if (QWindowsStaticOpenGLContext *glCtx = QOpenGLStaticContext::create())
return glCtx;
}
if (QWindowsOpenGLTester::Renderers glesRenderers = supportedRenderers & QWindowsOpenGLTester::GlesMask) {
if (QWindowsEGLStaticContext *eglCtx = QWindowsEGLStaticContext::create(glesRenderers))
return eglCtx;
}
return QOpenGLStaticContext::create(true);
#elif defined(QT_OPENGL_ES_2)
QWindowsOpenGLTester::Renderers glesRenderers = QWindowsOpenGLTester::requestedGlesRenderer();
if (glesRenderers == QWindowsOpenGLTester::InvalidRenderer)
glesRenderers = QWindowsOpenGLTester::supportedGlesRenderers();
return QWindowsEGLStaticContext::create(glesRenderers);
#elif !defined(QT_NO_OPENGL)
return QOpenGLStaticContext::create();
#endif
}
QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::create()
{
QWindowsStaticOpenGLContext *ctx = 0;
#if defined(QT_OPENGL_DYNAMIC)
const QByteArray requested = qgetenv("QT_OPENGL"); // angle, desktop, software
const bool angleRequested = QCoreApplication::testAttribute(Qt::AA_UseOpenGLES) || requested == "angle";
const bool desktopRequested = QCoreApplication::testAttribute(Qt::AA_UseDesktopOpenGL) || requested == "desktop";
const bool softwareRequested = QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL) || requested == "software";
// If ANGLE is requested, use it, don't try anything else.
if (angleRequested) {
ctx = QWindowsEGLStaticContext::create();
} else {
// If opengl32.dll seems to be OpenGL 2.x capable, or desktop OpenGL is requested, use it.
if (!softwareRequested && (desktopRequested || QWindowsOpenGLTester::testDesktopGL()))
ctx = QOpenGLStaticContext::create();
// If failed and desktop OpenGL is not explicitly requested, try ANGLE.
if (!ctx && !desktopRequested && !softwareRequested)
ctx = QWindowsEGLStaticContext::create();
// Try software.
if (!ctx) {
ctx = QOpenGLStaticContext::create(true);
// If software was explicitly requested but failed, try the regular one.
if (!ctx && softwareRequested && QWindowsOpenGLTester::testDesktopGL()) {
qCWarning(lcQpaGl, "Software OpenGL failed. Falling back to system OpenGL.");
ctx = QOpenGLStaticContext::create();
}
}
}
#elif defined(QT_OPENGL_ES_2)
ctx = QWindowsEGLStaticContext::create();
#elif !defined(QT_NO_OPENGL)
ctx = QOpenGLStaticContext::create();
#endif
q_staticOpenGLContext = ctx;
return ctx;
}
bool QWindowsIntegrationPrivate::ensureStaticOpenGLContext()
{
if (m_staticOpenGLContext.isNull())
m_staticOpenGLContext = QSharedPointer<QWindowsStaticOpenGLContext>(QWindowsStaticOpenGLContext::create());
return !m_staticOpenGLContext.isNull();
return QWindowsStaticOpenGLContext::doCreate();
}
QPlatformOpenGLContext *QWindowsIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
{
qCDebug(lcQpaGl) << __FUNCTION__ << context->format();
if (d->ensureStaticOpenGLContext()) {
QScopedPointer<QWindowsOpenGLContext> result(d->m_staticOpenGLContext->createContext(context));
if (QWindowsStaticOpenGLContext *staticOpenGLContext = QWindowsIntegration::staticOpenGLContext()) {
QScopedPointer<QWindowsOpenGLContext> result(staticOpenGLContext->createContext(context));
if (result->isValid())
return result.take();
}
@ -396,13 +396,18 @@ QOpenGLContext::OpenGLModuleType QWindowsIntegration::openGLModuleType()
#elif !defined(QT_OPENGL_DYNAMIC)
return QOpenGLContext::LibGL;
#else
return d->ensureStaticOpenGLContext() ? d->m_staticOpenGLContext->moduleType() : QOpenGLContext::LibGL;
if (const QWindowsStaticOpenGLContext *staticOpenGLContext = QWindowsIntegration::staticOpenGLContext())
return staticOpenGLContext->moduleType();
return QOpenGLContext::LibGL;
#endif
}
QWindowsStaticOpenGLContext *QWindowsIntegration::staticOpenGLContext()
{
return q_staticOpenGLContext;
QWindowsIntegrationPrivate *d = QWindowsIntegration::instance()->d.data();
if (d->m_staticOpenGLContext.isNull())
d->m_staticOpenGLContext = QSharedPointer<QWindowsStaticOpenGLContext>(QWindowsStaticOpenGLContext::create());
return d->m_staticOpenGLContext.data();
}
#endif // !QT_NO_OPENGL

View File

@ -422,11 +422,12 @@ bool QWindowsMouseHandler::translateMouseWheelEvent(QWindow *window, HWND,
}
// from bool QApplicationPrivate::translateTouchEvent()
bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND hwnd,
QtWindows::WindowsEventType,
MSG msg, LRESULT *)
{
#ifndef Q_OS_WINCE
Q_UNUSED(hwnd);
typedef QWindowSystemInterface::TouchPoint QTouchPoint;
typedef QList<QWindowSystemInterface::TouchPoint> QTouchPointList;
@ -495,8 +496,87 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
m_touchDevice,
touchPoints);
return true;
#else
return false;
#else //Q_OS_WINCE
GESTUREINFO gi;
memset(&gi, 0, sizeof(GESTUREINFO));
gi.cbSize = sizeof(GESTUREINFO);
if (!GetGestureInfo((HGESTUREINFO)msg.lParam, &gi))
return false;
const QPoint position = QPoint(gi.ptsLocation.x, gi.ptsLocation.y);
if (gi.dwID != GID_DIRECTMANIPULATION)
return true;
static QPoint lastTouchPos;
const QRect screenGeometry = window->screen()->geometry();
QWindowSystemInterface::TouchPoint touchPoint;
static QWindowSystemInterface::TouchPoint touchPoint2;
touchPoint.id = 0;//gi.dwInstanceID;
touchPoint.pressure = 1.0;
if (gi.dwFlags & GF_BEGIN)
touchPoint.state = Qt::TouchPointPressed;
else if (gi.dwFlags & GF_END)
touchPoint.state = Qt::TouchPointReleased;
else if (gi.dwFlags == 0)
touchPoint.state = Qt::TouchPointMoved;
else
return true;
touchPoint2.pressure = 1.0;
touchPoint2.id = 1;
const QPoint winEventPosition = position;
const int deltaX = GID_DIRECTMANIPULATION_DELTA_X(gi.ullArguments);
const int deltaY = GID_DIRECTMANIPULATION_DELTA_Y(gi.ullArguments);
//Touch points are taken from the whole screen so map the position to the screen
const QPoint globalPosition = QWindowsGeometryHint::mapToGlobal(hwnd, winEventPosition);
const QPoint globalPosition2 = QWindowsGeometryHint::mapToGlobal(hwnd, QPoint(position.x() + deltaX, position.y() + deltaY));
touchPoint.normalPosition =
QPointF( (qreal)globalPosition.x() / screenGeometry.width(), (qreal)globalPosition.y() / screenGeometry.height() );
touchPoint.area.moveCenter(globalPosition);
QList<QWindowSystemInterface::TouchPoint> pointList;
pointList.append(touchPoint);
if (deltaX != 0 && deltaY != 0) {
touchPoint2.state = m_had2ndTouchPoint ? Qt::TouchPointMoved : Qt::TouchPointPressed;
m_had2ndTouchPoint = true;
touchPoint2.normalPosition =
QPointF( (qreal)globalPosition2.x() / screenGeometry.width(), (qreal)globalPosition2.y() / screenGeometry.height() );
touchPoint2.area.moveCenter(globalPosition2);
lastTouchPos = globalPosition2;
pointList.append(touchPoint2);
} else if (m_had2ndTouchPoint) {
touchPoint2.normalPosition =
QPointF( (qreal)lastTouchPos.x() / screenGeometry.width(), (qreal)lastTouchPos.y() / screenGeometry.height() );
touchPoint2.area.moveCenter(lastTouchPos);
touchPoint2.state = Qt::TouchPointReleased;
pointList.append(touchPoint2);
m_had2ndTouchPoint = false;
}
if (!m_touchDevice) {
m_touchDevice = new QTouchDevice;
// TODO: Device used to be hardcoded to screen in previous code.
m_touchDevice->setType(QTouchDevice::TouchScreen);
m_touchDevice->setCapabilities(QTouchDevice::Position | QTouchDevice::Area | QTouchDevice::NormalizedPosition);
QWindowSystemInterface::registerTouchDevice(m_touchDevice);
}
QWindowSystemInterface::handleTouchEvent(window, m_touchDevice, pointList);
// handle window focusing in/out
if (window != m_windowUnderMouse) {
if (m_windowUnderMouse)
QWindowSystemInterface::handleLeaveEvent(m_windowUnderMouse);
if (window)
QWindowSystemInterface::handleEnterEvent(window);
m_windowUnderMouse = window;
}
return true;
#endif
}

View File

@ -79,6 +79,10 @@ private:
QTouchDevice *m_touchDevice;
bool m_leftButtonDown;
QWindow *m_previousCaptureWindow;
#ifdef Q_OS_WINCE
//This is required to send a touch up if we don't get a second touch position any more
bool m_had2ndTouchPoint;
#endif
};
Qt::MouseButtons QWindowsMouseHandler::keyStateToMouseButtons(int wParam)

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the plugins of the Qt Toolkit.
@ -35,6 +35,7 @@
#include "qwindowswindow.h"
#include "qwindowscontext.h"
#include "qwindowsopenglcontext.h"
#include "qwindowsopengltester.h"
#include "qwindowsintegration.h"
#include "qwindowsmime.h"
@ -223,4 +224,9 @@ QFunctionPointer QWindowsNativeInterface::platformFunction(const QByteArray &fun
return Q_NULLPTR;
}
QVariant QWindowsNativeInterface::gpu() const
{
return GpuDescription::detect().toVariant();
}
QT_END_NAMESPACE

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the plugins of the Qt Toolkit.
@ -58,6 +58,7 @@ class QWindowsNativeInterface : public QPlatformNativeInterface
{
Q_OBJECT
Q_PROPERTY(bool asyncExpose READ asyncExpose WRITE setAsyncExpose)
Q_PROPERTY(QVariant gpu READ gpu STORED false)
public:
void *nativeResourceForIntegration(const QByteArray &resource) Q_DECL_OVERRIDE;
@ -81,6 +82,8 @@ public:
bool asyncExpose() const;
void setAsyncExpose(bool value);
QVariant gpu() const;
QVariantMap windowProperties(QPlatformWindow *window) const Q_DECL_OVERRIDE;
QVariant windowProperty(QPlatformWindow *window, const QString &name) const Q_DECL_OVERRIDE;
QVariant windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const Q_DECL_OVERRIDE;

View File

@ -58,6 +58,9 @@ public:
// reimplement these.
virtual void *createWindowSurface(void * /*nativeWindow*/, void * /*nativeConfig*/) { return 0; }
virtual void destroyWindowSurface(void * /*nativeSurface*/) { }
private:
static QWindowsStaticOpenGLContext *doCreate();
};
class QWindowsOpenGLContext : public QPlatformOpenGLContext

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the plugins of the Qt Toolkit.
@ -32,13 +32,231 @@
****************************************************************************/
#include "qwindowsopengltester.h"
#include "qt_windows.h"
#include "qwindowscontext.h"
#include <QtCore/QVariantMap>
#include <QtCore/QDebug>
#include <QtCore/QTextStream>
#include <QtCore/QCoreApplication>
#ifndef Q_OS_WINCE
# include <QtCore/qt_windows.h>
# include <private/qsystemlibrary_p.h>
# include <d3d9.h>
# include <GL/gl.h>
#endif
QT_BEGIN_NAMESPACE
QString GpuDriverVersion::toString() const
{
return QString::number(product)
+ QLatin1Char('.') + QString::number(version)
+ QLatin1Char('.') + QString::number(subVersion)
+ QLatin1Char('.') + QString::number(build);
}
int GpuDriverVersion::compare(const GpuDriverVersion &rhs) const
{
if (product < rhs.product)
return -1;
if (product > rhs.product)
return 1;
if (version < rhs.version)
return -1;
if (version > rhs.version)
return 1;
if (subVersion < rhs.subVersion)
return -1;
if (subVersion > rhs.subVersion)
return 1;
if (build < rhs.build)
return -1;
if (build > rhs.build)
return 1;
return 0;
}
GpuDescription GpuDescription::detect()
{
#ifndef Q_OS_WINCE
typedef IDirect3D9 * (WINAPI *PtrDirect3DCreate9)(UINT);
GpuDescription result;
QSystemLibrary d3d9lib(QStringLiteral("d3d9"));
if (!d3d9lib.load())
return result;
PtrDirect3DCreate9 direct3DCreate9 = (PtrDirect3DCreate9)d3d9lib.resolve("Direct3DCreate9");
if (!direct3DCreate9)
return result;
IDirect3D9 *direct3D9 = direct3DCreate9(D3D_SDK_VERSION);
if (!direct3D9)
return result;
D3DADAPTER_IDENTIFIER9 adapterIdentifier;
const HRESULT hr = direct3D9->GetAdapterIdentifier(0, 0, &adapterIdentifier);
direct3D9->Release();
if (SUCCEEDED(hr)) {
result.vendorId = int(adapterIdentifier.VendorId);
result.deviceId = int(adapterIdentifier.DeviceId);
result.revision = int(adapterIdentifier.Revision);
result.subSysId = int(adapterIdentifier.SubSysId);
result.driverVersion.product = HIWORD(adapterIdentifier.DriverVersion.HighPart);
result.driverVersion.version = LOWORD(adapterIdentifier.DriverVersion.HighPart);
result.driverVersion.subVersion = HIWORD(adapterIdentifier.DriverVersion.LowPart);
result.driverVersion.build = LOWORD(adapterIdentifier.DriverVersion.LowPart);
result.driverName = adapterIdentifier.Driver;
result.description = adapterIdentifier.Description;
}
return result;
#else // !Q_OS_WINCE
GpuDescription result;
result.vendorId = result.deviceId = result.revision
= result.driverVersion.product = result.driverVersion.version
= result.driverVersion.build = 1;
result.driverName = result.description = QByteArrayLiteral("Generic");
return result;
#endif
}
QDebug operator<<(QDebug d, const GpuDriverVersion &v)
{
QDebugStateSaver s(d);
d.nospace();
d << v.product << '.' << v.version << '.' << v.subVersion << '.' << v.build;
return d;
}
QDebug operator<<(QDebug d, const GpuDescription &gd)
{
QDebugStateSaver s(d);
d.nospace();
d << hex << showbase << "GpuDescription(vendorId=" << gd.vendorId
<< ", deviceId=" << gd.deviceId << ", subSysId=" << gd.subSysId
<< dec << noshowbase << ", revision=" << gd.revision
<< ", driver: " << gd.driverName
<< ", version=" << gd.driverVersion << ", " << gd.description << ')';
return d;
}
// Return printable string formatted like the output of the dxdiag tool.
QString GpuDescription::toString() const
{
QString result;
QTextStream str(&result);
str << " Card name: " << description
<< "\n Driver Name: " << driverName
<< "\n Driver Version: " << driverVersion.toString()
<< "\n Vendor ID: 0x" << qSetPadChar(QLatin1Char('0'))
<< uppercasedigits << hex << qSetFieldWidth(4) << vendorId
<< "\n Device ID: 0x" << qSetFieldWidth(4) << deviceId
<< "\n SubSys ID: 0x" << qSetFieldWidth(8) << subSysId
<< "\n Revision ID: 0x" << qSetFieldWidth(4) << revision
<< dec;
return result;
}
QVariant GpuDescription::toVariant() const
{
QVariantMap result;
result.insert(QStringLiteral("vendorId"), QVariant(vendorId));
result.insert(QStringLiteral("deviceId"), QVariant(deviceId));
result.insert(QStringLiteral("subSysId"),QVariant(subSysId));
result.insert(QStringLiteral("revision"), QVariant(revision));
result.insert(QStringLiteral("driver"), QVariant(QLatin1String(driverName)));
result.insert(QStringLiteral("driverProduct"), QVariant(driverVersion.product));
result.insert(QStringLiteral("driverVersion"), QVariant(driverVersion.version));
result.insert(QStringLiteral("driverSubVersion"), QVariant(driverVersion.subVersion));
result.insert(QStringLiteral("driverBuild"), QVariant(driverVersion.build));
result.insert(QStringLiteral("driverVersionString"), driverVersion.toString());
result.insert(QStringLiteral("description"), QVariant(QLatin1String(description)));
result.insert(QStringLiteral("printable"), QVariant(toString()));
return result;
}
QWindowsOpenGLTester::Renderer QWindowsOpenGLTester::requestedGlesRenderer()
{
#ifndef Q_OS_WINCE
const char platformVar[] = "QT_ANGLE_PLATFORM";
if (qEnvironmentVariableIsSet(platformVar)) {
const QByteArray anglePlatform = qgetenv(platformVar);
if (anglePlatform == "d3d11")
return QWindowsOpenGLTester::AngleRendererD3d11;
if (anglePlatform == "d3d9")
return QWindowsOpenGLTester::AngleRendererD3d9;
if (anglePlatform == "warp")
return QWindowsOpenGLTester::AngleRendererD3d11Warp;
qCWarning(lcQpaGl) << "Invalid value set for " << platformVar << ": " << anglePlatform;
}
#endif // !Q_OS_WINCE
return QWindowsOpenGLTester::InvalidRenderer;
}
QWindowsOpenGLTester::Renderer QWindowsOpenGLTester::requestedRenderer()
{
#ifndef Q_OS_WINCE
const char openGlVar[] = "QT_OPENGL";
if (QCoreApplication::testAttribute(Qt::AA_UseOpenGLES)) {
const Renderer glesRenderer = QWindowsOpenGLTester::requestedGlesRenderer();
return glesRenderer != InvalidRenderer ? glesRenderer : Gles;
}
if (QCoreApplication::testAttribute(Qt::AA_UseDesktopOpenGL))
return QWindowsOpenGLTester::DesktopGl;
if (QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL))
return QWindowsOpenGLTester::SoftwareRasterizer;
if (qEnvironmentVariableIsSet(openGlVar)) {
const QByteArray requested = qgetenv(openGlVar);
if (requested == "angle") {
const Renderer glesRenderer = QWindowsOpenGLTester::requestedGlesRenderer();
return glesRenderer != InvalidRenderer ? glesRenderer : Gles;
}
if (requested == "desktop")
return QWindowsOpenGLTester::DesktopGl;
if (requested == "software")
return QWindowsOpenGLTester::SoftwareRasterizer;
qCWarning(lcQpaGl) << "Invalid value set for " << openGlVar << ": " << requested;
}
#endif // !Q_OS_WINCE
return QWindowsOpenGLTester::InvalidRenderer;
}
static inline QWindowsOpenGLTester::Renderers
detectSupportedRenderers(const GpuDescription &gpu, bool glesOnly)
{
Q_UNUSED(gpu)
#ifndef Q_OS_WINCE
// Add checks for card types with known issues here.
QWindowsOpenGLTester::Renderers result(QWindowsOpenGLTester::AngleRendererD3d11
| QWindowsOpenGLTester::AngleRendererD3d9
| QWindowsOpenGLTester::AngleRendererD3d11Warp
| QWindowsOpenGLTester::SoftwareRasterizer);
if (!glesOnly && QWindowsOpenGLTester::testDesktopGL())
result |= QWindowsOpenGLTester::DesktopGl;
return result;
#else // !Q_OS_WINCE
return QWindowsOpenGLTester::Gles;
#endif
}
QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::supportedGlesRenderers()
{
const GpuDescription gpu = GpuDescription::detect();
const QWindowsOpenGLTester::Renderers result = detectSupportedRenderers(gpu, true);
qDebug(lcQpaGl) << __FUNCTION__ << gpu << "renderer: " << result;
return result;
}
QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::supportedRenderers()
{
const GpuDescription gpu = GpuDescription::detect();
const QWindowsOpenGLTester::Renderers result = detectSupportedRenderers(gpu, false);
qDebug(lcQpaGl) << __FUNCTION__ << gpu << "renderer: " << result;
return result;
}
bool QWindowsOpenGLTester::testDesktopGL()
{
#ifndef Q_OS_WINCE
HMODULE lib = 0;
HWND wnd = 0;
HDC dc = 0;
@ -109,6 +327,37 @@ bool QWindowsOpenGLTester::testDesktopGL()
goto cleanup;
// Now that there is finally a context current, try doing something useful.
// Check the version. If we got 1.x then it's all hopeless and we can stop right here.
typedef const GLubyte * (APIENTRY * GetString_t)(GLenum name);
GetString_t GetString = reinterpret_cast<GetString_t>(::GetProcAddress(lib, "glGetString"));
if (GetString) {
const char *versionStr = (const char *) GetString(GL_VERSION);
if (versionStr) {
const QByteArray version(versionStr);
const int majorDot = version.indexOf('.');
if (majorDot != -1) {
int minorDot = version.indexOf('.', majorDot + 1);
if (minorDot == -1)
minorDot = version.size();
const int major = version.mid(0, majorDot).toInt();
const int minor = version.mid(majorDot + 1, minorDot - majorDot - 1).toInt();
qCDebug(lcQpaGl, "Basic wglCreateContext gives version %d.%d", major, minor);
// Try to be as lenient as possible. Missing version, bogus values and
// such are all accepted. The driver may still be functional. Only
// check for known-bad cases, like versions "1.4.0 ...".
if (major == 1) {
result = false;
qCDebug(lcQpaGl, "OpenGL version too low");
}
}
}
} else {
result = false;
qCDebug(lcQpaGl, "OpenGL 1.x entry points not found");
}
// Check for a shader-specific function.
if (WGL_GetProcAddress("glCreateShader")) {
result = true;
qCDebug(lcQpaGl, "OpenGL 2.0 entry points available");
@ -133,6 +382,9 @@ cleanup:
// No FreeLibrary. Some implementations, Mesa in particular, deadlock when trying to unload.
return result;
#else // !Q_OS_WINCE
return false;
#endif
}
QT_END_NAMESPACE

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the plugins of the Qt Toolkit.
@ -31,14 +31,91 @@
**
****************************************************************************/
#ifndef QWINDOWSOPENGLTESTER_H
#define QWINDOWSOPENGLTESTER_H
#include <qtwindowsglobal.h>
#include <QtCore/QByteArray>
#include <QtCore/QFlags>
QT_BEGIN_NAMESPACE
class QDebug;
class QVariant;
struct GpuDriverVersion // ### fixme: Use QVersionNumber in Qt 5.5?
{
GpuDriverVersion(int p = 0, int v = 0, int sv =0, int b = 0) : product(p), version(v), subVersion(sv), build(b) {}
QString toString() const;
int compare(const GpuDriverVersion &rhs) const;
int product;
int version;
int subVersion;
int build;
};
inline bool operator==(const GpuDriverVersion &v1, const GpuDriverVersion &v2)
{ return !v1.compare(v2); }
inline bool operator!=(const GpuDriverVersion &v1, const GpuDriverVersion &v2)
{ return v1.compare(v2); }
inline bool operator< (const GpuDriverVersion &v1, const GpuDriverVersion &v2)
{ return v1.compare(v2) < 0; }
inline bool operator<=(const GpuDriverVersion &v1, const GpuDriverVersion &v2)
{ return v1.compare(v2) <= 0; }
inline bool operator> (const GpuDriverVersion &v1, const GpuDriverVersion &v2)
{ return v1.compare(v2) > 0; }
inline bool operator>=(const GpuDriverVersion &v1, const GpuDriverVersion &v2)
{ return v1.compare(v2) >= 0; }
QDebug operator<<(QDebug d, const GpuDriverVersion &gd);
struct GpuDescription
{
GpuDescription() : vendorId(0), deviceId(0), revision(0), subSysId(0) {}
static GpuDescription detect();
QString toString() const;
QVariant toVariant() const;
int vendorId;
int deviceId;
int revision;
int subSysId;
GpuDriverVersion driverVersion;
QByteArray driverName;
QByteArray description;
};
QDebug operator<<(QDebug d, const GpuDescription &gd);
class QWindowsOpenGLTester
{
public:
enum Renderer {
InvalidRenderer = 0x0000,
DesktopGl = 0x0001,
AngleRendererD3d11 = 0x0002,
AngleRendererD3d9 = 0x0004,
AngleRendererD3d11Warp = 0x0008, // "Windows Advanced Rasterization Platform"
AngleBackendMask = AngleRendererD3d11 | AngleRendererD3d9 | AngleRendererD3d11Warp,
Gles = 0x0010, // ANGLE/unspecified or Generic GLES for Windows CE.
GlesMask = Gles | AngleBackendMask,
SoftwareRasterizer = 0x0020
};
Q_DECLARE_FLAGS(Renderers, Renderer)
static Renderer requestedGlesRenderer();
static Renderer requestedRenderer();
static Renderers supportedGlesRenderers();
static Renderers supportedRenderers();
static bool testDesktopGL();
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QWindowsOpenGLTester::Renderers)
QT_END_NAMESPACE
#endif // QWINDOWSOPENGLTESTER_H

View File

@ -504,4 +504,13 @@ void QWindowsScreenManager::clearScreens()
QWindowsIntegration::instance()->emitDestroyScreen(m_screens.takeLast());
}
const QWindowsScreen *QWindowsScreenManager::screenAtDp(const QPoint &p) const
{
foreach (QWindowsScreen *scr, m_screens) {
if (scr->geometryDp().contains(p))
return scr;
}
return Q_NULLPTR;
}
QT_END_NAMESPACE

View File

@ -133,6 +133,8 @@ public:
bool handleDisplayChange(WPARAM wParam, LPARAM lParam);
const WindowsScreenList &screens() const { return m_screens; }
const QWindowsScreen *screenAtDp(const QPoint &p) const;
private:
void removeScreen(int index);

View File

@ -37,6 +37,7 @@
#include "qwindowsdrag.h"
#include "qwindowsscreen.h"
#include "qwindowsscaling.h"
#include "qwindowsintegration.h"
#ifdef QT_NO_CURSOR
# include "qwindowscursor.h"
#endif
@ -169,6 +170,25 @@ QDebug operator<<(QDebug d, const NCCALCSIZE_PARAMS &p)
}
#endif // !Q_OS_WINCE
// QTBUG-43872, for windows that do not have WS_EX_TOOLWINDOW set, WINDOWPLACEMENT
// is in workspace/available area coordinates.
static QPoint windowPlacementOffset(HWND hwnd, const QPoint &point)
{
#ifndef Q_OS_WINCE
if (GetWindowLongPtr(hwnd, GWL_EXSTYLE) & WS_EX_TOOLWINDOW)
return QPoint(0, 0);
const QWindowsScreenManager &screenManager = QWindowsContext::instance()->screenManager();
const QWindowsScreen *screen = screenManager.screens().size() == 1
? screenManager.screens().first() : screenManager.screenAtDp(point);
if (screen)
return screen->availableGeometryDp().topLeft() - screen->geometryDp().topLeft();
#else
Q_UNUSED(hwnd)
Q_UNUSED(point)
#endif
return QPoint(0, 0);
}
// Return the frame geometry relative to the parent
// if there is one.
static inline QRect frameGeometry(HWND hwnd, bool topLevel)
@ -179,8 +199,10 @@ static inline QRect frameGeometry(HWND hwnd, bool topLevel)
WINDOWPLACEMENT windowPlacement;
windowPlacement.length = sizeof(WINDOWPLACEMENT);
GetWindowPlacement(hwnd, &windowPlacement);
if (windowPlacement.showCmd == SW_SHOWMINIMIZED)
return qrectFromRECT(windowPlacement.rcNormalPosition);
if (windowPlacement.showCmd == SW_SHOWMINIMIZED) {
const QRect result = qrectFromRECT(windowPlacement.rcNormalPosition);
return result.translated(windowPlacementOffset(hwnd, result.topLeft()));
}
}
#endif // !Q_OS_WINCE
GetWindowRect(hwnd, &rect); // Screen coordinates.
@ -205,6 +227,18 @@ static inline QSize clientSize(HWND hwnd)
return qSizeOfRect(rect);
}
static inline bool windowIsOpenGL(const QWindow *w)
{
switch (w->surfaceType()) {
case QSurface::OpenGLSurface:
return true;
case QSurface::RasterGLSurface:
return qt_window_private(const_cast<QWindow *>(w))->compositing;
default:
return false;
}
}
static bool applyBlurBehindWindow(HWND hwnd)
{
#ifdef Q_OS_WINCE
@ -328,6 +362,17 @@ static void setWindowOpacity(HWND hwnd, Qt::WindowFlags flags, bool hasAlpha, bo
#endif // !Q_OS_WINCE
}
static inline void updateGLWindowSettings(const QWindow *w, HWND hwnd, Qt::WindowFlags flags, qreal opacity)
{
const bool isGL = windowIsOpenGL(w);
const bool hasAlpha = w->format().hasAlpha();
if (isGL && hasAlpha)
applyBlurBehindWindow(hwnd);
setWindowOpacity(hwnd, flags, hasAlpha, isGL, opacity);
}
/*!
\class WindowCreationData
\brief Window creation code.
@ -369,14 +414,13 @@ struct WindowCreationData
void fromWindow(const QWindow *w, const Qt::WindowFlags flags, unsigned creationFlags = 0);
inline WindowData create(const QWindow *w, const WindowData &data, QString title) const;
inline void applyWindowFlags(HWND hwnd) const;
void initialize(HWND h, bool frameChange, qreal opacityLevel) const;
void initialize(const QWindow *w, HWND h, bool frameChange, qreal opacityLevel) const;
Qt::WindowFlags flags;
HWND parentHandle;
Qt::WindowType type;
unsigned style;
unsigned exStyle;
bool isGL;
bool topLevel;
bool popup;
bool dialog;
@ -389,7 +433,7 @@ struct WindowCreationData
QDebug operator<<(QDebug debug, const WindowCreationData &d)
{
debug.nospace() << QWindowsWindow::debugWindowFlags(d.flags)
<< " GL=" << d.isGL << " topLevel=" << d.topLevel << " popup="
<< " topLevel=" << d.topLevel << " popup="
<< d.popup << " dialog=" << d.dialog << " desktop=" << d.desktop
<< " embedded=" << d.embedded
<< " tool=" << d.tool << " style=" << debugWinStyle(d.style)
@ -420,8 +464,6 @@ static inline void fixTopLevelWindowFlags(Qt::WindowFlags &flags)
void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flagsIn,
unsigned creationFlags)
{
isGL = w->surfaceType() == QWindow::OpenGLSurface;
hasAlpha = w->format().hasAlpha();
flags = flagsIn;
// Sometimes QWindow doesn't have a QWindow parent but does have a native parent window,
@ -494,7 +536,7 @@ void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flag
// ### Commented out for now as it causes some problems, but
// this should be correct anyway, so dig some more into this
#ifdef Q_FLATTEN_EXPOSE
if (isGL)
if (windowIsOpenGL(w)) // a bit incorrect since the is-opengl status may change from false to true at any time later on
style |= WS_CLIPSIBLINGS | WS_CLIPCHILDREN; // see SetPixelFormat
#else
style |= WS_CLIPSIBLINGS | WS_CLIPCHILDREN ;
@ -514,8 +556,12 @@ void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flag
if (flags & Qt::WindowSystemMenuHint)
style |= WS_SYSMENU;
else if (dialog) {
style |= WS_SYSMENU | WS_BORDER; // QTBUG-2027, dialogs without system menu.
exStyle |= WS_EX_DLGMODALFRAME;
// QTBUG-2027, dialogs without system menu.
style |= WS_SYSMENU;
if (!(flags & Qt::FramelessWindowHint)) {
style |= WS_BORDER;
exStyle |= WS_EX_DLGMODALFRAME;
}
}
if (flags & Qt::WindowMinimizeButtonHint)
style |= WS_MINIMIZEBOX;
@ -569,7 +615,7 @@ QWindowsWindowData
const HINSTANCE appinst = (HINSTANCE)GetModuleHandle(0);
const QString windowClassName = QWindowsContext::instance()->registerWindowClass(w, isGL);
const QString windowClassName = QWindowsContext::instance()->registerWindowClass(w);
const QRect geometryDip = QWindowsScaling::mapFromNative(data.geometry);
QRect fixedGeometryDip = QPlatformWindow::initialGeometry(w, geometryDip, defaultWindowWidth, defaultWindowHeight);
@ -598,6 +644,10 @@ QWindowsWindowData
context->frameX, context->frameY,
context->frameWidth, context->frameHeight,
parentHandle, NULL, appinst, NULL);
#ifdef Q_OS_WINCE
if (DisableGestures(result.hwnd, TGF_GID_ALL, TGF_SCOPE_WINDOW))
EnableGestures(result.hwnd, TGF_GID_DIRECTMANIPULATION, TGF_SCOPE_WINDOW);
#endif
qCDebug(lcQpaWindows).nospace()
<< "CreateWindowEx: returns " << w << ' ' << result.hwnd << " obtained geometry: "
<< context->obtainedGeometry << context->margins;
@ -612,9 +662,6 @@ QWindowsWindowData
result.embedded = embedded;
result.customMargins = context->customMargins;
if (isGL && hasAlpha)
applyBlurBehindWindow(result.hwnd);
return result;
}
@ -637,7 +684,7 @@ void WindowCreationData::applyWindowFlags(HWND hwnd) const
<< debugWinExStyle(newExStyle);
}
void WindowCreationData::initialize(HWND hwnd, bool frameChange, qreal opacityLevel) const
void WindowCreationData::initialize(const QWindow *w, HWND hwnd, bool frameChange, qreal opacityLevel) const
{
if (desktop || !hwnd)
return;
@ -662,8 +709,7 @@ void WindowCreationData::initialize(HWND hwnd, bool frameChange, qreal opacityLe
else
EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_GRAYED);
}
setWindowOpacity(hwnd, flags, hasAlpha, isGL, opacityLevel);
updateGLWindowSettings(w, hwnd, flags, opacityLevel);
} else { // child.
SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, swpFlags);
}
@ -945,7 +991,8 @@ void QWindowsWindow::destroyWindow()
setDropSiteEnabled(false);
#ifndef QT_NO_OPENGL
if (m_surface) {
m_data.staticOpenGLContext->destroyWindowSurface(m_surface);
if (QWindowsStaticOpenGLContext *staticOpenGLContext = QWindowsIntegration::staticOpenGLContext())
staticOpenGLContext->destroyWindowSurface(m_surface);
m_surface = 0;
}
#endif
@ -1036,7 +1083,7 @@ QWindowsWindowData
creationData.fromWindow(w, parameters.flags);
QWindowsWindowData result = creationData.create(w, parameters, title);
// Force WM_NCCALCSIZE (with wParam=1) via SWP_FRAMECHANGED for custom margin.
creationData.initialize(result.hwnd, !parameters.customMargins.isNull(), 1);
creationData.initialize(w, result.hwnd, !parameters.customMargins.isNull(), 1);
return result;
}
@ -1272,8 +1319,10 @@ static QRect normalFrameGeometry(HWND hwnd)
#ifndef Q_OS_WINCE
WINDOWPLACEMENT wp;
wp.length = sizeof(WINDOWPLACEMENT);
if (GetWindowPlacement(hwnd, &wp))
return qrectFromRECT(wp.rcNormalPosition);
if (GetWindowPlacement(hwnd, &wp)) {
const QRect result = qrectFromRECT(wp.rcNormalPosition);
return result.translated(windowPlacementOffset(hwnd, result.topLeft()));
}
#else
Q_UNUSED(hwnd)
#endif
@ -1298,7 +1347,8 @@ void QWindowsWindow::setGeometryDp(const QRect &rectIn)
const QMargins margins = frameMarginsDp();
rect.moveTopLeft(rect.topLeft() + QPoint(margins.left(), margins.top()));
}
m_data.geometry = rect;
if (m_windowState == Qt::WindowMinimized)
m_data.geometry = rect; // Otherwise set by handleGeometryChange() triggered by event.
if (m_data.hwnd) {
// A ResizeEvent with resulting geometry will be sent. If we cannot
// achieve that size (for example, window title minimal constraint),
@ -1369,11 +1419,11 @@ void QWindowsWindow::handleGeometryChange()
// QTBUG-32121: OpenGL/normal windows (with exception of ANGLE) do not receive
// expose events when shrinking, synthesize.
if (!testFlag(OpenGL_ES2) && isExposed()
&& !(m_data.geometry.width() > previousGeometry.width() || m_data.geometry.height() > previousGeometry.height())) {
&& !(m_data.geometry.width() >= previousGeometry.width() || m_data.geometry.height() >= previousGeometry.height())) {
fireExpose(QRect(QPoint(0, 0), m_data.geometry.size()), true);
}
if (previousGeometry.topLeft() != m_data.geometry.topLeft()) {
QPlatformScreen *newScreen = screenForGeometry(m_data.geometry);
QPlatformScreen *newScreen = screenForGeometry(geometryDip);
if (newScreen != screen())
QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->screen());
}
@ -1402,7 +1452,8 @@ void QWindowsWindow::setGeometry_sys(const QRect &rect) const
// window, set the normal position of the window.
if ((windowPlacement.showCmd == SW_MAXIMIZE && !IsWindowVisible(m_data.hwnd))
|| windowPlacement.showCmd == SW_SHOWMINIMIZED) {
windowPlacement.rcNormalPosition = RECTfromQRect(frameGeometry);
windowPlacement.rcNormalPosition =
RECTfromQRect(frameGeometry.translated(-windowPlacementOffset(m_data.hwnd, frameGeometry.topLeft())));
windowPlacement.showCmd = windowPlacement.showCmd == SW_SHOWMINIMIZED ? SW_SHOWMINIMIZED : SW_HIDE;
result = SetWindowPlacement(m_data.hwnd, &windowPlacement);
} else
@ -1523,7 +1574,7 @@ QWindowsWindowData QWindowsWindow::setWindowFlags_sys(Qt::WindowFlags wt,
WindowCreationData creationData;
creationData.fromWindow(window(), wt, flags);
creationData.applyWindowFlags(m_data.hwnd);
creationData.initialize(m_data.hwnd, true, m_opacity);
creationData.initialize(window(), m_data.hwnd, true, m_opacity);
QWindowsWindowData result = m_data;
result.flags = creationData.flags;
@ -2287,8 +2338,10 @@ void *QWindowsWindow::surface(void *nativeConfig)
#ifdef QT_NO_OPENGL
return 0;
#else
if (!m_surface)
m_surface = m_data.staticOpenGLContext->createWindowSurface(m_data.hwnd, nativeConfig);
if (!m_surface) {
if (QWindowsStaticOpenGLContext *staticOpenGLContext = QWindowsIntegration::staticOpenGLContext())
m_surface = staticOpenGLContext->createWindowSurface(m_data.hwnd, nativeConfig);
}
return m_surface;
#endif
@ -2297,7 +2350,8 @@ void *QWindowsWindow::surface(void *nativeConfig)
void QWindowsWindow::invalidateSurface()
{
if (m_surface) {
m_data.staticOpenGLContext->destroyWindowSurface(m_surface);
if (QWindowsStaticOpenGLContext *staticOpenGLContext = QWindowsIntegration::staticOpenGLContext())
staticOpenGLContext->destroyWindowSurface(m_surface);
m_surface = 0;
}
}
@ -2322,4 +2376,22 @@ void QWindowsWindow::registerTouchWindow(QWindowsWindowFunctions::TouchWindowTou
#endif // !Q_OS_WINCE
}
void QWindowsWindow::aboutToMakeCurrent()
{
#ifndef QT_NO_OPENGL
// For RasterGLSurface windows, that become OpenGL windows dynamically, it might be
// time to set up some GL specifics. This is particularly important for layered
// windows (WS_EX_LAYERED due to alpha > 0).
const bool isCompositing = qt_window_private(window())->compositing;
if (isCompositing != testFlag(Compositing)) {
if (isCompositing)
setFlag(Compositing);
else
clearFlag(Compositing);
updateGLWindowSettings(window(), m_data.hwnd, m_data.flags, m_opacity);
}
#endif
}
QT_END_NAMESPACE

View File

@ -108,9 +108,6 @@ struct QWindowsWindowData
QMargins customMargins; // User-defined, additional frame for NCCALCSIZE
HWND hwnd;
bool embedded;
#ifndef QT_NO_OPENGL
QSharedPointer<QWindowsStaticOpenGLContext> staticOpenGLContext;
#endif // QT_NO_OPENGL
static QWindowsWindowData create(const QWindow *w,
const QWindowsWindowData &parameters,
@ -141,7 +138,8 @@ public:
WithinCreate = 0x20000,
WithinMaximize = 0x40000,
MaximizeToFullScreen = 0x80000,
InputMethodDisabled =0x100000
InputMethodDisabled = 0x100000,
Compositing = 0x200000
};
QWindowsWindow(QWindow *window, const QWindowsWindowData &data);
@ -255,6 +253,7 @@ public:
void *surface(void *nativeConfig);
void invalidateSurface() Q_DECL_OVERRIDE;
void aboutToMakeCurrent();
#ifndef Q_OS_WINCE
void setAlertState(bool enabled);

View File

@ -40,7 +40,8 @@ SOURCES += \
$$PWD/qwindowsservices.cpp \
$$PWD/qwindowsnativeimage.cpp \
$$PWD/qwindowsnativeinterface.cpp \
$$PWD/qwindowsscaling.cpp
$$PWD/qwindowsscaling.cpp \
$$PWD/qwindowsopengltester.cpp
HEADERS += \
$$PWD/qwindowswindow.h \
@ -66,9 +67,8 @@ HEADERS += \
$$PWD/qplatformfunctions_wince.h \
$$PWD/qwindowsnativeimage.h \
$$PWD/qwindowsnativeinterface.h \
$$PWD/qwindowsscaling.h
!wince: HEADERS += $$PWD/qwindowsopengltester.h
$$PWD/qwindowsscaling.h \
$$PWD/qwindowsopengltester.h
INCLUDEPATH += $$PWD
@ -84,8 +84,7 @@ contains(QT_CONFIG, opengles2) {
# Dynamic GL needs both WGL and EGL
contains(QT_CONFIG,dynamicgl) {
SOURCES += $$PWD/qwindowseglcontext.cpp \
$$PWD/qwindowsopengltester.cpp
SOURCES += $$PWD/qwindowseglcontext.cpp
HEADERS += $$PWD/qwindowseglcontext.h
}

Some files were not shown because too many files have changed in this diff Show More