diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2016-03-22 07:24:57 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2016-03-22 07:28:42 +0100 |
commit | a02863234d76abb6c9f289026ae4ea3145924f30 (patch) | |
tree | aef6381d0000a78ba69ac80eb03739b1c8ca5fc3 /src/plugins | |
parent | e77b13621f0057374d83a2b884f03dd2e5b7b88c (diff) | |
parent | e4d79e1fdeb6b26ba0b12b578daacf7cd672b960 (diff) |
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts:
configure
mkspecs/common/wince/qplatformdefs.h
src/plugins/platforms/directfb/qdirectfbbackingstore.cpp
src/plugins/platforms/xcb/qxcbbackingstore.cpp
Change-Id: Ied4d31264a9afca9514b51a7eb1494c28712793c
Diffstat (limited to 'src/plugins')
145 files changed, 1426 insertions, 1599 deletions
diff --git a/src/plugins/bearer/android/src/src.pro b/src/plugins/bearer/android/src/src.pro index 1050601896..eb0738386c 100644 --- a/src/plugins/bearer/android/src/src.pro +++ b/src/plugins/bearer/android/src/src.pro @@ -1,11 +1,5 @@ -include(wrappers/wrappers.pri) - TARGET = qandroidbearer -PLUGIN_TYPE = bearer -PLUGIN_CLASS_NAME = QAndroidBearerEnginePlugin -load(qt_plugin) - QT = core-private network-private HEADERS += qandroidbearerengine.h \ @@ -15,3 +9,9 @@ HEADERS += qandroidbearerengine.h \ SOURCES += main.cpp \ qandroidbearerengine.cpp \ ../../qnetworksession_impl.cpp + +include(wrappers/wrappers.pri) + +PLUGIN_TYPE = bearer +PLUGIN_CLASS_NAME = QAndroidBearerEnginePlugin +load(qt_plugin) diff --git a/src/plugins/bearer/connman/connman.pro b/src/plugins/bearer/connman/connman.pro index efa13a6ebd..9f3fff304b 100644 --- a/src/plugins/bearer/connman/connman.pro +++ b/src/plugins/bearer/connman/connman.pro @@ -1,9 +1,5 @@ TARGET = qconnmanbearer -PLUGIN_TYPE = bearer -PLUGIN_CLASS_NAME = QConnmanEnginePlugin -load(qt_plugin) - QT = core network-private dbus CONFIG += link_pkgconfig @@ -21,3 +17,6 @@ SOURCES += main.cpp \ OTHER_FILES += connman.json +PLUGIN_TYPE = bearer +PLUGIN_CLASS_NAME = QConnmanEnginePlugin +load(qt_plugin) diff --git a/src/plugins/bearer/connman/qconnmanservice_linux.cpp b/src/plugins/bearer/connman/qconnmanservice_linux.cpp index 901af8dece..135aad4dec 100644 --- a/src/plugins/bearer/connman/qconnmanservice_linux.cpp +++ b/src/plugins/bearer/connman/qconnmanservice_linux.cpp @@ -162,7 +162,7 @@ void QConnmanManagerInterface::connectNotify(const QMetaMethod &signal) QLatin1String(CONNMAN_MANAGER_INTERFACE), QLatin1String("PropertyChanged"), this,SIGNAL(propertyChanged(QString,QDBusVariant)))) { - qWarning() << "PropertyChanged not connected"; + qWarning("PropertyChanged not connected"); } } @@ -173,7 +173,7 @@ void QConnmanManagerInterface::connectNotify(const QMetaMethod &signal) QLatin1String(CONNMAN_MANAGER_INTERFACE), QLatin1String("ServicesChanged"), this,SLOT(onServicesChanged(ConnmanMapList, QList<QDBusObjectPath>)))) { - qWarning() << "servicesChanged not connected"; + qWarning("servicesChanged not connected"); } } } diff --git a/src/plugins/bearer/corewlan/corewlan.pro b/src/plugins/bearer/corewlan/corewlan.pro index 674af0cbbe..ab0257aecd 100644 --- a/src/plugins/bearer/corewlan/corewlan.pro +++ b/src/plugins/bearer/corewlan/corewlan.pro @@ -1,9 +1,5 @@ TARGET = qcorewlanbearer -PLUGIN_TYPE = bearer -PLUGIN_CLASS_NAME = QCoreWlanEnginePlugin -load(qt_plugin) - QT = core-private network-private LIBS += -framework Foundation -framework SystemConfiguration @@ -21,3 +17,7 @@ SOURCES += main.cpp \ OBJECTIVE_SOURCES += qcorewlanengine.mm OTHER_FILES += corewlan.json + +PLUGIN_TYPE = bearer +PLUGIN_CLASS_NAME = QCoreWlanEnginePlugin +load(qt_plugin) diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm index aab8a5e05b..3f8f80fc85 100644 --- a/src/plugins/bearer/corewlan/qcorewlanengine.mm +++ b/src/plugins/bearer/corewlan/qcorewlanengine.mm @@ -164,6 +164,7 @@ void QScanThread::run() mutex.lock(); CWInterface *currentInterface = [CWInterface interfaceWithName: QCFString::toNSString(interfaceName)]; mutex.unlock(); + const bool currentInterfaceServiceActive = currentInterface.serviceActive; if (currentInterface.powerOn) { NSError *err = nil; @@ -178,7 +179,7 @@ void QScanThread::run() QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Undefined; bool known = isKnownSsid(networkSsid); - if (currentInterface.serviceActive) { + if (currentInterfaceServiceActive) { if( networkSsid == QCFString::toQString( [currentInterface ssid])) { state = QNetworkConfiguration::Active; } @@ -221,7 +222,7 @@ void QScanThread::run() interfaceName = ij.value(); } - if (currentInterface.serviceActive) { + if (currentInterfaceServiceActive) { if( networkSsid == QCFString::toQString([currentInterface ssid])) { state = QNetworkConfiguration::Active; } diff --git a/src/plugins/bearer/generic/generic.pro b/src/plugins/bearer/generic/generic.pro index d0e17380e3..f71a901341 100644 --- a/src/plugins/bearer/generic/generic.pro +++ b/src/plugins/bearer/generic/generic.pro @@ -1,9 +1,5 @@ TARGET = qgenericbearer -PLUGIN_TYPE = bearer -PLUGIN_CLASS_NAME = QGenericEnginePlugin -load(qt_plugin) - QT = core-private network-private HEADERS += qgenericengine.h \ @@ -15,3 +11,7 @@ SOURCES += qgenericengine.cpp \ main.cpp OTHER_FILES += generic.json + +PLUGIN_TYPE = bearer +PLUGIN_CLASS_NAME = QGenericEnginePlugin +load(qt_plugin) diff --git a/src/plugins/bearer/nativewifi/nativewifi.pro b/src/plugins/bearer/nativewifi/nativewifi.pro index e372c8ca05..da7f2da353 100644 --- a/src/plugins/bearer/nativewifi/nativewifi.pro +++ b/src/plugins/bearer/nativewifi/nativewifi.pro @@ -1,9 +1,5 @@ TARGET = qnativewifibearer -PLUGIN_TYPE = bearer -PLUGIN_CLASS_NAME = QNativeWifiEnginePlugin -load(qt_plugin) - QT = core-private network-private HEADERS += qnativewifiengine.h \ @@ -16,3 +12,7 @@ SOURCES += main.cpp \ ../qnetworksession_impl.cpp OTHER_FILES += nativewifi.json + +PLUGIN_TYPE = bearer +PLUGIN_CLASS_NAME = QNativeWifiEnginePlugin +load(qt_plugin) diff --git a/src/plugins/bearer/networkmanager/networkmanager.pro b/src/plugins/bearer/networkmanager/networkmanager.pro index b3a270615c..e71c93f66f 100644 --- a/src/plugins/bearer/networkmanager/networkmanager.pro +++ b/src/plugins/bearer/networkmanager/networkmanager.pro @@ -1,9 +1,5 @@ TARGET = qnmbearer -PLUGIN_TYPE = bearer -PLUGIN_CLASS_NAME = QNetworkManagerEnginePlugin -load(qt_plugin) - QT = core network-private dbus HEADERS += qnetworkmanagerservice.h \ @@ -19,3 +15,7 @@ SOURCES += main.cpp \ ../qnetworksession_impl.cpp OTHER_FILES += networkmanager.json + +PLUGIN_TYPE = bearer +PLUGIN_CLASS_NAME = QNetworkManagerEnginePlugin +load(qt_plugin) diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp index 8eebf86d67..6c3c661db6 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp @@ -136,7 +136,7 @@ bool QNetworkManagerInterface::setConnections() QList <QDBusObjectPath> QNetworkManagerInterface::getDevices() { if (devicesPathList.isEmpty()) { - //qWarning() << "using blocking call!"; + //qWarning("using blocking call!"); QDBusReply<QList<QDBusObjectPath> > reply = call(QLatin1String("GetDevices")); devicesPathList = reply.value(); } @@ -639,7 +639,7 @@ void QNetworkManagerInterfaceDeviceWireless::accessPointsFinished(QDBusPendingCa QList <QDBusObjectPath> QNetworkManagerInterfaceDeviceWireless::getAccessPoints() { if (accessPointsList.isEmpty()) { - //qWarning() << "Using blocking call!"; + //qWarning("Using blocking call!"); QDBusReply<QList<QDBusObjectPath> > reply = call(QLatin1String("GetAccessPoints")); accessPointsList = reply.value(); @@ -802,7 +802,7 @@ bool QNetworkManagerSettings::setConnections() QList <QDBusObjectPath> QNetworkManagerSettings::listConnections() { if (connectionsList.isEmpty()) { - //qWarning() << "Using blocking call!"; + //qWarning("Using blocking call!"); QDBusReply<QList<QDBusObjectPath> > reply = call(QLatin1String("ListConnections")); connectionsList = reply.value(); @@ -874,7 +874,7 @@ void QNetworkManagerSettingsConnection::slotSettingsRemoved() QNmSettingsMap QNetworkManagerSettingsConnection::getSettings() { if (settingsMap.isEmpty()) { - //qWarning() << "Using blocking call!"; + //qWarning("Using blocking call!"); QDBusReply<QNmSettingsMap> reply = call(QLatin1String("GetSettings")); settingsMap = reply.value(); } diff --git a/src/plugins/bearer/nla/nla.pro b/src/plugins/bearer/nla/nla.pro index bac7608477..32ff5446e5 100644 --- a/src/plugins/bearer/nla/nla.pro +++ b/src/plugins/bearer/nla/nla.pro @@ -1,9 +1,5 @@ TARGET = qnlabearer -PLUGIN_TYPE = bearer -PLUGIN_CLASS_NAME = QNlaEnginePlugin -load(qt_plugin) - QT = core core-private network network-private !wince* { @@ -22,3 +18,7 @@ SOURCES += main.cpp \ ../qnetworksession_impl.cpp OTHER_FILES += nla.json + +PLUGIN_TYPE = bearer +PLUGIN_CLASS_NAME = QNlaEnginePlugin +load(qt_plugin) diff --git a/src/plugins/bearer/nla/qnlaengine.cpp b/src/plugins/bearer/nla/qnlaengine.cpp index 0b765a8485..726e1efb92 100644 --- a/src/plugins/bearer/nla/qnlaengine.cpp +++ b/src/plugins/bearer/nla/qnlaengine.cpp @@ -110,10 +110,10 @@ static void printBlob(NLA_BLOB *blob) << "\tshared adapter name:" << blob->data.ICS.remote.sharedAdapterName; break; default: - qDebug() << "UNKNOWN BLOB TYPE"; + qDebug("UNKNOWN BLOB TYPE"); } - qDebug() << "===== END NLA_BLOB ====="; + qDebug("===== END NLA_BLOB ====="); } #endif diff --git a/src/plugins/generic/evdevkeyboard/evdevkeyboard.pro b/src/plugins/generic/evdevkeyboard/evdevkeyboard.pro index 101ea30bcc..d23ad3bad0 100644 --- a/src/plugins/generic/evdevkeyboard/evdevkeyboard.pro +++ b/src/plugins/generic/evdevkeyboard/evdevkeyboard.pro @@ -1,10 +1,5 @@ TARGET = qevdevkeyboardplugin -PLUGIN_TYPE = generic -PLUGIN_EXTENDS = - -PLUGIN_CLASS_NAME = QEvdevKeyboardPlugin -load(qt_plugin) - QT += core-private platformsupport-private gui-private SOURCES = main.cpp @@ -12,3 +7,7 @@ SOURCES = main.cpp OTHER_FILES += \ evdevkeyboard.json +PLUGIN_TYPE = generic +PLUGIN_EXTENDS = - +PLUGIN_CLASS_NAME = QEvdevKeyboardPlugin +load(qt_plugin) diff --git a/src/plugins/generic/evdevmouse/evdevmouse.pro b/src/plugins/generic/evdevmouse/evdevmouse.pro index 57a67ead8d..1a0bc08853 100644 --- a/src/plugins/generic/evdevmouse/evdevmouse.pro +++ b/src/plugins/generic/evdevmouse/evdevmouse.pro @@ -1,10 +1,5 @@ TARGET = qevdevmouseplugin -PLUGIN_TYPE = generic -PLUGIN_EXTENDS = - -PLUGIN_CLASS_NAME = QEvdevMousePlugin -load(qt_plugin) - QT += core-private platformsupport-private gui-private SOURCES = main.cpp @@ -12,3 +7,7 @@ SOURCES = main.cpp OTHER_FILES += \ evdevmouse.json +PLUGIN_TYPE = generic +PLUGIN_EXTENDS = - +PLUGIN_CLASS_NAME = QEvdevMousePlugin +load(qt_plugin) diff --git a/src/plugins/generic/evdevtablet/evdevtablet.pro b/src/plugins/generic/evdevtablet/evdevtablet.pro index 8ffc0db84d..aaf0ef4c67 100644 --- a/src/plugins/generic/evdevtablet/evdevtablet.pro +++ b/src/plugins/generic/evdevtablet/evdevtablet.pro @@ -1,13 +1,13 @@ TARGET = qevdevtabletplugin -PLUGIN_TYPE = generic -PLUGIN_EXTENDS = - -PLUGIN_CLASS_NAME = QEvdevTabletPlugin -load(qt_plugin) - SOURCES = main.cpp QT += core-private platformsupport-private gui-private OTHER_FILES += \ evdevtablet.json + +PLUGIN_TYPE = generic +PLUGIN_EXTENDS = - +PLUGIN_CLASS_NAME = QEvdevTabletPlugin +load(qt_plugin) diff --git a/src/plugins/generic/evdevtouch/evdevtouch.pro b/src/plugins/generic/evdevtouch/evdevtouch.pro index 1f4d1b7e93..4d61db4eb0 100644 --- a/src/plugins/generic/evdevtouch/evdevtouch.pro +++ b/src/plugins/generic/evdevtouch/evdevtouch.pro @@ -1,10 +1,5 @@ TARGET = qevdevtouchplugin -PLUGIN_TYPE = generic -PLUGIN_EXTENDS = - -PLUGIN_CLASS_NAME = QEvdevTouchScreenPlugin -load(qt_plugin) - SOURCES = main.cpp QT += core-private platformsupport-private gui-private @@ -12,3 +7,7 @@ QT += core-private platformsupport-private gui-private OTHER_FILES += \ evdevtouch.json +PLUGIN_TYPE = generic +PLUGIN_EXTENDS = - +PLUGIN_CLASS_NAME = QEvdevTouchScreenPlugin +load(qt_plugin) diff --git a/src/plugins/generic/libinput/libinput.pro b/src/plugins/generic/libinput/libinput.pro index 17dbb23ef0..335605d354 100644 --- a/src/plugins/generic/libinput/libinput.pro +++ b/src/plugins/generic/libinput/libinput.pro @@ -1,12 +1,12 @@ TARGET = qlibinputplugin -PLUGIN_TYPE = generic -PLUGIN_EXTENDS = - -PLUGIN_CLASS_NAME = QLibInputPlugin -load(qt_plugin) - QT += core-private platformsupport-private gui-private SOURCES = main.cpp OTHER_FILES = libinput.json + +PLUGIN_TYPE = generic +PLUGIN_EXTENDS = - +PLUGIN_CLASS_NAME = QLibInputPlugin +load(qt_plugin) diff --git a/src/plugins/generic/tslib/tslib.pro b/src/plugins/generic/tslib/tslib.pro index be6fc4fbea..200d231cc8 100644 --- a/src/plugins/generic/tslib/tslib.pro +++ b/src/plugins/generic/tslib/tslib.pro @@ -1,10 +1,5 @@ TARGET = qtslibplugin -PLUGIN_TYPE = generic -PLUGIN_EXTENDS = - -PLUGIN_CLASS_NAME = QTsLibPlugin -load(qt_plugin) - SOURCES = main.cpp QT += gui-private platformsupport-private @@ -12,3 +7,8 @@ QT += gui-private platformsupport-private LIBS += -lts OTHER_FILES += tslib.json + +PLUGIN_TYPE = generic +PLUGIN_EXTENDS = - +PLUGIN_CLASS_NAME = QTsLibPlugin +load(qt_plugin) diff --git a/src/plugins/generic/tuiotouch/qoscbundle.cpp b/src/plugins/generic/tuiotouch/qoscbundle.cpp index ef5ca5b5f1..26dabebd23 100644 --- a/src/plugins/generic/tuiotouch/qoscbundle.cpp +++ b/src/plugins/generic/tuiotouch/qoscbundle.cpp @@ -122,7 +122,7 @@ QOscBundle::QOscBundle(const QByteArray &data) if (size == 0) { // empty bundle; these are valid, but should they be allowed? the // spec is unclear on this... - qWarning() << "Empty bundle?"; + qWarning("Empty bundle?"); m_isValid = true; m_immediate = isImmediate; m_timeEpoch = oscTimeEpoch; @@ -152,7 +152,7 @@ QOscBundle::QOscBundle(const QByteArray &data) m_timePico = oscTimePico; m_messages.append(subMessage); } else { - qWarning() << "Invalid sub-message"; + qWarning("Invalid sub-message"); return; } } else if (subdata.startsWith(bundleIdentifier)) { @@ -166,7 +166,7 @@ QOscBundle::QOscBundle(const QByteArray &data) m_bundles.append(subBundle); } } else { - qWarning() << "Malformed sub-data!"; + qWarning("Malformed sub-data!"); return; } } diff --git a/src/plugins/generic/tuiotouch/qtuiohandler.cpp b/src/plugins/generic/tuiotouch/qtuiohandler.cpp index e2c4bf9dc4..6026e06b55 100644 --- a/src/plugins/generic/tuiotouch/qtuiohandler.cpp +++ b/src/plugins/generic/tuiotouch/qtuiohandler.cpp @@ -165,7 +165,7 @@ void QTuioHandler::processPackets() QList<QVariant> arguments = message.arguments(); if (arguments.count() == 0) { - qWarning() << "Ignoring TUIO message with no arguments"; + qWarning("Ignoring TUIO message with no arguments"); continue; } @@ -195,7 +195,7 @@ void QTuioHandler::process2DCurSource(const QOscMessage &message) } if (QMetaType::Type(arguments.at(1).type()) != QMetaType::QByteArray) { - qWarning() << "Ignoring malformed TUIO source message (bad argument type)"; + qWarning("Ignoring malformed TUIO source message (bad argument type)"); return; } diff --git a/src/plugins/generic/tuiotouch/tuiotouch.pro b/src/plugins/generic/tuiotouch/tuiotouch.pro index 5e53403f5b..ae2ccde058 100644 --- a/src/plugins/generic/tuiotouch/tuiotouch.pro +++ b/src/plugins/generic/tuiotouch/tuiotouch.pro @@ -1,10 +1,5 @@ TARGET = qtuiotouchplugin -PLUGIN_TYPE = generic -PLUGIN_EXTENDS = - -PLUGIN_CLASS_NAME = QTuioTouchPlugin -load(qt_plugin) - QT += \ core-private \ gui-private \ @@ -24,3 +19,8 @@ HEADERS += \ OTHER_FILES += \ tuiotouch.json + +PLUGIN_TYPE = generic +PLUGIN_EXTENDS = - +PLUGIN_CLASS_NAME = QTuioTouchPlugin +load(qt_plugin) diff --git a/src/plugins/imageformats/gif/gif.pro b/src/plugins/imageformats/gif/gif.pro index 2a5048bb1c..a361bc2532 100644 --- a/src/plugins/imageformats/gif/gif.pro +++ b/src/plugins/imageformats/gif/gif.pro @@ -1,11 +1,11 @@ TARGET = qgif -PLUGIN_TYPE = imageformats -PLUGIN_CLASS_NAME = QGifPlugin -load(qt_plugin) - include(../../../gui/image/qgifhandler.pri) INCLUDEPATH += ../../../gui/image SOURCES += $$PWD/main.cpp HEADERS += $$PWD/main.h OTHER_FILES += gif.json + +PLUGIN_TYPE = imageformats +PLUGIN_CLASS_NAME = QGifPlugin +load(qt_plugin) diff --git a/src/plugins/imageformats/ico/ico.pro b/src/plugins/imageformats/ico/ico.pro index 4250fcb4bc..60afdaed70 100644 --- a/src/plugins/imageformats/ico/ico.pro +++ b/src/plugins/imageformats/ico/ico.pro @@ -1,12 +1,12 @@ TARGET = qico -PLUGIN_TYPE = imageformats -PLUGIN_CLASS_NAME = QICOPlugin -load(qt_plugin) - QTDIR_build:REQUIRES = "!contains(QT_CONFIG, no-ico)" HEADERS += qicohandler.h main.h SOURCES += main.cpp \ qicohandler.cpp OTHER_FILES += ico.json + +PLUGIN_TYPE = imageformats +PLUGIN_CLASS_NAME = QICOPlugin +load(qt_plugin) diff --git a/src/plugins/imageformats/jpeg/jpeg.pro b/src/plugins/imageformats/jpeg/jpeg.pro index e33fde1cdb..526556179c 100644 --- a/src/plugins/imageformats/jpeg/jpeg.pro +++ b/src/plugins/imageformats/jpeg/jpeg.pro @@ -1,9 +1,5 @@ TARGET = qjpeg -PLUGIN_TYPE = imageformats -PLUGIN_CLASS_NAME = QJpegPlugin -load(qt_plugin) - QT += core-private QTDIR_build:REQUIRES = "!contains(QT_CONFIG, no-jpeg)" @@ -13,3 +9,7 @@ INCLUDEPATH += ../../../gui/image SOURCES += main.cpp HEADERS += main.h OTHER_FILES += jpeg.json + +PLUGIN_TYPE = imageformats +PLUGIN_CLASS_NAME = QJpegPlugin +load(qt_plugin) diff --git a/src/plugins/platforminputcontexts/compose/compose.pro b/src/plugins/platforminputcontexts/compose/compose.pro index a4b5280e64..86bdd4729b 100644 --- a/src/plugins/platforminputcontexts/compose/compose.pro +++ b/src/plugins/platforminputcontexts/compose/compose.pro @@ -1,10 +1,5 @@ TARGET = composeplatforminputcontextplugin -PLUGIN_TYPE = platforminputcontexts -PLUGIN_EXTENDS = - -PLUGIN_CLASS_NAME = QComposePlatformInputContextPlugin -load(qt_plugin) - QT += core-private gui-private DEFINES += X11_PREFIX='\\"$$QMAKE_X11_PREFIX\\"' @@ -27,3 +22,8 @@ contains(QT_CONFIG, xkbcommon-qt): { } OTHER_FILES += $$PWD/compose.json + +PLUGIN_TYPE = platforminputcontexts +PLUGIN_EXTENDS = - +PLUGIN_CLASS_NAME = QComposePlatformInputContextPlugin +load(qt_plugin) diff --git a/src/plugins/platforminputcontexts/ibus/ibus.pro b/src/plugins/platforminputcontexts/ibus/ibus.pro index 401be6d42f..9f6c848e6a 100644 --- a/src/plugins/platforminputcontexts/ibus/ibus.pro +++ b/src/plugins/platforminputcontexts/ibus/ibus.pro @@ -1,10 +1,5 @@ TARGET = ibusplatforminputcontextplugin -PLUGIN_TYPE = platforminputcontexts -PLUGIN_EXTENDS = - -PLUGIN_CLASS_NAME = QIbusPlatformInputContextPlugin -load(qt_plugin) - QT += dbus gui-private SOURCES += $$PWD/qibusplatforminputcontext.cpp \ $$PWD/qibusproxy.cpp \ @@ -18,3 +13,8 @@ HEADERS += $$PWD/qibusplatforminputcontext.h \ $$PWD/qibustypes.h OTHER_FILES += $$PWD/ibus.json + +PLUGIN_TYPE = platforminputcontexts +PLUGIN_EXTENDS = - +PLUGIN_CLASS_NAME = QIbusPlatformInputContextPlugin +load(qt_plugin) diff --git a/src/plugins/platforminputcontexts/ibus/main.cpp b/src/plugins/platforminputcontexts/ibus/main.cpp index b47c0b40de..2846f52c8c 100644 --- a/src/plugins/platforminputcontexts/ibus/main.cpp +++ b/src/plugins/platforminputcontexts/ibus/main.cpp @@ -59,7 +59,6 @@ QIBusPlatformInputContext *QIbusPlatformInputContextPlugin::create(const QString Q_UNUSED(paramList); if (system.compare(system, QLatin1String("ibus"), Qt::CaseInsensitive) == 0) { - qDBusRegisterMetaType<QIBusSerializable>(); qDBusRegisterMetaType<QIBusAttribute>(); qDBusRegisterMetaType<QIBusAttributeList>(); qDBusRegisterMetaType<QIBusText>(); diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp index 2523b0b5dc..994fe8386b 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp +++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp @@ -289,7 +289,7 @@ void QIBusPlatformInputContext::updatePreeditText(const QDBusVariant &text, uint void QIBusPlatformInputContext::surroundingTextRequired() { if (debug) - qDebug() << "surroundingTextRequired"; + qDebug("surroundingTextRequired"); d->needsSurroundingText = true; update(Qt::ImSurroundingText); } diff --git a/src/plugins/platforminputcontexts/ibus/qibustypes.cpp b/src/plugins/platforminputcontexts/ibus/qibustypes.cpp index a168836a06..ac82fa3931 100644 --- a/src/plugins/platforminputcontexts/ibus/qibustypes.cpp +++ b/src/plugins/platforminputcontexts/ibus/qibustypes.cpp @@ -50,13 +50,9 @@ QIBusSerializable::QIBusSerializable() { } -QIBusSerializable::~QIBusSerializable() +void QIBusSerializable::deserializeFrom(const QDBusArgument &argument) { -} - -const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusSerializable &object) -{ - argument >> object.name; + argument >> name; argument.beginMap(); while (!argument.atEnd()) { @@ -66,19 +62,18 @@ const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusSerializable argument >> key; argument >> value; argument.endMapEntry(); - object.attachments[key] = value.variant().value<QDBusArgument>(); + attachments[key] = value.variant().value<QDBusArgument>(); } argument.endMap(); - return argument; } -QDBusArgument &operator<<(QDBusArgument &argument, const QIBusSerializable &object) +void QIBusSerializable::serializeTo(QDBusArgument &argument) const { - argument << object.name; + argument << name; argument.beginMap(qMetaTypeId<QString>(), qMetaTypeId<QDBusVariant>()); - QHashIterator<QString, QDBusArgument> i(object.attachments); + QHashIterator<QString, QDBusArgument> i(attachments); while (i.hasNext()) { i.next(); @@ -91,7 +86,6 @@ QDBusArgument &operator<<(QDBusArgument &argument, const QIBusSerializable &obje argument.endMapEntry(); } argument.endMap(); - return argument; } QIBusAttribute::QIBusAttribute() @@ -103,43 +97,35 @@ QIBusAttribute::QIBusAttribute() name = "IBusAttribute"; } -QIBusAttribute::~QIBusAttribute() -{ -} - -QDBusArgument &operator<<(QDBusArgument &argument, const QIBusAttribute &attribute) +void QIBusAttribute::serializeTo(QDBusArgument &argument) const { argument.beginStructure(); - argument << static_cast<const QIBusSerializable &>(attribute); + QIBusSerializable::serializeTo(argument); - quint32 t = (quint32) attribute.type; + quint32 t = (quint32) type; argument << t; - argument << attribute.value; - argument << attribute.start; - argument << attribute.end; + argument << value; + argument << start; + argument << end; argument.endStructure(); - - return argument; } -const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusAttribute &attribute) +void QIBusAttribute::deserializeFrom(const QDBusArgument &argument) { argument.beginStructure(); - argument >> static_cast<QIBusSerializable &>(attribute); + QIBusSerializable::deserializeFrom(argument); quint32 t; argument >> t; - attribute.type = (QIBusAttribute::Type) t; - argument >> attribute.value; - argument >> attribute.start; - argument >> attribute.end; + type = (QIBusAttribute::Type) t; + argument >> value; + argument >> start; + argument >> end; argument.endStructure(); - - return argument; } QTextCharFormat QIBusAttribute::format() const @@ -187,34 +173,30 @@ QIBusAttributeList::QIBusAttributeList() name = "IBusAttrList"; } -QIBusAttributeList::~QIBusAttributeList() -{ -} - -QDBusArgument &operator<<(QDBusArgument &argument, const QIBusAttributeList &attrList) +void QIBusAttributeList::serializeTo(QDBusArgument &argument) const { argument.beginStructure(); - argument << static_cast<const QIBusSerializable &>(attrList); + QIBusSerializable::serializeTo(argument); argument.beginArray(qMetaTypeId<QDBusVariant>()); - for (int i = 0; i < attrList.attributes.size(); ++i) { + for (int i = 0; i < attributes.size(); ++i) { QVariant variant; - variant.setValue(attrList.attributes.at(i)); + variant.setValue(attributes.at(i)); argument << QDBusVariant (variant); } argument.endArray(); argument.endStructure(); - return argument; } -const QDBusArgument &operator>>(const QDBusArgument &arg, QIBusAttributeList &attrList) +void QIBusAttributeList::deserializeFrom(const QDBusArgument &arg) { qCDebug(qtQpaInputMethodsSerialize) << "QIBusAttributeList::fromDBusArgument()" << arg.currentSignature(); + arg.beginStructure(); - arg >> static_cast<QIBusSerializable &>(attrList); + QIBusSerializable::deserializeFrom(arg); arg.beginArray(); while (!arg.atEnd()) { @@ -223,12 +205,11 @@ const QDBusArgument &operator>>(const QDBusArgument &arg, QIBusAttributeList &at QIBusAttribute attr; var.variant().value<QDBusArgument>() >> attr; - attrList.attributes.append(attr); + attributes.append(std::move(attr)); } arg.endArray(); arg.endStructure(); - return arg; } QList<QInputMethodEvent::Attribute> QIBusAttributeList::imAttributes() const @@ -269,138 +250,115 @@ QIBusText::QIBusText() name = "IBusText"; } -QIBusText::~QIBusText() -{ -} - -QDBusArgument &operator<<(QDBusArgument &argument, const QIBusText &text) +void QIBusText::serializeTo(QDBusArgument &argument) const { argument.beginStructure(); - argument << static_cast<const QIBusSerializable &>(text); + QIBusSerializable::serializeTo(argument); - argument << text.text << text.attributes; + argument << text << attributes; argument.endStructure(); - return argument; } -const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusText &text) +void QIBusText::deserializeFrom(const QDBusArgument &argument) { qCDebug(qtQpaInputMethodsSerialize) << "QIBusText::fromDBusArgument()" << argument.currentSignature(); + argument.beginStructure(); - argument >> static_cast<QIBusSerializable &>(text); + QIBusSerializable::deserializeFrom(argument); - argument >> text.text; + argument >> text; QDBusVariant variant; argument >> variant; - variant.variant().value<QDBusArgument>() >> text.attributes; + variant.variant().value<QDBusArgument>() >> attributes; argument.endStructure(); - return argument; } QIBusEngineDesc::QIBusEngineDesc() - : engine_name(""), - longname(""), - description(""), - language(""), - license(""), - author(""), - icon(""), - layout(""), - rank(0), - hotkeys(""), - symbol(""), - setup(""), - layout_variant(""), - layout_option(""), - version(""), - textdomain(""), - iconpropkey("") + : rank(0) { name = "IBusEngineDesc"; } -QIBusEngineDesc::~QIBusEngineDesc() -{ -} - -QDBusArgument &operator<<(QDBusArgument &argument, const QIBusEngineDesc &desc) +void QIBusEngineDesc::serializeTo(QDBusArgument &argument) const { argument.beginStructure(); - argument << static_cast<const QIBusSerializable &>(desc); - - argument << desc.engine_name; - argument << desc.longname; - argument << desc.description; - argument << desc.language; - argument << desc.license; - argument << desc.author; - argument << desc.icon; - argument << desc.layout; - argument << desc.rank; - argument << desc.hotkeys; - argument << desc.symbol; - argument << desc.setup; - argument << desc.layout_variant; - argument << desc.layout_option; - argument << desc.version; - argument << desc.textdomain; - argument << desc.iconpropkey; + QIBusSerializable::serializeTo(argument); + + argument << engine_name; + argument << longname; + argument << description; + argument << language; + argument << license; + argument << author; + argument << icon; + argument << layout; + argument << rank; + argument << hotkeys; + argument << symbol; + argument << setup; + argument << layout_variant; + argument << layout_option; + argument << version; + argument << textdomain; + argument << iconpropkey; argument.endStructure(); - return argument; } -const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusEngineDesc &desc) +void QIBusEngineDesc::deserializeFrom(const QDBusArgument &argument) { qCDebug(qtQpaInputMethodsSerialize) << "QIBusEngineDesc::fromDBusArgument()" << argument.currentSignature(); argument.beginStructure(); - argument >> static_cast<QIBusSerializable &>(desc); - - argument >> desc.engine_name; - argument >> desc.longname; - argument >> desc.description; - argument >> desc.language; - argument >> desc.license; - argument >> desc.author; - argument >> desc.icon; - argument >> desc.layout; - argument >> desc.rank; - argument >> desc.hotkeys; - argument >> desc.symbol; - argument >> desc.setup; + QIBusSerializable::deserializeFrom(argument); + + argument >> engine_name; + argument >> longname; + argument >> description; + argument >> language; + argument >> license; + argument >> author; + argument >> icon; + argument >> layout; + argument >> rank; + argument >> hotkeys; + argument >> symbol; + argument >> setup; // Previous IBusEngineDesc supports the arguments between engine_name // and setup. - if (argument.currentSignature() == "") { - argument.endStructure(); - return argument; - } - argument >> desc.layout_variant; - argument >> desc.layout_option; + if (argument.currentSignature() == "") + goto olderThanV2; + argument >> layout_variant; + argument >> layout_option; // Previous IBusEngineDesc supports the arguments between engine_name // and layout_option. - if (argument.currentSignature() == "") { - argument.endStructure(); - return argument; - } - argument >> desc.version; - if (argument.currentSignature() == "") { - argument.endStructure(); - return argument; - } - argument >> desc.textdomain; - if (argument.currentSignature() == "") { - argument.endStructure(); - return argument; - } - argument >> desc.iconpropkey; - + if (argument.currentSignature() == "") + goto olderThanV3; + argument >> version; + if (argument.currentSignature() == "") + goto olderThanV4; + argument >> textdomain; + if (argument.currentSignature() == "") + goto olderThanV5; + argument >> iconpropkey; + // <-- insert new member streaming here (1/2) + goto newest; +olderThanV2: + layout_variant.clear(); + layout_option.clear(); +olderThanV3: + version.clear(); +olderThanV4: + textdomain.clear(); +olderThanV5: + iconpropkey.clear(); + // <-- insert new members here (2/2) +newest: argument.endStructure(); - return argument; } QT_END_NAMESPACE diff --git a/src/plugins/platforminputcontexts/ibus/qibustypes.h b/src/plugins/platforminputcontexts/ibus/qibustypes.h index 9dca7e3903..217cd836fc 100644 --- a/src/plugins/platforminputcontexts/ibus/qibustypes.h +++ b/src/plugins/platforminputcontexts/ibus/qibustypes.h @@ -54,13 +54,15 @@ class QIBusSerializable { public: QIBusSerializable(); - virtual ~QIBusSerializable(); + + void serializeTo(QDBusArgument &argument) const; + void deserializeFrom(const QDBusArgument &argument); QString name; QHash<QString, QDBusArgument> attachments; }; -class QIBusAttribute : public QIBusSerializable +class QIBusAttribute : private QIBusSerializable { public: enum Type { @@ -79,42 +81,53 @@ public: }; QIBusAttribute(); - ~QIBusAttribute(); QTextCharFormat format() const; + void serializeTo(QDBusArgument &argument) const; + void deserializeFrom(const QDBusArgument &argument); + Type type; quint32 value; quint32 start; quint32 end; }; +Q_DECLARE_TYPEINFO(QIBusAttribute, Q_MOVABLE_TYPE); -class QIBusAttributeList : public QIBusSerializable +class QIBusAttributeList : private QIBusSerializable { public: QIBusAttributeList(); - ~QIBusAttributeList(); QList<QInputMethodEvent::Attribute> imAttributes() const; + void serializeTo(QDBusArgument &argument) const; + void deserializeFrom(const QDBusArgument &argument); + QVector<QIBusAttribute> attributes; }; +Q_DECLARE_TYPEINFO(QIBusAttributeList, Q_MOVABLE_TYPE); -class QIBusText : public QIBusSerializable +class QIBusText : private QIBusSerializable { public: QIBusText(); - ~QIBusText(); + + void serializeTo(QDBusArgument &argument) const; + void deserializeFrom(const QDBusArgument &argument); QString text; QIBusAttributeList attributes; }; +Q_DECLARE_TYPEINFO(QIBusText, Q_MOVABLE_TYPE); -class QIBusEngineDesc : public QIBusSerializable +class QIBusEngineDesc : private QIBusSerializable { public: QIBusEngineDesc(); - ~QIBusEngineDesc(); + + void serializeTo(QDBusArgument &argument) const; + void deserializeFrom(const QDBusArgument &argument); QString engine_name; QString longname; @@ -134,25 +147,30 @@ public: QString textdomain; QString iconpropkey; }; +Q_DECLARE_TYPEINFO(QIBusEngineDesc, Q_MOVABLE_TYPE); -QDBusArgument &operator<<(QDBusArgument &argument, const QIBusSerializable &object); -const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusSerializable &object); - -QDBusArgument &operator<<(QDBusArgument &argument, const QIBusAttribute &attribute); -const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusAttribute &attribute); +inline QDBusArgument &operator<<(QDBusArgument &argument, const QIBusAttribute &attribute) +{ attribute.serializeTo(argument); return argument; } +inline const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusAttribute &attribute) +{ attribute.deserializeFrom(argument); return argument; } -QDBusArgument &operator<<(QDBusArgument &argument, const QIBusAttributeList &attributeList); -const QDBusArgument &operator>>(const QDBusArgument &arg, QIBusAttributeList &attrList); +inline QDBusArgument &operator<<(QDBusArgument &argument, const QIBusAttributeList &attributeList) +{ attributeList.serializeTo(argument); return argument; } +inline const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusAttributeList &attributeList) +{ attributeList.deserializeFrom(argument); return argument; } -QDBusArgument &operator<<(QDBusArgument &argument, const QIBusText &text); -const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusText &text); +inline QDBusArgument &operator<<(QDBusArgument &argument, const QIBusText &text) +{ text.serializeTo(argument); return argument; } +inline const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusText &text) +{ text.deserializeFrom(argument); return argument; } -QDBusArgument &operator<<(QDBusArgument &argument, const QIBusEngineDesc &desc); -const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusEngineDesc &desc); +inline QDBusArgument &operator<<(QDBusArgument &argument, const QIBusEngineDesc &desc) +{ desc.serializeTo(argument); return argument; } +inline const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusEngineDesc &desc) +{ desc.deserializeFrom(argument); return argument; } QT_END_NAMESPACE -Q_DECLARE_METATYPE(QIBusSerializable) Q_DECLARE_METATYPE(QIBusAttribute) Q_DECLARE_METATYPE(QIBusAttributeList) Q_DECLARE_METATYPE(QIBusText) diff --git a/src/plugins/platforms/android/android.pro b/src/plugins/platforms/android/android.pro index 3ba817bf5b..045e55ec65 100644 --- a/src/plugins/platforms/android/android.pro +++ b/src/plugins/platforms/android/android.pro @@ -1,13 +1,9 @@ TARGET = qtforandroid -PLUGIN_TYPE = platforms - # STATICPLUGIN needed because there's a Q_IMPORT_PLUGIN in androidjnimain.cpp # Yes, the plugin imports itself statically DEFINES += QT_STATICPLUGIN -load(qt_plugin) - LIBS += -ljnigraphics -landroid QT += core-private gui-private platformsupport-private @@ -79,6 +75,9 @@ HEADERS += $$PWD/qandroidplatformintegration.h \ android-style-assets: SOURCES += $$PWD/extract.cpp else: SOURCES += $$PWD/extract-dummy.cpp +PLUGIN_TYPE = platforms +load(qt_plugin) + #Non-standard install directory, QTBUG-29859 DESTDIR = $$DESTDIR/android target.path = $${target.path}/android diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp index e680a0ed34..064a0c095c 100644 --- a/src/plugins/platforms/android/androidjniinput.cpp +++ b/src/plugins/platforms/android/androidjniinput.cpp @@ -98,7 +98,7 @@ namespace QtAndroidInput { QJNIObjectPrivate::callStaticMethod<void>(applicationClass(), "resetSoftwareKeyboard"); #ifdef QT_DEBUG_ANDROID_IM_PROTOCOL - qDebug() << "@@@ RESETSOFTWAREKEYBOARD"; + qDebug("@@@ RESETSOFTWAREKEYBOARD"); #endif } @@ -106,7 +106,7 @@ namespace QtAndroidInput { QJNIObjectPrivate::callStaticMethod<void>(applicationClass(), "hideSoftwareKeyboard"); #ifdef QT_DEBUG_ANDROID_IM_PROTOCOL - qDebug() << "@@@ HIDESOFTWAREKEYBOARD"; + qDebug("@@@ HIDESOFTWAREKEYBOARD"); #endif } diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index 6340d47c18..516fe60c8c 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -521,7 +521,7 @@ static jboolean startQtApplication(JNIEnv *env, jobject /*object*/, jstring para } m_main = (Main)dlsym(m_mainLibraryHnd, "main"); } else { - qWarning() << "No main library was specified; searching entire process (this is slow!)"; + qWarning("No main library was specified; searching entire process (this is slow!)"); m_main = (Main)dlsym(RTLD_DEFAULT, "main"); } diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index b73be718c0..c09dfeda43 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -78,7 +78,7 @@ static jboolean beginBatchEdit(JNIEnv */*env*/, jobject /*thiz*/) return JNI_FALSE; #ifdef QT_DEBUG_ANDROID_IM_PROTOCOL - qDebug() << "@@@ BEGINBATCH"; + qDebug("@@@ BEGINBATCH"); #endif return m_androidInputContext->beginBatchEdit(); @@ -92,7 +92,7 @@ static jboolean endBatchEdit(JNIEnv */*env*/, jobject /*thiz*/) return JNI_FALSE; #ifdef QT_DEBUG_ANDROID_IM_PROTOCOL - qDebug() << "@@@ ENDBATCH"; + qDebug("@@@ ENDBATCH"); #endif return m_androidInputContext->endBatchEdit(); @@ -134,7 +134,7 @@ static jboolean finishComposingText(JNIEnv */*env*/, jobject /*thiz*/) return JNI_FALSE; #ifdef QT_DEBUG_ANDROID_IM_PROTOCOL - qDebug() << "@@@ FINISH"; + qDebug("@@@ FINISH"); #endif return m_androidInputContext->finishComposingText(); } @@ -256,7 +256,7 @@ static jboolean selectAll(JNIEnv */*env*/, jobject /*thiz*/) return JNI_FALSE; #ifdef QT_DEBUG_ANDROID_IM_PROTOCOL - qDebug() << "@@@ SELALL"; + qDebug("@@@ SELALL"); #endif return m_androidInputContext->selectAll(); } @@ -267,7 +267,7 @@ static jboolean cut(JNIEnv */*env*/, jobject /*thiz*/) return JNI_FALSE; #ifdef QT_DEBUG_ANDROID_IM_PROTOCOL - qDebug() << "@@@"; + qDebug("@@@"); #endif return m_androidInputContext->cut(); } @@ -278,7 +278,7 @@ static jboolean copy(JNIEnv */*env*/, jobject /*thiz*/) return JNI_FALSE; #ifdef QT_DEBUG_ANDROID_IM_PROTOCOL - qDebug() << "@@@"; + qDebug("@@@"); #endif return m_androidInputContext->copy(); } @@ -289,7 +289,7 @@ static jboolean copyURL(JNIEnv */*env*/, jobject /*thiz*/) return JNI_FALSE; #ifdef QT_DEBUG_ANDROID_IM_PROTOCOL - qDebug() << "@@@"; + qDebug("@@@"); #endif return m_androidInputContext->copyURL(); } @@ -300,7 +300,7 @@ static jboolean paste(JNIEnv */*env*/, jobject /*thiz*/) return JNI_FALSE; #ifdef QT_DEBUG_ANDROID_IM_PROTOCOL - qDebug() << "@@@"; + qDebug("@@@"); #endif return m_androidInputContext->paste(); } @@ -311,7 +311,7 @@ static jboolean updateCursorPosition(JNIEnv */*env*/, jobject /*thiz*/) return JNI_FALSE; #ifdef QT_DEBUG_ANDROID_IM_PROTOCOL - qDebug() << "@@@ UPDATECURSORPOS"; + qDebug("@@@ UPDATECURSORPOS"); #endif m_androidInputContext->updateCursorPosition(); return true; @@ -371,43 +371,43 @@ QAndroidInputContext::QAndroidInputContext() m_extractedTextClass = static_cast<jclass>(env->NewGlobalRef(clazz)); m_classConstructorMethodID = env->GetMethodID(m_extractedTextClass, "<init>", "()V"); if (Q_UNLIKELY(!m_classConstructorMethodID)) { - qCritical() << "GetMethodID failed"; + qCritical("GetMethodID failed"); return; } m_partialEndOffsetFieldID = env->GetFieldID(m_extractedTextClass, "partialEndOffset", "I"); if (Q_UNLIKELY(!m_partialEndOffsetFieldID)) { - qCritical() << "Can't find field partialEndOffset"; + qCritical("Can't find field partialEndOffset"); return; } m_partialStartOffsetFieldID = env->GetFieldID(m_extractedTextClass, "partialStartOffset", "I"); if (Q_UNLIKELY(!m_partialStartOffsetFieldID)) { - qCritical() << "Can't find field partialStartOffset"; + qCritical("Can't find field partialStartOffset"); return; } m_selectionEndFieldID = env->GetFieldID(m_extractedTextClass, "selectionEnd", "I"); if (Q_UNLIKELY(!m_selectionEndFieldID)) { - qCritical() << "Can't find field selectionEnd"; + qCritical("Can't find field selectionEnd"); return; } m_selectionStartFieldID = env->GetFieldID(m_extractedTextClass, "selectionStart", "I"); if (Q_UNLIKELY(!m_selectionStartFieldID)) { - qCritical() << "Can't find field selectionStart"; + qCritical("Can't find field selectionStart"); return; } m_startOffsetFieldID = env->GetFieldID(m_extractedTextClass, "startOffset", "I"); if (Q_UNLIKELY(!m_startOffsetFieldID)) { - qCritical() << "Can't find field startOffset"; + qCritical("Can't find field startOffset"); return; } m_textFieldID = env->GetFieldID(m_extractedTextClass, "text", "Ljava/lang/String;"); if (Q_UNLIKELY(!m_textFieldID)) { - qCritical() << "Can't find field text"; + qCritical("Can't find field text"); return; } qRegisterMetaType<QInputMethodEvent *>("QInputMethodEvent*"); diff --git a/src/plugins/platforms/android/qandroidplatformtheme.cpp b/src/plugins/platforms/android/qandroidplatformtheme.cpp index 7bed4a739a..f8d0b9c8ba 100644 --- a/src/plugins/platforms/android/qandroidplatformtheme.cpp +++ b/src/plugins/platforms/android/qandroidplatformtheme.cpp @@ -216,7 +216,7 @@ QJsonObject AndroidStyle::loadStyleData() } if (Q_UNLIKELY(!document.isObject())) { - qCritical() << "Style.json does not contain a valid style."; + qCritical("Style.json does not contain a valid style."); return QJsonObject(); } return document.object(); diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index fec1da334f..02d8b16110 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -1,10 +1,5 @@ TARGET = qcocoa -PLUGIN_TYPE = platforms -PLUGIN_CLASS_NAME = QCocoaIntegrationPlugin -!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - -load(qt_plugin) - OBJECTIVE_SOURCES += main.mm \ qcocoaintegration.mm \ qcocoatheme.mm \ @@ -110,5 +105,8 @@ OTHER_FILES += cocoa.json # DEFINES += QT_COCOA_ENABLE_ACCESSIBILITY_INSPECTOR # include ($$PWD/../../../../util/accessibilityinspector/accessibilityinspector.pri) -# Window debug support -#DEFINES += QT_COCOA_ENABLE_WINDOW_DEBUG + +PLUGIN_TYPE = platforms +PLUGIN_CLASS_NAME = QCocoaIntegrationPlugin +!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - +load(qt_plugin) diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm index bc4cb227a8..1faa806480 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm @@ -63,7 +63,7 @@ void QCocoaAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event) return; QMacAccessibilityElement *element = [QMacAccessibilityElement elementWithId: event->uniqueId()]; if (!element) { - qWarning() << "QCocoaAccessibility::notifyAccessibilityUpdate: invalid element"; + qWarning("QCocoaAccessibility::notifyAccessibilityUpdate: invalid element"); return; } @@ -277,7 +277,7 @@ NSArray *unignoredChildren(QAccessibleInterface *interface) if (element) [kids addObject: element]; else - qWarning() << "QCocoaAccessibility: invalid child"; + qWarning("QCocoaAccessibility: invalid child"); } return NSAccessibilityUnignoredChildren(kids); } diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index 0f8081715b..7128fb72c3 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -555,7 +555,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of - (id)accessibilityHitTest:(NSPoint)point { QAccessibleInterface *iface = QAccessible::accessibleInterface(axid); if (!iface || !iface->isValid()) { -// qDebug() << "Hit test: INVALID"; +// qDebug("Hit test: INVALID"); return NSAccessibilityUnignoredAncestor(self); } @@ -585,7 +585,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of QAccessibleInterface *iface = QAccessible::accessibleInterface(axid); if (!iface || !iface->isValid()) { - qWarning() << "FocusedUIElement for INVALID"; + qWarning("FocusedUIElement for INVALID"); return nil; } diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.h b/src/plugins/platforms/cocoa/qcocoabackingstore.h index 18673a3667..fa05626d18 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.h +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.h @@ -57,7 +57,11 @@ public: QPaintDevice *paintDevice() Q_DECL_OVERRIDE; void flush(QWindow *widget, const QRegion ®ion, const QPoint &offset) Q_DECL_OVERRIDE; +#ifndef QT_NO_OPENGL QImage toImage() const Q_DECL_OVERRIDE; +#else + QImage toImage() const; // No QPlatformBackingStore::toImage() for NO_OPENGL builds. +#endif void resize (const QSize &size, const QRegion &) Q_DECL_OVERRIDE; bool scroll(const QRegion &area, int dx, int dy) Q_DECL_OVERRIDE; void beginPaint(const QRegion ®ion) Q_DECL_OVERRIDE; diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.h b/src/plugins/platforms/cocoa/qcocoaglcontext.h index cca541e0e3..5bee708b76 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.h +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.h @@ -63,7 +63,7 @@ public: bool makeCurrent(QPlatformSurface *surface) Q_DECL_OVERRIDE; void doneCurrent() Q_DECL_OVERRIDE; - void (*getProcAddress(const QByteArray &procName)) () Q_DECL_OVERRIDE; + QFunctionPointer getProcAddress(const char *procName) Q_DECL_OVERRIDE; void update(); diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm index e4712d88bc..7a12969972 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm @@ -44,6 +44,7 @@ #include <QtCore/private/qcore_mac_p.h> #include <QtPlatformSupport/private/cglconvenience_p.h> #include <QtPlatformHeaders/qcocoanativecontext.h> +#include <dlfcn.h> #import <AppKit/AppKit.h> @@ -335,9 +336,9 @@ void QCocoaGLContext::doneCurrent() [NSOpenGLContext clearCurrentContext]; } -void (*QCocoaGLContext::getProcAddress(const QByteArray &procName))() +QFunctionPointer QCocoaGLContext::getProcAddress(const char *procName) { - return qcgl_getProcAddress(procName); + return (QFunctionPointer)dlsym(RTLD_DEFAULT, procName); } void QCocoaGLContext::update() diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.h b/src/plugins/platforms/cocoa/qcocoahelpers.h index 766561a264..ec2f7f8cf1 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.h +++ b/src/plugins/platforms/cocoa/qcocoahelpers.h @@ -57,6 +57,8 @@ QT_BEGIN_NAMESPACE +Q_DECLARE_LOGGING_CATEGORY(lcQpaCocoaWindow) + class QPixmap; class QString; diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm index b6b1862d80..c91c67fe79 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.mm +++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm @@ -77,6 +77,8 @@ QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(lcQpaCocoaWindow, "qt.qpa.cocoa.window"); + // // Conversion Functions // @@ -766,11 +768,11 @@ CGContextRef qt_mac_cg_context(QPaintDevice *pdev) if (data && data->classId() == QPlatformPixmap::RasterClass) { image = data->buffer(); } else { - qDebug() << "qt_mac_cg_context: Unsupported pixmap class"; + qDebug("qt_mac_cg_context: Unsupported pixmap class"); } } else if (pdev->devType() == QInternal::Widget) { // TODO test: image = static_cast<QImage *>(static_cast<const QWidget *>(pdev)->backingStore()->paintDevice()); - qDebug() << "qt_mac_cg_context: not implemented: Widget class"; + qDebug("qt_mac_cg_context: not implemented: Widget class"); } if (!image) diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index f98ddbb14f..c021a551a7 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -428,14 +428,18 @@ void QCocoaIntegration::updateScreens() } siblings << screen; } + + // Set virtual siblings list. All screens in mScreens are siblings, because we ignored the + // mirrors. Note that some of the screens we update the siblings list for here may be deleted + // below, but update anyway to keep the to-be-deleted screens out of the siblings list. + foreach (QCocoaScreen* screen, mScreens) + screen->setVirtualSiblings(siblings); + // Now the leftovers in remainingScreens are no longer current, so we can delete them. foreach (QCocoaScreen* screen, remainingScreens) { mScreens.removeOne(screen); destroyScreen(screen); } - // All screens in mScreens are siblings, because we ignored the mirrors. - foreach (QCocoaScreen* screen, mScreens) - screen->setVirtualSiblings(siblings); } QCocoaScreen *QCocoaIntegration::screenAtIndex(int index) diff --git a/src/plugins/platforms/cocoa/qcocoamenu.h b/src/plugins/platforms/cocoa/qcocoamenu.h index 64299c6cd2..64eeabcc2d 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.h +++ b/src/plugins/platforms/cocoa/qcocoamenu.h @@ -81,8 +81,6 @@ public: inline NSMenu *nsMenu() const { return m_nativeMenu; } - inline NSMenuItem *nsMenuItem() const - { return m_nativeItem; } inline bool isVisible() const { return m_visible; } @@ -91,11 +89,9 @@ public: QList<QCocoaMenuItem *> items() const; QList<QCocoaMenuItem *> merged() const; - void setMenuBar(QCocoaMenuBar *menuBar); - QCocoaMenuBar *menuBar() const; - void setContainingMenuItem(QCocoaMenuItem *menuItem); - QCocoaMenuItem *containingMenuItem() const; + void setAttachedItem(NSMenuItem *item); + NSMenuItem *attachedItem() const; private: QCocoaMenuItem *itemOrNull(int index) const; @@ -103,13 +99,10 @@ private: QList<QCocoaMenuItem *> m_menuItems; NSMenu *m_nativeMenu; - NSMenuItem *m_nativeItem; - NSObject *m_delegate; + NSMenuItem *m_attachedItem; bool m_enabled; bool m_visible; quintptr m_tag; - QCocoaMenuBar *m_menuBar; - QCocoaMenuItem *m_containingMenuItem; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index 8c576c7cbe..3fc98c071f 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -102,6 +102,28 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaMenuDelegate); return self; } +- (NSInteger)numberOfItemsInMenu:(NSMenu *)menu +{ + Q_ASSERT(m_menu->nsMenu() == menu); + return m_menu->items().count(); +} + +- (BOOL)menu:(NSMenu *)menu updateItem:(NSMenuItem *)item atIndex:(NSInteger)index shouldCancel:(BOOL)shouldCancel +{ + Q_UNUSED(index); + Q_ASSERT(m_menu->nsMenu() == menu); + if (shouldCancel) { + // TODO detach all submenus + return NO; + } + + QCocoaMenuItem *menuItem = reinterpret_cast<QCocoaMenuItem *>(item.tag); + if (m_menu->items().contains(menuItem)) { + if (QCocoaMenu *itemSubmenu = menuItem->menu()) + itemSubmenu->setAttachedItem(item); + } + return YES; +} - (void)menu:(NSMenu*)menu willHighlightItem:(NSMenuItem*)item { @@ -234,20 +256,16 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaMenuDelegate); QT_BEGIN_NAMESPACE QCocoaMenu::QCocoaMenu() : + m_attachedItem(0), m_enabled(true), m_visible(true), - m_tag(0), - m_menuBar(0), - m_containingMenuItem(0) + m_tag(0) { QMacAutoReleasePool pool; - m_delegate = [[QCocoaMenuDelegate alloc] initWithMenu:this]; - m_nativeItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]; m_nativeMenu = [[NSMenu alloc] initWithTitle:@"Untitled"]; [m_nativeMenu setAutoenablesItems:YES]; - m_nativeMenu.delegate = (QCocoaMenuDelegate *) m_delegate; - [m_nativeItem setSubmenu:m_nativeMenu]; + m_nativeMenu.delegate = [[QCocoaMenuDelegate alloc] initWithMenu:this]; } QCocoaMenu::~QCocoaMenu() @@ -257,14 +275,11 @@ QCocoaMenu::~QCocoaMenu() SET_COCOA_MENU_ANCESTOR(item, 0); } - if (m_containingMenuItem) - m_containingMenuItem->clearMenu(this); - QMacAutoReleasePool pool; - [m_nativeItem setSubmenu:nil]; + NSObject *delegate = m_nativeMenu.delegate; + m_nativeMenu.delegate = nil; + [delegate release]; [m_nativeMenu release]; - [m_delegate release]; - [m_nativeItem release]; } void QCocoaMenu::setText(const QString &text) @@ -272,7 +287,6 @@ void QCocoaMenu::setText(const QString &text) QMacAutoReleasePool pool; QString stripped = qt_mac_removeAmpersandEscapes(text); [m_nativeMenu setTitle:QCFString::toNSString(stripped)]; - [m_nativeItem setTitle:QCFString::toNSString(stripped)]; } void QCocoaMenu::setMinimumWidth(int width) @@ -313,17 +327,13 @@ void QCocoaMenu::insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem * void QCocoaMenu::insertNative(QCocoaMenuItem *item, QCocoaMenuItem *beforeItem) { - [item->nsItem() setTarget:m_delegate]; + item->nsItem().target = m_nativeMenu.delegate; if (!item->menu()) [item->nsItem() setAction:@selector(itemFired:)]; if (item->isMerged()) return; - if ([item->nsItem() menu]) { - qWarning("Menu item is already in a menu, remove it from the other menu first before inserting"); - return; - } // if the item we're inserting before is merged, skip along until // we find a non-merged real item to insert ahead of. while (beforeItem && beforeItem->isMerged()) { @@ -451,12 +461,11 @@ void QCocoaMenu::setEnabled(bool enabled) bool QCocoaMenu::isEnabled() const { - return [m_nativeItem isEnabled]; + return m_attachedItem ? [m_attachedItem isEnabled] : m_enabled; } void QCocoaMenu::setVisible(bool visible) { - [m_nativeItem setSubmenu:(visible ? m_nativeMenu : nil)]; m_visible = visible; } @@ -593,8 +602,6 @@ void QCocoaMenu::syncModalState(bool modal) if (!m_enabled) modal = true; - [m_nativeItem setEnabled:!modal]; - foreach (QCocoaMenuItem *item, m_menuItems) { if (item->menu()) { // recurse into submenus item->menu()->syncModalState(modal); @@ -605,25 +612,24 @@ void QCocoaMenu::syncModalState(bool modal) } } -void QCocoaMenu::setMenuBar(QCocoaMenuBar *menuBar) +void QCocoaMenu::setAttachedItem(NSMenuItem *item) { - m_menuBar = menuBar; - SET_COCOA_MENU_ANCESTOR(this, menuBar); -} + if (item == m_attachedItem) + return; -QCocoaMenuBar *QCocoaMenu::menuBar() const -{ - return m_menuBar; -} + if (m_attachedItem) + m_attachedItem.submenu = nil; + + m_attachedItem = item; + + if (m_attachedItem) + m_attachedItem.submenu = m_nativeMenu; -void QCocoaMenu::setContainingMenuItem(QCocoaMenuItem *menuItem) -{ - m_containingMenuItem = menuItem; } -QCocoaMenuItem *QCocoaMenu::containingMenuItem() const +NSMenuItem *QCocoaMenu::attachedItem() const { - return m_containingMenuItem; + return m_attachedItem; } QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.h b/src/plugins/platforms/cocoa/qcocoamenubar.h index 0521bcd430..7ce2059450 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.h +++ b/src/plugins/platforms/cocoa/qcocoamenubar.h @@ -77,10 +77,10 @@ private: static QCocoaMenuBar *findGlobalMenubar(); bool shouldDisable(QCocoaWindow *active) const; - void insertNativeMenu(QCocoaMenu *menu, QCocoaMenu *beforeMenu); - void removeNativeMenu(QCocoaMenu *menu); - QList<QCocoaMenu*> m_menus; + NSMenuItem *nativeItemForMenu(QCocoaMenu *menu) const; + + QList<QPointer<QCocoaMenu> > m_menus; NSMenu *m_nativeMenu; QCocoaWindow *m_window; }; diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index c9a42e9d8e..e8b3823012 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm @@ -57,7 +57,6 @@ static inline QCocoaMenuLoader *getMenuLoader() return [NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)]; } - QCocoaMenuBar::QCocoaMenuBar() : m_window(0) { @@ -74,11 +73,20 @@ QCocoaMenuBar::~QCocoaMenuBar() #ifdef QT_COCOA_ENABLE_MENU_DEBUG qDebug() << "~QCocoaMenuBar" << this; #endif + foreach (QCocoaMenu *menu, m_menus) { + if (!menu) + continue; + NSMenuItem *item = nativeItemForMenu(menu); + if (menu->attachedItem() == item) + menu->setAttachedItem(nil); + } + [m_nativeMenu release]; static_menubars.removeOne(this); if (m_window && m_window->menubar() == this) { m_window->setMenubar(0); + // Delete the children first so they do not cause // the native menu items to be hidden after // the menu bar was updated @@ -87,24 +95,6 @@ QCocoaMenuBar::~QCocoaMenuBar() } } -void QCocoaMenuBar::insertNativeMenu(QCocoaMenu *menu, QCocoaMenu *beforeMenu) -{ - QMacAutoReleasePool pool; - - if (beforeMenu) { - NSUInteger nativeIndex = [m_nativeMenu indexOfItem:beforeMenu->nsMenuItem()]; - [m_nativeMenu insertItem: menu->nsMenuItem() atIndex: nativeIndex]; - } else { - [m_nativeMenu addItem: menu->nsMenuItem()]; - } - - menu->setMenuBar(this); - syncMenu(static_cast<QPlatformMenu *>(menu)); - if (menu->isVisible()) { - [m_nativeMenu setSubmenu: menu->nsMenu() forItem: menu->nsMenuItem()]; - } -} - void QCocoaMenuBar::insertMenu(QPlatformMenu *platformMenu, QPlatformMenu *before) { QCocoaMenu *menu = static_cast<QCocoaMenu *>(platformMenu); @@ -113,31 +103,40 @@ void QCocoaMenuBar::insertMenu(QPlatformMenu *platformMenu, QPlatformMenu *befor qDebug() << "QCocoaMenuBar" << this << "insertMenu" << menu << "before" << before; #endif - if (m_menus.contains(menu)) { + if (m_menus.contains(QPointer<QCocoaMenu>(menu))) { qWarning("This menu already belongs to the menubar, remove it first"); return; } - if (beforeMenu && !m_menus.contains(beforeMenu)) { + if (beforeMenu && !m_menus.contains(QPointer<QCocoaMenu>(beforeMenu))) { qWarning("The before menu does not belong to the menubar"); return; } - m_menus.insert(beforeMenu ? m_menus.indexOf(beforeMenu) : m_menus.size(), menu); - if (!menu->menuBar()) - insertNativeMenu(menu, beforeMenu); - if (m_window && m_window->window()->isActive()) - updateMenuBarImmediately(); -} + int insertionIndex = beforeMenu ? m_menus.indexOf(beforeMenu) : m_menus.size(); + m_menus.insert(insertionIndex, menu); + + { + QMacAutoReleasePool pool; + NSMenuItem *item = [[[NSMenuItem alloc] init] autorelease]; + item.tag = reinterpret_cast<NSInteger>(menu); + + if (beforeMenu) { + // QMenuBar::toNSMenu() exposes the native menubar and + // the user could have inserted its own items in there. + // Same remark applies to removeMenu(). + NSMenuItem *beforeItem = nativeItemForMenu(beforeMenu); + NSInteger nativeIndex = [m_nativeMenu indexOfItem:beforeItem]; + [m_nativeMenu insertItem:item atIndex:nativeIndex]; + } else { + [m_nativeMenu addItem:item]; + } + } -void QCocoaMenuBar::removeNativeMenu(QCocoaMenu *menu) -{ - QMacAutoReleasePool pool; + syncMenu(menu); - if (menu->menuBar() == this) - menu->setMenuBar(0); - NSUInteger realIndex = [m_nativeMenu indexOfItem:menu->nsMenuItem()]; - [m_nativeMenu removeItemAtIndex: realIndex]; + if (m_window && m_window->window()->isActive()) + updateMenuBarImmediately(); } void QCocoaMenuBar::removeMenu(QPlatformMenu *platformMenu) @@ -147,8 +146,17 @@ void QCocoaMenuBar::removeMenu(QPlatformMenu *platformMenu) qWarning("Trying to remove a menu that does not belong to the menubar"); return; } + + NSMenuItem *item = nativeItemForMenu(menu); + if (menu->attachedItem() == item) + menu->setAttachedItem(nil); m_menus.removeOne(menu); - removeNativeMenu(menu); + + QMacAutoReleasePool pool; + + // See remark in insertMenu(). + NSInteger nativeIndex = [m_nativeMenu indexOfItem:item]; + [m_nativeMenu removeItemAtIndex:nativeIndex]; } void QCocoaMenuBar::syncMenu(QPlatformMenu *menu) @@ -170,7 +178,16 @@ void QCocoaMenuBar::syncMenu(QPlatformMenu *menu) break; } } - [cocoaMenu->nsMenuItem() setHidden:shouldHide]; + + nativeItemForMenu(cocoaMenu).hidden = shouldHide; +} + +NSMenuItem *QCocoaMenuBar::nativeItemForMenu(QCocoaMenu *menu) const +{ + if (!menu) + return nil; + + return [m_nativeMenu itemWithTag:reinterpret_cast<NSInteger>(menu)]; } void QCocoaMenuBar::handleReparent(QWindow *newParentWindow) @@ -297,24 +314,16 @@ void QCocoaMenuBar::updateMenuBarImmediately() qDebug() << "QCocoaMenuBar" << "updateMenuBarImmediately" << cw; #endif bool disableForModal = mb->shouldDisable(cw); - // force a sync? - foreach (QCocoaMenu *m, mb->m_menus) { - mb->syncMenu(m); - m->syncModalState(disableForModal); - } - // reparent shared menu items if necessary. - // We browse the list in reverse order to be sure that the next items are redrawn before the current ones, - // in this way we are sure that "beforeMenu" (see below) is part of the native menu before "m" is redraw - for (int i = mb->m_menus.size() - 1; i >= 0; i--) { - QCocoaMenu *m = mb->m_menus.at(i); - QCocoaMenuBar *menuBar = m->menuBar(); - if (menuBar != mb) { - QCocoaMenu *beforeMenu = i < (mb->m_menus.size() - 1) ? mb->m_menus.at(i + 1) : 0; - if (menuBar) - menuBar->removeNativeMenu(m); - mb->insertNativeMenu(m, beforeMenu); - } + foreach (QCocoaMenu *menu, mb->m_menus) { + if (!menu) + continue; + NSMenuItem *item = mb->nativeItemForMenu(menu); + menu->setAttachedItem(item); + SET_COCOA_MENU_ANCESTOR(menu, mb); + // force a sync? + mb->syncMenu(menu); + menu->syncModalState(disableForModal); } QCocoaMenuLoader *loader = getMenuLoader(); diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.h b/src/plugins/platforms/cocoa/qcocoamenuitem.h index 0d6f67959b..bba9ce3963 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.h +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.h @@ -93,7 +93,6 @@ public: inline bool isSeparator() const { return m_isSeparator; } QCocoaMenu *menu() const { return m_menu; } - void clearMenu(QCocoaMenu *menu); MenuRole effectiveRole() const; private: @@ -105,7 +104,7 @@ private: QString m_text; bool m_textSynced; QIcon m_icon; - QCocoaMenu *m_menu; + QPointer<QCocoaMenu> m_menu; bool m_isVisible; bool m_enabled; bool m_isSeparator; diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm index 9e4f0b9ad1..de0271ce4d 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm @@ -142,15 +142,12 @@ void QCocoaMenuItem::setMenu(QPlatformMenu *menu) if (m_menu) { if (COCOA_MENU_ANCESTOR(m_menu) == this) SET_COCOA_MENU_ANCESTOR(m_menu, 0); - if (m_menu->containingMenuItem() == this) - m_menu->setContainingMenuItem(0); } QMacAutoReleasePool pool; m_menu = static_cast<QCocoaMenu *>(menu); if (m_menu) { SET_COCOA_MENU_ANCESTOR(m_menu, this); - m_menu->setContainingMenuItem(this); } else { // we previously had a menu, but no longer // clear out our item so the nexy sync() call builds a new one @@ -159,12 +156,6 @@ void QCocoaMenuItem::setMenu(QPlatformMenu *menu) } } -void QCocoaMenuItem::clearMenu(QCocoaMenu *menu) -{ - if (menu == m_menu) - m_menu = 0; -} - void QCocoaMenuItem::setVisible(bool isVisible) { m_isVisible = isVisible; @@ -226,14 +217,6 @@ NSMenuItem *QCocoaMenuItem::sync() m_native = nil; } - if (m_menu) { - if (m_native != m_menu->nsMenuItem()) { - [m_native release]; - m_native = [m_menu->nsMenuItem() retain]; - [m_native setTag:reinterpret_cast<NSInteger>(this)]; - } - } - if ((m_role != NoRole && !m_textSynced) || m_merged) { NSMenuItem *mergeItem = nil; QCocoaMenuLoader *loader = getMenuLoader(); diff --git a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm index 7fd5537215..be5fa61b8b 100644 --- a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm +++ b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm @@ -153,6 +153,7 @@ static QMacPaletteMap mac_widget_colors[] = { QMacPaletteMap(QPlatformTheme::LabelPalette, kThemeTextColorPlacardActive, kThemeTextColorPlacardInactive), QMacPaletteMap(QPlatformTheme::GroupBoxPalette, kThemeTextColorPlacardActive, kThemeTextColorPlacardInactive), QMacPaletteMap(QPlatformTheme::MenuPalette, kThemeTextColorMenuItemActive, kThemeTextColorMenuItemDisabled), + QMacPaletteMap(QPlatformTheme::MenuBarPalette, kThemeTextColorMenuItemActive, kThemeTextColorMenuItemDisabled), //### TODO: The zeros below gives white-on-black text. QMacPaletteMap(QPlatformTheme::TextEditPalette, 0, 0), QMacPaletteMap(QPlatformTheme::TextLineEditPalette, 0, 0), @@ -177,7 +178,8 @@ QHash<QPlatformTheme::Palette, QPalette*> qt_mac_createRolePalettes() pal.setColor(QPalette::Disabled, QPalette::WindowText, qc); pal.setColor(QPalette::Disabled, QPalette::HighlightedText, qc); } - if (mac_widget_colors[i].paletteRole == QPlatformTheme::MenuPalette) { + if (mac_widget_colors[i].paletteRole == QPlatformTheme::MenuPalette + || mac_widget_colors[i].paletteRole == QPlatformTheme::MenuBarPalette) { pal.setBrush(QPalette::Background, qt_mac_brushForTheme(kThemeBrushMenuBackground)); qc = qt_mac_colorForThemeTextColor(kThemeTextColorMenuItemActive); pal.setBrush(QPalette::ButtonText, qc); diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 9572b5ac4c..01e72303be 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -376,9 +376,8 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw) , m_bottomContentBorderThickness(0) , m_normalGeometry(QRect(0,0,-1,-1)) { -#ifdef QT_COCOA_ENABLE_WINDOW_DEBUG - qDebug() << "QCocoaWindow::QCocoaWindow" << this; -#endif + qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::QCocoaWindow" << window(); + QMacAutoReleasePool pool; if (tlw->type() == Qt::ForeignWindow) { @@ -411,11 +410,10 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw) QCocoaWindow::~QCocoaWindow() { -#ifdef QT_COCOA_ENABLE_WINDOW_DEBUG - qDebug() << "QCocoaWindow::~QCocoaWindow" << this; -#endif + qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::~QCocoaWindow" << window(); QMacAutoReleasePool pool; + [m_nsWindow makeFirstResponder:nil]; [m_nsWindow setContentView:nil]; [m_nsWindow.helper detachFromPlatformWindow]; if (m_isNSWindowChild) { @@ -470,6 +468,8 @@ QSurfaceFormat QCocoaWindow::format() const void QCocoaWindow::setGeometry(const QRect &rectIn) { + qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::setGeometry" << window() << rectIn; + QBoolBlocker inSetGeometry(m_inSetGeometry, true); QRect rect = rectIn; @@ -482,9 +482,7 @@ void QCocoaWindow::setGeometry(const QRect &rectIn) } if (geometry() == rect) return; -#ifdef QT_COCOA_ENABLE_WINDOW_DEBUG - qDebug() << "QCocoaWindow::setGeometry" << this << rect; -#endif + setCocoaGeometry(rect); } @@ -507,6 +505,7 @@ QRect QCocoaWindow::geometry() const void QCocoaWindow::setCocoaGeometry(const QRect &rect) { + qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::setCocoaGeometry" << window() << rect; QMacAutoReleasePool pool; if (m_contentViewIsEmbedded) { @@ -630,6 +629,8 @@ void QCocoaWindow::show(bool becauseOfAncestor) void QCocoaWindow::setVisible(bool visible) { + qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::setVisible" << window() << visible; + if (m_isNSWindowChild && m_hiddenByClipping) return; @@ -639,9 +640,7 @@ void QCocoaWindow::setVisible(bool visible) QCocoaWindow *parentCocoaWindow = 0; if (window()->transientParent()) parentCocoaWindow = static_cast<QCocoaWindow *>(window()->transientParent()->handle()); -#ifdef QT_COCOA_ENABLE_WINDOW_DEBUG - qDebug() << "QCocoaWindow::setVisible" << window() << visible; -#endif + if (visible) { // We need to recreate if the modality has changed as the style mask will need updating if (m_windowModality != window()->modality()) @@ -862,9 +861,6 @@ NSUInteger QCocoaWindow::windowStyleMask(Qt::WindowFlags flags) if (m_drawContentBorderGradient) styleMask |= NSTexturedBackgroundWindowMask; -#ifdef QT_COCOA_ENABLE_WINDOW_DEBUG - qDebug("windowStyleMask of '%s': flags %X -> styleMask %lX", qPrintable(window()->title()), (int)flags, styleMask); -#endif return styleMask; } @@ -986,7 +982,8 @@ bool QCocoaWindow::isAlertState() const void QCocoaWindow::raise() { - //qDebug() << "raise" << this; + qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::raise" << window(); + // ### handle spaces (see Qt 4 raise_sys in qwidget_mac.mm) if (!m_nsWindow) return; @@ -1006,7 +1003,15 @@ void QCocoaWindow::raise() [parentNSWindow removeChildWindow:m_nsWindow]; [parentNSWindow addChildWindow:m_nsWindow ordered:NSWindowAbove]; } else { - [m_nsWindow orderFront: m_nsWindow]; + { + // Clean up autoreleased temp objects from orderFront immediately. + // Failure to do so has been observed to cause leaks also beyond any outer + // autorelease pool (for example around a complete QWindow + // construct-show-raise-hide-delete cyle), counter to expected autoreleasepool + // behavior. + QMacAutoReleasePool pool; + [m_nsWindow orderFront: m_nsWindow]; + } static bool raiseProcess = qt_mac_resolveOption(true, "QT_MAC_SET_RAISE_PROCESS"); if (raiseProcess) { ProcessSerialNumber psn; @@ -1019,6 +1024,7 @@ void QCocoaWindow::raise() void QCocoaWindow::lower() { + qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::lower" << window(); if (!m_nsWindow) return; if (m_isNSWindowChild) { @@ -1071,13 +1077,11 @@ void QCocoaWindow::propagateSizeHints() if (!m_nsWindow) return; -#ifdef QT_COCOA_ENABLE_WINDOW_DEBUG - qDebug() << "QCocoaWindow::propagateSizeHints" << this; - qDebug() << " min/max" << windowMinimumSize() << windowMaximumSize(); - qDebug() << "size increment" << windowSizeIncrement(); - qDebug() << " basesize" << windowBaseSize(); - qDebug() << " geometry" << windowGeometry(); -#endif + qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::propagateSizeHints" << window() << "\n" + << " min/max" << windowMinimumSize() << windowMaximumSize() + << "size increment" << windowSizeIncrement() + << " basesize" << windowBaseSize() + << " geometry" << windowGeometry(); // Set the minimum content size. const QSize minimumSize = windowMinimumSize(); @@ -1109,6 +1113,7 @@ void QCocoaWindow::propagateSizeHints() void QCocoaWindow::setOpacity(qreal level) { + qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::setOpacity" << level; if (m_nsWindow) { [m_nsWindow setAlphaValue:level]; [m_nsWindow setOpaque: isOpaque()]; @@ -1117,6 +1122,7 @@ void QCocoaWindow::setOpacity(qreal level) void QCocoaWindow::setMask(const QRegion ®ion) { + qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::setMask" << window() << region; if (m_nsWindow) [m_nsWindow setBackgroundColor:[NSColor clearColor]]; @@ -1126,6 +1132,7 @@ void QCocoaWindow::setMask(const QRegion ®ion) bool QCocoaWindow::setKeyboardGrabEnabled(bool grab) { + qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::setKeyboardGrabEnabled" << window() << grab; if (!m_nsWindow) return false; @@ -1138,6 +1145,7 @@ bool QCocoaWindow::setKeyboardGrabEnabled(bool grab) bool QCocoaWindow::setMouseGrabEnabled(bool grab) { + qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::setMouseGrabEnabled" << window() << grab; if (!m_nsWindow) return false; @@ -1155,6 +1163,8 @@ WId QCocoaWindow::winId() const void QCocoaWindow::setParent(const QPlatformWindow *parentWindow) { + qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::setParent" << window() << (parentWindow ? parentWindow->window() : 0); + // recreate the window for compatibility bool unhideAfterRecreate = parentWindow && !m_contentViewIsToBeEmbedded && ![m_contentView isHidden]; recreateWindow(parentWindow); @@ -1238,6 +1248,7 @@ void QCocoaWindow::windowDidEndLiveResize() bool QCocoaWindow::windowShouldClose() { + qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::windowShouldClose" << window(); // This callback should technically only determine if the window // should (be allowed to) close, but since our QPA API to determine // that also involves actually closing the window we do both at the @@ -1278,6 +1289,9 @@ QCocoaGLContext *QCocoaWindow::currentContext() const void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow) { + qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::recreateWindow" << window() + << "parent" << (parentWindow ? parentWindow->window() : 0); + bool wasNSWindowChild = m_isNSWindowChild; BOOL requestNSWindowChild = qt_mac_resolveOption(NO, window(), "_q_platform_MacUseNSWindow", "QT_MAC_USE_NSWINDOW"); @@ -1614,10 +1628,6 @@ void QCocoaWindow::syncWindowState(Qt::WindowState newState) } } -#ifdef QT_COCOA_ENABLE_WINDOW_DEBUG - qDebug() << "QCocoaWindow::syncWindowState" << newState << "actual" << predictedState << "was" << m_synchedWindowState << "effectively maximized" << m_effectivelyMaximized; -#endif - // New state is now the current synched state m_synchedWindowState = predictedState; } @@ -1810,7 +1820,9 @@ void QCocoaWindow::exposeWindow() m_isExposed = true; m_exposedGeometry = geometry(); m_exposedDevicePixelRatio = devicePixelRatio(); - QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(0, 0), m_exposedGeometry.size())); + QRect geometry(QPoint(0, 0), m_exposedGeometry.size()); + qCDebug(lcQpaCocoaWindow) << "QCocoaWindow: exposeWindow" << window() << geometry; + QWindowSystemInterface::handleExposeEvent(window(), geometry); } } @@ -1820,6 +1832,8 @@ void QCocoaWindow::obscureWindow() if (m_isExposed) { m_geometryUpdateExposeAllowed = false; m_isExposed = false; + + qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::obscureWindow" << window(); QWindowSystemInterface::handleExposeEvent(window(), QRegion()); } } @@ -1846,7 +1860,10 @@ void QCocoaWindow::updateExposedGeometry() m_isExposed = true; m_exposedGeometry = geometry(); m_exposedDevicePixelRatio = devicePixelRatio(); - QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(0, 0), m_exposedGeometry.size())); + + QRect geometry(QPoint(0, 0), m_exposedGeometry.size()); + qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::updateExposedGeometry" << window() << geometry; + QWindowSystemInterface::handleExposeEvent(window(), geometry); } QWindow *QCocoaWindow::childWindowAt(QPoint windowPoint) diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index cbd92df9cf..b5738abf4c 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -43,6 +43,7 @@ #include <AppKit/AppKit.h> #include <QtCore/QPointer> +#include <QtCore/QSet> #include <QtGui/QImage> #include <QtGui/QAccessible> @@ -59,6 +60,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper)); @interface QT_MANGLE_NAMESPACE(QNSView) : NSView <NSTextInputClient> { QCocoaBackingStore* m_backingStore; QPoint m_backingStoreOffset; + QRegion m_maskRegion; CGImageRef m_maskImage; uchar *m_maskData; bool m_shouldInvalidateWindowShadow; @@ -66,6 +68,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper)); QCocoaWindow *m_platformWindow; NSTrackingArea *m_trackingArea; Qt::MouseButtons m_buttons; + Qt::MouseButtons m_acceptedMouseDowns; Qt::MouseButtons m_frameStrutButtons; QString m_composingText; bool m_sendKeyEvent; @@ -85,6 +88,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper)); bool m_exposedOnMoveToWindow; NSEvent *m_currentlyInterpretedKeyEvent; bool m_isMenuView; + QSet<quint32> m_acceptedKeyDowns; } - (id)init; @@ -118,6 +122,9 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper)); - (void)resetMouseButtons; - (void)handleMouseEvent:(NSEvent *)theEvent; +- (bool)handleMouseDownEvent:(NSEvent *)theEvent; +- (bool)handleMouseDraggedEvent:(NSEvent *)theEvent; +- (bool)handleMouseUpEvent:(NSEvent *)theEvent; - (void)mouseDown:(NSEvent *)theEvent; - (void)mouseDragged:(NSEvent *)theEvent; - (void)mouseUp:(NSEvent *)theEvent; @@ -139,7 +146,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper)); - (int) convertKeyCode : (QChar)keyCode; + (Qt::KeyboardModifiers) convertKeyModifiers : (ulong)modifierFlags; -- (void)handleKeyEvent:(NSEvent *)theEvent eventType:(int)eventType; +- (bool)handleKeyEvent:(NSEvent *)theEvent eventType:(int)eventType; - (void)keyDown:(NSEvent *)theEvent; - (void)keyUp:(NSEvent *)theEvent; diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 360ad3baf7..bb12c30fa3 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -145,6 +145,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil; m_shouldInvalidateWindowShadow = false; m_window = 0; m_buttons = Qt::NoButton; + m_acceptedMouseDowns = Qt::NoButton; m_frameStrutButtons = Qt::NoButton; m_sendKeyEvent = false; m_subscribesForGlobalFrameNotifications = false; @@ -361,15 +362,16 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil; if (m_platformWindow->m_nsWindow && geometry == m_platformWindow->geometry()) return; + const bool isResize = geometry.size() != m_platformWindow->geometry().size(); + // It can happen that self.window is nil (if we are changing // styleMask from/to borderless and content view is being re-parented) // - this results in an invalid coordinates. if (m_platformWindow->m_inSetStyleMask && !self.window) return; -#ifdef QT_COCOA_ENABLE_WINDOW_DEBUG - qDebug() << "QNSView::udpateGeometry" << m_platformWindow << geometry; -#endif + qCDebug(lcQpaCocoaWindow) << "[QNSView udpateGeometry:]" << m_window + << "current" << m_platformWindow->geometry() << "new" << geometry; // Call setGeometry on QPlatformWindow. (not on QCocoaWindow, // doing that will initiate a geometry change it and possibly create @@ -390,7 +392,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil; // calles, which Qt and Qt applications do not excpect. if (!m_platformWindow->m_inSetGeometry) QWindowSystemInterface::flushWindowSystemEvents(); - else + else if (isResize) m_backingStore = 0; } } @@ -512,6 +514,8 @@ QT_WARNING_POP - (void) flushBackingStore:(QCocoaBackingStore *)backingStore region:(const QRegion &)region offset:(QPoint)offset { + qCDebug(lcQpaCocoaWindow) << "[QNSView flushBackingStore:]" << m_window << region.rectCount() << region.boundingRect() << offset; + m_backingStore = backingStore; m_backingStoreOffset = offset * m_backingStore->getBackingStoreDevicePixelRatio(); for (const QRect &rect : region) @@ -526,7 +530,7 @@ QT_WARNING_POP - (BOOL) hasMask { - return m_maskImage != 0; + return !m_maskRegion.isEmpty(); } - (BOOL) isOpaque @@ -539,6 +543,7 @@ QT_WARNING_POP - (void) setMaskRegion:(const QRegion *)region { m_shouldInvalidateWindowShadow = true; + m_maskRegion = *region; if (m_maskImage) CGImageRelease(m_maskImage); if (region->isEmpty()) { @@ -574,6 +579,8 @@ QT_WARNING_POP - (void) drawRect:(NSRect)dirtyRect { + qCDebug(lcQpaCocoaWindow) << "[QNSView drawRect:]" << m_window << qt_mac_toQRect(dirtyRect); + #ifndef QT_NO_OPENGL if (m_glContext && m_shouldSetGLContextinDrawRect) { [m_glContext->nsOpenGLContext() setView:self]; @@ -813,6 +820,82 @@ QT_WARNING_POP QWindowSystemInterface::handleFrameStrutMouseEvent(m_window, timestamp, qtWindowPoint, qtScreenPoint, m_frameStrutButtons); } +- (bool)handleMouseDownEvent:(NSEvent *)theEvent +{ + if (m_window && (m_window->flags() & Qt::WindowTransparentForInput)) + return false; + + Qt::MouseButton button = cocoaButton2QtButton([theEvent buttonNumber]); + + QPointF qtWindowPoint; + QPointF qtScreenPoint; + [self convertFromScreen:[self screenMousePoint:theEvent] toWindowPoint:&qtWindowPoint andScreenPoint:&qtScreenPoint]; + Q_UNUSED(qtScreenPoint); + + // Maintain masked state for the button for use by MouseDragged and MouseUp. + const bool masked = m_maskRegion.contains(qtWindowPoint.toPoint()); + if (masked) + m_acceptedMouseDowns &= ~button; + else + m_acceptedMouseDowns |= button; + + // Forward masked out events to the next responder + if (masked) + return false; + + if (button == Qt::RightButton) + m_sendUpAsRightButton = true; + + m_buttons |= button; + + [self handleMouseEvent:theEvent]; + return true; +} + +- (bool)handleMouseDraggedEvent:(NSEvent *)theEvent +{ + if (m_window && (m_window->flags() & Qt::WindowTransparentForInput)) + return false; + + Qt::MouseButton button = cocoaButton2QtButton([theEvent buttonNumber]); + + // Forward the event to the next responder if Qt did not accept the + // corresponding mouse down for this button + if (!(m_acceptedMouseDowns & button) == button) + return false; + + if (!(m_buttons & (m_sendUpAsRightButton ? Qt::RightButton : Qt::LeftButton))) { + qCWarning(lcQpaCocoaWindow) << "QNSView mouseDragged: Internal mouse button tracking" + << "invalid (missing Qt::LeftButton)"; + } + + [self handleMouseEvent:theEvent]; + return true; +} + +- (bool)handleMouseUpEvent:(NSEvent *)theEvent +{ + if (m_window && (m_window->flags() & Qt::WindowTransparentForInput)) + return false; + + Qt::MouseButton button = cocoaButton2QtButton([theEvent buttonNumber]); + + // Forward the event to the next responder if Qt did not accept the + // corresponding mouse down for this button + if (!(m_acceptedMouseDowns & button) == button) + return false; + + if (m_sendUpAsRightButton && button == Qt::LeftButton) + button = Qt::RightButton; + if (button == Qt::RightButton) + m_sendUpAsRightButton = false; + + m_buttons &= ~button; + + [self handleMouseEvent:theEvent]; + return true; +} + - (void)mouseDown:(NSEvent *)theEvent { if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) ) @@ -851,6 +934,25 @@ QT_WARNING_POP } } + QPointF qtWindowPoint; + QPointF qtScreenPoint; + [self convertFromScreen:[self screenMousePoint:theEvent] toWindowPoint:&qtWindowPoint andScreenPoint:&qtScreenPoint]; + Q_UNUSED(qtScreenPoint); + + bool masked = m_maskRegion.contains(qtWindowPoint.toPoint()); + + // Maintain masked state for the button for use by MouseDragged and Up. + if (masked) + m_acceptedMouseDowns &= ~Qt::LeftButton; + else + m_acceptedMouseDowns |= Qt::LeftButton; + + // Forward masked out events to the next responder + if (masked) { + [super mouseDown:theEvent]; + return; + } + if ([self hasMarkedText]) { [[NSTextInputContext currentInputContext] handleEvent:theEvent]; } else { @@ -866,24 +968,58 @@ QT_WARNING_POP - (void)mouseDragged:(NSEvent *)theEvent { - if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) ) - return [super mouseDragged:theEvent]; - if (!(m_buttons & (m_sendUpAsRightButton ? Qt::RightButton : Qt::LeftButton))) - qWarning("QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton)"); - [self handleMouseEvent:theEvent]; + const bool accepted = [self handleMouseDraggedEvent:theEvent]; + if (!accepted) + [super mouseDragged:theEvent]; } - (void)mouseUp:(NSEvent *)theEvent { - if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) ) - return [super mouseUp:theEvent]; - if (m_sendUpAsRightButton) { - m_buttons &= ~Qt::RightButton; - m_sendUpAsRightButton = false; - } else { - m_buttons &= ~Qt::LeftButton; - } - [self handleMouseEvent:theEvent]; + const bool accepted = [self handleMouseUpEvent:theEvent]; + if (!accepted) + [super mouseUp:theEvent]; +} + +- (void)rightMouseDown:(NSEvent *)theEvent +{ + const bool accepted = [self handleMouseDownEvent:theEvent]; + if (!accepted) + [super rightMouseDown:theEvent]; +} + +- (void)rightMouseDragged:(NSEvent *)theEvent +{ + const bool accepted = [self handleMouseDraggedEvent:theEvent]; + if (!accepted) + [super rightMouseDragged:theEvent]; +} + +- (void)rightMouseUp:(NSEvent *)theEvent +{ + const bool accepted = [self handleMouseUpEvent:theEvent]; + if (!accepted) + [super rightMouseUp:theEvent]; +} + +- (void)otherMouseDown:(NSEvent *)theEvent +{ + const bool accepted = [self handleMouseDownEvent:theEvent]; + if (!accepted) + [super otherMouseDown:theEvent]; +} + +- (void)otherMouseDragged:(NSEvent *)theEvent +{ + const bool accepted = [self handleMouseDraggedEvent:theEvent]; + if (!accepted) + [super otherMouseDragged:theEvent]; +} + +- (void)otherMouseUp:(NSEvent *)theEvent +{ + const bool accepted = [self handleMouseUpEvent:theEvent]; + if (!accepted) + [super otherMouseUp:theEvent]; } - (void)updateTrackingAreas @@ -994,58 +1130,6 @@ QT_WARNING_POP m_platformWindow->m_enterLeaveTargetWindow = 0; } -- (void)rightMouseDown:(NSEvent *)theEvent -{ - if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) ) - return [super rightMouseDown:theEvent]; - m_buttons |= Qt::RightButton; - m_sendUpAsRightButton = true; - [self handleMouseEvent:theEvent]; -} - -- (void)rightMouseDragged:(NSEvent *)theEvent -{ - if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) ) - return [super rightMouseDragged:theEvent]; - if (!(m_buttons & Qt::RightButton)) - qWarning("QNSView rightMouseDragged: Internal mouse button tracking invalid (missing Qt::RightButton)"); - [self handleMouseEvent:theEvent]; -} - -- (void)rightMouseUp:(NSEvent *)theEvent -{ - if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) ) - return [super rightMouseUp:theEvent]; - m_buttons &= ~Qt::RightButton; - m_sendUpAsRightButton = false; - [self handleMouseEvent:theEvent]; -} - -- (void)otherMouseDown:(NSEvent *)theEvent -{ - if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) ) - return [super otherMouseDown:theEvent]; - m_buttons |= cocoaButton2QtButton([theEvent buttonNumber]); - [self handleMouseEvent:theEvent]; -} - -- (void)otherMouseDragged:(NSEvent *)theEvent -{ - if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) ) - return [super otherMouseDragged:theEvent]; - if (!(m_buttons & ~(Qt::LeftButton | Qt::RightButton))) - qWarning("QNSView otherMouseDragged: Internal mouse button tracking invalid (missing Qt::MiddleButton or Qt::ExtraButton*)"); - [self handleMouseEvent:theEvent]; -} - -- (void)otherMouseUp:(NSEvent *)theEvent -{ - if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) ) - return [super otherMouseUp:theEvent]; - m_buttons &= ~cocoaButton2QtButton([theEvent buttonNumber]); - [self handleMouseEvent:theEvent]; -} - struct QCocoaTabletDeviceData { QTabletEvent::TabletDevice device; @@ -1413,8 +1497,10 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) } else if (phase == NSEventPhaseNone && momentumPhase == NSEventPhaseNone) { ph = Qt::NoScrollPhase; } + // "isInverted": natural OS X scrolling, inverted from the Qt/other platform/Jens perspective. + bool isInverted = [theEvent isDirectionInvertedFromDevice]; - QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_screenPoint, pixelDelta, angleDelta, currentWheelModifiers, ph, source); + QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_screenPoint, pixelDelta, angleDelta, currentWheelModifiers, ph, source, isInverted); } #endif //QT_NO_WHEELEVENT @@ -1439,7 +1525,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) return qtMods; } -- (void)handleKeyEvent:(NSEvent *)nsevent eventType:(int)eventType +- (bool)handleKeyEvent:(NSEvent *)nsevent eventType:(int)eventType { ulong timestamp = [nsevent timestamp] * 1000; ulong nativeModifiers = [nsevent modifierFlags]; @@ -1509,26 +1595,46 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) m_sendKeyEvent = true; } - if (m_sendKeyEvent && m_composingText.isEmpty()) + bool accepted = true; + if (m_sendKeyEvent && m_composingText.isEmpty()) { QWindowSystemInterface::handleExtendedKeyEvent(window, timestamp, QEvent::Type(eventType), keyCode, modifiers, nativeScanCode, nativeVirtualKey, nativeModifiers, text, [nsevent isARepeat], 1, false); - + accepted = QWindowSystemInterface::flushWindowSystemEvents(); + } m_sendKeyEvent = false; m_resendKeyEvent = false; + return accepted; } - (void)keyDown:(NSEvent *)nsevent { if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) ) return [super keyDown:nsevent]; - [self handleKeyEvent:nsevent eventType:int(QEvent::KeyPress)]; + + const bool accepted = [self handleKeyEvent:nsevent eventType:int(QEvent::KeyPress)]; + + // Track keyDown acceptance state for later acceptance of the keyUp. + if (accepted) + m_acceptedKeyDowns.insert([nsevent keyCode]); + + // Propagate the keyDown to the next responder if Qt did not accept it. + if (!accepted) + [super keyDown:nsevent]; } - (void)keyUp:(NSEvent *)nsevent { if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) ) return [super keyUp:nsevent]; - [self handleKeyEvent:nsevent eventType:int(QEvent::KeyRelease)]; + + const bool keyUpAccepted = [self handleKeyEvent:nsevent eventType:int(QEvent::KeyRelease)]; + + // Propagate the keyUp if neither Qt accepted it nor the corresponding KeyDown was + // accepted. Qt text controls wil often not use and ignore keyUp events, but we + // want to avoid propagating unmatched keyUps. + const bool keyDownAccepted = m_acceptedKeyDowns.remove([nsevent keyCode]); + if (!keyUpAccepted && !keyDownAccepted) + [super keyUp:nsevent]; } - (void)cancelOperation:(id)sender diff --git a/src/plugins/platforms/cocoa/qt_mac_p.h b/src/plugins/platforms/cocoa/qt_mac_p.h index 18a3d1b3e5..03eae1b2e7 100644 --- a/src/plugins/platforms/cocoa/qt_mac_p.h +++ b/src/plugins/platforms/cocoa/qt_mac_p.h @@ -64,6 +64,7 @@ #include "QtCore/qvariant.h" #include "QtCore/qmimedata.h" #include "QtCore/qpointer.h" +#include "QtCore/qloggingcategory.h" #include "private/qcore_mac_p.h" diff --git a/src/plugins/platforms/direct2d/direct2d.pro b/src/plugins/platforms/direct2d/direct2d.pro index 8f2ccc3aa6..005a4da6db 100644 --- a/src/plugins/platforms/direct2d/direct2d.pro +++ b/src/plugins/platforms/direct2d/direct2d.pro @@ -1,10 +1,5 @@ TARGET = qdirect2d -PLUGIN_TYPE = platforms -PLUGIN_CLASS_NAME = QWindowsDirect2DIntegrationPlugin -!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - -load(qt_plugin) - QT *= core-private QT *= gui-private QT *= platformsupport-private @@ -40,3 +35,8 @@ HEADERS += \ qwindowsdirect2dwindow.h OTHER_FILES += direct2d.json + +PLUGIN_TYPE = platforms +PLUGIN_CLASS_NAME = QWindowsDirect2DIntegrationPlugin +!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - +load(qt_plugin) diff --git a/src/plugins/platforms/directfb/directfb.pro b/src/plugins/platforms/directfb/directfb.pro index 89d8d42cea..5c81e0283a 100644 --- a/src/plugins/platforms/directfb/directfb.pro +++ b/src/plugins/platforms/directfb/directfb.pro @@ -1,10 +1,5 @@ TARGET = qdirectfb -PLUGIN_TYPE = platforms -PLUGIN_CLASS_NAME = QDirectFbIntegrationPlugin -!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - -load(qt_plugin) - QT += core-private gui-private platformsupport-private LIBS += $$QMAKE_LIBS_DIRECTFB @@ -51,3 +46,8 @@ contains(QT_CONFIG, directfb_egl) { CONFIG += qpa/genericunixfontdatabase OTHER_FILES += directfb.json + +PLUGIN_TYPE = platforms +PLUGIN_CLASS_NAME = QDirectFbIntegrationPlugin +!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - +load(qt_plugin) diff --git a/src/plugins/platforms/directfb/qdirectfbbackingstore.cpp b/src/plugins/platforms/directfb/qdirectfbbackingstore.cpp index ebb8dc1571..9786f66b7c 100644 --- a/src/plugins/platforms/directfb/qdirectfbbackingstore.cpp +++ b/src/plugins/platforms/directfb/qdirectfbbackingstore.cpp @@ -71,7 +71,7 @@ void QDirectFbBackingStore::flush(QWindow *, const QRegion ®ion, const QPoint m_pmdata->blittable()->unlock(); for (const QRect &rect : region) { - DFBRegion dfbReg = { rect.x() + offset.x(),rect.y() + offset.y(),rect.right() + offset.x(),rect.bottom() + offset.y()}; + DFBRegion dfbReg(rect.x() + offset.x(),rect.y() + offset.y(),rect.right() + offset.x(),rect.bottom() + offset.y()); m_dfbSurface->Flip(m_dfbSurface.data(), &dfbReg, DFBSurfaceFlipFlags(DSFLIP_BLIT|DSFLIP_ONSYNC)); } } @@ -90,9 +90,9 @@ void QDirectFbBackingStore::resize(const QSize &size, const QRegion& reg) static inline void scrollSurface(IDirectFBSurface *surface, const QRect &r, int dx, int dy) { - const DFBRectangle rect = { r.x(), r.y(), r.width(), r.height() }; + const DFBRectangle rect(r.x(), r.y(), r.width(), r.height()); surface->Blit(surface, surface, &rect, r.x() + dx, r.y() + dy); - const DFBRegion region = { rect.x + dx, rect.y + dy, r.right() + dx, r.bottom() + dy }; + const DFBRegion region(rect.x + dx, rect.y + dy, r.right() + dx, r.bottom() + dy); surface->Flip(surface, ®ion, DFBSurfaceFlipFlags(DSFLIP_BLIT)); } diff --git a/src/plugins/platforms/directfb/qdirectfbblitter.cpp b/src/plugins/platforms/directfb/qdirectfbblitter.cpp index 939bab9303..3e21a1925d 100644 --- a/src/plugins/platforms/directfb/qdirectfbblitter.cpp +++ b/src/plugins/platforms/directfb/qdirectfbblitter.cpp @@ -179,8 +179,8 @@ void QDirectFbBlitter::drawPixmapOpacity(const QRectF &rect, const QPixmap &pixm { QRect sQRect = subrect.toRect(); QRect dQRect = rect.toRect(); - DFBRectangle sRect = { sQRect.x(), sQRect.y(), sQRect.width(), sQRect.height() }; - DFBRectangle dRect = { dQRect.x(), dQRect.y(), dQRect.width(), dQRect.height() }; + DFBRectangle sRect(sQRect.x(), sQRect.y(), sQRect.width(), sQRect.height()); + DFBRectangle dRect(dQRect.x(), dQRect.y(), dQRect.width(), dQRect.height()); DFBResult result; // skip if dst too small diff --git a/src/plugins/platforms/directfb/qdirectfbglcontext.cpp b/src/plugins/platforms/directfb/qdirectfbglcontext.cpp index 1136591c78..8018433fb6 100644 --- a/src/plugins/platforms/directfb/qdirectfbglcontext.cpp +++ b/src/plugins/platforms/directfb/qdirectfbglcontext.cpp @@ -40,6 +40,7 @@ #include "qdirectfbglcontext.h" #include <directfbgl.h> +#include <dlfcn.h> #include <QDebug> @@ -80,19 +81,19 @@ void QDirectFbGLContext::doneCurrent() m_dfbGlContext->Unlock(m_dfbGlContext); } -void *QDirectFbGLContext::getProcAddress(const QString &procName) +QFunctionPointer QDirectFbGLContext::getProcAddress(const char *procName) { void *proc; - DFBResult result = m_dfbGlContext->GetProcAddress(m_dfbGlContext,qPrintable(procName),&proc); + DFBResult result = m_dfbGlContext->GetProcAddress(m_dfbGlContext, procName, &proc); if (result == DFB_OK) - return proc; - return 0; + return (QFunctionPointer) proc; + return dlsym(RTLD_DEFAULT, procName); } void QDirectFbGLContext::swapBuffers() { // m_dfbGlContext->Unlock(m_dfbGlContext); //maybe not in doneCurrent() - qDebug() << "Swap buffers"; + qDebug("Swap buffers"); } QPlatformWindowFormat QDirectFbGLContext::platformWindowFormat() const diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/eglfs_brcm.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/eglfs_brcm.pro index 2026b6a6c6..e2ebf9f7ee 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/eglfs_brcm.pro +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/eglfs_brcm.pro @@ -1,9 +1,5 @@ TARGET = qeglfs-brcm-integration -PLUGIN_TYPE = egldeviceintegrations -PLUGIN_CLASS_NAME = QEglFSBrcmIntegrationPlugin -load(qt_plugin) - QT += core-private gui-private platformsupport-private eglfs_device_lib-private INCLUDEPATH += $$PWD/../.. @@ -21,3 +17,7 @@ SOURCES += $$PWD/qeglfsbrcmmain.cpp \ HEADERS += $$PWD/qeglfsbrcmintegration.h OTHER_FILES += $$PWD/eglfs_brcm.json + +PLUGIN_TYPE = egldeviceintegrations +PLUGIN_CLASS_NAME = QEglFSBrcmIntegrationPlugin +load(qt_plugin) diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.pro index e53793ce54..12ae0a13b1 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.pro +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.pro @@ -1,9 +1,5 @@ TARGET = qeglfs-kms-integration -PLUGIN_TYPE = egldeviceintegrations -PLUGIN_CLASS_NAME = QEglFSKmsIntegrationPlugin -load(qt_plugin) - QT += core-private gui-private platformsupport-private eglfs_device_lib-private INCLUDEPATH += $$PWD/../.. @@ -29,3 +25,7 @@ HEADERS += $$PWD/qeglfskmsintegration.h \ $$PWD/qeglfskmscursor.h OTHER_FILES += $$PWD/eglfs_kms.json + +PLUGIN_TYPE = egldeviceintegrations +PLUGIN_CLASS_NAME = QEglFSKmsIntegrationPlugin +load(qt_plugin) diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/eglfs_kms_egldevice.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/eglfs_kms_egldevice.pro index 393ddd14a5..1932f861b9 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/eglfs_kms_egldevice.pro +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/eglfs_kms_egldevice.pro @@ -1,9 +1,5 @@ TARGET = qeglfs-kms-egldevice-integration -PLUGIN_TYPE = egldeviceintegrations -PLUGIN_CLASS_NAME = QEglFSKmsEglDeviceIntegrationPlugin -load(qt_plugin) - QT += core-private gui-private platformsupport-private eglfs_device_lib-private INCLUDEPATH += $$PWD/../.. @@ -21,3 +17,7 @@ HEADERS += $$PWD/qeglfskmsegldeviceintegration.h OTHER_FILES += $$PWD/eglfs_kms_egldevice.json LIBS += -ldrm + +PLUGIN_TYPE = egldeviceintegrations +PLUGIN_CLASS_NAME = QEglFSKmsEglDeviceIntegrationPlugin +load(qt_plugin) diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/eglfs_mali.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/eglfs_mali.pro index 33f219db96..7fc4568ae3 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/eglfs_mali.pro +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/eglfs_mali.pro @@ -1,9 +1,5 @@ TARGET = qeglfs-mali-integration -PLUGIN_TYPE = egldeviceintegrations -PLUGIN_CLASS_NAME = QEglFSMaliIntegrationPlugin -load(qt_plugin) - QT += core-private gui-private platformsupport-private eglfs_device_lib-private # Avoid X11 header collision @@ -19,3 +15,7 @@ SOURCES += $$PWD/qeglfsmalimain.cpp \ HEADERS += $$PWD/qeglfsmaliintegration.h OTHER_FILES += $$PWD/eglfs_mali.json + +PLUGIN_TYPE = egldeviceintegrations +PLUGIN_CLASS_NAME = QEglFSMaliIntegrationPlugin +load(qt_plugin) diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/eglfs_viv.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/eglfs_viv.pro index fc0533127c..6fac2f529a 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/eglfs_viv.pro +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/eglfs_viv.pro @@ -1,9 +1,5 @@ TARGET = qeglfs-viv-integration -PLUGIN_TYPE = egldeviceintegrations -PLUGIN_CLASS_NAME = QEglFSVivIntegrationPlugin -load(qt_plugin) - QT += core-private gui-private platformsupport-private eglfs_device_lib-private INCLUDEPATH += $$PWD/../.. @@ -18,3 +14,7 @@ SOURCES += $$PWD/qeglfsvivmain.cpp \ HEADERS += $$PWD/qeglfsvivintegration.h OTHER_FILES += $$PWD/eglfs_viv.json + +PLUGIN_TYPE = egldeviceintegrations +PLUGIN_CLASS_NAME = QEglFSVivIntegrationPlugin +load(qt_plugin) diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/eglfs_viv_wl.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/eglfs_viv_wl.pro index 26b6a2e9ea..44f75c40e0 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/eglfs_viv_wl.pro +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/eglfs_viv_wl.pro @@ -1,9 +1,5 @@ TARGET = qeglfs-viv-wl-integration -PLUGIN_TYPE = egldeviceintegrations -PLUGIN_CLASS_NAME = QEglFSVivWaylandIntegrationPlugin -load(qt_plugin) - QT += core-private gui-private platformsupport-private eglfs_device_lib-private INCLUDEPATH += $$PWD/../.. @@ -21,3 +17,7 @@ OTHER_FILES += $$PWD/eglfs_viv_wl.json CONFIG += link_pkgconfig PKGCONFIG_PRIVATE += wayland-server + +PLUGIN_TYPE = egldeviceintegrations +PLUGIN_CLASS_NAME = QEglFSVivWaylandIntegrationPlugin +load(qt_plugin) diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.pro index 86fefac8aa..83f0c74910 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.pro +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.pro @@ -1,9 +1,5 @@ TARGET = qeglfs-x11-integration -PLUGIN_TYPE = egldeviceintegrations -PLUGIN_CLASS_NAME = QEglFSX11IntegrationPlugin -load(qt_plugin) - QT += core-private gui-private platformsupport-private eglfs_device_lib-private # Avoid X11 header collision @@ -21,3 +17,7 @@ SOURCES += $$PWD/qeglfsx11main.cpp \ HEADERS += $$PWD/qeglfsx11integration.h OTHER_FILES += $$PWD/eglfs_x11.json + +PLUGIN_TYPE = egldeviceintegrations +PLUGIN_CLASS_NAME = QEglFSX11IntegrationPlugin +load(qt_plugin) diff --git a/src/plugins/platforms/eglfs/eglfs-plugin.pro b/src/plugins/platforms/eglfs/eglfs-plugin.pro index 0f493fdc01..a628cdccd9 100644 --- a/src/plugins/platforms/eglfs/eglfs-plugin.pro +++ b/src/plugins/platforms/eglfs/eglfs-plugin.pro @@ -1,12 +1,12 @@ TARGET = qeglfs -PLUGIN_TYPE = platforms -PLUGIN_CLASS_NAME = QEglFSIntegrationPlugin -!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - -load(qt_plugin) - QT += platformsupport-private eglfs_device_lib-private SOURCES += $$PWD/qeglfsmain.cpp OTHER_FILES += $$PWD/eglfs.json + +PLUGIN_TYPE = platforms +PLUGIN_CLASS_NAME = QEglFSIntegrationPlugin +!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - +load(qt_plugin) diff --git a/src/plugins/platforms/eglfs/eglfs_device_lib.pro b/src/plugins/platforms/eglfs/eglfs_device_lib.pro index 4fe2ce4897..f784020fb6 100644 --- a/src/plugins/platforms/eglfs/eglfs_device_lib.pro +++ b/src/plugins/platforms/eglfs/eglfs_device_lib.pro @@ -6,8 +6,6 @@ TARGET = QtEglDeviceIntegration CONFIG += no_module_headers internal_module -load(qt_module) - QT += core-private gui-private platformsupport-private LIBS += $$QMAKE_LIBS_DYNLOAD @@ -52,3 +50,5 @@ INCLUDEPATH += $$PWD CONFIG += egl qpa/genericunixfontdatabase !contains(DEFINES, QT_NO_CURSOR): RESOURCES += $$PWD/cursor.qrc + +load(qt_module) diff --git a/src/plugins/platforms/haiku/haiku.pro b/src/plugins/platforms/haiku/haiku.pro index 87f31997a3..ea5bb632db 100644 --- a/src/plugins/platforms/haiku/haiku.pro +++ b/src/plugins/platforms/haiku/haiku.pro @@ -1,7 +1,4 @@ TARGET = qhaiku -PLUGIN_TYPE = platforms -PLUGIN_CLASS_NAME = QHaikuIntegrationPlugin -load(qt_plugin) QT += platformsupport-private core-private gui-private @@ -40,3 +37,7 @@ LIBS += -lbe OTHER_FILES += haiku.json include (../../../platformsupport/fontdatabases/fontdatabases.pri) + +PLUGIN_TYPE = platforms +PLUGIN_CLASS_NAME = QHaikuIntegrationPlugin +load(qt_plugin) diff --git a/src/plugins/platforms/ios/ios.pro b/src/plugins/platforms/ios/ios.pro index b1075d3c0f..d82b47fb74 100644 --- a/src/plugins/platforms/ios/ios.pro +++ b/src/plugins/platforms/ios/ios.pro @@ -1,10 +1,5 @@ TARGET = qios -PLUGIN_TYPE = platforms -PLUGIN_CLASS_NAME = QIOSIntegrationPlugin -!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - -load(qt_plugin) - QT += core-private gui-private platformsupport-private LIBS += -framework Foundation -framework UIKit -framework QuartzCore -framework AssetsLibrary -framework AudioToolbox @@ -61,3 +56,8 @@ HEADERS = \ OTHER_FILES = \ quiview_textinput.mm \ quiview_accessibility.mm + +PLUGIN_TYPE = platforms +PLUGIN_CLASS_NAME = QIOSIntegrationPlugin +!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - +load(qt_plugin) diff --git a/src/plugins/platforms/ios/qiosbackingstore.mm b/src/plugins/platforms/ios/qiosbackingstore.mm index 4a39c4d7ab..fb0c9805f9 100644 --- a/src/plugins/platforms/ios/qiosbackingstore.mm +++ b/src/plugins/platforms/ios/qiosbackingstore.mm @@ -149,12 +149,12 @@ void QIOSBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoin } if (window->surfaceType() == QSurface::RasterGLSurface) { - QPainter painter(m_glDevice); - painter.drawImage(QPoint(), m_image); + static QPlatformTextureList emptyTextureList; + composeAndFlush(window, region, offset, &emptyTextureList, m_context, false); + } else { + m_context->makeCurrent(window); + m_context->swapBuffers(window); } - - m_context->makeCurrent(window); - m_context->swapBuffers(window); } void QIOSBackingStore::resize(const QSize &size, const QRegion &staticContents) @@ -169,7 +169,7 @@ void QIOSBackingStore::resize(const QSize &size, const QRegion &staticContents) // size in beginPaint(). if (size != window()->size() && !window()->inherits("QWidgetWindow")) - qWarning() << "QIOSBackingStore needs to have the same size as its window"; + qWarning("QIOSBackingStore needs to have the same size as its window"); return; } diff --git a/src/plugins/platforms/ios/qioscontext.h b/src/plugins/platforms/ios/qioscontext.h index 53ef1d7b54..c8a4fae20c 100644 --- a/src/plugins/platforms/ios/qioscontext.h +++ b/src/plugins/platforms/ios/qioscontext.h @@ -64,7 +64,7 @@ public: void doneCurrent() Q_DECL_OVERRIDE; GLuint defaultFramebufferObject(QPlatformSurface *) const Q_DECL_OVERRIDE; - QFunctionPointer getProcAddress(const QByteArray &procName) Q_DECL_OVERRIDE; + QFunctionPointer getProcAddress(const char *procName) Q_DECL_OVERRIDE; bool isSharing() const Q_DECL_OVERRIDE; bool isValid() const Q_DECL_OVERRIDE; diff --git a/src/plugins/platforms/ios/qioscontext.mm b/src/plugins/platforms/ios/qioscontext.mm index b7ca88b9ee..546b003d14 100644 --- a/src/plugins/platforms/ios/qioscontext.mm +++ b/src/plugins/platforms/ios/qioscontext.mm @@ -266,9 +266,9 @@ void QIOSContext::windowDestroyed(QObject *object) } } -QFunctionPointer QIOSContext::getProcAddress(const QByteArray& functionName) +QFunctionPointer QIOSContext::getProcAddress(const char *functionName) { - return QFunctionPointer(dlsym(RTLD_DEFAULT, functionName.constData())); + return QFunctionPointer(dlsym(RTLD_DEFAULT, functionName)); } bool QIOSContext::isValid() const diff --git a/src/plugins/platforms/ios/qiosglobal.h b/src/plugins/platforms/ios/qiosglobal.h index 06ebf4809c..0fe81ceb91 100644 --- a/src/plugins/platforms/ios/qiosglobal.h +++ b/src/plugins/platforms/ios/qiosglobal.h @@ -50,11 +50,11 @@ QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(lcQpaInputMethods); #if !defined(QT_NO_DEBUG) -#define qImDebug(...) \ +#define qImDebug \ for (bool qt_category_enabled = lcQpaInputMethods().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) \ - QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC, lcQpaInputMethods().categoryName()).debug(__VA_ARGS__) + QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC, lcQpaInputMethods().categoryName()).debug #else -#define qImDebug() QT_NO_QDEBUG_MACRO() +#define qImDebug QT_NO_QDEBUG_MACRO #endif class QPlatformScreen; diff --git a/src/plugins/platforms/ios/qiosglobal.mm b/src/plugins/platforms/ios/qiosglobal.mm index 4dd66388ad..c2f3d6b9e1 100644 --- a/src/plugins/platforms/ios/qiosglobal.mm +++ b/src/plugins/platforms/ios/qiosglobal.mm @@ -93,7 +93,7 @@ Qt::ScreenOrientation toQtScreenOrientation(UIDeviceOrientation uiDeviceOrientat break; case UIDeviceOrientationFaceUp: case UIDeviceOrientationFaceDown: - qWarning() << "Falling back to Qt::PortraitOrientation for UIDeviceOrientationFaceUp/UIDeviceOrientationFaceDown"; + qWarning("Falling back to Qt::PortraitOrientation for UIDeviceOrientationFaceUp/UIDeviceOrientationFaceDown"); qtOrientation = Qt::PortraitOrientation; break; default: diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm index f2292ad0ab..d553d16698 100644 --- a/src/plugins/platforms/ios/qiosinputcontext.mm +++ b/src/plugins/platforms/ios/qiosinputcontext.mm @@ -227,7 +227,7 @@ static QUIView *focusView() Q_UNUSED(sender); if (self.state == UIGestureRecognizerStateBegan) { - qImDebug() << "hide keyboard gesture was triggered"; + qImDebug("hide keyboard gesture was triggered"); UIResponder *firstResponder = [UIResponder currentFirstResponder]; Q_ASSERT([firstResponder isKindOfClass:[QIOSTextInputResponder class]]); [firstResponder resignFirstResponder]; @@ -239,12 +239,12 @@ static QUIView *focusView() [super reset]; if (!m_context->isInputPanelVisible()) { - qImDebug() << "keyboard was hidden, disabling hide-keyboard gesture"; + qImDebug("keyboard was hidden, disabling hide-keyboard gesture"); self.enabled = NO; } else { - qImDebug() << "gesture completed without triggering"; + qImDebug("gesture completed without triggering"); if (self.hasDeferredScrollToCursor) { - qImDebug() << "applying deferred scroll to cursor"; + qImDebug("applying deferred scroll to cursor"); m_context->scrollToCursor(); } } @@ -313,22 +313,22 @@ QIOSInputContext::~QIOSInputContext() void QIOSInputContext::showInputPanel() { // No-op, keyboard controlled fully by platform based on focus - qImDebug() << "can't show virtual keyboard without a focus object, ignoring"; + qImDebug("can't show virtual keyboard without a focus object, ignoring"); } void QIOSInputContext::hideInputPanel() { if (![m_textResponder isFirstResponder]) { - qImDebug() << "QIOSTextInputResponder is not first responder, ignoring"; + qImDebug("QIOSTextInputResponder is not first responder, ignoring"); return; } if (qGuiApp->focusObject() != m_imeState.focusObject) { - qImDebug() << "current focus object does not match IM state, likely hiding from focusOut event, so ignoring"; + qImDebug("current focus object does not match IM state, likely hiding from focusOut event, so ignoring"); return; } - qImDebug() << "hiding VKB as requested by QInputMethod::hide()"; + qImDebug("hiding VKB as requested by QInputMethod::hide()"); [m_textResponder resignFirstResponder]; } @@ -380,7 +380,7 @@ void QIOSInputContext::updateKeyboardState(NSNotification *notification) qImDebug() << qPrintable(QString::fromNSString(notification.name)) << "from" << fromCGRect(frameBegin) << "to" << fromCGRect(frameEnd) << "(curve =" << m_keyboardState.animationCurve << "duration =" << m_keyboardState.animationDuration << "s)"; } else { - qImDebug() << "No notification to update keyboard state based on, just updating keyboard rect"; + qImDebug("No notification to update keyboard state based on, just updating keyboard rect"); } if (!focusView() || CGRectIsEmpty(currentKeyboardRect)) @@ -434,7 +434,7 @@ void QIOSInputContext::scrollToCursor() if (m_keyboardHideGesture.state == UIGestureRecognizerStatePossible && m_keyboardHideGesture.numberOfTouches == 1) { // Don't scroll to the cursor if the user is touching the screen and possibly // trying to trigger the hide-keyboard gesture. - qImDebug() << "deferring scrolling to cursor as we're still waiting for a possible gesture"; + qImDebug("deferring scrolling to cursor as we're still waiting for a possible gesture"); m_keyboardHideGesture.hasDeferredScrollToCursor = YES; return; } @@ -451,7 +451,7 @@ void QIOSInputContext::scrollToCursor() // We only support auto-scroll for docked keyboards for now, so make sure that's the case if (CGRectGetMaxY(m_keyboardState.keyboardEndRect) != CGRectGetMaxY([UIScreen mainScreen].bounds)) { - qImDebug() << "Keyboard not docked, ignoring request to scroll to reveal cursor"; + qImDebug("Keyboard not docked, ignoring request to scroll to reveal cursor"); return; } @@ -550,7 +550,7 @@ void QIOSInputContext::setFocusObject(QObject *focusObject) clearCurrentFocusObject(); return; } else if (focusObject == m_imeState.focusObject) { - qImDebug() << "same focus object as last update, skipping reset"; + qImDebug("same focus object as last update, skipping reset"); return; } @@ -594,23 +594,23 @@ void QIOSInputContext::update(Qt::InputMethodQueries updatedProperties) if (inputMethodAccepted()) { if (!m_textResponder || [m_textResponder needsKeyboardReconfigure:changedProperties]) { - qImDebug() << "creating new text responder"; + qImDebug("creating new text responder"); [m_textResponder autorelease]; m_textResponder = [[QIOSTextInputResponder alloc] initWithInputContext:this]; } else { - qImDebug() << "no need to reconfigure keyboard, just notifying input delegate"; + qImDebug("no need to reconfigure keyboard, just notifying input delegate"); [m_textResponder notifyInputDelegate:changedProperties]; } if (![m_textResponder isFirstResponder]) { - qImDebug() << "IM enabled, making text responder first responder"; + qImDebug("IM enabled, making text responder first responder"); [m_textResponder becomeFirstResponder]; } if (changedProperties & Qt::ImCursorRectangle) scrollToCursor(); } else if ([m_textResponder isFirstResponder]) { - qImDebug() << "IM not enabled, resigning text responder as first responder"; + qImDebug("IM not enabled, resigning text responder as first responder"); [m_textResponder resignFirstResponder]; } } @@ -640,7 +640,7 @@ bool QIOSInputContext::inputMethodAccepted() const */ void QIOSInputContext::reset() { - qImDebug() << "updating Qt::ImQueryAll and unmarking text"; + qImDebug("updating Qt::ImQueryAll and unmarking text"); update(Qt::ImQueryAll); @@ -658,7 +658,7 @@ void QIOSInputContext::reset() */ void QIOSInputContext::commit() { - qImDebug() << "unmarking text"; + qImDebug("unmarking text"); [m_textResponder unmarkText]; [m_textResponder notifyInputDelegate:Qt::ImSurroundingText]; diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm index a894963bbe..6a66bf213e 100644 --- a/src/plugins/platforms/ios/qiostextresponder.mm +++ b/src/plugins/platforms/ios/qiostextresponder.mm @@ -261,7 +261,7 @@ // as well, as the IM state that we were based on may have been invalidated when // IM was switched off. - qImDebug() << "IM was turned on, we need to check hints and platform data as well"; + qImDebug("IM was turned on, we need to check hints and platform data as well"); updatedProperties |= (Qt::ImHints | Qt::ImPlatformData); } @@ -311,7 +311,7 @@ // Don't allow activation events of the window that we're doing text on behalf on // to steal responder. if (FirstResponderCandidate::currentCandidate() == [self nextResponder]) { - qImDebug() << "not allowing parent window to steal responder"; + qImDebug("not allowing parent window to steal responder"); return NO; } @@ -334,7 +334,7 @@ if ([self currentImeState:Qt::ImEnabled].toBool()) { // The current focus object expects text input, but there // is no keyboard to get input from. So we clear focus. - qImDebug() << "no keyboard available, clearing focus object"; + qImDebug("no keyboard available, clearing focus object"); m_inputContext->clearCurrentFocusObject(); } } else { @@ -342,7 +342,7 @@ // another QIOSTextResponder was made first-responder, another UIView was // made first-responder, or the first-responder was cleared globally. In // either of these cases we don't have to do anything. - qImDebug() << "lost first responder, but not clearing focus object"; + qImDebug("lost first responder, but not clearing focus object"); } return YES; diff --git a/src/plugins/platforms/linuxfb/linuxfb.pro b/src/plugins/platforms/linuxfb/linuxfb.pro index 389d45c29c..b5de192346 100644 --- a/src/plugins/platforms/linuxfb/linuxfb.pro +++ b/src/plugins/platforms/linuxfb/linuxfb.pro @@ -1,10 +1,5 @@ TARGET = qlinuxfb -PLUGIN_TYPE = platforms -PLUGIN_CLASS_NAME = QLinuxFbIntegrationPlugin -!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - -load(qt_plugin) - QT += core-private gui-private platformsupport-private SOURCES = main.cpp qlinuxfbintegration.cpp qlinuxfbscreen.cpp @@ -13,3 +8,8 @@ HEADERS = qlinuxfbintegration.h qlinuxfbscreen.h CONFIG += qpa/genericunixfontdatabase OTHER_FILES += linuxfb.json + +PLUGIN_TYPE = platforms +PLUGIN_CLASS_NAME = QLinuxFbIntegrationPlugin +!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - +load(qt_plugin) diff --git a/src/plugins/platforms/minimal/minimal.pro b/src/plugins/platforms/minimal/minimal.pro index 3ed4d2cdde..d6914026ae 100644 --- a/src/plugins/platforms/minimal/minimal.pro +++ b/src/plugins/platforms/minimal/minimal.pro @@ -1,10 +1,5 @@ TARGET = qminimal -PLUGIN_TYPE = platforms -PLUGIN_CLASS_NAME = QMinimalIntegrationPlugin -!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - -load(qt_plugin) - QT += core-private gui-private platformsupport-private SOURCES = main.cpp \ @@ -14,3 +9,8 @@ HEADERS = qminimalintegration.h \ qminimalbackingstore.h OTHER_FILES += minimal.json + +PLUGIN_TYPE = platforms +PLUGIN_CLASS_NAME = QMinimalIntegrationPlugin +!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - +load(qt_plugin) diff --git a/src/plugins/platforms/minimal/qminimalbackingstore.cpp b/src/plugins/platforms/minimal/qminimalbackingstore.cpp index 19a581625a..402ee7e2dd 100644 --- a/src/plugins/platforms/minimal/qminimalbackingstore.cpp +++ b/src/plugins/platforms/minimal/qminimalbackingstore.cpp @@ -62,7 +62,7 @@ QMinimalBackingStore::~QMinimalBackingStore() QPaintDevice *QMinimalBackingStore::paintDevice() { if (mDebug) - qDebug() << "QMinimalBackingStore::paintDevice"; + qDebug("QMinimalBackingStore::paintDevice"); return &mImage; } diff --git a/src/plugins/platforms/minimalegl/minimalegl.pro b/src/plugins/platforms/minimalegl/minimalegl.pro index e78dcb8bc5..ac67249591 100644 --- a/src/plugins/platforms/minimalegl/minimalegl.pro +++ b/src/plugins/platforms/minimalegl/minimalegl.pro @@ -1,10 +1,5 @@ TARGET = qminimalegl -PLUGIN_TYPE = platforms -PLUGIN_CLASS_NAME = QMinimalEglIntegrationPlugin -!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - -load(qt_plugin) - QT += core-private gui-private platformsupport-private #DEFINES += QEGL_EXTRA_DEBUG @@ -29,3 +24,8 @@ CONFIG += egl qpa/genericunixfontdatabase OTHER_FILES += \ minimalegl.json + +PLUGIN_TYPE = platforms +PLUGIN_CLASS_NAME = QMinimalEglIntegrationPlugin +!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - +load(qt_plugin) diff --git a/src/plugins/platforms/mirclient/mirclient.pro b/src/plugins/platforms/mirclient/mirclient.pro index 0851e8d719..d5d35f1632 100644 --- a/src/plugins/platforms/mirclient/mirclient.pro +++ b/src/plugins/platforms/mirclient/mirclient.pro @@ -1,10 +1,4 @@ -TARGET = mirclient -TEMPLATE = lib - -PLUGIN_TYPE = platforms -PLUGIN_CLASS_NAME = MirServerIntegrationPlugin -!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - -load(qt_plugin) +TARGET = qmirclient QT += core-private gui-private platformsupport-private dbus @@ -47,3 +41,8 @@ HEADERS = \ qmirclientscreen.h \ qmirclienttheme.h \ qmirclientwindow.h + +PLUGIN_TYPE = platforms +PLUGIN_CLASS_NAME = MirServerIntegrationPlugin +!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - +load(qt_plugin) diff --git a/src/plugins/platforms/mirclient/qmirclientglcontext.cpp b/src/plugins/platforms/mirclient/qmirclientglcontext.cpp index e1e7727486..b1ca0b1f7c 100644 --- a/src/plugins/platforms/mirclient/qmirclientglcontext.cpp +++ b/src/plugins/platforms/mirclient/qmirclientglcontext.cpp @@ -40,6 +40,7 @@ #include "qmirclientlogging.h" #include <QtPlatformSupport/private/qeglconvenience_p.h> #include <QtGui/private/qopenglcontext_p.h> +#include <dlfcn.h> #if !defined(QT_NO_DEBUG) static void printOpenGLESConfig() { @@ -143,12 +144,15 @@ void QMirClientOpenGLContext::swapBuffers(QPlatformSurface* surface) ubuntuWindow->onSwapBuffersDone(); } -void (*QMirClientOpenGLContext::getProcAddress(const QByteArray& procName)) () +QFunctionPointer QMirClientOpenGLContext::getProcAddress(const char *procName) { #if defined(QT_NO_DEBUG) eglBindAPI(api_in_use()); #else ASSERT(eglBindAPI(api_in_use()) == EGL_TRUE); #endif - return eglGetProcAddress(procName.constData()); + QFunctionPointer proc = (QFunctionPointer) eglGetProcAddress(procName); + if (!proc) + proc = (QFunctionPointer) dlsym(RTLD_DEFAULT, procName); + return proc; } diff --git a/src/plugins/platforms/mirclient/qmirclientglcontext.h b/src/plugins/platforms/mirclient/qmirclientglcontext.h index 29c196ce5c..9278cc7beb 100644 --- a/src/plugins/platforms/mirclient/qmirclientglcontext.h +++ b/src/plugins/platforms/mirclient/qmirclientglcontext.h @@ -53,7 +53,7 @@ public: bool makeCurrent(QPlatformSurface* surface) override; void doneCurrent() override; bool isValid() const override { return mEglContext != EGL_NO_CONTEXT; } - void (*getProcAddress(const QByteArray& procName)) () override; + QFunctionPointer getProcAddress(const char *procName) override; EGLContext eglContext() const { return mEglContext; } diff --git a/src/plugins/platforms/mirclient/qmirclientinput.cpp b/src/plugins/platforms/mirclient/qmirclientinput.cpp index addeda634c..3af714465b 100644 --- a/src/plugins/platforms/mirclient/qmirclientinput.cpp +++ b/src/plugins/platforms/mirclient/qmirclientinput.cpp @@ -214,7 +214,7 @@ void QMirClientInput::customEvent(QEvent* event) const MirEvent *nativeEvent = ubuntuEvent->nativeEvent; if ((ubuntuEvent->window == nullptr) || (ubuntuEvent->window->window() == nullptr)) { - qWarning() << "Attempted to deliver an event to a non-existent window, ignoring."; + qWarning("Attempted to deliver an event to a non-existent window, ignoring."); return; } diff --git a/src/plugins/platforms/offscreen/offscreen.pro b/src/plugins/platforms/offscreen/offscreen.pro index 94eeac6acc..999550a7e1 100644 --- a/src/plugins/platforms/offscreen/offscreen.pro +++ b/src/plugins/platforms/offscreen/offscreen.pro @@ -1,10 +1,5 @@ TARGET = qoffscreen -PLUGIN_TYPE = platforms -PLUGIN_CLASS_NAME = QOffscreenIntegrationPlugin -!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - -load(qt_plugin) - QT += core-private gui-private platformsupport-private SOURCES = main.cpp \ @@ -25,3 +20,8 @@ contains(QT_CONFIG, xlib):contains(QT_CONFIG, opengl):!contains(QT_CONFIG, openg } else { SOURCES += qoffscreenintegration_dummy.cpp } + +PLUGIN_TYPE = platforms +PLUGIN_CLASS_NAME = QOffscreenIntegrationPlugin +!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - +load(qt_plugin) diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp index bec7fc9c96..2187eceed4 100644 --- a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp +++ b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp @@ -227,9 +227,9 @@ void QOffscreenX11GLXContext::swapBuffers(QPlatformSurface *) { } -void (*QOffscreenX11GLXContext::getProcAddress(const QByteArray &procName)) () +QFunctionPointer QOffscreenX11GLXContext::getProcAddress(const char *procName) { - return (void (*)())glXGetProcAddressARB(reinterpret_cast<const GLubyte *>(procName.constData())); + return (QFunctionPointer)glXGetProcAddressARB(reinterpret_cast<const GLubyte *>(procName)); } QSurfaceFormat QOffscreenX11GLXContext::format() const diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.h b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.h index a19ded7c11..aaca74d2fb 100644 --- a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.h +++ b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.h @@ -91,7 +91,7 @@ public: bool makeCurrent(QPlatformSurface *surface) Q_DECL_OVERRIDE; void doneCurrent() Q_DECL_OVERRIDE; void swapBuffers(QPlatformSurface *surface) Q_DECL_OVERRIDE; - QFunctionPointer getProcAddress(const QByteArray &procName) Q_DECL_OVERRIDE; + QFunctionPointer getProcAddress(const char *procName) Q_DECL_OVERRIDE; QSurfaceFormat format() const Q_DECL_OVERRIDE; bool isSharing() const Q_DECL_OVERRIDE; diff --git a/src/plugins/platforms/openwfd/openwf.pro b/src/plugins/platforms/openwfd/openwf.pro index 38bac057bd..152e4f57d7 100644 --- a/src/plugins/platforms/openwfd/openwf.pro +++ b/src/plugins/platforms/openwfd/openwf.pro @@ -1,10 +1,5 @@ TARGET = qopenwf -PLUGIN_TYPE = platforms -PLUGIN_CLASS_NAME = QOpenWFDIntegrationPlugin -!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - -load(qt_plugin) - QT += core-private gui-private platformsupport-private CONFIG += qpa/genericunixfontdatabase @@ -38,3 +33,7 @@ SOURCES += \ LIBS += -lWFD -lgbm -lGLESv2 -lEGL +PLUGIN_TYPE = platforms +PLUGIN_CLASS_NAME = QOpenWFDIntegrationPlugin +!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - +load(qt_plugin) diff --git a/src/plugins/platforms/openwfd/qopenwfddevice.cpp b/src/plugins/platforms/openwfd/qopenwfddevice.cpp index 1a4ba59817..7a9d22e74d 100644 --- a/src/plugins/platforms/openwfd/qopenwfddevice.cpp +++ b/src/plugins/platforms/openwfd/qopenwfddevice.cpp @@ -55,11 +55,11 @@ QOpenWFDDevice::QOpenWFDDevice(QOpenWFDIntegration *integration, WFDint device_e { mDevice = wfdCreateDevice(WFD_DEFAULT_DEVICE_ID,WFD_NONE); if (mDevice == WFD_INVALID_HANDLE) - qDebug() << "failed to create device"; + qDebug("failed to create device"); mEvent = wfdCreateEvent(mDevice,0); if (mEvent == WFD_INVALID_HANDLE) - qDebug() << "failed to create event handle"; + qDebug("failed to create event handle"); //initialize pipelines for device. wfdEnumeratePipelines(mDevice,WFD_NONE,0,WFD_NONE); @@ -181,22 +181,22 @@ void QOpenWFDDevice::readEvents(WFDtime wait) case WFD_EVENT_NONE: return; case WFD_EVENT_DESTROYED: - qDebug() << "Event or Device destoryed!"; + qDebug("Event or Device destoryed!"); return; case WFD_EVENT_PORT_ATTACH_DETACH: handlePortAttachDetach(); break; case WFD_EVENT_PORT_PROTECTION_FAILURE: - qDebug() << "Port protection event handling not implemented"; + qDebug("Port protection event handling not implemented"); break; case WFD_EVENT_PIPELINE_BIND_SOURCE_COMPLETE: handlePipelineBindSourceComplete(); break; case WFD_EVENT_PIPELINE_BIND_MASK_COMPLETE: - qDebug() << "Pipeline bind mask event handling not implemented"; + qDebug("Pipeline bind mask event handling not implemented"); break; default: - qDebug() << "Not recognised event type"; + qDebug("Unrecognized event type: %lu", static_cast<long unsigned int>(type)); break; } @@ -206,10 +206,10 @@ void QOpenWFDDevice::readEvents(WFDtime wait) void QOpenWFDDevice::initializeGbmAndEgl() { - qDebug() << "initializing GBM and EGL"; + qDebug("initializing GBM and EGL"); int fd = wfdGetDeviceAttribi(mDevice,WFD_DEVICE_ID); if (fd < 0) { - qDebug() << "failed to get WFD_DEVICE_ID"; + qDebug("failed to get WFD_DEVICE_ID"); } mGbmDevice = gbm_create_device(fd); @@ -221,12 +221,12 @@ void QOpenWFDDevice::initializeGbmAndEgl() EGLint minor, major; if (!eglInitialize(mEglDisplay,&major,&minor)) { - qDebug() << "failed to initialize egl"; + qDebug("failed to initialize egl"); } QByteArray eglExtensions = eglQueryString(mEglDisplay, EGL_EXTENSIONS); if (!eglExtensions.contains("EGL_KHR_surfaceless_opengl")) { - qDebug() << "This egl implementation does not have the required EGL extension EGL_KHR_surfaceless_opengl"; + qDebug("This egl implementation does not have the required EGL extension EGL_KHR_surfaceless_opengl"); } eglBindAPI(EGL_OPENGL_ES_API); @@ -238,7 +238,7 @@ void QOpenWFDDevice::initializeGbmAndEgl() mEglContext = eglCreateContext(mEglDisplay,NULL,EGL_NO_CONTEXT,contextAttribs); if (mEglContext == EGL_NO_CONTEXT) { - qDebug() << "Failed to create EGL context"; + qDebug("Failed to create EGL context"); } eglCreateImage = (PFNEGLCREATEIMAGEKHRPROC) eglGetProcAddress("eglCreateImageKHR"); @@ -269,7 +269,7 @@ void QOpenWFDDevice::handlePortAttachDetach() for (int i = 0; i < mPorts.size(); i++) { if (mPorts.at(i)->portId() == id) { indexToAdd = i; - qDebug() << "found index to attach"; + qDebug("found index to attach"); break; } } @@ -301,7 +301,7 @@ void QOpenWFDDevice::handlePipelineBindSourceComplete() WFDint overflow = wfdGetEventAttribi(mDevice,mEvent, WFD_EVENT_PIPELINE_BIND_QUEUE_OVERFLOW); if (overflow == WFD_TRUE) { - qDebug() << "PIPELINE_BIND_QUEUE_OVERFLOW event occurred"; + qDebug("PIPELINE_BIND_QUEUE_OVERFLOW event occurred"); } WFDint pipelineId = wfdGetEventAttribi(mDevice,mEvent,WFD_EVENT_PIPELINE_BIND_PIPELINE_ID); diff --git a/src/plugins/platforms/openwfd/qopenwfdglcontext.cpp b/src/plugins/platforms/openwfd/qopenwfdglcontext.cpp index d76c56db65..cf267ea203 100644 --- a/src/plugins/platforms/openwfd/qopenwfdglcontext.cpp +++ b/src/plugins/platforms/openwfd/qopenwfdglcontext.cpp @@ -41,6 +41,7 @@ #include "qopenwfdwindow.h" #include "qopenwfdscreen.h" +#include <dlfcn.h> QOpenWFDGLContext::QOpenWFDGLContext(QOpenWFDDevice *device) : QPlatformOpenGLContext() @@ -60,7 +61,7 @@ bool QOpenWFDGLContext::makeCurrent(QPlatformSurface *surface) EGLDisplay display = mWfdDevice->eglDisplay(); EGLContext context = mWfdDevice->eglContext(); if (!eglMakeCurrent(display,EGL_NO_SURFACE,EGL_NO_SURFACE,context)) { - qDebug() << "GLContext: eglMakeCurrent FAILED!"; + qDebug("GLContext: eglMakeCurrent FAILED!"); } QPlatformWindow *window = static_cast<QPlatformWindow *>(surface); @@ -84,9 +85,12 @@ void QOpenWFDGLContext::swapBuffers(QPlatformSurface *surface) screen->swapBuffers(); } -void (*QOpenWFDGLContext::getProcAddress(const QByteArray &procName)) () +QFunctionPointer QOpenWFDGLContext::getProcAddress(const char *procName) { - return eglGetProcAddress(procName.data()); + QFunctionPointer proc = (QFunctionPointer) eglGetProcAddress(procName); + if (!proc) + proc = (QFunctionPointer) dlsym(RTLD_DEFAULT, procName); + return proc; } EGLContext QOpenWFDGLContext::eglContext() const diff --git a/src/plugins/platforms/openwfd/qopenwfdglcontext.h b/src/plugins/platforms/openwfd/qopenwfdglcontext.h index 7b5a003253..1c2541e098 100644 --- a/src/plugins/platforms/openwfd/qopenwfdglcontext.h +++ b/src/plugins/platforms/openwfd/qopenwfdglcontext.h @@ -56,7 +56,7 @@ public: void swapBuffers(QPlatformSurface *surface); - void (*getProcAddress(const QByteArray &procName)) (); + QFunctionPointer getProcAddress(const char *procName); EGLContext eglContext() const; private: diff --git a/src/plugins/platforms/openwfd/qopenwfdintegration.cpp b/src/plugins/platforms/openwfd/qopenwfdintegration.cpp index 26fc93fc11..71e2b381fc 100644 --- a/src/plugins/platforms/openwfd/qopenwfdintegration.cpp +++ b/src/plugins/platforms/openwfd/qopenwfdintegration.cpp @@ -79,7 +79,7 @@ QOpenWFDIntegration::QOpenWFDIntegration() QOpenWFDIntegration::~QOpenWFDIntegration() { //don't delete screens since they are deleted by the devices - qDebug() << "deleting platform integration"; + qDebug("deleting platform integration"); for (int i = 0; i < mDevices.size(); i++) { delete mDevices[i]; } diff --git a/src/plugins/platforms/openwfd/qopenwfdoutputbuffer.cpp b/src/plugins/platforms/openwfd/qopenwfdoutputbuffer.cpp index dc560b98da..4d0de7b0d4 100644 --- a/src/plugins/platforms/openwfd/qopenwfdoutputbuffer.cpp +++ b/src/plugins/platforms/openwfd/qopenwfdoutputbuffer.cpp @@ -69,7 +69,7 @@ QOpenWFDOutputBuffer::~QOpenWFDOutputBuffer() { wfdDestroySource(mPort->device()->handle(),mWfdSource); if (!mPort->device()->eglDestroyImage(mPort->device()->eglDisplay(),mEglImage)) { - qDebug() << "could not delete eglImage"; + qDebug("could not delete eglImage"); } gbm_bo_destroy(mGbm_buffer); @@ -83,6 +83,6 @@ void QOpenWFDOutputBuffer::bindToCurrentFbo() GL_RENDERBUFFER, mRbo); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { - qDebug() << "framebuffer not ready!"; + qDebug("framebuffer not ready!"); } } diff --git a/src/plugins/platforms/openwfd/qopenwfdport.cpp b/src/plugins/platforms/openwfd/qopenwfdport.cpp index 73d1fb99e7..33254fe83c 100644 --- a/src/plugins/platforms/openwfd/qopenwfdport.cpp +++ b/src/plugins/platforms/openwfd/qopenwfdport.cpp @@ -80,7 +80,7 @@ void QOpenWFDPort::attach() Q_ASSERT(actualNumberOfPortModes == numberOfPortModes); if (!actualNumberOfPortModes) { - qDebug() << "didn't find any available port modes"; + qDebug("didn't find any available port modes"); return; } @@ -94,7 +94,7 @@ void QOpenWFDPort::attach() mPixelSize = setNativeResolutionMode(); if (mPixelSize.isEmpty()) { - qDebug() << "Could not set native resolution mode in QOpenWFPort"; + qDebug("Could not set native resolution mode in QOpenWFPort"); } WFDfloat physicalWFDSize[2]; diff --git a/src/plugins/platforms/openwfd/qopenwfdscreen.cpp b/src/plugins/platforms/openwfd/qopenwfdscreen.cpp index f8a61dbb68..ab394fa594 100644 --- a/src/plugins/platforms/openwfd/qopenwfdscreen.cpp +++ b/src/plugins/platforms/openwfd/qopenwfdscreen.cpp @@ -65,7 +65,7 @@ QOpenWFDScreen::QOpenWFDScreen(QOpenWFDPort *port) EGLContext context = mPort->device()->eglContext(); if (!eglMakeCurrent(display,EGL_NO_SURFACE,EGL_NO_SURFACE,context)) { - qDebug() << "screen: eglMakeCurrent FAILED"; + qDebug("screen: eglMakeCurrent FAILED"); } glGenFramebuffers(1,&mFbo); diff --git a/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp b/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp index d07c619752..a08ac2b839 100644 --- a/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp +++ b/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp @@ -162,7 +162,7 @@ void QQnxButtonEventNotifier::updateButtonStates() break; default: - qButtonDebug() << "Unknown hardware button"; + qButtonDebug("Unknown hardware button"); continue; } diff --git a/src/plugins/platforms/qnx/qqnxglcontext.cpp b/src/plugins/platforms/qnx/qqnxglcontext.cpp index 8207de4cbe..0d3076a743 100644 --- a/src/plugins/platforms/qnx/qqnxglcontext.cpp +++ b/src/plugins/platforms/qnx/qqnxglcontext.cpp @@ -252,7 +252,7 @@ void QQnxGLContext::swapBuffers(QPlatformSurface *surface) platformWindow->swapEGLBuffers(); } -QFunctionPointer QQnxGLContext::getProcAddress(const QByteArray &procName) +QFunctionPointer QQnxGLContext::getProcAddress(const char *procName) { qGLContextDebug(); @@ -262,7 +262,7 @@ QFunctionPointer QQnxGLContext::getProcAddress(const QByteArray &procName) qFatal("QQNX: failed to set EGL API, err=%d", eglGetError()); // Lookup EGL extension function pointer - return static_cast<QFunctionPointer>(eglGetProcAddress(procName.constData())); + return static_cast<QFunctionPointer>(eglGetProcAddress(procName)); } bool QQnxGLContext::isSharing() const diff --git a/src/plugins/platforms/qnx/qqnxglcontext.h b/src/plugins/platforms/qnx/qqnxglcontext.h index 897dbefc38..74cd3b4c48 100644 --- a/src/plugins/platforms/qnx/qqnxglcontext.h +++ b/src/plugins/platforms/qnx/qqnxglcontext.h @@ -67,7 +67,7 @@ public: bool makeCurrent(QPlatformSurface *surface); void doneCurrent(); void swapBuffers(QPlatformSurface *surface); - QFunctionPointer getProcAddress(const QByteArray &procName); + QFunctionPointer getProcAddress(const char *procName); virtual QSurfaceFormat format() const { return m_windowFormat; } bool isSharing() const; diff --git a/src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp b/src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp index 64f38265f6..79ff74b113 100644 --- a/src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp +++ b/src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp @@ -385,7 +385,7 @@ static int32_t ic_perform_editor_action(input_session_t *ic, int32_t editor_acti Q_UNUSED(ic); Q_UNUSED(editor_action); - qCritical() << "ic_perform_editor_action not implemented"; + qCritical("ic_perform_editor_action not implemented"); return 0; } @@ -395,7 +395,7 @@ static int32_t ic_report_fullscreen_mode(input_session_t *ic, int32_t enabled) Q_UNUSED(ic); Q_UNUSED(enabled); - qCritical() << "ic_report_fullscreen_mode not implemented"; + qCritical("ic_report_fullscreen_mode not implemented"); return 0; } @@ -406,7 +406,7 @@ static extracted_text_t *ic_get_extracted_text(input_session_t *ic, extracted_te Q_UNUSED(request); Q_UNUSED(flags); - qCritical() << "ic_get_extracted_text not implemented"; + qCritical("ic_get_extracted_text not implemented"); return 0; } @@ -416,7 +416,7 @@ static spannable_string_t *ic_get_selected_text(input_session_t *ic, int32_t fla Q_UNUSED(ic); Q_UNUSED(flags); - qCritical() << "ic_get_selected_text not implemented"; + qCritical("ic_get_selected_text not implemented"); return 0; } @@ -426,7 +426,7 @@ static int32_t ic_get_cursor_caps_mode(input_session_t *ic, int32_t req_modes) Q_UNUSED(ic); Q_UNUSED(req_modes); - qCritical() << "ic_get_cursor_caps_mode not implemented"; + qCritical("ic_get_cursor_caps_mode not implemented"); return 0; } @@ -436,7 +436,7 @@ static int32_t ic_clear_meta_key_states(input_session_t *ic, int32_t states) Q_UNUSED(ic); Q_UNUSED(states); - qCritical() << "ic_clear_meta_key_states not implemented"; + qCritical("ic_clear_meta_key_states not implemented"); return 0; } @@ -447,7 +447,7 @@ static int32_t ic_set_selection(input_session_t *ic, int32_t start, int32_t end) Q_UNUSED(start); Q_UNUSED(end); - qCritical() << "ic_set_selection not implemented"; + qCritical("ic_set_selection not implemented"); return 0; } diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp index 261c8e8773..599d43a8c8 100644 --- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp +++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp @@ -553,7 +553,7 @@ void QQnxScreenEventHandler::handleDisplayEvent(screen_event_t event) if (val[0] == 0 && val[1] == 0) //If screen size is invalid, wait for the next event return; - qScreenEventDebug() << "creating new QQnxScreen for newly attached display"; + qScreenEventDebug("creating new QQnxScreen for newly attached display"); m_qnxIntegration->createDisplay(nativeDisplay, false /* not primary, we assume */); } } else if (!isAttached) { @@ -566,7 +566,7 @@ void QQnxScreenEventHandler::handleDisplayEvent(screen_event_t event) if (!screen->isPrimaryScreen()) { // libscreen display is deactivated, let's remove the QQnxScreen / QScreen - qScreenEventDebug() << "removing display"; + qScreenEventDebug("removing display"); m_qnxIntegration->removeDisplay(screen); } } diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp index 9d591286c0..e04f16db92 100644 --- a/src/plugins/platforms/qnx/qqnxwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxwindow.cpp @@ -475,7 +475,7 @@ void QQnxWindow::setParent(const QPlatformWindow *window) return; if (screen()->rootWindow() == this) { - qWarning() << "Application window cannot be reparented"; + qWarning("Application window cannot be reparented"); return; } diff --git a/src/plugins/platforms/windows/openglblacklists/default.json b/src/plugins/platforms/windows/openglblacklists/default.json index 767eac161c..f7a8844611 100644 --- a/src/plugins/platforms/windows/openglblacklists/default.json +++ b/src/plugins/platforms/windows/openglblacklists/default.json @@ -78,6 +78,18 @@ "features": [ "disable_rotation" ] + }, + { + "id": 7, + "description": "AMD FirePro V5900 driver causes crashes in Direct3D on Windows.", + "vendor_id": "0x1002", + "device_id": ["0x6707"], + "os": { + "type": "win" + }, + "features": [ + "disable_angle" + ] } ] } diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index 72d9d5a71b..0eab37aed2 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -1472,18 +1472,21 @@ public: }; // Return the first suffix from the name filter "Foo files (*.foo;*.bar)" -> "foo". +// Also handles the simple name filter case "*.txt" -> "txt" static inline QString suffixFromFilter(const QString &filter) { - int suffixPos = filter.indexOf(QLatin1String("(*.")); + int suffixPos = filter.indexOf(QLatin1String("*.")); if (suffixPos < 0) return QString(); - suffixPos += 3; + suffixPos += 2; int endPos = filter.indexOf(QLatin1Char(' '), suffixPos + 1); if (endPos < 0) endPos = filter.indexOf(QLatin1Char(';'), suffixPos + 1); if (endPos < 0) endPos = filter.indexOf(QLatin1Char(')'), suffixPos + 1); - return endPos >= 0 ? filter.mid(suffixPos, endPos - suffixPos) : QString(); + if (endPos < 0) + endPos = filter.size(); + return filter.mid(suffixPos, endPos - suffixPos); } void QWindowsNativeSaveFileDialog::setNameFilters(const QStringList &f) diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp index a11196d1d2..42caeb1c89 100644 --- a/src/plugins/platforms/windows/qwindowseglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp @@ -107,11 +107,7 @@ static void *resolveFunc(HMODULE lib, const char *name) void *QWindowsLibEGL::resolve(const char *name) { - void *proc = m_lib ? resolveFunc(m_lib, name) : 0; - if (!proc) - qErrnoWarning(::GetLastError(), "Failed to resolve EGL function %s", name); - - return proc; + return m_lib ? resolveFunc(m_lib, name) : 0; } #endif // !QT_STATIC @@ -174,11 +170,7 @@ bool QWindowsLibEGL::init() #if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC) void *QWindowsLibGLESv2::resolve(const char *name) { - void *proc = m_lib ? resolveFunc(m_lib, name) : 0; - if (!proc) - qWarning() << "Failed to resolve OpenGL ES function" << name; - - return proc; + return m_lib ? resolveFunc(m_lib, name) : 0; } #endif // !QT_STATIC @@ -200,150 +192,10 @@ bool QWindowsLibGLESv2::init() } #endif // !QT_STATIC - glBindTexture = RESOLVE((void (APIENTRY *)(GLenum , GLuint )), glBindTexture); - glBlendFunc = RESOLVE((void (APIENTRY *)(GLenum , GLenum )), glBlendFunc); - glClear = RESOLVE((void (APIENTRY *)(GLbitfield )), glClear); - glClearColor = RESOLVE((void (APIENTRY *)(GLfloat , GLfloat , GLfloat , GLfloat )), glClearColor); - glClearStencil = RESOLVE((void (APIENTRY *)(GLint )), glClearStencil); - glColorMask = RESOLVE((void (APIENTRY *)(GLboolean , GLboolean , GLboolean , GLboolean )), glColorMask); - glCopyTexImage2D = RESOLVE((void (APIENTRY *)(GLenum , GLint , GLenum , GLint , GLint , GLsizei , GLsizei , GLint )), glCopyTexImage2D); - glCopyTexSubImage2D = RESOLVE((void (APIENTRY *)(GLenum , GLint , GLint , GLint , GLint , GLint , GLsizei , GLsizei )), glCopyTexSubImage2D); - glCullFace = RESOLVE((void (APIENTRY *)(GLenum )), glCullFace); - glDeleteTextures = RESOLVE((void (APIENTRY *)(GLsizei , const GLuint *)), glDeleteTextures); - glDepthFunc = RESOLVE((void (APIENTRY *)(GLenum )), glDepthFunc); - glDepthMask = RESOLVE((void (APIENTRY *)(GLboolean )), glDepthMask); - glDisable = RESOLVE((void (APIENTRY *)(GLenum )), glDisable); - glDrawArrays = RESOLVE((void (APIENTRY *)(GLenum , GLint , GLsizei )), glDrawArrays); - glDrawElements = RESOLVE((void (APIENTRY *)(GLenum , GLsizei , GLenum , const GLvoid *)), glDrawElements); - glEnable = RESOLVE((void (APIENTRY *)(GLenum )), glEnable); - glFinish = RESOLVE((void (APIENTRY *)()), glFinish); - glFlush = RESOLVE((void (APIENTRY *)()), glFlush); - glFrontFace = RESOLVE((void (APIENTRY *)(GLenum )), glFrontFace); - glGenTextures = RESOLVE((void (APIENTRY *)(GLsizei , GLuint *)), glGenTextures); - glGetBooleanv = RESOLVE((void (APIENTRY *)(GLenum , GLboolean *)), glGetBooleanv); - glGetError = RESOLVE((GLenum (APIENTRY *)()), glGetError); - glGetFloatv = RESOLVE((void (APIENTRY *)(GLenum , GLfloat *)), glGetFloatv); - glGetIntegerv = RESOLVE((void (APIENTRY *)(GLenum , GLint *)), glGetIntegerv); + void (APIENTRY * glBindTexture)(GLenum target, GLuint texture) = RESOLVE((void (APIENTRY *)(GLenum , GLuint )), glBindTexture); + GLuint (APIENTRY * glCreateShader)(GLenum type) = RESOLVE((GLuint (APIENTRY *)(GLenum )), glCreateShader); + void (APIENTRY * glClearDepthf)(GLclampf depth) = RESOLVE((void (APIENTRY *)(GLclampf )), glClearDepthf); glGetString = RESOLVE((const GLubyte * (APIENTRY *)(GLenum )), glGetString); - glGetTexParameterfv = RESOLVE((void (APIENTRY *)(GLenum , GLenum , GLfloat *)), glGetTexParameterfv); - glGetTexParameteriv = RESOLVE((void (APIENTRY *)(GLenum , GLenum , GLint *)), glGetTexParameteriv); - glHint = RESOLVE((void (APIENTRY *)(GLenum , GLenum )), glHint); - glIsEnabled = RESOLVE((GLboolean (APIENTRY *)(GLenum )), glIsEnabled); - glIsTexture = RESOLVE((GLboolean (APIENTRY *)(GLuint )), glIsTexture); - glLineWidth = RESOLVE((void (APIENTRY *)(GLfloat )), glLineWidth); - glPixelStorei = RESOLVE((void (APIENTRY *)(GLenum , GLint )), glPixelStorei); - glPolygonOffset = RESOLVE((void (APIENTRY *)(GLfloat , GLfloat )), glPolygonOffset); - glReadPixels = RESOLVE((void (APIENTRY *)(GLint , GLint , GLsizei , GLsizei , GLenum , GLenum , GLvoid *)), glReadPixels); - glScissor = RESOLVE((void (APIENTRY *)(GLint , GLint , GLsizei , GLsizei )), glScissor); - glStencilFunc = RESOLVE((void (APIENTRY *)(GLenum , GLint , GLuint )), glStencilFunc); - glStencilMask = RESOLVE((void (APIENTRY *)(GLuint )), glStencilMask); - glStencilOp = RESOLVE((void (APIENTRY *)(GLenum , GLenum , GLenum )), glStencilOp); - glTexImage2D = RESOLVE((void (APIENTRY *)(GLenum , GLint , GLint , GLsizei , GLsizei , GLint , GLenum , GLenum , const GLvoid *)), glTexImage2D); - glTexParameterf = RESOLVE((void (APIENTRY *)(GLenum , GLenum , GLfloat )), glTexParameterf); - glTexParameterfv = RESOLVE((void (APIENTRY *)(GLenum , GLenum , const GLfloat *)), glTexParameterfv); - glTexParameteri = RESOLVE((void (APIENTRY *)(GLenum , GLenum , GLint )), glTexParameteri); - glTexParameteriv = RESOLVE((void (APIENTRY *)(GLenum , GLenum , const GLint *)), glTexParameteriv); - glTexSubImage2D = RESOLVE((void (APIENTRY *)(GLenum , GLint , GLint , GLint , GLsizei , GLsizei , GLenum , GLenum , const GLvoid *)), glTexSubImage2D); - glViewport = RESOLVE((void (APIENTRY *)(GLint , GLint , GLsizei , GLsizei )), glViewport); - - glActiveTexture = RESOLVE((void (APIENTRY *)(GLenum)), glActiveTexture); - glAttachShader = RESOLVE((void (APIENTRY *)(GLuint , GLuint )), glAttachShader); - glBindAttribLocation = RESOLVE((void (APIENTRY *)(GLuint , GLuint , const GLchar* )), glBindAttribLocation); - glBindBuffer = RESOLVE((void (APIENTRY *)(GLenum , GLuint )), glBindBuffer); - glBindFramebuffer = RESOLVE((void (APIENTRY *)(GLenum , GLuint )), glBindFramebuffer); - glBindRenderbuffer = RESOLVE((void (APIENTRY *)(GLenum , GLuint )), glBindRenderbuffer); - glBlendColor = RESOLVE((void (APIENTRY *)(GLclampf , GLclampf , GLclampf , GLclampf )), glBlendColor); - glBlendEquation = RESOLVE((void (APIENTRY *)(GLenum )), glBlendEquation); - glBlendEquationSeparate = RESOLVE((void (APIENTRY *)(GLenum , GLenum )), glBlendEquationSeparate); - glBlendFuncSeparate = RESOLVE((void (APIENTRY *)(GLenum , GLenum , GLenum , GLenum )), glBlendFuncSeparate); - glBufferData = RESOLVE((void (APIENTRY *)(GLenum , qopengl_GLsizeiptr , const GLvoid* , GLenum )), glBufferData); - glBufferSubData = RESOLVE((void (APIENTRY *)(GLenum , qopengl_GLintptr , qopengl_GLsizeiptr , const GLvoid* )), glBufferSubData); - glCheckFramebufferStatus = RESOLVE((GLenum (APIENTRY *)(GLenum )), glCheckFramebufferStatus); - glCompileShader = RESOLVE((void (APIENTRY *)(GLuint )), glCompileShader); - glCompressedTexImage2D = RESOLVE((void (APIENTRY *)(GLenum , GLint , GLenum , GLsizei , GLsizei, GLint, GLsizei, const GLvoid* )), glCompressedTexImage2D); - glCompressedTexSubImage2D = RESOLVE((void (APIENTRY *)(GLenum , GLint , GLint , GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid* )), glCompressedTexSubImage2D); - glCreateProgram = RESOLVE((GLuint (APIENTRY *)(void)), glCreateProgram); - glCreateShader = RESOLVE((GLuint (APIENTRY *)(GLenum )), glCreateShader); - glDeleteBuffers = RESOLVE((void (APIENTRY *)(GLsizei , const GLuint*)), glDeleteBuffers); - glDeleteFramebuffers = RESOLVE((void (APIENTRY *)(GLsizei , const GLuint* )), glDeleteFramebuffers); - glDeleteProgram = RESOLVE((void (APIENTRY *)(GLuint )), glDeleteProgram); - glDeleteRenderbuffers = RESOLVE((void (APIENTRY *)(GLsizei , const GLuint* )), glDeleteRenderbuffers); - glDeleteShader = RESOLVE((void (APIENTRY *)(GLuint )), glDeleteShader); - glDetachShader = RESOLVE((void (APIENTRY *)(GLuint , GLuint )), glDetachShader); - glDisableVertexAttribArray = RESOLVE((void (APIENTRY *)(GLuint )), glDisableVertexAttribArray); - glEnableVertexAttribArray = RESOLVE((void (APIENTRY *)(GLuint )), glEnableVertexAttribArray); - glFramebufferRenderbuffer = RESOLVE((void (APIENTRY *)(GLenum , GLenum , GLenum , GLuint )), glFramebufferRenderbuffer); - glFramebufferTexture2D = RESOLVE((void (APIENTRY *)(GLenum , GLenum , GLenum , GLuint , GLint )), glFramebufferTexture2D); - glGenBuffers = RESOLVE((void (APIENTRY *)(GLsizei , GLuint* )), glGenBuffers); - glGenerateMipmap = RESOLVE((void (APIENTRY *)(GLenum )), glGenerateMipmap); - glGenFramebuffers = RESOLVE((void (APIENTRY *)(GLsizei , GLuint* )), glGenFramebuffers); - glGenRenderbuffers = RESOLVE((void (APIENTRY *)(GLsizei , GLuint* )), glGenRenderbuffers); - glGetActiveAttrib = RESOLVE((void (APIENTRY *)(GLuint , GLuint , GLsizei , GLsizei* , GLint* , GLenum* , GLchar* )), glGetActiveAttrib); - glGetActiveUniform = RESOLVE((void (APIENTRY *)(GLuint , GLuint , GLsizei , GLsizei* , GLint* , GLenum* , GLchar* )), glGetActiveUniform); - glGetAttachedShaders = RESOLVE((void (APIENTRY *)(GLuint , GLsizei , GLsizei*, GLuint* )), glGetAttachedShaders); - glGetAttribLocation = RESOLVE((int (APIENTRY *)(GLuint , const GLchar* )), glGetAttribLocation); - glGetBufferParameteriv = RESOLVE((void (APIENTRY *)(GLenum , GLenum , GLint* )), glGetBufferParameteriv); - glGetFramebufferAttachmentParameteriv = RESOLVE((void (APIENTRY *)(GLenum , GLenum, GLenum , GLint* )), glGetFramebufferAttachmentParameteriv); - glGetProgramiv = RESOLVE((void (APIENTRY *)(GLuint , GLenum , GLint* )), glGetProgramiv); - glGetProgramInfoLog = RESOLVE((void (APIENTRY *)(GLuint , GLsizei , GLsizei* , GLchar* )), glGetProgramInfoLog); - glGetRenderbufferParameteriv = RESOLVE((void (APIENTRY *)(GLenum , GLenum , GLint* )), glGetRenderbufferParameteriv); - glGetShaderiv = RESOLVE((void (APIENTRY *)(GLuint , GLenum , GLint* )), glGetShaderiv); - glGetShaderInfoLog = RESOLVE((void (APIENTRY *)(GLuint , GLsizei , GLsizei*, GLchar*)), glGetShaderInfoLog); - glGetShaderPrecisionFormat = RESOLVE((void (APIENTRY *)(GLenum , GLenum , GLint* , GLint* )), glGetShaderPrecisionFormat); - glGetShaderSource = RESOLVE((void (APIENTRY *)(GLuint , GLsizei , GLsizei* , GLchar* )), glGetShaderSource); - glGetUniformfv = RESOLVE((void (APIENTRY *)(GLuint , GLint , GLfloat*)), glGetUniformfv); - glGetUniformiv = RESOLVE((void (APIENTRY *)(GLuint , GLint , GLint*)), glGetUniformiv); - glGetUniformLocation = RESOLVE((int (APIENTRY *)(GLuint , const GLchar* )), glGetUniformLocation); - glGetVertexAttribfv = RESOLVE((void (APIENTRY *)(GLuint , GLenum , GLfloat* )), glGetVertexAttribfv); - glGetVertexAttribiv = RESOLVE((void (APIENTRY *)(GLuint , GLenum , GLint* )), glGetVertexAttribiv); - glGetVertexAttribPointerv = RESOLVE((void (APIENTRY *)(GLuint , GLenum , GLvoid** pointer)), glGetVertexAttribPointerv); - glIsBuffer = RESOLVE((GLboolean (APIENTRY *)(GLuint )), glIsBuffer); - glIsFramebuffer = RESOLVE((GLboolean (APIENTRY *)(GLuint )), glIsFramebuffer); - glIsProgram = RESOLVE((GLboolean (APIENTRY *)(GLuint )), glIsProgram); - glIsRenderbuffer = RESOLVE((GLboolean (APIENTRY *)(GLuint )), glIsRenderbuffer); - glIsShader = RESOLVE((GLboolean (APIENTRY *)(GLuint )), glIsShader); - glLinkProgram = RESOLVE((void (APIENTRY *)(GLuint )), glLinkProgram); - glReleaseShaderCompiler = RESOLVE((void (APIENTRY *)(void)), glReleaseShaderCompiler); - glRenderbufferStorage = RESOLVE((void (APIENTRY *)(GLenum , GLenum , GLsizei , GLsizei )), glRenderbufferStorage); - glSampleCoverage = RESOLVE((void (APIENTRY *)(GLclampf , GLboolean )), glSampleCoverage); - glShaderBinary = RESOLVE((void (APIENTRY *)(GLsizei , const GLuint*, GLenum , const GLvoid* , GLsizei )), glShaderBinary); - glShaderSource = RESOLVE((void (APIENTRY *)(GLuint , GLsizei , const GLchar* *, const GLint* )), glShaderSource); - glStencilFuncSeparate = RESOLVE((void (APIENTRY *)(GLenum , GLenum , GLint , GLuint )), glStencilFuncSeparate); - glStencilMaskSeparate = RESOLVE((void (APIENTRY *)(GLenum , GLuint )), glStencilMaskSeparate); - glStencilOpSeparate = RESOLVE((void (APIENTRY *)(GLenum , GLenum , GLenum , GLenum )), glStencilOpSeparate); - glUniform1f = RESOLVE((void (APIENTRY *)(GLint , GLfloat )), glUniform1f); - glUniform1fv = RESOLVE((void (APIENTRY *)(GLint , GLsizei , const GLfloat* )), glUniform1fv); - glUniform1i = RESOLVE((void (APIENTRY *)(GLint , GLint )), glUniform1i); - glUniform1iv = RESOLVE((void (APIENTRY *)(GLint , GLsizei , const GLint* )), glUniform1iv); - glUniform2f = RESOLVE((void (APIENTRY *)(GLint , GLfloat , GLfloat )), glUniform2f); - glUniform2fv = RESOLVE((void (APIENTRY *)(GLint , GLsizei , const GLfloat* )), glUniform2fv); - glUniform2i = RESOLVE((void (APIENTRY *)(GLint , GLint , GLint )), glUniform2i); - glUniform2iv = RESOLVE((void (APIENTRY *)(GLint , GLsizei , const GLint* )), glUniform2iv); - glUniform3f = RESOLVE((void (APIENTRY *)(GLint , GLfloat , GLfloat , GLfloat )), glUniform3f); - glUniform3fv = RESOLVE((void (APIENTRY *)(GLint , GLsizei , const GLfloat* )), glUniform3fv); - glUniform3i = RESOLVE((void (APIENTRY *)(GLint , GLint , GLint , GLint )), glUniform3i); - glUniform3iv = RESOLVE((void (APIENTRY *)(GLint , GLsizei , const GLint* )), glUniform3iv); - glUniform4f = RESOLVE((void (APIENTRY *)(GLint , GLfloat , GLfloat , GLfloat , GLfloat )), glUniform4f); - glUniform4fv = RESOLVE((void (APIENTRY *)(GLint , GLsizei , const GLfloat* )), glUniform4fv); - glUniform4i = RESOLVE((void (APIENTRY *)(GLint , GLint , GLint , GLint , GLint )), glUniform4i); - glUniform4iv = RESOLVE((void (APIENTRY *)(GLint , GLsizei , const GLint* )), glUniform4iv); - glUniformMatrix2fv = RESOLVE((void (APIENTRY *)(GLint , GLsizei , GLboolean , const GLfloat* )), glUniformMatrix2fv); - glUniformMatrix3fv = RESOLVE((void (APIENTRY *)(GLint , GLsizei , GLboolean , const GLfloat* )), glUniformMatrix3fv); - glUniformMatrix4fv = RESOLVE((void (APIENTRY *)(GLint , GLsizei , GLboolean , const GLfloat* )), glUniformMatrix4fv); - glUseProgram = RESOLVE((void (APIENTRY *)(GLuint )), glUseProgram); - glValidateProgram = RESOLVE((void (APIENTRY *)(GLuint )), glValidateProgram); - glVertexAttrib1f = RESOLVE((void (APIENTRY *)(GLuint , GLfloat )), glVertexAttrib1f); - glVertexAttrib1fv = RESOLVE((void (APIENTRY *)(GLuint , const GLfloat* )), glVertexAttrib1fv); - glVertexAttrib2f = RESOLVE((void (APIENTRY *)(GLuint , GLfloat , GLfloat )), glVertexAttrib2f); - glVertexAttrib2fv = RESOLVE((void (APIENTRY *)(GLuint , const GLfloat* )), glVertexAttrib2fv); - glVertexAttrib3f = RESOLVE((void (APIENTRY *)(GLuint , GLfloat , GLfloat , GLfloat )), glVertexAttrib3f); - glVertexAttrib3fv = RESOLVE((void (APIENTRY *)(GLuint , const GLfloat* )), glVertexAttrib3fv); - glVertexAttrib4f = RESOLVE((void (APIENTRY *)(GLuint , GLfloat , GLfloat , GLfloat , GLfloat )), glVertexAttrib4f); - glVertexAttrib4fv = RESOLVE((void (APIENTRY *)(GLuint , const GLfloat* )), glVertexAttrib4fv); - glVertexAttribPointer = RESOLVE((void (APIENTRY *)(GLuint , GLint, GLenum, GLboolean, GLsizei, const GLvoid* )), glVertexAttribPointer); - - glClearDepthf = RESOLVE((void (APIENTRY *)(GLclampf )), glClearDepthf); - glDepthRangef = RESOLVE((void (APIENTRY *)(GLclampf , GLclampf )), glDepthRangef); return glBindTexture && glCreateShader && glClearDepthf; } @@ -683,170 +535,192 @@ void QWindowsEGLContext::swapBuffers(QPlatformSurface *surface) } } -QFunctionPointer QWindowsEGLContext::getProcAddress(const QByteArray &procName) +QFunctionPointer QWindowsEGLContext::getProcAddress(const char *procName) { + QWindowsEGLStaticContext::libEGL.eglBindAPI(m_api); + + QFunctionPointer procAddress = nullptr; + + // Special logic for ANGLE extensions for blitFramebuffer and + // renderbufferStorageMultisample. In version 2 contexts the extensions + // must be used instead of the suffixless, version 3.0 functions. + if (m_format.majorVersion() < 3) { + if (!strcmp(procName, "glBlitFramebuffer") || !strcmp(procName, "glRenderbufferStorageMultisample")) { + char extName[32 + 5 + 1]; + strcpy(extName, procName); + strcat(extName, "ANGLE"); + procAddress = reinterpret_cast<QFunctionPointer>(QWindowsEGLStaticContext::libEGL.eglGetProcAddress(extName)); + } + } + + if (!procAddress) + procAddress = reinterpret_cast<QFunctionPointer>(QWindowsEGLStaticContext::libEGL.eglGetProcAddress(procName)); + // We support AllGLFunctionsQueryable, which means this function must be able to // return a function pointer for standard GLES2 functions too. These are not // guaranteed to be queryable via eglGetProcAddress(). - static struct StdFunc { - const char *name; - void *func; - } standardFuncs[] = { - { "glBindTexture", (void *) QWindowsEGLStaticContext::libGLESv2.glBindTexture }, - { "glBlendFunc", (void *) QWindowsEGLStaticContext::libGLESv2.glBlendFunc }, - { "glClear", (void *) QWindowsEGLStaticContext::libGLESv2.glClear }, - { "glClearColor", (void *) QWindowsEGLStaticContext::libGLESv2.glClearColor }, - { "glClearStencil", (void *) QWindowsEGLStaticContext::libGLESv2.glClearStencil }, - { "glColorMask", (void *) QWindowsEGLStaticContext::libGLESv2.glColorMask }, - { "glCopyTexImage2D", (void *) QWindowsEGLStaticContext::libGLESv2.glCopyTexImage2D }, - { "glCopyTexSubImage2D", (void *) QWindowsEGLStaticContext::libGLESv2.glCopyTexSubImage2D }, - { "glCullFace", (void *) QWindowsEGLStaticContext::libGLESv2.glCullFace }, - { "glDeleteTextures", (void *) QWindowsEGLStaticContext::libGLESv2.glDeleteTextures }, - { "glDepthFunc", (void *) QWindowsEGLStaticContext::libGLESv2.glDepthFunc }, - { "glDepthMask", (void *) QWindowsEGLStaticContext::libGLESv2.glDepthMask }, - { "glDisable", (void *) QWindowsEGLStaticContext::libGLESv2.glDisable }, - { "glDrawArrays", (void *) QWindowsEGLStaticContext::libGLESv2.glDrawArrays }, - { "glDrawElements", (void *) QWindowsEGLStaticContext::libGLESv2.glDrawElements }, - { "glEnable", (void *) QWindowsEGLStaticContext::libGLESv2.glEnable }, - { "glFinish", (void *) QWindowsEGLStaticContext::libGLESv2.glFinish }, - { "glFlush", (void *) QWindowsEGLStaticContext::libGLESv2.glFlush }, - { "glFrontFace", (void *) QWindowsEGLStaticContext::libGLESv2.glFrontFace }, - { "glGenTextures", (void *) QWindowsEGLStaticContext::libGLESv2.glGenTextures }, - { "glGetBooleanv", (void *) QWindowsEGLStaticContext::libGLESv2.glGetBooleanv }, - { "glGetError", (void *) QWindowsEGLStaticContext::libGLESv2.glGetError }, - { "glGetFloatv", (void *) QWindowsEGLStaticContext::libGLESv2.glGetFloatv }, - { "glGetIntegerv", (void *) QWindowsEGLStaticContext::libGLESv2.glGetIntegerv }, - { "glGetString", (void *) QWindowsEGLStaticContext::libGLESv2.glGetString }, - { "glGetTexParameterfv", (void *) QWindowsEGLStaticContext::libGLESv2.glGetTexParameterfv }, - { "glGetTexParameteriv", (void *) QWindowsEGLStaticContext::libGLESv2.glGetTexParameteriv }, - { "glHint", (void *) QWindowsEGLStaticContext::libGLESv2.glHint }, - { "glIsEnabled", (void *) QWindowsEGLStaticContext::libGLESv2.glIsEnabled }, - { "glIsTexture", (void *) QWindowsEGLStaticContext::libGLESv2.glIsTexture }, - { "glLineWidth", (void *) QWindowsEGLStaticContext::libGLESv2.glLineWidth }, - { "glPixelStorei", (void *) QWindowsEGLStaticContext::libGLESv2.glPixelStorei }, - { "glPolygonOffset", (void *) QWindowsEGLStaticContext::libGLESv2.glPolygonOffset }, - { "glReadPixels", (void *) QWindowsEGLStaticContext::libGLESv2.glReadPixels }, - { "glScissor", (void *) QWindowsEGLStaticContext::libGLESv2.glScissor }, - { "glStencilFunc", (void *) QWindowsEGLStaticContext::libGLESv2.glStencilFunc }, - { "glStencilMask", (void *) QWindowsEGLStaticContext::libGLESv2.glStencilMask }, - { "glStencilOp", (void *) QWindowsEGLStaticContext::libGLESv2.glStencilOp }, - { "glTexImage2D", (void *) QWindowsEGLStaticContext::libGLESv2.glTexImage2D }, - { "glTexParameterf", (void *) QWindowsEGLStaticContext::libGLESv2.glTexParameterf }, - { "glTexParameterfv", (void *) QWindowsEGLStaticContext::libGLESv2.glTexParameterfv }, - { "glTexParameteri", (void *) QWindowsEGLStaticContext::libGLESv2.glTexParameteri }, - { "glTexParameteriv", (void *) QWindowsEGLStaticContext::libGLESv2.glTexParameteriv }, - { "glTexSubImage2D", (void *) QWindowsEGLStaticContext::libGLESv2.glTexSubImage2D }, - { "glViewport", (void *) QWindowsEGLStaticContext::libGLESv2.glViewport }, - - { "glActiveTexture", (void *) QWindowsEGLStaticContext::libGLESv2.glActiveTexture }, - { "glAttachShader", (void *) QWindowsEGLStaticContext::libGLESv2.glAttachShader }, - { "glBindAttribLocation", (void *) QWindowsEGLStaticContext::libGLESv2.glBindAttribLocation }, - { "glBindBuffer", (void *) QWindowsEGLStaticContext::libGLESv2.glBindBuffer }, - { "glBindFramebuffer", (void *) QWindowsEGLStaticContext::libGLESv2.glBindFramebuffer }, - { "glBindRenderbuffer", (void *) QWindowsEGLStaticContext::libGLESv2.glBindRenderbuffer }, - { "glBlendColor", (void *) QWindowsEGLStaticContext::libGLESv2.glBlendColor }, - { "glBlendEquation", (void *) QWindowsEGLStaticContext::libGLESv2.glBlendEquation }, - { "glBlendEquationSeparate", (void *) QWindowsEGLStaticContext::libGLESv2.glBlendEquationSeparate }, - { "glBlendFuncSeparate", (void *) QWindowsEGLStaticContext::libGLESv2.glBlendFuncSeparate }, - { "glBufferData", (void *) QWindowsEGLStaticContext::libGLESv2.glBufferData }, - { "glBufferSubData", (void *) QWindowsEGLStaticContext::libGLESv2.glBufferSubData }, - { "glCheckFramebufferStatus", (void *) QWindowsEGLStaticContext::libGLESv2.glCheckFramebufferStatus }, - { "glCompileShader", (void *) QWindowsEGLStaticContext::libGLESv2.glCompileShader }, - { "glCompressedTexImage2D", (void *) QWindowsEGLStaticContext::libGLESv2.glCompressedTexImage2D }, - { "glCompressedTexSubImage2D", (void *) QWindowsEGLStaticContext::libGLESv2.glCompressedTexSubImage2D }, - { "glCreateProgram", (void *) QWindowsEGLStaticContext::libGLESv2.glCreateProgram }, - { "glCreateShader", (void *) QWindowsEGLStaticContext::libGLESv2.glCreateShader }, - { "glDeleteBuffers", (void *) QWindowsEGLStaticContext::libGLESv2.glDeleteBuffers }, - { "glDeleteFramebuffers", (void *) QWindowsEGLStaticContext::libGLESv2.glDeleteFramebuffers }, - { "glDeleteProgram", (void *) QWindowsEGLStaticContext::libGLESv2.glDeleteProgram }, - { "glDeleteRenderbuffers", (void *) QWindowsEGLStaticContext::libGLESv2.glDeleteRenderbuffers }, - { "glDeleteShader", (void *) QWindowsEGLStaticContext::libGLESv2.glDeleteShader }, - { "glDetachShader", (void *) QWindowsEGLStaticContext::libGLESv2.glDetachShader }, - { "glDisableVertexAttribArray", (void *) QWindowsEGLStaticContext::libGLESv2.glDisableVertexAttribArray }, - { "glEnableVertexAttribArray", (void *) QWindowsEGLStaticContext::libGLESv2.glEnableVertexAttribArray }, - { "glFramebufferRenderbuffer", (void *) QWindowsEGLStaticContext::libGLESv2.glFramebufferRenderbuffer }, - { "glFramebufferTexture2D", (void *) QWindowsEGLStaticContext::libGLESv2.glFramebufferTexture2D }, - { "glGenBuffers", (void *) QWindowsEGLStaticContext::libGLESv2.glGenBuffers }, - { "glGenerateMipmap", (void *) QWindowsEGLStaticContext::libGLESv2.glGenerateMipmap }, - { "glGenFramebuffers", (void *) QWindowsEGLStaticContext::libGLESv2.glGenFramebuffers }, - { "glGenRenderbuffers", (void *) QWindowsEGLStaticContext::libGLESv2.glGenRenderbuffers }, - { "glGetActiveAttrib", (void *) QWindowsEGLStaticContext::libGLESv2.glGetActiveAttrib }, - { "glGetActiveUniform", (void *) QWindowsEGLStaticContext::libGLESv2.glGetActiveUniform }, - { "glGetAttachedShaders", (void *) QWindowsEGLStaticContext::libGLESv2.glGetAttachedShaders }, - { "glGetAttribLocation", (void *) QWindowsEGLStaticContext::libGLESv2.glGetAttribLocation }, - { "glGetBufferParameteriv", (void *) QWindowsEGLStaticContext::libGLESv2.glGetBufferParameteriv }, - { "glGetFramebufferAttachmentParameteriv", (void *) QWindowsEGLStaticContext::libGLESv2.glGetFramebufferAttachmentParameteriv }, - { "glGetProgramiv", (void *) QWindowsEGLStaticContext::libGLESv2.glGetProgramiv }, - { "glGetProgramInfoLog", (void *) QWindowsEGLStaticContext::libGLESv2.glGetProgramInfoLog }, - { "glGetRenderbufferParameteriv", (void *) QWindowsEGLStaticContext::libGLESv2.glGetRenderbufferParameteriv }, - { "glGetShaderiv", (void *) QWindowsEGLStaticContext::libGLESv2.glGetShaderiv }, - { "glGetShaderInfoLog", (void *) QWindowsEGLStaticContext::libGLESv2.glGetShaderInfoLog }, - { "glGetShaderPrecisionFormat", (void *) QWindowsEGLStaticContext::libGLESv2.glGetShaderPrecisionFormat }, - { "glGetShaderSource", (void *) QWindowsEGLStaticContext::libGLESv2.glGetShaderSource }, - { "glGetUniformfv", (void *) QWindowsEGLStaticContext::libGLESv2.glGetUniformfv }, - { "glGetUniformiv", (void *) QWindowsEGLStaticContext::libGLESv2.glGetUniformiv }, - { "glGetUniformLocation", (void *) QWindowsEGLStaticContext::libGLESv2.glGetUniformLocation }, - { "glGetVertexAttribfv", (void *) QWindowsEGLStaticContext::libGLESv2.glGetVertexAttribfv }, - { "glGetVertexAttribiv", (void *) QWindowsEGLStaticContext::libGLESv2.glGetVertexAttribiv }, - { "glGetVertexAttribPointerv", (void *) QWindowsEGLStaticContext::libGLESv2.glGetVertexAttribPointerv }, - { "glIsBuffer", (void *) QWindowsEGLStaticContext::libGLESv2.glIsBuffer }, - { "glIsFramebuffer", (void *) QWindowsEGLStaticContext::libGLESv2.glIsFramebuffer }, - { "glIsProgram", (void *) QWindowsEGLStaticContext::libGLESv2.glIsProgram }, - { "glIsRenderbuffer", (void *) QWindowsEGLStaticContext::libGLESv2.glIsRenderbuffer }, - { "glIsShader", (void *) QWindowsEGLStaticContext::libGLESv2.glIsShader }, - { "glLinkProgram", (void *) QWindowsEGLStaticContext::libGLESv2.glLinkProgram }, - { "glReleaseShaderCompiler", (void *) QWindowsEGLStaticContext::libGLESv2.glReleaseShaderCompiler }, - { "glRenderbufferStorage", (void *) QWindowsEGLStaticContext::libGLESv2.glRenderbufferStorage }, - { "glSampleCoverage", (void *) QWindowsEGLStaticContext::libGLESv2.glSampleCoverage }, - { "glShaderBinary", (void *) QWindowsEGLStaticContext::libGLESv2.glShaderBinary }, - { "glShaderSource", (void *) QWindowsEGLStaticContext::libGLESv2.glShaderSource }, - { "glStencilFuncSeparate", (void *) QWindowsEGLStaticContext::libGLESv2.glStencilFuncSeparate }, - { "glStencilMaskSeparate", (void *) QWindowsEGLStaticContext::libGLESv2.glStencilMaskSeparate }, - { "glStencilOpSeparate", (void *) QWindowsEGLStaticContext::libGLESv2.glStencilOpSeparate }, - { "glUniform1f", (void *) QWindowsEGLStaticContext::libGLESv2.glUniform1f }, - { "glUniform1fv", (void *) QWindowsEGLStaticContext::libGLESv2.glUniform1fv }, - { "glUniform1i", (void *) QWindowsEGLStaticContext::libGLESv2.glUniform1i }, - { "glUniform1iv", (void *) QWindowsEGLStaticContext::libGLESv2.glUniform1iv }, - { "glUniform2f", (void *) QWindowsEGLStaticContext::libGLESv2.glUniform2f }, - { "glUniform2fv", (void *) QWindowsEGLStaticContext::libGLESv2.glUniform2fv }, - { "glUniform2i", (void *) QWindowsEGLStaticContext::libGLESv2.glUniform2i }, - { "glUniform2iv", (void *) QWindowsEGLStaticContext::libGLESv2.glUniform2iv }, - { "glUniform3f", (void *) QWindowsEGLStaticContext::libGLESv2.glUniform3f }, - { "glUniform3fv", (void *) QWindowsEGLStaticContext::libGLESv2.glUniform3fv }, - { "glUniform3i", (void *) QWindowsEGLStaticContext::libGLESv2.glUniform3i }, - { "glUniform3iv", (void *) QWindowsEGLStaticContext::libGLESv2.glUniform3iv }, - { "glUniform4f", (void *) QWindowsEGLStaticContext::libGLESv2.glUniform4f }, - { "glUniform4fv", (void *) QWindowsEGLStaticContext::libGLESv2.glUniform4fv }, - { "glUniform4i", (void *) QWindowsEGLStaticContext::libGLESv2.glUniform4i }, - { "glUniform4iv", (void *) QWindowsEGLStaticContext::libGLESv2.glUniform4iv }, - { "glUniformMatrix2fv", (void *) QWindowsEGLStaticContext::libGLESv2.glUniformMatrix2fv }, - { "glUniformMatrix3fv", (void *) QWindowsEGLStaticContext::libGLESv2.glUniformMatrix3fv }, - { "glUniformMatrix4fv", (void *) QWindowsEGLStaticContext::libGLESv2.glUniformMatrix4fv }, - { "glUseProgram", (void *) QWindowsEGLStaticContext::libGLESv2.glUseProgram }, - { "glValidateProgram", (void *) QWindowsEGLStaticContext::libGLESv2.glValidateProgram }, - { "glVertexAttrib1f", (void *) QWindowsEGLStaticContext::libGLESv2.glVertexAttrib1f }, - { "glVertexAttrib1fv", (void *) QWindowsEGLStaticContext::libGLESv2.glVertexAttrib1fv }, - { "glVertexAttrib2f", (void *) QWindowsEGLStaticContext::libGLESv2.glVertexAttrib2f }, - { "glVertexAttrib2fv", (void *) QWindowsEGLStaticContext::libGLESv2.glVertexAttrib2fv }, - { "glVertexAttrib3f", (void *) QWindowsEGLStaticContext::libGLESv2.glVertexAttrib3f }, - { "glVertexAttrib3fv", (void *) QWindowsEGLStaticContext::libGLESv2.glVertexAttrib3fv }, - { "glVertexAttrib4f", (void *) QWindowsEGLStaticContext::libGLESv2.glVertexAttrib4f }, - { "glVertexAttrib4fv", (void *) QWindowsEGLStaticContext::libGLESv2.glVertexAttrib4fv }, - { "glVertexAttribPointer", (void *) QWindowsEGLStaticContext::libGLESv2.glVertexAttribPointer }, - - { "glClearDepthf", (void *) QWindowsEGLStaticContext::libGLESv2.glClearDepthf }, - { "glDepthRangef", (void *) QWindowsEGLStaticContext::libGLESv2.glDepthRangef } - }; - for (size_t i = 0; i < sizeof(standardFuncs) / sizeof(StdFunc); ++i) - if (procName == standardFuncs[i].name) - return reinterpret_cast<QFunctionPointer>(standardFuncs[i].func); + if (!procAddress) { +#if defined(QT_STATIC) + static struct StdFunc { + const char *name; + void *func; + } standardFuncs[] = { + { "glBindTexture", (void *) ::glBindTexture }, + { "glBlendFunc", (void *) ::glBlendFunc }, + { "glClear", (void *) ::glClear }, + { "glClearColor", (void *) ::glClearColor }, + { "glClearStencil", (void *) ::glClearStencil }, + { "glColorMask", (void *) ::glColorMask }, + { "glCopyTexImage2D", (void *) ::glCopyTexImage2D }, + { "glCopyTexSubImage2D", (void *) ::glCopyTexSubImage2D }, + { "glCullFace", (void *) ::glCullFace }, + { "glDeleteTextures", (void *) ::glDeleteTextures }, + { "glDepthFunc", (void *) ::glDepthFunc }, + { "glDepthMask", (void *) ::glDepthMask }, + { "glDisable", (void *) ::glDisable }, + { "glDrawArrays", (void *) ::glDrawArrays }, + { "glDrawElements", (void *) ::glDrawElements }, + { "glEnable", (void *) ::glEnable }, + { "glFinish", (void *) ::glFinish }, + { "glFlush", (void *) ::glFlush }, + { "glFrontFace", (void *) ::glFrontFace }, + { "glGenTextures", (void *) ::glGenTextures }, + { "glGetBooleanv", (void *) ::glGetBooleanv }, + { "glGetError", (void *) ::glGetError }, + { "glGetFloatv", (void *) ::glGetFloatv }, + { "glGetIntegerv", (void *) ::glGetIntegerv }, + { "glGetString", (void *) ::glGetString }, + { "glGetTexParameterfv", (void *) ::glGetTexParameterfv }, + { "glGetTexParameteriv", (void *) ::glGetTexParameteriv }, + { "glHint", (void *) ::glHint }, + { "glIsEnabled", (void *) ::glIsEnabled }, + { "glIsTexture", (void *) ::glIsTexture }, + { "glLineWidth", (void *) ::glLineWidth }, + { "glPixelStorei", (void *) ::glPixelStorei }, + { "glPolygonOffset", (void *) ::glPolygonOffset }, + { "glReadPixels", (void *) ::glReadPixels }, + { "glScissor", (void *) ::glScissor }, + { "glStencilFunc", (void *) ::glStencilFunc }, + { "glStencilMask", (void *) ::glStencilMask }, + { "glStencilOp", (void *) ::glStencilOp }, + { "glTexImage2D", (void *) ::glTexImage2D }, + { "glTexParameterf", (void *) ::glTexParameterf }, + { "glTexParameterfv", (void *) ::glTexParameterfv }, + { "glTexParameteri", (void *) ::glTexParameteri }, + { "glTexParameteriv", (void *) ::glTexParameteriv }, + { "glTexSubImage2D", (void *) ::glTexSubImage2D }, + { "glViewport", (void *) ::glViewport }, + + { "glActiveTexture", (void *) ::glActiveTexture }, + { "glAttachShader", (void *) ::glAttachShader }, + { "glBindAttribLocation", (void *) ::glBindAttribLocation }, + { "glBindBuffer", (void *) ::glBindBuffer }, + { "glBindFramebuffer", (void *) ::glBindFramebuffer }, + { "glBindRenderbuffer", (void *) ::glBindRenderbuffer }, + { "glBlendColor", (void *) ::glBlendColor }, + { "glBlendEquation", (void *) ::glBlendEquation }, + { "glBlendEquationSeparate", (void *) ::glBlendEquationSeparate }, + { "glBlendFuncSeparate", (void *) ::glBlendFuncSeparate }, + { "glBufferData", (void *) ::glBufferData }, + { "glBufferSubData", (void *) ::glBufferSubData }, + { "glCheckFramebufferStatus", (void *) ::glCheckFramebufferStatus }, + { "glCompileShader", (void *) ::glCompileShader }, + { "glCompressedTexImage2D", (void *) ::glCompressedTexImage2D }, + { "glCompressedTexSubImage2D", (void *) ::glCompressedTexSubImage2D }, + { "glCreateProgram", (void *) ::glCreateProgram }, + { "glCreateShader", (void *) ::glCreateShader }, + { "glDeleteBuffers", (void *) ::glDeleteBuffers }, + { "glDeleteFramebuffers", (void *) ::glDeleteFramebuffers }, + { "glDeleteProgram", (void *) ::glDeleteProgram }, + { "glDeleteRenderbuffers", (void *) ::glDeleteRenderbuffers }, + { "glDeleteShader", (void *) ::glDeleteShader }, + { "glDetachShader", (void *) ::glDetachShader }, + { "glDisableVertexAttribArray", (void *) ::glDisableVertexAttribArray }, + { "glEnableVertexAttribArray", (void *) ::glEnableVertexAttribArray }, + { "glFramebufferRenderbuffer", (void *) ::glFramebufferRenderbuffer }, + { "glFramebufferTexture2D", (void *) ::glFramebufferTexture2D }, + { "glGenBuffers", (void *) ::glGenBuffers }, + { "glGenerateMipmap", (void *) ::glGenerateMipmap }, + { "glGenFramebuffers", (void *) ::glGenFramebuffers }, + { "glGenRenderbuffers", (void *) ::glGenRenderbuffers }, + { "glGetActiveAttrib", (void *) ::glGetActiveAttrib }, + { "glGetActiveUniform", (void *) ::glGetActiveUniform }, + { "glGetAttachedShaders", (void *) ::glGetAttachedShaders }, + { "glGetAttribLocation", (void *) ::glGetAttribLocation }, + { "glGetBufferParameteriv", (void *) ::glGetBufferParameteriv }, + { "glGetFramebufferAttachmentParameteriv", (void *) ::glGetFramebufferAttachmentParameteriv }, + { "glGetProgramiv", (void *) ::glGetProgramiv }, + { "glGetProgramInfoLog", (void *) ::glGetProgramInfoLog }, + { "glGetRenderbufferParameteriv", (void *) ::glGetRenderbufferParameteriv }, + { "glGetShaderiv", (void *) ::glGetShaderiv }, + { "glGetShaderInfoLog", (void *) ::glGetShaderInfoLog }, + { "glGetShaderPrecisionFormat", (void *) ::glGetShaderPrecisionFormat }, + { "glGetShaderSource", (void *) ::glGetShaderSource }, + { "glGetUniformfv", (void *) ::glGetUniformfv }, + { "glGetUniformiv", (void *) ::glGetUniformiv }, + { "glGetUniformLocation", (void *) ::glGetUniformLocation }, + { "glGetVertexAttribfv", (void *) ::glGetVertexAttribfv }, + { "glGetVertexAttribiv", (void *) ::glGetVertexAttribiv }, + { "glGetVertexAttribPointerv", (void *) ::glGetVertexAttribPointerv }, + { "glIsBuffer", (void *) ::glIsBuffer }, + { "glIsFramebuffer", (void *) ::glIsFramebuffer }, + { "glIsProgram", (void *) ::glIsProgram }, + { "glIsRenderbuffer", (void *) ::glIsRenderbuffer }, + { "glIsShader", (void *) ::glIsShader }, + { "glLinkProgram", (void *) ::glLinkProgram }, + { "glReleaseShaderCompiler", (void *) ::glReleaseShaderCompiler }, + { "glRenderbufferStorage", (void *) ::glRenderbufferStorage }, + { "glSampleCoverage", (void *) ::glSampleCoverage }, + { "glShaderBinary", (void *) ::glShaderBinary }, + { "glShaderSource", (void *) ::glShaderSource }, + { "glStencilFuncSeparate", (void *) ::glStencilFuncSeparate }, + { "glStencilMaskSeparate", (void *) ::glStencilMaskSeparate }, + { "glStencilOpSeparate", (void *) ::glStencilOpSeparate }, + { "glUniform1f", (void *) ::glUniform1f }, + { "glUniform1fv", (void *) ::glUniform1fv }, + { "glUniform1i", (void *) ::glUniform1i }, + { "glUniform1iv", (void *) ::glUniform1iv }, + { "glUniform2f", (void *) ::glUniform2f }, + { "glUniform2fv", (void *) ::glUniform2fv }, + { "glUniform2i", (void *) ::glUniform2i }, + { "glUniform2iv", (void *) ::glUniform2iv }, + { "glUniform3f", (void *) ::glUniform3f }, + { "glUniform3fv", (void *) ::glUniform3fv }, + { "glUniform3i", (void *) ::glUniform3i }, + { "glUniform3iv", (void *) ::glUniform3iv }, + { "glUniform4f", (void *) ::glUniform4f }, + { "glUniform4fv", (void *) ::glUniform4fv }, + { "glUniform4i", (void *) ::glUniform4i }, + { "glUniform4iv", (void *) ::glUniform4iv }, + { "glUniformMatrix2fv", (void *) ::glUniformMatrix2fv }, + { "glUniformMatrix3fv", (void *) ::glUniformMatrix3fv }, + { "glUniformMatrix4fv", (void *) ::glUniformMatrix4fv }, + { "glUseProgram", (void *) ::glUseProgram }, + { "glValidateProgram", (void *) ::glValidateProgram }, + { "glVertexAttrib1f", (void *) ::glVertexAttrib1f }, + { "glVertexAttrib1fv", (void *) ::glVertexAttrib1fv }, + { "glVertexAttrib2f", (void *) ::glVertexAttrib2f }, + { "glVertexAttrib2fv", (void *) ::glVertexAttrib2fv }, + { "glVertexAttrib3f", (void *) ::glVertexAttrib3f }, + { "glVertexAttrib3fv", (void *) ::glVertexAttrib3fv }, + { "glVertexAttrib4f", (void *) ::glVertexAttrib4f }, + { "glVertexAttrib4fv", (void *) ::glVertexAttrib4fv }, + { "glVertexAttribPointer", (void *) ::glVertexAttribPointer }, + + { "glClearDepthf", (void *) ::glClearDepthf }, + { "glDepthRangef", (void *) ::glDepthRangef } + }; + for (size_t i = 0; i < sizeof(standardFuncs) / sizeof(StdFunc); ++i) + if (!qstrcmp(procName, standardFuncs[i].name)) + return reinterpret_cast<QFunctionPointer>(standardFuncs[i].func); +#else + procAddress = reinterpret_cast<QFunctionPointer>(QWindowsEGLStaticContext::libGLESv2.resolve(procName)); +#endif +} - QWindowsEGLStaticContext::libEGL.eglBindAPI(m_api); - QFunctionPointer procAddress = reinterpret_cast<QFunctionPointer>(QWindowsEGLStaticContext::libEGL.eglGetProcAddress(procName.constData())); if (QWindowsContext::verbose > 1) qCDebug(lcQpaGl) << __FUNCTION__ << procName << QWindowsEGLStaticContext::libEGL.eglGetCurrentContext() << "returns" << procAddress; - if (!procAddress && QWindowsContext::verbose) - qWarning("%s: Unable to resolve '%s'", __FUNCTION__, procName.constData()); + return procAddress; } diff --git a/src/plugins/platforms/windows/qwindowseglcontext.h b/src/plugins/platforms/windows/qwindowseglcontext.h index ccc2cdcad1..c7f7cee3c2 100644 --- a/src/plugins/platforms/windows/qwindowseglcontext.h +++ b/src/plugins/platforms/windows/qwindowseglcontext.h @@ -98,157 +98,11 @@ struct QWindowsLibGLESv2 void *moduleHandle() const { return Q_NULLPTR; } #endif - // GL1+GLES2 common - void (APIENTRY * glBindTexture)(GLenum target, GLuint texture); - void (APIENTRY * glBlendFunc)(GLenum sfactor, GLenum dfactor); - void (APIENTRY * glClear)(GLbitfield mask); - void (APIENTRY * glClearColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); - void (APIENTRY * glClearStencil)(GLint s); - void (APIENTRY * glColorMask)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); - void (APIENTRY * glCopyTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); - void (APIENTRY * glCopyTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); - void (APIENTRY * glCullFace)(GLenum mode); - void (APIENTRY * glDeleteTextures)(GLsizei n, const GLuint* textures); - void (APIENTRY * glDepthFunc)(GLenum func); - void (APIENTRY * glDepthMask)(GLboolean flag); - void (APIENTRY * glDisable)(GLenum cap); - void (APIENTRY * glDrawArrays)(GLenum mode, GLint first, GLsizei count); - void (APIENTRY * glDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices); - void (APIENTRY * glEnable)(GLenum cap); - void (APIENTRY * glFinish)(); - void (APIENTRY * glFlush)(); - void (APIENTRY * glFrontFace)(GLenum mode); - void (APIENTRY * glGenTextures)(GLsizei n, GLuint* textures); - void (APIENTRY * glGetBooleanv)(GLenum pname, GLboolean* params); - GLenum (APIENTRY * glGetError)(); - void (APIENTRY * glGetFloatv)(GLenum pname, GLfloat* params); - void (APIENTRY * glGetIntegerv)(GLenum pname, GLint* params); const GLubyte * (APIENTRY * glGetString)(GLenum name); - void (APIENTRY * glGetTexParameterfv)(GLenum target, GLenum pname, GLfloat* params); - void (APIENTRY * glGetTexParameteriv)(GLenum target, GLenum pname, GLint* params); - void (APIENTRY * glHint)(GLenum target, GLenum mode); - GLboolean (APIENTRY * glIsEnabled)(GLenum cap); - GLboolean (APIENTRY * glIsTexture)(GLuint texture); - void (APIENTRY * glLineWidth)(GLfloat width); - void (APIENTRY * glPixelStorei)(GLenum pname, GLint param); - void (APIENTRY * glPolygonOffset)(GLfloat factor, GLfloat units); - void (APIENTRY * glReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels); - void (APIENTRY * glScissor)(GLint x, GLint y, GLsizei width, GLsizei height); - void (APIENTRY * glStencilFunc)(GLenum func, GLint ref, GLuint mask); - void (APIENTRY * glStencilMask)(GLuint mask); - void (APIENTRY * glStencilOp)(GLenum fail, GLenum zfail, GLenum zpass); - void (APIENTRY * glTexImage2D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels); - void (APIENTRY * glTexParameterf)(GLenum target, GLenum pname, GLfloat param); - void (APIENTRY * glTexParameterfv)(GLenum target, GLenum pname, const GLfloat* params); - void (APIENTRY * glTexParameteri)(GLenum target, GLenum pname, GLint param); - void (APIENTRY * glTexParameteriv)(GLenum target, GLenum pname, const GLint* params); - void (APIENTRY * glTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels); - void (APIENTRY * glViewport)(GLint x, GLint y, GLsizei width, GLsizei height); - // GLES2 - void (APIENTRY * glActiveTexture)(GLenum texture); - void (APIENTRY * glAttachShader)(GLuint program, GLuint shader); - void (APIENTRY * glBindAttribLocation)(GLuint program, GLuint index, const char* name); - void (APIENTRY * glBindBuffer)(GLenum target, GLuint buffer); - void (APIENTRY * glBindFramebuffer)(GLenum target, GLuint framebuffer); - void (APIENTRY * glBindRenderbuffer)(GLenum target, GLuint renderbuffer); - void (APIENTRY * glBlendColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); - void (APIENTRY * glBlendEquation)(GLenum mode); - void (APIENTRY * glBlendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha); - void (APIENTRY * glBlendFuncSeparate)(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); - void (APIENTRY * glBufferData)(GLenum target, qopengl_GLsizeiptr size, const void* data, GLenum usage); - void (APIENTRY * glBufferSubData)(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr size, const void* data); - GLenum (APIENTRY * glCheckFramebufferStatus)(GLenum target); - void (APIENTRY * glCompileShader)(GLuint shader); - void (APIENTRY * glCompressedTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data); - void (APIENTRY * glCompressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data); - GLuint (APIENTRY * glCreateProgram)(); - GLuint (APIENTRY * glCreateShader)(GLenum type); - void (APIENTRY * glDeleteBuffers)(GLsizei n, const GLuint* buffers); - void (APIENTRY * glDeleteFramebuffers)(GLsizei n, const GLuint* framebuffers); - void (APIENTRY * glDeleteProgram)(GLuint program); - void (APIENTRY * glDeleteRenderbuffers)(GLsizei n, const GLuint* renderbuffers); - void (APIENTRY * glDeleteShader)(GLuint shader); - void (APIENTRY * glDetachShader)(GLuint program, GLuint shader); - void (APIENTRY * glDisableVertexAttribArray)(GLuint index); - void (APIENTRY * glEnableVertexAttribArray)(GLuint index); - void (APIENTRY * glFramebufferRenderbuffer)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); - void (APIENTRY * glFramebufferTexture2D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); - void (APIENTRY * glGenBuffers)(GLsizei n, GLuint* buffers); - void (APIENTRY * glGenerateMipmap)(GLenum target); - void (APIENTRY * glGenFramebuffers)(GLsizei n, GLuint* framebuffers); - void (APIENTRY * glGenRenderbuffers)(GLsizei n, GLuint* renderbuffers); - void (APIENTRY * glGetActiveAttrib)(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name); - void (APIENTRY * glGetActiveUniform)(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name); - void (APIENTRY * glGetAttachedShaders)(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); - GLint (APIENTRY * glGetAttribLocation)(GLuint program, const char* name); - void (APIENTRY * glGetBufferParameteriv)(GLenum target, GLenum pname, GLint* params); - void (APIENTRY * glGetFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment, GLenum pname, GLint* params); - void (APIENTRY * glGetProgramiv)(GLuint program, GLenum pname, GLint* params); - void (APIENTRY * glGetProgramInfoLog)(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog); - void (APIENTRY * glGetRenderbufferParameteriv)(GLenum target, GLenum pname, GLint* params); - void (APIENTRY * glGetShaderiv)(GLuint shader, GLenum pname, GLint* params); - void (APIENTRY * glGetShaderInfoLog)(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog); - void (APIENTRY * glGetShaderPrecisionFormat)(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); - void (APIENTRY * glGetShaderSource)(GLuint shader, GLsizei bufsize, GLsizei* length, char* source); - void (APIENTRY * glGetUniformfv)(GLuint program, GLint location, GLfloat* params); - void (APIENTRY * glGetUniformiv)(GLuint program, GLint location, GLint* params); - GLint (APIENTRY * glGetUniformLocation)(GLuint program, const char* name); - void (APIENTRY * glGetVertexAttribfv)(GLuint index, GLenum pname, GLfloat* params); - void (APIENTRY * glGetVertexAttribiv)(GLuint index, GLenum pname, GLint* params); - void (APIENTRY * glGetVertexAttribPointerv)(GLuint index, GLenum pname, void** pointer); - GLboolean (APIENTRY * glIsBuffer)(GLuint buffer); - GLboolean (APIENTRY * glIsFramebuffer)(GLuint framebuffer); - GLboolean (APIENTRY * glIsProgram)(GLuint program); - GLboolean (APIENTRY * glIsRenderbuffer)(GLuint renderbuffer); - GLboolean (APIENTRY * glIsShader)(GLuint shader); - void (APIENTRY * glLinkProgram)(GLuint program); - void (APIENTRY * glReleaseShaderCompiler)(); - void (APIENTRY * glRenderbufferStorage)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); - void (APIENTRY * glSampleCoverage)(GLclampf value, GLboolean invert); - void (APIENTRY * glShaderBinary)(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length); - void (APIENTRY * glShaderSource)(GLuint shader, GLsizei count, const char** string, const GLint* length); - void (APIENTRY * glStencilFuncSeparate)(GLenum face, GLenum func, GLint ref, GLuint mask); - void (APIENTRY * glStencilMaskSeparate)(GLenum face, GLuint mask); - void (APIENTRY * glStencilOpSeparate)(GLenum face, GLenum fail, GLenum zfail, GLenum zpass); - void (APIENTRY * glUniform1f)(GLint location, GLfloat x); - void (APIENTRY * glUniform1fv)(GLint location, GLsizei count, const GLfloat* v); - void (APIENTRY * glUniform1i)(GLint location, GLint x); - void (APIENTRY * glUniform1iv)(GLint location, GLsizei count, const GLint* v); - void (APIENTRY * glUniform2f)(GLint location, GLfloat x, GLfloat y); - void (APIENTRY * glUniform2fv)(GLint location, GLsizei count, const GLfloat* v); - void (APIENTRY * glUniform2i)(GLint location, GLint x, GLint y); - void (APIENTRY * glUniform2iv)(GLint location, GLsizei count, const GLint* v); - void (APIENTRY * glUniform3f)(GLint location, GLfloat x, GLfloat y, GLfloat z); - void (APIENTRY * glUniform3fv)(GLint location, GLsizei count, const GLfloat* v); - void (APIENTRY * glUniform3i)(GLint location, GLint x, GLint y, GLint z); - void (APIENTRY * glUniform3iv)(GLint location, GLsizei count, const GLint* v); - void (APIENTRY * glUniform4f)(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); - void (APIENTRY * glUniform4fv)(GLint location, GLsizei count, const GLfloat* v); - void (APIENTRY * glUniform4i)(GLint location, GLint x, GLint y, GLint z, GLint w); - void (APIENTRY * glUniform4iv)(GLint location, GLsizei count, const GLint* v); - void (APIENTRY * glUniformMatrix2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); - void (APIENTRY * glUniformMatrix3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); - void (APIENTRY * glUniformMatrix4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); - void (APIENTRY * glUseProgram)(GLuint program); - void (APIENTRY * glValidateProgram)(GLuint program); - void (APIENTRY * glVertexAttrib1f)(GLuint indx, GLfloat x); - void (APIENTRY * glVertexAttrib1fv)(GLuint indx, const GLfloat* values); - void (APIENTRY * glVertexAttrib2f)(GLuint indx, GLfloat x, GLfloat y); - void (APIENTRY * glVertexAttrib2fv)(GLuint indx, const GLfloat* values); - void (APIENTRY * glVertexAttrib3f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z); - void (APIENTRY * glVertexAttrib3fv)(GLuint indx, const GLfloat* values); - void (APIENTRY * glVertexAttrib4f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w); - void (APIENTRY * glVertexAttrib4fv)(GLuint indx, const GLfloat* values); - void (APIENTRY * glVertexAttribPointer)(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr); - - // ES only - void (APIENTRY * glClearDepthf)(GLclampf depth); - void (APIENTRY * glDepthRangef)(GLclampf nearVal, GLclampf farVal); - -private: #if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC) void *resolve(const char *name); +private: HMODULE m_lib; #endif }; @@ -292,7 +146,7 @@ public: bool makeCurrent(QPlatformSurface *surface) Q_DECL_OVERRIDE; void doneCurrent() Q_DECL_OVERRIDE; void swapBuffers(QPlatformSurface *surface) Q_DECL_OVERRIDE; - QFunctionPointer getProcAddress(const QByteArray &procName) Q_DECL_OVERRIDE; + QFunctionPointer getProcAddress(const char *procName) Q_DECL_OVERRIDE; QSurfaceFormat format() const Q_DECL_OVERRIDE { return m_format; } bool isSharing() const Q_DECL_OVERRIDE { return m_shareContext != EGL_NO_CONTEXT; } diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp index 743408949d..966be8c991 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp @@ -1769,28 +1769,35 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request, lf.lfFaceName[nameSubstituteLength] = 0; } - IDWriteFont *directWriteFont = 0; - HRESULT hr = data->directWriteGdiInterop->CreateFontFromLOGFONT(&lf, &directWriteFont); - if (FAILED(hr)) { - const QString errorString = qt_error_string(int(GetLastError())); - qWarning().noquote().nospace() << "DirectWrite: CreateFontFromLOGFONT() failed (" - << errorString << ") for " << request << ' ' << lf << " dpi=" << dpi; + HFONT hfont = CreateFontIndirect(&lf); + if (!hfont) { + qErrnoWarning("%s: CreateFontIndirect failed", __FUNCTION__); } else { + HGDIOBJ oldFont = SelectObject(data->hdc, hfont); + IDWriteFontFace *directWriteFontFace = NULL; - hr = directWriteFont->CreateFontFace(&directWriteFontFace); + HRESULT hr = data->directWriteGdiInterop->CreateFontFaceFromHdc(data->hdc, &directWriteFontFace); if (FAILED(hr)) { - const QString errorString = qt_error_string(int(GetLastError())); - qWarning().noquote() << "DirectWrite: CreateFontFace() failed (" + const QString errorString = qt_error_string(int(hr)); + qWarning().noquote().nospace() << "DirectWrite: CreateFontFaceFromHDC() failed (" << errorString << ") for " << request << ' ' << lf << " dpi=" << dpi; } else { QWindowsFontEngineDirectWrite *fedw = new QWindowsFontEngineDirectWrite(directWriteFontFace, request.pixelSize, data); - fedw->initFontInfo(request, dpi, directWriteFont); + + wchar_t n[64]; + GetTextFace(data->hdc, 64, n); + + QFontDef fontDef = request; + fontDef.family = QString::fromWCharArray(n); + + fedw->initFontInfo(fontDef, dpi); fe = fedw; } - directWriteFont->Release(); + SelectObject(data->hdc, oldFont); + DeleteObject(hfont); } } #endif // QT_NO_DIRECTWRITE diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp index c78412c8ec..a3e3870d90 100644 --- a/src/plugins/platforms/windows/qwindowsfontengine.cpp +++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp @@ -37,11 +37,6 @@ ** ****************************************************************************/ -#if _WIN32_WINNT < 0x0500 -#undef _WIN32_WINNT -#define _WIN32_WINNT 0x0500 -#endif - #include "qwindowsintegration.h" #include "qwindowsfontengine.h" #include "qwindowsnativeimage.h" @@ -85,11 +80,8 @@ QT_BEGIN_NAMESPACE #define TT_PRIM_CSPLINE 3 #endif -#ifdef MAKE_TAG -#undef MAKE_TAG -#endif // GetFontData expects the tags in little endian ;( -#define MAKE_TAG(ch1, ch2, ch3, ch4) (\ +#define MAKE_LITTLE_ENDIAN_TAG(ch1, ch2, ch3, ch4) (\ (((quint32)(ch4)) << 24) | \ (((quint32)(ch3)) << 16) | \ (((quint32)(ch2)) << 8) | \ @@ -142,28 +134,28 @@ bool QWindowsFontEngine::hasCFFTable() const { HDC hdc = m_fontEngineData->hdc; SelectObject(hdc, hfont); - return GetFontData(hdc, MAKE_TAG('C', 'F', 'F', ' '), 0, 0, 0) != GDI_ERROR; + return GetFontData(hdc, MAKE_LITTLE_ENDIAN_TAG('C', 'F', 'F', ' '), 0, 0, 0) != GDI_ERROR; } bool QWindowsFontEngine::hasCMapTable() const { HDC hdc = m_fontEngineData->hdc; SelectObject(hdc, hfont); - return GetFontData(hdc, MAKE_TAG('c', 'm', 'a', 'p'), 0, 0, 0) != GDI_ERROR; + return GetFontData(hdc, MAKE_LITTLE_ENDIAN_TAG('c', 'm', 'a', 'p'), 0, 0, 0) != GDI_ERROR; } bool QWindowsFontEngine::hasGlyfTable() const { HDC hdc = m_fontEngineData->hdc; SelectObject(hdc, hfont); - return GetFontData(hdc, MAKE_TAG('g', 'l', 'y', 'f'), 0, 0, 0) != GDI_ERROR; + return GetFontData(hdc, MAKE_LITTLE_ENDIAN_TAG('g', 'l', 'y', 'f'), 0, 0, 0) != GDI_ERROR; } bool QWindowsFontEngine::hasEbdtTable() const { HDC hdc = m_fontEngineData->hdc; SelectObject(hdc, hfont); - return GetFontData(hdc, MAKE_TAG('E', 'B', 'D', 'T'), 0, 0, 0) != GDI_ERROR; + return GetFontData(hdc, MAKE_LITTLE_ENDIAN_TAG('E', 'B', 'D', 'T'), 0, 0, 0) != GDI_ERROR; } static inline QString stringFromOutLineTextMetric(const OUTLINETEXTMETRIC *otm, PSTR offset) @@ -182,7 +174,7 @@ void QWindowsFontEngine::getCMap() SelectObject(hdc, hfont); bool symb = false; if (ttf) { - cmapTable = getSfntTable(qbswap<quint32>(MAKE_TAG('c', 'm', 'a', 'p'))); + cmapTable = getSfntTable(MAKE_TAG('c', 'm', 'a', 'p')); cmap = QFontEngine::getCMap(reinterpret_cast<const uchar *>(cmapTable.constData()), cmapTable.size(), &symb, &cmapSize); } @@ -956,7 +948,7 @@ int QWindowsFontEngine::synthesized() const if(synthesized_flags == -1) { synthesized_flags = 0; if(ttf) { - const DWORD HEAD = MAKE_TAG('h', 'e', 'a', 'd'); + const DWORD HEAD = MAKE_LITTLE_ENDIAN_TAG('h', 'e', 'a', 'd'); HDC hdc = m_fontEngineData->hdc; SelectObject(hdc, hfont); uchar data[4]; diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp index 2831962ef4..eeb9e5eb6e 100644 --- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp +++ b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp @@ -39,15 +39,6 @@ #ifndef QT_NO_DIRECTWRITE -#if WINVER < 0x0600 -# undef WINVER -# define WINVER 0x0600 -#endif -#if _WIN32_WINNT < 0x0600 -#undef _WIN32_WINNT -#define _WIN32_WINNT 0x0600 -#endif - #include "qwindowsfontenginedirectwrite.h" #include "qwindowsfontdatabase.h" #include "qwindowscontext.h" @@ -654,71 +645,11 @@ QFontEngine *QWindowsFontEngineDirectWrite::cloneWithSize(qreal pixelSize) const return fontEngine; } -// Dynamically resolve GetUserDefaultLocaleName, which is available from Windows -// Vista onwards. ### fixme 5.7: Consider reverting to direct linking. -typedef int (WINAPI *GetUserDefaultLocaleNamePtr)(LPWSTR, int); - -static inline GetUserDefaultLocaleNamePtr resolveGetUserDefaultLocaleName() -{ - QSystemLibrary library(QStringLiteral("kernel32")); - return (GetUserDefaultLocaleNamePtr)library.resolve("GetUserDefaultLocaleName"); -} - void QWindowsFontEngineDirectWrite::initFontInfo(const QFontDef &request, - int dpi, IDWriteFont *font) + int dpi) { fontDef = request; - IDWriteFontFamily *fontFamily = NULL; - HRESULT hr = font->GetFontFamily(&fontFamily); - - IDWriteLocalizedStrings *familyNames = NULL; - if (SUCCEEDED(hr)) - hr = fontFamily->GetFamilyNames(&familyNames); - - UINT32 index = 0; - - if (SUCCEEDED(hr)) { - BOOL exists = false; - - wchar_t localeName[LOCALE_NAME_MAX_LENGTH]; - static const GetUserDefaultLocaleNamePtr getUserDefaultLocaleName = resolveGetUserDefaultLocaleName(); - const int defaultLocaleSuccess = getUserDefaultLocaleName - ? getUserDefaultLocaleName(localeName, LOCALE_NAME_MAX_LENGTH) : 0; - if (defaultLocaleSuccess) - hr = familyNames->FindLocaleName(localeName, &index, &exists); - - if (SUCCEEDED(hr) && !exists) - hr = familyNames->FindLocaleName(L"en-us", &index, &exists); - - if (!exists) - index = 0; - } - - // Get the family name. - if (SUCCEEDED(hr)) { - UINT32 length = 0; - - hr = familyNames->GetStringLength(index, &length); - - if (SUCCEEDED(hr)) { - QVarLengthArray<wchar_t, 128> name(length+1); - - hr = familyNames->GetString(index, name.data(), name.size()); - - if (SUCCEEDED(hr)) - fontDef.family = QString::fromWCharArray(name.constData()); - } - } - - if (familyNames != NULL) - familyNames->Release(); - if (fontFamily) - fontFamily->Release(); - - if (FAILED(hr)) - qErrnoWarning(hr, "initFontInfo: Failed to get family name"); - if (fontDef.pointSize < 0) fontDef.pointSize = fontDef.pixelSize * 72. / dpi; else if (fontDef.pixelSize == -1) diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h index 25709d8ee1..4558cfbdcc 100644 --- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h +++ b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h @@ -65,7 +65,7 @@ public: const QSharedPointer<QWindowsFontEngineData> &d); ~QWindowsFontEngineDirectWrite(); - void initFontInfo(const QFontDef &request, int dpi, IDWriteFont *font); + void initFontInfo(const QFontDef &request, int dpi); QFixed lineThickness() const Q_DECL_OVERRIDE; QFixed underlinePosition() const Q_DECL_OVERRIDE; diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp index 48f2e3aaef..cc2f05b6d1 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp @@ -156,8 +156,6 @@ void *QWindowsOpengl32DLL::resolve(const char *name) #else void *proc = m_lib ? (void *) ::GetProcAddress(m_lib, (const wchar_t *) QString::fromLatin1(name).utf16()) : 0; #endif - if (!proc) - qErrnoWarning(::GetLastError(), "Failed to resolve OpenGL function %s", name); return proc; } @@ -199,56 +197,11 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering) wglSwapBuffers = reinterpret_cast<BOOL (WINAPI *)(HDC)>(resolve("wglSwapBuffers")); wglSetPixelFormat = reinterpret_cast<BOOL (WINAPI *)(HDC, int, const PIXELFORMATDESCRIPTOR *)>(resolve("wglSetPixelFormat")); - glBindTexture = reinterpret_cast<void (APIENTRY *)(GLenum , GLuint )>(resolve("glBindTexture")); - glBlendFunc = reinterpret_cast<void (APIENTRY *)(GLenum , GLenum )>(resolve("glBlendFunc")); - glClear = reinterpret_cast<void (APIENTRY *)(GLbitfield )>(resolve("glClear")); - glClearColor = reinterpret_cast<void (APIENTRY *)(GLfloat , GLfloat , GLfloat , GLfloat )>(resolve("glClearColor")); - glClearStencil = reinterpret_cast<void (APIENTRY *)(GLint )>(resolve("glClearStencil")); - glColorMask = reinterpret_cast<void (APIENTRY *)(GLboolean , GLboolean , GLboolean , GLboolean )>(resolve("glColorMask")); - glCopyTexImage2D = reinterpret_cast<void (APIENTRY *)(GLenum , GLint , GLenum , GLint , GLint , GLsizei , GLsizei , GLint )>(resolve("glCopyTexImage2D")); - glCopyTexSubImage2D = reinterpret_cast<void (APIENTRY *)(GLenum , GLint , GLint , GLint , GLint , GLint , GLsizei , GLsizei )>(resolve("glCopyTexSubImage2D")); - glCullFace = reinterpret_cast<void (APIENTRY *)(GLenum )>(resolve("glCullFace")); - glDeleteTextures = reinterpret_cast<void (APIENTRY *)(GLsizei , const GLuint *)>(resolve("glDeleteTextures")); - glDepthFunc = reinterpret_cast<void (APIENTRY *)(GLenum )>(resolve("glDepthFunc")); - glDepthMask = reinterpret_cast<void (APIENTRY *)(GLboolean )>(resolve("glDepthMask")); - glDisable = reinterpret_cast<void (APIENTRY *)(GLenum )>(resolve("glDisable")); - glDrawArrays = reinterpret_cast<void (APIENTRY *)(GLenum , GLint , GLsizei )>(resolve("glDrawArrays")); - glDrawElements = reinterpret_cast<void (APIENTRY *)(GLenum , GLsizei , GLenum , const GLvoid *)>(resolve("glDrawElements")); - glEnable = reinterpret_cast<void (APIENTRY *)(GLenum )>(resolve("glEnable")); - glFinish = reinterpret_cast<void (APIENTRY *)()>(resolve("glFinish")); - glFlush = reinterpret_cast<void (APIENTRY *)()>(resolve("glFlush")); - glFrontFace = reinterpret_cast<void (APIENTRY *)(GLenum )>(resolve("glFrontFace")); - glGenTextures = reinterpret_cast<void (APIENTRY *)(GLsizei , GLuint *)>(resolve("glGenTextures")); - glGetBooleanv = reinterpret_cast<void (APIENTRY *)(GLenum , GLboolean *)>(resolve("glGetBooleanv")); glGetError = reinterpret_cast<GLenum (APIENTRY *)()>(resolve("glGetError")); - glGetFloatv = reinterpret_cast<void (APIENTRY *)(GLenum , GLfloat *)>(resolve("glGetFloatv")); glGetIntegerv = reinterpret_cast<void (APIENTRY *)(GLenum , GLint *)>(resolve("glGetIntegerv")); glGetString = reinterpret_cast<const GLubyte * (APIENTRY *)(GLenum )>(resolve("glGetString")); - glGetTexParameterfv = reinterpret_cast<void (APIENTRY *)(GLenum , GLenum , GLfloat *)>(resolve("glGetTexParameterfv")); - glGetTexParameteriv = reinterpret_cast<void (APIENTRY *)(GLenum , GLenum , GLint *)>(resolve("glGetTexParameteriv")); - glHint = reinterpret_cast<void (APIENTRY *)(GLenum , GLenum )>(resolve("glHint")); - glIsEnabled = reinterpret_cast<GLboolean (APIENTRY *)(GLenum )>(resolve("glIsEnabled")); - glIsTexture = reinterpret_cast<GLboolean (APIENTRY *)(GLuint )>(resolve("glIsTexture")); - glLineWidth = reinterpret_cast<void (APIENTRY *)(GLfloat )>(resolve("glLineWidth")); - glPixelStorei = reinterpret_cast<void (APIENTRY *)(GLenum , GLint )>(resolve("glPixelStorei")); - glPolygonOffset = reinterpret_cast<void (APIENTRY *)(GLfloat , GLfloat )>(resolve("glPolygonOffset")); - glReadPixels = reinterpret_cast<void (APIENTRY *)(GLint , GLint , GLsizei , GLsizei , GLenum , GLenum , GLvoid *)>(resolve("glReadPixels")); - glScissor = reinterpret_cast<void (APIENTRY *)(GLint , GLint , GLsizei , GLsizei )>(resolve("glScissor")); - glStencilFunc = reinterpret_cast<void (APIENTRY *)(GLenum , GLint , GLuint )>(resolve("glStencilFunc")); - glStencilMask = reinterpret_cast<void (APIENTRY *)(GLuint )>(resolve("glStencilMask")); - glStencilOp = reinterpret_cast<void (APIENTRY *)(GLenum , GLenum , GLenum )>(resolve("glStencilOp")); - glTexImage2D = reinterpret_cast<void (APIENTRY *)(GLenum , GLint , GLint , GLsizei , GLsizei , GLint , GLenum , GLenum , const GLvoid *)>(resolve("glTexImage2D")); - glTexParameterf = reinterpret_cast<void (APIENTRY *)(GLenum , GLenum , GLfloat )>(resolve("glTexParameterf")); - glTexParameterfv = reinterpret_cast<void (APIENTRY *)(GLenum , GLenum , const GLfloat *)>(resolve("glTexParameterfv")); - glTexParameteri = reinterpret_cast<void (APIENTRY *)(GLenum , GLenum , GLint )>(resolve("glTexParameteri")); - glTexParameteriv = reinterpret_cast<void (APIENTRY *)(GLenum , GLenum , const GLint *)>(resolve("glTexParameteriv")); - glTexSubImage2D = reinterpret_cast<void (APIENTRY *)(GLenum , GLint , GLint , GLint , GLsizei , GLsizei , GLenum , GLenum , const GLvoid *)>(resolve("glTexSubImage2D")); - glViewport = reinterpret_cast<void (APIENTRY *)(GLint , GLint , GLsizei , GLsizei )>(resolve("glViewport")); - - glClearDepth = reinterpret_cast<void (APIENTRY *)(GLdouble )>(resolve("glClearDepth")); - glDepthRange = reinterpret_cast<void (APIENTRY *)(GLdouble , GLdouble )>(resolve("glDepthRange")); - - return wglCreateContext && glBindTexture && glClearDepth; + + return wglCreateContext && glGetError && glGetString; } BOOL QWindowsOpengl32DLL::swapBuffers(HDC dc) @@ -1381,80 +1334,25 @@ void QWindowsGLContext::doneCurrent() releaseDCs(); } -QFunctionPointer QWindowsGLContext::getProcAddress(const QByteArray &procName) +QFunctionPointer QWindowsGLContext::getProcAddress(const char *procName) { + // Even though we use QFunctionPointer, it does not mean the function can be called. + // It will need to be cast to the proper function type with the correct calling + // convention. QFunctionPointer is nothing more than a glorified void* here. + QFunctionPointer procAddress = reinterpret_cast<QFunctionPointer>(QOpenGLStaticContext::opengl32.wglGetProcAddress(procName)); + // We support AllGLFunctionsQueryable, which means this function must be able to // return a function pointer even for functions that are in GL.h and exported // normally from opengl32.dll. wglGetProcAddress() is not guaranteed to work for such // functions, however in QT_OPENGL_DYNAMIC builds QOpenGLFunctions will just blindly - // call into here for _any_ OpenGL function. Hence the need to handle these specially - // here. The list has to match QOpenGLFunctions. See - // QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *). - static struct StdFunc { - const char *name; - void *func; - } standardFuncs[] = { - { "glBindTexture", (void *) QOpenGLStaticContext::opengl32.glBindTexture }, - { "glBlendFunc", (void *) QOpenGLStaticContext::opengl32.glBlendFunc }, - { "glClear", (void *) QOpenGLStaticContext::opengl32.glClear }, - { "glClearColor", (void *) QOpenGLStaticContext::opengl32.glClearColor }, - { "glClearStencil", (void *) QOpenGLStaticContext::opengl32.glClearStencil }, - { "glColorMask", (void *) QOpenGLStaticContext::opengl32.glColorMask }, - { "glCopyTexImage2D", (void *) QOpenGLStaticContext::opengl32.glCopyTexImage2D }, - { "glCopyTexSubImage2D", (void *) QOpenGLStaticContext::opengl32.glCopyTexSubImage2D }, - { "glCullFace", (void *) QOpenGLStaticContext::opengl32.glCullFace }, - { "glDeleteTextures", (void *) QOpenGLStaticContext::opengl32.glDeleteTextures }, - { "glDepthFunc", (void *) QOpenGLStaticContext::opengl32.glDepthFunc }, - { "glDepthMask", (void *) QOpenGLStaticContext::opengl32.glDepthMask }, - { "glDisable", (void *) QOpenGLStaticContext::opengl32.glDisable }, - { "glDrawArrays", (void *) QOpenGLStaticContext::opengl32.glDrawArrays }, - { "glDrawElements", (void *) QOpenGLStaticContext::opengl32.glDrawElements }, - { "glEnable", (void *) QOpenGLStaticContext::opengl32.glEnable }, - { "glFinish", (void *) QOpenGLStaticContext::opengl32.glFinish }, - { "glFlush", (void *) QOpenGLStaticContext::opengl32.glFlush }, - { "glFrontFace", (void *) QOpenGLStaticContext::opengl32.glFrontFace }, - { "glGenTextures", (void *) QOpenGLStaticContext::opengl32.glGenTextures }, - { "glGetBooleanv", (void *) QOpenGLStaticContext::opengl32.glGetBooleanv }, - { "glGetError", (void *) QOpenGLStaticContext::opengl32.glGetError }, - { "glGetFloatv", (void *) QOpenGLStaticContext::opengl32.glGetFloatv }, - { "glGetIntegerv", (void *) QOpenGLStaticContext::opengl32.glGetIntegerv }, - { "glGetString", (void *) QOpenGLStaticContext::opengl32.glGetString }, - { "glGetTexParameterfv", (void *) QOpenGLStaticContext::opengl32.glGetTexParameterfv }, - { "glGetTexParameteriv", (void *) QOpenGLStaticContext::opengl32.glGetTexParameteriv }, - { "glHint", (void *) QOpenGLStaticContext::opengl32.glHint }, - { "glIsEnabled", (void *) QOpenGLStaticContext::opengl32.glIsEnabled }, - { "glIsTexture", (void *) QOpenGLStaticContext::opengl32.glIsTexture }, - { "glLineWidth", (void *) QOpenGLStaticContext::opengl32.glLineWidth }, - { "glPixelStorei", (void *) QOpenGLStaticContext::opengl32.glPixelStorei }, - { "glPolygonOffset", (void *) QOpenGLStaticContext::opengl32.glPolygonOffset }, - { "glReadPixels", (void *) QOpenGLStaticContext::opengl32.glReadPixels }, - { "glScissor", (void *) QOpenGLStaticContext::opengl32.glScissor }, - { "glStencilFunc", (void *) QOpenGLStaticContext::opengl32.glStencilFunc }, - { "glStencilMask", (void *) QOpenGLStaticContext::opengl32.glStencilMask }, - { "glStencilOp", (void *) QOpenGLStaticContext::opengl32.glStencilOp }, - { "glTexImage2D", (void *) QOpenGLStaticContext::opengl32.glTexImage2D }, - { "glTexParameterf", (void *) QOpenGLStaticContext::opengl32.glTexParameterf }, - { "glTexParameterfv", (void *) QOpenGLStaticContext::opengl32.glTexParameterfv }, - { "glTexParameteri", (void *) QOpenGLStaticContext::opengl32.glTexParameteri }, - { "glTexParameteriv", (void *) QOpenGLStaticContext::opengl32.glTexParameteriv }, - { "glTexSubImage2D", (void *) QOpenGLStaticContext::opengl32.glTexSubImage2D }, - { "glViewport", (void *) QOpenGLStaticContext::opengl32.glViewport }, - - { "glClearDepth", (void *) QOpenGLStaticContext::opengl32.glClearDepth }, - { "glDepthRange", (void *) QOpenGLStaticContext::opengl32.glDepthRange }, - }; - for (size_t i = 0; i < sizeof(standardFuncs) / sizeof(StdFunc); ++i) - if (procName == standardFuncs[i].name) - return reinterpret_cast<QFunctionPointer>(standardFuncs[i].func); + // call into here for _any_ OpenGL function. + if (!procAddress || procAddress == reinterpret_cast<void *>(0x1) || procAddress == reinterpret_cast<void *>(0x2) + || procAddress == reinterpret_cast<void *>(0x3) || procAddress == reinterpret_cast<void *>(-1)) + procAddress = reinterpret_cast<QFunctionPointer>(QOpenGLStaticContext::opengl32.resolve(procName)); - // Even though we use QFunctionPointer, it does not mean the function can be called. - // It will need to be cast to the proper function type with the correct calling - // convention. QFunctionPointer is nothing more than a glorified void* here. - QFunctionPointer procAddress = reinterpret_cast<QFunctionPointer>(QOpenGLStaticContext::opengl32.wglGetProcAddress(procName.constData())); if (QWindowsContext::verbose > 1) qCDebug(lcQpaGl) << __FUNCTION__ << procName << QOpenGLStaticContext::opengl32.wglGetCurrentContext() << "returns" << procAddress; - if (!procAddress && QWindowsContext::verbose) - qWarning("%s: Unable to resolve '%s'", __FUNCTION__, procName.constData()); + return procAddress; } diff --git a/src/plugins/platforms/windows/qwindowsglcontext.h b/src/plugins/platforms/windows/qwindowsglcontext.h index 3acfed1ccf..e8c78860f2 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.h +++ b/src/plugins/platforms/windows/qwindowsglcontext.h @@ -118,58 +118,12 @@ struct QWindowsOpengl32DLL BOOL (WINAPI * wglShareLists)(HGLRC context1, HGLRC context2); // GL1+GLES2 common - void (APIENTRY * glBindTexture)(GLenum target, GLuint texture); - void (APIENTRY * glBlendFunc)(GLenum sfactor, GLenum dfactor); - void (APIENTRY * glClear)(GLbitfield mask); - void (APIENTRY * glClearColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); - void (APIENTRY * glClearStencil)(GLint s); - void (APIENTRY * glColorMask)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); - void (APIENTRY * glCopyTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); - void (APIENTRY * glCopyTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); - void (APIENTRY * glCullFace)(GLenum mode); - void (APIENTRY * glDeleteTextures)(GLsizei n, const GLuint* textures); - void (APIENTRY * glDepthFunc)(GLenum func); - void (APIENTRY * glDepthMask)(GLboolean flag); - void (APIENTRY * glDisable)(GLenum cap); - void (APIENTRY * glDrawArrays)(GLenum mode, GLint first, GLsizei count); - void (APIENTRY * glDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices); - void (APIENTRY * glEnable)(GLenum cap); - void (APIENTRY * glFinish)(); - void (APIENTRY * glFlush)(); - void (APIENTRY * glFrontFace)(GLenum mode); - void (APIENTRY * glGenTextures)(GLsizei n, GLuint* textures); - void (APIENTRY * glGetBooleanv)(GLenum pname, GLboolean* params); GLenum (APIENTRY * glGetError)(); - void (APIENTRY * glGetFloatv)(GLenum pname, GLfloat* params); void (APIENTRY * glGetIntegerv)(GLenum pname, GLint* params); const GLubyte * (APIENTRY * glGetString)(GLenum name); - void (APIENTRY * glGetTexParameterfv)(GLenum target, GLenum pname, GLfloat* params); - void (APIENTRY * glGetTexParameteriv)(GLenum target, GLenum pname, GLint* params); - void (APIENTRY * glHint)(GLenum target, GLenum mode); - GLboolean (APIENTRY * glIsEnabled)(GLenum cap); - GLboolean (APIENTRY * glIsTexture)(GLuint texture); - void (APIENTRY * glLineWidth)(GLfloat width); - void (APIENTRY * glPixelStorei)(GLenum pname, GLint param); - void (APIENTRY * glPolygonOffset)(GLfloat factor, GLfloat units); - void (APIENTRY * glReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels); - void (APIENTRY * glScissor)(GLint x, GLint y, GLsizei width, GLsizei height); - void (APIENTRY * glStencilFunc)(GLenum func, GLint ref, GLuint mask); - void (APIENTRY * glStencilMask)(GLuint mask); - void (APIENTRY * glStencilOp)(GLenum fail, GLenum zfail, GLenum zpass); - void (APIENTRY * glTexImage2D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels); - void (APIENTRY * glTexParameterf)(GLenum target, GLenum pname, GLfloat param); - void (APIENTRY * glTexParameterfv)(GLenum target, GLenum pname, const GLfloat* params); - void (APIENTRY * glTexParameteri)(GLenum target, GLenum pname, GLint param); - void (APIENTRY * glTexParameteriv)(GLenum target, GLenum pname, const GLint* params); - void (APIENTRY * glTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels); - void (APIENTRY * glViewport)(GLint x, GLint y, GLsizei width, GLsizei height); - - // GL only - void (APIENTRY * glClearDepth)(GLdouble depth); - void (APIENTRY * glDepthRange)(GLdouble zNear, GLdouble zFar); -private: void *resolve(const char *name); +private: HMODULE m_lib; bool m_nonOpengl32; @@ -251,7 +205,7 @@ public: typedef void (*GL_Proc) (); - QFunctionPointer getProcAddress(const QByteArray &procName) Q_DECL_OVERRIDE; + QFunctionPointer getProcAddress(const char *procName) Q_DECL_OVERRIDE; HGLRC renderingContext() const { return m_renderingContext; } diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index 48de7d56f8..5b2370b69d 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -1253,7 +1253,12 @@ QList<int> QWindowsKeyMapper::possibleKeys(const QKeyEvent *e) const { QList<int> result; - const KeyboardLayoutItem &kbItem = keyLayout[e->nativeVirtualKey()]; + + const quint32 nativeVirtualKey = e->nativeVirtualKey(); + if (nativeVirtualKey > 255) + return result; + + const KeyboardLayoutItem &kbItem = keyLayout[nativeVirtualKey]; if (!kbItem.exists) return result; diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp b/src/plugins/platforms/windows/qwindowstabletsupport.cpp index 8db6895999..3689978b41 100644 --- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp +++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp @@ -208,7 +208,7 @@ QWindowsTabletSupport *QWindowsTabletSupport::create() if (currentQueueSize != TabletPacketQSize) { if (!QWindowsTabletSupport::m_winTab32DLL.wTQueueSizeSet(context, TabletPacketQSize)) { if (!QWindowsTabletSupport::m_winTab32DLL.wTQueueSizeSet(context, currentQueueSize)) { - qWarning() << "Unable to set queue size on tablet. The tablet will not work."; + qWarning("Unable to set queue size on tablet. The tablet will not work."); QWindowsTabletSupport::m_winTab32DLL.wTClose(context); DestroyWindow(window); return 0; diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 4a665c15ad..cb48e13934 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -700,7 +700,7 @@ void WindowCreationData::initialize(const QWindow *w, HWND hwnd, bool frameChang if ((flags & Qt::WindowStaysOnTopHint) || (type == Qt::ToolTip)) { SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, swpFlags); if (flags & Qt::WindowStaysOnBottomHint) - qWarning() << "QWidget: Incompatible window flags: the window can't be on top and on bottom at the same time"; + qWarning("QWidget: Incompatible window flags: the window can't be on top and on bottom at the same time"); } else if (flags & Qt::WindowStaysOnBottomHint) { SetWindowPos(hwnd, HWND_BOTTOM, 0, 0, 0, 0, swpFlags); } else if (frameChange) { // Force WM_NCCALCSIZE with wParam=1 in case of custom margins. @@ -1668,11 +1668,11 @@ void QWindowsWindow::releaseDC() bool QWindowsWindow::handleWmPaint(HWND hwnd, UINT message, WPARAM, LPARAM) { + if (message == WM_ERASEBKGND) // Backing store - ignored. + return true; // Ignore invalid update bounding rectangles if (!GetUpdateRect(m_data.hwnd, 0, FALSE)) return false; - if (message == WM_ERASEBKGND) // Backing store - ignored. - return true; PAINTSTRUCT ps; // Observed painting problems with Aero style disabled (QTBUG-7865). @@ -2211,7 +2211,7 @@ void QWindowsWindow::getSizeHints(MINMAXINFO *mmi) const mmi->ptMaxPosition.x = availableGeometry.x(); mmi->ptMaxPosition.y = availableGeometry.y(); } else if (!screen){ - qWarning() << "window()->screen() returned a null screen"; + qWarning("window()->screen() returned a null screen"); } } diff --git a/src/plugins/platforms/windows/windows.pro b/src/plugins/platforms/windows/windows.pro index cc0373c077..2e0f723693 100644 --- a/src/plugins/platforms/windows/windows.pro +++ b/src/plugins/platforms/windows/windows.pro @@ -1,10 +1,5 @@ TARGET = qwindows -PLUGIN_TYPE = platforms -PLUGIN_CLASS_NAME = QWindowsIntegrationPlugin -!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - -load(qt_plugin) - QT *= core-private QT *= gui-private QT *= platformsupport-private @@ -25,3 +20,8 @@ HEADERS += \ qwindowsgdinativeinterface.h OTHER_FILES += windows.json + +PLUGIN_TYPE = platforms +PLUGIN_CLASS_NAME = QWindowsIntegrationPlugin +!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - +load(qt_plugin) diff --git a/src/plugins/platforms/winrt/qwinrteglcontext.cpp b/src/plugins/platforms/winrt/qwinrteglcontext.cpp index 34f439b70f..dfc9e31f14 100644 --- a/src/plugins/platforms/winrt/qwinrteglcontext.cpp +++ b/src/plugins/platforms/winrt/qwinrteglcontext.cpp @@ -195,7 +195,7 @@ QSurfaceFormat QWinRTEGLContext::format() const return d->format; } -QFunctionPointer QWinRTEGLContext::getProcAddress(const QByteArray &procName) +QFunctionPointer QWinRTEGLContext::getProcAddress(const char *procName) { static QHash<QByteArray, QFunctionPointer> standardFuncs; if (standardFuncs.isEmpty()) { @@ -347,7 +347,7 @@ QFunctionPointer QWinRTEGLContext::getProcAddress(const QByteArray &procName) if (i != standardFuncs.end()) return i.value(); - return eglGetProcAddress(procName.constData()); + return eglGetProcAddress(procName); } EGLDisplay QWinRTEGLContext::display() diff --git a/src/plugins/platforms/winrt/qwinrteglcontext.h b/src/plugins/platforms/winrt/qwinrteglcontext.h index 49b289cd79..6f38e2535d 100644 --- a/src/plugins/platforms/winrt/qwinrteglcontext.h +++ b/src/plugins/platforms/winrt/qwinrteglcontext.h @@ -56,7 +56,7 @@ public: void swapBuffers(QPlatformSurface *windowSurface) Q_DECL_OVERRIDE; QSurfaceFormat format() const Q_DECL_OVERRIDE; - QFunctionPointer getProcAddress(const QByteArray &procName) Q_DECL_OVERRIDE; + QFunctionPointer getProcAddress(const char *procName) Q_DECL_OVERRIDE; static EGLDisplay display(); private: diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp index 4c4d553b2d..47e68ae0af 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.cpp +++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp @@ -39,8 +39,10 @@ #include "qwinrtbackingstore.h" #include "qwinrtinputcontext.h" #include "qwinrtcursor.h" +#include "qwinrtwindow.h" #include <private/qeventdispatcher_winrt_p.h> +#include <QtCore/QLoggingCategory> #include <QtGui/QSurfaceFormat> #include <QtGui/QGuiApplication> #include <qpa/qwindowsysteminterface.h> @@ -469,6 +471,7 @@ QWinRTScreen::QWinRTScreen() : d_ptr(new QWinRTScreenPrivate) { Q_D(QWinRTScreen); + qCDebug(lcQpaWindows) << __FUNCTION__; d->orientation = Qt::PrimaryOrientation; d->touchDevice = Q_NULLPTR; @@ -553,6 +556,7 @@ QWinRTScreen::QWinRTScreen() QWinRTScreen::~QWinRTScreen() { Q_D(QWinRTScreen); + qCDebug(lcQpaWindows) << __FUNCTION__ << this; // Unregister callbacks HRESULT hr; @@ -631,6 +635,12 @@ QDpi QWinRTScreen::logicalDpi() const return QDpi(d->logicalDpi, d->logicalDpi); } +qreal QWinRTScreen::pixelDensity() const +{ + Q_D(const QWinRTScreen); + return qRound(d->logicalDpi / 96); +} + qreal QWinRTScreen::scaleFactor() const { Q_D(const QWinRTScreen); @@ -697,6 +707,8 @@ Xaml::IDependencyObject *QWinRTScreen::canvas() const void QWinRTScreen::setStatusBarVisibility(bool visible, QWindow *window) { Q_D(QWinRTScreen); + qCDebug(lcQpaWindows) << __FUNCTION__ << window << visible; + const Qt::WindowFlags windowType = window->flags() & Qt::WindowType_Mask; if (!window || (windowType != Qt::Window && windowType != Qt::Dialog)) return; @@ -768,6 +780,7 @@ QWindow *QWinRTScreen::topWindow() const void QWinRTScreen::addWindow(QWindow *window) { Q_D(QWinRTScreen); + qCDebug(lcQpaWindows) << __FUNCTION__ << window; if (window == topWindow()) return; @@ -785,6 +798,7 @@ void QWinRTScreen::addWindow(QWindow *window) void QWinRTScreen::removeWindow(QWindow *window) { Q_D(QWinRTScreen); + qCDebug(lcQpaWindows) << __FUNCTION__ << window; #ifdef Q_OS_WINPHONE if (window->visibility() == QWindow::Minimized) @@ -1131,6 +1145,7 @@ HRESULT QWinRTScreen::onSizeChanged(ICoreWindow *, IWindowSizeChangedEventArgs * hr = d->coreWindow->get_Bounds(&size); RETURN_OK_IF_FAILED("Failed to get window bounds"); d->logicalSize = QSizeF(size.Width, size.Height); + qCDebug(lcQpaWindows) << __FUNCTION__ << d->logicalSize; QWindowSystemInterface::handleScreenGeometryChange(screen(), geometry(), availableGeometry()); QPlatformScreen::resizeMaximizedWindows(); handleExpose(); @@ -1140,6 +1155,7 @@ HRESULT QWinRTScreen::onSizeChanged(ICoreWindow *, IWindowSizeChangedEventArgs * HRESULT QWinRTScreen::onActivated(ICoreWindow *, IWindowActivatedEventArgs *args) { Q_D(QWinRTScreen); + qCDebug(lcQpaWindows) << __FUNCTION__; CoreWindowActivationState activationState; args->get_WindowActivationState(&activationState); @@ -1159,6 +1175,8 @@ HRESULT QWinRTScreen::onActivated(ICoreWindow *, IWindowActivatedEventArgs *args HRESULT QWinRTScreen::onClosed(ICoreWindow *, ICoreWindowEventArgs *) { + qCDebug(lcQpaWindows) << __FUNCTION__; + foreach (QWindow *w, QGuiApplication::topLevelWindows()) QWindowSystemInterface::handleCloseEvent(w); return S_OK; @@ -1170,6 +1188,7 @@ HRESULT QWinRTScreen::onVisibilityChanged(ICoreWindow *, IVisibilityChangedEvent boolean visible; HRESULT hr = args ? args->get_Visible(&visible) : d->coreWindow->get_Visible(&visible); RETURN_OK_IF_FAILED("Failed to get visibility."); + qCDebug(lcQpaWindows) << __FUNCTION__ << visible; QWindowSystemInterface::handleApplicationStateChanged(visible ? Qt::ApplicationActive : Qt::ApplicationHidden); if (visible) handleExpose(); @@ -1179,7 +1198,7 @@ HRESULT QWinRTScreen::onVisibilityChanged(ICoreWindow *, IVisibilityChangedEvent HRESULT QWinRTScreen::onOrientationChanged(IDisplayInformation *, IInspectable *) { Q_D(QWinRTScreen); - + qCDebug(lcQpaWindows) << __FUNCTION__; DisplayOrientations displayOrientation; HRESULT hr = d->displayInformation->get_CurrentOrientation(&displayOrientation); RETURN_OK_IF_FAILED("Failed to get current orientations."); @@ -1187,7 +1206,8 @@ HRESULT QWinRTScreen::onOrientationChanged(IDisplayInformation *, IInspectable * Qt::ScreenOrientation newOrientation = static_cast<Qt::ScreenOrientation>(static_cast<int>(qtOrientationsFromNative(displayOrientation))); if (d->orientation != newOrientation) { d->orientation = newOrientation; -#ifdef Q_OS_WINPHONE + qCDebug(lcQpaWindows) << " New orientation:" << newOrientation; +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) onSizeChanged(nullptr, nullptr); #endif QWindowSystemInterface::handleScreenOrientationChange(screen(), d->orientation); @@ -1211,6 +1231,8 @@ HRESULT QWinRTScreen::onDpiChanged(IDisplayInformation *, IInspectable *) hr = d->displayInformation->get_ResolutionScale(&resolutionScale); d->scaleFactor = qreal(resolutionScale) / 100; #endif + qCDebug(lcQpaWindows) << __FUNCTION__ << "Scale Factor:" << d->scaleFactor; + RETURN_OK_IF_FAILED("Failed to get scale factor"); FLOAT dpi; @@ -1225,6 +1247,8 @@ HRESULT QWinRTScreen::onDpiChanged(IDisplayInformation *, IInspectable *) hr = d->displayInformation->get_RawDpiY(&dpi); RETURN_OK_IF_FAILED("Failed to get y raw DPI."); d->physicalDpi.second = dpi ? dpi : 96.0; + qCDebug(lcQpaWindows) << __FUNCTION__ << "Logical DPI:" << d->logicalDpi + << "Physical DPI:" << d->physicalDpi; return S_OK; } @@ -1232,12 +1256,14 @@ HRESULT QWinRTScreen::onDpiChanged(IDisplayInformation *, IInspectable *) #ifdef Q_OS_WINPHONE HRESULT QWinRTScreen::onStatusBarShowing(IStatusBar *, IInspectable *) { + qCDebug(lcQpaWindows) << __FUNCTION__; onSizeChanged(nullptr, nullptr); return S_OK; } HRESULT QWinRTScreen::onStatusBarHiding(IStatusBar *, IInspectable *) { + qCDebug(lcQpaWindows) << __FUNCTION__; onSizeChanged(nullptr, nullptr); return S_OK; } diff --git a/src/plugins/platforms/winrt/qwinrtscreen.h b/src/plugins/platforms/winrt/qwinrtscreen.h index 0043b2cfa3..ac9db9bfef 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.h +++ b/src/plugins/platforms/winrt/qwinrtscreen.h @@ -93,6 +93,7 @@ public: QImage::Format format() const Q_DECL_OVERRIDE; QSizeF physicalSize() const Q_DECL_OVERRIDE; QDpi logicalDpi() const Q_DECL_OVERRIDE; + qreal pixelDensity() const Q_DECL_OVERRIDE; qreal scaleFactor() const; QPlatformCursor *cursor() const Q_DECL_OVERRIDE; Qt::KeyboardModifiers keyboardModifiers() const; diff --git a/src/plugins/platforms/winrt/winrt.pro b/src/plugins/platforms/winrt/winrt.pro index 991ec1789b..261295ef0b 100644 --- a/src/plugins/platforms/winrt/winrt.pro +++ b/src/plugins/platforms/winrt/winrt.pro @@ -1,10 +1,6 @@ TARGET = qwinrt -CONFIG -= precompile_header -PLUGIN_TYPE = platforms -PLUGIN_CLASS_NAME = QWinRTIntegrationPlugin -!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - -load(qt_plugin) +CONFIG -= precompile_header QT += core-private gui-private platformsupport-private @@ -50,3 +46,8 @@ HEADERS = \ qwinrtwindow.h OTHER_FILES += winrt.json + +PLUGIN_TYPE = platforms +PLUGIN_CLASS_NAME = QWinRTIntegrationPlugin +!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - +load(qt_plugin) diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.pro b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.pro index 28a572a2c9..6d52332bad 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.pro +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.pro @@ -1,10 +1,5 @@ TARGET = qxcb-egl-integration -PLUGIN_CLASS_NAME = QXcbEglIntegrationPlugin -PLUGIN_TYPE = xcbglintegrations - -load(qt_plugin) - include(../gl_integrations_plugin_base.pri) CONFIG += egl @@ -22,3 +17,7 @@ SOURCES += \ qxcbeglwindow.cpp \ qxcbeglmain.cpp \ qxcbeglnativeinterfacehandler.cpp + +PLUGIN_CLASS_NAME = QXcbEglIntegrationPlugin +PLUGIN_TYPE = xcbglintegrations +load(qt_plugin) 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 ff624d9755..4290ec54fc 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp @@ -550,10 +550,10 @@ void QGLXContext::swapBuffers(QPlatformSurface *surface) } } -void (*QGLXContext::getProcAddress(const QByteArray &procName)) () +QFunctionPointer QGLXContext::getProcAddress(const char *procName) { #ifdef QT_STATIC - return glXGetProcAddressARB(reinterpret_cast<const GLubyte *>(procName.constData())); + return glXGetProcAddressARB(reinterpret_cast<const GLubyte *>(procName)); #else typedef void *(*qt_glXGetProcAddressARB)(const GLubyte *); static qt_glXGetProcAddressARB glXGetProcAddressARB = 0; @@ -585,7 +585,7 @@ void (*QGLXContext::getProcAddress(const QByteArray &procName)) () } if (!glXGetProcAddressARB) return 0; - return (void (*)())glXGetProcAddressARB(reinterpret_cast<const GLubyte *>(procName.constData())); + return (void (*)())glXGetProcAddressARB(reinterpret_cast<const GLubyte *>(procName)); #endif } diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h index e5cbee3363..f00d96e6d5 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h @@ -63,7 +63,7 @@ public: bool makeCurrent(QPlatformSurface *surface) Q_DECL_OVERRIDE; void doneCurrent() Q_DECL_OVERRIDE; void swapBuffers(QPlatformSurface *surface) Q_DECL_OVERRIDE; - QFunctionPointer getProcAddress(const QByteArray &procName) Q_DECL_OVERRIDE; + QFunctionPointer getProcAddress(const char *procName) Q_DECL_OVERRIDE; QSurfaceFormat format() const Q_DECL_OVERRIDE; bool isSharing() const Q_DECL_OVERRIDE; diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro index 1c577e5dc9..67fd68765a 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro @@ -1,10 +1,5 @@ TARGET = qxcb-glx-integration -PLUGIN_CLASS_NAME = QXcbGlxIntegrationPlugin -PLUGIN_TYPE = xcbglintegrations - -load(qt_plugin) - include(../gl_integrations_plugin_base.pri) #should be removed from the sources @@ -31,3 +26,7 @@ SOURCES += \ qxcbglxwindow.cpp \ qglxintegration.cpp \ qxcbglxnativeinterfacehandler.cpp + +PLUGIN_CLASS_NAME = QXcbGlxIntegrationPlugin +PLUGIN_TYPE = xcbglintegrations +load(qt_plugin) diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp index 3d22c9f4dd..9ea1f5c33d 100644 --- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp +++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp @@ -74,13 +74,17 @@ public: QSize size() const { return m_qimage.size(); } bool hasAlpha() const { return m_hasAlpha; } + bool hasShm() const { return m_shm_info.shmaddr != nullptr; } - void put(xcb_window_t window, const QPoint &dst, const QRect &source); + void put(xcb_window_t window, const QRegion ®ion, const QPoint &offset); void preparePaint(const QRegion ®ion); private: void destroy(); + void flushPixmap(const QRegion ®ion); + void setClip(const QRegion ®ion); + xcb_shm_segment_info_t m_shm_info; xcb_image_t *m_xcb_image; @@ -91,7 +95,15 @@ private: xcb_gcontext_t m_gc; xcb_window_t m_gc_window; - QRegion m_dirty; + // When using shared memory this is the region currently shared with the server + QRegion m_dirtyShm; + + // When not using shared memory, we maintain a server-side pixmap with the backing + // store as well as repainted content not yet flushed to the pixmap. We only flush + // the regions we need and only when these are marked dirty. This way we can just + // do a server-side copy on expose instead of sending the pixels every time + xcb_pixmap_t m_xcb_pixmap; + QRegion m_pendingFlush; bool m_hasAlpha; }; @@ -131,17 +143,12 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size, uint depth, QI , m_graphics_buffer(Q_NULLPTR) , m_gc(0) , m_gc_window(0) + , m_xcb_pixmap(0) { Q_XCB_NOOP(connection()); - const xcb_setup_t *setup = xcb_get_setup(xcb_connection()); - xcb_format_t *fmt = xcb_setup_pixmap_formats(setup); - xcb_format_t *fmtend = fmt + xcb_setup_pixmap_formats_length(setup); - for (; fmt != fmtend; ++fmt) - if (fmt->depth == depth) - break; - - Q_ASSERT(fmt != fmtend); + const xcb_format_t *fmt = connection()->formatForDepth(depth); + Q_ASSERT(fmt); m_xcb_image = xcb_image_create(size.width(), size.height(), XCB_IMAGE_FORMAT_Z_PIXMAP, @@ -180,7 +187,7 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size, uint depth, QI m_xcb_image->data = (uint8_t *)malloc(segmentSize); } else { if (shmctl(m_shm_info.shmid, IPC_RMID, 0) == -1) - qWarning() << "QXcbBackingStore: Error while marking the shared memory segment to be destroyed"; + qWarning("QXcbBackingStore: Error while marking the shared memory segment to be destroyed"); } m_hasAlpha = QImage::toPixelFormat(format).alphaUsage() == QPixelFormat::UsesAlpha; @@ -189,6 +196,15 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size, uint depth, QI m_qimage = QImage( (uchar*) m_xcb_image->data, m_xcb_image->width, m_xcb_image->height, m_xcb_image->stride, format); m_graphics_buffer = new QXcbShmGraphicsBuffer(&m_qimage); + + if (!hasShm()) { + m_xcb_pixmap = xcb_generate_id(xcb_connection()); + Q_XCB_CALL(xcb_create_pixmap(xcb_connection(), + m_xcb_image->depth, + m_xcb_pixmap, + screen->screen()->root, + m_xcb_image->width, m_xcb_image->height)); + } } void QXcbShmImage::destroy() @@ -212,95 +228,163 @@ void QXcbShmImage::destroy() Q_XCB_CALL(xcb_free_gc(xcb_connection(), m_gc)); delete m_graphics_buffer; m_graphics_buffer = Q_NULLPTR; -} -void QXcbShmImage::put(xcb_window_t window, const QPoint &target, const QRect &source) -{ - Q_XCB_NOOP(connection()); - if (m_gc_window != window) { - if (m_gc) - Q_XCB_CALL(xcb_free_gc(xcb_connection(), m_gc)); - - m_gc = xcb_generate_id(xcb_connection()); - Q_XCB_CALL(xcb_create_gc(xcb_connection(), m_gc, window, 0, 0)); - - m_gc_window = window; + if (m_xcb_pixmap) { + Q_XCB_CALL(xcb_free_pixmap(xcb_connection(), m_xcb_pixmap)); + m_xcb_pixmap = 0; } +} - Q_XCB_NOOP(connection()); - if (m_shm_info.shmaddr) { - xcb_image_shm_put(xcb_connection(), - window, - m_gc, - m_xcb_image, - m_shm_info, - source.x(), - source.y(), - target.x(), - target.y(), - source.width(), - source.height(), - false); - } else { - // If we upload the whole image in a single chunk, the result might be - // larger than the server's maximum request size and stuff breaks. - // To work around that, we upload the image in chunks where each chunk - // is small enough for a single request. - int src_x = source.x(); - int src_y = source.y(); - int target_x = target.x(); - int target_y = target.y(); - int width = source.width(); - int height = source.height(); +void QXcbShmImage::flushPixmap(const QRegion ®ion) +{ + const QVector<QRect> rects = m_pendingFlush.intersected(region).rects(); + m_pendingFlush -= region; + for (const QRect &rect : rects) { // We must make sure that each request is not larger than max_req_size. // Each request takes req_size + m_xcb_image->stride * height bytes. - uint32_t max_req_size = xcb_get_maximum_request_length(xcb_connection()); - uint32_t req_size = sizeof(xcb_put_image_request_t); - int rows_per_put = (max_req_size - req_size) / m_xcb_image->stride; + static const uint32_t req_size = sizeof(xcb_put_image_request_t); + const uint32_t max_req_size = xcb_get_maximum_request_length(xcb_connection()); + const int rows_per_put = (max_req_size - req_size) / m_xcb_image->stride; // This assert could trigger if a single row has more pixels than fit in // a single PutImage request. However, max_req_size is guaranteed to be // at least 16384 bytes. That should be enough for quite large images. Q_ASSERT(rows_per_put > 0); - // Convert the image to the native byte order. - xcb_image_t *converted_image = xcb_image_native(xcb_connection(), m_xcb_image, 1); + // If we upload the whole image in a single chunk, the result might be + // larger than the server's maximum request size and stuff breaks. + // To work around that, we upload the image in chunks where each chunk + // is small enough for a single request. + int src_x = rect.x(); + int src_y = rect.y(); + int target_x = rect.x(); + int target_y = rect.y(); + int width = rect.width(); + int height = rect.height(); while (height > 0) { int rows = std::min(height, rows_per_put); - xcb_image_t *subimage = xcb_image_subimage(converted_image, src_x, src_y, width, rows, + xcb_image_t *subimage = xcb_image_subimage(m_xcb_image, src_x, src_y, width, rows, 0, 0, 0); + + // Convert the image to the native byte order. + xcb_image_t *native_subimage = xcb_image_native(xcb_connection(), subimage, 1); + xcb_image_put(xcb_connection(), - window, + m_xcb_pixmap, m_gc, - subimage, + native_subimage, target_x, target_y, 0); + if (native_subimage != subimage) + xcb_image_destroy(native_subimage); + xcb_image_destroy(subimage); src_y += rows; target_y += rows; height -= rows; } + } +} + +void QXcbShmImage::setClip(const QRegion ®ion) +{ + if (region.isEmpty()) { + static const uint32_t mask = XCB_GC_CLIP_MASK; + static const uint32_t values[] = { XCB_NONE }; + Q_XCB_CALL(xcb_change_gc(xcb_connection(), + m_gc, + mask, + values)); + } else { + const QVector<QRect> qrects = region.rects(); + QVector<xcb_rectangle_t> xcb_rects(qrects.size()); + + for (int i = 0; i < qrects.size(); i++) { + xcb_rects[i].x = qrects[i].x(); + xcb_rects[i].y = qrects[i].y(); + xcb_rects[i].width = qrects[i].width(); + xcb_rects[i].height = qrects[i].height(); + } - if (converted_image != m_xcb_image) - xcb_image_destroy(converted_image); + Q_XCB_CALL(xcb_set_clip_rectangles(xcb_connection(), + XCB_CLIP_ORDERING_YX_BANDED, + m_gc, + 0, 0, + xcb_rects.size(), xcb_rects.constData())); } +} + +void QXcbShmImage::put(xcb_window_t window, const QRegion ®ion, const QPoint &offset) +{ Q_XCB_NOOP(connection()); - m_dirty = m_dirty | source; + if (m_gc_window != window) { + if (m_gc) + Q_XCB_CALL(xcb_free_gc(xcb_connection(), m_gc)); + + static const uint32_t mask = XCB_GC_GRAPHICS_EXPOSURES; + static const uint32_t values[] = { 0 }; + + m_gc = xcb_generate_id(xcb_connection()); + Q_XCB_CALL(xcb_create_gc(xcb_connection(), m_gc, window, mask, values)); + + m_gc_window = window; + } + + Q_XCB_NOOP(connection()); + + setClip(region); + + const QRect bounds = region.boundingRect(); + const QPoint target = bounds.topLeft(); + const QRect source = bounds.translated(offset); + + if (hasShm()) { + Q_XCB_CALL(xcb_shm_put_image(xcb_connection(), + window, + m_gc, + m_xcb_image->width, + m_xcb_image->height, + source.x(), source.y(), + source.width(), source.height(), + target.x(), target.y(), + m_xcb_image->depth, + m_xcb_image->format, + 0, // send event? + m_shm_info.shmseg, + m_xcb_image->data - m_shm_info.shmaddr)); + m_dirtyShm |= region.translated(offset); + } else { + flushPixmap(region); + Q_XCB_CALL(xcb_copy_area(xcb_connection(), + m_xcb_pixmap, + window, + m_gc, + source.x(), source.y(), + target.x(), target.y(), + source.width(), source.height())); + } + + setClip(QRegion()); + Q_XCB_NOOP(connection()); } void QXcbShmImage::preparePaint(const QRegion ®ion) { - // to prevent X from reading from the image region while we're writing to it - if (m_dirty.intersects(region)) { - connection()->sync(); - m_dirty = QRegion(); + if (hasShm()) { + // to prevent X from reading from the image region while we're writing to it + if (m_dirtyShm.intersects(region)) { + connection()->sync(); + m_dirtyShm = QRegion(); + } + } else { + m_pendingFlush |= region; } } @@ -396,10 +480,7 @@ void QXcbBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoin return; } - for (const QRect &r : clipped) { - QRect rect = QRect(r.topLeft(), r.size()); - m_image->put(platformWindow->xcb_window(), rect.topLeft(), rect.translated(offset)); - } + m_image->put(platformWindow->xcb_window(), clipped, offset); Q_XCB_NOOP(connection()); diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 998f4884aa..4fee772cd6 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -1962,7 +1962,9 @@ static const char * xcb_atomnames = { "_COMPIZ_DECOR_PENDING\0" "_COMPIZ_DECOR_REQUEST\0" "_COMPIZ_DECOR_DELETE_PIXMAP\0" - "_COMPIZ_TOOLKIT_ACTION\0" // \0\0 terminates loop. + "_COMPIZ_TOOLKIT_ACTION\0" + "_GTK_LOAD_ICONTHEMES\0" + // \0\0 terminates loop. }; QXcbAtom::Atom QXcbConnection::qatom(xcb_atom_t xatom) const @@ -2173,7 +2175,7 @@ void QXcbConnection::initializeXKB() #ifndef QT_NO_XKB const xcb_query_extension_reply_t *reply = xcb_get_extension_data(m_connection, &xcb_xkb_id); if (!reply || !reply->present) { - qWarning() << "Qt: XKEYBOARD extension not present on the X server."; + qWarning("Qt: XKEYBOARD extension not present on the X server."); xkb_first_event = 0; return; } @@ -2227,7 +2229,7 @@ void QXcbConnection::initializeXKB() xcb_generic_error_t *error = xcb_request_check(c, select); if (error) { free(error); - qWarning() << "Qt: failed to select notify events from xcb-xkb"; + qWarning("Qt: failed to select notify events from xcb-xkb"); return; } #endif diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 02dc95e852..9fed7b52f1 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -294,6 +294,7 @@ namespace QXcbAtom { _COMPIZ_DECOR_REQUEST, _COMPIZ_DECOR_DELETE_PIXMAP, _COMPIZ_TOOLKIT_ACTION, + _GTK_LOAD_ICONTHEMES, NPredefinedAtoms, @@ -355,7 +356,7 @@ public: virtual void handleFocusOutEvent(const xcb_focus_out_event_t *) {} virtual void handlePropertyNotifyEvent(const xcb_property_notify_event_t *) {} #ifdef XCB_USE_XINPUT22 - virtual void handleXIMouseEvent(xcb_ge_event_t *) {} + virtual void handleXIMouseEvent(xcb_ge_event_t *, Qt::MouseEventSource = Qt::MouseEventNotSynthesized) {} virtual void handleXIEnterLeave(xcb_ge_event_t *) {} #endif virtual QXcbWindow *toWindow() { return 0; } diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index e94433dd4b..63a650a514 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -1136,7 +1136,7 @@ bool QXcbConnection::xi2HandleTabletEvent(void *event, TabletData *tabletData, Q // Synthesize mouse events since otherwise there are no mouse events from // the pen on the XI 2.2+ path. if (xi2MouseEvents() && eventListener) - eventListener->handleXIMouseEvent(reinterpret_cast<xcb_ge_event_t *>(event)); + eventListener->handleXIMouseEvent(reinterpret_cast<xcb_ge_event_t *>(event), Qt::MouseEventSynthesizedByQt); #else Q_UNUSED(eventListener); #endif diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp index 9409de2406..ea20ef7a04 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.cpp +++ b/src/plugins/platforms/xcb/qxcbdrag.cpp @@ -429,6 +429,7 @@ void QXcbDrag::move(const QPoint &globalPos) xcb_client_message_event_t enter; enter.response_type = XCB_CLIENT_MESSAGE; + enter.sequence = 0; enter.window = target; enter.format = 32; enter.type = atom(QXcbAtom::XdndEnter); @@ -457,6 +458,7 @@ void QXcbDrag::move(const QPoint &globalPos) xcb_client_message_event_t move; move.response_type = XCB_CLIENT_MESSAGE; + move.sequence = 0; move.window = target; move.format = 32; move.type = atom(QXcbAtom::XdndPosition); @@ -485,6 +487,7 @@ void QXcbDrag::drop(const QPoint &globalPos) xcb_client_message_event_t drop; drop.response_type = XCB_CLIENT_MESSAGE; + drop.sequence = 0; drop.window = current_target; drop.format = 32; drop.type = atom(QXcbAtom::XdndDrop); @@ -746,6 +749,7 @@ void QXcbDrag::handle_xdnd_position(QPlatformWindow *w, const xcb_client_message xcb_client_message_event_t response; response.response_type = XCB_CLIENT_MESSAGE; + response.sequence = 0; response.window = xdnd_dragsource; response.format = 32; response.type = atom(QXcbAtom::XdndStatus); @@ -892,6 +896,7 @@ void QXcbDrag::send_leave() xcb_client_message_event_t leave; leave.response_type = XCB_CLIENT_MESSAGE; + leave.sequence = 0; leave.window = current_target; leave.format = 32; leave.type = atom(QXcbAtom::XdndLeave); @@ -962,6 +967,7 @@ void QXcbDrag::handleDrop(QPlatformWindow *, const xcb_client_message_event_t *e xcb_client_message_event_t finished; finished.response_type = XCB_CLIENT_MESSAGE; + finished.sequence = 0; finished.window = xdnd_dragsource; finished.format = 32; finished.type = atom(QXcbAtom::XdndFinished); diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index 6e8755a220..b5e03e68fe 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -164,7 +164,7 @@ QXcbIntegration::QXcbIntegration(const QStringList ¶meters, int &argc, char bool underDebugger = runningUnderDebugger(); if (noGrabArg && doGrabArg && underDebugger) { - qWarning() << "Both -nograb and -dograb command line arguments specified. Please pick one. -nograb takes prcedence"; + qWarning("Both -nograb and -dograb command line arguments specified. Please pick one. -nograb takes prcedence"); doGrabArg = false; } @@ -203,7 +203,7 @@ QPlatformWindow *QXcbIntegration::createPlatformWindow(QWindow *window) const { QXcbScreen *screen = static_cast<QXcbScreen *>(window->screen()->handle()); QXcbGlIntegration *glIntegration = screen->connection()->glIntegration(); - if (window->type() != Qt::Desktop) { + if (window->type() != Qt::Desktop && window->supportsOpenGL()) { if (glIntegration) { QXcbWindow *xcbWindow = glIntegration->createWindow(window); xcbWindow->create(); diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp index 4de7716703..a16e24061c 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp @@ -676,13 +676,13 @@ void QXcbKeyboard::printKeymapError(const char *error) const { qWarning() << error; if (xkb_context) { - qWarning() << "Current XKB configuration data search paths are: "; + qWarning("Current XKB configuration data search paths are: "); for (unsigned int i = 0; i < xkb_context_num_include_paths(xkb_context); ++i) qWarning() << xkb_context_include_path_get(xkb_context, i); } - qWarning() << "Use QT_XKB_CONFIG_ROOT environmental variable to provide an additional search path, " - "add ':' as separator to provide several search paths and/or make sure that XKB configuration data " - "directory contains recent enough contents, to update please see http://cgit.freedesktop.org/xkeyboard-config/ ."; + qWarning("Use QT_XKB_CONFIG_ROOT environmental variable to provide an additional search path, " + "add ':' as separator to provide several search paths and/or make sure that XKB configuration data " + "directory contains recent enough contents, to update please see http://cgit.freedesktop.org/xkeyboard-config/ ."); } void QXcbKeyboard::updateKeymap() diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp index 189053c5bf..a8d401e15b 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp @@ -55,6 +55,7 @@ #include <QtPlatformHeaders/qxcbwindowfunctions.h> #include <QtPlatformHeaders/qxcbintegrationfunctions.h> +#include <QtPlatformHeaders/qxcbscreenfunctions.h> #ifndef QT_NO_DBUS #include "QtPlatformSupport/private/qdbusmenuconnection_p.h" @@ -83,9 +84,10 @@ static int resourceType(const QByteArray &key) QByteArrayLiteral("startupid"), QByteArrayLiteral("traywindow"), QByteArrayLiteral("gettimestamp"), QByteArrayLiteral("x11screen"), QByteArrayLiteral("rootwindow"), - QByteArrayLiteral("subpixeltype"), QByteArrayLiteral("antialiasingEnabled"), + QByteArrayLiteral("subpixeltype"), QByteArrayLiteral("antialiasingenabled"), QByteArrayLiteral("nofonthinting"), - QByteArrayLiteral("atspibus") + QByteArrayLiteral("atspibus"), + QByteArrayLiteral("compositingenabled") }; const QByteArray *end = names + sizeof(names) / sizeof(names[0]); const QByteArray *result = std::find(names, end, key); @@ -202,7 +204,7 @@ void *QXcbNativeInterface::nativeResourceForContext(const QByteArray &resourceSt void *QXcbNativeInterface::nativeResourceForScreen(const QByteArray &resourceString, QScreen *screen) { if (!screen) { - qWarning() << "nativeResourceForScreen: null screen"; + qWarning("nativeResourceForScreen: null screen"); return Q_NULLPTR; } @@ -246,6 +248,10 @@ void *QXcbNativeInterface::nativeResourceForScreen(const QByteArray &resourceStr case RootWindow: result = reinterpret_cast<void *>(xcbScreen->root()); break; + case CompositingEnabled: + if (QXcbVirtualDesktop *vd = xcbScreen->virtualDesktop()) + result = vd->compositingActive() ? this : Q_NULLPTR; + break; default: break; } @@ -376,6 +382,10 @@ QFunctionPointer QXcbNativeInterface::platformFunction(const QByteArray &functio if (function == QXcbWindowFunctions::visualIdIdentifier()) { return QFunctionPointer(QXcbWindowFunctions::VisualId(QXcbWindow::visualIdStatic)); } + + if (function == QXcbScreenFunctions::virtualDesktopNumberIdentifier()) + return QFunctionPointer(QXcbScreenFunctions::VirtualDesktopNumber(QXcbScreen::virtualDesktopNumberStatic)); + return Q_NULLPTR; } diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h index a3e188195f..ba19cd869c 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.h +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h @@ -74,7 +74,8 @@ public: ScreenSubpixelType, ScreenAntialiasingEnabled, NoFontHinting, - AtspiBus + AtspiBus, + CompositingEnabled }; QXcbNativeInterface(); diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 339529edf1..67a9b2f190 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -367,6 +367,7 @@ void QXcbScreen::sendStartupMessage(const QByteArray &message) const ev.response_type = XCB_CLIENT_MESSAGE; ev.format = 8; ev.type = connection()->atom(QXcbAtom::_NET_STARTUP_INFO_BEGIN); + ev.sequence = 0; ev.window = rootWindow; int sent = 0; int length = message.length() + 1; // include NUL byte @@ -444,6 +445,14 @@ void QXcbScreen::setOutput(xcb_randr_output_t outputId, // TODO: Send an event to the QScreen instance that the screen changed its name } +int QXcbScreen::virtualDesktopNumberStatic(const QScreen *screen) +{ + if (screen && screen->handle()) + return static_cast<const QXcbScreen *>(screen->handle())->screenNumber(); + + return 0; +} + /*! \brief handle the XCB screen change event and update properties diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h index e97631e2af..30c5073459 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.h +++ b/src/plugins/platforms/xcb/qxcbscreen.h @@ -139,6 +139,7 @@ public: bool isPrimary() const { return m_primary; } int screenNumber() const { return m_virtualDesktop->number(); } + static int virtualDesktopNumberStatic(const QScreen *screen); xcb_screen_t *screen() const { return m_virtualDesktop->screen(); } xcb_window_t root() const { return screen()->root; } diff --git a/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp b/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp index cfed556ec9..5522af86de 100644 --- a/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp +++ b/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp @@ -100,9 +100,9 @@ xcb_window_t QXcbSystemTrayTracker::locateTrayWindow(const QXcbConnection *conne void QXcbSystemTrayTracker::requestSystemTrayWindowDock(xcb_window_t window) const { xcb_client_message_event_t trayRequest; - memset(&trayRequest, 0, sizeof(trayRequest)); trayRequest.response_type = XCB_CLIENT_MESSAGE; trayRequest.format = 32; + trayRequest.sequence = 0; trayRequest.window = m_trayWindow; trayRequest.type = m_trayAtom; trayRequest.data.data32[0] = XCB_CURRENT_TIME; diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index c910ec18ed..a426e04721 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -40,6 +40,7 @@ #include "qxcbwindow.h" #include <QtDebug> +#include <QMetaEnum> #include <QScreen> #include <QtGui/QIcon> #include <QtGui/QRegion> @@ -201,6 +202,20 @@ static inline QImage::Format imageFormatForVisual(int depth, quint32 red_mask, q case 16: if (blue_mask == 0x1f) return QImage::Format_RGB16; + if (red_mask == 0x1f) { + if (rgbSwap) + *rgbSwap = true; + return QImage::Format_RGB16; + } + break; + case 15: + if (blue_mask == 0x1f) + return QImage::Format_RGB555; + if (red_mask == 0x1f) { + if (rgbSwap) + *rgbSwap = true; + return QImage::Format_RGB555; + } break; default: break; @@ -358,7 +373,7 @@ void QXcbWindow::create() if (visual) m_visualId = connection()->defaultVisualId(); if (!visual) - qWarning() << "Could not use default visual id. Falling back to root_visual for screen."; + qWarning("Could not use default visual id. Falling back to root_visual for screen."); } if (!visual) visual = platformScreen->visualForId(m_visualId); @@ -1096,21 +1111,37 @@ QXcbWindow::NetWmStates QXcbWindow::netWmStates() void QXcbWindow::setNetWmStates(NetWmStates states) { QVector<xcb_atom_t> atoms; - if (states & NetWmStateAbove) + + xcb_get_property_cookie_t get_cookie = + xcb_get_property_unchecked(xcb_connection(), 0, m_window, atom(QXcbAtom::_NET_WM_STATE), + XCB_ATOM_ATOM, 0, 1024); + + xcb_get_property_reply_t *reply = + xcb_get_property_reply(xcb_connection(), get_cookie, NULL); + + if (reply && reply->format == 32 && reply->type == XCB_ATOM_ATOM && reply->value_len > 0) { + const xcb_atom_t *data = static_cast<const xcb_atom_t *>(xcb_get_property_value(reply)); + atoms.resize(reply->value_len); + memcpy((void *)&atoms.first(), (void *)data, reply->value_len * sizeof(xcb_atom_t)); + } + + free(reply); + + if (states & NetWmStateAbove && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_ABOVE))) atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_ABOVE)); - if (states & NetWmStateBelow) + if (states & NetWmStateBelow && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_BELOW))) atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_BELOW)); - if (states & NetWmStateFullScreen) + if (states & NetWmStateFullScreen && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_FULLSCREEN))) atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_FULLSCREEN)); - if (states & NetWmStateMaximizedHorz) + if (states & NetWmStateMaximizedHorz && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_HORZ))) atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_HORZ)); - if (states & NetWmStateMaximizedVert) + if (states & NetWmStateMaximizedVert && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_VERT))) atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_VERT)); - if (states & NetWmStateModal) + if (states & NetWmStateModal && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_MODAL))) atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_MODAL)); - if (states & NetWmStateStaysOnTop) + if (states & NetWmStateStaysOnTop && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_STAYS_ON_TOP))) atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_STAYS_ON_TOP)); - if (states & NetWmStateDemandsAttention) + if (states & NetWmStateDemandsAttention && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_DEMANDS_ATTENTION))) atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_DEMANDS_ATTENTION)); if (atoms.isEmpty()) { @@ -1230,6 +1261,7 @@ void QXcbWindow::changeNetWmState(bool set, xcb_atom_t one, xcb_atom_t two) event.response_type = XCB_CLIENT_MESSAGE; event.format = 32; + event.sequence = 0; event.window = m_window; event.type = atom(QXcbAtom::_NET_WM_STATE); event.data.data32[0] = set ? 1 : 0; @@ -1271,6 +1303,7 @@ void QXcbWindow::setWindowState(Qt::WindowState state) event.response_type = XCB_CLIENT_MESSAGE; event.format = 32; + event.sequence = 0; event.window = m_window; event.type = atom(QXcbAtom::WM_CHANGE_STATE); event.data.data32[0] = XCB_WM_STATE_ICONIC; @@ -1675,6 +1708,7 @@ void QXcbWindow::requestActivateWindow() event.response_type = XCB_CLIENT_MESSAGE; event.format = 32; + event.sequence = 0; event.window = m_window; event.type = atom(QXcbAtom::_NET_ACTIVE_WINDOW); event.data.data32[0] = 1; @@ -2049,8 +2083,9 @@ void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *even } else if (event->type == atom(QXcbAtom::_COMPIZ_DECOR_PENDING) || event->type == atom(QXcbAtom::_COMPIZ_DECOR_REQUEST) || event->type == atom(QXcbAtom::_COMPIZ_DECOR_DELETE_PIXMAP) - || event->type == atom(QXcbAtom::_COMPIZ_TOOLKIT_ACTION)) { - //silence the _COMPIZ messages for now + || event->type == atom(QXcbAtom::_COMPIZ_TOOLKIT_ACTION) + || event->type == atom(QXcbAtom::_GTK_LOAD_ICONTHEMES)) { + //silence the _COMPIZ and _GTK messages for now } else { qWarning() << "QXcbWindow: Unhandled client message:" << connection()->atomName(event->type); } @@ -2171,7 +2206,7 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event) } void QXcbWindow::handleButtonPressEvent(int event_x, int event_y, int root_x, int root_y, - int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp) + int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp, Qt::MouseEventSource source) { const bool isWheel = detail >= 4 && detail <= 7; if (!isWheel && window() != QGuiApplication::focusWindow()) { @@ -2207,11 +2242,11 @@ void QXcbWindow::handleButtonPressEvent(int event_x, int event_y, int root_x, in return; } - handleMouseEvent(timestamp, local, global, modifiers); + handleMouseEvent(timestamp, local, global, modifiers, source); } void QXcbWindow::handleButtonReleaseEvent(int event_x, int event_y, int root_x, int root_y, - int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp) + int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp, Qt::MouseEventSource source) { QPoint local(event_x, event_y); QPoint global(root_x, root_y); @@ -2221,7 +2256,7 @@ void QXcbWindow::handleButtonReleaseEvent(int event_x, int event_y, int root_x, return; } - handleMouseEvent(timestamp, local, global, modifiers); + handleMouseEvent(timestamp, local, global, modifiers, source); } static bool ignoreLeaveEvent(quint8 mode, quint8 detail) @@ -2304,11 +2339,11 @@ void QXcbWindow::handleLeaveNotifyEvent(int root_x, int root_y, } void QXcbWindow::handleMotionNotifyEvent(int event_x, int event_y, int root_x, int root_y, - Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp) + Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp, Qt::MouseEventSource source) { QPoint local(event_x, event_y); QPoint global(root_x, root_y); - handleMouseEvent(timestamp, local, global, modifiers); + handleMouseEvent(timestamp, local, global, modifiers, source); } // Handlers for plain xcb events. Used only when XI 2.2 or newer is not available. @@ -2339,7 +2374,7 @@ static inline int fixed1616ToInt(FP1616 val) } // With XI 2.2+ press/release/motion comes here instead of the above handlers. -void QXcbWindow::handleXIMouseEvent(xcb_ge_event_t *event) +void QXcbWindow::handleXIMouseEvent(xcb_ge_event_t *event, Qt::MouseEventSource source) { QXcbConnection *conn = connection(); xXIDeviceEvent *ev = reinterpret_cast<xXIDeviceEvent *>(event); @@ -2359,20 +2394,27 @@ void QXcbWindow::handleXIMouseEvent(xcb_ge_event_t *event) conn->setButton(conn->translateMouseButton(i), XIMaskIsSet(buttonMask, i)); } + const char *sourceName = nullptr; + if (lcQpaXInput().isDebugEnabled()) { + const QMetaObject *metaObject = qt_getEnumMetaObject(source); + const QMetaEnum me = metaObject->enumerator(metaObject->indexOfEnumerator(qt_getEnumName(source))); + sourceName = me.valueToKey(source); + } + switch (ev->evtype) { case XI_ButtonPress: - qCDebug(lcQpaXInput, "XI2 mouse press, button %d, time %d", button, ev->time); + qCDebug(lcQpaXInput, "XI2 mouse press, button %d, time %d, source %s", button, ev->time, sourceName); conn->setButton(button, true); - handleButtonPressEvent(event_x, event_y, root_x, root_y, ev->detail, modifiers, ev->time); + handleButtonPressEvent(event_x, event_y, root_x, root_y, ev->detail, modifiers, ev->time, source); break; case XI_ButtonRelease: - qCDebug(lcQpaXInput, "XI2 mouse release, button %d, time %d", button, ev->time); + qCDebug(lcQpaXInput, "XI2 mouse release, button %d, time %d, source %s", button, ev->time, sourceName); conn->setButton(button, false); - handleButtonReleaseEvent(event_x, event_y, root_x, root_y, ev->detail, modifiers, ev->time); + handleButtonReleaseEvent(event_x, event_y, root_x, root_y, ev->detail, modifiers, ev->time, source); break; case XI_Motion: - qCDebug(lcQpaXInput, "XI2 mouse motion %d,%d, time %d", event_x, event_y, ev->time); - handleMotionNotifyEvent(event_x, event_y, root_x, root_y, modifiers, ev->time); + qCDebug(lcQpaXInput, "XI2 mouse motion %d,%d, time %d, source %s", event_x, event_y, ev->time, sourceName); + handleMotionNotifyEvent(event_x, event_y, root_x, root_y, modifiers, ev->time, source); break; default: qWarning() << "Unrecognized XI2 mouse event" << ev->evtype; @@ -2415,10 +2457,11 @@ void QXcbWindow::handleXIEnterLeave(xcb_ge_event_t *event) QXcbWindow *QXcbWindow::toWindow() { return this; } -void QXcbWindow::handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global, Qt::KeyboardModifiers modifiers) +void QXcbWindow::handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global, + Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source) { connection()->setTime(time); - QWindowSystemInterface::handleMouseEvent(window(), time, local, global, connection()->buttons(), modifiers); + QWindowSystemInterface::handleMouseEvent(window(), time, local, global, connection()->buttons(), modifiers, source); } void QXcbWindow::handleEnterNotifyEvent(const xcb_enter_notify_event_t *event) @@ -2612,6 +2655,7 @@ bool QXcbWindow::startSystemResize(const QPoint &pos, Qt::Corner corner) xcb_client_message_event_t xev; xev.response_type = XCB_CLIENT_MESSAGE; xev.type = moveResize; + xev.sequence = 0; xev.window = xcb_window(); xev.format = 32; const QPoint globalPos = window()->mapToGlobal(pos); @@ -2640,6 +2684,7 @@ void QXcbWindow::sendXEmbedMessage(xcb_window_t window, quint32 message, event.response_type = XCB_CLIENT_MESSAGE; event.format = 32; + event.sequence = 0; event.window = window; event.type = atom(QXcbAtom::_XEMBED); event.data.data32[0] = connection()->time(); diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index 72688cdf16..7b70dc2ef8 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -139,13 +139,14 @@ public: void handleFocusOutEvent(const xcb_focus_out_event_t *event) Q_DECL_OVERRIDE; void handlePropertyNotifyEvent(const xcb_property_notify_event_t *event) Q_DECL_OVERRIDE; #ifdef XCB_USE_XINPUT22 - void handleXIMouseEvent(xcb_ge_event_t *) Q_DECL_OVERRIDE; + void handleXIMouseEvent(xcb_ge_event_t *, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized) Q_DECL_OVERRIDE; void handleXIEnterLeave(xcb_ge_event_t *) Q_DECL_OVERRIDE; #endif QXcbWindow *toWindow() Q_DECL_OVERRIDE; - void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global, Qt::KeyboardModifiers modifiers); + void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global, + Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source); void updateNetWmUserTime(xcb_timestamp_t timestamp); @@ -214,13 +215,13 @@ protected: bool compressExposeEvent(QRegion &exposeRegion); void handleButtonPressEvent(int event_x, int event_y, int root_x, int root_y, - int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp); + int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized); void handleButtonReleaseEvent(int event_x, int event_y, int root_x, int root_y, - int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp); + int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized); void handleMotionNotifyEvent(int event_x, int event_y, int root_x, int root_y, - Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp); + Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized); void handleEnterNotifyEvent(int event_x, int event_y, int root_x, int root_y, quint8 mode, quint8 detail, xcb_timestamp_t timestamp); diff --git a/src/plugins/platforms/xcb/qxcbwmsupport.cpp b/src/plugins/platforms/xcb/qxcbwmsupport.cpp index 38116ac239..470f021314 100644 --- a/src/plugins/platforms/xcb/qxcbwmsupport.cpp +++ b/src/plugins/platforms/xcb/qxcbwmsupport.cpp @@ -122,10 +122,10 @@ void QXcbWMSupport::updateVirtualRoots() } while (remaining > 0); #ifdef Q_XCB_DEBUG - qDebug() << "======== updateVirtualRoots"; + qDebug("======== updateVirtualRoots"); for (int i = 0; i < net_virtual_roots.size(); ++i) qDebug() << connection()->atomName(net_virtual_roots.at(i)); - qDebug() << "======== updateVirtualRoots"; + qDebug("======== updateVirtualRoots"); #endif } diff --git a/src/plugins/platforms/xcb/xcb-plugin.pro b/src/plugins/platforms/xcb/xcb-plugin.pro index 09ab1ad77a..75684a769b 100644 --- a/src/plugins/platforms/xcb/xcb-plugin.pro +++ b/src/plugins/platforms/xcb/xcb-plugin.pro @@ -1,13 +1,12 @@ TARGET = qxcb -PLUGIN_TYPE = platforms -PLUGIN_CLASS_NAME = QXcbIntegrationPlugin -!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - -load(qt_plugin) - QT += core-private gui-private platformsupport-private xcb_qpa_lib-private SOURCES = \ qxcbmain.cpp OTHER_FILES += xcb.json README +PLUGIN_TYPE = platforms +PLUGIN_CLASS_NAME = QXcbIntegrationPlugin +!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - +load(qt_plugin) diff --git a/src/plugins/platforms/xcb/xcb_qpa_lib.pro b/src/plugins/platforms/xcb/xcb_qpa_lib.pro index 302d87e007..f4a4e5a78a 100644 --- a/src/plugins/platforms/xcb/xcb_qpa_lib.pro +++ b/src/plugins/platforms/xcb/xcb_qpa_lib.pro @@ -1,8 +1,6 @@ TARGET = QtXcbQpa CONFIG += no_module_headers internal_module -load(qt_module) - QT += core-private gui-private platformsupport-private SOURCES = \ @@ -105,3 +103,4 @@ contains(QT_CONFIG, xkbcommon-qt) { QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_XKBCOMMON } +load(qt_module) diff --git a/src/plugins/printsupport/cocoa/cocoa.pro b/src/plugins/printsupport/cocoa/cocoa.pro index c993b42574..242c596bcd 100644 --- a/src/plugins/printsupport/cocoa/cocoa.pro +++ b/src/plugins/printsupport/cocoa/cocoa.pro @@ -1,8 +1,5 @@ TARGET = cocoaprintersupport MODULE = cocoaprintersupport -PLUGIN_TYPE = printsupport -PLUGIN_CLASS_NAME = QCocoaPrinterSupportPlugin -load(qt_plugin) QT += gui-private printsupport-private LIBS += -framework AppKit @@ -10,3 +7,7 @@ LIBS += -framework AppKit SOURCES += main.cpp OTHER_FILES += cocoa.json + +PLUGIN_TYPE = printsupport +PLUGIN_CLASS_NAME = QCocoaPrinterSupportPlugin +load(qt_plugin) diff --git a/src/plugins/printsupport/cups/cups.pro b/src/plugins/printsupport/cups/cups.pro index cdbb08b10a..757408e7f7 100644 --- a/src/plugins/printsupport/cups/cups.pro +++ b/src/plugins/printsupport/cups/cups.pro @@ -1,8 +1,5 @@ TARGET = cupsprintersupport MODULE = cupsprintersupport -PLUGIN_TYPE = printsupport -PLUGIN_CLASS_NAME = QCupsPrinterSupportPlugin -load(qt_plugin) QT += core-private gui-private printsupport printsupport-private @@ -20,3 +17,7 @@ HEADERS += qcupsprintersupport_p.h \ qcupsprintengine_p.h OTHER_FILES += cups.json + +PLUGIN_TYPE = printsupport +PLUGIN_CLASS_NAME = QCupsPrinterSupportPlugin +load(qt_plugin) diff --git a/src/plugins/printsupport/windows/windows.pro b/src/plugins/printsupport/windows/windows.pro index 3366262ef0..06694fb7fe 100644 --- a/src/plugins/printsupport/windows/windows.pro +++ b/src/plugins/printsupport/windows/windows.pro @@ -1,8 +1,5 @@ TARGET = windowsprintersupport MODULE = windowsprintersupport -PLUGIN_TYPE = printsupport -PLUGIN_CLASS_NAME = QWindowsPrinterSupportPlugin -load(qt_plugin) QT *= core-private QT *= gui-private @@ -22,3 +19,7 @@ HEADERS += \ OTHER_FILES += windows.json LIBS += -lwinspool -lcomdlg32 -lgdi32 -luser32 + +PLUGIN_TYPE = printsupport +PLUGIN_CLASS_NAME = QWindowsPrinterSupportPlugin +load(qt_plugin) |