summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorThe Qt Project <gerrit-noreply@qt-project.org>2019-10-14 08:49:14 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2019-10-14 08:49:14 +0000
commiteba59bfd14d0ea29f36e80be81137d26cc67e23a (patch)
tree69ff8601b3d4a62bea38e1a32245f45cb744aaac /src/plugins
parentf03ac58b1ecc24f01cb83b275a9b6088f9483545 (diff)
parentf4b4c4f79b629498f3cddbbc10df8c1b4d6020d9 (diff)
Merge "Merge remote-tracking branch 'origin/wip/qt6' into wip/cmake" into wip/cmake
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/bearer/android/jar/jar.pro2
-rw-r--r--src/plugins/bearer/connman/qconnmanengine.cpp45
-rw-r--r--src/plugins/bearer/connman/qconnmanservice_linux.cpp9
-rw-r--r--src/plugins/bearer/linux_common/qofonoservice_linux.cpp15
-rw-r--r--src/plugins/imageformats/jpeg/qjpeghandler.cpp29
-rw-r--r--src/plugins/platforms/android/androidjnimain.cpp6
-rw-r--r--src/plugins/platforms/android/androidjnimenu.cpp12
-rw-r--r--src/plugins/platforms/android/qandroidplatformmenu.cpp43
-rw-r--r--src/plugins/platforms/android/qandroidplatformmenu.h5
-rw-r--r--src/plugins/platforms/android/qandroidplatformmenubar.cpp34
-rw-r--r--src/plugins/platforms/android/qandroidplatformmenubar.h6
-rw-r--r--src/plugins/platforms/android/qandroidplatformscreen.cpp8
-rw-r--r--src/plugins/platforms/android/qandroidplatformscreen.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoabackingstore.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.mm11
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm13
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenuloader.mm48
-rw-r--r--src/plugins/platforms/cocoa/qcocoanativeinterface.mm3
-rw-r--r--src/plugins/platforms/cocoa/qcocoascreen.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm69
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindowmanager.mm3
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsintegration.cpp1
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfswindow.cpp9
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfswindow_p.h1
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp3
-rw-r--r--src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp2
-rw-r--r--src/plugins/platforms/offscreen/qoffscreencommon.cpp3
-rw-r--r--src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp2
-rw-r--r--src/plugins/platforms/vnc/qvncclient.cpp13
-rw-r--r--src/plugins/platforms/wasm/qwasmintegration.cpp1
-rw-r--r--src/plugins/platforms/windows/qwindowsglcontext.cpp11
-rw-r--r--src/plugins/platforms/windows/qwindowsscreen.cpp9
-rw-r--r--src/plugins/platforms/windows/qwindowsscreen.h2
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp11
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp12
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp26
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h8
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection_basic.cpp21
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection_basic.h6
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection_xi2.cpp6
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.cpp25
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.h20
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.cpp17
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.h3
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp28
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.h2
-rw-r--r--src/plugins/platforms/xcb/xcb-static/xcb-static.pro80
-rw-r--r--src/plugins/platforms/xcb/xcb.pro2
-rw-r--r--src/plugins/platforms/xcb/xcb_qpa_lib.pro30
-rw-r--r--src/plugins/printsupport/cups/qppdprintdevice.cpp2
-rw-r--r--src/plugins/styles/mac/qmacstyle_mac.mm5
-rw-r--r--src/plugins/styles/windowsvista/qwindowsvistastyle.cpp8
-rw-r--r--src/plugins/styles/windowsvista/qwindowsxpstyle.cpp32
55 files changed, 354 insertions, 416 deletions
diff --git a/src/plugins/bearer/android/jar/jar.pro b/src/plugins/bearer/android/jar/jar.pro
index f988019dac..8277a8abc1 100644
--- a/src/plugins/bearer/android/jar/jar.pro
+++ b/src/plugins/bearer/android/jar/jar.pro
@@ -1,3 +1,5 @@
+CONFIG += single_arch
+
TARGET = QtAndroidBearer
load(qt_build_paths)
diff --git a/src/plugins/bearer/connman/qconnmanengine.cpp b/src/plugins/bearer/connman/qconnmanengine.cpp
index eabae5a07b..8b2076bd18 100644
--- a/src/plugins/bearer/connman/qconnmanengine.cpp
+++ b/src/plugins/bearer/connman/qconnmanengine.cpp
@@ -46,6 +46,7 @@
#include <QtNetwork/qnetworksession.h>
#include <QtCore/qdebug.h>
+#include <QtCore/private/qlocking_p.h>
#include <QtDBus/QtDBus>
#include <QtDBus/QDBusConnection>
@@ -74,13 +75,13 @@ QConnmanEngine::~QConnmanEngine()
bool QConnmanEngine::connmanAvailable() const
{
- QMutexLocker locker(&mutex);
+ const auto locker = qt_scoped_lock(mutex);
return connmanManager->isValid();
}
void QConnmanEngine::initialize()
{
- QMutexLocker locker(&mutex);
+ const auto locker = qt_scoped_lock(mutex);
connect(ofonoManager,SIGNAL(modemChanged()),this,SLOT(changedModem()));
ofonoNetwork = new QOfonoNetworkRegistrationInterface(ofonoManager->currentModem(),this);
@@ -101,7 +102,7 @@ void QConnmanEngine::initialize()
void QConnmanEngine::changedModem()
{
- QMutexLocker locker(&mutex);
+ const auto locker = qt_scoped_lock(mutex);
if (ofonoNetwork)
delete ofonoNetwork;
@@ -114,7 +115,7 @@ void QConnmanEngine::changedModem()
void QConnmanEngine::servicesReady(const QStringList &list)
{
- QMutexLocker locker(&mutex);
+ const auto locker = qt_scoped_lock(mutex);
for (const QString &servPath : list)
addServiceConfiguration(servPath);
@@ -123,7 +124,7 @@ void QConnmanEngine::servicesReady(const QStringList &list)
QList<QNetworkConfigurationPrivate *> QConnmanEngine::getConfigurations()
{
- QMutexLocker locker(&mutex);
+ const auto locker = qt_scoped_lock(mutex);
QList<QNetworkConfigurationPrivate *> fetchedConfigurations;
QNetworkConfigurationPrivate* cpPriv = 0;
const int numFoundConfigurations = foundConfigurations.count();
@@ -150,19 +151,19 @@ QList<QNetworkConfigurationPrivate *> QConnmanEngine::getConfigurations()
QString QConnmanEngine::getInterfaceFromId(const QString &id)
{
- QMutexLocker locker(&mutex);
+ const auto locker = qt_scoped_lock(mutex);
return configInterfaces.value(id);
}
bool QConnmanEngine::hasIdentifier(const QString &id)
{
- QMutexLocker locker(&mutex);
+ const auto locker = qt_scoped_lock(mutex);
return accessPointConfigurations.contains(id);
}
void QConnmanEngine::connectToId(const QString &id)
{
- QMutexLocker locker(&mutex);
+ const auto locker = qt_scoped_lock(mutex);
QConnmanServiceInterface *serv = connmanServiceInterfaces.value(id);
@@ -184,7 +185,7 @@ void QConnmanEngine::connectToId(const QString &id)
void QConnmanEngine::disconnectFromId(const QString &id)
{
- QMutexLocker locker(&mutex);
+ const auto locker = qt_scoped_lock(mutex);
QConnmanServiceInterface *serv = connmanServiceInterfaces.value(id);
if (!serv || !serv->isValid()) {
@@ -196,7 +197,7 @@ void QConnmanEngine::disconnectFromId(const QString &id)
void QConnmanEngine::requestUpdate()
{
- QMutexLocker locker(&mutex);
+ const auto locker = qt_scoped_lock(mutex);
QTimer::singleShot(0, this, SLOT(doRequestUpdate()));
}
@@ -215,7 +216,7 @@ void QConnmanEngine::finishedScan(bool error)
void QConnmanEngine::updateServices(const ConnmanMapList &changed, const QList<QDBusObjectPath> &removed)
{
- QMutexLocker locker(&mutex);
+ const auto locker = qt_scoped_lock(mutex);
foreach (const QDBusObjectPath &objectPath, removed) {
removeConfiguration(objectPath.path());
@@ -234,7 +235,7 @@ void QConnmanEngine::updateServices(const ConnmanMapList &changed, const QList<Q
QNetworkSession::State QConnmanEngine::sessionStateForId(const QString &id)
{
- QMutexLocker locker(&mutex);
+ const auto locker = qt_scoped_lock(mutex);
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
@@ -275,7 +276,7 @@ QNetworkSession::State QConnmanEngine::sessionStateForId(const QString &id)
quint64 QConnmanEngine::bytesWritten(const QString &id)
{//TODO use connman counter API
- QMutexLocker locker(&mutex);
+ const auto locker = qt_scoped_lock(mutex);
quint64 result = 0;
QString devFile = getInterfaceFromId(id);
QFile tx("/sys/class/net/"+devFile+"/statistics/tx_bytes");
@@ -290,7 +291,7 @@ quint64 QConnmanEngine::bytesWritten(const QString &id)
quint64 QConnmanEngine::bytesReceived(const QString &id)
{//TODO use connman counter API
- QMutexLocker locker(&mutex);
+ const auto locker = qt_scoped_lock(mutex);
quint64 result = 0;
QString devFile = getInterfaceFromId(id);
QFile rx("/sys/class/net/"+devFile+"/statistics/rx_bytes");
@@ -305,7 +306,7 @@ quint64 QConnmanEngine::bytesReceived(const QString &id)
quint64 QConnmanEngine::startTime(const QString &/*id*/)
{
// TODO
- QMutexLocker locker(&mutex);
+ const auto locker = qt_scoped_lock(mutex);
if (activeTime.isNull()) {
return 0;
}
@@ -327,7 +328,7 @@ QNetworkSessionPrivate *QConnmanEngine::createSessionBackend()
QNetworkConfigurationPrivatePointer QConnmanEngine::defaultConfiguration()
{
- const QMutexLocker locker(&mutex);
+ const auto locker = qt_scoped_lock(mutex);
const auto servPaths = connmanManager->getServices();
for (const QString &servPath : servPaths) {
if (connmanServiceInterfaces.contains(servPath)) {
@@ -352,7 +353,7 @@ void QConnmanEngine::configurationChange(QConnmanServiceInterface *serv)
{
if (!serv)
return;
- QMutexLocker locker(&mutex);
+ auto locker = qt_unique_lock(mutex);
QString id = serv->path();
if (accessPointConfigurations.contains(id)) {
@@ -381,7 +382,7 @@ void QConnmanEngine::configurationChange(QConnmanServiceInterface *serv)
if (changed) {
locker.unlock();
emit configurationChanged(ptr);
- locker.relock();
+ locker.lock();
}
}
@@ -391,7 +392,7 @@ void QConnmanEngine::configurationChange(QConnmanServiceInterface *serv)
QNetworkConfiguration::StateFlags QConnmanEngine::getStateForService(const QString &service)
{
- QMutexLocker locker(&mutex);
+ const auto locker = qt_scoped_lock(mutex);
QConnmanServiceInterface *serv = connmanServiceInterfaces.value(service);
if (!serv)
return QNetworkConfiguration::Undefined;
@@ -472,7 +473,7 @@ bool QConnmanEngine::isRoamingAllowed(const QString &context)
void QConnmanEngine::removeConfiguration(const QString &id)
{
- QMutexLocker locker(&mutex);
+ auto locker = qt_unique_lock(mutex);
if (accessPointConfigurations.contains(id)) {
@@ -485,13 +486,12 @@ void QConnmanEngine::removeConfiguration(const QString &id)
foundConfigurations.removeOne(ptr.data());
locker.unlock();
emit configurationRemoved(ptr);
- locker.relock();
}
}
void QConnmanEngine::addServiceConfiguration(const QString &servicePath)
{
- QMutexLocker locker(&mutex);
+ auto locker = qt_unique_lock(mutex);
if (!connmanServiceInterfaces.contains(servicePath)) {
QConnmanServiceInterface *serv = new QConnmanServiceInterface(servicePath, this);
connmanServiceInterfaces.insert(serv->path(),serv);
@@ -547,7 +547,6 @@ void QConnmanEngine::addServiceConfiguration(const QString &servicePath)
locker.unlock();
Q_EMIT configurationAdded(ptr);
- locker.relock();
}
}
diff --git a/src/plugins/bearer/connman/qconnmanservice_linux.cpp b/src/plugins/bearer/connman/qconnmanservice_linux.cpp
index 3659eb7740..35d9c40680 100644
--- a/src/plugins/bearer/connman/qconnmanservice_linux.cpp
+++ b/src/plugins/bearer/connman/qconnmanservice_linux.cpp
@@ -80,8 +80,7 @@ QConnmanManagerInterface::QConnmanManagerInterface( QObject *parent)
qDBusRegisterMetaType<ConnmanMap>();
qDBusRegisterMetaType<ConnmanMapList>();
- QList<QVariant> argumentList;
- QDBusPendingReply<QVariantMap> props_reply = asyncCallWithArgumentList(QLatin1String("GetProperties"), argumentList);
+ QDBusPendingReply<QVariantMap> props_reply = asyncCall(QLatin1String("GetProperties"));
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(props_reply, this);
QObject::connect(watcher,SIGNAL(finished(QDBusPendingCallWatcher*)),
@@ -106,8 +105,7 @@ QConnmanManagerInterface::QConnmanManagerInterface( QObject *parent)
QLatin1String("TechnologyRemoved"),
this,SLOT(technologyRemoved(QDBusObjectPath)));
- QList<QVariant> argumentList2;
- QDBusPendingReply<ConnmanMapList> serv_reply = asyncCallWithArgumentList(QLatin1String("GetServices"), argumentList2);
+ QDBusPendingReply<ConnmanMapList> serv_reply = asyncCall(QLatin1String("GetServices"));
QDBusPendingCallWatcher *watcher2 = new QDBusPendingCallWatcher(serv_reply, this);
QObject::connect(watcher2,SIGNAL(finished(QDBusPendingCallWatcher*)),
@@ -289,8 +287,7 @@ QConnmanServiceInterface::QConnmanServiceInterface(const QString &dbusPathName,Q
CONNMAN_SERVICE_INTERFACE,
QDBusConnection::systemBus(), parent)
{
- QList<QVariant> argumentList;
- QDBusPendingReply<QVariantMap> props_reply = asyncCallWithArgumentList(QLatin1String("GetProperties"), argumentList);
+ QDBusPendingReply<QVariantMap> props_reply = asyncCall(QLatin1String("GetProperties"));
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(props_reply, this);
diff --git a/src/plugins/bearer/linux_common/qofonoservice_linux.cpp b/src/plugins/bearer/linux_common/qofonoservice_linux.cpp
index 5d72731bc4..05f9b3ca17 100644
--- a/src/plugins/bearer/linux_common/qofonoservice_linux.cpp
+++ b/src/plugins/bearer/linux_common/qofonoservice_linux.cpp
@@ -99,8 +99,7 @@ QOfonoManagerInterface::~QOfonoManagerInterface()
QStringList QOfonoManagerInterface::getModems()
{
if (modemList.isEmpty()) {
- QList<QVariant> argumentList;
- QDBusPendingReply<PathPropertiesList> reply = callWithArgumentList(QDBus::Block, QLatin1String("GetModems"), argumentList);
+ QDBusPendingReply<PathPropertiesList> reply = call(QDBus::Block, QLatin1String("GetModems"));
reply.waitForFinished();
if (!reply.isError()) {
const auto modems = reply.value();
@@ -184,8 +183,7 @@ QStringList QOfonoModemInterface::interfaces()
QVariantMap QOfonoModemInterface::getProperties()
{
if (propertiesMap.isEmpty()) {
- QList<QVariant> argumentList;
- QDBusPendingReply<QVariantMap> reply = callWithArgumentList(QDBus::Block, QLatin1String("GetProperties"), argumentList);
+ QDBusPendingReply<QVariantMap> reply = call(QDBus::Block, QLatin1String("GetProperties"));
if (!reply.isError()) {
propertiesMap = reply.value();
}
@@ -233,8 +231,7 @@ QVariant QOfonoNetworkRegistrationInterface::getProperty(const QString &property
QVariantMap QOfonoNetworkRegistrationInterface::getProperties()
{
if (propertiesMap.isEmpty()) {
- QList<QVariant> argumentList;
- QDBusPendingReply<QVariantMap> reply = callWithArgumentList(QDBus::Block, QLatin1String("GetProperties"), argumentList);
+ QDBusPendingReply<QVariantMap> reply = call(QDBus::Block, QLatin1String("GetProperties"));
reply.waitForFinished();
if (!reply.isError()) {
propertiesMap = reply.value();
@@ -306,8 +303,7 @@ QVariant QOfonoDataConnectionManagerInterface::getProperty(const QString &proper
QVariantMap &QOfonoDataConnectionManagerInterface::getProperties()
{
if (propertiesMap.isEmpty()) {
- QList<QVariant> argumentList;
- QDBusPendingReply<QVariantMap> reply = callWithArgumentList(QDBus::Block, QLatin1String("GetProperties"), argumentList);
+ QDBusPendingReply<QVariantMap> reply = call(QDBus::Block, QLatin1String("GetProperties"));
if (!reply.isError()) {
propertiesMap = reply.value();
}
@@ -343,8 +339,7 @@ QOfonoConnectionContextInterface::~QOfonoConnectionContextInterface()
QVariantMap QOfonoConnectionContextInterface::getProperties()
{
if (propertiesMap.isEmpty()) {
- QList<QVariant> argumentList;
- QDBusPendingReply<QVariantMap> reply = callWithArgumentList(QDBus::Block, QLatin1String("GetProperties"), argumentList);
+ QDBusPendingReply<QVariantMap> reply = call(QDBus::Block, QLatin1String("GetProperties"));
if (!reply.isError()) {
propertiesMap = reply.value();
}
diff --git a/src/plugins/imageformats/jpeg/qjpeghandler.cpp b/src/plugins/imageformats/jpeg/qjpeghandler.cpp
index 0fb21df1d3..1f1675e490 100644
--- a/src/plugins/imageformats/jpeg/qjpeghandler.cpp
+++ b/src/plugins/imageformats/jpeg/qjpeghandler.cpp
@@ -492,6 +492,8 @@ inline my_jpeg_destination_mgr::my_jpeg_destination_mgr(QIODevice *device)
free_in_buffer = max_buf;
}
+static constexpr int maxMarkerSize = 65533;
+
static inline void set_text(const QImage &image, j_compress_ptr cinfo, const QString &description)
{
const QMap<QString, QString> text = qt_getImageText(image, description);
@@ -500,12 +502,33 @@ static inline void set_text(const QImage &image, j_compress_ptr cinfo, const QSt
if (!comment.isEmpty())
comment += ": ";
comment += it.value().toUtf8();
- if (comment.length() > 65530)
- comment.truncate(65530);
+ if (comment.length() > maxMarkerSize)
+ comment.truncate(maxMarkerSize);
jpeg_write_marker(cinfo, JPEG_COM, (const JOCTET *)comment.constData(), comment.size());
}
}
+static inline void write_icc_profile(const QImage &image, j_compress_ptr cinfo)
+{
+ const QByteArray iccProfile = image.colorSpace().iccProfile();
+ if (iccProfile.isEmpty())
+ return;
+
+ const QByteArray iccSignature("ICC_PROFILE", 12);
+ constexpr int maxIccMarkerSize = maxMarkerSize - (12 + 2);
+ int index = 0;
+ const int markers = (iccProfile.size() + (maxIccMarkerSize - 1)) / maxIccMarkerSize;
+ Q_ASSERT(markers < 256);
+ for (int marker = 1; marker <= markers; ++marker) {
+ const int len = std::min(iccProfile.size() - index, maxIccMarkerSize);
+ const QByteArray block = iccSignature
+ + QByteArray(1, char(marker)) + QByteArray(1, char(markers))
+ + iccProfile.mid(index, len);
+ jpeg_write_marker(cinfo, JPEG_APP0 + 2, reinterpret_cast<const JOCTET *>(block.constData()), block.size());
+ index += len;
+ }
+}
+
static bool write_jpeg_image(const QImage &image, QIODevice *device, volatile int sourceQuality, const QString &description, bool optimize, bool progressive)
{
bool success = false;
@@ -586,6 +609,8 @@ static bool write_jpeg_image(const QImage &image, QIODevice *device, volatile in
jpeg_start_compress(&cinfo, TRUE);
set_text(image, &cinfo, description);
+ if (cinfo.in_color_space == JCS_RGB)
+ write_icc_profile(image, &cinfo);
row_pointer[0] = new uchar[cinfo.image_width*cinfo.input_components];
int w = cinfo.image_width;
diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp
index 70dde46ffa..915f7f0f5b 100644
--- a/src/plugins/platforms/android/androidjnimain.cpp
+++ b/src/plugins/platforms/android/androidjnimain.cpp
@@ -454,9 +454,9 @@ static jboolean startQtAndroidPlugin(JNIEnv *env, jobject /*object*/, jstring pa
const QList<QByteArray> envVars = QByteArray(nativeString).split('\t');
env->ReleaseStringUTFChars(environmentString, nativeString);
for (const QByteArray &envVar : envVars) {
- const QList<QByteArray> envVarPair = envVar.split('=');
- if (envVarPair.size() == 2 && ::setenv(envVarPair[0], envVarPair[1], 1) != 0)
- qWarning() << "Can't set environment" << envVarPair;
+ int pos = envVar.indexOf('=');
+ if (pos != -1 && ::setenv(envVar.left(pos), envVar.mid(pos + 1), 1) != 0)
+ qWarning() << "Can't set environment" << envVar;
}
}
diff --git a/src/plugins/platforms/android/androidjnimenu.cpp b/src/plugins/platforms/android/androidjnimenu.cpp
index f51a3920b8..de2fdaa0e2 100644
--- a/src/plugins/platforms/android/androidjnimenu.cpp
+++ b/src/plugins/platforms/android/androidjnimenu.cpp
@@ -225,10 +225,11 @@ namespace QtAndroidMenu
QString itemText = removeAmpersandEscapes(item->text());
jstring jtext = env->NewString(reinterpret_cast<const jchar *>(itemText.data()),
itemText.length());
+ jint menuId = platformMenu->menuId(item);
jobject menuItem = env->CallObjectMethod(menu,
addMenuItemMethodID,
menuNoneValue,
- int(item->tag()),
+ menuId,
order++,
jtext);
env->DeleteLocalRef(jtext);
@@ -262,10 +263,11 @@ namespace QtAndroidMenu
QString itemText = removeAmpersandEscapes(item->text());
jstring jtext = env->NewString(reinterpret_cast<const jchar *>(itemText.data()),
itemText.length());
+ jint menuId = visibleMenuBar->menuId(item);
jobject menuItem = env->CallObjectMethod(menu,
addMenuItemMethodID,
menuNoneValue,
- int(item->tag()),
+ menuId,
order++,
jtext);
env->DeleteLocalRef(jtext);
@@ -290,7 +292,7 @@ namespace QtAndroidMenu
const QAndroidPlatformMenuBar::PlatformMenusType &menus = visibleMenuBar->menus();
if (menus.size() == 1) { // Expanded menu
- QAndroidPlatformMenuItem *item = static_cast<QAndroidPlatformMenuItem *>(menus.front()->menuItemForTag(menuId));
+ QAndroidPlatformMenuItem *item = static_cast<QAndroidPlatformMenuItem *>(menus.front()->menuItemForId(menuId));
if (item) {
if (item->menu()) {
showContextMenu(item->menu(), QRect(), env);
@@ -301,7 +303,7 @@ namespace QtAndroidMenu
}
}
} else {
- QAndroidPlatformMenu *menu = static_cast<QAndroidPlatformMenu *>(visibleMenuBar->menuForTag(menuId));
+ QAndroidPlatformMenu *menu = static_cast<QAndroidPlatformMenu *>(visibleMenuBar->menuForId(menuId));
if (menu)
showContextMenu(menu, QRect(), env);
}
@@ -341,7 +343,7 @@ namespace QtAndroidMenu
static jboolean onContextItemSelected(JNIEnv *env, jobject /*thiz*/, jint menuId, jboolean checked)
{
QMutexLocker lock(&visibleMenuMutex);
- QAndroidPlatformMenuItem * item = static_cast<QAndroidPlatformMenuItem *>(visibleMenu->menuItemForTag(menuId));
+ QAndroidPlatformMenuItem * item = static_cast<QAndroidPlatformMenuItem *>(visibleMenu->menuItemForId(menuId));
if (item) {
if (item->menu()) {
showContextMenu(item->menu(), QRect(), env);
diff --git a/src/plugins/platforms/android/qandroidplatformmenu.cpp b/src/plugins/platforms/android/qandroidplatformmenu.cpp
index d9cecebf2c..7ce603831f 100644
--- a/src/plugins/platforms/android/qandroidplatformmenu.cpp
+++ b/src/plugins/platforms/android/qandroidplatformmenu.cpp
@@ -62,6 +62,7 @@ void QAndroidPlatformMenu::insertMenuItem(QPlatformMenuItem *menuItem, QPlatform
m_menuItems.end(),
static_cast<QAndroidPlatformMenuItem *>(before)),
static_cast<QAndroidPlatformMenuItem *>(menuItem));
+ m_menuHash.insert(m_nextMenuId++, menuItem);
}
void QAndroidPlatformMenu::removeMenuItem(QPlatformMenuItem *menuItem)
@@ -72,6 +73,21 @@ void QAndroidPlatformMenu::removeMenuItem(QPlatformMenuItem *menuItem)
static_cast<QAndroidPlatformMenuItem *>(menuItem));
if (it != m_menuItems.end())
m_menuItems.erase(it);
+
+ {
+ int maxId = -1;
+ QHash<int, QPlatformMenuItem *>::iterator it = m_menuHash.begin();
+ while (it != m_menuHash.end()) {
+ if (it.value() == menuItem) {
+ it = m_menuHash.erase(it);
+ } else {
+ maxId = qMax(maxId, it.key());
+ ++it;
+ }
+ }
+
+ m_nextMenuId = maxId + 1;
+ }
}
void QAndroidPlatformMenu::syncMenuItem(QPlatformMenuItem *menuItem)
@@ -139,6 +155,16 @@ void QAndroidPlatformMenu::showPopup(const QWindow *parentWindow, const QRect &t
QtAndroidMenu::showContextMenu(this, targetRect, QJNIEnvironmentPrivate());
}
+QPlatformMenuItem *QAndroidPlatformMenu::menuItemForTag(quintptr tag) const
+{
+ for (QAndroidPlatformMenuItem *menuItem : m_menuItems) {
+ if (menuItem->tag() == tag)
+ return menuItem;
+ }
+
+ return nullptr;
+}
+
QPlatformMenuItem *QAndroidPlatformMenu::menuItemAt(int position) const
{
if (position < m_menuItems.size())
@@ -146,13 +172,20 @@ QPlatformMenuItem *QAndroidPlatformMenu::menuItemAt(int position) const
return 0;
}
-QPlatformMenuItem *QAndroidPlatformMenu::menuItemForTag(quintptr tag) const
+int QAndroidPlatformMenu::menuId(QPlatformMenuItem *menu) const
{
- for (QPlatformMenuItem *menuItem : m_menuItems) {
- if (menuItem->tag() == tag)
- return menuItem;
+ QHash<int, QPlatformMenuItem *>::const_iterator it;
+ for (it = m_menuHash.constBegin(); it != m_menuHash.constEnd(); ++it) {
+ if (it.value() == menu)
+ return it.key();
}
- return 0;
+
+ return -1;
+}
+
+QPlatformMenuItem *QAndroidPlatformMenu::menuItemForId(int menuId) const
+{
+ return m_menuHash.value(menuId);
}
QAndroidPlatformMenu::PlatformMenuItemsType QAndroidPlatformMenu::menuItems() const
diff --git a/src/plugins/platforms/android/qandroidplatformmenu.h b/src/plugins/platforms/android/qandroidplatformmenu.h
index 47e650f2d7..b1d6a88787 100644
--- a/src/plugins/platforms/android/qandroidplatformmenu.h
+++ b/src/plugins/platforms/android/qandroidplatformmenu.h
@@ -73,6 +73,8 @@ public:
QPlatformMenuItem *menuItemAt(int position) const override;
QPlatformMenuItem *menuItemForTag(quintptr tag) const override;
+ QPlatformMenuItem *menuItemForId(int menuId) const;
+ int menuId(QPlatformMenuItem *menuItem) const;
PlatformMenuItemsType menuItems() const;
QMutex *menuItemsMutex();
@@ -84,6 +86,9 @@ private:
bool m_enabled;
bool m_isVisible;
QMutex m_menuItemsMutex;
+
+ int m_nextMenuId = 0;
+ QHash<int, QPlatformMenuItem *> m_menuHash;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/android/qandroidplatformmenubar.cpp b/src/plugins/platforms/android/qandroidplatformmenubar.cpp
index 35930f0628..7c6299b4b7 100644
--- a/src/plugins/platforms/android/qandroidplatformmenubar.cpp
+++ b/src/plugins/platforms/android/qandroidplatformmenubar.cpp
@@ -61,6 +61,7 @@ void QAndroidPlatformMenuBar::insertMenu(QPlatformMenu *menu, QPlatformMenu *bef
m_menus.end(),
static_cast<QAndroidPlatformMenu *>(before)),
static_cast<QAndroidPlatformMenu *>(menu));
+ m_menuHash.insert(m_nextMenuId++, menu);
}
void QAndroidPlatformMenuBar::removeMenu(QPlatformMenu *menu)
@@ -69,6 +70,30 @@ void QAndroidPlatformMenuBar::removeMenu(QPlatformMenu *menu)
m_menus.erase(std::find(m_menus.begin(),
m_menus.end(),
static_cast<QAndroidPlatformMenu *>(menu)));
+
+ int maxId = -1;
+ QHash<int, QPlatformMenu *>::iterator it = m_menuHash.begin();
+ while (it != m_menuHash.end()) {
+ if (it.value() == menu) {
+ it = m_menuHash.erase(it);
+ } else {
+ maxId = qMax(maxId, it.key());
+ ++it;
+ }
+ }
+
+ m_nextMenuId = maxId + 1;
+}
+
+int QAndroidPlatformMenuBar::menuId(QPlatformMenu *menu) const
+{
+ QHash<int, QPlatformMenu *>::const_iterator it;
+ for (it = m_menuHash.constBegin(); it != m_menuHash.constEnd(); ++it) {
+ if (it.value() == menu)
+ return it.key();
+ }
+
+ return -1;
}
void QAndroidPlatformMenuBar::syncMenu(QPlatformMenu *menu)
@@ -86,12 +111,17 @@ void QAndroidPlatformMenuBar::handleReparent(QWindow *newParentWindow)
QPlatformMenu *QAndroidPlatformMenuBar::menuForTag(quintptr tag) const
{
- for (QPlatformMenu *menu : m_menus) {
+ for (QAndroidPlatformMenu *menu : m_menus) {
if (menu->tag() == tag)
return menu;
}
- return 0;
+ return nullptr;
+}
+
+QPlatformMenu *QAndroidPlatformMenuBar::menuForId(int menuId) const
+{
+ return m_menuHash.value(menuId);
}
QWindow *QAndroidPlatformMenuBar::parentWindow() const
diff --git a/src/plugins/platforms/android/qandroidplatformmenubar.h b/src/plugins/platforms/android/qandroidplatformmenubar.h
index f5935b8177..81a26c72f4 100644
--- a/src/plugins/platforms/android/qandroidplatformmenubar.h
+++ b/src/plugins/platforms/android/qandroidplatformmenubar.h
@@ -43,6 +43,7 @@
#include <qpa/qplatformmenu.h>
#include <qvector.h>
#include <qmutex.h>
+#include <qhash.h>
QT_BEGIN_NAMESPACE
@@ -60,6 +61,8 @@ public:
void syncMenu(QPlatformMenu *menu) override;
void handleReparent(QWindow *newParentWindow) override;
QPlatformMenu *menuForTag(quintptr tag) const override;
+ QPlatformMenu *menuForId(int menuId) const;
+ int menuId(QPlatformMenu *menu) const;
QWindow *parentWindow() const override;
PlatformMenusType menus() const;
@@ -69,6 +72,9 @@ private:
PlatformMenusType m_menus;
QWindow *m_parentWindow;
QMutex m_menusListMutex;
+
+ int m_nextMenuId = 0;
+ QHash<int, QPlatformMenu *> m_menuHash;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/android/qandroidplatformscreen.cpp b/src/plugins/platforms/android/qandroidplatformscreen.cpp
index 7dc8bb8080..80757c2135 100644
--- a/src/plugins/platforms/android/qandroidplatformscreen.cpp
+++ b/src/plugins/platforms/android/qandroidplatformscreen.cpp
@@ -401,15 +401,17 @@ void QAndroidPlatformScreen::doRedraw()
m_dirtyRect = QRect();
}
+static const int androidLogicalDpi = 72;
+
QDpi QAndroidPlatformScreen::logicalDpi() const
{
- qreal lDpi = QtAndroid::scaledDensity() * 72;
+ qreal lDpi = QtAndroid::scaledDensity() * androidLogicalDpi;
return QDpi(lDpi, lDpi);
}
-qreal QAndroidPlatformScreen::pixelDensity() const
+QDpi QAndroidPlatformScreen::logicalBaseDpi() const
{
- return QtAndroid::pixelDensity();
+ return QDpi(androidLogicalDpi, androidLogicalDpi);
}
Qt::ScreenOrientation QAndroidPlatformScreen::orientation() const
diff --git a/src/plugins/platforms/android/qandroidplatformscreen.h b/src/plugins/platforms/android/qandroidplatformscreen.h
index f15aeae3fd..5dc158e351 100644
--- a/src/plugins/platforms/android/qandroidplatformscreen.h
+++ b/src/plugins/platforms/android/qandroidplatformscreen.h
@@ -103,7 +103,7 @@ protected:
private:
QDpi logicalDpi() const override;
- qreal pixelDensity() const override;
+ QDpi logicalBaseDpi() const override;
Qt::ScreenOrientation orientation() const override;
Qt::ScreenOrientation nativeOrientation() const override;
void surfaceChanged(JNIEnv *env, jobject surface, int w, int h) override;
diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
index 6015257f4e..15e0236107 100644
--- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm
+++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
@@ -153,7 +153,7 @@ void QNSWindowBackingStore::flush(QWindow *window, const QRegion &region, const
// context is set up correctly (coordinate system, clipping, etc). Outside
// of the normal display cycle there is no focused view, as explained above,
// so we have to handle it manually. There's also a corner case inside the
- // normal display cycle due to way QWidgetBackingStore composits native child
+ // normal display cycle due to way QWidgetRepaintManager composits native child
// widgets, where we'll get a flush of a native child during the drawRect of
// its parent/ancestor, and the parent/ancestor being the one locked by AppKit.
// In this case we also need to lock and unlock focus manually.
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
index 7b124ea517..ba7d12ce30 100644
--- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
@@ -197,8 +197,15 @@ NSOpenGLPixelFormat *QCocoaGLContext::pixelFormatForSurfaceFormat(const QSurface
attrs << NSOpenGLPFAStencilSize << format.stencilBufferSize();
if (format.alphaBufferSize() > 0)
attrs << NSOpenGLPFAAlphaSize << format.alphaBufferSize();
- if (format.redBufferSize() > 0 && format.greenBufferSize() > 0 && format.blueBufferSize() > 0) {
- const int colorSize = format.redBufferSize() + format.greenBufferSize() + format.blueBufferSize();
+
+ auto rbz = format.redBufferSize();
+ auto gbz = format.greenBufferSize();
+ auto bbz = format.blueBufferSize();
+ if (rbz > 0 || gbz > 0 || bbz > 0) {
+ auto fallbackSize = qMax(rbz, qMax(gbz, bbz));
+ auto colorSize = (rbz > 0 ? rbz : fallbackSize)
+ + (gbz > 0 ? gbz : fallbackSize)
+ + (bbz > 0 ? bbz : fallbackSize);
attrs << NSOpenGLPFAColorSize << colorSize << NSOpenGLPFAMinimumPolicy;
}
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h
index bfc3bfe9de..0e2656e046 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.h
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.h
@@ -124,6 +124,8 @@ public:
void beep() const override;
+ void closePopups(QWindow *forWindow = nullptr);
+
private Q_SLOTS:
void focusWindowChanged(QWindow *);
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index 9a2f19c2f2..67ad0b3492 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -487,6 +487,19 @@ void QCocoaIntegration::beep() const
NSBeep();
}
+void QCocoaIntegration::closePopups(QWindow *forWindow)
+{
+ for (auto it = m_popupWindowStack.begin(); it != m_popupWindowStack.end();) {
+ auto *popup = *it;
+ if (!forWindow || popup->window()->transientParent() == forWindow) {
+ it = m_popupWindowStack.erase(it);
+ QWindowSystemInterface::handleCloseEvent<QWindowSystemInterface::SynchronousDelivery>(popup->window());
+ } else {
+ ++it;
+ }
+ }
+}
+
void QCocoaIntegration::focusWindowChanged(QWindow *focusWindow)
{
// Don't revert icon just because we lost focus
diff --git a/src/plugins/platforms/cocoa/qcocoamenuloader.mm b/src/plugins/platforms/cocoa/qcocoamenuloader.mm
index da0fc5c6a1..d384078e91 100644
--- a/src/plugins/platforms/cocoa/qcocoamenuloader.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenuloader.mm
@@ -59,7 +59,6 @@
NSMenuItem *aboutItem;
NSMenuItem *aboutQtItem;
NSMenuItem *hideItem;
- NSMenuItem *lastAppSpecificItem;
NSMenuItem *servicesItem;
NSMenuItem *hideAllOthersItem;
NSMenuItem *showAllItem;
@@ -118,6 +117,9 @@
[appMenu addItem:[NSMenuItem separatorItem]];
// Preferences
+ // We'll be adding app specific items after this. The macOS HIG state that,
+ // "In general, a Preferences menu item should be the first app-specific menu item."
+ // https://developer.apple.com/macos/human-interface-guidelines/menus/menu-bar-menus/
preferencesItem = [[QCocoaNSMenuItem alloc] init];
preferencesItem.title = @"Preferences…";
preferencesItem.keyEquivalent = @",";
@@ -126,11 +128,6 @@
preferencesItem.hidden = YES;
[appMenu addItem:preferencesItem];
- // We'll be adding app specific items after this. The macOS HIG state that,
- // "In general, a Preferences menu item should be the first app-specific menu item."
- // https://developer.apple.com/macos/human-interface-guidelines/menus/menu-bar-menus/
- lastAppSpecificItem = preferencesItem;
-
[appMenu addItem:[NSMenuItem separatorItem]];
// Services item and menu
@@ -194,8 +191,6 @@
[showAllItem release];
[quitItem release];
- [lastAppSpecificItem release];
-
[super dealloc];
}
@@ -272,25 +267,20 @@
// No reason to create the item if it already exists.
for (NSMenuItem *item in appMenu.itemArray)
if (qt_objc_cast<QCocoaNSMenuItem *>(item).platformMenuItem == platformItem)
- return [[item retain] autorelease];
+ return item;
// Create an App-Specific menu item, insert it into the menu and return
// it as an autorelease item.
QCocoaNSMenuItem *item;
if (platformItem->isSeparator())
- item = [[QCocoaNSMenuItem separatorItemWithPlatformMenuItem:platformItem] retain];
+ item = [QCocoaNSMenuItem separatorItemWithPlatformMenuItem:platformItem];
else
- item = [[QCocoaNSMenuItem alloc] initWithPlatformMenuItem:platformItem];
-
- const auto location = [appMenu indexOfItem:lastAppSpecificItem];
+ item = [[[QCocoaNSMenuItem alloc] initWithPlatformMenuItem:platformItem] autorelease];
- if (!lastAppSpecificItem.separatorItem)
- [lastAppSpecificItem release];
- lastAppSpecificItem = item; // Keep track of this for later (i.e., don't release it)
+ const auto location = [self indexOfLastAppSpecificMenuItem];
+ [appMenu insertItem:item atIndex:NSInteger(location) + 1];
- [appMenu insertItem:item atIndex:location + 1];
-
- return [[item retain] autorelease];
+ return item;
}
- (void)orderFrontStandardAboutPanel:(id)sender
@@ -344,8 +334,24 @@
- (NSArray<NSMenuItem *> *)mergeable
{
// Don't include the quitItem here, since we want it always visible and enabled regardless
- // Note that lastAppSpecificItem may be nil, so we can't use @[] here.
- return [NSArray arrayWithObjects:preferencesItem, aboutItem, aboutQtItem, lastAppSpecificItem, nil];
+ auto items = [NSArray arrayWithObjects:preferencesItem, aboutItem, aboutQtItem,
+ appMenu.itemArray[[self indexOfLastAppSpecificMenuItem]], nil];
+ return items;
}
+- (NSUInteger)indexOfLastAppSpecificMenuItem
+{
+ // Either the 'Preferences', which is the first app specific menu item, or something
+ // else we appended later (thus the reverse order):
+ const auto location = [appMenu.itemArray indexOfObjectWithOptions:NSEnumerationReverse
+ passingTest:^BOOL(NSMenuItem *item, NSUInteger, BOOL *) {
+ if (auto qtItem = qt_objc_cast<QCocoaNSMenuItem*>(item))
+ return qtItem != quitItem;
+ return NO;
+ }];
+ Q_ASSERT(location != NSNotFound);
+ return location;
+}
+
+
@end
diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
index 7979e430ac..9bd19dd07c 100644
--- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
+++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
@@ -177,6 +177,9 @@ void *QCocoaNativeInterface::NSPrintInfoForPrintEngine(QPrintEngine *printEngine
QPixmap QCocoaNativeInterface::defaultBackgroundPixmapForQWizard()
{
+ // Note: starting with macOS 10.14, the KeyboardSetupAssistant app bundle no
+ // longer contains the "Background.png" image. This function then returns a
+ // null pixmap.
const int ExpectedImageWidth = 242;
const int ExpectedImageHeight = 414;
QCFType<CFArrayRef> urls = LSCopyApplicationURLsForBundleIdentifier(
diff --git a/src/plugins/platforms/cocoa/qcocoascreen.h b/src/plugins/platforms/cocoa/qcocoascreen.h
index 491af2fe9c..60243b79be 100644
--- a/src/plugins/platforms/cocoa/qcocoascreen.h
+++ b/src/plugins/platforms/cocoa/qcocoascreen.h
@@ -68,6 +68,7 @@ public:
qreal devicePixelRatio() const override { return m_devicePixelRatio; }
QSizeF physicalSize() const override { return m_physicalSize; }
QDpi logicalDpi() const override { return m_logicalDpi; }
+ QDpi logicalBaseDpi() const override { return m_logicalDpi; }
qreal refreshRate() const override { return m_refreshRate; }
QString name() const override { return m_name; }
QPlatformCursor *cursor() const override { return m_cursor; }
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
index fef72bc496..1e46cd2dde 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.h
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -151,6 +151,7 @@ public:
Q_NOTIFICATION_HANDLER(NSWindowDidEndLiveResizeNotification) void windowDidEndLiveResize();
Q_NOTIFICATION_HANDLER(NSWindowDidBecomeKeyNotification) void windowDidBecomeKey();
Q_NOTIFICATION_HANDLER(NSWindowDidResignKeyNotification) void windowDidResignKey();
+ Q_NOTIFICATION_HANDLER(NSWindowWillMiniaturizeNotification) void windowWillMiniaturize();
Q_NOTIFICATION_HANDLER(NSWindowDidMiniaturizeNotification) void windowDidMiniaturize();
Q_NOTIFICATION_HANDLER(NSWindowDidDeminiaturizeNotification) void windowDidDeminiaturize();
Q_NOTIFICATION_HANDLER(NSWindowWillEnterFullScreenNotification) void windowWillEnterFullScreen();
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 8f3c192745..7621508bdd 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -71,14 +71,6 @@ enum {
defaultWindowHeight = 160
};
-static void qt_closePopups()
-{
- while (QCocoaWindow *popup = QCocoaIntegration::instance()->popPopupWindow()) {
- QWindowSystemInterface::handleCloseEvent(popup->window());
- QWindowSystemInterface::flushWindowSystemEvents();
- }
-}
-
Q_LOGGING_CATEGORY(lcCocoaNotifications, "qt.qpa.cocoa.notifications");
static void qRegisterNotificationCallbacks()
@@ -800,6 +792,11 @@ void QCocoaWindow::windowDidExitFullScreen()
}
}
+void QCocoaWindow::windowWillMiniaturize()
+{
+ QCocoaIntegration::instance()->closePopups(window());
+}
+
void QCocoaWindow::windowDidMiniaturize()
{
if (!isContentView())
@@ -1138,7 +1135,7 @@ void QCocoaWindow::viewDidChangeGlobalFrame()
void QCocoaWindow::windowWillMove()
{
// Close any open popups on window move
- qt_closePopups();
+ QCocoaIntegration::instance()->closePopups();
}
void QCocoaWindow::windowDidMove()
@@ -1267,7 +1264,7 @@ void QCocoaWindow::windowWillClose()
{
// Close any open popups on window closing.
if (window() && !windowIsPopupType(window()->type()))
- qt_closePopups();
+ QCocoaIntegration::instance()->closePopups();
}
// ----------------------- NSWindowDelegate callbacks -----------------------
@@ -1544,12 +1541,6 @@ QCocoaNSWindow *QCocoaWindow::createNSWindow(bool shouldBePanel)
Qt::WindowType type = window()->type();
Qt::WindowFlags flags = window()->flags();
- // Note: The macOS window manager has a bug, where if a screen is rotated, it will not allow
- // a window to be created within the area of the screen that has a Y coordinate (I quadrant)
- // higher than the height of the screen in its non-rotated state, unless the window is
- // created with the NSWindowStyleMaskBorderless style mask.
- NSWindowStyleMask styleMask = windowStyleMask(flags);
-
QRect rect = geometry();
QScreen *targetScreen = nullptr;
@@ -1560,35 +1551,57 @@ QCocoaNSWindow *QCocoaWindow::createNSWindow(bool shouldBePanel)
}
}
+ NSWindowStyleMask styleMask = windowStyleMask(flags);
+
if (!targetScreen) {
qCWarning(lcQpaWindow) << "Window position" << rect << "outside any known screen, using primary screen";
targetScreen = QGuiApplication::primaryScreen();
- // AppKit will only reposition a window that's outside the target screen area if
- // the window has a title bar. If left out, the window ends up with no screen.
- // The style mask will be corrected to the original style mask in setWindowFlags.
- styleMask |= NSWindowStyleMaskTitled;
+ // Unless the window is created as borderless AppKit won't find a position and
+ // screen that's close to the requested invalid position, and will always place
+ // the window on the primary screen.
+ styleMask = NSWindowStyleMaskBorderless;
}
rect.translate(-targetScreen->geometry().topLeft());
- QCocoaScreen *cocoaScreen = static_cast<QCocoaScreen *>(targetScreen->handle());
- NSRect frame = QCocoaScreen::mapToNative(rect, cocoaScreen);
+ auto *targetCocoaScreen = static_cast<QCocoaScreen *>(targetScreen->handle());
+ NSRect contentRect = QCocoaScreen::mapToNative(rect, targetCocoaScreen);
+
+ if (targetScreen->primaryOrientation() == Qt::PortraitOrientation) {
+ // The macOS window manager has a bug, where if a screen is rotated, it will not allow
+ // a window to be created within the area of the screen that has a Y coordinate (I quadrant)
+ // higher than the height of the screen in its non-rotated state (including a magic padding
+ // of 24 points), unless the window is created with the NSWindowStyleMaskBorderless style mask.
+ if (styleMask && (contentRect.origin.y + 24 > targetScreen->geometry().width())) {
+ qCDebug(lcQpaWindow) << "Window positioned on portrait screen."
+ << "Adjusting style mask during creation";
+ styleMask = NSWindowStyleMaskBorderless;
+ }
+ }
// Create NSWindow
Class windowClass = shouldBePanel ? [QNSPanel class] : [QNSWindow class];
- QCocoaNSWindow *nsWindow = [[windowClass alloc] initWithContentRect:frame
+ QCocoaNSWindow *nsWindow = [[windowClass alloc] initWithContentRect:contentRect
+ // Mask will be updated in setWindowFlags if not the final mask
styleMask:styleMask
// Deferring window creation breaks OpenGL (the GL context is
// set up before the window is shown and needs a proper window)
backing:NSBackingStoreBuffered defer:NO
- screen:cocoaScreen->nativeScreen()
+ screen:targetCocoaScreen->nativeScreen()
platformWindow:this];
- Q_ASSERT_X(nsWindow.screen == cocoaScreen->nativeScreen(), "QCocoaWindow",
- "Resulting NSScreen should match the requested NSScreen");
+ // The resulting screen can be different from the screen requested if
+ // for example the application has been assigned to a specific display.
+ auto resultingScreen = QCocoaScreen::get(nsWindow.screen);
+
+ // But may not always be resolved at this point, in which case we fall back
+ // to the target screen. The real screen will be delivered as a screen change
+ // when resolved as part of ordering the window on screen.
+ if (!resultingScreen)
+ resultingScreen = targetCocoaScreen;
- if (targetScreen != window()->screen()) {
+ if (resultingScreen->screen() != window()->screen()) {
QWindowSystemInterface::handleWindowScreenChanged<
- QWindowSystemInterface::SynchronousDelivery>(window(), targetScreen);
+ QWindowSystemInterface::SynchronousDelivery>(window(), resultingScreen->screen());
}
static QSharedPointer<QNSWindowDelegate> sharedDelegate([[QNSWindowDelegate alloc] init],
diff --git a/src/plugins/platforms/cocoa/qcocoawindowmanager.mm b/src/plugins/platforms/cocoa/qcocoawindowmanager.mm
index 879bfaa546..9c45d8c7fc 100644
--- a/src/plugins/platforms/cocoa/qcocoawindowmanager.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindowmanager.mm
@@ -92,7 +92,8 @@ void QCocoaWindowManager::modalSessionChanged()
if (NSApp.modalWindow) {
// Lower window to that of the modal windows, but no less
nativeWindow.level = NSModalPanelWindowLevel;
- [nativeWindow orderBack:nil];
+ if ([nativeWindow isVisible])
+ [nativeWindow orderBack:nil];
} else {
// Restore window's natural window level, whatever that was
nativeWindow.level = naturalWindowLevel;
diff --git a/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp
index c8a1ddf9b9..674f579b4f 100644
--- a/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp
@@ -265,6 +265,7 @@ bool QEglFSIntegration::hasCapability(QPlatformIntegration::Capability cap) cons
case RasterGLSurface: return false;
#endif
case WindowManagement: return false;
+ case OpenGLOnRasterSurface: return true;
default: return QPlatformIntegration::hasCapability(cap);
}
}
diff --git a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp
index c1d5af47aa..1fed182882 100644
--- a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp
@@ -64,7 +64,6 @@ QEglFSWindow::QEglFSWindow(QWindow *w)
m_backingStore(0),
m_rasterCompositingContext(0),
#endif
- m_raster(false),
m_winId(0),
m_surface(EGL_NO_SURFACE),
m_window(0),
@@ -94,11 +93,6 @@ void QEglFSWindow::create()
m_winId = newWId();
- // Save the original surface type before changing to OpenGLSurface.
- m_raster = (window()->surfaceType() == QSurface::RasterSurface);
- if (m_raster) // change to OpenGL, but not for RasterGLSurface
- window()->setSurfaceType(QSurface::OpenGLSurface);
-
if (window()->type() == Qt::Desktop) {
QRect fullscreenRect(QPoint(), screen()->availableGeometry().size());
QWindowSystemInterface::handleGeometryChange(window(), fullscreenRect);
@@ -329,7 +323,8 @@ QEglFSScreen *QEglFSWindow::screen() const
bool QEglFSWindow::isRaster() const
{
- return m_raster || window()->surfaceType() == QSurface::RasterGLSurface;
+ const QWindow::SurfaceType type = window()->surfaceType();
+ return type == QSurface::RasterSurface || type == QSurface::RasterGLSurface;
}
#ifndef QT_NO_OPENGL
diff --git a/src/plugins/platforms/eglfs/api/qeglfswindow_p.h b/src/plugins/platforms/eglfs/api/qeglfswindow_p.h
index b0091e2a62..be2a0630d3 100644
--- a/src/plugins/platforms/eglfs/api/qeglfswindow_p.h
+++ b/src/plugins/platforms/eglfs/api/qeglfswindow_p.h
@@ -118,7 +118,6 @@ protected:
QOpenGLCompositorBackingStore *m_backingStore;
QOpenGLContext *m_rasterCompositingContext;
#endif
- bool m_raster;
WId m_winId;
EGLSurface m_surface;
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp
index 09a10bcc9c..2034632fb3 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp
@@ -331,6 +331,9 @@ void QEglFSKmsGbmScreen::flip()
static int zpos = qEnvironmentVariableIntValue("QT_QPA_EGLFS_KMS_ZPOS");
if (zpos)
drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->zposPropertyId, zpos);
+ static uint blendOp = uint(qEnvironmentVariableIntValue("QT_QPA_EGLFS_KMS_BLEND_OP"));
+ if (blendOp)
+ drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->blendOpPropertyId, blendOp);
}
#endif
} else {
diff --git a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp
index dc7ea08dc5..cb8962d4b8 100644
--- a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp
+++ b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp
@@ -188,7 +188,7 @@ static QImage::Format determineFormat(const fb_var_screeninfo &info, int depth)
if (memcmp(rgba, rgb888, 3 * sizeof(fb_bitfield)) == 0) {
format = QImage::Format_RGB888;
} else if (memcmp(rgba, bgr888, 3 * sizeof(fb_bitfield)) == 0) {
- format = QImage::Format_RGB888;
+ format = QImage::Format_BGR888;
// pixeltype = BGRPixel;
}
break;
diff --git a/src/plugins/platforms/offscreen/qoffscreencommon.cpp b/src/plugins/platforms/offscreen/qoffscreencommon.cpp
index f0eb69718a..eae25012c1 100644
--- a/src/plugins/platforms/offscreen/qoffscreencommon.cpp
+++ b/src/plugins/platforms/offscreen/qoffscreencommon.cpp
@@ -77,7 +77,8 @@ public:
if (containing != previous)
QWindowSystemInterface::handleEnterLeaveEvent(containing, previous, local, pos);
- QWindowSystemInterface::handleMouseEvent(containing, local, pos, QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers());
+ QWindowSystemInterface::handleMouseEvent(containing, local, pos, QGuiApplication::mouseButtons(), Qt::NoButton,
+ QEvent::MouseMove, QGuiApplication::keyboardModifiers(), Qt::MouseEventSynthesizedByQt);
QOffscreenScreen::windowContainingCursor = containing ? containing->handle() : 0;
}
diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
index 56131dcc48..a9b5860187 100644
--- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
+++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
@@ -636,7 +636,7 @@ void QQnxScreenEventHandler::handleDisplayEvent(screen_event_t event)
// We never remove the primary display, the qpa plugin doesn't support that and it crashes.
// To support it, this would be needed:
// - Adjust all qnx qpa code which uses screens
- // - Make QWidgetBackingStore not dereference a null paint device
+ // - Make QWidgetRepaintManager not dereference a null paint device
// - Create platform resources ( QQnxWindow ) for all QWindow because they would be deleted
// when you delete the screen
diff --git a/src/plugins/platforms/vnc/qvncclient.cpp b/src/plugins/platforms/vnc/qvncclient.cpp
index 9dfe873927..3a373a5e4b 100644
--- a/src/plugins/platforms/vnc/qvncclient.cpp
+++ b/src/plugins/platforms/vnc/qvncclient.cpp
@@ -587,9 +587,18 @@ void QVncClient::frameBufferUpdateRequest()
void QVncClient::pointerEvent()
{
QRfbPointerEvent ev;
+ static int buttonState = Qt::NoButton;
if (ev.read(m_clientSocket)) {
- const QPoint pos = m_server->screen()->geometry().topLeft() + QPoint(ev.x, ev.y);
- QWindowSystemInterface::handleMouseEvent(0, pos, pos, ev.buttons, QGuiApplication::keyboardModifiers());
+ const QPointF pos = m_server->screen()->geometry().topLeft() + QPoint(ev.x, ev.y);
+ int buttonStateChange = buttonState ^ int(ev.buttons);
+ QEvent::Type type = QEvent::MouseMove;
+ if (int(ev.buttons) > buttonState)
+ type = QEvent::MouseButtonPress;
+ else if (int(ev.buttons) < buttonState)
+ type = QEvent::MouseButtonRelease;
+ QWindowSystemInterface::handleMouseEvent(nullptr, pos, pos, ev.buttons, Qt::MouseButton(buttonStateChange),
+ type, QGuiApplication::keyboardModifiers());
+ buttonState = int(ev.buttons);
m_handleMsg = false;
}
}
diff --git a/src/plugins/platforms/wasm/qwasmintegration.cpp b/src/plugins/platforms/wasm/qwasmintegration.cpp
index 116612c286..1e9f68027c 100644
--- a/src/plugins/platforms/wasm/qwasmintegration.cpp
+++ b/src/plugins/platforms/wasm/qwasmintegration.cpp
@@ -168,6 +168,7 @@ bool QWasmIntegration::hasCapability(QPlatformIntegration::Capability cap) const
case RasterGLSurface: return false; // to enable this you need to fix qopenglwidget and quickwidget for wasm
case MultipleWindows: return true;
case WindowManagement: return true;
+ case OpenGLOnRasterSurface: return true;
default: return QPlatformIntegration::hasCapability(cap);
}
}
diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp
index 24526bad2c..101db75d0b 100644
--- a/src/plugins/platforms/windows/qwindowsglcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp
@@ -876,10 +876,6 @@ QWindowsOpenGLContextFormat QWindowsOpenGLContextFormat::current()
result.options |= QSurfaceFormat::DeprecatedFunctions;
if (value & GL_CONTEXT_FLAG_DEBUG_BIT)
result.options |= QSurfaceFormat::DebugContext;
- value = 0;
- QOpenGLStaticContext::opengl32.glGetIntegerv(RESET_NOTIFICATION_STRATEGY_ARB, &value);
- if (value == LOSE_CONTEXT_ON_RESET_ARB)
- result.options |= QSurfaceFormat::ResetNotification;
if (result.version < 0x0302)
return result;
// v3.2 onwards: Profiles
@@ -889,6 +885,13 @@ QWindowsOpenGLContextFormat QWindowsOpenGLContextFormat::current()
result.profile = QSurfaceFormat::CoreProfile;
else if (value & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)
result.profile = QSurfaceFormat::CompatibilityProfile;
+ if (result.version < 0x0400)
+ return result;
+ // v4.0 onwards
+ value = 0;
+ QOpenGLStaticContext::opengl32.glGetIntegerv(RESET_NOTIFICATION_STRATEGY_ARB, &value);
+ if (value == LOSE_CONTEXT_ON_RESET_ARB)
+ result.options |= QSurfaceFormat::ResetNotification;
return result;
}
diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp
index 282c0b107e..8cd09a34eb 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.cpp
+++ b/src/plugins/platforms/windows/qwindowsscreen.cpp
@@ -256,15 +256,6 @@ QWindow *QWindowsScreen::windowAt(const QPoint &screenPoint, unsigned flags)
return result;
}
-qreal QWindowsScreen::pixelDensity() const
-{
- // QTBUG-49195: Use logical DPI instead of physical DPI to calculate
- // the pixel density since it is reflects the Windows UI scaling.
- // High DPI auto scaling should be disabled when the user chooses
- // small fonts on a High DPI monitor, resulting in lower logical DPI.
- return qMax(1, qRound(logicalDpi().first / 96));
-}
-
/*!
\brief Determine siblings in a virtual desktop system.
diff --git a/src/plugins/platforms/windows/qwindowsscreen.h b/src/plugins/platforms/windows/qwindowsscreen.h
index 0ccebf6d71..2fd56f53cf 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.h
+++ b/src/plugins/platforms/windows/qwindowsscreen.h
@@ -87,7 +87,7 @@ public:
QImage::Format format() const override { return m_data.format; }
QSizeF physicalSize() const override { return m_data.physicalSizeMM; }
QDpi logicalDpi() const override { return m_data.dpi; }
- qreal pixelDensity() const override;
+ QDpi logicalBaseDpi() const override { return QDpi(96, 96); };
qreal devicePixelRatio() const override { return 1.0; }
qreal refreshRate() const override { return m_data.refreshRateHz; }
QString name() const override { return m_data.name; }
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index e80eefc34d..0a97305dd4 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -2674,7 +2674,8 @@ bool QWindowsWindow::handleNonClientHitTest(const QPoint &globalPos, LRESULT *re
// QTBUG-32663, suppress resize cursor for fixed size windows.
const QWindow *w = window();
if (!w->isTopLevel() // Task 105852, minimized windows need to respond to user input.
- || !(m_windowState & ~Qt::WindowActive)
+ || (m_windowState != Qt::WindowNoState)
+ || !isActive()
|| (m_data.flags & Qt::FramelessWindowHint)) {
return false;
}
@@ -2694,12 +2695,10 @@ bool QWindowsWindow::handleNonClientHitTest(const QPoint &globalPos, LRESULT *re
return true;
}
if (localPos.y() < 0) {
- const QMargins margins = frameMargins();
- const int topResizeBarPos = margins.left() - margins.top();
- if (localPos.y() < topResizeBarPos) {
+ const int topResizeBarPos = -frameMargins().top();
+ if (localPos.y() >= topResizeBarPos)
*result = HTCAPTION; // Extend caption over top resize bar, let's user move the window.
- return true;
- }
+ return true;
}
}
if (fixedWidth && (localPos.x() < 0 || localPos.x() >= size.width())) {
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
index f26f698e76..5e5fefca90 100644
--- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
@@ -163,10 +163,12 @@ static void updateFormatFromContext(QSurfaceFormat &format)
format.setOption(QSurfaceFormat::StereoBuffers);
if (format.renderableType() == QSurfaceFormat::OpenGL) {
- GLint value = 0;
- glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &value);
- if (value == GL_LOSE_CONTEXT_ON_RESET_ARB)
- format.setOption(QSurfaceFormat::ResetNotification);
+ if (format.version() >= qMakePair(4, 0)) {
+ GLint value = 0;
+ glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &value);
+ if (value == GL_LOSE_CONTEXT_ON_RESET_ARB)
+ format.setOption(QSurfaceFormat::ResetNotification);
+ }
if (format.version() < qMakePair(3, 0)) {
format.setOption(QSurfaceFormat::DeprecatedFunctions);
@@ -175,7 +177,7 @@ static void updateFormatFromContext(QSurfaceFormat &format)
// Version 3.0 onwards - check if it includes deprecated functionality or is
// a debug context
- value = 0;
+ GLint value = 0;
glGetIntegerv(GL_CONTEXT_FLAGS, &value);
if (!(value & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT))
format.setOption(QSurfaceFormat::DeprecatedFunctions);
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index cac6345b66..e51c3d0502 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -66,14 +66,10 @@
#include <errno.h>
#include <xcb/xfixes.h>
-#if QT_CONFIG(xkb)
#define explicit dont_use_cxx_explicit
#include <xcb/xkb.h>
#undef explicit
-#endif
-#if QT_CONFIG(xcb_xinput)
#include <xcb/xinput.h>
-#endif
QT_BEGIN_NAMESPACE
@@ -88,12 +84,6 @@ Q_LOGGING_CATEGORY(lcQpaKeyboard, "qt.qpa.xkeyboard")
Q_LOGGING_CATEGORY(lcQpaClipboard, "qt.qpa.clipboard")
Q_LOGGING_CATEGORY(lcQpaXDnd, "qt.qpa.xdnd")
-// this event type was added in libxcb 1.10,
-// but we support also older version
-#ifndef XCB_GE_GENERIC
-#define XCB_GE_GENERIC 35
-#endif
-
QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGrabServer, xcb_visualid_t defaultVisualId, const char *displayName)
: QXcbBasicConnection(displayName)
, m_canGrabServer(canGrabServer)
@@ -112,12 +102,10 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
initializeScreens();
-#if QT_CONFIG(xcb_xinput)
if (hasXInput2()) {
xi2SetupDevices();
xi2SelectStateEvents();
}
-#endif
m_wmSupport.reset(new QXcbWMSupport(this));
m_keyboard = new QXcbKeyboard(this);
@@ -518,7 +506,6 @@ Qt::MouseButton QXcbConnection::translateMouseButton(xcb_button_t s)
}
}
-#if QT_CONFIG(xkb)
namespace {
typedef union {
/* All XKB events share these fields. */
@@ -534,7 +521,6 @@ namespace {
xcb_xkb_state_notify_event_t state_notify;
} _xkb_event;
}
-#endif
void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
{
@@ -611,16 +597,12 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
HANDLE_PLATFORM_WINDOW_EVENT(xcb_client_message_event_t, window, handleClientMessageEvent);
}
case XCB_ENTER_NOTIFY:
-#if QT_CONFIG(xcb_xinput)
if (hasXInput2() && !xi2MouseEventsDisabled())
break;
-#endif
HANDLE_PLATFORM_WINDOW_EVENT(xcb_enter_notify_event_t, event, handleEnterNotifyEvent);
case XCB_LEAVE_NOTIFY:
-#if QT_CONFIG(xcb_xinput)
if (hasXInput2() && !xi2MouseEventsDisabled())
break;
-#endif
m_keyboard->updateXKBStateFromCore(reinterpret_cast<xcb_leave_notify_event_t *>(event)->state);
HANDLE_PLATFORM_WINDOW_EVENT(xcb_leave_notify_event_t, event, handleLeaveNotifyEvent);
case XCB_FOCUS_IN:
@@ -682,13 +664,11 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
}
break;
}
-#if QT_CONFIG(xcb_xinput)
case XCB_GE_GENERIC:
// Here the windowEventListener is invoked from xi2HandleEvent()
if (hasXInput2() && isXIEvent(event))
xi2HandleEvent(reinterpret_cast<xcb_ge_event_t *>(event));
break;
-#endif
default:
handled = false; // event type not recognized
break;
@@ -712,7 +692,6 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
auto change_event = reinterpret_cast<xcb_randr_screen_change_notify_event_t *>(event);
if (auto virtualDesktop = virtualDesktopForRootWindow(change_event->root))
virtualDesktop->handleScreenChange(change_event);
-#if QT_CONFIG(xkb)
} else if (isXkbType(response_type)) {
auto xkb_event = reinterpret_cast<_xkb_event *>(event);
if (xkb_event->any.deviceID == m_keyboard->coreDeviceId()) {
@@ -735,7 +714,6 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
break;
}
}
-#endif
} else {
handled = false; // event type still not recognized
}
@@ -912,7 +890,6 @@ bool QXcbConnection::compressEvent(xcb_generic_event_t *event) const
});
}
-#if QT_CONFIG(xcb_xinput)
// compress XI_* events
if (responseType == XCB_GE_GENERIC) {
if (!hasXInput2())
@@ -948,7 +925,6 @@ bool QXcbConnection::compressEvent(xcb_generic_event_t *event) const
return false;
}
-#endif
if (responseType == XCB_CONFIGURE_NOTIFY) {
// compress multiple configure notify events for the same window
@@ -978,7 +954,6 @@ bool QXcbConnection::isUserInputEvent(xcb_generic_event_t *event) const
if (isInputEvent)
return true;
-#if QT_CONFIG(xcb_xinput)
if (connection()->hasXInput2()) {
isInputEvent = isXIType(event, XCB_INPUT_BUTTON_PRESS) ||
isXIType(event, XCB_INPUT_BUTTON_RELEASE) ||
@@ -993,7 +968,6 @@ bool QXcbConnection::isUserInputEvent(xcb_generic_event_t *event) const
}
if (isInputEvent)
return true;
-#endif
if (eventType == XCB_CLIENT_MESSAGE) {
auto clientMessage = reinterpret_cast<const xcb_client_message_event_t *>(event);
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h
index 7cf25d41a6..a894944096 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.h
+++ b/src/plugins/platforms/xcb/qxcbconnection.h
@@ -104,10 +104,8 @@ public:
virtual void handleFocusInEvent(const xcb_focus_in_event_t *) {}
virtual void handleFocusOutEvent(const xcb_focus_out_event_t *) {}
virtual void handlePropertyNotifyEvent(const xcb_property_notify_event_t *) {}
-#if QT_CONFIG(xcb_xinput)
virtual void handleXIMouseEvent(xcb_ge_event_t *, Qt::MouseEventSource = Qt::MouseEventNotSynthesized) {}
virtual void handleXIEnterLeave(xcb_ge_event_t *) {}
-#endif
virtual QXcbWindow *toWindow() { return nullptr; }
};
@@ -225,7 +223,6 @@ public:
bool isUserInputEvent(xcb_generic_event_t *event) const;
-#if QT_CONFIG(xcb_xinput)
void xi2SelectStateEvents();
void xi2SelectDeviceEvents(xcb_window_t window);
void xi2SelectDeviceEventsCompatibility(xcb_window_t window);
@@ -236,7 +233,6 @@ public:
bool startSystemMoveResizeForTouchBegin(xcb_window_t window, const QPoint &point, int corner);
void abortSystemMoveResizeForTouch();
bool isTouchScreen(int id);
-#endif
bool canGrab() const { return m_canGrabServer; }
@@ -267,7 +263,6 @@ private:
inline bool timeGreaterThan(xcb_timestamp_t a, xcb_timestamp_t b) const
{ return static_cast<int32_t>(a - b) > 0 || b == XCB_CURRENT_TIME; }
-#if QT_CONFIG(xcb_xinput)
void xi2SetupDevice(void *info, bool removeExisting = true);
void xi2SetupDevices();
struct TouchDeviceData {
@@ -341,7 +336,6 @@ private:
uint32_t pointid;
int corner;
} m_startSystemMoveResizeInfo;
-#endif // QT_CONFIG(xcb_xinput)
const bool m_canGrabServer;
const xcb_visualid_t m_defaultVisualId;
@@ -389,12 +383,10 @@ private:
QTimer m_focusInTimer;
};
-#if QT_CONFIG(xcb_xinput)
#if QT_CONFIG(tabletevent)
Q_DECLARE_TYPEINFO(QXcbConnection::TabletData::ValuatorClassInfo, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(QXcbConnection::TabletData, Q_MOVABLE_TYPE);
#endif
-#endif
class QXcbConnectionGrabber
{
diff --git a/src/plugins/platforms/xcb/qxcbconnection_basic.cpp b/src/plugins/platforms/xcb/qxcbconnection_basic.cpp
index 9a028e5a7e..1ba4b4a1b9 100644
--- a/src/plugins/platforms/xcb/qxcbconnection_basic.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection_basic.cpp
@@ -45,14 +45,10 @@
#include <xcb/xfixes.h>
#include <xcb/xinerama.h>
#include <xcb/render.h>
-#if QT_CONFIG(xcb_xinput)
#include <xcb/xinput.h>
-#endif
-#if QT_CONFIG(xkb)
#define explicit dont_use_cxx_explicit
#include <xcb/xkb.h>
#undef explicit
-#endif
#if QT_CONFIG(xcb_xlib)
#define register /* C++17 deprecated register */
@@ -138,14 +134,7 @@ QXcbBasicConnection::QXcbBasicConnection(const char *displayName)
xcb_extension_t *extensions[] = {
&xcb_shm_id, &xcb_xfixes_id, &xcb_randr_id, &xcb_shape_id, &xcb_sync_id,
- &xcb_render_id,
-#if QT_CONFIG(xkb)
- &xcb_xkb_id,
-#endif
-#if QT_CONFIG(xcb_xinput)
- &xcb_input_id,
-#endif
- 0
+ &xcb_render_id, &xcb_xkb_id, &xcb_input_id, 0
};
for (xcb_extension_t **ext_it = extensions; *ext_it; ++ext_it)
@@ -160,10 +149,8 @@ QXcbBasicConnection::QXcbBasicConnection(const char *displayName)
initializeXinerama();
initializeXFixes();
initializeXRender();
-#if QT_CONFIG(xcb_xinput)
if (!qEnvironmentVariableIsSet("QT_XCB_NO_XI2"))
initializeXInput2();
-#endif
initializeXShape();
initializeXKB();
}
@@ -213,7 +200,6 @@ 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"
// - "pad1" and "pad" became "pad0"
@@ -240,7 +226,6 @@ bool QXcbBasicConnection::isXIType(xcb_generic_event_t *event, uint16_t type) co
auto *e = reinterpret_cast<qt_xcb_ge_event_t *>(event);
return e->event_type == type;
}
-#endif // QT_CONFIG(xcb_xinput)
bool QXcbBasicConnection::isXFixesType(uint responseType, int eventType) const
{
@@ -370,7 +355,6 @@ void QXcbBasicConnection::initializeXRandr()
m_xrandrFirstEvent = reply->first_event;
}
-#if QT_CONFIG(xcb_xinput)
void QXcbBasicConnection::initializeXInput2()
{
const xcb_query_extension_reply_t *reply = xcb_get_extension_data(m_xcbConnection, &xcb_input_id);
@@ -393,7 +377,6 @@ void QXcbBasicConnection::initializeXInput2()
m_xinputFirstEvent = reply->first_event;
m_xi2Minor = xinputQuery->minor_version;
}
-#endif
void QXcbBasicConnection::initializeXShape()
{
@@ -417,7 +400,6 @@ void QXcbBasicConnection::initializeXShape()
void QXcbBasicConnection::initializeXKB()
{
-#if QT_CONFIG(xkb)
const xcb_query_extension_reply_t *reply = xcb_get_extension_data(m_xcbConnection, &xcb_xkb_id);
if (!reply || !reply->present) {
qCWarning(lcQpaXcb, "XKeyboard extension not present on the X server");
@@ -439,7 +421,6 @@ void QXcbBasicConnection::initializeXKB()
m_hasXkb = true;
m_xkbFirstEvent = reply->first_event;
-#endif
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/qxcbconnection_basic.h b/src/plugins/platforms/xcb/qxcbconnection_basic.h
index 1bd4310562..109186f966 100644
--- a/src/plugins/platforms/xcb/qxcbconnection_basic.h
+++ b/src/plugins/platforms/xcb/qxcbconnection_basic.h
@@ -99,12 +99,10 @@ public:
bool hasXinerama() const { return m_hasXinerama; }
bool hasBigRequest() const;
-#if QT_CONFIG(xcb_xinput)
bool isAtLeastXI21() const { return m_xi2Enabled && m_xi2Minor >= 1; }
bool isAtLeastXI22() const { return m_xi2Enabled && m_xi2Minor >= 2; }
bool isXIEvent(xcb_generic_event_t *event) const;
bool isXIType(xcb_generic_event_t *event, uint16_t type) const;
-#endif
bool isXFixesType(uint responseType, int eventType) const;
bool isXRandrType(uint responseType, int eventType) const;
@@ -119,9 +117,7 @@ protected:
void initializeXShape();
void initializeXKB();
void initializeXSync();
-#if QT_CONFIG(xcb_xinput)
void initializeXInput2();
-#endif
private:
#if QT_CONFIG(xcb_xlib)
@@ -147,11 +143,9 @@ private:
QPair<int, int> m_xrenderVersion;
bool m_xi2Enabled = false;
-#if QT_CONFIG(xcb_xinput)
int m_xi2Minor = -1;
int m_xiOpCode = -1;
uint32_t m_xinputFirstEvent = 0;
-#endif
uint32_t m_xfixesFirstEvent = 0;
uint32_t m_xrandrFirstEvent = 0;
diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
index bc09fe2f91..4639185416 100644
--- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
@@ -997,8 +997,8 @@ void QXcbConnection::xi2HandleScrollEvent(void *event, ScrollingDevice &scrollin
QPoint global(fixed1616ToReal(xiDeviceEvent->root_x), fixed1616ToReal(xiDeviceEvent->root_y));
Qt::KeyboardModifiers modifiers = keyboard()->translateModifiers(xiDeviceEvent->mods.effective);
if (modifiers & Qt::AltModifier) {
- std::swap(angleDelta.rx(), angleDelta.ry());
- std::swap(rawDelta.rx(), rawDelta.ry());
+ angleDelta = angleDelta.transposed();
+ rawDelta = rawDelta.transposed();
}
qCDebug(lcQpaXInputEvents) << "scroll wheel @ window pos" << local << "delta px" << rawDelta << "angle" << angleDelta;
QWindowSystemInterface::handleWheelEvent(platformWindow->window(), xiDeviceEvent->time, local, global, rawDelta, angleDelta, modifiers);
@@ -1024,7 +1024,7 @@ void QXcbConnection::xi2HandleScrollEvent(void *event, ScrollingDevice &scrollin
QPoint global(fixed1616ToReal(xiDeviceEvent->root_x), fixed1616ToReal(xiDeviceEvent->root_y));
Qt::KeyboardModifiers modifiers = keyboard()->translateModifiers(xiDeviceEvent->mods.effective);
if (modifiers & Qt::AltModifier)
- std::swap(angleDelta.rx(), angleDelta.ry());
+ angleDelta = angleDelta.transposed();
qCDebug(lcQpaXInputEvents) << "scroll wheel (button" << xiDeviceEvent->detail << ") @ window pos" << local << "delta angle" << angleDelta;
QWindowSystemInterface::handleWheelEvent(platformWindow->window(), xiDeviceEvent->time, local, global, QPoint(), angleDelta, modifiers);
}
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
index d0e02ecdd1..3caee3f409 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
@@ -49,13 +49,7 @@
#include <private/qguiapplication_p.h>
-#if QT_CONFIG(xkb)
-#include <xkbcommon/xkbcommon-x11.h>
-#endif
-
-#if QT_CONFIG(xcb_xinput)
#include <xcb/xinput.h>
-#endif
QT_BEGIN_NAMESPACE
@@ -392,20 +386,16 @@ void QXcbKeyboard::updateKeymap()
xkb_context_set_log_level(m_xkbContext.get(), logLevel);
}
-#if QT_CONFIG(xkb)
if (connection()->hasXKB()) {
m_xkbKeymap.reset(xkb_x11_keymap_new_from_device(m_xkbContext.get(), xcb_connection(),
core_device_id, XKB_KEYMAP_COMPILE_NO_FLAGS));
if (m_xkbKeymap)
m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
} else {
-#endif
m_xkbKeymap.reset(keymapFromCore(keysymMods));
if (m_xkbKeymap)
m_xkbState.reset(xkb_state_new(m_xkbKeymap.get()));
-#if QT_CONFIG(xkb)
}
-#endif
if (!m_xkbKeymap) {
qCWarning(lcQpaKeyboard, "failed to compile a keymap");
@@ -428,7 +418,6 @@ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
return QXkbCommon::possibleKeys(m_xkbState.get(), event, m_superAsMeta, m_hyperAsMeta);
}
-#if QT_CONFIG(xkb)
void QXcbKeyboard::updateXKBState(xcb_xkb_state_notify_event_t *state)
{
if (m_config && connection()->hasXKB()) {
@@ -444,7 +433,6 @@ void QXcbKeyboard::updateXKBState(xcb_xkb_state_notify_event_t *state)
handleStateChanges(changedComponents);
}
}
-#endif
static xkb_layout_index_t lockedGroup(quint16 state)
{
@@ -473,7 +461,6 @@ void QXcbKeyboard::updateXKBStateFromCore(quint16 state)
}
}
-#if QT_CONFIG(xcb_xinput)
void QXcbKeyboard::updateXKBStateFromXI(void *modInfo, void *groupInfo)
{
if (m_config && !connection()->hasXKB()) {
@@ -491,7 +478,6 @@ void QXcbKeyboard::updateXKBStateFromXI(void *modInfo, void *groupInfo)
handleStateChanges(changedComponents);
}
}
-#endif
void QXcbKeyboard::handleStateChanges(xkb_state_component changedComponents)
{
@@ -541,7 +527,6 @@ void QXcbKeyboard::updateXKBMods()
QXcbKeyboard::QXcbKeyboard(QXcbConnection *connection)
: QXcbObject(connection)
{
-#if QT_CONFIG(xkb)
core_device_id = 0;
if (connection->hasXKB()) {
selectEvents();
@@ -551,11 +536,9 @@ QXcbKeyboard::QXcbKeyboard(QXcbConnection *connection)
return;
}
} else {
-#endif
m_key_symbols = xcb_key_symbols_alloc(xcb_connection());
-#if QT_CONFIG(xkb)
}
-#endif
+
updateKeymap();
}
@@ -573,7 +556,6 @@ void QXcbKeyboard::initialize()
void QXcbKeyboard::selectEvents()
{
-#if QT_CONFIG(xkb)
const uint16_t required_map_parts = (XCB_XKB_MAP_PART_KEY_TYPES |
XCB_XKB_MAP_PART_KEY_SYMS |
XCB_XKB_MAP_PART_MODIFIER_MAP |
@@ -604,12 +586,10 @@ void QXcbKeyboard::selectEvents()
free(error);
qCWarning(lcQpaXcb, "failed to select notify events from XKB");
}
-#endif
}
void QXcbKeyboard::updateVModMapping()
{
-#if QT_CONFIG(xkb)
xcb_xkb_get_names_value_list_t names_list;
memset(&vmod_masks, 0, sizeof(vmod_masks));
@@ -667,12 +647,10 @@ void QXcbKeyboard::updateVModMapping()
else if (qstrcmp(vmod_name, "Hyper") == 0)
vmod_masks.hyper = bit;
}
-#endif
}
void QXcbKeyboard::updateVModToRModMapping()
{
-#if QT_CONFIG(xkb)
xcb_xkb_get_map_map_t map;
memset(&rmod_masks, 0, sizeof(rmod_masks));
@@ -729,7 +707,6 @@ void QXcbKeyboard::updateVModToRModMapping()
else if (vmod_masks.hyper == bit)
rmod_masks.hyper = modmap;
}
-#endif
}
// Small helper: set modifier bit, if modifier position is valid
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.h b/src/plugins/platforms/xcb/qxcbkeyboard.h
index e35c82ad24..0ee08aeff2 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.h
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.h
@@ -43,14 +43,12 @@
#include "qxcbobject.h"
#include <xcb/xcb_keysyms.h>
-#if QT_CONFIG(xkb)
#define explicit dont_use_cxx_explicit
#include <xcb/xkb.h>
#undef explicit
-#endif
-#include <xkbcommon/xkbcommon.h>
#include <QtXkbCommonSupport/private/qxkbcommon_p.h>
+#include <xkbcommon/xkbcommon-x11.h>
#include <QEvent>
@@ -74,18 +72,14 @@ public:
void updateKeymap();
QList<int> possibleKeys(const QKeyEvent *event) const;
- // when XKEYBOARD not present on the X server
void updateXKBMods();
xkb_mod_mask_t xkbModMask(quint16 state);
void updateXKBStateFromCore(quint16 state);
-#if QT_CONFIG(xcb_xinput)
void updateXKBStateFromXI(void *modInfo, void *groupInfo);
-#endif
-#if QT_CONFIG(xkb)
- // when XKEYBOARD is present on the X server
+
int coreDeviceId() const { return core_device_id; }
void updateXKBState(xcb_xkb_state_notify_event_t *state);
-#endif
+
void handleStateChanges(xkb_state_component changedComponents);
protected:
@@ -97,10 +91,9 @@ protected:
typedef QMap<xcb_keysym_t, int> KeysymModifierMap;
struct xkb_keymap *keymapFromCore(const KeysymModifierMap &keysymMods);
- // when XKEYBOARD not present on the X server
void updateModifiers(const KeysymModifierMap &keysymMods);
KeysymModifierMap keysymsToModifiers();
- // when XKEYBOARD is present on the X server
+
void updateVModMapping();
void updateVModToRModMapping();
@@ -119,7 +112,6 @@ private:
_mod_masks rmod_masks;
- // when XKEYBOARD not present on the X server
xcb_key_symbols_t *m_key_symbols = nullptr;
struct _xkb_mods {
xkb_mod_index_t shift;
@@ -132,11 +124,9 @@ private:
xkb_mod_index_t mod5;
};
_xkb_mods xkb_mods;
-#if QT_CONFIG(xkb)
- // when XKEYBOARD is present on the X server
+
_mod_masks vmod_masks;
int core_device_id;
-#endif
QXkbCommon::ScopedXKBState m_xkbState;
QXkbCommon::ScopedXKBKeymap m_xkbKeymap;
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp
index 8c34bd9c91..0fe22bd318 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.cpp
+++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
@@ -660,10 +660,6 @@ QImage::Format QXcbScreen::format() const
int QXcbScreen::forcedDpi() const
{
- static const int overrideDpi = qEnvironmentVariableIntValue("QT_FONT_DPI");
- if (overrideDpi)
- return overrideDpi;
-
const int forcedDpi = m_virtualDesktop->forcedDpi();
if (forcedDpi > 0)
return forcedDpi;
@@ -679,11 +675,6 @@ QDpi QXcbScreen::logicalDpi() const
return m_virtualDesktop->dpi();
}
-qreal QXcbScreen::pixelDensity() const
-{
- return m_pixelDensity;
-}
-
QPlatformCursor *QXcbScreen::cursor() const
{
return m_cursor;
@@ -747,14 +738,6 @@ void QXcbScreen::updateGeometry(const QRect &geometry, uint8_t rotation)
if (m_sizeMillimeters.isEmpty())
m_sizeMillimeters = sizeInMillimeters(geometry.size(), m_virtualDesktop->dpi());
- qreal dpi = forcedDpi();
- if (dpi <= 0)
- dpi = geometry.width() / physicalSize().width() * qreal(25.4);
-
- // Use 128 as a reference DPI on small screens. This favors "small UI" over "large UI".
- qreal referenceDpi = physicalSize().width() <= 320 ? 128 : 96;
-
- m_pixelDensity = qMax(1, qRound(dpi/referenceDpi));
m_geometry = geometry;
m_availableGeometry = geometry & m_virtualDesktop->workArea();
QWindowSystemInterface::handleScreenGeometryChange(QPlatformScreen::screen(), m_geometry, m_availableGeometry);
diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h
index ec3b07bfb7..62931d2500 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.h
+++ b/src/plugins/platforms/xcb/qxcbscreen.h
@@ -161,7 +161,7 @@ public:
QImage::Format format() const override;
QSizeF physicalSize() const override { return m_sizeMillimeters; }
QDpi logicalDpi() const override;
- qreal pixelDensity() const override;
+ QDpi logicalBaseDpi() const override { return QDpi(96, 96); };
QPlatformCursor *cursor() const override;
qreal refreshRate() const override { return m_refreshRate; }
Qt::ScreenOrientation orientation() const override { return m_orientation; }
@@ -227,7 +227,6 @@ private:
Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
QXcbCursor *m_cursor;
int m_refreshRate = 60;
- int m_pixelDensity = 1;
QEdidParser m_edid;
};
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index 1d1a4eea1c..76d3545d35 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -67,9 +67,7 @@
#include <xcb/xcb_icccm.h>
#include <xcb/xfixes.h>
#include <xcb/shape.h>
-#if QT_CONFIG(xcb_xinput)
#include <xcb/xinput.h>
-#endif
#include <private/qguiapplication_p.h>
#include <private/qwindow_p.h>
@@ -492,14 +490,12 @@ void QXcbWindow::create()
atom(QXcbAtom::_XEMBED_INFO),
32, 2, (void *)data);
-#if QT_CONFIG(xcb_xinput)
if (connection()->hasXInput2()) {
if (connection()->xi2MouseEventsDisabled())
connection()->xi2SelectDeviceEventsCompatibility(m_window);
else
connection()->xi2SelectDeviceEvents(m_window);
}
-#endif
setWindowState(window()->windowStates());
setWindowFlags(window()->flags());
@@ -1895,9 +1891,7 @@ void QXcbWindow::handleButtonPressEvent(int event_x, int event_y, int root_x, in
QPoint global(root_x, root_y);
if (isWheel) {
-#if QT_CONFIG(xcb_xinput)
if (!connection()->isAtLeastXI21()) {
-#endif
QPoint angleDelta;
if (detail == 4)
angleDelta.setY(120);
@@ -1908,11 +1902,9 @@ void QXcbWindow::handleButtonPressEvent(int event_x, int event_y, int root_x, in
else if (detail == 7)
angleDelta.setX(-120);
if (modifiers & Qt::AltModifier)
- std::swap(angleDelta.rx(), angleDelta.ry());
+ angleDelta = angleDelta.transposed();
QWindowSystemInterface::handleWheelEvent(window(), timestamp, local, global, QPoint(), angleDelta, modifiers);
-#if QT_CONFIG(xcb_xinput)
}
-#endif
return;
}
@@ -1948,13 +1940,8 @@ static inline bool doCheckUnGrabAncestor(QXcbConnection *conn)
* not pressed, otherwise (e.g. on Alt+Tab) it can igonre important enter/leave events.
*/
if (conn) {
-
const bool mouseButtonsPressed = (conn->buttonState() != Qt::NoButton);
-#if QT_CONFIG(xcb_xinput)
return mouseButtonsPressed || (conn->hasXInput2() && !conn->xi2MouseEventsDisabled());
-#else
- return mouseButtonsPressed;
-#endif
}
return true;
}
@@ -1986,10 +1973,9 @@ void QXcbWindow::handleEnterNotifyEvent(int event_x, int event_y, int root_x, in
if (ignoreEnterEvent(mode, detail, connection()) || connection()->mousePressWindow())
return;
-#if QT_CONFIG(xcb_xinput)
+
// Updates scroll valuators, as user might have done some scrolling outside our X client.
connection()->xi2UpdateScrollingDevices();
-#endif
const QPoint local(event_x, event_y);
QWindowSystemInterface::handleEnterEvent(window(), local, global);
@@ -2064,7 +2050,6 @@ void QXcbWindow::handleMotionNotifyEvent(const xcb_motion_notify_event_t *event)
event->time, QEvent::MouseMove);
}
-#if QT_CONFIG(xcb_xinput)
static inline int fixed1616ToInt(xcb_input_fp1616_t val)
{
return int(qreal(val) / 0x10000);
@@ -2165,7 +2150,6 @@ void QXcbWindow::handleXIEnterLeave(xcb_ge_event_t *event)
break;
}
}
-#endif
QXcbWindow *QXcbWindow::toWindow() { return this; }
@@ -2301,14 +2285,12 @@ bool QXcbWindow::setMouseGrabEnabled(bool grab)
if (grab && !connection()->canGrab())
return false;
-#if QT_CONFIG(xcb_xinput)
if (connection()->hasXInput2() && !connection()->xi2MouseEventsDisabled()) {
bool result = connection()->xi2SetMouseGrabEnabled(m_window, grab);
if (grab && result)
connection()->setMouseGrabber(this);
return result;
}
-#endif
if (!grab) {
xcb_ungrab_pointer(xcb_connection(), XCB_TIME_CURRENT_TIME);
@@ -2376,7 +2358,7 @@ bool QXcbWindow::startSystemMoveResize(const QPoint &pos, int corner)
return false;
const QPoint globalPos = QHighDpi::toNativePixels(window()->mapToGlobal(pos), window()->screen());
-#if QT_CONFIG(xcb_xinput)
+
// ### FIXME QTBUG-53389
bool startedByTouch = connection()->startSystemMoveResizeForTouchBegin(m_window, globalPos, corner);
if (startedByTouch) {
@@ -2386,9 +2368,7 @@ bool QXcbWindow::startSystemMoveResize(const QPoint &pos, int corner)
return false;
}
// KWin, Openbox, AwesomeWM have been tested to work with _NET_WM_MOVERESIZE.
- } else
-#endif
- { // Started by mouse press.
+ } else { // Started by mouse press.
if (connection()->isUnity())
return false; // _NET_WM_MOVERESIZE on this WM is bouncy (WM bug?).
diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h
index 5de5974ca7..13b37db028 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.h
+++ b/src/plugins/platforms/xcb/qxcbwindow.h
@@ -137,10 +137,8 @@ public:
void handleFocusInEvent(const xcb_focus_in_event_t *event) override;
void handleFocusOutEvent(const xcb_focus_out_event_t *event) override;
void handlePropertyNotifyEvent(const xcb_property_notify_event_t *event) override;
-#if QT_CONFIG(xcb_xinput)
void handleXIMouseEvent(xcb_ge_event_t *, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized) override;
void handleXIEnterLeave(xcb_ge_event_t *) override;
-#endif
QXcbWindow *toWindow() override;
diff --git a/src/plugins/platforms/xcb/xcb-static/xcb-static.pro b/src/plugins/platforms/xcb/xcb-static/xcb-static.pro
deleted file mode 100644
index 078b275381..0000000000
--- a/src/plugins/platforms/xcb/xcb-static/xcb-static.pro
+++ /dev/null
@@ -1,80 +0,0 @@
-#
-# Statically compile in code for
-# libxcb-fixes, libxcb-randr, libxcb-shm, libxcb-sync, libxcb-image,
-# libxcb-keysyms, libxcb-icccm, libxcb-renderutil, libxcb-xkb,
-# libxcb-xinerama, libxcb-xinput
-#
-CONFIG += static
-
-XCB_DIR = $$QT_SOURCE_TREE/src/3rdparty/xcb
-
-MODULE_INCLUDEPATH += $$XCB_DIR/include $$XCB_DIR/sysinclude
-INCLUDEPATH += $$XCB_DIR/include/xcb
-
-QMAKE_USE += xcb/nolink
-
-# ignore compiler warnings in 3rdparty code
-QMAKE_CFLAGS_STATIC_LIB+=-w
-
-#
-# libxcb
-#
-LIBXCB_DIR = $$XCB_DIR/libxcb
-
-SOURCES += \
- $$LIBXCB_DIR/xfixes.c \
- $$LIBXCB_DIR/randr.c \
- $$LIBXCB_DIR/shm.c \
- $$LIBXCB_DIR/sync.c \
- $$LIBXCB_DIR/render.c \
- $$LIBXCB_DIR/shape.c \
- $$LIBXCB_DIR/xkb.c \
- $$LIBXCB_DIR/xinerama.c \
- $$LIBXCB_DIR/xinput.c
-
-#
-# xcb-util
-#
-XCB_UTIL_DIR = $$XCB_DIR/xcb-util
-
-
-SOURCES += \
- $$XCB_UTIL_DIR/xcb_aux.c \
- $$XCB_UTIL_DIR/atoms.c \
- $$XCB_UTIL_DIR/event.c
-
-#
-# xcb-util-image
-#
-XCB_IMAGE_DIR = $$XCB_DIR/xcb-util-image
-
-SOURCES += $$XCB_IMAGE_DIR/xcb_image.c
-
-#
-# xcb-util-keysyms
-#
-XCB_KEYSYMS_DIR = $$XCB_DIR/xcb-util-keysyms
-
-SOURCES += $$XCB_KEYSYMS_DIR/keysyms.c
-
-#
-# xcb-util-renderutil
-#
-
-XCB_RENDERUTIL_DIR = $$XCB_DIR/xcb-util-renderutil
-
-SOURCES += $$XCB_RENDERUTIL_DIR/util.c
-
-#
-# xcb-util-wm
-#
-XCB_WM_DIR = $$XCB_DIR/xcb-util-wm
-
-SOURCES += \
- $$XCB_WM_DIR/icccm.c
-
-OTHER_FILES = $$XCB_DIR/README
-
-TR_EXCLUDE += $$XCB_DIR/*
-
-load(qt_helper_lib)
diff --git a/src/plugins/platforms/xcb/xcb.pro b/src/plugins/platforms/xcb/xcb.pro
index 0d27645a60..1c43c5ca04 100644
--- a/src/plugins/platforms/xcb/xcb.pro
+++ b/src/plugins/platforms/xcb/xcb.pro
@@ -2,8 +2,6 @@ TEMPLATE = subdirs
CONFIG += ordered
QT_FOR_CONFIG += gui-private
-!qtConfig(system-xcb): SUBDIRS += xcb-static
-
SUBDIRS += xcb_qpa_lib.pro
SUBDIRS += xcb-plugin.pro
SUBDIRS += gl_integrations
diff --git a/src/plugins/platforms/xcb/xcb_qpa_lib.pro b/src/plugins/platforms/xcb/xcb_qpa_lib.pro
index 34c671c8c7..a5d05faa9c 100644
--- a/src/plugins/platforms/xcb/xcb_qpa_lib.pro
+++ b/src/plugins/platforms/xcb/xcb_qpa_lib.pro
@@ -35,6 +35,7 @@ SOURCES = \
qxcbeventdispatcher.cpp \
qxcbconnection_basic.cpp \
qxcbconnection_screens.cpp \
+ qxcbconnection_xi2.cpp \
qxcbatom.cpp
HEADERS = \
@@ -71,10 +72,6 @@ qtConfig(xcb-xlib) {
QMAKE_USE += xcb_xlib
}
-qtConfig(xcb-xinput) {
- SOURCES += qxcbconnection_xi2.cpp
-}
-
qtConfig(xcb-sm) {
QMAKE_USE += x11sm
SOURCES += qxcbsessionmanager.cpp
@@ -94,20 +91,19 @@ qtConfig(vulkan) {
qxcbvulkanwindow.h
}
-!qtConfig(system-xcb) {
- QMAKE_USE += xcb-static
-} else {
- qtConfig(xcb-xinput): QMAKE_USE += xcb_xinput
- QMAKE_USE += \
- xcb_icccm xcb_image xcb_keysyms xcb_randr xcb_render xcb_renderutil \
- xcb_shape xcb_shm xcb_sync xcb_xfixes xcb_xinerama
-}
-QMAKE_USE += xcb
+QMAKE_USE += \
+ xcb xcb_icccm xcb_image xcb_keysyms xcb_randr xcb_render xcb_renderutil \
+ xcb_shape xcb_shm xcb_sync xcb_xfixes xcb_xinerama xcb_xkb xkbcommon xkbcommon_x11
-QMAKE_USE += xkbcommon
-qtConfig(xkb) {
- QMAKE_USE += xkbcommon_x11
- qtConfig(system-xcb): QMAKE_USE += xcb_xkb
+qtConfig(system-xcb-xinput) {
+ QMAKE_USE += xcb_xinput
+} else {
+ # Use bundled xcb-xinput sources.
+ XCB_DIR = $$QT_SOURCE_TREE/src/3rdparty/xcb
+ INCLUDEPATH += $$XCB_DIR/include/
+ SOURCES += $$XCB_DIR/libxcb/xinput.c
+ # Ignore compiler warnings in 3rdparty C code.
+ QMAKE_CFLAGS+=-w
}
qtConfig(dlopen): QMAKE_USE += libdl
diff --git a/src/plugins/printsupport/cups/qppdprintdevice.cpp b/src/plugins/printsupport/cups/qppdprintdevice.cpp
index ea6336c4d1..90411f2a2c 100644
--- a/src/plugins/printsupport/cups/qppdprintdevice.cpp
+++ b/src/plugins/printsupport/cups/qppdprintdevice.cpp
@@ -41,7 +41,9 @@
#include "qcupsprintersupport_p.h"
+#if QT_CONFIG(mimetype)
#include <QtCore/QMimeDatabase>
+#endif
#include <qdebug.h>
#include "private/qcups_p.h" // Only needed for PDPK_*
diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm
index 968ca68619..ec3bb91ebf 100644
--- a/src/plugins/styles/mac/qmacstyle_mac.mm
+++ b/src/plugins/styles/mac/qmacstyle_mac.mm
@@ -2294,11 +2294,11 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW
}
break;
case PM_SmallIconSize:
- ret = int(QStyleHelper::dpiScaled(16.));
+ ret = int(QStyleHelper::dpiScaled(16., opt));
break;
case PM_LargeIconSize:
- ret = int(QStyleHelper::dpiScaled(32.));
+ ret = int(QStyleHelper::dpiScaled(32., opt));
break;
case PM_IconViewIconSize:
@@ -3899,6 +3899,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
CGContextScaleCTM(ctx, -1, 1);
CGContextTranslateCTM(ctx, -frameRect.left(), 0);
} else if (tabDirection == QMacStylePrivate::West && tp == QStyleOptionTab::Beginning) {
+ CGContextTranslateCTM(ctx, 0, opt->rect.top());
CGContextScaleCTM(ctx, 1, -1);
CGContextTranslateCTM(ctx, 0, -frameRect.right());
} else if (tabDirection == QMacStylePrivate::East && tp == QStyleOptionTab::End) {
diff --git a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp
index 6881ea8f16..c4ada66ca9 100644
--- a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp
+++ b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp
@@ -987,7 +987,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
XPThemeData theme(widget, 0, QWindowsXPStylePrivate::ToolBarTheme,
TP_DROPDOWNBUTTON);
if (theme.isValid()) {
- const QSizeF size = theme.size() * QStyleHelper::dpiScaled(1);
+ const QSizeF size = theme.size() * QStyleHelper::dpiScaled(1, option);
if (!size.isEmpty()) {
mbiw = qRound(size.width());
mbih = qRound(size.height());
@@ -2145,7 +2145,7 @@ QRect QWindowsVistaStyle::subControlRect(ComplexControl control, const QStyleOpt
const int x = cb->rect.x(), y = cb->rect.y(), wi = cb->rect.width(), he = cb->rect.height();
const int margin = cb->frame ? 3 : 0;
const int bmarg = cb->frame ? 2 : 0;
- const int arrowWidth = qRound(QStyleHelper::dpiScaled(16));
+ const int arrowWidth = qRound(QStyleHelper::dpiScaled(16, option));
const int arrowButtonWidth = bmarg + arrowWidth;
const int xpos = x + wi - arrowButtonWidth;
@@ -2179,7 +2179,7 @@ QRect QWindowsVistaStyle::subControlRect(ComplexControl control, const QStyleOpt
const int height = tb->rect.height();
const int width = tb->rect.width();
const int buttonWidth =
- qRound(qreal(GetSystemMetrics(SM_CXSIZE)) * factor - QStyleHelper::dpiScaled(4));
+ qRound(qreal(GetSystemMetrics(SM_CXSIZE)) * factor - QStyleHelper::dpiScaled(4, option));
const int frameWidth = proxy()->pixelMetric(PM_MdiSubWindowFrameWidth, option, widget);
const bool sysmenuHint = (tb->titleBarFlags & Qt::WindowSystemMenuHint) != 0;
@@ -2280,7 +2280,7 @@ int QWindowsVistaStyle::pixelMetric(PixelMetric metric, const QStyleOption *opti
int ret = QWindowsVistaStylePrivate::fixedPixelMetric(metric);
if (ret != QWindowsStylePrivate::InvalidMetric)
- return int(QStyleHelper::dpiScaled(ret));
+ return int(QStyleHelper::dpiScaled(ret, option));
return QWindowsXPStyle::pixelMetric(metric, option, widget);
}
diff --git a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp
index a331b2ee87..e2c5bdc924 100644
--- a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp
+++ b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp
@@ -1486,8 +1486,9 @@ case PE_Frame:
// Inner white border
p->setPen(QPen(option->palette.base().color(), 0));
- const auto topLevelAdjustment = QStyleHelper::dpiScaled(0.5);
- const auto bottomRightAdjustment = QStyleHelper::dpiScaled(-1);
+ const qreal dpi = QStyleHelper::dpi(option);
+ const auto topLevelAdjustment = QStyleHelper::dpiScaled(0.5, dpi);
+ const auto bottomRightAdjustment = QStyleHelper::dpiScaled(-1, dpi);
p->drawRect(QRectF(option->rect).adjusted(topLevelAdjustment, topLevelAdjustment,
bottomRightAdjustment, bottomRightAdjustment));
// Outer dark border
@@ -3313,7 +3314,8 @@ int QWindowsXPStyle::pixelMetric(PixelMetric pm, const QStyleOption *option, con
break;
case PM_SplitterWidth:
- res = qMax(int(QStyleHelper::dpiScaled(5.)), QApplication::globalStrut().width());
+ res = qMax(int(QStyleHelper::dpiScaled(5., option)),
+ QApplication::globalStrut().width());
break;
case PM_MdiSubWindowMinimizedWidth:
@@ -3322,13 +3324,13 @@ int QWindowsXPStyle::pixelMetric(PixelMetric pm, const QStyleOption *option, con
#if QT_CONFIG(toolbar)
case PM_ToolBarHandleExtent:
- res = int(QStyleHelper::dpiScaled(8.));
+ res = int(QStyleHelper::dpiScaled(8., option));
break;
#endif // QT_CONFIG(toolbar)
case PM_DockWidgetSeparatorExtent:
case PM_DockWidgetTitleMargin:
- res = int(QStyleHelper::dpiScaled(4.));
+ res = int(QStyleHelper::dpiScaled(4., option));
break;
case PM_ButtonShiftHorizontal:
@@ -3413,7 +3415,7 @@ QRect QWindowsXPStyle::subControlRect(ComplexControl cc, const QStyleOptionCompl
const bool isToolTitle = false;
const int height = tb->rect.height();
const int width = tb->rect.width();
- const int buttonMargin = int(QStyleHelper::dpiScaled(4));
+ const int buttonMargin = int(QStyleHelper::dpiScaled(4, option));
const qreal factor = QWindowsStylePrivate::nativeMetricScaleFactor(widget);
int buttonHeight = qRound(qreal(GetSystemMetrics(SM_CYSIZE)) * factor)
- buttonMargin;
@@ -3524,23 +3526,27 @@ QRect QWindowsXPStyle::subControlRect(ComplexControl cc, const QStyleOptionCompl
case CC_ComboBox:
if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
const int x = cmb->rect.x(), y = cmb->rect.y(), wi = cmb->rect.width(), he = cmb->rect.height();
- const int xpos = x + wi - qRound(QStyleHelper::dpiScaled(1 + 16));
+ const int xpos = x + wi - qRound(QStyleHelper::dpiScaled(1 + 16, option));
switch (subControl) {
case SC_ComboBoxFrame:
rect = cmb->rect;
break;
- case SC_ComboBoxArrow:
- rect = QRect(xpos, y + qRound(QStyleHelper::dpiScaled(1)),
- qRound(QStyleHelper::dpiScaled(16)), he - qRound(QStyleHelper::dpiScaled(2)));
+ case SC_ComboBoxArrow: {
+ const qreal dpi = QStyleHelper::dpi(option);
+ rect = QRect(xpos, y + qRound(QStyleHelper::dpiScaled(1, dpi)),
+ qRound(QStyleHelper::dpiScaled(16, dpi)),
+ he - qRound(QStyleHelper::dpiScaled(2, dpi)));
+ }
break;
case SC_ComboBoxEditField: {
- const int frame = qRound(QStyleHelper::dpiScaled(2));
+ const qreal dpi = QStyleHelper::dpi(option);
+ const int frame = qRound(QStyleHelper::dpiScaled(2, dpi));
rect = QRect(x + frame, y + frame,
- wi - qRound(QStyleHelper::dpiScaled(3 + 16)),
- he - qRound(QStyleHelper::dpiScaled(4)));
+ wi - qRound(QStyleHelper::dpiScaled(3 + 16, dpi)),
+ he - qRound(QStyleHelper::dpiScaled(4, dpi)));
}
break;