summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp4
-rw-r--r--src/plugins/bearer/qnetworksession_impl.cpp4
-rw-r--r--src/plugins/generic/tuiotouch/qtuiohandler.cpp10
-rw-r--r--src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp46
-rw-r--r--src/plugins/platforminputcontexts/platforminputcontexts.pro2
-rw-r--r--src/plugins/platforms/android/android.pro8
-rw-r--r--src/plugins/platforms/android/androidcontentfileengine.cpp92
-rw-r--r--src/plugins/platforms/android/androidcontentfileengine.h (renamed from src/plugins/platforms/offscreen/qoffscreenintegration_dummy.cpp)25
-rw-r--r--src/plugins/platforms/android/androidjniaccessibility.cpp5
-rw-r--r--src/plugins/platforms/android/androidjnimain.cpp5
-rw-r--r--src/plugins/platforms/android/extract-dummy.cpp10
-rw-r--r--src/plugins/platforms/android/extract.cpp40
-rw-r--r--src/plugins/platforms/android/qandroidplatformfiledialoghelper.cpp149
-rw-r--r--src/plugins/platforms/android/qandroidplatformfiledialoghelper.h81
-rw-r--r--src/plugins/platforms/android/qandroidplatformtheme.cpp5
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm46
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm3
-rw-r--r--src/plugins/platforms/cocoa/qnsview_drawing.mm2
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp2
-rw-r--r--src/plugins/platforms/offscreen/offscreen.pro5
-rw-r--r--src/plugins/platforms/offscreen/qoffscreenintegration.cpp14
-rw-r--r--src/plugins/platforms/offscreen/qoffscreenintegration.h1
-rw-r--r--src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp117
-rw-r--r--src/plugins/platforms/offscreen/qoffscreenintegration_x11.h12
-rw-r--r--src/plugins/platforms/qnx/qqnxintegration.cpp23
-rw-r--r--src/plugins/platforms/qnx/qqnxintegration.h1
-rw-r--r--src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp5
-rw-r--r--src/plugins/platforms/qnx/qqnxwindow.cpp88
-rw-r--r--src/plugins/platforms/qnx/qqnxwindow.h4
-rw-r--r--src/plugins/platforms/vnc/qvnc.cpp10
-rw-r--r--src/plugins/platforms/vnc/qvncscreen.cpp2
-rw-r--r--src/plugins/platforms/wasm/qtloader.js8
-rw-r--r--src/plugins/platforms/wasm/qwasmclipboard.cpp204
-rw-r--r--src/plugins/platforms/wasm/qwasmclipboard.h59
-rw-r--r--src/plugins/platforms/wasm/qwasmcursor.cpp8
-rw-r--r--src/plugins/platforms/wasm/qwasmeventtranslator.cpp567
-rw-r--r--src/plugins/platforms/wasm/qwasmeventtranslator.h178
-rw-r--r--src/plugins/platforms/wasm/qwasmintegration.cpp35
-rw-r--r--src/plugins/platforms/wasm/qwasmintegration.h8
-rw-r--r--src/plugins/platforms/wasm/qwasmscreen.cpp5
-rw-r--r--src/plugins/platforms/wasm/qwasmwindow.cpp4
-rw-r--r--src/plugins/platforms/wasm/wasm.pro6
-rw-r--r--src/plugins/platforms/windows/qwindowsinputcontext.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeinterface.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.cpp19
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp8
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.h2
-rw-r--r--src/plugins/platforms/xcb/nativepainting/qpaintengine_x11.cpp2
-rw-r--r--src/plugins/platforms/xcb/nativepainting/qpaintengine_x11_p.h2
-rw-r--r--src/plugins/platforms/xcb/qxcbbackingstore.cpp17
-rw-r--r--src/plugins/platforms/xcb/qxcbclipboard.cpp23
-rw-r--r--src/plugins/platforms/xcb/qxcbclipboard.h4
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp26
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h10
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection_basic.cpp14
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection_basic.h5
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection_screens.cpp4
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection_xi2.cpp6
-rw-r--r--src/plugins/platforms/xcb/qxcbeventqueue.cpp6
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.cpp2
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.cpp2
-rw-r--r--src/plugins/platforms/xcb/qxcbsessionmanager.h2
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp33
-rw-r--r--src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.h2
-rw-r--r--src/plugins/printsupport/cups/qcupsprintengine_p.h4
-rw-r--r--src/plugins/printsupport/windows/qwindowsprintersupport.h2
-rw-r--r--src/plugins/sqldrivers/mysql/qsql_mysql.cpp12
-rw-r--r--src/plugins/sqldrivers/odbc/qsql_odbc.cpp2
-rw-r--r--src/plugins/sqldrivers/psql/main.cpp8
-rw-r--r--src/plugins/sqldrivers/psql/qsql_psql.cpp195
-rw-r--r--src/plugins/sqldrivers/psql/qsql_psql_p.h4
-rw-r--r--src/plugins/styles/android/qandroidstyle_p.h2
-rw-r--r--src/plugins/styles/mac/qmacstyle_mac.mm2
-rw-r--r--src/plugins/styles/mac/qmacstyle_mac_p.h2
-rw-r--r--src/plugins/styles/windowsvista/qwindowsvistastyle.cpp12
-rw-r--r--src/plugins/styles/windowsvista/qwindowsvistastyle_p.h2
-rw-r--r--src/plugins/styles/windowsvista/qwindowsxpstyle.cpp9
-rw-r--r--src/plugins/styles/windowsvista/qwindowsxpstyle_p.h2
79 files changed, 1652 insertions, 704 deletions
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
index 543e66491d..e74b1cf744 100644
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
@@ -465,7 +465,7 @@ void QNetworkManagerEngine::newConnection(const QDBusObjectPath &path,
cpPriv->state |= QNetworkConfiguration::Active;
if (deviceType == DEVICE_TYPE_ETHERNET) {
- for (const auto *interfaceDevice : interfaceDevices) {
+ for (auto interfaceDevice : qAsConst(interfaceDevices)) {
if (interfaceDevice->deviceType() == deviceType) {
auto *wiredDevice = wiredDevices.value(interfaceDevice->path());
if (wiredDevice && wiredDevice->carrier()) {
@@ -716,7 +716,7 @@ QNetworkSession::State QNetworkManagerEngine::sessionStateForId(const QString &i
if (!ptr->isValid)
return QNetworkSession::Invalid;
- for (QNetworkManagerConnectionActive *activeConnection : activeConnectionsList) {
+ for (QNetworkManagerConnectionActive *activeConnection : qAsConst(activeConnectionsList)) {
const QString identifier = activeConnection->connection().path();
if (id == identifier) {
diff --git a/src/plugins/bearer/qnetworksession_impl.cpp b/src/plugins/bearer/qnetworksession_impl.cpp
index 847479047f..a09ae72cb5 100644
--- a/src/plugins/bearer/qnetworksession_impl.cpp
+++ b/src/plugins/bearer/qnetworksession_impl.cpp
@@ -82,8 +82,6 @@ Q_SIGNALS:
void forcedSessionClose(const QNetworkConfiguration &config);
};
-#include "qnetworksession_impl.moc"
-
Q_GLOBAL_STATIC(QNetworkSessionManagerPrivate, sessionManager);
void QNetworkSessionPrivateImpl::syncStateWithInterface()
@@ -432,3 +430,5 @@ void QNetworkSessionPrivateImpl::decrementTimeout()
}
QT_END_NAMESPACE
+
+#include "qnetworksession_impl.moc"
diff --git a/src/plugins/generic/tuiotouch/qtuiohandler.cpp b/src/plugins/generic/tuiotouch/qtuiohandler.cpp
index bb18ba5085..cb82672acd 100644
--- a/src/plugins/generic/tuiotouch/qtuiohandler.cpp
+++ b/src/plugins/generic/tuiotouch/qtuiohandler.cpp
@@ -169,7 +169,7 @@ void QTuioHandler::processPackets()
messages.push_back(msg);
}
- for (const QOscMessage &message : messages) {
+ for (const QOscMessage &message : qAsConst(messages)) {
if (message.addressPattern() == "/tuio/2Dcur") {
QList<QVariant> arguments = message.arguments();
if (arguments.count() == 0) {
@@ -368,12 +368,12 @@ void QTuioHandler::process2DCurFseq(const QOscMessage &message)
QList<QWindowSystemInterface::TouchPoint> tpl;
tpl.reserve(m_activeCursors.size() + m_deadCursors.size());
- for (const QTuioCursor &tc : m_activeCursors) {
+ for (const QTuioCursor &tc : qAsConst(m_activeCursors)) {
QWindowSystemInterface::TouchPoint tp = cursorToTouchPoint(tc, win);
tpl.append(tp);
}
- for (const QTuioCursor &tc : m_deadCursors) {
+ for (const QTuioCursor &tc : qAsConst(m_deadCursors)) {
QWindowSystemInterface::TouchPoint tp = cursorToTouchPoint(tc, win);
tp.state = Qt::TouchPointReleased;
tpl.append(tp);
@@ -542,12 +542,12 @@ void QTuioHandler::process2DObjFseq(const QOscMessage &message)
QList<QWindowSystemInterface::TouchPoint> tpl;
tpl.reserve(m_activeTokens.size() + m_deadTokens.size());
- for (const QTuioToken & t : m_activeTokens) {
+ for (const QTuioToken & t : qAsConst(m_activeTokens)) {
QWindowSystemInterface::TouchPoint tp = tokenToTouchPoint(t, win);
tpl.append(tp);
}
- for (const QTuioToken & t : m_deadTokens) {
+ for (const QTuioToken & t : qAsConst(m_deadTokens)) {
QWindowSystemInterface::TouchPoint tp = tokenToTouchPoint(t, win);
tp.state = Qt::TouchPointReleased;
tp.velocity = QVector2D();
diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
index ca315840e2..7e66439ea7 100644
--- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
+++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
@@ -47,7 +47,9 @@
#include <qpa/qplatformcursor.h>
#include <qpa/qplatformscreen.h>
-#include <qpa/qwindowsysteminterface.h>
+#include <qpa/qwindowsysteminterface_p.h>
+
+#include <QtGui/private/qguiapplication_p.h>
#include "qibusproxy.h"
#include "qibusproxyportal.h"
@@ -217,17 +219,14 @@ void QIBusPlatformInputContext::update(Qt::InputMethodQueries q)
&& (q.testFlag(Qt::ImSurroundingText)
|| q.testFlag(Qt::ImCursorPosition)
|| q.testFlag(Qt::ImAnchorPosition))) {
- QInputMethodQueryEvent srrndTextQuery(Qt::ImSurroundingText);
- QInputMethodQueryEvent cursorPosQuery(Qt::ImCursorPosition);
- QInputMethodQueryEvent anchorPosQuery(Qt::ImAnchorPosition);
- QCoreApplication::sendEvent(input, &srrndTextQuery);
- QCoreApplication::sendEvent(input, &cursorPosQuery);
- QCoreApplication::sendEvent(input, &anchorPosQuery);
+ QInputMethodQueryEvent query(Qt::ImSurroundingText | Qt::ImCursorPosition | Qt::ImAnchorPosition);
+
+ QCoreApplication::sendEvent(input, &query);
- QString surroundingText = srrndTextQuery.value(Qt::ImSurroundingText).toString();
- uint cursorPosition = cursorPosQuery.value(Qt::ImCursorPosition).toUInt();
- uint anchorPosition = anchorPosQuery.value(Qt::ImAnchorPosition).toUInt();
+ QString surroundingText = query.value(Qt::ImSurroundingText).toString();
+ uint cursorPosition = query.value(Qt::ImCursorPosition).toUInt();
+ uint anchorPosition = query.value(Qt::ImAnchorPosition).toUInt();
QIBusText text;
text.text = surroundingText;
@@ -422,9 +421,9 @@ bool QIBusPlatformInputContext::filterEvent(const QEvent *event)
QDBusPendingReply<bool> reply = d->context->ProcessKeyEvent(sym, code - 8, ibusState);
if (m_eventFilterUseSynchronousMode || reply.isFinished()) {
- bool retval = reply.value();
- qCDebug(qtQpaInputMethods) << "filterEvent return" << code << sym << state << retval;
- return retval;
+ bool filtered = reply.value();
+ qCDebug(qtQpaInputMethods) << "filterEvent return" << code << sym << state << filtered;
+ return filtered;
}
Qt::KeyboardModifiers modifiers = keyEvent->modifiers();
@@ -494,23 +493,22 @@ void QIBusPlatformInputContext::filterEventFinished(QDBusPendingCallWatcher *cal
const bool isAutoRepeat = args.at(7).toBool();
// copied from QXcbKeyboard::handleKeyEvent()
- bool retval = reply.value();
- qCDebug(qtQpaInputMethods) << "filterEventFinished return" << code << sym << state << retval;
- if (!retval) {
+ bool filtered = reply.value();
+ qCDebug(qtQpaInputMethods) << "filterEventFinished return" << code << sym << state << filtered;
+ if (!filtered) {
#ifndef QT_NO_CONTEXTMENU
if (type == QEvent::KeyPress && qtcode == Qt::Key_Menu
&& window != NULL) {
const QPoint globalPos = window->screen()->handle()->cursor()->pos();
const QPoint pos = window->mapFromGlobal(globalPos);
-#ifndef QT_NO_CONTEXTMENU
- QWindowSystemInterface::handleContextMenuEvent(window, false, pos,
- globalPos, modifiers);
-#endif
+ QWindowSystemInterfacePrivate::ContextMenuEvent contextMenuEvent(window, false, pos,
+ globalPos, modifiers);
+ QGuiApplicationPrivate::processWindowSystemEvent(&contextMenuEvent);
}
-#endif // QT_NO_CONTEXTMENU
- QWindowSystemInterface::handleExtendedKeyEvent(window, time, type, qtcode, modifiers,
- code, sym, state, string, isAutoRepeat);
-
+#endif
+ QWindowSystemInterfacePrivate::KeyEvent keyEvent(window, time, type, qtcode, modifiers,
+ code, sym, state, string, isAutoRepeat);
+ QGuiApplicationPrivate::processWindowSystemEvent(&keyEvent);
}
call->deleteLater();
}
diff --git a/src/plugins/platforminputcontexts/platforminputcontexts.pro b/src/plugins/platforminputcontexts/platforminputcontexts.pro
index ed6b1b8702..68f6792377 100644
--- a/src/plugins/platforminputcontexts/platforminputcontexts.pro
+++ b/src/plugins/platforminputcontexts/platforminputcontexts.pro
@@ -5,6 +5,6 @@ qtHaveModule(dbus) {
!mac:!win32:SUBDIRS += ibus
}
-qtConfig(xcb): SUBDIRS += compose
+qtConfig(xkbcommon): SUBDIRS += compose
diff --git a/src/plugins/platforms/android/android.pro b/src/plugins/platforms/android/android.pro
index 73db9e93a3..78632a9bea 100644
--- a/src/plugins/platforms/android/android.pro
+++ b/src/plugins/platforms/android/android.pro
@@ -20,6 +20,7 @@ INCLUDEPATH += \
$$QT_SOURCE_TREE/src/3rdparty/android
SOURCES += $$PWD/androidplatformplugin.cpp \
+ $$PWD/androidcontentfileengine.cpp \
$$PWD/androiddeadlockprotector.cpp \
$$PWD/androidjnimain.cpp \
$$PWD/androidjniaccessibility.cpp \
@@ -46,9 +47,11 @@ SOURCES += $$PWD/androidplatformplugin.cpp \
$$PWD/qandroidplatformopenglcontext.cpp \
$$PWD/qandroidplatformforeignwindow.cpp \
$$PWD/qandroideventdispatcher.cpp \
- $$PWD/qandroidplatformoffscreensurface.cpp
+ $$PWD/qandroidplatformoffscreensurface.cpp \
+ $$PWD/qandroidplatformfiledialoghelper.cpp
HEADERS += $$PWD/qandroidplatformintegration.h \
+ $$PWD/androidcontentfileengine.h \
$$PWD/androiddeadlockprotector.h \
$$PWD/androidjnimain.h \
$$PWD/androidjniaccessibility.h \
@@ -75,7 +78,8 @@ HEADERS += $$PWD/qandroidplatformintegration.h \
$$PWD/qandroidplatformopenglcontext.h \
$$PWD/qandroidplatformforeignwindow.h \
$$PWD/qandroideventdispatcher.h \
- $$PWD/qandroidplatformoffscreensurface.h
+ $$PWD/qandroidplatformoffscreensurface.h \
+ $$PWD/qandroidplatformfiledialoghelper.h
qtConfig(android-style-assets): SOURCES += $$PWD/extract.cpp
else: SOURCES += $$PWD/extract-dummy.cpp
diff --git a/src/plugins/platforms/android/androidcontentfileengine.cpp b/src/plugins/platforms/android/androidcontentfileengine.cpp
new file mode 100644
index 0000000000..1444407195
--- /dev/null
+++ b/src/plugins/platforms/android/androidcontentfileengine.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Volker Krause <vkrause@kde.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "androidcontentfileengine.h"
+
+#include <private/qjni_p.h>
+#include <private/qjnihelpers_p.h>
+
+#include <QDebug>
+
+AndroidContentFileEngine::AndroidContentFileEngine(const QString &fileName)
+ : QFSFileEngine(fileName)
+{
+}
+
+bool AndroidContentFileEngine::open(QIODevice::OpenMode openMode)
+{
+ QString openModeStr;
+ if (openMode & QFileDevice::ReadOnly) {
+ openModeStr += QLatin1Char('r');
+ }
+ if (openMode & QFileDevice::WriteOnly) {
+ openModeStr += QLatin1Char('w');
+ }
+ if (openMode & QFileDevice::Truncate) {
+ openModeStr += QLatin1Char('t');
+ } else if (openMode & QFileDevice::Append) {
+ openModeStr += QLatin1Char('a');
+ }
+
+ const auto fd = QJNIObjectPrivate::callStaticMethod<jint>("org/qtproject/qt5/android/QtNative",
+ "openFdForContentUrl",
+ "(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)I",
+ QtAndroidPrivate::context(),
+ QJNIObjectPrivate::fromString(fileName(DefaultName)).object(),
+ QJNIObjectPrivate::fromString(openModeStr).object());
+
+ if (fd < 0) {
+ return false;
+ }
+
+ return QFSFileEngine::open(openMode, fd, QFile::AutoCloseHandle);
+}
+
+
+AndroidContentFileEngineHandler::AndroidContentFileEngineHandler() = default;
+AndroidContentFileEngineHandler::~AndroidContentFileEngineHandler() = default;
+
+QAbstractFileEngine* AndroidContentFileEngineHandler::create(const QString &fileName) const
+{
+ if (!fileName.startsWith(QLatin1String("content"))) {
+ return nullptr;
+ }
+
+ return new AndroidContentFileEngine(fileName);
+}
diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration_dummy.cpp b/src/plugins/platforms/android/androidcontentfileengine.h
index 78b289ea49..db3def03d6 100644
--- a/src/plugins/platforms/offscreen/qoffscreenintegration_dummy.cpp
+++ b/src/plugins/platforms/android/androidcontentfileengine.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2019 Volker Krause <vkrause@kde.org>
** Contact: https://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
@@ -37,9 +37,24 @@
**
****************************************************************************/
-#include "qoffscreenintegration.h"
+#ifndef ANDROIDCONTENTFILEENGINE_H
+#define ANDROIDCONTENTFILEENGINE_H
-QOffscreenIntegration *QOffscreenIntegration::createOffscreenIntegration()
+#include <private/qfsfileengine_p.h>
+
+class AndroidContentFileEngine : public QFSFileEngine
+{
+public:
+ AndroidContentFileEngine(const QString &fileName);
+ bool open(QIODevice::OpenMode openMode) override;
+};
+
+class AndroidContentFileEngineHandler : public QAbstractFileEngineHandler
{
- return new QOffscreenIntegration;
-}
+public:
+ AndroidContentFileEngineHandler();
+ ~AndroidContentFileEngineHandler();
+ QAbstractFileEngine *create(const QString &fileName) const override;
+};
+
+#endif // ANDROIDCONTENTFILEENGINE_H
diff --git a/src/plugins/platforms/android/androidjniaccessibility.cpp b/src/plugins/platforms/android/androidjniaccessibility.cpp
index 309e41bfd6..d4b7f38bf6 100644
--- a/src/plugins/platforms/android/androidjniaccessibility.cpp
+++ b/src/plugins/platforms/android/androidjniaccessibility.cpp
@@ -329,10 +329,7 @@ if (!clazz) { \
GET_AND_CHECK_STATIC_METHOD(m_setFocusedMethodID, nodeInfoClass, "setFocused", "(Z)V");
GET_AND_CHECK_STATIC_METHOD(m_setScrollableMethodID, nodeInfoClass, "setScrollable", "(Z)V");
GET_AND_CHECK_STATIC_METHOD(m_setVisibleToUserMethodID, nodeInfoClass, "setVisibleToUser", "(Z)V");
-
- if (QtAndroidPrivate::androidSdkVersion() >= 18) {
- GET_AND_CHECK_STATIC_METHOD(m_setTextSelectionMethodID, nodeInfoClass, "setTextSelection", "(II)V");
- }
+ GET_AND_CHECK_STATIC_METHOD(m_setTextSelectionMethodID, nodeInfoClass, "setTextSelection", "(II)V");
return true;
}
diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp
index 13d41bea99..37cfbc13ec 100644
--- a/src/plugins/platforms/android/androidjnimain.cpp
+++ b/src/plugins/platforms/android/androidjnimain.cpp
@@ -49,6 +49,7 @@
#include "androidjniinput.h"
#include "androidjniclipboard.h"
#include "androidjnimenu.h"
+#include "androidcontentfileengine.h"
#include "androiddeadlockprotector.h"
#include "qandroidplatformdialoghelpers.h"
#include "qandroidplatformintegration.h"
@@ -116,6 +117,7 @@ static double m_scaledDensity = 0;
static double m_density = 1.0;
static AndroidAssetsFileEngineHandler *m_androidAssetsFileEngineHandler = nullptr;
+static AndroidContentFileEngineHandler *m_androidContentFileEngineHandler = nullptr;
@@ -445,6 +447,7 @@ static jboolean startQtAndroidPlugin(JNIEnv *env, jobject /*object*/, jstring pa
{
m_androidPlatformIntegration = nullptr;
m_androidAssetsFileEngineHandler = new AndroidAssetsFileEngineHandler();
+ m_androidContentFileEngineHandler = new AndroidContentFileEngineHandler();
m_mainLibraryHnd = nullptr;
{ // Set env. vars
const char *nativeString = env->GetStringUTFChars(environmentString, 0);
@@ -555,6 +558,8 @@ static void quitQtAndroidPlugin(JNIEnv *env, jclass /*clazz*/)
m_androidPlatformIntegration = nullptr;
delete m_androidAssetsFileEngineHandler;
m_androidAssetsFileEngineHandler = nullptr;
+ delete m_androidContentFileEngineHandler;
+ m_androidContentFileEngineHandler = nullptr;
}
static void terminateQt(JNIEnv *env, jclass /*clazz*/)
diff --git a/src/plugins/platforms/android/extract-dummy.cpp b/src/plugins/platforms/android/extract-dummy.cpp
index d07fbe1ba7..fdce8ec64c 100644
--- a/src/plugins/platforms/android/extract-dummy.cpp
+++ b/src/plugins/platforms/android/extract-dummy.cpp
@@ -40,16 +40,6 @@
#include <jni.h>
#include <extract.h>
-extern "C" JNIEXPORT jintArray JNICALL Java_org_qtproject_qt5_android_ExtractStyle_extractNativeChunkInfo(JNIEnv *, jobject, Res_png_9patch*)
-{
- return 0;
-}
-
-extern "C" JNIEXPORT jintArray JNICALL Java_org_qtproject_qt5_android_ExtractStyle_extractChunkInfo(JNIEnv *, jobject, jbyteArray)
-{
- return 0;
-}
-
extern "C" JNIEXPORT jintArray JNICALL Java_org_qtproject_qt5_android_ExtractStyle_extractNativeChunkInfo20(JNIEnv *, jobject, long)
{
return 0;
diff --git a/src/plugins/platforms/android/extract.cpp b/src/plugins/platforms/android/extract.cpp
index 2f2ffa7126..acffa353f1 100644
--- a/src/plugins/platforms/android/extract.cpp
+++ b/src/plugins/platforms/android/extract.cpp
@@ -48,46 +48,6 @@
#define LOG_TAG "extractSyleInfo"
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
-extern "C" JNIEXPORT jintArray JNICALL Java_org_qtproject_qt5_android_ExtractStyle_extractNativeChunkInfo(JNIEnv * env, jobject, Res_png_9patch* chunk)
-{
- Res_png_9patch::deserialize(chunk);
- //printChunkInformation(chunk);
- jintArray result;
- size_t size = 3+chunk->numXDivs+chunk->numYDivs+chunk->numColors;
- result = env->NewIntArray(size);
- if (!result)
- return 0;
-
- jint *data = (jint*)malloc(sizeof(jint)*size);
- size_t pos = 0;
- data[pos++]=chunk->numXDivs;
- data[pos++]=chunk->numYDivs;
- data[pos++]=chunk->numColors;
- for (int x = 0; x <chunk->numXDivs; x ++)
- data[pos++]=chunk->xDivs[x];
- for (int y = 0; y <chunk->numYDivs; y ++)
- data[pos++]=chunk->yDivs[y];
- for (int c = 0; c <chunk->numColors; c ++)
- data[pos++]=chunk->colors[c];
- env->SetIntArrayRegion(result, 0, size, data);
- free(data);
- return result;
-}
-
-extern "C" JNIEXPORT jintArray JNICALL Java_org_qtproject_qt5_android_ExtractStyle_extractChunkInfo(JNIEnv * env, jobject obj, jbyteArray chunkObj)
-{
- size_t chunkSize = env->GetArrayLength(chunkObj);
- void* storage = alloca(chunkSize);
- env->GetByteArrayRegion(chunkObj, 0, chunkSize,
- reinterpret_cast<jbyte*>(storage));
-
- if (!env->ExceptionCheck())
- return Java_org_qtproject_qt5_android_ExtractStyle_extractNativeChunkInfo(env, obj, static_cast<Res_png_9patch*>(storage));
- else
- env->ExceptionClear();
- return 0;
-}
-
// The following part was shamelessly stolen from ResourceTypes.cpp from Android's sources
/*
* Copyright (C) 2005 The Android Open Source Project
diff --git a/src/plugins/platforms/android/qandroidplatformfiledialoghelper.cpp b/src/plugins/platforms/android/qandroidplatformfiledialoghelper.cpp
new file mode 100644
index 0000000000..4fb271a75c
--- /dev/null
+++ b/src/plugins/platforms/android/qandroidplatformfiledialoghelper.cpp
@@ -0,0 +1,149 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qandroidplatformfiledialoghelper.h"
+
+#include <androidjnimain.h>
+#include <private/qjni_p.h>
+#include <jni.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtAndroidFileDialogHelper {
+
+#define RESULT_OK -1
+#define REQUEST_CODE 1305 // Arbitrary
+
+QAndroidPlatformFileDialogHelper::QAndroidPlatformFileDialogHelper()
+ : QPlatformFileDialogHelper()
+ , m_selectedFile()
+{
+}
+
+bool QAndroidPlatformFileDialogHelper::handleActivityResult(jint requestCode, jint resultCode, jobject data)
+{
+ if (requestCode != REQUEST_CODE)
+ return false;
+
+ if (resultCode == RESULT_OK) {
+ const QJNIObjectPrivate intent = QJNIObjectPrivate::fromLocalRef(data);
+ const QJNIObjectPrivate uri = intent.callObjectMethod("getData", "()Landroid/net/Uri;");
+ const QString uriStr = uri.callObjectMethod("toString", "()Ljava/lang/String;").toString();
+ m_selectedFile = QUrl(uriStr);
+ Q_EMIT fileSelected(m_selectedFile);
+ Q_EMIT accept();
+ } else {
+ Q_EMIT reject();
+ }
+
+ return true;
+}
+
+bool QAndroidPlatformFileDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
+{
+ Q_UNUSED(windowFlags)
+ Q_UNUSED(windowModality)
+ Q_UNUSED(parent)
+
+ if (options()->fileMode() != QFileDialogOptions::FileMode::ExistingFile)
+ return false;
+
+ QtAndroidPrivate::registerActivityResultListener(this);
+
+ const QJNIObjectPrivate ACTION_OPEN_DOCUMENT = QJNIObjectPrivate::getStaticObjectField("android/content/Intent", "ACTION_OPEN_DOCUMENT", "Ljava/lang/String;");
+ QJNIObjectPrivate intent("android/content/Intent", "(Ljava/lang/String;)V", ACTION_OPEN_DOCUMENT.object());
+ const QJNIObjectPrivate CATEGORY_OPENABLE = QJNIObjectPrivate::getStaticObjectField("android/content/Intent", "CATEGORY_OPENABLE", "Ljava/lang/String;");
+ intent.callObjectMethod("addCategory", "(Ljava/lang/String;)Landroid/content/Intent;", CATEGORY_OPENABLE.object());
+ intent.callObjectMethod("setType", "(Ljava/lang/String;)Landroid/content/Intent;", QJNIObjectPrivate::fromString(QStringLiteral("*/*")).object());
+
+ const QJNIObjectPrivate activity(QtAndroid::activity());
+ activity.callMethod<void>("startActivityForResult", "(Landroid/content/Intent;I)V", intent.object(), REQUEST_CODE);
+
+ return true;
+}
+
+void QAndroidPlatformFileDialogHelper::exec()
+{
+}
+
+void QAndroidPlatformFileDialogHelper::hide()
+{
+}
+
+QString QAndroidPlatformFileDialogHelper::selectedNameFilter() const
+{
+ return QString();
+}
+
+void QAndroidPlatformFileDialogHelper::selectNameFilter(const QString &filter)
+{
+ Q_UNUSED(filter)
+}
+
+void QAndroidPlatformFileDialogHelper::setFilter()
+{
+}
+
+QList<QUrl> QAndroidPlatformFileDialogHelper::selectedFiles() const
+{
+ return {m_selectedFile};
+}
+
+void QAndroidPlatformFileDialogHelper::selectFile(const QUrl &file)
+{
+ Q_UNUSED(file)
+}
+
+QUrl QAndroidPlatformFileDialogHelper::directory() const
+{
+ return QUrl();
+}
+
+void QAndroidPlatformFileDialogHelper::setDirectory(const QUrl &directory)
+{
+ Q_UNUSED(directory)
+}
+
+bool QAndroidPlatformFileDialogHelper::defaultNameFilterDisables() const
+{
+ return false;
+}
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/android/qandroidplatformfiledialoghelper.h b/src/plugins/platforms/android/qandroidplatformfiledialoghelper.h
new file mode 100644
index 0000000000..e445aa2fef
--- /dev/null
+++ b/src/plugins/platforms/android/qandroidplatformfiledialoghelper.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB)
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QANDROIDPLATFORMFILEDIALOGHELPER_H
+#define QANDROIDPLATFORMFILEDIALOGHELPER_H
+
+#include <jni.h>
+#include <qpa/qplatformdialoghelper.h>
+#include <QtCore/private/qjnihelpers_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtAndroidFileDialogHelper {
+
+class QAndroidPlatformFileDialogHelper: public QPlatformFileDialogHelper, public QtAndroidPrivate::ActivityResultListener
+{
+ Q_OBJECT
+
+public:
+ QAndroidPlatformFileDialogHelper();
+ void exec() override;
+
+ bool show(Qt::WindowFlags windowFlags,
+ Qt::WindowModality windowModality,
+ QWindow *parent) override;
+ void hide() override;
+
+ QString selectedNameFilter() const override;
+ void selectNameFilter(const QString &filter) override;
+ void setFilter() override;
+ QList<QUrl> selectedFiles() const override;
+ void selectFile(const QUrl &file) override;
+ QUrl directory() const override;
+ void setDirectory(const QUrl &directory) override;
+ bool defaultNameFilterDisables() const override;
+ bool handleActivityResult(jint requestCode, jint resultCode, jobject data) override;
+
+private:
+ QUrl m_selectedFile;
+};
+
+}
+QT_END_NAMESPACE
+
+#endif // QANDROIDPLATFORMFILEDIALOGHELPER_H
diff --git a/src/plugins/platforms/android/qandroidplatformtheme.cpp b/src/plugins/platforms/android/qandroidplatformtheme.cpp
index b891407c44..a78a62337f 100644
--- a/src/plugins/platforms/android/qandroidplatformtheme.cpp
+++ b/src/plugins/platforms/android/qandroidplatformtheme.cpp
@@ -44,6 +44,7 @@
#include "qandroidplatformmenu.h"
#include "qandroidplatformmenuitem.h"
#include "qandroidplatformdialoghelpers.h"
+#include "qandroidplatformfiledialoghelper.h"
#include <QCoreApplication>
#include <QDebug>
@@ -512,6 +513,8 @@ bool QAndroidPlatformTheme::usePlatformNativeDialog(QPlatformTheme::DialogType t
{
if (type == MessageDialog)
return qEnvironmentVariableIntValue("QT_USE_ANDROID_NATIVE_DIALOGS") == 1;
+ if (type == FileDialog)
+ return true;
return false;
}
@@ -520,6 +523,8 @@ QPlatformDialogHelper *QAndroidPlatformTheme::createPlatformDialogHelper(QPlatfo
switch (type) {
case MessageDialog:
return new QtAndroidDialogHelpers::QAndroidPlatformMessageDialogHelper;
+ case FileDialog:
+ return new QtAndroidFileDialogHelper::QAndroidPlatformFileDialogHelper;
default:
return 0;
}
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
index f26263261c..f0ef70e3a3 100644
--- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
+++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
@@ -51,6 +51,19 @@ QT_USE_NAMESPACE
#ifndef QT_NO_ACCESSIBILITY
+/**
+ * Converts between absolute character offsets and line numbers of a
+ * QAccessibleTextInterface. Works in exactly one of two modes:
+ *
+ * - Pass *line == -1 in order to get a line containing character at the given
+ * *offset
+ * - Pass *offset == -1 in order to get the offset of first character of the
+ * given *line
+ *
+ * You can optionally also pass non-NULL `start` and `end`, which will in both
+ * modes be filled with the offset of the first and last characters of the
+ * relevant line.
+ */
static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *offset, NSUInteger *start = 0, NSUInteger *end = 0)
{
Q_ASSERT(*line == -1 || *offset == -1);
@@ -224,7 +237,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
return [attributes autorelease];
}
-- (id)parentElement {
+- (id)accessibilityParent {
QAccessibleInterface *iface = QAccessible::accessibleInterface(axid);
if (!iface || !iface->isValid())
return nil;
@@ -237,7 +250,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
if (QAccessibleInterface *parent = iface->parent()) {
if (parent->role() != QAccessible::Application) {
QAccessible::Id parentId = QAccessible::uniqueId(parent);
- return [QMacAccessibilityElement elementWithId: parentId];
+ return NSAccessibilityUnignoredAncestor([QMacAccessibilityElement elementWithId: parentId]);
}
}
@@ -245,12 +258,18 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
QPlatformWindow *platformWindow = window->handle();
if (platformWindow) {
QCocoaWindow *win = static_cast<QCocoaWindow*>(platformWindow);
- return qnsview_cast(win->view());
+ return NSAccessibilityUnignoredAncestor(qnsview_cast(win->view()));
}
}
return nil;
}
+- (NSRect)accessibilityFrame {
+ QAccessibleInterface *iface = QAccessible::accessibleInterface(axid);
+ if (!iface || !iface->isValid())
+ return NSZeroRect;
+ return QCocoaScreen::mapToNative(iface->rect());
+}
- (id) minValueAttribute:(QAccessibleInterface*)iface {
if (QAccessibleValueInterface *val = iface->valueInterface())
@@ -285,13 +304,13 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
id focusedElement = [NSApp accessibilityAttributeValue:NSAccessibilityFocusedUIElementAttribute];
return @([focusedElement isEqual:self]);
} else if ([attribute isEqualToString:NSAccessibilityParentAttribute]) {
- return NSAccessibilityUnignoredAncestor([self parentElement]);
+ return self.accessibilityParent;
} else if ([attribute isEqualToString:NSAccessibilityWindowAttribute]) {
// We're in the same window as our parent.
- return [[self parentElement] accessibilityAttributeValue:NSAccessibilityWindowAttribute];
+ return [[self accessibilityParent] accessibilityAttributeValue:NSAccessibilityWindowAttribute];
} else if ([attribute isEqualToString:NSAccessibilityTopLevelUIElementAttribute]) {
// We're in the same top level element as our parent.
- return [[self parentElement] accessibilityAttributeValue:NSAccessibilityTopLevelUIElementAttribute];
+ return [[self accessibilityParent] accessibilityAttributeValue:NSAccessibilityTopLevelUIElementAttribute];
} else if ([attribute isEqualToString:NSAccessibilityPositionAttribute]) {
// The position in points of the element's lower-left corner in screen-relative coordinates
QPointF qtPosition = QRectF(iface->rect()).bottomLeft();
@@ -347,12 +366,8 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
return [NSValue valueWithRange: NSMakeRange(0, iface->text(QAccessible::Name).length())];
} else if ([attribute isEqualToString:NSAccessibilityInsertionPointLineNumberAttribute]) {
if (QAccessibleTextInterface *text = iface->textInterface()) {
- int line = 0; // true for all single line edits
- if (iface->state().multiLine) {
- int position = text->cursorPosition();
- convertLineOffset(text, &line, &position);
- }
- return @(line);
+ int position = text->cursorPosition();
+ return [self accessibilityAttributeValue:NSAccessibilityLineForIndexParameterizedAttribute forParameter:@(position)];
}
return nil;
} else if ([attribute isEqualToString:NSAccessibilityMinValueAttribute]) {
@@ -408,8 +423,11 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
int index = [parameter intValue];
if (index < 0 || index > iface->textInterface()->characterCount())
return nil;
- int line = -1;
- convertLineOffset(iface->textInterface(), &line, &index);
+ int line = 0; // true for all single line edits
+ if (iface->state().multiLine) {
+ line = -1;
+ convertLineOffset(iface->textInterface(), &line, &index);
+ }
return @(line);
}
if ([attribute isEqualToString: NSAccessibilityRangeForLineParameterizedAttribute]) {
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
index 93d95b38ea..fe1fc31553 100644
--- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
@@ -86,7 +86,7 @@ QCocoaGLContext::QCocoaGLContext(QOpenGLContext *context)
}
m_context = nativeHandle.value<QCocoaNativeContext>().context();
if (!m_context) {
- qCWarning(lcQpaOpenGLContext, "QCocoaNativeContext's NSOpenGLContext can not be null");
+ qCWarning(lcQpaOpenGLContext, "QCocoaNativeContext's NSOpenGLContext cannot be null");
return;
}
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 50adbad518..298d11fe08 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -217,6 +217,7 @@ QCocoaWindow::~QCocoaWindow()
}
[m_view release];
+ [m_nsWindow close];
[m_nsWindow release];
}
@@ -618,7 +619,7 @@ void QCocoaWindow::applyWindowState(Qt::WindowStates requestedState)
if (nsWindow.styleMask & NSWindowStyleMaskUtilityWindow
&& newState & (Qt::WindowMinimized | Qt::WindowFullScreen)) {
- qWarning() << window()->type() << "windows can not be made" << newState;
+ qWarning() << window()->type() << "windows cannot be made" << newState;
handleWindowStateChanged(HandleUnconditionally);
return;
}
diff --git a/src/plugins/platforms/cocoa/qnsview_drawing.mm b/src/plugins/platforms/cocoa/qnsview_drawing.mm
index e9af90a45c..6db5ed8bad 100644
--- a/src/plugins/platforms/cocoa/qnsview_drawing.mm
+++ b/src/plugins/platforms/cocoa/qnsview_drawing.mm
@@ -106,7 +106,7 @@
"_q_mac_wantsLayer", "QT_MAC_WANTS_LAYER");
if (wantsLayer != -1 && [self layerEnabledByMacOS]) {
- qCWarning(lcQpaDrawing) << "Layer-backing can not be explicitly controlled on 10.14 when built against the 10.14 SDK";
+ qCWarning(lcQpaDrawing) << "Layer-backing cannot be explicitly controlled on 10.14 when built against the 10.14 SDK";
return true;
}
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp
index 24f82e7843..24051c352e 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp
@@ -423,7 +423,7 @@ void QEglFSKmsGbmScreen::updateFlipStatus()
if (m_flipPending)
return;
- for (const CloneDestination &d : m_cloneDests) {
+ for (const CloneDestination &d : qAsConst(m_cloneDests)) {
if (d.cloneFlipPending)
return;
}
diff --git a/src/plugins/platforms/offscreen/offscreen.pro b/src/plugins/platforms/offscreen/offscreen.pro
index 392ee8bed1..f226132592 100644
--- a/src/plugins/platforms/offscreen/offscreen.pro
+++ b/src/plugins/platforms/offscreen/offscreen.pro
@@ -17,13 +17,10 @@ HEADERS = qoffscreenintegration.h \
OTHER_FILES += offscreen.json
-qtConfig(system-xcb):qtConfig(xlib):qtConfig(opengl):!qtConfig(opengles2) {
+qtConfig(xlib):qtConfig(opengl):!qtConfig(opengles2) {
SOURCES += qoffscreenintegration_x11.cpp
HEADERS += qoffscreenintegration_x11.h
QT += glx_support-private
- system(echo "Using X11 offscreen integration with GLX")
-} else {
- SOURCES += qoffscreenintegration_dummy.cpp
}
PLUGIN_TYPE = platforms
diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
index 9815be16a3..f2933b7179 100644
--- a/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+++ b/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
@@ -66,6 +66,10 @@
#include <qpa/qplatformservices.h>
+#if QT_CONFIG(xlib) && QT_CONFIG(opengl) && !QT_CONFIG(opengles2)
+#include "qoffscreenintegration_x11.h"
+#endif
+
QT_BEGIN_NAMESPACE
class QCoreTextFontEngine;
@@ -219,4 +223,14 @@ QPlatformServices *QOffscreenIntegration::services() const
return m_services.data();
}
+QOffscreenIntegration *QOffscreenIntegration::createOffscreenIntegration()
+{
+#if QT_CONFIG(xlib) && QT_CONFIG(opengl) && !QT_CONFIG(opengles2)
+ QByteArray glx = qgetenv("QT_QPA_OFFSCREEN_NO_GLX");
+ if (glx.isEmpty())
+ return new QOffscreenX11Integration;
+#endif
+ return new QOffscreenIntegration;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration.h b/src/plugins/platforms/offscreen/qoffscreenintegration.h
index fc988126bb..098e726550 100644
--- a/src/plugins/platforms/offscreen/qoffscreenintegration.h
+++ b/src/plugins/platforms/offscreen/qoffscreenintegration.h
@@ -41,6 +41,7 @@
#define QOFFSCREENINTEGRATION_H
#include <qpa/qplatformintegration.h>
+#include <qpa/qplatformnativeinterface.h>
#include <qscopedpointer.h>
diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp
index 93566220e8..92fc8aa57a 100644
--- a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp
+++ b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp
@@ -41,6 +41,7 @@
#include <QByteArray>
#include <QOpenGLContext>
+#include <QtPlatformHeaders/QGLXNativeContext>
#include <X11/Xlib.h>
#include <GL/glx.h>
@@ -52,16 +53,36 @@
QT_BEGIN_NAMESPACE
-QOffscreenIntegration *QOffscreenIntegration::createOffscreenIntegration()
+class QOffscreenX11Info
{
- return new QOffscreenX11Integration;
-}
+public:
+ QOffscreenX11Info(QOffscreenX11Connection *connection)
+ : m_connection(connection)
+ {
+ }
+
+ Display *display() const {
+ return (Display *)m_connection->display();
+ }
+
+ Window root() const {
+ return DefaultRootWindow(display());
+ }
+
+ int screenNumber() const {
+ return m_connection->screenNumber();
+ }
+
+private:
+ QOffscreenX11Connection *m_connection;
+};
bool QOffscreenX11Integration::hasCapability(QPlatformIntegration::Capability cap) const
{
switch (cap) {
case OpenGL: return true;
case ThreadedOpenGL: return true;
+ case RasterGLSurface: return true;
default: return QOffscreenIntegration::hasCapability(cap);
}
}
@@ -77,6 +98,40 @@ QPlatformOpenGLContext *QOffscreenX11Integration::createPlatformOpenGLContext(QO
return new QOffscreenX11GLXContext(m_connection->x11Info(), context);
}
+QPlatformNativeInterface *QOffscreenX11Integration::nativeInterface() const
+{
+ return const_cast<QOffscreenX11Integration *>(this);
+}
+
+void *QOffscreenX11Integration::nativeResourceForScreen(const QByteArray &resource, QScreen *screen)
+{
+ Q_UNUSED(screen)
+ if (resource.toLower() == QByteArrayLiteral("display") ) {
+ if (!m_connection)
+ m_connection.reset(new QOffscreenX11Connection);
+ return m_connection->display();
+ }
+ return nullptr;
+}
+
+#ifndef QT_NO_OPENGL
+void *QOffscreenX11Integration::nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) {
+ if (resource.toLower() == QByteArrayLiteral("glxconfig") ) {
+ if (context) {
+ QOffscreenX11GLXContext *glxPlatformContext = static_cast<QOffscreenX11GLXContext *>(context->handle());
+ return glxPlatformContext->glxConfig();
+ }
+ }
+ if (resource.toLower() == QByteArrayLiteral("glxcontext") ) {
+ if (context) {
+ QOffscreenX11GLXContext *glxPlatformContext = static_cast<QOffscreenX11GLXContext *>(context->handle());
+ return glxPlatformContext->glxContext();
+ }
+ }
+ return nullptr;
+}
+#endif
+
QOffscreenX11Connection::QOffscreenX11Connection()
{
XInitThreads();
@@ -93,30 +148,6 @@ QOffscreenX11Connection::~QOffscreenX11Connection()
XCloseDisplay((Display *)m_display);
}
-class QOffscreenX11Info
-{
-public:
- QOffscreenX11Info(QOffscreenX11Connection *connection)
- : m_connection(connection)
- {
- }
-
- Display *display() const {
- return (Display *)m_connection->display();
- }
-
- Window root() const {
- return DefaultRootWindow(display());
- }
-
- int screenNumber() const {
- return m_connection->screenNumber();
- }
-
-private:
- QOffscreenX11Connection *m_connection;
-};
-
QOffscreenX11Info *QOffscreenX11Connection::x11Info()
{
if (!m_x11Info)
@@ -127,11 +158,12 @@ QOffscreenX11Info *QOffscreenX11Connection::x11Info()
class QOffscreenX11GLXContextData
{
public:
- QOffscreenX11Info *x11;
+ QOffscreenX11Info *x11 = nullptr;
QSurfaceFormat format;
- GLXContext context;
- GLXContext shareContext;
- Window window;
+ GLXContext context = nullptr;
+ GLXContext shareContext = nullptr;
+ GLXFBConfig config = nullptr;
+ Window window = 0;
};
static Window createDummyWindow(QOffscreenX11Info *x11, XVisualInfo *visualInfo)
@@ -142,6 +174,7 @@ static Window createDummyWindow(QOffscreenX11Info *x11, XVisualInfo *visualInfo)
a.border_pixel = BlackPixel(x11->display(), x11->screenNumber());
a.colormap = cmap;
+
Window window = XCreateWindow(x11->display(), x11->root(),
0, 0, 100, 100,
0, visualInfo->depth, InputOutput, visualInfo->visual,
@@ -163,14 +196,23 @@ static Window createDummyWindow(QOffscreenX11Info *x11, GLXFBConfig config)
QOffscreenX11GLXContext::QOffscreenX11GLXContext(QOffscreenX11Info *x11, QOpenGLContext *context)
: d(new QOffscreenX11GLXContextData)
{
+
d->x11 = x11;
d->format = context->format();
+ if (d->format.renderableType() == QSurfaceFormat::DefaultRenderableType)
+ d->format.setRenderableType(QSurfaceFormat::OpenGL);
+
+ if (d->format.renderableType() != QSurfaceFormat::OpenGL)
+ return;
+
d->shareContext = 0;
if (context->shareHandle())
d->shareContext = static_cast<QOffscreenX11GLXContext *>(context->shareHandle())->d->context;
GLXFBConfig config = qglx_findConfig(x11->display(), x11->screenNumber(), d->format);
+ d->config = config;
+
if (config) {
d->context = glXCreateNewContext(x11->display(), config, GLX_RGBA_TYPE, d->shareContext, true);
if (!d->context && d->shareContext) {
@@ -199,6 +241,9 @@ QOffscreenX11GLXContext::QOffscreenX11GLXContext(QOffscreenX11Info *x11, QOpenGL
d->window = createDummyWindow(x11, visualInfo);
XFree(visualInfo);
}
+ if (d->context)
+ context->setNativeHandle(QVariant::fromValue<QGLXNativeContext>(QGLXNativeContext(d->context)));
+
}
QOffscreenX11GLXContext::~QOffscreenX11GLXContext()
@@ -251,4 +296,14 @@ bool QOffscreenX11GLXContext::isValid() const
return d->context && d->window;
}
+void *QOffscreenX11GLXContext::glxContext() const
+{
+ return d->context;
+}
+
+void *QOffscreenX11GLXContext::glxConfig() const
+{
+ return d->config;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.h b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.h
index 5e1c6b799b..5ef51a15a8 100644
--- a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.h
+++ b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.h
@@ -52,12 +52,19 @@ QT_BEGIN_NAMESPACE
class QOffscreenX11Connection;
class QOffscreenX11Info;
-class QOffscreenX11Integration : public QOffscreenIntegration
+class QOffscreenX11Integration : public QOffscreenIntegration, public QPlatformNativeInterface
{
public:
bool hasCapability(QPlatformIntegration::Capability cap) const override;
QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const override;
+ QPlatformNativeInterface *nativeInterface()const override;
+
+ // QPlatformNativeInterface
+ void *nativeResourceForScreen(const QByteArray &resource, QScreen *screen) override;
+#ifndef QT_NO_OPENGL
+ void *nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) override;
+#endif
private:
mutable QScopedPointer<QOffscreenX11Connection> m_connection;
@@ -97,6 +104,9 @@ public:
bool isSharing() const override;
bool isValid() const override;
+ void *glxConfig() const;
+ void *glxContext() const;
+
private:
QScopedPointer<QOffscreenX11GLXContextData> d;
};
diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp
index db79780407..a996e765c4 100644
--- a/src/plugins/platforms/qnx/qqnxintegration.cpp
+++ b/src/plugins/platforms/qnx/qqnxintegration.cpp
@@ -72,6 +72,9 @@
# endif
#endif
+#include <qpa/qplatforminputcontextfactory_p.h>
+#include <qpa/qplatforminputcontext.h>
+
#include "private/qgenericunixfontdatabase_p.h"
#include "private/qgenericunixeventdispatcher_p.h"
@@ -152,6 +155,7 @@ QQnxIntegration::QQnxIntegration(const QStringList &paramList)
, m_inputContext(0)
, m_buttonsNotifier(new QQnxButtonEventNotifier())
#endif
+ , m_qpaInputContext(0)
, m_services(0)
, m_fontDatabase(new QGenericUnixFontDatabase())
, m_eventDispatcher(createUnixEventDispatcher())
@@ -194,13 +198,17 @@ QQnxIntegration::QQnxIntegration(const QStringList &paramList)
m_screenEventHandler->setScreenEventThread(m_screenEventThread);
m_screenEventThread->start();
+ m_qpaInputContext = QPlatformInputContextFactory::create();
+
#if QT_CONFIG(qqnx_pps)
- // Create/start the keyboard class.
- m_virtualKeyboard = new QQnxVirtualKeyboardPps();
+ if (!m_qpaInputContext) {
+ // Create/start the keyboard class.
+ m_virtualKeyboard = new QQnxVirtualKeyboardPps();
- // delay invocation of start() to the time the event loop is up and running
- // needed to have the QThread internals of the main thread properly initialized
- QMetaObject::invokeMethod(m_virtualKeyboard, "start", Qt::QueuedConnection);
+ // delay invocation of start() to the time the event loop is up and running
+ // needed to have the QThread internals of the main thread properly initialized
+ QMetaObject::invokeMethod(m_virtualKeyboard, "start", Qt::QueuedConnection);
+ }
#endif
#if QT_CONFIG(qqnx_pps)
@@ -281,6 +289,7 @@ QQnxIntegration::~QQnxIntegration()
// Destroy input context
delete m_inputContext;
#endif
+ delete m_qpaInputContext;
// Destroy the keyboard class.
delete m_virtualKeyboard;
@@ -397,13 +406,13 @@ QPlatformOpenGLContext *QQnxIntegration::createPlatformOpenGLContext(QOpenGLCont
}
#endif
-#if QT_CONFIG(qqnx_pps)
QPlatformInputContext *QQnxIntegration::inputContext() const
{
qIntegrationDebug();
+ if (m_qpaInputContext)
+ return m_qpaInputContext;
return m_inputContext;
}
-#endif
void QQnxIntegration::moveToScreen(QWindow *window, int screen)
{
diff --git a/src/plugins/platforms/qnx/qqnxintegration.h b/src/plugins/platforms/qnx/qqnxintegration.h
index 4a6f15fc08..366556dc4b 100644
--- a/src/plugins/platforms/qnx/qqnxintegration.h
+++ b/src/plugins/platforms/qnx/qqnxintegration.h
@@ -153,6 +153,7 @@ private:
QQnxInputContext *m_inputContext;
QQnxButtonEventNotifier *m_buttonsNotifier;
#endif
+ QPlatformInputContext *m_qpaInputContext;
QQnxServices *m_services;
QPlatformFontDatabase *m_fontDatabase;
mutable QAbstractEventDispatcher *m_eventDispatcher;
diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
index e4843cb438..f29e11489b 100644
--- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
+++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
@@ -381,6 +381,8 @@ void QQnxScreenEventHandler::handlePointerEvent(screen_event_t event)
if (m_lastGlobalMousePoint != globalPoint ||
m_lastLocalMousePoint != localPoint ||
m_lastButtonState != buttons) {
+ if (m_lastButtonState != 0 && buttons == 0)
+ (static_cast<QQnxWindow *>(w->handle()))->handleActivationEvent();
QWindowSystemInterface::handleMouseEvent(w, localPoint, globalPoint, buttons);
qScreenEventDebug() << "Qt mouse, w=" << w << ", (" << localPoint.x() << "," << localPoint.y() << "), b=" << static_cast<int>(buttons);
}
@@ -457,6 +459,9 @@ void QQnxScreenEventHandler::handleTouchEvent(screen_event_t event, int qnxType)
m_lastMouseWindow = qnxWindow;
if (w) {
+ if (qnxType == SCREEN_EVENT_MTOUCH_RELEASE)
+ (static_cast<QQnxWindow *>(w->handle()))->handleActivationEvent();
+
// get size of screen which contains window
QPlatformScreen *platformScreen = QPlatformScreen::platformScreenForWindow(w);
QSizeF screenSize = platformScreen->geometry().size();
diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp
index 2096bc789e..7644e28b44 100644
--- a/src/plugins/platforms/qnx/qqnxwindow.cpp
+++ b/src/plugins/platforms/qnx/qqnxwindow.cpp
@@ -156,7 +156,8 @@ QQnxWindow::QQnxWindow(QWindow *window, screen_context_t context, bool needRootW
m_visible(false),
m_exposed(true),
m_windowState(Qt::WindowNoState),
- m_mmRendererWindow(0)
+ m_mmRendererWindow(0),
+ m_firstActivateHandled(false)
{
qWindowDebug() << "window =" << window << ", size =" << window->size();
@@ -341,6 +342,14 @@ void QQnxWindow::setVisible(bool visible)
if (visible) {
applyWindowState();
} else {
+ if (showWithoutActivating() && focusable() && m_firstActivateHandled) {
+ m_firstActivateHandled = false;
+ int val = SCREEN_SENSITIVITY_NO_FOCUS;
+ Q_SCREEN_CHECKERROR(
+ screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SENSITIVITY, &val),
+ "Failed to set window sensitivity");
+ }
+
// Flush the context, otherwise it won't disappear immediately
screen_flush_context(m_screenContext, 0);
}
@@ -618,13 +627,56 @@ void QQnxWindow::requestActivateWindow()
void QQnxWindow::setFocus(screen_window_t newFocusWindow)
{
+ screen_window_t temporaryFocusWindow = nullptr;
+
screen_group_t screenGroup = 0;
- screen_get_window_property_pv(nativeHandle(), SCREEN_PROPERTY_GROUP,
- reinterpret_cast<void**>(&screenGroup));
- if (screenGroup) {
- screen_set_group_property_pv(screenGroup, SCREEN_PROPERTY_FOCUS,
- reinterpret_cast<void**>(&newFocusWindow));
+ Q_SCREEN_CHECKERROR(screen_get_window_property_pv(nativeHandle(), SCREEN_PROPERTY_GROUP,
+ reinterpret_cast<void **>(&screenGroup)),
+ "Failed to retrieve window group");
+
+ if (showWithoutActivating() && focusable() && !m_firstActivateHandled) {
+ m_firstActivateHandled = true;
+ int val = SCREEN_SENSITIVITY_TEST;
+ Q_SCREEN_CHECKERROR(
+ screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SENSITIVITY, &val),
+ "Failed to set window sensitivity");
+
+#if _SCREEN_VERSION < _SCREEN_MAKE_VERSION(1, 0, 0)
+ // For older versions of screen, the window may still have group
+ // focus even though it was marked NO_FOCUS when it was hidden.
+ // In that situation, focus has to be given to another window
+ // so that this window can take focus back from it.
+ screen_window_t oldFocusWindow = nullptr;
+ Q_SCREEN_CHECKERROR(
+ screen_get_group_property_pv(screenGroup, SCREEN_PROPERTY_FOCUS,
+ reinterpret_cast<void **>(&oldFocusWindow)),
+ "Failed to retrieve group focus");
+ if (newFocusWindow == oldFocusWindow) {
+ char groupName[256];
+ memset(groupName, 0, sizeof(groupName));
+ Q_SCREEN_CHECKERROR(screen_get_group_property_cv(screenGroup, SCREEN_PROPERTY_NAME,
+ sizeof(groupName) - 1, groupName),
+ "Failed to retrieve group name");
+
+ Q_SCREEN_CHECKERROR(screen_create_window_type(&temporaryFocusWindow,
+ m_screenContext, SCREEN_CHILD_WINDOW),
+ "Failed to create temporary focus window");
+ Q_SCREEN_CHECKERROR(screen_join_window_group(temporaryFocusWindow, groupName),
+ "Temporary focus window failed to join window group");
+ Q_SCREEN_CHECKERROR(
+ screen_set_group_property_pv(screenGroup, SCREEN_PROPERTY_FOCUS,
+ reinterpret_cast<void **>(&temporaryFocusWindow)),
+ "Temporary focus window failed to take focus");
+ screen_flush_context(m_screenContext, 0);
+ }
+#endif
}
+
+ Q_SCREEN_CHECKERROR(screen_set_group_property_pv(screenGroup, SCREEN_PROPERTY_FOCUS,
+ reinterpret_cast<void **>(&newFocusWindow)),
+ "Failed to set group focus");
+
+ screen_destroy_window(temporaryFocusWindow);
}
void QQnxWindow::setWindowState(Qt::WindowStates state)
@@ -711,7 +763,11 @@ void QQnxWindow::initWindow()
screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SWAP_INTERVAL, &val),
"Failed to set swap interval");
- if (window()->flags() & Qt::WindowDoesNotAcceptFocus) {
+ if (showWithoutActivating() || !focusable()) {
+ // NO_FOCUS is temporary for showWithoutActivating (and pop-up) windows.
+ // Using NO_FOCUS ensures that screen doesn't activate the window because
+ // it was just created. Sensitivity will be changed to TEST when the
+ // window is clicked or touched.
val = SCREEN_SENSITIVITY_NO_FOCUS;
Q_SCREEN_CHECKERROR(
screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SENSITIVITY, &val),
@@ -825,4 +881,22 @@ bool QQnxWindow::shouldMakeFullScreen() const
&& (QQnxIntegration::instance()->options() & QQnxIntegration::FullScreenApplication));
}
+
+void QQnxWindow::handleActivationEvent()
+{
+ if (showWithoutActivating() && focusable() && !m_firstActivateHandled)
+ requestActivateWindow();
+}
+
+bool QQnxWindow::showWithoutActivating() const
+{
+ return (window()->flags() & Qt::Popup) == Qt::Popup
+ || window()->property("_q_showWithoutActivating").toBool();
+}
+
+bool QQnxWindow::focusable() const
+{
+ return (window()->flags() & Qt::WindowDoesNotAcceptFocus) != Qt::WindowDoesNotAcceptFocus;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/qnx/qqnxwindow.h b/src/plugins/platforms/qnx/qqnxwindow.h
index 2895a547b1..20c38cb4b7 100644
--- a/src/plugins/platforms/qnx/qqnxwindow.h
+++ b/src/plugins/platforms/qnx/qqnxwindow.h
@@ -113,6 +113,7 @@ public:
bool shouldMakeFullScreen() const;
void windowPosted();
+ void handleActivationEvent();
protected:
virtual int pixelFormat() const = 0;
@@ -131,6 +132,8 @@ private:
void updateZorder(screen_window_t window, int &zOrder);
void applyWindowState();
void setFocus(screen_window_t newFocusWindow);
+ bool showWithoutActivating() const;
+ bool focusable() const;
screen_window_t m_window;
QSize m_bufferSize;
@@ -152,6 +155,7 @@ private:
QByteArray m_parentGroupName;
bool m_isTopLevel;
+ bool m_firstActivateHandled;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/vnc/qvnc.cpp b/src/plugins/platforms/vnc/qvnc.cpp
index ffe00de2b1..32114c6443 100644
--- a/src/plugins/platforms/vnc/qvnc.cpp
+++ b/src/plugins/platforms/vnc/qvnc.cpp
@@ -600,7 +600,7 @@ void QVncClientCursor::changeCursor(QCursor *widgetCursor, QWindow *window)
cursor = *platformImage.image();
hotspot = platformImage.hotspot();
}
- for (auto client : clients)
+ for (auto client : qAsConst(clients))
client->setDirtyCursor();
}
@@ -638,16 +638,14 @@ void QVncServer::init()
QVncServer::~QVncServer()
{
- for (auto client : clients) {
- delete client;
- }
+ qDeleteAll(clients);
}
void QVncServer::setDirty()
{
- for (auto client : clients) {
+ for (auto client : qAsConst(clients))
client->setDirty(qvnc_screen->dirtyRegion);
- }
+
qvnc_screen->clearDirty();
}
diff --git a/src/plugins/platforms/vnc/qvncscreen.cpp b/src/plugins/platforms/vnc/qvncscreen.cpp
index 67d33de2f0..2eca18fb4d 100644
--- a/src/plugins/platforms/vnc/qvncscreen.cpp
+++ b/src/plugins/platforms/vnc/qvncscreen.cpp
@@ -75,7 +75,7 @@ bool QVncScreen::initialize()
mDepth = 32;
mPhysicalSize = QSizeF(mGeometry.width()/96.*25.4, mGeometry.height()/96.*25.4);
- for (const QString &arg : mArgs) {
+ for (const QString &arg : qAsConst(mArgs)) {
QRegularExpressionMatch match;
if (arg.contains(mmSizeRx, &match)) {
mPhysicalSize = QSizeF(match.captured("width").toDouble(), match.captured("height").toDouble());
diff --git a/src/plugins/platforms/wasm/qtloader.js b/src/plugins/platforms/wasm/qtloader.js
index 37a5308034..84694c7b9f 100644
--- a/src/plugins/platforms/wasm/qtloader.js
+++ b/src/plugins/platforms/wasm/qtloader.js
@@ -312,13 +312,13 @@ function QtLoader(config)
// and is ready to be instantiated. Define the instantiateWasm callback which
// emscripten will call to create the instance.
Module.instantiateWasm = function(imports, successCallback) {
- return WebAssembly.instantiate(wasmModule, imports).then(function(instance) {
- successCallback(instance);
- return instance;
+ WebAssembly.instantiate(wasmModule, imports).then(function(instance) {
+ successCallback(instance, wasmModule);
}, function(error) {
self.error = error;
setStatus("Error");
});
+ return {};
};
Module.locateFile = Module.locateFile || function(filename) {
@@ -382,6 +382,8 @@ function QtLoader(config)
}
});
+ Module.mainScriptUrlOrBlob = new Blob([emscriptenModuleSource], {type: 'text/javascript'});
+
config.restart = function() {
// Restart by reloading the page. This will wipe all state which means
diff --git a/src/plugins/platforms/wasm/qwasmclipboard.cpp b/src/plugins/platforms/wasm/qwasmclipboard.cpp
new file mode 100644
index 0000000000..ec058f05dd
--- /dev/null
+++ b/src/plugins/platforms/wasm/qwasmclipboard.cpp
@@ -0,0 +1,204 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwasmclipboard.h"
+#include "qwasmwindow.h"
+
+#include <emscripten.h>
+#include <emscripten/html5.h>
+#include <emscripten/bind.h>
+
+#include <QCoreApplication>
+#include <qpa/qwindowsysteminterface.h>
+
+using namespace emscripten;
+
+// there has got to be a better way...
+static QByteArray g_clipboardArray;
+static QByteArray g_clipboardFormat;
+
+static val getClipboardData()
+{
+ return val(g_clipboardArray.constData());
+}
+
+static val getClipboardFormat()
+{
+ return val(g_clipboardFormat.constData());
+}
+
+static void pasteClipboardData(emscripten::val format, emscripten::val dataPtr)
+{
+ QString formatString = QString::fromStdString(format.as<std::string>());
+ QByteArray dataArray = QByteArray::fromStdString(dataPtr.as<std::string>());
+ QMimeData *mMimeData = new QMimeData;
+ mMimeData->setData(formatString, dataArray);
+ QWasmClipboard::qWasmClipboardPaste(mMimeData);
+}
+
+static void qClipboardPromiseResolve(emscripten::val something)
+{
+ pasteClipboardData(emscripten::val("text/plain"), something);
+}
+
+static void qClipboardCopyTo(val event)
+{
+ val target = event["target"];
+ val clipboard = event["clipboardData"];
+
+ val module = val::global("Module");
+ val clipdata = module.call<val>("getClipboardData");
+ val clipFormat = module.call<val>("getClipboardFormat");
+ clipboard.call<void>("setData", clipFormat, clipdata);
+ target.call<void>("preventDefault");
+}
+
+static void qClipboardPasteTo(val event)
+{
+ val target = event["clipboardData"];
+ val module = val::global("Module");
+ val clipdata = module.call<val>("getClipboardData");
+
+ const std::string data = clipdata.as<std::string>();
+ if (data.length() > 0) {
+ QString qstr = QString::fromStdString(data);
+ QMimeData *mMimeData = new QMimeData;
+ mMimeData->setText(qstr);
+ QWasmClipboard::qWasmClipboardPaste(mMimeData);
+ }
+}
+
+EMSCRIPTEN_BINDINGS(clipboard_module) {
+ function("getClipboardData", &getClipboardData);
+ function("getClipboardFormat", &getClipboardFormat);
+ function("pasteClipboardData", &pasteClipboardData);
+ function("qClipboardPromiseResolve", &qClipboardPromiseResolve);
+ function("qClipboardCopyTo", &qClipboardCopyTo);
+ function("qClipboardPasteTo", &qClipboardPasteTo);
+}
+
+QWasmClipboard::QWasmClipboard() :
+ hasClipboardApi(false)
+{
+ initClipboardEvents();
+}
+
+QWasmClipboard::~QWasmClipboard()
+{
+ g_clipboardArray.clear();
+ g_clipboardFormat.clear();
+}
+
+QMimeData* QWasmClipboard::mimeData(QClipboard::Mode mode)
+{
+ if (mode != QClipboard::Clipboard)
+ return nullptr;
+
+ return QPlatformClipboard::mimeData(mode);
+}
+
+void QWasmClipboard::setMimeData(QMimeData* mimeData, QClipboard::Mode mode)
+{
+ if (mimeData->hasText()) {
+ g_clipboardFormat = mimeData->formats().at(0).toUtf8();
+ g_clipboardArray = mimeData->text().toUtf8();
+ } else if (mimeData->hasHtml()) {
+ g_clipboardFormat =mimeData->formats().at(0).toUtf8();
+ g_clipboardArray = mimeData->html().toUtf8();
+ }
+
+ QPlatformClipboard::setMimeData(mimeData, mode);
+}
+
+bool QWasmClipboard::supportsMode(QClipboard::Mode mode) const
+{
+ return mode == QClipboard::Clipboard;
+}
+
+bool QWasmClipboard::ownsMode(QClipboard::Mode mode) const
+{
+ Q_UNUSED(mode);
+ return false;
+}
+
+void QWasmClipboard::qWasmClipboardPaste(QMimeData *mData)
+{
+ QWasmIntegration::get()->clipboard()->setMimeData(mData, QClipboard::Clipboard);
+
+ QWindowSystemInterface::handleKeyEvent<QWindowSystemInterface::SynchronousDelivery>(
+ 0, QEvent::KeyPress, Qt::Key_V, Qt::ControlModifier, "V");
+}
+
+void QWasmClipboard::initClipboardEvents()
+{
+ val navigator = val::global("navigator");
+ val permissions = navigator["permissions"];
+ val clipboard = navigator["clipboard"];
+
+ hasClipboardApi = (!clipboard.isUndefined());
+ if (hasClipboardApi) {
+ val readPermissionsMap = val::object();
+ readPermissionsMap.set("name", val("clipboard-read"));
+ permissions.call<val>("query", readPermissionsMap);
+
+ val writePermissionsMap = val::object();
+ writePermissionsMap.set("name", val("clipboard-write"));
+ permissions.call<val>("query", writePermissionsMap);
+
+ } else {
+
+ val window = val::global("window");
+ window.call<void>("addEventListener", std::string("paste"),
+ val::module_property("qClipboardPasteTo"));
+
+ window.call<void>("addEventListener", std::string("copy"),
+ val::module_property("qClipboardCopyTo"));
+ }
+}
+
+void QWasmClipboard::readTextFromClipboard()
+{
+ if (QWasmIntegration::get()->getWasmClipboard()->hasClipboardApi) {
+ val navigator = val::global("navigator");
+ val textPromise = navigator["clipboard"].call<val>("readText");
+ val readTextResolve = val::global("Module")["qClipboardPromiseResolve"];
+ textPromise.call<val>("then", readTextResolve);
+ }
+}
+
+void QWasmClipboard::writeTextToClipboard()
+{
+ if (QWasmIntegration::get()->getWasmClipboard()->hasClipboardApi) {
+ val module = val::global("Module");
+ val txt = module.call<val>("getClipboardData");
+ val format = module.call<val>("getClipboardFormat");
+ val navigator = val::global("navigator");
+ navigator["clipboard"].call<void>("writeText", txt.as<std::string>());
+ }
+}
diff --git a/src/plugins/platforms/wasm/qwasmclipboard.h b/src/plugins/platforms/wasm/qwasmclipboard.h
new file mode 100644
index 0000000000..e64b2e5007
--- /dev/null
+++ b/src/plugins/platforms/wasm/qwasmclipboard.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWasmClipboard_H
+#define QWasmClipboard_H
+
+#include <QObject>
+
+#include <qpa/qplatformclipboard.h>
+#include <QMimeData>
+
+#include <emscripten/bind.h>
+
+class QWasmClipboard : public QObject, public QPlatformClipboard
+{
+public:
+ QWasmClipboard();
+ virtual ~QWasmClipboard();
+
+ // QPlatformClipboard methods.
+ QMimeData* mimeData(QClipboard::Mode mode = QClipboard::Clipboard) override;
+ void setMimeData(QMimeData* data, QClipboard::Mode mode = QClipboard::Clipboard) override;
+ bool supportsMode(QClipboard::Mode mode) const override;
+ bool ownsMode(QClipboard::Mode mode) const override;
+
+ static void qWasmClipboardPaste(QMimeData *mData);
+ void initClipboardEvents();
+ bool hasClipboardApi;
+ void readTextFromClipboard();
+ void writeTextToClipboard();
+};
+
+#endif // QWASMCLIPBOARD_H
diff --git a/src/plugins/platforms/wasm/qwasmcursor.cpp b/src/plugins/platforms/wasm/qwasmcursor.cpp
index 54804a55b3..744b160dd1 100644
--- a/src/plugins/platforms/wasm/qwasmcursor.cpp
+++ b/src/plugins/platforms/wasm/qwasmcursor.cpp
@@ -32,6 +32,7 @@
#include <QtCore/qdebug.h>
#include <emscripten/emscripten.h>
+#include <emscripten/bind.h>
void QWasmCursor::changeCursor(QCursor *windowCursor, QWindow *window)
{
@@ -52,11 +53,8 @@ void QWasmCursor::changeCursor(QCursor *windowCursor, QWindow *window)
htmlCursorName = "auto";
// Set cursor on the main canvas
- EM_ASM_ARGS({
- if (Module['canvas']) {
- Module['canvas'].style['cursor'] = Pointer_stringify($0);
- }
- }, htmlCursorName.constData());
+ emscripten::val canvasStyle = emscripten::val::module_property("canvas")["style"];
+ canvasStyle.set("cursor", emscripten::val(htmlCursorName.constData()));
}
QByteArray QWasmCursor::cursorShapeToHtml(Qt::CursorShape shape)
diff --git a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp
index 8ab109f03c..334f183703 100644
--- a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp
+++ b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp
@@ -31,6 +31,7 @@
#include "qwasmeventdispatcher.h"
#include "qwasmcompositor.h"
#include "qwasmintegration.h"
+#include "qwasmclipboard.h"
#include <QtGui/qevent.h>
#include <qpa/qwindowsysteminterface.h>
@@ -39,6 +40,9 @@
#include <QtCore/qobject.h>
#include <QtCore/qdeadlinetimer.h>
+#include <private/qmakearray_p.h>
+#include <QtCore/qnamespace.h>
+
#include <emscripten/bind.h>
#include <iostream>
@@ -46,18 +50,274 @@
QT_BEGIN_NAMESPACE
using namespace emscripten;
+typedef struct emkb2qt {
+ const char *em;
+ unsigned int qt;
+
+ constexpr bool operator <=(const emkb2qt &that) const noexcept
+ {
+ return !(strcmp(that) > 0);
+ }
+
+ bool operator <(const emkb2qt &that) const noexcept
+ {
+ return ::strcmp(em, that.em) < 0;
+ }
+ constexpr int strcmp(const emkb2qt &that, const int i = 0) const
+ {
+ return em[i] == 0 && that.em[i] == 0 ? 0
+ : em[i] == 0 ? -1
+ : that.em[i] == 0 ? 1
+ : em[i] < that.em[i] ? -1
+ : em[i] > that.em[i] ? 1
+ : strcmp(that, i + 1);
+ }
+} emkb2qt_t;
+
+template<unsigned int Qt, char ... EmChar>
+struct Emkb2Qt
+{
+ static constexpr const char storage[sizeof ... (EmChar) + 1] = {EmChar..., '\0'};
+ using Type = emkb2qt_t;
+ static constexpr Type data() noexcept { return Type{storage, Qt}; }
+};
+
+template<unsigned int Qt, char ... EmChar> constexpr char Emkb2Qt<Qt, EmChar...>::storage[];
+
+static constexpr const auto KeyTbl = qMakeArray(
+ QSortedData<
+ Emkb2Qt< Qt::Key_Escape, 'E','s','c','a','p','e' >,
+ Emkb2Qt< Qt::Key_Tab, 'T','a','b' >,
+ Emkb2Qt< Qt::Key_Backspace, 'B','a','c','k','s','p','a','c','e' >,
+ Emkb2Qt< Qt::Key_Return, 'E','n','t','e','r' >,
+ Emkb2Qt< Qt::Key_Insert, 'I','n','s','e','r','t' >,
+ Emkb2Qt< Qt::Key_Delete, 'D','e','l','e','t','e' >,
+ Emkb2Qt< Qt::Key_Pause, 'P','a','u','s','e' >,
+ Emkb2Qt< Qt::Key_Pause, 'C','l','e','a','r' >,
+ Emkb2Qt< Qt::Key_Home, 'H','o','m','e' >,
+ Emkb2Qt< Qt::Key_End, 'E','n','d' >,
+ Emkb2Qt< Qt::Key_Left, 'A','r','r','o','w','L','e','f','t' >,
+ Emkb2Qt< Qt::Key_Up, 'A','r','r','o','w','U','p' >,
+ Emkb2Qt< Qt::Key_Right, 'A','r','r','o','w','R','i','g','h','t' >,
+ Emkb2Qt< Qt::Key_Down, 'A','r','r','o','w','D','o','w','n' >,
+ Emkb2Qt< Qt::Key_PageUp, 'P','a','g','e','U','p' >,
+ Emkb2Qt< Qt::Key_PageDown, 'P','a','g','e','D','o','w','n' >,
+ Emkb2Qt< Qt::Key_Shift, 'S','h','i','f','t' >,
+ Emkb2Qt< Qt::Key_Control, 'C','o','n','t','r','o','l' >,
+ Emkb2Qt< Qt::Key_Meta, 'O','S'>,
+ Emkb2Qt< Qt::Key_Alt, 'A','l','t','L','e','f','t' >,
+ Emkb2Qt< Qt::Key_Alt, 'A','l','t' >,
+ Emkb2Qt< Qt::Key_CapsLock, 'C','a','p','s','L','o','c','k' >,
+ Emkb2Qt< Qt::Key_NumLock, 'N','u','m','L','o','c','k' >,
+ Emkb2Qt< Qt::Key_ScrollLock, 'S','c','r','o','l','l','L','o','c','k' >,
+ Emkb2Qt< Qt::Key_F1, 'F','1' >,
+ Emkb2Qt< Qt::Key_F2, 'F','2' >,
+ Emkb2Qt< Qt::Key_F3, 'F','3' >,
+ Emkb2Qt< Qt::Key_F4, 'F','4' >,
+ Emkb2Qt< Qt::Key_F5, 'F','5' >,
+ Emkb2Qt< Qt::Key_F6, 'F','6' >,
+ Emkb2Qt< Qt::Key_F7, 'F','7' >,
+ Emkb2Qt< Qt::Key_F8, 'F','8' >,
+ Emkb2Qt< Qt::Key_F9, 'F','9' >,
+ Emkb2Qt< Qt::Key_F10, 'F','1','0' >,
+ Emkb2Qt< Qt::Key_F11, 'F','1','1' >,
+ Emkb2Qt< Qt::Key_F12, 'F','1','2' >,
+ Emkb2Qt< Qt::Key_F13, 'F','1','3' >,
+ Emkb2Qt< Qt::Key_F14, 'F','1','4' >,
+ Emkb2Qt< Qt::Key_F15, 'F','1','5' >,
+ Emkb2Qt< Qt::Key_F16, 'F','1','6' >,
+ Emkb2Qt< Qt::Key_F17, 'F','1','7' >,
+ Emkb2Qt< Qt::Key_F18, 'F','1','8' >,
+ Emkb2Qt< Qt::Key_F19, 'F','1','9' >,
+ Emkb2Qt< Qt::Key_F20, 'F','2','0' >,
+ Emkb2Qt< Qt::Key_F21, 'F','2','1' >,
+ Emkb2Qt< Qt::Key_F22, 'F','2','2' >,
+ Emkb2Qt< Qt::Key_F23, 'F','2','3' >,
+ Emkb2Qt< Qt::Key_Space, ' ' >,
+ Emkb2Qt< Qt::Key_Comma, ',' >,
+ Emkb2Qt< Qt::Key_Minus, '-' >,
+ Emkb2Qt< Qt::Key_Period, '.' >,
+ Emkb2Qt< Qt::Key_Slash, '/' >,
+ Emkb2Qt< Qt::Key_0, '0' >,
+ Emkb2Qt< Qt::Key_1, '1' >,
+ Emkb2Qt< Qt::Key_2, '2' >,
+ Emkb2Qt< Qt::Key_3, '3' >,
+ Emkb2Qt< Qt::Key_4, '4' >,
+ Emkb2Qt< Qt::Key_5, '5' >,
+ Emkb2Qt< Qt::Key_6, '6' >,
+ Emkb2Qt< Qt::Key_7, '7' >,
+ Emkb2Qt< Qt::Key_8, '8' >,
+ Emkb2Qt< Qt::Key_9, '9' >,
+ Emkb2Qt< Qt::Key_Semicolon, ';' >,
+ Emkb2Qt< Qt::Key_Equal, '=' >,
+ Emkb2Qt< Qt::Key_A, 'K','e','y','A' >,
+ Emkb2Qt< Qt::Key_B, 'K','e','y','B' >,
+ Emkb2Qt< Qt::Key_C, 'K','e','y','C' >,
+ Emkb2Qt< Qt::Key_D, 'K','e','y','D' >,
+ Emkb2Qt< Qt::Key_E, 'K','e','y','E' >,
+ Emkb2Qt< Qt::Key_F, 'K','e','y','F' >,
+ Emkb2Qt< Qt::Key_G, 'K','e','y','G' >,
+ Emkb2Qt< Qt::Key_H, 'K','e','y','H' >,
+ Emkb2Qt< Qt::Key_I, 'K','e','y','I' >,
+ Emkb2Qt< Qt::Key_J, 'K','e','y','J' >,
+ Emkb2Qt< Qt::Key_K, 'K','e','y','K' >,
+ Emkb2Qt< Qt::Key_L, 'K','e','y','L' >,
+ Emkb2Qt< Qt::Key_M, 'K','e','y','M' >,
+ Emkb2Qt< Qt::Key_N, 'K','e','y','N' >,
+ Emkb2Qt< Qt::Key_O, 'K','e','y','O' >,
+ Emkb2Qt< Qt::Key_P, 'K','e','y','P' >,
+ Emkb2Qt< Qt::Key_Q, 'K','e','y','Q' >,
+ Emkb2Qt< Qt::Key_R, 'K','e','y','R' >,
+ Emkb2Qt< Qt::Key_S, 'K','e','y','S' >,
+ Emkb2Qt< Qt::Key_T, 'K','e','y','T' >,
+ Emkb2Qt< Qt::Key_U, 'K','e','y','U' >,
+ Emkb2Qt< Qt::Key_V, 'K','e','y','V' >,
+ Emkb2Qt< Qt::Key_W, 'K','e','y','W' >,
+ Emkb2Qt< Qt::Key_X, 'K','e','y','X' >,
+ Emkb2Qt< Qt::Key_Y, 'K','e','y','Y' >,
+ Emkb2Qt< Qt::Key_Z, 'K','e','y','Z' >,
+ Emkb2Qt< Qt::Key_BracketLeft, '[' >,
+ Emkb2Qt< Qt::Key_Backslash, '\\' >,
+ Emkb2Qt< Qt::Key_BracketRight, ']' >,
+ Emkb2Qt< Qt::Key_Apostrophe, '\'' >,
+ Emkb2Qt< Qt::Key_QuoteLeft, 'B','a','c','k','q','u','o','t','e' >,
+ Emkb2Qt< Qt::Key_multiply, 'N','u','m','p','a','d','M','u','l','t','i','p','l','y' >,
+ Emkb2Qt< Qt::Key_Minus, 'N','u','m','p','a','d','S','u','b','t','r','a','c','t' >,
+ Emkb2Qt< Qt::Key_Period, 'N','u','m','p','a','d','D','e','c','i','m','a','l' >,
+ Emkb2Qt< Qt::Key_Plus, 'N','u','m','p','a','d','A','d','d' >,
+ Emkb2Qt< Qt::Key_division, 'N','u','m','p','a','d','D','i','v','i','d','e' >,
+ Emkb2Qt< Qt::Key_Equal, 'N','u','m','p','a','d','E','q','u','a','l' >,
+ Emkb2Qt< Qt::Key_0, 'N','u','m','p','a','d','0' >,
+ Emkb2Qt< Qt::Key_1, 'N','u','m','p','a','d','1' >,
+ Emkb2Qt< Qt::Key_2, 'N','u','m','p','a','d','2' >,
+ Emkb2Qt< Qt::Key_3, 'N','u','m','p','a','d','3' >,
+ Emkb2Qt< Qt::Key_4, 'N','u','m','p','a','d','4' >,
+ Emkb2Qt< Qt::Key_5, 'N','u','m','p','a','d','5' >,
+ Emkb2Qt< Qt::Key_6, 'N','u','m','p','a','d','6' >,
+ Emkb2Qt< Qt::Key_7, 'N','u','m','p','a','d','7' >,
+ Emkb2Qt< Qt::Key_8, 'N','u','m','p','a','d','8' >,
+ Emkb2Qt< Qt::Key_9, 'N','u','m','p','a','d','9' >,
+ Emkb2Qt< Qt::Key_Comma, 'N','u','m','p','a','d','C','o','m','m','a' >,
+ Emkb2Qt< Qt::Key_Enter, 'N','u','m','p','a','d','E','n','t','e','r' >,
+ Emkb2Qt< Qt::Key_Paste, 'P','a','s','t','e' >,
+ Emkb2Qt< Qt::Key_AltGr, 'A','l','t','R','i','g','h','t' >,
+ Emkb2Qt< Qt::Key_Help, 'H','e','l','p' >,
+ Emkb2Qt< Qt::Key_Equal, '=' >,
+ Emkb2Qt< Qt::Key_yen, 'I','n','t','l','Y','e','n' >,
+
+ Emkb2Qt< Qt::Key_Exclam, '\x21' >,
+ Emkb2Qt< Qt::Key_QuoteDbl, '\x22' >,
+ Emkb2Qt< Qt::Key_NumberSign, '\x23' >,
+ Emkb2Qt< Qt::Key_Dollar, '\x24' >,
+ Emkb2Qt< Qt::Key_Percent, '\x25' >,
+ Emkb2Qt< Qt::Key_Ampersand, '\x26' >,
+ Emkb2Qt< Qt::Key_ParenLeft, '\x28' >,
+ Emkb2Qt< Qt::Key_ParenRight, '\x29' >,
+ Emkb2Qt< Qt::Key_Asterisk, '\x2a' >,
+ Emkb2Qt< Qt::Key_Plus, '\x2b' >,
+ Emkb2Qt< Qt::Key_Colon, '\x3a' >,
+ Emkb2Qt< Qt::Key_Semicolon, '\x3b' >,
+ Emkb2Qt< Qt::Key_Less, '\x3c' >,
+ Emkb2Qt< Qt::Key_Equal, '\x3d' >,
+ Emkb2Qt< Qt::Key_Greater, '\x3e' >,
+ Emkb2Qt< Qt::Key_Question, '\x3f' >,
+ Emkb2Qt< Qt::Key_At, '\x40' >,
+ Emkb2Qt< Qt::Key_BracketLeft, '\x5b' >,
+ Emkb2Qt< Qt::Key_Backslash, '\x5c' >,
+ Emkb2Qt< Qt::Key_BracketRight, '\x5d' >,
+ Emkb2Qt< Qt::Key_AsciiCircum, '\x5e' >,
+ Emkb2Qt< Qt::Key_Underscore, '\x5f' >,
+ Emkb2Qt< Qt::Key_QuoteLeft, '\x60'>,
+ Emkb2Qt< Qt::Key_BraceLeft, '\x7b'>,
+ Emkb2Qt< Qt::Key_Bar, '\x7c'>,
+ Emkb2Qt< Qt::Key_BraceRight, '\x7d'>,
+ Emkb2Qt< Qt::Key_AsciiTilde, '\x7e'>,
+ Emkb2Qt< Qt::Key_Space, '\x20' >,
+ Emkb2Qt< Qt::Key_Comma, '\x2c' >,
+ Emkb2Qt< Qt::Key_Minus, '\x2d' >,
+ Emkb2Qt< Qt::Key_Period, '\x2e' >,
+ Emkb2Qt< Qt::Key_Slash, '\x2f' >,
+ Emkb2Qt< Qt::Key_Apostrophe, '\x27' >,
+ Emkb2Qt< Qt::Key_Menu, 'C','o','n','t','e','x','t','M','e','n','u' >,
+
+ Emkb2Qt< Qt::Key_Agrave, '\xc3','\xa0' >,
+ Emkb2Qt< Qt::Key_Aacute, '\xc3','\xa1' >,
+ Emkb2Qt< Qt::Key_Acircumflex, '\xc3','\xa2' >,
+ Emkb2Qt< Qt::Key_Adiaeresis, '\xc3','\xa4' >,
+ Emkb2Qt< Qt::Key_AE, '\xc3','\xa6' >,
+ Emkb2Qt< Qt::Key_Atilde, '\xc3','\xa3' >,
+ Emkb2Qt< Qt::Key_Aring, '\xc3','\xa5' >,
+ Emkb2Qt< Qt::Key_Ccedilla, '\xc3','\xa7' >,
+ Emkb2Qt< Qt::Key_Egrave, '\xc3','\xa8' >,
+ Emkb2Qt< Qt::Key_Eacute, '\xc3','\xa9' >,
+ Emkb2Qt< Qt::Key_Ecircumflex, '\xc3','\xaa' >,
+ Emkb2Qt< Qt::Key_Ediaeresis, '\xc3','\xab' >,
+ Emkb2Qt< Qt::Key_Icircumflex, '\xc3','\xae' >,
+ Emkb2Qt< Qt::Key_Idiaeresis, '\xc3','\xaf' >,
+ Emkb2Qt< Qt::Key_Ocircumflex, '\xc3','\xb4' >,
+ Emkb2Qt< Qt::Key_Odiaeresis, '\xc3','\xb6' >,
+ Emkb2Qt< Qt::Key_Ograve, '\xc3','\xb2' >,
+ Emkb2Qt< Qt::Key_Oacute, '\xc3','\xb3' >,
+ Emkb2Qt< Qt::Key_Ooblique, '\xc3','\xb8' >,
+ Emkb2Qt< Qt::Key_Otilde, '\xc3','\xb5' >,
+ Emkb2Qt< Qt::Key_Ucircumflex, '\xc3','\xbb' >,
+ Emkb2Qt< Qt::Key_Udiaeresis, '\xc3','\xbc' >,
+ Emkb2Qt< Qt::Key_Ugrave, '\xc3','\xb9' >,
+ Emkb2Qt< Qt::Key_Uacute, '\xc3','\xba' >,
+ Emkb2Qt< Qt::Key_Ntilde, '\xc3','\xb1' >,
+ Emkb2Qt< Qt::Key_ydiaeresis, '\xc3','\xbf' >
+ >::Data{}
+ );
+
+static constexpr const auto DeadKeyShiftTbl = qMakeArray(
+ QSortedData<
+ // shifted
+ Emkb2Qt< Qt::Key_Agrave, '\xc3','\x80' >,
+ Emkb2Qt< Qt::Key_Aacute, '\xc3','\x81' >,
+ Emkb2Qt< Qt::Key_Acircumflex, '\xc3','\x82' >,
+ Emkb2Qt< Qt::Key_Adiaeresis, '\xc3','\x84' >,
+ Emkb2Qt< Qt::Key_AE, '\xc3','\x86' >,
+ Emkb2Qt< Qt::Key_Atilde, '\xc3','\x83' >,
+ Emkb2Qt< Qt::Key_Aring, '\xc3','\x85' >,
+ Emkb2Qt< Qt::Key_Egrave, '\xc3','\x88' >,
+ Emkb2Qt< Qt::Key_Eacute, '\xc3','\x89' >,
+ Emkb2Qt< Qt::Key_Ecircumflex, '\xc3','\x8a' >,
+ Emkb2Qt< Qt::Key_Ediaeresis, '\xc3','\x8b' >,
+ Emkb2Qt< Qt::Key_Icircumflex, '\xc3','\x8e' >,
+ Emkb2Qt< Qt::Key_Idiaeresis, '\xc3','\x8f' >,
+ Emkb2Qt< Qt::Key_Ocircumflex, '\xc3','\x94' >,
+ Emkb2Qt< Qt::Key_Odiaeresis, '\xc3','\x96' >,
+ Emkb2Qt< Qt::Key_Ograve, '\xc3','\x92' >,
+ Emkb2Qt< Qt::Key_Oacute, '\xc3','\x93' >,
+ Emkb2Qt< Qt::Key_Ooblique, '\xc3','\x98' >,
+ Emkb2Qt< Qt::Key_Otilde, '\xc3','\x95' >,
+ Emkb2Qt< Qt::Key_Ucircumflex, '\xc3','\x9b' >,
+ Emkb2Qt< Qt::Key_Udiaeresis, '\xc3','\x9c' >,
+ Emkb2Qt< Qt::Key_Ugrave, '\xc3','\x99' >,
+ Emkb2Qt< Qt::Key_Uacute, '\xc3','\x9a' >,
+ Emkb2Qt< Qt::Key_Ntilde, '\xc3','\x91' >,
+ Emkb2Qt< Qt::Key_Ccedilla, '\xc3','\x87' >,
+ Emkb2Qt< Qt::Key_ydiaeresis, '\xc3','\x8f' >
+ >::Data{}
+);
+
// macOS CTRL <-> META switching. We most likely want to enable
// the existing switching code in QtGui, but for now do it here.
static bool g_usePlatformMacCtrlMetaSwitching = false;
bool g_useNaturalScrolling = true; // natural scrolling is default on linux/windows
-void setNaturalScrolling(bool use) {
- g_useNaturalScrolling = use;
+static void mouseWheelEvent(emscripten::val event) {
+
+ emscripten::val wheelInterted = event["webkitDirectionInvertedFromDevice"];
+
+ if (wheelInterted.as<bool>()) {
+ g_useNaturalScrolling = true;
+ }
}
EMSCRIPTEN_BINDINGS(mouse_module) {
- function("setNaturalScrolling", &setNaturalScrolling);
+ function("mouseWheelEvent", &mouseWheelEvent);
}
QWasmEventTranslator::QWasmEventTranslator(QObject *parent)
@@ -93,23 +353,19 @@ QWasmEventTranslator::QWasmEventTranslator(QObject *parent)
GenericPlatform,
MacOSPlatform
};
- Platform platform =
- Platform(EM_ASM_INT("if (navigator.platform.includes(\"Mac\")) return 1; return 0;"));
-
+ Platform platform = Platform(emscripten::val::global("navigator")["platform"]
+ .call<bool>("includes", emscripten::val("Mac")));
g_usePlatformMacCtrlMetaSwitching = (platform == MacOSPlatform);
if (platform == MacOSPlatform) {
g_useNaturalScrolling = false; // make this !default on macOS
- EM_ASM(
- if (window.safari !== undefined) {//this only works on safari
- Module["canvas"].addEventListener('wheel', mouseWheelEvent);
- function mouseWheelEvent(e) {
- if (event.webkitDirectionInvertedFromDevice) {
- Module.setNaturalScrolling(event.webkitDirectionInvertedFromDevice);
- }
- }
- }
- );
+
+ if (emscripten::val::global("window")["safari"].isUndefined()) {
+
+ emscripten::val::global("canvas").call<void>("addEventListener",
+ std::string("wheel"),
+ val::module_property("mouseWheelEvent"));
+ }
}
}
@@ -153,132 +409,44 @@ QFlags<Qt::KeyboardModifier> QWasmEventTranslator::translateMouseEventModifier(c
int QWasmEventTranslator::keyboard_cb(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData)
{
- Q_UNUSED(userData)
+ QWasmEventTranslator *wasmTranslator = reinterpret_cast<QWasmEventTranslator *>(userData);
+ bool accepted = wasmTranslator->processKeyboard(eventType, keyEvent);
- bool alphanumeric;
- Qt::Key qtKey = translateEmscriptKey(keyEvent, &alphanumeric);
-
- QEvent::Type keyType = QEvent::None;
- switch (eventType) {
- case EMSCRIPTEN_EVENT_KEYPRESS:
- case EMSCRIPTEN_EVENT_KEYDOWN: //down
- keyType = QEvent::KeyPress;
- break;
- case EMSCRIPTEN_EVENT_KEYUP: //up
- keyType = QEvent::KeyRelease;
- break;
- default:
- break;
- };
-
- if (keyType == QEvent::None)
- return 0;
-
- QString keyText = alphanumeric ? QString(keyEvent->key) : QString();
- bool accepted = QWindowSystemInterface::handleKeyEvent<QWindowSystemInterface::SynchronousDelivery>(
- 0, keyType, qtKey, translateKeyboardEventModifier(keyEvent), keyText);
- QWasmEventDispatcher::maintainTimers();
return accepted ? 1 : 0;
}
-Qt::Key QWasmEventTranslator::translateEmscriptKey(const EmscriptenKeyboardEvent *emscriptKey, bool *outAlphanumeric)
+Qt::Key QWasmEventTranslator::translateEmscriptKey(const EmscriptenKeyboardEvent *emscriptKey)
{
- Qt::Key qtKey;
- if (outAlphanumeric)
- *outAlphanumeric = false;
-
- switch (emscriptKey->keyCode) {
- case KeyMultiply: qtKey = Qt::Key_Asterisk; *outAlphanumeric = true; break;
- case KeyAdd: qtKey = Qt::Key_Plus; *outAlphanumeric = true; break;
- case KeyMinus: qtKey = Qt::Key_Minus; *outAlphanumeric = true; break;
- case KeySubtract: qtKey = Qt::Key_Minus; *outAlphanumeric = true; break;
- case KeyDecimal: qtKey = Qt::Key_Period; *outAlphanumeric = true; break;
- case KeyDivide: qtKey = Qt::Key_Slash; *outAlphanumeric = true; break;
- case KeyNumPad0: qtKey = Qt::Key_0; *outAlphanumeric = true; break;
- case KeyNumPad1: qtKey = Qt::Key_1; *outAlphanumeric = true; break;
- case KeyNumPad2: qtKey = Qt::Key_2; *outAlphanumeric = true; break;
- case KeyNumPad3: qtKey = Qt::Key_3; *outAlphanumeric = true; break;
- case KeyNumPad4: qtKey = Qt::Key_4; *outAlphanumeric = true; break;
- case KeyNumPad5: qtKey = Qt::Key_5; *outAlphanumeric = true; break;
- case KeyNumPad6: qtKey = Qt::Key_6; *outAlphanumeric = true; break;
- case KeyNumPad7: qtKey = Qt::Key_7; *outAlphanumeric = true; break;
- case KeyNumPad8: qtKey = Qt::Key_8; *outAlphanumeric = true; break;
- case KeyNumPad9: qtKey = Qt::Key_9; *outAlphanumeric = true; break;
- case KeyComma: qtKey = Qt::Key_Comma; *outAlphanumeric = true; break;
- case KeyPeriod: qtKey = Qt::Key_Period; *outAlphanumeric = true; break;
- case KeySlash: qtKey = Qt::Key_Slash; *outAlphanumeric = true; break;
- case KeySemiColon: qtKey = Qt::Key_Semicolon; *outAlphanumeric = true; break;
- case KeyEquals: qtKey = Qt::Key_Equal; *outAlphanumeric = true; break;
- case KeyOpenBracket: qtKey = Qt::Key_BracketLeft; *outAlphanumeric = true; break;
- case KeyCloseBracket: qtKey = Qt::Key_BracketRight; *outAlphanumeric = true; break;
- case KeyBackSlash: qtKey = Qt::Key_Backslash; *outAlphanumeric = true; break;
- case KeyMeta:
- Q_FALLTHROUGH();
- case KeyMetaRight:
- qtKey = Qt::Key_Meta;
- break;
- case KeyTab: qtKey = Qt::Key_Tab; break;
- case KeyClear: qtKey = Qt::Key_Clear; break;
- case KeyBackSpace: qtKey = Qt::Key_Backspace; break;
- case KeyEnter: qtKey = Qt::Key_Return; break;
- case KeyShift: qtKey = Qt::Key_Shift; break;
- case KeyControl: qtKey = Qt::Key_Control; break;
- case KeyAlt: qtKey = Qt::Key_Alt; break;
- case KeyCapsLock: qtKey = Qt::Key_CapsLock; break;
- case KeyEscape: qtKey = Qt::Key_Escape; break;
- case KeyPageUp: qtKey = Qt::Key_PageUp; break;
- case KeyPageDown: qtKey = Qt::Key_PageDown; break;
- case KeyEnd: qtKey = Qt::Key_End; break;
- case KeyHome: qtKey = Qt::Key_Home; break;
- case KeyLeft: qtKey = Qt::Key_Left; break;
- case KeyUp: qtKey = Qt::Key_Up; break;
- case KeyRight: qtKey = Qt::Key_Right; break;
- case KeyDown: qtKey = Qt::Key_Down; break;
- case KeyBrightnessDown: qtKey = Qt::Key_MonBrightnessDown; break;
- case KeyBrightnessUp: qtKey = Qt::Key_MonBrightnessUp; break;
- case KeyMediaTrackPrevious: qtKey = Qt::Key_MediaPrevious; break;
- case KeyMediaPlayPause: qtKey = Qt::Key_MediaTogglePlayPause; break;
- case KeyMediaTrackNext: qtKey = Qt::Key_MediaNext; break;
- case KeyAudioVolumeMute: qtKey = Qt::Key_VolumeMute; break;
- case KeyAudioVolumeDown: qtKey = Qt::Key_VolumeDown; break;
- case KeyAudioVolumeUp: qtKey = Qt::Key_VolumeUp; break;
- case KeyDelete: qtKey = Qt::Key_Delete; break;
-
- case KeyF1: qtKey = Qt::Key_F1; break;
- case KeyF2: qtKey = Qt::Key_F2; break;
- case KeyF3: qtKey = Qt::Key_F3; break;
- case KeyF4: qtKey = Qt::Key_F4; break;
- case KeyF5: qtKey = Qt::Key_F5; break;
- case KeyF6: qtKey = Qt::Key_F6; break;
- case KeyF7: qtKey = Qt::Key_F7; break;
- case KeyF8: qtKey = Qt::Key_F8; break;
- case KeyF9: qtKey = Qt::Key_F9; break;
- case KeyF10: qtKey = Qt::Key_F10; break;
- case KeyF11: qtKey = Qt::Key_F11; break;
- case KeyF12: qtKey = Qt::Key_F12; break;
- case 124: qtKey = Qt::Key_F13; break;
- case 125: qtKey = Qt::Key_F14; break;
-
- case KeySpace:
- default:
- if (outAlphanumeric)
- *outAlphanumeric = true;
- qtKey = static_cast<Qt::Key>(emscriptKey->keyCode);
- break;
- }
+ Qt::Key qtKey = Qt::Key_unknown;
+
+ if (qstrncmp(emscriptKey->code, "Key", 3) == 0 || qstrncmp(emscriptKey->code, "Numpad", 6) == 0) {
- // Handle Mac command key. Using event->keyCode as above is
- // no reliable since the codes differ between browsers.
- if (qstrncmp(emscriptKey->key, "Meta", 4) == 0) {
- qtKey = Qt::Key_Meta;
- *outAlphanumeric = false;
+ emkb2qt_t searchKey{emscriptKey->code, 0}; // search emcsripten code
+ auto it1 = std::lower_bound(KeyTbl.cbegin(), KeyTbl.cend(), searchKey);
+ if (it1 != KeyTbl.end() && !(searchKey < *it1)) {
+ qtKey = static_cast<Qt::Key>(it1->qt);
+ }
+ } else if (qstrncmp(emscriptKey->key, "Dead", 4) == 0 ) {
+ emkb2qt_t searchKey1{emscriptKey->code, 0};
+ for (auto it1 = KeyTbl.cbegin(); it1 != KeyTbl.end(); ++it1)
+ if (it1 != KeyTbl.end() && (qstrcmp(searchKey1.em, it1->em) == 0)) {
+ qtKey = static_cast<Qt::Key>(it1->qt);
+ }
}
- if (g_usePlatformMacCtrlMetaSwitching) {
- if (qtKey == Qt::Key_Meta)
- qtKey = Qt::Key_Control;
- else if (qtKey == Qt::Key_Control)
- qtKey = Qt::Key_Meta;
+ if (qtKey == Qt::Key_unknown) {
+ emkb2qt_t searchKey{emscriptKey->key, 0}; // search unicode key
+ auto it1 = std::lower_bound(KeyTbl.cbegin(), KeyTbl.cend(), searchKey);
+ if (it1 != KeyTbl.end() && !(searchKey < *it1)) {
+ qtKey = static_cast<Qt::Key>(it1->qt);
+ }
+ }
+ if (qtKey == Qt::Key_unknown) {//try harder with shifted number keys
+ emkb2qt_t searchKey1{emscriptKey->key, 0};
+ for (auto it1 = KeyTbl.cbegin(); it1 != KeyTbl.end(); ++it1)
+ if (it1 != KeyTbl.end() && (qstrcmp(searchKey1.em, it1->em) == 0)) {
+ qtKey = static_cast<Qt::Key>(it1->qt);
+ }
}
return qtKey;
@@ -382,8 +550,11 @@ void QWasmEventTranslator::processMouse(int eventType, const EmscriptenMouseEven
switch (eventType) {
case EMSCRIPTEN_EVENT_MOUSEDOWN:
{
- if (window2)
+ if (window2) {
window2->raise();
+ if (!window2->isActive())
+ window2->requestActivate();
+ }
pressedButtons.setFlag(button);
@@ -463,7 +634,6 @@ int QWasmEventTranslator::focus_cb(int /*eventType*/, const EmscriptenFocusEvent
int QWasmEventTranslator::wheel_cb(int eventType, const EmscriptenWheelEvent *wheelEvent, void *userData)
{
Q_UNUSED(eventType)
- Q_UNUSED(userData)
EmscriptenMouseEvent mouseEvent = wheelEvent->mouse;
@@ -483,7 +653,8 @@ int QWasmEventTranslator::wheel_cb(int eventType, const EmscriptenWheelEvent *wh
if (g_useNaturalScrolling) //macOS platform has document oriented scrolling
scrollFactor = -scrollFactor;
- Qt::KeyboardModifiers modifiers = translateMouseEventModifier(&mouseEvent);
+ QWasmEventTranslator *translator = (QWasmEventTranslator*)userData;
+ Qt::KeyboardModifiers modifiers = translator->translateMouseEventModifier(&mouseEvent);
auto timestamp = mouseEvent.timestamp;
QPoint globalPoint(mouseEvent.canvasX, mouseEvent.canvasY);
@@ -496,8 +667,8 @@ int QWasmEventTranslator::wheel_cb(int eventType, const EmscriptenWheelEvent *wh
if (wheelEvent->deltaY != 0) pixelDelta.setY(wheelEvent->deltaY * scrollFactor);
if (wheelEvent->deltaX != 0) pixelDelta.setX(wheelEvent->deltaX * scrollFactor);
- QWindowSystemInterface::handleWheelEvent(window2, timestamp, localPoint, globalPoint, QPoint(), pixelDelta, modifiers);
-
+ QWindowSystemInterface::handleWheelEvent(window2, timestamp, localPoint,
+ globalPoint, QPoint(), pixelDelta, modifiers);
QWasmEventDispatcher::maintainTimers();
return 1;
@@ -544,12 +715,16 @@ int QWasmEventTranslator::touchCallback(int eventType, const EmscriptenTouchEven
}
QWasmEventTranslator *wasmEventTranslator = (QWasmEventTranslator*)userData;
- QFlags<Qt::KeyboardModifier> keyModifier = translatKeyModifier(touchEvent);
+ QFlags<Qt::KeyboardModifier> keyModifier = wasmEventTranslator->translatKeyModifier(touchEvent);
if (eventType != EMSCRIPTEN_EVENT_TOUCHCANCEL)
- QWindowSystemInterface::handleTouchEvent<QWindowSystemInterface::SynchronousDelivery>(window2, wasmEventTranslator->getTimestamp(), wasmEventTranslator->touchDevice, touchPointList, keyModifier);
+ QWindowSystemInterface::handleTouchEvent
+ <QWindowSystemInterface::SynchronousDelivery>(window2, wasmEventTranslator->getTimestamp(),
+ wasmEventTranslator->touchDevice,
+ touchPointList, keyModifier);
else
- QWindowSystemInterface::handleTouchCancelEvent(window2, wasmEventTranslator->getTimestamp(), wasmEventTranslator->touchDevice, keyModifier);
+ QWindowSystemInterface::handleTouchCancelEvent(window2, wasmEventTranslator->getTimestamp(),
+ wasmEventTranslator->touchDevice, keyModifier);
QWasmEventDispatcher::maintainTimers();
return 1;
@@ -560,4 +735,112 @@ quint64 QWasmEventTranslator::getTimestamp()
return QDeadlineTimer::current().deadlineNSecs() / 1000;
}
+Qt::Key QWasmEventTranslator::translateDeadKey(Qt::Key deadKey, Qt::Key accentBaseKey)
+{
+ Qt::Key wasmKey = Qt::Key_unknown;
+ switch (deadKey) {
+#ifdef Q_OS_MACOS
+ case Qt::Key_QuoteLeft: // ` macOS: Key_Dead_Grave
+#else
+ case Qt::Key_O: // ´ Key_Dead_Grave
+#endif
+ wasmKey = graveKeyTable.value(accentBaseKey);
+ break;
+ case Qt::Key_E: // ´ Key_Dead_Acute
+ wasmKey = acuteKeyTable.value(accentBaseKey);
+ break;
+ case Qt::Key_AsciiTilde:
+ case Qt::Key_N:// Key_Dead_Tilde
+ wasmKey = tildeKeyTable.value(accentBaseKey);
+ break;
+#ifndef Q_OS_MACOS
+ case Qt::Key_QuoteLeft:
+#endif
+ case Qt::Key_U:// ¨ Key_Dead_Diaeresis
+ wasmKey = diaeresisKeyTable.value(accentBaseKey);
+ break;
+ case Qt::Key_I:// macOS Key_Dead_Circumflex
+ case Qt::Key_6:// linux
+ case Qt::Key_Apostrophe:// linux
+ wasmKey = circumflexKeyTable.value(accentBaseKey);
+ break;
+ break;
+ default:
+ break;
+ };
+
+ return wasmKey;
+}
+
+bool QWasmEventTranslator::processKeyboard(int eventType, const EmscriptenKeyboardEvent *keyEvent)
+{
+ Qt::Key qtKey = translateEmscriptKey(keyEvent);
+
+ Qt::KeyboardModifiers modifiers = translateKeyboardEventModifier(keyEvent);
+
+ QString keyText;
+ QEvent::Type keyType = QEvent::None;
+ switch (eventType) {
+ case EMSCRIPTEN_EVENT_KEYPRESS:
+ case EMSCRIPTEN_EVENT_KEYDOWN: // down
+ keyType = QEvent::KeyPress;
+
+ if (m_emDeadKey != Qt::Key_unknown) {
+
+ Qt::Key transformedKey = translateDeadKey(m_emDeadKey, qtKey);
+
+ if (transformedKey != Qt::Key_unknown)
+ qtKey = transformedKey;
+
+ if (keyEvent->shiftKey == 0) {
+ for (auto it = KeyTbl.cbegin(); it != KeyTbl.end(); ++it) {
+ if (it != KeyTbl.end() && (qtKey == static_cast<Qt::Key>(it->qt))) {
+ keyText = it->em;
+ m_emDeadKey = Qt::Key_unknown;
+ break;
+ }
+ }
+ } else {
+ for (auto it = DeadKeyShiftTbl.cbegin(); it != DeadKeyShiftTbl.end(); ++it) {
+ if (it != DeadKeyShiftTbl.end() && (qtKey == static_cast<Qt::Key>(it->qt))) {
+ keyText = it->em;
+ m_emDeadKey = Qt::Key_unknown;
+ break;
+ }
+ }
+ }
+ }
+ if (qstrncmp(keyEvent->key, "Dead", 4) == 0 || qtKey == Qt::Key_AltGr) {
+ qtKey = translateEmscriptKey(keyEvent);
+ m_emStickyDeadKey = true;
+ if (keyEvent->shiftKey == 1 && qtKey == Qt::Key_QuoteLeft)
+ qtKey = Qt::Key_AsciiTilde;
+ m_emDeadKey = qtKey;
+ }
+ break;
+ case EMSCRIPTEN_EVENT_KEYUP: // up
+ keyType = QEvent::KeyRelease;
+ if (m_emStickyDeadKey && qtKey != Qt::Key_Alt) {
+ m_emStickyDeadKey = false;
+ }
+ break;
+ default:
+ break;
+ };
+
+ if (keyType == QEvent::None)
+ return 0;
+
+ bool accepted = false;
+
+ if (keyText.isEmpty())
+ keyText = QString(keyEvent->key);
+ if (keyText.size() > 1)
+ keyText.clear();
+ accepted = QWindowSystemInterface::handleKeyEvent<QWindowSystemInterface::SynchronousDelivery>(
+ 0, keyType, qtKey, modifiers, keyText);
+ QWasmEventDispatcher::maintainTimers();
+ return accepted ? 1 : 0;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/wasm/qwasmeventtranslator.h b/src/plugins/platforms/wasm/qwasmeventtranslator.h
index f3dff8e48c..25e2a630b6 100644
--- a/src/plugins/platforms/wasm/qwasmeventtranslator.h
+++ b/src/plugins/platforms/wasm/qwasmeventtranslator.h
@@ -36,6 +36,7 @@
#include <emscripten/html5.h>
#include "qwasmwindow.h"
#include <QtGui/qtouchdevice.h>
+#include <QHash>
QT_BEGIN_NAMESPACE
@@ -45,130 +46,6 @@ class QWasmEventTranslator : public QObject
{
Q_OBJECT
- enum KeyCode {
- // numpad
- KeyNumPad0 = 0x60,
- KeyNumPad1 = 0x61,
- KeyNumPad2 = 0x62,
- KeyNumPad3 = 0x63,
- KeyNumPad4 = 0x64,
- KeyNumPad5 = 0x65,
- KeyNumPad6 = 0x66,
- KeyNumPad7 = 0x67,
- KeyNumPad8 = 0x68,
- KeyNumPad9 = 0x69,
- KeyMultiply = 0x6A,
- KeyAdd = 0x6B,
- KeySeparator = 0x6C,
- KeySubtract = 0x6D,
- KeyDecimal = 0x6E,
- KeyDivide = 0x6F,
- KeyMeta = 0x5B,
- KeyMetaRight = 0x5C,
- ////////
- KeyClear = 0x90,
- KeyEnter = 0xD,
- KeyBackSpace = 0x08,
- KeyCancel = 0x03,
- KeyTab = 0x09,
- KeyShift = 0x10,
- KeyControl = 0x11,
- KeyAlt = 0x12,
- KeyPause = 0x13,
- KeyCapsLock = 0x14,
- KeyEscape = 0x1B,
- KeySpace = 0x20,
- KeyPageUp = 0x21,
- KeyPageDown = 0x22,
- KeyEnd = 0x23,
- KeyHome = 0x24,
- KeyLeft = 0x25,
- KeyUp = 0x26,
- KeyRight = 0x27,
- KeyDown = 0x28,
- KeyComma = 0xBC,
- KeyPeriod = 0xBE,
- KeySlash = 0xBF,
- KeyZero = 0x30,
- KeyOne = 0x31,
- KeyTwo = 0x32,
- KeyThree = 0x33,
- KeyFour = 0x34,
- KeyFive = 0x35,
- KeySix = 0x36,
- KeySeven = 0x37,
- KeyEight = 0x38,
- KeyNine = 0x39,
- KeyBrightnessDown = 0xD8,
- KeyBrightnessUp = 0xD9,
- KeyMediaTrackPrevious = 0xB1,
- KeyMediaPlayPause = 0xB3,
- KeyMediaTrackNext = 0xB0,
- KeyAudioVolumeMute = 0xAD,
- KeyAudioVolumeDown = 0xAE,
- KeyAudioVolumeUp = 0xAF,
- KeySemiColon = 0xBA,
- KeyEquals = 0xBB,
- KeyMinus = 0xBD,
- KeyA = 0x41,
- KeyB = 0x42,
- KeyC = 0x43,
- KeyD = 0x44,
- KeyE = 0x45,
- KeyF = 0x46,
- KeyG = 0x47,
- KeyH = 0x48,
- KeyI = 0x49,
- KeyJ = 0x4A,
- KeyK = 0x4B,
- KeyL = 0x4C,
- KeyM = 0x4D,
- KeyN = 0x4E,
- KeyO = 0x4F,
- KeyP = 0x50,
- KeyQ = 0x51,
- KeyR = 0x52,
- KeyS = 0x53,
- KeyT = 0x54,
- KeyU = 0x55,
- KeyV = 0x56,
- KeyW = 0x57,
- KeyX = 0x58,
- KeyY = 0x59,
- KeyZ = 0x5A,
- KeyOpenBracket = 0xDB,
- KeyBackSlash = 0xDC,
- KeyCloseBracket = 0xDD,
- KeyF1 = 0x70,
- KeyF2 = 0x71,
- KeyF3 = 0x72,
- KeyF4 = 0x73,
- KeyF5 = 0x74,
- KeyF6 = 0x75,
- KeyF7 = 0x76,
- KeyF8 = 0x77,
- KeyF9 = 0x78,
- KeyF10 = 0x79,
- KeyF11 = 0x7A,
- KeyF12 = 0x7B,
- KeyDelete = 0x2E,
- KeyNumLock = 0x90,
- KeyScrollLock = 0x91,
- KeyPrintScreen = 0x9A,
- KeyInsert = 0x9B,
- KeyHelp = 0x9C,
- KeyBackQuote = 0xC0,
- KeyQuote = 0xDE,
- KeyFinal = 0x18,
- KeyConvert = 0x1C,
- KeyNonConvert = 0x1D,
- KeyAccept = 0x1E,
- KeyModeChange = 0x1F,
- KeyKana = 0x15,
- KeyKanji = 0x19,
- KeyUndefined = 0x0
- };
-
public:
explicit QWasmEventTranslator(QObject *parent = 0);
@@ -185,14 +62,54 @@ public:
Q_SIGNALS:
void getWindowAt(const QPoint &point, QWindow **window);
private:
- static Qt::Key translateEmscriptKey(const EmscriptenKeyboardEvent *emscriptKey, bool *outAlphanumretic);
+
+ Qt::Key translateEmscriptKey(const EmscriptenKeyboardEvent *emscriptKey);
template <typename Event>
- static QFlags<Qt::KeyboardModifier> translatKeyModifier(const Event *event);
- static QFlags<Qt::KeyboardModifier> translateKeyboardEventModifier(const EmscriptenKeyboardEvent *keyEvent);
- static QFlags<Qt::KeyboardModifier> translateMouseEventModifier(const EmscriptenMouseEvent *mouseEvent);
- static Qt::MouseButton translateMouseButton(unsigned short button);
+ QFlags<Qt::KeyboardModifier> translatKeyModifier(const Event *event);
+ QFlags<Qt::KeyboardModifier> translateKeyboardEventModifier(const EmscriptenKeyboardEvent *keyEvent);
+ QFlags<Qt::KeyboardModifier> translateMouseEventModifier(const EmscriptenMouseEvent *mouseEvent);
+ Qt::MouseButton translateMouseButton(unsigned short button);
void processMouse(int eventType, const EmscriptenMouseEvent *mouseEvent);
+ bool processKeyboard(int eventType, const EmscriptenKeyboardEvent *keyEvent);
+
+ Qt::Key translateDeadKey(Qt::Key deadKey, Qt::Key accentBaseKey);
+
+ QHash<Qt::Key , Qt::Key> tildeKeyTable { // ~
+ { Qt::Key_A, Qt::Key_Atilde},
+ { Qt::Key_N, Qt::Key_Ntilde},
+ { Qt::Key_O, Qt::Key_Otilde}
+ };
+ QHash<Qt::Key , Qt::Key> graveKeyTable { // `
+ { Qt::Key_A, Qt::Key_Agrave},
+ { Qt::Key_E, Qt::Key_Egrave},
+ { Qt::Key_I, Qt::Key_Igrave},
+ { Qt::Key_O, Qt::Key_Ograve},
+ { Qt::Key_U, Qt::Key_Ugrave}
+ };
+ QHash<Qt::Key , Qt::Key> acuteKeyTable { // '
+ { Qt::Key_A, Qt::Key_Aacute},
+ { Qt::Key_E, Qt::Key_Eacute},
+ { Qt::Key_I, Qt::Key_Iacute},
+ { Qt::Key_O, Qt::Key_Oacute},
+ { Qt::Key_U, Qt::Key_Uacute},
+ { Qt::Key_Y, Qt::Key_Yacute}
+ };
+ QHash<Qt::Key , Qt::Key> diaeresisKeyTable { // umlaut ¨
+ { Qt::Key_A, Qt::Key_Adiaeresis},
+ { Qt::Key_E, Qt::Key_Ediaeresis},
+ { Qt::Key_I, Qt::Key_Idiaeresis},
+ { Qt::Key_O, Qt::Key_Odiaeresis},
+ { Qt::Key_U, Qt::Key_Udiaeresis},
+ { Qt::Key_Y, Qt::Key_ydiaeresis}
+ };
+ QHash<Qt::Key , Qt::Key> circumflexKeyTable { // ^
+ { Qt::Key_A, Qt::Key_Acircumflex},
+ { Qt::Key_E, Qt::Key_Ecircumflex},
+ { Qt::Key_I, Qt::Key_Icircumflex},
+ { Qt::Key_O, Qt::Key_Ocircumflex},
+ { Qt::Key_U, Qt::Key_Ucircumflex}
+ };
private:
QWindow *draggedWindow;
@@ -205,6 +122,9 @@ private:
QRect resizeStartRect;
QTouchDevice *touchDevice;
quint64 getTimestamp();
+
+ Qt::Key m_emDeadKey = Qt::Key_unknown;
+ bool m_emStickyDeadKey = false;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/wasm/qwasmintegration.cpp b/src/plugins/platforms/wasm/qwasmintegration.cpp
index 1be909f0a0..6f96ec69da 100644
--- a/src/plugins/platforms/wasm/qwasmintegration.cpp
+++ b/src/plugins/platforms/wasm/qwasmintegration.cpp
@@ -33,6 +33,7 @@
#include "qwasmcompositor.h"
#include "qwasmopenglcontext.h"
#include "qwasmtheme.h"
+#include "qwasmclipboard.h"
#include "qwasmwindow.h"
#ifndef QT_NO_OPENGL
@@ -55,7 +56,7 @@
using namespace emscripten;
QT_BEGIN_NAMESPACE
-void browserBeforeUnload()
+void browserBeforeUnload(emscripten::val)
{
QWasmIntegration::QWasmBrowserExit();
}
@@ -65,17 +66,16 @@ EMSCRIPTEN_BINDINGS(my_module)
function("browserBeforeUnload", &browserBeforeUnload);
}
-static QWasmIntegration *globalHtml5Integration;
-QWasmIntegration *QWasmIntegration::get() { return globalHtml5Integration; }
+QWasmIntegration *QWasmIntegration::s_instance;
QWasmIntegration::QWasmIntegration()
: m_fontDb(nullptr),
m_compositor(new QWasmCompositor),
m_screen(new QWasmScreen(m_compositor)),
- m_eventDispatcher(nullptr)
+ m_eventDispatcher(nullptr),
+ m_clipboard(new QWasmClipboard)
{
-
- globalHtml5Integration = this;
+ s_instance = this;
updateQScreenAndCanvasRenderSize();
screenAdded(m_screen);
@@ -83,11 +83,8 @@ QWasmIntegration::QWasmIntegration()
m_eventTranslator = new QWasmEventTranslator;
- EM_ASM(// exit app if browser closes
- window.onbeforeunload = function () {
- Module.browserBeforeUnload();
- };
- );
+ emscripten::val::global("window").set("onbeforeunload", val::module_property("browserBeforeUnload"));
+
}
QWasmIntegration::~QWasmIntegration()
@@ -96,6 +93,7 @@ QWasmIntegration::~QWasmIntegration()
destroyScreen(m_screen);
delete m_fontDb;
delete m_eventTranslator;
+ s_instance = nullptr;
}
void QWasmIntegration::QWasmBrowserExit()
@@ -187,11 +185,9 @@ int QWasmIntegration::uiEvent_cb(int eventType, const EmscriptenUiEvent *e, void
static void set_canvas_size(double width, double height)
{
- EM_ASM_({
- var canvas = Module.canvas;
- canvas.width = $0;
- canvas.height = $1;
- }, width, height);
+ emscripten::val canvas = emscripten::val::global("canvas");
+ canvas.set("width", width);
+ canvas.set("height", height);
}
void QWasmIntegration::updateQScreenAndCanvasRenderSize()
@@ -216,4 +212,11 @@ void QWasmIntegration::updateQScreenAndCanvasRenderSize()
QWasmIntegration::get()->m_compositor->redrawWindowContent();
}
+QPlatformClipboard* QWasmIntegration::clipboard() const
+{
+ if (!m_clipboard)
+ m_clipboard = new QWasmClipboard;
+ return m_clipboard;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/wasm/qwasmintegration.h b/src/plugins/platforms/wasm/qwasmintegration.h
index ebc3d9d431..4c5aeb4ebc 100644
--- a/src/plugins/platforms/wasm/qwasmintegration.h
+++ b/src/plugins/platforms/wasm/qwasmintegration.h
@@ -49,6 +49,7 @@ class QWasmEventDispatcher;
class QWasmScreen;
class QWasmCompositor;
class QWasmBackingStore;
+class QWasmClipboard;
class QWasmIntegration : public QObject, public QPlatformIntegration
{
@@ -68,12 +69,14 @@ public:
QVariant styleHint(QPlatformIntegration::StyleHint hint) const override;
QStringList themeNames() const override;
QPlatformTheme *createPlatformTheme(const QString &name) const override;
+ QPlatformClipboard *clipboard() const override;
- static QWasmIntegration *get();
QWasmScreen *screen() { return m_screen; }
QWasmCompositor *compositor() { return m_compositor; }
QWasmEventTranslator *eventTranslator() { return m_eventTranslator; }
+ QWasmClipboard *getWasmClipboard() { return m_clipboard; }
+ static QWasmIntegration *get() { return s_instance; }
static void QWasmBrowserExit();
static void updateQScreenAndCanvasRenderSize();
@@ -85,6 +88,9 @@ private:
mutable QWasmEventDispatcher *m_eventDispatcher;
static int uiEvent_cb(int eventType, const EmscriptenUiEvent *e, void *userData);
mutable QHash<QWindow *, QWasmBackingStore *> m_backingStores;
+
+ mutable QWasmClipboard *m_clipboard;
+ static QWasmIntegration *s_instance;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/wasm/qwasmscreen.cpp b/src/plugins/platforms/wasm/qwasmscreen.cpp
index 93e9906ffc..37f1efadc6 100644
--- a/src/plugins/platforms/wasm/qwasmscreen.cpp
+++ b/src/plugins/platforms/wasm/qwasmscreen.cpp
@@ -30,6 +30,7 @@
#include "qwasmscreen.h"
#include "qwasmwindow.h"
#include "qwasmcompositor.h"
+#include <emscripten/bind.h>
#include <QtEglSupport/private/qeglconvenience_p.h>
#ifndef QT_NO_OPENGL
@@ -77,9 +78,7 @@ qreal QWasmScreen::devicePixelRatio() const
// HTML window dpr if the OpenGL driver/GPU allocates a less than
// full resolution surface. Use emscripten_webgl_get_drawing_buffer_size()
// and compute the dpr instead.
- double htmlWindowDpr = EM_ASM_DOUBLE({
- return window.devicePixelRatio;
- });
+ double htmlWindowDpr = emscripten::val::global("window")["devicePixelRatio"].as<double>();
return qreal(htmlWindowDpr);
}
diff --git a/src/plugins/platforms/wasm/qwasmwindow.cpp b/src/plugins/platforms/wasm/qwasmwindow.cpp
index 25a0190053..39797cb09d 100644
--- a/src/plugins/platforms/wasm/qwasmwindow.cpp
+++ b/src/plugins/platforms/wasm/qwasmwindow.cpp
@@ -198,8 +198,10 @@ void QWasmWindow::injectMouseReleased(const QPoint &local, const QPoint &global,
if (!hasTitleBar() || button != Qt::LeftButton)
return;
- if (closeButtonRect().contains(global) && m_activeControl == QWasmCompositor::SC_TitleBarCloseButton)
+ if (closeButtonRect().contains(global) && m_activeControl == QWasmCompositor::SC_TitleBarCloseButton) {
window()->close();
+ return;
+ }
if (maxButtonRect().contains(global) && m_activeControl == QWasmCompositor::SC_TitleBarMaxButton) {
window()->setWindowState(Qt::WindowMaximized);
diff --git a/src/plugins/platforms/wasm/wasm.pro b/src/plugins/platforms/wasm/wasm.pro
index eaaba53aa2..5aa6dfccf3 100644
--- a/src/plugins/platforms/wasm/wasm.pro
+++ b/src/plugins/platforms/wasm/wasm.pro
@@ -18,7 +18,8 @@ SOURCES = \
qwasmcompositor.cpp \
qwasmcursor.cpp \
qwasmopenglcontext.cpp \
- qwasmtheme.cpp
+ qwasmtheme.cpp \
+ qwasmclipboard.cpp
HEADERS = \
qwasmintegration.h \
@@ -31,7 +32,8 @@ HEADERS = \
qwasmstylepixmaps_p.h \
qwasmcursor.h \
qwasmopenglcontext.h \
- qwasmtheme.h
+ qwasmtheme.h \
+ qwasmclipboard.h
wasmfonts.files = \
../../../3rdparty/wasm/Vera.ttf \
diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp
index 8adcf56b11..878f55e56b 100644
--- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp
@@ -445,7 +445,7 @@ static inline QTextFormat standardFormat(StandardFormat format)
const QPalette palette = QGuiApplication::palette();
const QColor background = palette.text().color();
result.setBackground(QBrush(background));
- result.setForeground(palette.background());
+ result.setForeground(palette.window());
break;
}
}
diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
index 32eec322e8..7b314878f5 100644
--- a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
+++ b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
@@ -277,6 +277,8 @@ QFunctionPointer QWindowsNativeInterface::platformFunction(const QByteArray &fun
return QFunctionPointer(QWindowsWindow::setTouchWindowTouchTypeStatic);
if (function == QWindowsWindowFunctions::setHasBorderInFullScreenIdentifier())
return QFunctionPointer(QWindowsWindow::setHasBorderInFullScreenStatic);
+ if (function == QWindowsWindowFunctions::setHasBorderInFullScreenDefaultIdentifier())
+ return QFunctionPointer(QWindowsWindow::setHasBorderInFullScreenDefault);
if (function == QWindowsWindowFunctions::setWindowActivationBehaviorIdentifier())
return QFunctionPointer(QWindowsNativeInterface::setWindowActivationBehavior);
if (function == QWindowsWindowFunctions::isTabletModeIdentifier())
diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp
index 6dd3e6ed56..a6b9781252 100644
--- a/src/plugins/platforms/windows/qwindowstheme.cpp
+++ b/src/plugins/platforms/windows/qwindowstheme.cpp
@@ -284,24 +284,24 @@ static inline QPalette systemPalette()
result.setColor(QPalette::Link, Qt::blue);
result.setColor(QPalette::LinkVisited, Qt::magenta);
result.setColor(QPalette::Inactive, QPalette::Button, result.button().color());
- result.setColor(QPalette::Inactive, QPalette::Window, result.background().color());
+ result.setColor(QPalette::Inactive, QPalette::Window, result.window().color());
result.setColor(QPalette::Inactive, QPalette::Light, result.light().color());
result.setColor(QPalette::Inactive, QPalette::Dark, result.dark().color());
if (result.midlight() == result.button())
result.setColor(QPalette::Midlight, result.button().color().lighter(110));
- if (result.background() != result.base()) {
+ if (result.window() != result.base()) {
result.setColor(QPalette::Inactive, QPalette::Highlight, result.color(QPalette::Inactive, QPalette::Window));
result.setColor(QPalette::Inactive, QPalette::HighlightedText, result.color(QPalette::Inactive, QPalette::Text));
}
const QColor disabled =
- mixColors(result.foreground().color(), result.button().color());
+ mixColors(result.windowText().color(), result.button().color());
- result.setColorGroup(QPalette::Disabled, result.foreground(), result.button(),
+ result.setColorGroup(QPalette::Disabled, result.windowText(), result.button(),
result.light(), result.dark(), result.mid(),
result.text(), result.brightText(), result.base(),
- result.background());
+ result.window());
result.setColor(QPalette::Disabled, QPalette::WindowText, disabled);
result.setColor(QPalette::Disabled, QPalette::Text, disabled);
result.setColor(QPalette::Disabled, QPalette::ButtonText, disabled);
@@ -310,7 +310,7 @@ static inline QPalette systemPalette()
result.setColor(QPalette::Disabled, QPalette::HighlightedText,
getSysColor(COLOR_HIGHLIGHTTEXT));
result.setColor(QPalette::Disabled, QPalette::Base,
- result.background().color());
+ result.window().color());
return result;
}
@@ -333,7 +333,7 @@ static inline QPalette toolTipPalette(const QPalette &systemPalette)
result.setColor(QPalette::All, QPalette::ToolTipBase, tipBgColor);
result.setColor(QPalette::All, QPalette::ToolTipText, tipTextColor);
const QColor disabled =
- mixColors(result.foreground().color(), result.button().color());
+ mixColors(result.windowText().color(), result.button().color());
result.setColor(QPalette::Disabled, QPalette::WindowText, disabled);
result.setColor(QPalette::Disabled, QPalette::Text, disabled);
result.setColor(QPalette::Disabled, QPalette::ToolTipText, disabled);
@@ -858,7 +858,8 @@ QPixmap QWindowsFileIconEngine::filePixmap(const QSize &size, QIcon::Mode, QIcon
int iIcon = (useDefaultFolderIcon && defaultFolderIIcon >= 0) ? defaultFolderIIcon
: **dirIconEntryCache.object(filePath);
if (iIcon) {
- QPixmapCache::find(dirIconPixmapCacheKey(iIcon, iconSize, requestedImageListSize), pixmap);
+ QPixmapCache::find(dirIconPixmapCacheKey(iIcon, iconSize, requestedImageListSize),
+ &pixmap);
if (pixmap.isNull()) // Let's keep both caches in sync
dirIconEntryCache.remove(filePath);
else
@@ -889,7 +890,7 @@ QPixmap QWindowsFileIconEngine::filePixmap(const QSize &size, QIcon::Mode, QIcon
//using the unique icon index provided by windows save us from duplicate keys
key = dirIconPixmapCacheKey(info.iIcon, iconSize, requestedImageListSize);
- QPixmapCache::find(key, pixmap);
+ QPixmapCache::find(key, &pixmap);
if (!pixmap.isNull()) {
QMutexLocker locker(&mx);
dirIconEntryCache.insert(filePath, FakePointer<int>::create(info.iIcon));
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index c5d57be2ad..99be4882bb 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -1180,6 +1180,7 @@ QWindowCreationContext::QWindowCreationContext(const QWindow *w,
const char *QWindowsWindow::embeddedNativeParentHandleProperty = "_q_embedded_native_parent_handle";
const char *QWindowsWindow::hasBorderInFullScreenProperty = "_q_has_border_in_fullscreen";
+bool QWindowsWindow::m_borderInFullScreenDefault = false;
QWindowsWindow::QWindowsWindow(QWindow *aWindow, const QWindowsWindowData &data) :
QWindowsBaseWindow(aWindow),
@@ -1217,7 +1218,7 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const QWindowsWindowData &data)
if (aWindow->isTopLevel())
setWindowIcon(aWindow->icon());
- if (aWindow->property(hasBorderInFullScreenProperty).toBool())
+ if (m_borderInFullScreenDefault || aWindow->property(hasBorderInFullScreenProperty).toBool())
setFlag(HasBorderInFullScreen);
clearFlag(WithinCreate);
}
@@ -2816,6 +2817,11 @@ void QWindowsWindow::setHasBorderInFullScreenStatic(QWindow *window, bool border
window->setProperty(hasBorderInFullScreenProperty, QVariant(border));
}
+void QWindowsWindow::setHasBorderInFullScreenDefault(bool border)
+{
+ m_borderInFullScreenDefault = border;
+}
+
void QWindowsWindow::setHasBorderInFullScreen(bool border)
{
if (testFlag(HasBorderInFullScreen) == border)
diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h
index b9b398b67b..b07bd15d2a 100644
--- a/src/plugins/platforms/windows/qwindowswindow.h
+++ b/src/plugins/platforms/windows/qwindowswindow.h
@@ -341,6 +341,7 @@ public:
static void setTouchWindowTouchTypeStatic(QWindow *window, QWindowsWindowFunctions::TouchWindowTouchTypes touchTypes);
void registerTouchWindow(QWindowsWindowFunctions::TouchWindowTouchTypes touchTypes = QWindowsWindowFunctions::NormalTouch);
static void setHasBorderInFullScreenStatic(QWindow *window, bool border);
+ static void setHasBorderInFullScreenDefault(bool border);
void setHasBorderInFullScreen(bool border);
static QString formatWindowTitle(const QString &title);
@@ -386,6 +387,7 @@ private:
// note: intentionally not using void * in order to avoid breaking x86
VkSurfaceKHR m_vkSurface = 0;
#endif
+ static bool m_borderInFullScreenDefault;
};
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/plugins/platforms/xcb/nativepainting/qpaintengine_x11.cpp b/src/plugins/platforms/xcb/nativepainting/qpaintengine_x11.cpp
index a3e6cedecd..2688d6e884 100644
--- a/src/plugins/platforms/xcb/nativepainting/qpaintengine_x11.cpp
+++ b/src/plugins/platforms/xcb/nativepainting/qpaintengine_x11.cpp
@@ -458,7 +458,7 @@ static QPixmap qt_patternForAlpha(uchar alpha, int screen)
% HexString<uchar>(alpha)
% HexString<int>(screen);
- if (!QPixmapCache::find(key, pm)) {
+ if (!QPixmapCache::find(key, &pm)) {
// #### why not use a mono image here????
QImage pattern(DITHER_SIZE, DITHER_SIZE, QImage::Format_ARGB32);
pattern.fill(0xffffffff);
diff --git a/src/plugins/platforms/xcb/nativepainting/qpaintengine_x11_p.h b/src/plugins/platforms/xcb/nativepainting/qpaintengine_x11_p.h
index 9b01c0a3fc..bc82351283 100644
--- a/src/plugins/platforms/xcb/nativepainting/qpaintengine_x11_p.h
+++ b/src/plugins/platforms/xcb/nativepainting/qpaintengine_x11_p.h
@@ -116,7 +116,7 @@ protected:
friend GC qt_x11_get_brush_gc(QPainter *);
private:
- Q_DISABLE_COPY(QX11PaintEngine)
+ Q_DISABLE_COPY_MOVE(QX11PaintEngine)
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
index f9240a45cc..741317d766 100644
--- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp
+++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
@@ -641,17 +641,17 @@ void QXcbBackingStoreImage::flushPixmap(const QRegion &region, bool fullRegion)
xcb_subimage.bit_order = m_xcb_image->bit_order;
const bool needsByteSwap = xcb_subimage.byte_order != m_xcb_image->byte_order;
+ // Ensure that we don't send more than maxPutImageRequestDataBytes per request.
+ const auto maxPutImageRequestDataBytes = connection()->maxRequestDataBytes(sizeof(xcb_put_image_request_t));
for (const QRect &rect : region) {
- // We must make sure that each request is not larger than max_req_size.
- // Each request takes req_size + m_xcb_image->stride * height bytes.
- static const uint32_t req_size = sizeof(xcb_put_image_request_t);
- const uint32_t max_req_size = xcb_get_maximum_request_length(xcb_connection());
- const int rows_per_put = (max_req_size - req_size) / m_xcb_image->stride;
+ const quint32 stride = round_up_scanline(rect.width() * m_qimage.depth(), xcb_subimage.scanline_pad) >> 3;
+ const int rows_per_put = maxPutImageRequestDataBytes / stride;
// This assert could trigger if a single row has more pixels than fit in
- // a single PutImage request. However, max_req_size is guaranteed to be
- // at least 16384 bytes. That should be enough for quite large images.
+ // a single PutImage request. In the absence of the BIG-REQUESTS extension
+ // the theoretical maximum lengths of maxPutImageRequestDataBytes can be
+ // roughly 256kB.
Q_ASSERT(rows_per_put > 0);
// If we upload the whole image in a single chunk, the result might be
@@ -666,9 +666,10 @@ void QXcbBackingStoreImage::flushPixmap(const QRegion &region, bool fullRegion)
while (height > 0) {
const int rows = std::min(height, rows_per_put);
const QRect subRect(x, y, width, rows);
- const quint32 stride = round_up_scanline(width * m_qimage.depth(), xcb_subimage.scanline_pad) >> 3;
const QImage subImage = native_sub_image(&m_flushBuffer, stride, m_qimage, subRect, needsByteSwap);
+ Q_ASSERT(static_cast<size_t>(subImage.sizeInBytes()) <= maxPutImageRequestDataBytes);
+
xcb_subimage.width = width;
xcb_subimage.height = rows;
xcb_subimage.data = const_cast<uint8_t *>(subImage.constBits());
diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp
index ac8b029916..2cb6720d40 100644
--- a/src/plugins/platforms/xcb/qxcbclipboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp
@@ -240,8 +240,8 @@ QXcbClipboard::QXcbClipboard(QXcbConnection *c)
xcb_xfixes_select_selection_input_checked(xcb_connection(), m_owner, atom(QXcbAtom::CLIPBOARD), mask);
}
- // change property protocol request is 24 bytes
- m_increment = (xcb_get_maximum_request_length(xcb_connection()) * 4) - 24;
+ // xcb_change_property_request_t and xcb_get_property_request_t are the same size
+ m_maxPropertyRequestDataBytes = connection()->maxRequestDataBytes(sizeof(xcb_change_property_request_t));
}
QXcbClipboard::~QXcbClipboard()
@@ -486,7 +486,7 @@ xcb_atom_t QXcbClipboard::sendSelection(QMimeData *d, xcb_atom_t target, xcb_win
if (m_clipboard_closing)
allow_incr = false;
- if (data.size() > m_increment && allow_incr) {
+ if (data.size() > m_maxPropertyRequestDataBytes && allow_incr) {
long bytes = data.size();
xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, window, property,
atom(QXcbAtom::INCR), 32, 1, (const void *)&bytes);
@@ -496,7 +496,7 @@ xcb_atom_t QXcbClipboard::sendSelection(QMimeData *d, xcb_atom_t target, xcb_win
}
// make sure we can perform the XChangeProperty in a single request
- if (data.size() > m_increment)
+ if (data.size() > m_maxPropertyRequestDataBytes)
return XCB_NONE; // ### perhaps use several XChangeProperty calls w/ PropModeAppend?
int dataSize = data.size() / (dataFormat / 8);
// use a single request to transfer data
@@ -678,17 +678,8 @@ void QXcbClipboard::handleXFixesSelectionRequest(xcb_xfixes_selection_notify_eve
emitChanged(mode);
}
-
-static inline int maxSelectionIncr(xcb_connection_t *c)
-{
- int l = xcb_get_maximum_request_length(c);
- return (l > 65536 ? 65536*4 : l*4) - 100;
-}
-
bool QXcbClipboard::clipboardReadProperty(xcb_window_t win, xcb_atom_t property, bool deleteProperty, QByteArray *buffer, int *size, xcb_atom_t *type, int *format)
{
- int maxsize = maxSelectionIncr(xcb_connection());
- ulong bytes_left; // bytes_after
xcb_atom_t dummy_type;
int dummy_format;
@@ -705,7 +696,8 @@ bool QXcbClipboard::clipboardReadProperty(xcb_window_t win, xcb_atom_t property,
}
*type = reply->type;
*format = reply->format;
- bytes_left = reply->bytes_after;
+
+ auto bytes_left = reply->bytes_after;
int offset = 0, buffer_offset = 0;
@@ -720,7 +712,8 @@ bool QXcbClipboard::clipboardReadProperty(xcb_window_t win, xcb_atom_t property,
while (bytes_left) {
// more to read...
- reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(), false, win, property, XCB_GET_PROPERTY_TYPE_ANY, offset, maxsize/4);
+ reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(), false, win, property,
+ XCB_GET_PROPERTY_TYPE_ANY, offset, m_maxPropertyRequestDataBytes / 4);
if (!reply || reply->type == XCB_NONE)
break;
diff --git a/src/plugins/platforms/xcb/qxcbclipboard.h b/src/plugins/platforms/xcb/qxcbclipboard.h
index 26d3b3b395..51ae0dc1ee 100644
--- a/src/plugins/platforms/xcb/qxcbclipboard.h
+++ b/src/plugins/platforms/xcb/qxcbclipboard.h
@@ -113,7 +113,7 @@ public:
xcb_window_t getSelectionOwner(xcb_atom_t atom) const;
QByteArray getSelection(xcb_atom_t selection, xcb_atom_t target, xcb_atom_t property, xcb_timestamp_t t = 0);
- int increment() const { return m_increment; }
+ int increment() const { return m_maxPropertyRequestDataBytes; }
int clipboardTimeout() const { return clipboard_timeout; }
void removeTransaction(xcb_window_t window) { m_transactions.remove(window); }
@@ -137,7 +137,7 @@ private:
static const int clipboard_timeout;
- int m_increment = 0;
+ int m_maxPropertyRequestDataBytes = 0;
bool m_clipboard_closing = false;
xcb_timestamp_t m_incr_receive_time = 0;
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index 29acf0e86d..1ff06dd39e 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -132,6 +132,12 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
if (!m_startupId.isNull())
qunsetenv("DESKTOP_STARTUP_ID");
+ m_focusInTimer.setSingleShot(true);
+ m_focusInTimer.callOnTimeout([]() {
+ // No FocusIn events for us, proceed with FocusOut normally.
+ QWindowSystemInterface::handleWindowActivated(nullptr, Qt::ActiveWindowFocusReason);
+ });
+
sync();
}
@@ -732,11 +738,6 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
m_glIntegration->handleXcbEvent(event, response_type);
}
-void QXcbConnection::addPeekFunc(PeekFunc f)
-{
- m_peekFuncs.append(f);
-}
-
void QXcbConnection::setFocusWindow(QWindow *w)
{
m_focusWindow = w ? static_cast<QXcbWindow *>(w->handle()) : nullptr;
@@ -1016,15 +1017,6 @@ void QXcbConnection::processXcbEvents(QEventLoop::ProcessEventsFlags flags)
if (compressEvent(event))
continue;
- auto isWaitingFor = [=](PeekFunc peekFunc) {
- // These callbacks return true if the event is what they were
- // waiting for, remove them from the list in that case.
- return peekFunc(this, event);
- };
- m_peekFuncs.erase(std::remove_if(m_peekFuncs.begin(), m_peekFuncs.end(),
- isWaitingFor),
- m_peekFuncs.end());
-
handleXcbEvent(event);
// The lock-based solution used to free the lock inside this loop,
@@ -1033,12 +1025,6 @@ void QXcbConnection::processXcbEvents(QEventLoop::ProcessEventsFlags flags)
m_eventQueue->flushBufferedEvents();
}
- // Indicate with a null event that the event the callbacks are waiting for
- // is not in the queue currently.
- for (PeekFunc f : qAsConst(m_peekFuncs))
- f(this, nullptr);
- m_peekFuncs.clear();
-
xcb_flush(xcb_connection());
}
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h
index 47036ca257..0e3ecd135b 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.h
+++ b/src/plugins/platforms/xcb/qxcbconnection.h
@@ -43,6 +43,7 @@
#include <xcb/xcb.h>
#include <xcb/randr.h>
+#include <QtCore/QTimer>
#include <QtGui/private/qtguiglobal_p.h>
#include "qxcbexport.h"
#include <QHash>
@@ -183,9 +184,6 @@ public:
QXcbWindowEventListener *windowEventListenerFromId(xcb_window_t id);
QXcbWindow *platformWindowFromId(xcb_window_t id);
- typedef bool (*PeekFunc)(QXcbConnection *, xcb_generic_event_t *);
- void addPeekFunc(PeekFunc f);
-
inline xcb_timestamp_t time() const { return m_time; }
inline void setTime(xcb_timestamp_t t) { if (t > m_time) m_time = t; }
@@ -247,6 +245,8 @@ public:
void flush() { xcb_flush(xcb_connection()); }
void processXcbEvents(QEventLoop::ProcessEventsFlags flags);
+ QTimer &focusInTimer() { return m_focusInTimer; }
+
protected:
bool event(QEvent *e) override;
@@ -364,8 +364,6 @@ private:
WindowMapper m_mapper;
- QVector<PeekFunc> m_peekFuncs;
-
Qt::MouseButtons m_buttonState = 0;
Qt::MouseButton m_button = Qt::NoButton;
@@ -386,6 +384,8 @@ private:
friend class QXcbEventQueue;
QByteArray m_xdgCurrentDesktop;
+ QTimer m_focusInTimer;
+
};
#if QT_CONFIG(xcb_xinput)
#if QT_CONFIG(tabletevent)
diff --git a/src/plugins/platforms/xcb/qxcbconnection_basic.cpp b/src/plugins/platforms/xcb/qxcbconnection_basic.cpp
index af72285135..9a028e5a7e 100644
--- a/src/plugins/platforms/xcb/qxcbconnection_basic.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection_basic.cpp
@@ -134,6 +134,7 @@ QXcbBasicConnection::QXcbBasicConnection(const char *displayName)
m_setup = xcb_get_setup(m_xcbConnection);
m_xcbAtom.initialize(m_xcbConnection);
+ m_maximumRequestLength = xcb_get_maximum_request_length(m_xcbConnection);
xcb_extension_t *extensions[] = {
&xcb_shm_id, &xcb_xfixes_id, &xcb_randr_id, &xcb_shape_id, &xcb_sync_id,
@@ -178,6 +179,14 @@ QXcbBasicConnection::~QXcbBasicConnection()
}
}
+size_t QXcbBasicConnection::maxRequestDataBytes(size_t requestSize) const
+{
+ if (hasBigRequest())
+ requestSize += 4; // big-request encoding adds 4 bytes
+
+ return m_maximumRequestLength * 4 - requestSize;
+}
+
xcb_atom_t QXcbBasicConnection::internAtom(const char *name)
{
if (!name || *name == 0)
@@ -199,6 +208,11 @@ QByteArray QXcbBasicConnection::atomName(xcb_atom_t atom)
return QByteArray();
}
+bool QXcbBasicConnection::hasBigRequest() const
+{
+ return m_maximumRequestLength > m_setup->maximum_request_length;
+}
+
#if QT_CONFIG(xcb_xinput)
// Starting from the xcb version 1.9.3 struct xcb_ge_event_t has changed:
// - "pad0" became "extension"
diff --git a/src/plugins/platforms/xcb/qxcbconnection_basic.h b/src/plugins/platforms/xcb/qxcbconnection_basic.h
index ca91f7fa45..3691763398 100644
--- a/src/plugins/platforms/xcb/qxcbconnection_basic.h
+++ b/src/plugins/platforms/xcb/qxcbconnection_basic.h
@@ -73,6 +73,8 @@ public:
}
const xcb_setup_t *setup() const { return m_setup; }
+ size_t maxRequestDataBytes(size_t requestSize) const;
+
inline xcb_atom_t atom(QXcbAtom::Atom qatom) const { return m_xcbAtom.atom(qatom); }
QXcbAtom::Atom qatom(xcb_atom_t atom) const { return m_xcbAtom.qatom(atom); }
xcb_atom_t internAtom(const char *name);
@@ -94,6 +96,7 @@ public:
bool hasShmFd() const { return m_hasShmFd; }
bool hasXSync() const { return m_hasXSync; }
bool hasXinerama() const { return m_hasXinerama; }
+ bool hasBigRequest() const;
#if QT_CONFIG(xcb_xinput)
bool isAtLeastXI21() const { return m_xi2Enabled && m_xi2Minor >= 1; }
@@ -152,6 +155,8 @@ private:
uint32_t m_xfixesFirstEvent = 0;
uint32_t m_xrandrFirstEvent = 0;
uint32_t m_xkbFirstEvent = 0;
+
+ uint32_t m_maximumRequestLength = 0;
};
#define Q_XCB_REPLY_CONNECTION_ARG(connection, ...) connection
diff --git a/src/plugins/platforms/xcb/qxcbconnection_screens.cpp b/src/plugins/platforms/xcb/qxcbconnection_screens.cpp
index 9aba996bb9..4bafe83156 100644
--- a/src/plugins/platforms/xcb/qxcbconnection_screens.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection_screens.cpp
@@ -208,7 +208,7 @@ void QXcbConnection::updateScreen(QXcbScreen *screen, const xcb_randr_output_cha
const int idx = m_screens.indexOf(screen);
if (idx > 0) {
qAsConst(m_screens).first()->setPrimary(false);
- m_screens.swap(0, idx);
+ m_screens.swapItemsAt(0, idx);
}
screen->virtualDesktop()->setPrimaryScreen(screen);
QXcbIntegration::instance()->setPrimaryScreen(screen);
@@ -260,7 +260,7 @@ void QXcbConnection::destroyScreen(QXcbScreen *screen)
newPrimary->setPrimary(true);
const int idx = m_screens.indexOf(newPrimary);
if (idx > 0)
- m_screens.swap(0, idx);
+ m_screens.swapItemsAt(0, idx);
QXcbIntegration::instance()->setPrimaryScreen(newPrimary);
}
diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
index 04ddd3c98c..78ef7760af 100644
--- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
@@ -637,7 +637,7 @@ void QXcbConnection::xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindo
qreal nx = -1.0, ny = -1.0;
qreal w = 0.0, h = 0.0;
bool majorAxisIsY = touchPoint.area.height() > touchPoint.area.width();
- for (const TouchDeviceData::ValuatorClassInfo vci : dev->valuatorInfo) {
+ for (const TouchDeviceData::ValuatorClassInfo &vci : qAsConst(dev->valuatorInfo)) {
double value;
if (!xi2GetValuatorValueIfSet(xiDeviceEvent, vci.number, &value))
continue;
@@ -823,7 +823,7 @@ bool QXcbConnection::xi2SetMouseGrabEnabled(xcb_window_t w, bool grab)
| XCB_INPUT_XI_EVENT_MASK_TOUCH_UPDATE
| XCB_INPUT_XI_EVENT_MASK_TOUCH_END;
- for (int id : m_xiMasterPointerIds) {
+ for (int id : qAsConst(m_xiMasterPointerIds)) {
xcb_generic_error_t *error = nullptr;
auto cookie = xcb_input_xi_grab_device(xcb_connection(), w, XCB_CURRENT_TIME, XCB_CURSOR_NONE, id,
XCB_INPUT_GRAB_MODE_22_ASYNC, XCB_INPUT_GRAB_MODE_22_ASYNC,
@@ -841,7 +841,7 @@ bool QXcbConnection::xi2SetMouseGrabEnabled(xcb_window_t w, bool grab)
free(reply);
}
} else { // ungrab
- for (int id : m_xiMasterPointerIds) {
+ for (int id : qAsConst(m_xiMasterPointerIds)) {
auto cookie = xcb_input_xi_ungrab_device_checked(xcb_connection(), XCB_CURRENT_TIME, id);
xcb_generic_error_t *error = xcb_request_check(xcb_connection(), cookie);
if (error) {
diff --git a/src/plugins/platforms/xcb/qxcbeventqueue.cpp b/src/plugins/platforms/xcb/qxcbeventqueue.cpp
index acec0486c2..82a36c0727 100644
--- a/src/plugins/platforms/xcb/qxcbeventqueue.cpp
+++ b/src/plugins/platforms/xcb/qxcbeventqueue.cpp
@@ -262,7 +262,7 @@ qint32 QXcbEventQueue::generatePeekerId()
bool QXcbEventQueue::removePeekerId(qint32 peekerId)
{
- const auto it = m_peekerToNode.find(peekerId);
+ const auto it = m_peekerToNode.constFind(peekerId);
if (it == m_peekerToNode.constEnd()) {
qCWarning(lcQpaXcb, "failed to remove unknown peeker id: %d", peekerId);
return false;
@@ -281,7 +281,7 @@ bool QXcbEventQueue::peekEventQueue(PeekerCallback peeker, void *peekerData,
const bool peekerIdProvided = peekerId != -1;
auto peekerToNodeIt = m_peekerToNode.find(peekerId);
- if (peekerIdProvided && peekerToNodeIt == m_peekerToNode.constEnd()) {
+ if (peekerIdProvided && peekerToNodeIt == m_peekerToNode.end()) {
qCWarning(lcQpaXcb, "failed to find index for unknown peeker id: %d", peekerId);
return false;
}
@@ -341,7 +341,7 @@ bool QXcbEventQueue::peekEventQueue(PeekerCallback peeker, void *peekerData,
// Before updating, make sure that a peeker callback did not remove
// the peeker id.
peekerToNodeIt = m_peekerToNode.find(peekerId);
- if (peekerToNodeIt != m_peekerToNode.constEnd())
+ if (peekerToNodeIt != m_peekerToNode.end())
*peekerToNodeIt = node; // id still in the cache, update node
}
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
index 524af5a2a7..4d526a6bda 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
@@ -304,7 +304,7 @@ QPlatformNativeInterface::NativeResourceForWindowFunction QXcbNativeInterface::n
QPlatformNativeInterface::NativeResourceForBackingStoreFunction QXcbNativeInterface::nativeResourceFunctionForBackingStore(const QByteArray &resource)
{
const QByteArray lowerCaseResource = resource.toLower();
- NativeResourceForBackingStoreFunction func = handlerNativeResourceFunctionForBackingStore(resource);
+ NativeResourceForBackingStoreFunction func = handlerNativeResourceFunctionForBackingStore(lowerCaseResource);
return func;
}
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp
index 57dbdc9bec..0fa0e8cd7b 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.cpp
+++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
@@ -147,7 +147,7 @@ void QXcbVirtualDesktop::setPrimaryScreen(QPlatformScreen *s)
{
const int idx = m_screens.indexOf(s);
Q_ASSERT(idx > -1);
- m_screens.swap(0, idx);
+ m_screens.swapItemsAt(0, idx);
}
QXcbXSettings *QXcbVirtualDesktop::xSettings() const
diff --git a/src/plugins/platforms/xcb/qxcbsessionmanager.h b/src/plugins/platforms/xcb/qxcbsessionmanager.h
index 0ad9445361..79c587b38d 100644
--- a/src/plugins/platforms/xcb/qxcbsessionmanager.h
+++ b/src/plugins/platforms/xcb/qxcbsessionmanager.h
@@ -85,8 +85,6 @@ public:
private:
QEventLoop *m_eventLoop;
-
- Q_DISABLE_COPY(QXcbSessionManager)
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index 3bfcbf2adb..9382488b74 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -843,40 +843,12 @@ void QXcbWindow::doFocusIn()
QWindowSystemInterface::handleWindowActivated(w, Qt::ActiveWindowFocusReason);
}
-static bool focusInPeeker(QXcbConnection *connection, xcb_generic_event_t *event)
-{
- if (!event) {
- // FocusIn event is not in the queue, proceed with FocusOut normally.
- QWindowSystemInterface::handleWindowActivated(nullptr, Qt::ActiveWindowFocusReason);
- return true;
- }
- uint response_type = event->response_type & ~0x80;
- if (response_type == XCB_FOCUS_IN) {
- // Ignore focus events that are being sent only because the pointer is over
- // our window, even if the input focus is in a different window.
- xcb_focus_in_event_t *e = (xcb_focus_in_event_t *) event;
- if (e->detail != XCB_NOTIFY_DETAIL_POINTER)
- return true;
- }
-
- /* We are also interested in XEMBED_FOCUS_IN events */
- if (response_type == XCB_CLIENT_MESSAGE) {
- xcb_client_message_event_t *cme = (xcb_client_message_event_t *)event;
- if (cme->type == connection->atom(QXcbAtom::_XEMBED)
- && cme->data.data32[1] == XEMBED_FOCUS_IN)
- return true;
- }
-
- return false;
-}
-
void QXcbWindow::doFocusOut()
{
connection()->setFocusWindow(nullptr);
relayFocusToModalWindow();
// Do not set the active window to nullptr if there is a FocusIn coming.
- // The FocusIn handler will update QXcbConnection::setFocusWindow() accordingly.
- connection()->addPeekFunc(focusInPeeker);
+ connection()->focusInTimer().start(400);
}
struct QtMotifWmHints {
@@ -2264,6 +2236,8 @@ void QXcbWindow::handleFocusInEvent(const xcb_focus_in_event_t *event)
// our window, even if the input focus is in a different window.
if (event->detail == XCB_NOTIFY_DETAIL_POINTER)
return;
+
+ connection()->focusInTimer().stop();
doFocusIn();
}
@@ -2491,6 +2465,7 @@ void QXcbWindow::handleXEmbedMessage(const xcb_client_message_event_t *event)
xcbScreen()->windowShown(this);
break;
case XEMBED_FOCUS_IN:
+ connection()->focusInTimer().stop();
Qt::FocusReason reason;
switch (event->data.data32[2]) {
case XEMBED_FOCUS_FIRST:
diff --git a/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.h b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.h
index 4c5f474595..3497c6a6f1 100644
--- a/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.h
+++ b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.h
@@ -84,7 +84,7 @@ public:
private:
QScopedPointer<QXdgDesktopPortalThemePrivate> d_ptr;
- Q_DISABLE_COPY(QXdgDesktopPortalTheme)
+ Q_DISABLE_COPY_MOVE(QXdgDesktopPortalTheme)
};
QT_END_NAMESPACE
diff --git a/src/plugins/printsupport/cups/qcupsprintengine_p.h b/src/plugins/printsupport/cups/qcupsprintengine_p.h
index 2a1a83b9d7..c021b0c643 100644
--- a/src/plugins/printsupport/cups/qcupsprintengine_p.h
+++ b/src/plugins/printsupport/cups/qcupsprintengine_p.h
@@ -77,7 +77,7 @@ public:
// end reimplementations QPdfPrintEngine
private:
- Q_DISABLE_COPY(QCupsPrintEngine)
+ Q_DISABLE_COPY_MOVE(QCupsPrintEngine)
};
class QCupsPrintEnginePrivate : public QPdfPrintEnginePrivate
@@ -91,7 +91,7 @@ public:
void closePrintDevice() override;
private:
- Q_DISABLE_COPY(QCupsPrintEnginePrivate)
+ Q_DISABLE_COPY_MOVE(QCupsPrintEnginePrivate)
void changePrinter(const QString &newPrinter);
void setPageSize(const QPageSize &pageSize);
diff --git a/src/plugins/printsupport/windows/qwindowsprintersupport.h b/src/plugins/printsupport/windows/qwindowsprintersupport.h
index 4267701145..400701628e 100644
--- a/src/plugins/printsupport/windows/qwindowsprintersupport.h
+++ b/src/plugins/printsupport/windows/qwindowsprintersupport.h
@@ -46,7 +46,7 @@ QT_BEGIN_NAMESPACE
class QWindowsPrinterSupport : public QPlatformPrinterSupport
{
- Q_DISABLE_COPY(QWindowsPrinterSupport)
+ Q_DISABLE_COPY_MOVE(QWindowsPrinterSupport)
public:
QWindowsPrinterSupport();
~QWindowsPrinterSupport() override;
diff --git a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
index f2ae3fbc47..febbe58506 100644
--- a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+++ b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
@@ -197,6 +197,7 @@ protected:
QSqlRecord record() const override;
void virtual_hook(int id, void *data) override;
bool nextResult() override;
+ void detachFromResultSet() override;
#if MYSQL_VERSION_ID >= 40108
bool prepare(const QString &stmt) override;
@@ -804,6 +805,15 @@ int QMYSQLResult::numRowsAffected()
return d->rowsAffected;
}
+void QMYSQLResult::detachFromResultSet()
+{
+ Q_D(QMYSQLResult);
+
+ if (d->preparedQuery) {
+ mysql_stmt_free_result(d->stmt);
+ }
+}
+
QVariant QMYSQLResult::lastInsertId() const
{
Q_D(const QMYSQLResult);
@@ -1541,7 +1551,7 @@ QSqlIndex QMYSQLDriver::primaryIndex(const QString& tablename) const
QSqlQuery i(createResult());
QString stmt(QLatin1String("show index from %1;"));
QSqlRecord fil = record(tablename);
- i.exec(stmt.arg(tablename));
+ i.exec(stmt.arg(escapeIdentifier(tablename, QSqlDriver::TableName)));
while (i.isActive() && i.next()) {
if (i.value(2).toString() == QLatin1String("PRIMARY")) {
idx.append(fil.field(i.value(4).toString()));
diff --git a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
index 1fbbcd0ef1..7f98efccba 100644
--- a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
+++ b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
@@ -345,7 +345,7 @@ static QSqlError qMakeError(const QString& err, QSqlError::ErrorType type,
{
int nativeCode = -1;
QString message = qODBCWarn(p, &nativeCode);
- return QSqlError(QLatin1String("QODBC3: ") + err, qODBCWarn(p), type,
+ return QSqlError(QLatin1String("QODBC3: ") + err, message, type,
nativeCode != -1 ? QString::number(nativeCode) : QString());
}
diff --git a/src/plugins/sqldrivers/psql/main.cpp b/src/plugins/sqldrivers/psql/main.cpp
index c5d546f6ff..a0862a238a 100644
--- a/src/plugins/sqldrivers/psql/main.cpp
+++ b/src/plugins/sqldrivers/psql/main.cpp
@@ -61,11 +61,9 @@ QPSQLDriverPlugin::QPSQLDriverPlugin()
QSqlDriver* QPSQLDriverPlugin::create(const QString &name)
{
- if (name == QLatin1String("QPSQL") || name == QLatin1String("QPSQL7")) {
- QPSQLDriver* driver = new QPSQLDriver();
- return driver;
- }
- return 0;
+ if (name == QLatin1String("QPSQL") || name == QLatin1String("QPSQL7"))
+ return new QPSQLDriver;
+ return nullptr;
}
QT_END_NAMESPACE
diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp
index 7ad9db1ea8..49b793ce38 100644
--- a/src/plugins/sqldrivers/psql/qsql_psql.cpp
+++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp
@@ -42,7 +42,7 @@
#include <qcoreapplication.h>
#include <qvariant.h>
#include <qdatetime.h>
-#include <qregexp.h>
+#include <qregularexpression.h>
#include <qsqlerror.h>
#include <qsqlfield.h>
#include <qsqlindex.h>
@@ -54,6 +54,8 @@
#include <QtSql/private/qsqlresult_p.h>
#include <QtSql/private/qsqldriver_p.h>
+#include <queue>
+
#include <libpq-fe.h>
#include <pg_config.h>
@@ -147,10 +149,10 @@ class QPSQLDriverPrivate final : public QSqlDriverPrivate
Q_DECLARE_PUBLIC(QPSQLDriver)
public:
QPSQLDriverPrivate() : QSqlDriverPrivate(),
- connection(0),
+ connection(nullptr),
isUtf8(false),
pro(QPSQLDriver::Version6),
- sn(0),
+ sn(nullptr),
pendingNotifyCheck(false),
hasBackslashEscape(false),
stmtCount(0),
@@ -187,11 +189,13 @@ public:
void QPSQLDriverPrivate::appendTables(QStringList &tl, QSqlQuery &t, QChar type)
{
- QString query = QString::fromLatin1("select pg_class.relname, pg_namespace.nspname from pg_class "
- "left join pg_namespace on (pg_class.relnamespace = pg_namespace.oid) "
- "where (pg_class.relkind = '%1') and (pg_class.relname !~ '^Inv') "
- "and (pg_class.relname !~ '^pg_') "
- "and (pg_namespace.nspname != 'information_schema')").arg(type);
+ const QString query =
+ QStringLiteral("SELECT pg_class.relname, pg_namespace.nspname FROM pg_class "
+ "LEFT JOIN pg_namespace ON (pg_class.relnamespace = pg_namespace.oid) "
+ "WHERE (pg_class.relkind = '") + type +
+ QStringLiteral("') AND (pg_class.relname !~ '^Inv') "
+ "AND (pg_class.relname !~ '^pg_') "
+ "AND (pg_namespace.nspname != 'information_schema')");
t.exec(query);
while (t.next()) {
QString schema = t.value(1).toString();
@@ -294,10 +298,10 @@ public:
Q_DECLARE_SQLDRIVER_PRIVATE(QPSQLDriver)
QPSQLResultPrivate(QPSQLResult *q, const QPSQLDriver *drv)
: QSqlResultPrivate(q, drv),
- result(0),
+ result(nullptr),
+ stmtId(InvalidStatementId),
currentSize(-1),
canFetchMoreRows(false),
- stmtId(InvalidStatementId),
preparedQueriesEnabled(false)
{ }
@@ -305,12 +309,12 @@ public:
void deallocatePreparedStmt();
PGresult *result;
- QList<PGresult*> nextResultSets;
+ std::queue<PGresult*> nextResultSets;
+ QString preparedStmtId;
+ StatementId stmtId;
int currentSize;
bool canFetchMoreRows;
- StatementId stmtId;
bool preparedQueriesEnabled;
- QString preparedStmtId;
bool processResults();
};
@@ -423,7 +427,7 @@ static QVariant::Type qDecodePSQLType(int t)
void QPSQLResultPrivate::deallocatePreparedStmt()
{
- const QString stmt = QLatin1String("DEALLOCATE ") + preparedStmtId;
+ const QString stmt = QStringLiteral("DEALLOCATE ") + preparedStmtId;
PGresult *result = drv_d_func()->exec(stmt);
if (PQresultStatus(result) != PGRES_COMMAND_OK)
@@ -460,8 +464,10 @@ void QPSQLResult::cleanup()
if (d->result)
PQclear(d->result);
d->result = nullptr;
- while (!d->nextResultSets.isEmpty())
- PQclear(d->nextResultSets.takeFirst());
+ while (!d->nextResultSets.empty()) {
+ PQclear(d->nextResultSets.front());
+ d->nextResultSets.pop();
+ }
if (d->stmtId != InvalidStatementId) {
if (d->drv_d_func())
d->drv_d_func()->finishQuery(d->stmtId);
@@ -622,7 +628,11 @@ bool QPSQLResult::nextResult()
if (d->result)
PQclear(d->result);
- d->result = d->nextResultSets.isEmpty() ? nullptr : d->nextResultSets.takeFirst();
+ d->result = nullptr;
+ if (!d->nextResultSets.empty()) {
+ d->result = d->nextResultSets.front();
+ d->nextResultSets.pop();
+ }
return d->processResults();
}
@@ -646,9 +656,9 @@ QVariant QPSQLResult::data(int i)
return d->drv_d_func()->isUtf8 ? QString::fromUtf8(val) : QString::fromLatin1(val);
case QVariant::LongLong:
if (val[0] == '-')
- return QString::fromLatin1(val).toLongLong();
+ return QByteArray::fromRawData(val, qstrlen(val)).toLongLong();
else
- return QString::fromLatin1(val).toULongLong();
+ return QByteArray::fromRawData(val, qstrlen(val)).toULongLong();
case QVariant::Int:
return atoi(val);
case QVariant::Double: {
@@ -754,7 +764,7 @@ bool QPSQLResult::reset (const QString& query)
if (!isForwardOnly()) {
// Fetch all result sets right away
while (PGresult *nextResultSet = d->drv_d_func()->getResult(d->stmtId))
- d->nextResultSets.append(nextResultSet);
+ d->nextResultSets.push(nextResultSet);
}
return d->processResults();
}
@@ -768,7 +778,8 @@ int QPSQLResult::size()
int QPSQLResult::numRowsAffected()
{
Q_D(const QPSQLResult);
- return QString::fromLatin1(PQcmdTuples(d->result)).toInt();
+ const char *tuples = PQcmdTuples(d->result);
+ return QByteArray::fromRawData(tuples, qstrlen(tuples)).toInt();
}
QVariant QPSQLResult::lastInsertId() const
@@ -777,7 +788,7 @@ QVariant QPSQLResult::lastInsertId() const
if (d->drv_d_func()->pro >= QPSQLDriver::Version8_1) {
QSqlQuery qry(driver()->createResult());
// Most recent sequence value obtained from nextval
- if (qry.exec(QLatin1String("SELECT lastval();")) && qry.next())
+ if (qry.exec(QStringLiteral("SELECT lastval();")) && qry.next())
return qry.value(0);
} else if (isActive()) {
Oid id = PQoidValue(d->result);
@@ -868,15 +879,13 @@ static QString qCreateParamString(const QVector<QVariant> &boundValues, const QS
QString params;
QSqlField f;
- for (int i = 0; i < boundValues.count(); ++i) {
- const QVariant &val = boundValues.at(i);
-
+ for (const QVariant &val : boundValues) {
f.setType(val.type());
if (val.isNull())
f.clear();
else
f.setValue(val);
- if(!params.isNull())
+ if (!params.isNull())
params.append(QLatin1String(", "));
params.append(driver->formatValue(f));
}
@@ -886,7 +895,7 @@ static QString qCreateParamString(const QVector<QVariant> &boundValues, const QS
QString qMakePreparedStmtId()
{
static QBasicAtomicInt qPreparedStmtCount = Q_BASIC_ATOMIC_INITIALIZER(0);
- QString id = QLatin1String("qpsqlpstmt_") + QString::number(qPreparedStmtCount.fetchAndAddRelaxed(1) + 1, 16);
+ QString id = QStringLiteral("qpsqlpstmt_") + QString::number(qPreparedStmtCount.fetchAndAddRelaxed(1) + 1, 16);
return id;
}
@@ -902,7 +911,7 @@ bool QPSQLResult::prepare(const QString &query)
d->deallocatePreparedStmt();
const QString stmtId = qMakePreparedStmtId();
- const QString stmt = QString::fromLatin1("PREPARE %1 AS ").arg(stmtId).append(d->positionalToNamedBinding(query));
+ const QString stmt = QStringLiteral("PREPARE %1 AS ").arg(stmtId).append(d->positionalToNamedBinding(query));
PGresult *result = d->drv_d_func()->exec(stmt);
@@ -930,9 +939,9 @@ bool QPSQLResult::exec()
QString stmt;
const QString params = qCreateParamString(boundValues(), driver());
if (params.isEmpty())
- stmt = QString::fromLatin1("EXECUTE %1").arg(d->preparedStmtId);
+ stmt = QStringLiteral("EXECUTE %1").arg(d->preparedStmtId);
else
- stmt = QString::fromLatin1("EXECUTE %1 (%2)").arg(d->preparedStmtId, params);
+ stmt = QStringLiteral("EXECUTE %1 (%2)").arg(d->preparedStmtId, params);
d->stmtId = d->drv_d_func()->sendQuery(stmt);
if (d->stmtId == InvalidStatementId) {
@@ -948,7 +957,7 @@ bool QPSQLResult::exec()
if (!isForwardOnly()) {
// Fetch all result sets right away
while (PGresult *nextResultSet = d->drv_d_func()->getResult(d->stmtId))
- d->nextResultSets.append(nextResultSet);
+ d->nextResultSets.push(nextResultSet);
}
return d->processResults();
}
@@ -994,7 +1003,7 @@ void QPSQLDriverPrivate::detectBackslashEscape()
hasBackslashEscape = true;
} else {
hasBackslashEscape = false;
- PGresult* result = exec(QLatin1String("SELECT '\\\\' x"));
+ PGresult* result = exec(QStringLiteral("SELECT '\\\\' x"));
int status = PQresultStatus(result);
if (status == PGRES_COMMAND_OK || status == PGRES_TUPLES_OK)
if (QString::fromLatin1(PQgetvalue(result, 0, 0)) == QLatin1String("\\"))
@@ -1072,20 +1081,21 @@ static QPSQLDriver::Protocol qMakePSQLVersion(int vMaj, int vMin)
static QPSQLDriver::Protocol qFindPSQLVersion(const QString &versionString)
{
- const QRegExp rx(QStringLiteral("(\\d+)(?:\\.(\\d+))?"));
- if (rx.indexIn(versionString) != -1) {
+ const QRegularExpression rx(QStringLiteral("(\\d+)(?:\\.(\\d+))?"));
+ const QRegularExpressionMatch match = rx.match(versionString);
+ if (match.hasMatch()) {
// Beginning with PostgreSQL version 10, a major release is indicated by
// increasing the first part of the version, e.g. 10 to 11.
// Before version 10, a major release was indicated by increasing either
// the first or second part of the version number, e.g. 9.5 to 9.6.
- int vMaj = rx.cap(1).toInt();
+ int vMaj = match.capturedRef(1).toInt();
int vMin;
if (vMaj >= 10) {
vMin = 0;
} else {
- if (rx.cap(2).isEmpty())
+ if (match.capturedRef(2).isEmpty())
return QPSQLDriver::VersionUnknown;
- vMin = rx.cap(2).toInt();
+ vMin = match.capturedRef(2).toInt();
}
return qMakePSQLVersion(vMaj, vMin);
}
@@ -1096,7 +1106,7 @@ static QPSQLDriver::Protocol qFindPSQLVersion(const QString &versionString)
QPSQLDriver::Protocol QPSQLDriverPrivate::getPSQLVersion()
{
QPSQLDriver::Protocol serverVersion = QPSQLDriver::Version6;
- PGresult* result = exec("select version()");
+ PGresult* result = exec("SELECT version()");
int status = PQresultStatus(result);
if (status == PGRES_COMMAND_OK || status == PGRES_TUPLES_OK) {
serverVersion = qFindPSQLVersion(
@@ -1355,8 +1365,8 @@ QStringList QPSQLDriver::tables(QSql::TableType type) const
if (type & QSql::Views)
const_cast<QPSQLDriverPrivate*>(d)->appendTables(tl, t, QLatin1Char('v'));
if (type & QSql::SystemTables) {
- t.exec(QLatin1String("select relname from pg_class where (relkind = 'r') "
- "and (relname like 'pg_%') "));
+ t.exec(QStringLiteral("SELECT relname FROM pg_class WHERE (relkind = 'r') "
+ "AND (relname LIKE 'pg_%') "));
while (t.next())
tl.append(t.value(0).toString());
}
@@ -1383,31 +1393,23 @@ QSqlIndex QPSQLDriver::primaryIndex(const QString& tablename) const
QString tbl = tablename;
QString schema;
qSplitTableName(tbl, schema);
-
- if (isIdentifierEscaped(tbl, QSqlDriver::TableName))
- tbl = stripDelimiters(tbl, QSqlDriver::TableName);
- else
- tbl = std::move(tbl).toLower();
-
- if (isIdentifierEscaped(schema, QSqlDriver::TableName))
- schema = stripDelimiters(schema, QSqlDriver::TableName);
- else
- schema = std::move(schema).toLower();
-
- QString stmt = QLatin1String("SELECT pg_attribute.attname, pg_attribute.atttypid::int, "
- "pg_class.relname "
- "FROM pg_attribute, pg_class "
- "WHERE %1 pg_class.oid IN "
- "(SELECT indexrelid FROM pg_index WHERE indisprimary = true AND indrelid IN "
- "(SELECT oid FROM pg_class WHERE relname = '%2')) "
- "AND pg_attribute.attrelid = pg_class.oid "
- "AND pg_attribute.attisdropped = false "
- "ORDER BY pg_attribute.attnum");
+ schema = stripDelimiters(schema, QSqlDriver::TableName);
+ tbl = stripDelimiters(tbl, QSqlDriver::TableName);
+
+ QString stmt = QStringLiteral("SELECT pg_attribute.attname, pg_attribute.atttypid::int, "
+ "pg_class.relname "
+ "FROM pg_attribute, pg_class "
+ "WHERE %1 pg_class.oid IN "
+ "(SELECT indexrelid FROM pg_index WHERE indisprimary = true AND indrelid IN "
+ "(SELECT oid FROM pg_class WHERE relname = '%2')) "
+ "AND pg_attribute.attrelid = pg_class.oid "
+ "AND pg_attribute.attisdropped = false "
+ "ORDER BY pg_attribute.attnum");
if (schema.isEmpty())
- stmt = stmt.arg(QLatin1String("pg_table_is_visible(pg_class.oid) AND"));
+ stmt = stmt.arg(QStringLiteral("pg_table_is_visible(pg_class.oid) AND"));
else
- stmt = stmt.arg(QString::fromLatin1("pg_class.relnamespace = (select oid from "
- "pg_namespace where pg_namespace.nspname = '%1') AND").arg(schema));
+ stmt = stmt.arg(QStringLiteral("pg_class.relnamespace = (SELECT oid FROM "
+ "pg_namespace WHERE pg_namespace.nspname = '%1') AND").arg(schema));
i.exec(stmt.arg(tbl));
while (i.isActive() && i.next()) {
@@ -1427,34 +1429,26 @@ QSqlRecord QPSQLDriver::record(const QString& tablename) const
QString tbl = tablename;
QString schema;
qSplitTableName(tbl, schema);
-
- if (isIdentifierEscaped(tbl, QSqlDriver::TableName))
- tbl = stripDelimiters(tbl, QSqlDriver::TableName);
- else
- tbl = std::move(tbl).toLower();
-
- if (isIdentifierEscaped(schema, QSqlDriver::TableName))
- schema = stripDelimiters(schema, QSqlDriver::TableName);
- else
- schema = std::move(schema).toLower();
-
- QString stmt = QLatin1String("select pg_attribute.attname, pg_attribute.atttypid::int, "
- "pg_attribute.attnotnull, pg_attribute.attlen, pg_attribute.atttypmod, "
- "pg_attrdef.adsrc "
- "from pg_class, pg_attribute "
- "left join pg_attrdef on (pg_attrdef.adrelid = "
- "pg_attribute.attrelid and pg_attrdef.adnum = pg_attribute.attnum) "
- "where %1 "
- "and pg_class.relname = '%2' "
- "and pg_attribute.attnum > 0 "
- "and pg_attribute.attrelid = pg_class.oid "
- "and pg_attribute.attisdropped = false "
- "order by pg_attribute.attnum");
+ schema = stripDelimiters(schema, QSqlDriver::TableName);
+ tbl = stripDelimiters(tbl, QSqlDriver::TableName);
+
+ QString stmt = QStringLiteral("SELECT pg_attribute.attname, pg_attribute.atttypid::int, "
+ "pg_attribute.attnotnull, pg_attribute.attlen, pg_attribute.atttypmod, "
+ "pg_attrdef.adsrc "
+ "FROM pg_class, pg_attribute "
+ "LEFT JOIN pg_attrdef ON (pg_attrdef.adrelid = "
+ "pg_attribute.attrelid AND pg_attrdef.adnum = pg_attribute.attnum) "
+ "WHERE %1 "
+ "AND pg_class.relname = '%2' "
+ "AND pg_attribute.attnum > 0 "
+ "AND pg_attribute.attrelid = pg_class.oid "
+ "AND pg_attribute.attisdropped = false "
+ "ORDER BY pg_attribute.attnum");
if (schema.isEmpty())
- stmt = stmt.arg(QLatin1String("pg_table_is_visible(pg_class.oid)"));
+ stmt = stmt.arg(QStringLiteral("pg_table_is_visible(pg_class.oid)"));
else
- stmt = stmt.arg(QString::fromLatin1("pg_class.relnamespace = (select oid from "
- "pg_namespace where pg_namespace.nspname = '%1')").arg(schema));
+ stmt = stmt.arg(QStringLiteral("pg_class.relnamespace = (SELECT oid FROM "
+ "pg_namespace WHERE pg_namespace.nspname = '%1')").arg(schema));
QSqlQuery query(createResult());
query.exec(stmt.arg(tbl));
@@ -1496,9 +1490,10 @@ inline void assignSpecialPsqlFloatValue(FloatType val, QString *target)
QString QPSQLDriver::formatValue(const QSqlField &field, bool trimStrings) const
{
Q_D(const QPSQLDriver);
+ const auto nullStr = [](){ return QStringLiteral("NULL"); };
QString r;
if (field.isNull()) {
- r = QLatin1String("NULL");
+ r = nullStr();
} else {
switch (int(field.type())) {
case QVariant::DateTime:
@@ -1507,14 +1502,14 @@ QString QPSQLDriver::formatValue(const QSqlField &field, bool trimStrings) const
// we force the value to be considered with a timezone information, and we force it to be UTC
// this is safe since postgresql stores only the UTC value and not the timezone offset (only used
// while parsing), so we have correct behavior in both case of with timezone and without tz
- r = QLatin1String("TIMESTAMP WITH TIME ZONE ") + QLatin1Char('\'') +
- QLocale::c().toString(field.value().toDateTime().toUTC(), QLatin1String("yyyy-MM-ddThh:mm:ss.zzz")) +
+ r = QStringLiteral("TIMESTAMP WITH TIME ZONE ") + QLatin1Char('\'') +
+ QLocale::c().toString(field.value().toDateTime().toUTC(), QStringLiteral("yyyy-MM-ddThh:mm:ss.zzz")) +
QLatin1Char('Z') + QLatin1Char('\'');
} else {
- r = QLatin1String("NULL");
+ r = nullStr();
}
#else
- r = QLatin1String("NULL");
+ r = nullStr();
#endif // datestring
break;
case QVariant::Time:
@@ -1524,19 +1519,19 @@ QString QPSQLDriver::formatValue(const QSqlField &field, bool trimStrings) const
} else
#endif
{
- r = QLatin1String("NULL");
+ r = nullStr();
}
break;
case QVariant::String:
r = QSqlDriver::formatValue(field, trimStrings);
if (d->hasBackslashEscape)
- r.replace(QLatin1String("\\"), QLatin1String("\\\\"));
+ r.replace(QLatin1Char('\\'), QLatin1String("\\\\"));
break;
case QVariant::Bool:
if (field.value().toBool())
- r = QLatin1String("TRUE");
+ r = QStringLiteral("TRUE");
else
- r = QLatin1String("FALSE");
+ r = QStringLiteral("FALSE");
break;
case QVariant::ByteArray: {
QByteArray ba(field.value().toByteArray());
@@ -1615,7 +1610,7 @@ bool QPSQLDriver::subscribeToNotification(const QString &name)
// Add the name to the list of subscriptions here so that QSQLDriverPrivate::exec knows
// to check for notifications immediately after executing the LISTEN
d->seid << name;
- QString query = QLatin1String("LISTEN ") + escapeIdentifier(name, QSqlDriver::TableName);
+ QString query = QStringLiteral("LISTEN ") + escapeIdentifier(name, QSqlDriver::TableName);
PGresult *result = d->exec(query);
if (PQresultStatus(result) != PGRES_COMMAND_OK) {
d->seid.removeLast();
@@ -1651,7 +1646,7 @@ bool QPSQLDriver::unsubscribeFromNotification(const QString &name)
return false;
}
- QString query = QLatin1String("UNLISTEN ") + escapeIdentifier(name, QSqlDriver::TableName);
+ QString query = QStringLiteral("UNLISTEN ") + escapeIdentifier(name, QSqlDriver::TableName);
PGresult *result = d->exec(query);
if (PQresultStatus(result) != PGRES_COMMAND_OK) {
setLastError(qMakeError(tr("Unable to unsubscribe"), QSqlError::StatementError, d, result));
diff --git a/src/plugins/sqldrivers/psql/qsql_psql_p.h b/src/plugins/sqldrivers/psql/qsql_psql_p.h
index 7e1849d857..4f372346c6 100644
--- a/src/plugins/sqldrivers/psql/qsql_psql_p.h
+++ b/src/plugins/sqldrivers/psql/qsql_psql_p.h
@@ -96,8 +96,8 @@ public:
UnknownLaterVersion = 100000
};
- explicit QPSQLDriver(QObject *parent=0);
- explicit QPSQLDriver(PGconn *conn, QObject *parent=0);
+ explicit QPSQLDriver(QObject *parent = nullptr);
+ explicit QPSQLDriver(PGconn *conn, QObject *parent = nullptr);
~QPSQLDriver();
bool hasFeature(DriverFeature f) const override;
bool open(const QString & db,
diff --git a/src/plugins/styles/android/qandroidstyle_p.h b/src/plugins/styles/android/qandroidstyle_p.h
index 3faa08afb9..6cb30a2f79 100644
--- a/src/plugins/styles/android/qandroidstyle_p.h
+++ b/src/plugins/styles/android/qandroidstyle_p.h
@@ -371,7 +371,7 @@ public:
void unpolish(QWidget *widget);
private:
- Q_DISABLE_COPY(QAndroidStyle)
+ Q_DISABLE_COPY_MOVE(QAndroidStyle)
static ItemType qtControl(QStyle::ComplexControl control);
static ItemType qtControl(QStyle::ContentsType contentsType);
static ItemType qtControl(QStyle::ControlElement controlElement);
diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm
index 13ef98b840..9602340f9d 100644
--- a/src/plugins/styles/mac/qmacstyle_mac.mm
+++ b/src/plugins/styles/mac/qmacstyle_mac.mm
@@ -4004,7 +4004,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
titleRect.width());
const auto text = p->fontMetrics().elidedText(dwOpt->title, Qt::ElideRight, titleRect.width());
- proxy()->drawItemText(p, titleRect, Qt::AlignCenter | Qt::TextShowMnemonic, dwOpt->palette,
+ proxy()->drawItemText(p, titleRect, Qt::AlignCenter, dwOpt->palette,
dwOpt->state & State_Enabled, text, QPalette::WindowText);
}
p->restore();
diff --git a/src/plugins/styles/mac/qmacstyle_mac_p.h b/src/plugins/styles/mac/qmacstyle_mac_p.h
index d6874001d3..88f104cccf 100644
--- a/src/plugins/styles/mac/qmacstyle_mac_p.h
+++ b/src/plugins/styles/mac/qmacstyle_mac_p.h
@@ -115,7 +115,7 @@ public:
const QWidget *widget = 0) const;
private:
- Q_DISABLE_COPY(QMacStyle)
+ Q_DISABLE_COPY_MOVE(QMacStyle)
Q_DECLARE_PRIVATE(QMacStyle)
};
diff --git a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp
index 771552a121..8a3ae17b1d 100644
--- a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp
+++ b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp
@@ -632,7 +632,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
{
QPen pen = painter->pen();
int margin = 3;
- painter->setPen(option->palette.background().color().darker(114));
+ painter->setPen(option->palette.window().color().darker(114));
if (option->state & State_Horizontal) {
int x1 = option->rect.center().x();
painter->drawLine(QPoint(x1, option->rect.top() + margin), QPoint(x1, option->rect.bottom() - margin));
@@ -704,7 +704,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
if (sectionSize.width() > 0 && sectionSize.height() > 0) {
QString key = QString::fromLatin1("qvdelegate-%1-%2-%3-%4-%5").arg(sectionSize.width())
.arg(sectionSize.height()).arg(selected).arg(active).arg(hover);
- if (!QPixmapCache::find(key, pixmap)) {
+ if (!QPixmapCache::find(key, &pixmap)) {
pixmap = QPixmap(sectionSize);
pixmap.fill(Qt::transparent);
@@ -1053,7 +1053,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
}
QString name = QString::fromLatin1("qiprogress-%1-%2").arg(pixmapSize.width()).arg(pixmapSize.height());
QPixmap pixmap;
- if (!QPixmapCache::find(name, pixmap)) {
+ if (!QPixmapCache::find(name, &pixmap)) {
QImage image(pixmapSize, QImage::Format_ARGB32);
image.fill(Qt::transparent);
QPainter imagePainter(&image);
@@ -1363,7 +1363,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
case CE_ToolBar:
if (const QStyleOptionToolBar *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) {
QPalette pal = option->palette;
- pal.setColor(QPalette::Dark, option->palette.background().color().darker(130));
+ pal.setColor(QPalette::Dark, option->palette.window().color().darker(130));
QStyleOptionToolBar copyOpt = *toolbar;
copyOpt.palette = pal;
QWindowsStyle::drawControl(element, &copyOpt, painter, widget);
@@ -1388,8 +1388,8 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
painter->translate(-rect.left() + 1, -rect.top());
}
- painter->setBrush(option->palette.background().color().darker(110));
- painter->setPen(option->palette.background().color().darker(130));
+ painter->setBrush(option->palette.window().color().darker(110));
+ painter->setPen(option->palette.window().color().darker(130));
painter->drawRect(rect.adjusted(0, 1, -1, -3));
int buttonMargin = 4;
diff --git a/src/plugins/styles/windowsvista/qwindowsvistastyle_p.h b/src/plugins/styles/windowsvista/qwindowsvistastyle_p.h
index 0ebb0eb41a..43a2a670f8 100644
--- a/src/plugins/styles/windowsvista/qwindowsvistastyle_p.h
+++ b/src/plugins/styles/windowsvista/qwindowsvistastyle_p.h
@@ -99,7 +99,7 @@ public:
QPalette standardPalette() const override;
private:
- Q_DISABLE_COPY(QWindowsVistaStyle)
+ Q_DISABLE_COPY_MOVE(QWindowsVistaStyle)
Q_DECLARE_PRIVATE(QWindowsVistaStyle)
friend class QStyleFactory;
};
diff --git a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp
index 4b583e13d3..90026e5bf0 100644
--- a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp
+++ b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp
@@ -511,8 +511,8 @@ QRegion QWindowsXPStylePrivate::region(XPThemeData &themeData)
if (numBytes == 0)
return QRegion();
- char *buf = new char[numBytes];
- if (buf == 0)
+ char *buf = new (std::nothrow) char[numBytes];
+ if (!buf)
return QRegion();
RGNDATA *rd = reinterpret_cast<RGNDATA*>(buf);
@@ -740,7 +740,8 @@ bool QWindowsXPStylePrivate::drawBackgroundDirectly(HDC dc, XPThemeData &themeDa
{
QPainter *painter = themeData.painter;
- const QPointF redirectionDelta(painter->deviceMatrix().dx(), painter->deviceMatrix().dy());
+ const auto deviceTransform = painter->deviceTransform();
+ const QPointF redirectionDelta(deviceTransform.dx(), deviceTransform.dy());
const QRect area = scaleRect(QRectF(themeData.rect), additionalDevicePixelRatio).translated(redirectionDelta).toRect();
QRegion sysRgn = painter->paintEngine()->systemClip();
@@ -835,7 +836,7 @@ bool QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa
alphaType = data.alphaType;
potentialInvalidAlpha = data.hadInvalidAlpha;
- haveCachedPixmap = QPixmapCache::find(pixmapCacheKey, cachedPixmap);
+ haveCachedPixmap = QPixmapCache::find(pixmapCacheKey, &cachedPixmap);
#ifdef DEBUG_XP_STYLE
char buf[25];
diff --git a/src/plugins/styles/windowsvista/qwindowsxpstyle_p.h b/src/plugins/styles/windowsvista/qwindowsxpstyle_p.h
index 7e9f4ddda6..0f70105b0e 100644
--- a/src/plugins/styles/windowsvista/qwindowsxpstyle_p.h
+++ b/src/plugins/styles/windowsvista/qwindowsxpstyle_p.h
@@ -96,7 +96,7 @@ public:
const QWidget *widget = nullptr) const override;
private:
- Q_DISABLE_COPY(QWindowsXPStyle)
+ Q_DISABLE_COPY_MOVE(QWindowsXPStyle)
Q_DECLARE_PRIVATE(QWindowsXPStyle)
friend class QStyleFactory;
};