diff options
Diffstat (limited to 'src/plugins/platforms')
119 files changed, 468 insertions, 2469 deletions
diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index f500d6e413..2bc3b0dc7d 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -487,7 +487,7 @@ static jboolean startQtApplication(JNIEnv *env, jobject /*object*/, jstring para // Obtain a handle to the main library (the library that contains the main() function). // This library should already be loaded, and calling dlopen() will just return a reference to it. m_mainLibraryHnd = dlopen(m_applicationParams.first().data(), 0); - if (m_mainLibraryHnd == nullptr) { + if (Q_UNLIKELY(!m_mainLibraryHnd)) { qCritical() << "dlopen failed:" << dlerror(); return false; } @@ -497,7 +497,7 @@ static jboolean startQtApplication(JNIEnv *env, jobject /*object*/, jstring para m_main = (Main)dlsym(RTLD_DEFAULT, "main"); } - if (!m_main) { + if (Q_UNLIKELY(!m_main)) { qCritical() << "dlsym failed:" << dlerror() << endl << "Could not find main method"; return false; diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index e3ea048e84..92c0c2cf0f 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -339,7 +339,7 @@ QAndroidInputContext::QAndroidInputContext() : QPlatformInputContext(), m_composingTextStart(-1), m_blockUpdateSelection(false), m_batchEditNestingLevel(0), m_focusObject(0) { jclass clazz = QJNIEnvironmentPrivate::findClass(QtNativeInputConnectionClassName); - if (clazz == NULL) { + if (Q_UNLIKELY(!clazz)) { qCritical() << "Native registration unable to find class '" << QtNativeInputConnectionClassName << '\''; @@ -347,7 +347,7 @@ QAndroidInputContext::QAndroidInputContext() } QJNIEnvironmentPrivate env; - if (env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])) < 0) { + if (Q_UNLIKELY(env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])) < 0)) { qCritical() << "RegisterNatives failed for '" << QtNativeInputConnectionClassName << '\''; @@ -355,7 +355,7 @@ QAndroidInputContext::QAndroidInputContext() } clazz = QJNIEnvironmentPrivate::findClass(QtExtractedTextClassName); - if (clazz == NULL) { + if (Q_UNLIKELY(!clazz)) { qCritical() << "Native registration unable to find class '" << QtExtractedTextClassName << '\''; @@ -364,43 +364,43 @@ QAndroidInputContext::QAndroidInputContext() m_extractedTextClass = static_cast<jclass>(env->NewGlobalRef(clazz)); m_classConstructorMethodID = env->GetMethodID(m_extractedTextClass, "<init>", "()V"); - if (m_classConstructorMethodID == NULL) { + if (Q_UNLIKELY(!m_classConstructorMethodID)) { qCritical() << "GetMethodID failed"; return; } m_partialEndOffsetFieldID = env->GetFieldID(m_extractedTextClass, "partialEndOffset", "I"); - if (m_partialEndOffsetFieldID == NULL) { + if (Q_UNLIKELY(!m_partialEndOffsetFieldID)) { qCritical() << "Can't find field partialEndOffset"; return; } m_partialStartOffsetFieldID = env->GetFieldID(m_extractedTextClass, "partialStartOffset", "I"); - if (m_partialStartOffsetFieldID == NULL) { + if (Q_UNLIKELY(!m_partialStartOffsetFieldID)) { qCritical() << "Can't find field partialStartOffset"; return; } m_selectionEndFieldID = env->GetFieldID(m_extractedTextClass, "selectionEnd", "I"); - if (m_selectionEndFieldID == NULL) { + if (Q_UNLIKELY(!m_selectionEndFieldID)) { qCritical() << "Can't find field selectionEnd"; return; } m_selectionStartFieldID = env->GetFieldID(m_extractedTextClass, "selectionStart", "I"); - if (m_selectionStartFieldID == NULL) { + if (Q_UNLIKELY(!m_selectionStartFieldID)) { qCritical() << "Can't find field selectionStart"; return; } m_startOffsetFieldID = env->GetFieldID(m_extractedTextClass, "startOffset", "I"); - if (m_startOffsetFieldID == NULL) { + if (Q_UNLIKELY(!m_startOffsetFieldID)) { qCritical() << "Can't find field startOffset"; return; } m_textFieldID = env->GetFieldID(m_extractedTextClass, "text", "Ljava/lang/String;"); - if (m_textFieldID == NULL) { + if (Q_UNLIKELY(!m_textFieldID)) { qCritical() << "Can't find field text"; return; } diff --git a/src/plugins/platforms/android/qandroidplatformfontdatabase.cpp b/src/plugins/platforms/android/qandroidplatformfontdatabase.cpp index a8bbec9400..835ca8a10a 100644 --- a/src/plugins/platforms/android/qandroidplatformfontdatabase.cpp +++ b/src/plugins/platforms/android/qandroidplatformfontdatabase.cpp @@ -47,7 +47,7 @@ void QAndroidPlatformFontDatabase::populateFontDatabase() QString fontpath = fontDir(); QDir dir(fontpath); - if (!dir.exists()) { + if (Q_UNLIKELY(!dir.exists())) { qFatal("QFontDatabase: Cannot find font directory %s - is Qt installed correctly?", qPrintable(fontpath)); } diff --git a/src/plugins/platforms/android/qandroidplatformintegration.cpp b/src/plugins/platforms/android/qandroidplatformintegration.cpp index 2a127f5c3c..23d242a95f 100644 --- a/src/plugins/platforms/android/qandroidplatformintegration.cpp +++ b/src/plugins/platforms/android/qandroidplatformintegration.cpp @@ -120,14 +120,14 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList ¶ m_androidPlatformNativeInterface = new QAndroidPlatformNativeInterface(); m_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); - if (m_eglDisplay == EGL_NO_DISPLAY) + if (Q_UNLIKELY(m_eglDisplay == EGL_NO_DISPLAY)) qFatal("Could not open egl display"); EGLint major, minor; - if (!eglInitialize(m_eglDisplay, &major, &minor)) + if (Q_UNLIKELY(!eglInitialize(m_eglDisplay, &major, &minor))) qFatal("Could not initialize egl display"); - if (!eglBindAPI(EGL_OPENGL_ES_API)) + if (Q_UNLIKELY(!eglBindAPI(EGL_OPENGL_ES_API))) qFatal("Could not bind GL_ES API"); m_primaryScreen = new QAndroidPlatformScreen(); diff --git a/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp b/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp index 57d3bfaf22..85f51d7d29 100644 --- a/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp +++ b/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp @@ -175,7 +175,7 @@ void QAndroidPlatformOpenGLWindow::createEgl(EGLConfig config) m_androidSurfaceObject = QJNIObjectPrivate(); m_eglSurface = eglCreateWindowSurface(m_eglDisplay, config, m_nativeWindow, NULL); m_format = q_glFormatFromConfig(m_eglDisplay, config, window()->requestedFormat()); - if (m_eglSurface == EGL_NO_SURFACE) { + if (Q_UNLIKELY(m_eglSurface == EGL_NO_SURFACE)) { EGLint error = eglGetError(); eglTerminate(m_eglDisplay); qFatal("EGL Error : Could not create the egl surface: error = 0x%x\n", error); diff --git a/src/plugins/platforms/android/qandroidplatformtheme.cpp b/src/plugins/platforms/android/qandroidplatformtheme.cpp index 5531910555..94e132fc9a 100644 --- a/src/plugins/platforms/android/qandroidplatformtheme.cpp +++ b/src/plugins/platforms/android/qandroidplatformtheme.cpp @@ -204,12 +204,12 @@ QJsonObject AndroidStyle::loadStyleData() QJsonParseError error; QJsonDocument document = QJsonDocument::fromJson(f.readAll(), &error); - if (document.isNull()) { + if (Q_UNLIKELY(document.isNull())) { qCritical() << error.errorString(); return QJsonObject(); } - if (!document.isObject()) { + if (Q_UNLIKELY(!document.isObject())) { qCritical() << "Style.json does not contain a valid style."; return QJsonObject(); } @@ -219,7 +219,7 @@ QJsonObject AndroidStyle::loadStyleData() static std::shared_ptr<AndroidStyle> loadAndroidStyle(QPalette *defaultPalette) { double pixelDensity = QHighDpiScaling::isActive() ? QtAndroid::pixelDensity() : 1.0; - std::shared_ptr<AndroidStyle> style(new AndroidStyle); + std::shared_ptr<AndroidStyle> style = std::make_shared<AndroidStyle>(); style->m_styleData = AndroidStyle::loadStyleData(); if (style->m_styleData.isEmpty()) return std::shared_ptr<AndroidStyle>(); diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index ba0e6b001a..fec1da334f 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -84,7 +84,7 @@ contains(QT_CONFIG, opengl.*) { RESOURCES += qcocoaresources.qrc -LIBS += -framework Cocoa -framework Carbon -framework IOKit -lcups +LIBS += -framework AppKit -framework Carbon -framework IOKit -lcups QT += core-private gui-private platformsupport-private diff --git a/src/plugins/platforms/cocoa/main.mm b/src/plugins/platforms/cocoa/main.mm index 43ff715161..4ec2b4ffc4 100644 --- a/src/plugins/platforms/cocoa/main.mm +++ b/src/plugins/platforms/cocoa/main.mm @@ -31,7 +31,7 @@ ** ****************************************************************************/ -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> #include <qpa/qplatformintegrationplugin.h> #include <qpa/qplatformthemeplugin.h> diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.h b/src/plugins/platforms/cocoa/qcocoaaccessibility.h index 228643ab26..2d1aa41a9a 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibility.h +++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.h @@ -33,7 +33,7 @@ #ifndef QCOCOAACCESIBILITY_H #define QCOCOAACCESIBILITY_H -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> #include <QtGui> #include <qpa/qplatformaccessibility.h> diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm index 4e901ba015..f83d15f48e 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm @@ -334,6 +334,7 @@ bool hasValueAttribute(QAccessibleInterface *interface) Q_ASSERT(interface); const QAccessible::Role qtrole = interface->role(); if (qtrole == QAccessible::EditableText + || qtrole == QAccessible::StaticText || interface->valueInterface() || interface->state().checkable) { return true; @@ -345,6 +346,9 @@ bool hasValueAttribute(QAccessibleInterface *interface) id getValueAttribute(QAccessibleInterface *interface) { const QAccessible::Role qtrole = interface->role(); + if (qtrole == QAccessible::StaticText) { + return QCFString::toNSString(interface->text(QAccessible::Name)); + } if (qtrole == QAccessible::EditableText) { if (QAccessibleTextInterface *textInterface = interface->textInterface()) { // VoiceOver will read out the entire text string at once when returning diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index b55393c7dc..5b2ee1c284 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -292,6 +292,8 @@ static void convertLineOffset(QAccessibleTextInterface *text, int &line, int &of QSize qtSize = iface->rect().size(); return [NSValue valueWithSize: NSMakeSize(qtSize.width(), qtSize.height())]; } else if ([attribute isEqualToString:NSAccessibilityTitleAttribute]) { + if (iface->role() == QAccessible::StaticText) + return nil; return QCFString::toNSString(iface->text(QAccessible::Name)); } else if ([attribute isEqualToString:NSAccessibilityDescriptionAttribute]) { return QCFString::toNSString(iface->text(QAccessible::Description)); diff --git a/src/plugins/platforms/cocoa/qcocoaapplication.mm b/src/plugins/platforms/cocoa/qcocoaapplication.mm index d9919f1120..7d0018a595 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplication.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplication.mm @@ -181,7 +181,7 @@ QT_BEGIN_NAMESPACE void qt_redirectNSApplicationSendEvent() { - if (QCoreApplication::testAttribute(Qt::AA_MacPluginApplication)) + if (QCoreApplication::testAttribute(Qt::AA_PluginApplication)) // In a plugin we cannot chain sendEvent hooks: a second plugin could // store the implementation of the first, which during the program flow // can be unloaded. @@ -207,7 +207,7 @@ void qt_redirectNSApplicationSendEvent() void qt_resetNSApplicationSendEvent() { - if (QCoreApplication::testAttribute(Qt::AA_MacPluginApplication)) + if (QCoreApplication::testAttribute(Qt::AA_PluginApplication)) return; diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h index abaaba91a5..a0eb8cc6fd 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h @@ -79,7 +79,7 @@ // -#import <Cocoa/Cocoa.h> +#import <AppKit/AppKit.h> #include <qglobal.h> #include <private/qcore_mac_p.h> diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.h b/src/plugins/platforms/cocoa/qcocoabackingstore.h index 5a199de4a5..839b536863 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.h +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.h @@ -34,7 +34,7 @@ #ifndef QBACKINGSTORE_COCOA_H #define QBACKINGSTORE_COCOA_H -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> #include "qcocoawindow.h" #include "qnsview.h" diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm index 8843e009a2..ddc2938855 100644 --- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm @@ -31,13 +31,13 @@ ** ****************************************************************************/ -#include "qcocoacolordialoghelper.h" - #ifndef QT_NO_COLORDIALOG #include <QtCore/qdebug.h> #include <QtCore/qtimer.h> +#include <qpa/qplatformtheme.h> +#include "qcocoacolordialoghelper.h" #include "qcocoahelpers.h" #import <AppKit/AppKit.h> @@ -52,7 +52,7 @@ static NSButton *macCreateButton(const char *text, NSView *superview) [button setButtonType:NSMomentaryLightButton]; [button setBezelStyle:NSRoundedBezelStyle]; [button setTitle:(NSString*)(CFStringRef)QCFString( - qt_mac_removeMnemonics(QCoreApplication::translate("QDialogButtonBox", text)))]; + QPlatformTheme::removeMnemonics(QCoreApplication::translate("QDialogButtonBox", text)))]; [[button cell] setFont:[NSFont systemFontOfSize: [NSFont systemFontSizeForControlSize:NSRegularControlSize]]]; [superview addSubview:button]; diff --git a/src/plugins/platforms/cocoa/qcocoacursor.h b/src/plugins/platforms/cocoa/qcocoacursor.h index d104939f0c..58be5414f1 100644 --- a/src/plugins/platforms/cocoa/qcocoacursor.h +++ b/src/plugins/platforms/cocoa/qcocoacursor.h @@ -34,7 +34,7 @@ #ifndef QWINDOWSCURSOR_H #define QWINDOWSCURSOR_H -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> #include <QtCore> #include <qpa/qplatformcursor.h> diff --git a/src/plugins/platforms/cocoa/qcocoadrag.h b/src/plugins/platforms/cocoa/qcocoadrag.h index c1eeb34679..51de5dd5ed 100644 --- a/src/plugins/platforms/cocoa/qcocoadrag.h +++ b/src/plugins/platforms/cocoa/qcocoadrag.h @@ -34,7 +34,7 @@ #ifndef QCOCOADRAG_H #define QCOCOADRAG_H -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> #include <QtGui> #include <qpa/qplatformdrag.h> #include <private/qsimpledrag_p.h> diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm index 1865624d57..117eba1b2a 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm @@ -80,7 +80,7 @@ #include <qdebug.h> #undef slots -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> #include <Carbon/Carbon.h> QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm index 9dc013ba4d..0bfb105a5d 100644 --- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm @@ -31,6 +31,8 @@ ** ****************************************************************************/ +#include <qpa/qplatformtheme.h> + #include "qcocoafiledialoghelper.h" #ifndef QT_NO_FILEDIALOG @@ -180,7 +182,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSOpenSavePanelDelegate); static QString strippedText(QString s) { s.remove( QString::fromLatin1("...") ); - return qt_mac_removeMnemonics(s).trimmed(); + return QPlatformTheme::removeMnemonics(s).trimmed(); } - (NSString *)strip:(const QString &)label diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm index d1802fe4f9..c1c871f02b 100644 --- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm @@ -31,17 +31,17 @@ ** ****************************************************************************/ -#include "qcocoafontdialoghelper.h" - #ifndef QT_NO_FONTDIALOG #include <QtCore/qtimer.h> #include <QtGui/qfontdatabase.h> +#include <qpa/qplatformtheme.h> #include <private/qfont_p.h> #include <private/qfontengine_p.h> #include <private/qfontengine_coretext_p.h> +#include "qcocoafontdialoghelper.h" #include "qcocoahelpers.h" #import <AppKit/AppKit.h> @@ -72,7 +72,7 @@ static NSButton *macCreateButton(const char *text, NSView *superview) [button setButtonType:NSMomentaryLightButton]; [button setBezelStyle:NSRoundedBezelStyle]; [button setTitle:(NSString*)(CFStringRef)QCFString( - qt_mac_removeMnemonics(QCoreApplication::translate("QDialogButtonBox", text)))]; + QPlatformTheme::removeMnemonics(QCoreApplication::translate("QDialogButtonBox", text)))]; [[button cell] setFont:[NSFont systemFontOfSize: [NSFont systemFontSizeForControlSize:NSRegularControlSize]]]; [superview addSubview:button]; diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.h b/src/plugins/platforms/cocoa/qcocoaglcontext.h index fa6db018a7..cac53b14f9 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.h +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.h @@ -40,7 +40,7 @@ #include <QtGui/QWindow> #undef slots -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm index 0f9b8b900d..d43c8e5ee9 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm @@ -39,7 +39,7 @@ #include <QtPlatformSupport/private/cglconvenience_p.h> #include <QtPlatformHeaders/qcocoanativecontext.h> -#import <Cocoa/Cocoa.h> +#import <AppKit/AppKit.h> QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.h b/src/plugins/platforms/cocoa/qcocoahelpers.h index b86a17ca12..a75316acba 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.h +++ b/src/plugins/platforms/cocoa/qcocoahelpers.h @@ -90,7 +90,6 @@ Qt::DropActions qt_mac_mapNSDragOperations(NSDragOperation nsActions); // Misc void qt_mac_transformProccessToForegroundApplication(); -QString qt_mac_removeMnemonics(const QString &original); CGColorSpaceRef qt_mac_genericColorSpace(); CGColorSpaceRef qt_mac_displayColorSpace(const QWidget *widget); CGColorSpaceRef qt_mac_colorSpaceForDeviceType(const QPaintDevice *paintDevice); diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm index f51c21ee9b..cfb7e911cc 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.mm +++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm @@ -31,6 +31,8 @@ ** ****************************************************************************/ +#include <qpa/qplatformtheme.h> + #include "qcocoahelpers.h" @@ -46,6 +48,8 @@ #include <algorithm> +#include <Carbon/Carbon.h> + QT_BEGIN_NAMESPACE // @@ -439,88 +443,49 @@ Qt::DropActions qt_mac_mapNSDragOperations(NSDragOperation nsActions) // Misc // -// Changes the process type for this process to kProcessTransformToForegroundApplication, +// Sets the activation policy for this process to NSApplicationActivationPolicyRegular, // unless either LSUIElement or LSBackgroundOnly is set in the Info.plist. void qt_mac_transformProccessToForegroundApplication() { - ProcessSerialNumber psn; - if (GetCurrentProcess(&psn) == noErr) { - bool forceTransform = true; - CFTypeRef value = CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), - CFSTR("LSUIElement")); + bool forceTransform = true; + CFTypeRef value = CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), + CFSTR("LSUIElement")); + if (value) { + CFTypeID valueType = CFGetTypeID(value); + // Officially it's supposed to be a string, a boolean makes sense, so we'll check. + // A number less so, but OK. + if (valueType == CFStringGetTypeID()) + forceTransform = !(QCFString::toQString(static_cast<CFStringRef>(value)).toInt()); + else if (valueType == CFBooleanGetTypeID()) + forceTransform = !CFBooleanGetValue(static_cast<CFBooleanRef>(value)); + else if (valueType == CFNumberGetTypeID()) { + int valueAsInt; + CFNumberGetValue(static_cast<CFNumberRef>(value), kCFNumberIntType, &valueAsInt); + forceTransform = !valueAsInt; + } + } + + if (forceTransform) { + value = CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), + CFSTR("LSBackgroundOnly")); if (value) { CFTypeID valueType = CFGetTypeID(value); - // Officially it's supposed to be a string, a boolean makes sense, so we'll check. - // A number less so, but OK. - if (valueType == CFStringGetTypeID()) - forceTransform = !(QCFString::toQString(static_cast<CFStringRef>(value)).toInt()); - else if (valueType == CFBooleanGetTypeID()) + if (valueType == CFBooleanGetTypeID()) forceTransform = !CFBooleanGetValue(static_cast<CFBooleanRef>(value)); + else if (valueType == CFStringGetTypeID()) + forceTransform = !(QCFString::toQString(static_cast<CFStringRef>(value)).toInt()); else if (valueType == CFNumberGetTypeID()) { int valueAsInt; CFNumberGetValue(static_cast<CFNumberRef>(value), kCFNumberIntType, &valueAsInt); forceTransform = !valueAsInt; } } - - if (forceTransform) { - value = CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), - CFSTR("LSBackgroundOnly")); - if (value) { - CFTypeID valueType = CFGetTypeID(value); - if (valueType == CFBooleanGetTypeID()) - forceTransform = !CFBooleanGetValue(static_cast<CFBooleanRef>(value)); - else if (valueType == CFStringGetTypeID()) - forceTransform = !(QCFString::toQString(static_cast<CFStringRef>(value)).toInt()); - else if (valueType == CFNumberGetTypeID()) { - int valueAsInt; - CFNumberGetValue(static_cast<CFNumberRef>(value), kCFNumberIntType, &valueAsInt); - forceTransform = !valueAsInt; - } - } - } - - if (forceTransform) { - TransformProcessType(&psn, kProcessTransformToForegroundApplication); - } } -} -QString qt_mac_removeMnemonics(const QString &original) -{ - QString returnText(original.size(), 0); - int finalDest = 0; - int currPos = 0; - int l = original.length(); - while (l) { - if (original.at(currPos) == QLatin1Char('&') - && (l == 1 || original.at(currPos + 1) != QLatin1Char('&'))) { - ++currPos; - --l; - if (l == 0) - break; - } else if (original.at(currPos) == QLatin1Char('(') && l >= 4 && - original.at(currPos + 1) == QLatin1Char('&') && - original.at(currPos + 2) != QLatin1Char('&') && - original.at(currPos + 3) == QLatin1Char(')')) { - /* remove mnemonics its format is "\s*(&X)" */ - int n = 0; - while (finalDest > n && returnText.at(finalDest - n - 1).isSpace()) - ++n; - finalDest -= n; - currPos += 4; - l -= 4; - continue; - } - returnText[finalDest] = original.at(currPos); - ++currPos; - ++finalDest; - --l; + if (forceTransform) { + [[NSApplication sharedApplication] setActivationPolicy:NSApplicationActivationPolicyRegular]; } - returnText.truncate(finalDest); - return returnText; } - static CGColorSpaceRef m_genericColorSpace = 0; static QHash<CGDirectDisplayID, CGColorSpaceRef> m_displayColorSpaceHash; static bool m_postRoutineRegistered = false; @@ -774,7 +739,7 @@ bool qt_mac_execute_apple_script(const QString &script, AEDesc *ret) QString qt_mac_removeAmpersandEscapes(QString s) { - return qt_mac_removeMnemonics(s).trimmed(); + return QPlatformTheme::removeMnemonics(s).trimmed(); } /*! \internal diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h index e7e21c356a..c7875af83e 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.h +++ b/src/plugins/platforms/cocoa/qcocoaintegration.h @@ -34,7 +34,7 @@ #ifndef QPLATFORMINTEGRATION_COCOA_H #define QPLATFORMINTEGRATION_COCOA_H -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> #include "qcocoacursor.h" #include "qcocoawindow.h" diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 6bec6b191d..e469ec5c74 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -317,7 +317,7 @@ QCocoaIntegration::QCocoaIntegration(const QStringList ¶mList) // ### For AA_MacPluginApplication we don't want to load the menu nib. // Qt 4 also does not set the application delegate, so that behavior // is matched here. - if (!QCoreApplication::testAttribute(Qt::AA_MacPluginApplication)) { + if (!QCoreApplication::testAttribute(Qt::AA_PluginApplication)) { // Set app delegate, link to the current delegate (if any) QCocoaApplicationDelegate *newDelegate = [QCocoaApplicationDelegate sharedDelegate]; @@ -344,7 +344,7 @@ QCocoaIntegration::~QCocoaIntegration() qt_resetNSApplicationSendEvent(); QMacAutoReleasePool pool; - if (!QCoreApplication::testAttribute(Qt::AA_MacPluginApplication)) { + if (!QCoreApplication::testAttribute(Qt::AA_PluginApplication)) { // remove the apple event handlers installed by QCocoaApplicationDelegate QCocoaApplicationDelegate *delegate = [QCocoaApplicationDelegate sharedDelegate]; [delegate removeAppleEventHandlers]; diff --git a/src/plugins/platforms/cocoa/qcocoakeymapper.h b/src/plugins/platforms/cocoa/qcocoakeymapper.h index 11bbdc5426..9e79d634ab 100644 --- a/src/plugins/platforms/cocoa/qcocoakeymapper.h +++ b/src/plugins/platforms/cocoa/qcocoakeymapper.h @@ -36,7 +36,7 @@ #include <qcocoahelpers.h> -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> #include <Carbon/Carbon.h> #include <QtCore/QList> diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index 1a516f874b..d404438db6 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm @@ -31,7 +31,7 @@ ** ****************************************************************************/ -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> #include "qcocoamenubar.h" #include "qcocoawindow.h" diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm index 0f551bcd7d..968d1a2a4d 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm @@ -31,6 +31,8 @@ ** ****************************************************************************/ +#include <qpa/qplatformtheme.h> + #include "qcocoamenuitem.h" #include "qcocoamenu.h" @@ -318,7 +320,7 @@ NSMenuItem *QCocoaMenuItem::sync() if (accel.count() > 1) text += QLatin1String(" (") + accel.toString(QKeySequence::NativeText) + QLatin1String(")"); - QString finalString = qt_mac_removeMnemonics(text); + QString finalString = QPlatformTheme::removeMnemonics(text); bool useAttributedTitle = false; // Cocoa Font and title if (m_font.resolve()) { diff --git a/src/plugins/platforms/cocoa/qcocoamenuloader.h b/src/plugins/platforms/cocoa/qcocoamenuloader.h index bdc943f78a..a3eea8bc15 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuloader.h +++ b/src/plugins/platforms/cocoa/qcocoamenuloader.h @@ -45,7 +45,7 @@ // We mean it. // -#import <Cocoa/Cocoa.h> +#import <AppKit/AppKit.h> #include <QtCore/private/qcore_mac_p.h> @interface QT_MANGLE_NAMESPACE(QCocoaMenuLoader) : NSResponder diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm index 41ea1fa49c..d2d3a7d562 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm @@ -60,7 +60,7 @@ #include <QtPlatformHeaders/qcocoawindowfunctions.h> -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoaservices.mm b/src/plugins/platforms/cocoa/qcocoaservices.mm index 6f3f6c4e1d..75fc32f338 100644 --- a/src/plugins/platforms/cocoa/qcocoaservices.mm +++ b/src/plugins/platforms/cocoa/qcocoaservices.mm @@ -33,8 +33,6 @@ #include "qcocoaservices.h" -#include "qt_mac_p.h" - #include <AppKit/NSWorkspace.h> #include <Foundation/NSURL.h> @@ -47,7 +45,7 @@ bool QCocoaServices::openUrl(const QUrl &url) const QString scheme = url.scheme(); if (scheme.isEmpty()) return openDocument(url); - return [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:QCFString::toNSString(url.toString(QUrl::FullyEncoded))]]; + return [[NSWorkspace sharedWorkspace] openURL:url.toNSURL()]; } bool QCocoaServices::openDocument(const QUrl &url) @@ -55,7 +53,7 @@ bool QCocoaServices::openDocument(const QUrl &url) if (!url.isValid()) return false; - return [[NSWorkspace sharedWorkspace] openFile:QCFString::toNSString(url.toLocalFile())]; + return [[NSWorkspace sharedWorkspace] openFile:url.toLocalFile().toNSString()]; } QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index 4b73d0af08..51e96cac89 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -31,7 +31,7 @@ ** ****************************************************************************/ -#import <Cocoa/Cocoa.h> +#import <AppKit/AppKit.h> #include "qcocoatheme.h" #include "messages.h" @@ -55,6 +55,8 @@ #include <qpa/qplatformintegration.h> #include <qpa/qplatformnativeinterface.h> +#include <Carbon/Carbon.h> + QT_BEGIN_NAMESPACE const char *QCocoaTheme::name = "cocoa"; diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 05e6cf3c9e..e830be212a 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -34,7 +34,7 @@ #ifndef QCOCOAWINDOW_H #define QCOCOAWINDOW_H -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> #include <qpa/qplatformwindow.h> #include <QRect> diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 5a59a842c6..18abaddfd7 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -47,8 +47,7 @@ #include <qpa/qwindowsysteminterface.h> #include <qpa/qplatformscreen.h> -#include <Cocoa/Cocoa.h> -#include <Carbon/Carbon.h> +#include <AppKit/AppKit.h> #include <QDebug> @@ -685,7 +684,16 @@ void QCocoaWindow::setVisible(bool visible) cocoaEventDispatcherPrivate->beginModalSession(window()); m_hasModalSession = true; } else if ([m_nsWindow canBecomeKeyWindow]) { - [m_nsWindow makeKeyAndOrderFront:nil]; + QCocoaEventDispatcher *cocoaEventDispatcher = qobject_cast<QCocoaEventDispatcher *>(QGuiApplication::instance()->eventDispatcher()); + QCocoaEventDispatcherPrivate *cocoaEventDispatcherPrivate = 0; + if (cocoaEventDispatcher) + cocoaEventDispatcherPrivate = static_cast<QCocoaEventDispatcherPrivate *>(QObjectPrivate::get(cocoaEventDispatcher)); + + if (!(cocoaEventDispatcherPrivate && cocoaEventDispatcherPrivate->currentModalSession())) + [m_nsWindow makeKeyAndOrderFront:nil]; + else + [m_nsWindow orderFront:nil]; + foreach (QCocoaWindow *childWindow, m_childWindows) childWindow->show(true); } else { @@ -1341,6 +1349,9 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow) } } else { // Child windows have no NSWindow, link the NSViews instead. + if ([m_contentView superview]) + [m_contentView removeFromSuperview]; + [m_parentCocoaWindow->m_contentView addSubview : m_contentView]; QRect rect = windowGeometry(); // Prevent setting a (0,0) window size; causes opengl context diff --git a/src/plugins/platforms/cocoa/qmacclipboard.h b/src/plugins/platforms/cocoa/qmacclipboard.h index 0d1f195f48..8b290866c6 100644 --- a/src/plugins/platforms/cocoa/qmacclipboard.h +++ b/src/plugins/platforms/cocoa/qmacclipboard.h @@ -39,7 +39,7 @@ #undef slots -#import <Cocoa/Cocoa.h> +#import <AppKit/AppKit.h> QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qmacdefines_mac.h b/src/plugins/platforms/cocoa/qmacdefines_mac.h index b2773a2b9f..fd540e7c34 100644 --- a/src/plugins/platforms/cocoa/qmacdefines_mac.h +++ b/src/plugins/platforms/cocoa/qmacdefines_mac.h @@ -92,7 +92,7 @@ typedef signed long OSStatus; # define old_slots slots # undef slots # endif -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> # ifdef old_slots # undef slots # define slots diff --git a/src/plugins/platforms/cocoa/qmultitouch_mac_p.h b/src/plugins/platforms/cocoa/qmultitouch_mac_p.h index e4eec41295..0af0505a47 100644 --- a/src/plugins/platforms/cocoa/qmultitouch_mac_p.h +++ b/src/plugins/platforms/cocoa/qmultitouch_mac_p.h @@ -47,7 +47,7 @@ #include <QtCore/qglobal.h> -#import <Cocoa/Cocoa.h> +#import <AppKit/AppKit.h> #include <qpa/qwindowsysteminterface.h> #include <qhash.h> diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index 50b456cab7..a3541829c6 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -34,7 +34,7 @@ #ifndef QNSVIEW_H #define QNSVIEW_H -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> #include <QtCore/QPointer> #include <QtGui/QImage> diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 3faa292ae0..528e6f120f 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -33,7 +33,6 @@ #include <QtCore/qglobal.h> -#include <Carbon/Carbon.h> #include <dlfcn.h> #include "qnsview.h" diff --git a/src/plugins/platforms/cocoa/qnsviewaccessibility.mm b/src/plugins/platforms/cocoa/qnsviewaccessibility.mm index 1f15da5b3b..d44b02549d 100644 --- a/src/plugins/platforms/cocoa/qnsviewaccessibility.mm +++ b/src/plugins/platforms/cocoa/qnsviewaccessibility.mm @@ -31,8 +31,6 @@ ** ****************************************************************************/ -#include <Carbon/Carbon.h> - #include "qnsview.h" #include "qcocoahelpers.h" #include "qcocoaaccessibility.h" diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.h b/src/plugins/platforms/cocoa/qnswindowdelegate.h index b8d344aa0e..794059bc68 100644 --- a/src/plugins/platforms/cocoa/qnswindowdelegate.h +++ b/src/plugins/platforms/cocoa/qnswindowdelegate.h @@ -34,7 +34,7 @@ #ifndef QNSWINDOWDELEGATE_H #define QNSWINDOWDELEGATE_H -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> #include "qcocoawindow.h" diff --git a/src/plugins/platforms/cocoa/qt_mac_p.h b/src/plugins/platforms/cocoa/qt_mac_p.h index 576e0f9729..9bfc0f7ba1 100644 --- a/src/plugins/platforms/cocoa/qt_mac_p.h +++ b/src/plugins/platforms/cocoa/qt_mac_p.h @@ -48,7 +48,7 @@ #include "qmacdefines_mac.h" #ifdef __OBJC__ -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> #include <objc/runtime.h> #endif @@ -63,30 +63,10 @@ #include "QtGui/qpainter.h" -#include <Carbon/Carbon.h> - QT_BEGIN_NAMESPACE class QWidget; class QDragMoveEvent; -/* Event masks */ -// internal Qt types - -enum { - //AE types - typeAEClipboardChanged = 1, - //types - typeQWidget = 1, /* QWidget * */ - //params - kEventParamQWidget = 'qwid', /* typeQWidget */ - //events - kEventQtRequestContext = 13, - kEventQtRequestMenubarUpdate = 14, - kEventQtRequestShowSheet = 17, - kEventQtRequestActivate = 18, - kEventQtRequestWindowChange = 20 -}; - // Simple class to manage short-lived regions class QMacSmartQuickDrawRegion { @@ -103,8 +83,6 @@ public: } }; -QString qt_mac_removeMnemonics(const QString &original); //implemented in qmacstyle_mac.cpp - class Q_WIDGETS_EXPORT QMacWindowChangeEvent { private: @@ -173,10 +151,6 @@ extern QPoint qt_mac_nativeMapFromParent(const QWidget *child, const QPoint &pt) # undef check #endif -QFont qfontForThemeFont(ThemeFontID themeID); - -QColor qcolorForThemeTextColor(ThemeTextColor themeColor); - struct QMacDndAnswerRecord { QRect rect; Qt::KeyboardModifiers modifiers; diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2ddevicecontext.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2ddevicecontext.cpp index 154023fb11..418c2e3745 100644 --- a/src/plugins/platforms/direct2d/qwindowsdirect2ddevicecontext.cpp +++ b/src/plugins/platforms/direct2d/qwindowsdirect2ddevicecontext.cpp @@ -51,7 +51,7 @@ public: HRESULT hr = QWindowsDirect2DContext::instance()->d2dDevice()->CreateDeviceContext( D2D1_DEVICE_CONTEXT_OPTIONS_NONE, &deviceContext); - if (FAILED(hr)) + if (Q_UNLIKELY(FAILED(hr))) qFatal("%s: Couldn't create Direct2D Device Context: %#x", __FUNCTION__, hr); } diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.cpp index d1814fb85d..789f2fa86f 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.cpp @@ -77,7 +77,7 @@ void QEglFSKmsIntegration::platformInit() qCDebug(qLcEglfsKmsDebug) << "Found the following video devices:" << devices; d->deleteLater(); - if (devices.isEmpty()) + if (Q_UNLIKELY(devices.isEmpty())) qFatal("Could not find DRM device!"); m_devicePath = devices.first(); @@ -85,7 +85,7 @@ void QEglFSKmsIntegration::platformInit() } m_device = new QEglFSKmsDevice(this, m_devicePath); - if (!m_device->open()) + if (Q_UNLIKELY(!m_device->open())) qFatal("Could not open device %s - aborting!", qPrintable(m_devicePath)); } diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp index 1ddcb3b862..b364056b91 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp @@ -52,20 +52,20 @@ QEglFSKmsEglDeviceIntegration::QEglFSKmsEglDeviceIntegration() void QEglFSKmsEglDeviceIntegration::platformInit() { - if (!query_egl_device()) + if (Q_UNLIKELY(!query_egl_device())) qFatal("Could not set up EGL device!"); const char *deviceName = m_funcs->query_device_string(m_egl_device, EGL_DRM_DEVICE_FILE_EXT); - if (!deviceName) + if (Q_UNLIKELY(!deviceName)) qFatal("Failed to query device name from EGLDevice"); qCDebug(qLcEglfsKmsDebug, "Opening %s", deviceName); m_dri_fd = drmOpen(deviceName, Q_NULLPTR); - if (m_dri_fd < 0) + if (Q_UNLIKELY(m_dri_fd < 0)) qFatal("Could not open DRM device"); - if (!setup_kms()) + if (Q_UNLIKELY(!setup_kms())) qFatal("Could not set up KMS on device %s!", m_device.constData()); qCDebug(qLcEglfsKmsDebug, "DRM/KMS initialized"); @@ -100,14 +100,14 @@ EGLDisplay QEglFSKmsEglDeviceIntegration::createDisplay(EGLNativeDisplayType nat display = eglGetDisplay(nativeDisplay); } - if (display == EGL_NO_DISPLAY) + if (Q_UNLIKELY(display == EGL_NO_DISPLAY)) qFatal("Could not get EGL display"); EGLint major, minor; - if (!eglInitialize(display, &major, &minor)) + if (Q_UNLIKELY(!eglInitialize(display, &major, &minor))) qFatal("Could not initialize egl display"); - if (!eglBindAPI(EGL_OPENGL_ES_API)) + if (Q_UNLIKELY(!eglBindAPI(EGL_OPENGL_ES_API))) qFatal("Failed to bind EGL_OPENGL_ES_API\n"); return display; @@ -255,8 +255,8 @@ QEglFSWindow *QEglFSKmsEglDeviceIntegration::createWindow(QWindow *window) const QEglJetsonTK1Window *eglWindow = new QEglJetsonTK1Window(window, this); m_funcs->initialize(eglWindow->screen()->display()); - if (!(m_funcs->has_egl_output_base && m_funcs->has_egl_output_drm && m_funcs->has_egl_stream - && m_funcs->has_egl_stream_producer_eglsurface && m_funcs->has_egl_stream_consumer_egloutput)) + if (Q_UNLIKELY(!(m_funcs->has_egl_output_base && m_funcs->has_egl_output_drm && m_funcs->has_egl_stream && + m_funcs->has_egl_stream_producer_eglsurface && m_funcs->has_egl_stream_consumer_egloutput))) qFatal("Required extensions missing!"); return eglWindow; @@ -298,7 +298,7 @@ void QEglFSKmsEglDeviceIntegration::waitForVSync(QPlatformSurface *) const -1, 0, 0, &m_drm_connector->connector_id, 1, const_cast<const drmModeModeInfoPtr>(&m_drm_mode)); - if (ret) + if (Q_UNLIKELY(ret)) qFatal("drmModeSetCrtc failed"); } } @@ -367,7 +367,7 @@ bool QEglFSKmsEglDeviceIntegration::setup_kms() } } - if (crtc == 0) + if (Q_UNLIKELY(crtc == 0)) qFatal("No suitable CRTC available"); m_drm_connector = connector; @@ -387,7 +387,7 @@ bool QEglFSKmsEglDeviceIntegration::setup_kms() bool QEglFSKmsEglDeviceIntegration::query_egl_device() { m_funcs = new QEGLStreamConvenience; - if (!m_funcs->has_egl_device_base) + if (Q_UNLIKELY(!m_funcs->has_egl_device_base)) qFatal("EGL_EXT_device_base missing"); EGLint num_devices = 0; diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp index 4d29b96608..ef586622e2 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp @@ -172,7 +172,7 @@ void QEglFSX11Integration::sendConnectionEvent(xcb_atom_t a) void QEglFSX11Integration::platformInit() { m_display = XOpenDisplay(0); - if (!m_display) + if (Q_UNLIKELY(!m_display)) qFatal("Could not open display"); XSetEventQueueOwner(DISPLAY, XCBOwnsEventQueue); diff --git a/src/plugins/platforms/eglfs/qeglfscursor.cpp b/src/plugins/platforms/eglfs/qeglfscursor.cpp index eea130a754..bfb69d3e8f 100644 --- a/src/plugins/platforms/eglfs/qeglfscursor.cpp +++ b/src/plugins/platforms/eglfs/qeglfscursor.cpp @@ -38,6 +38,7 @@ #include <qpa/qwindowsysteminterface.h> #include <QtGui/QOpenGLContext> #include <QtGui/QOpenGLShaderProgram> +#include <QtCore/QFile> #include <QtCore/QJsonDocument> #include <QtCore/QJsonArray> #include <QtCore/QJsonObject> diff --git a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp index 064b9f6306..e55a17585e 100644 --- a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp +++ b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp @@ -155,7 +155,7 @@ void QEGLDeviceIntegration::platformInit() framebuffer = qt_safe_open(fbDev, O_RDONLY); - if (framebuffer == -1) { + if (Q_UNLIKELY(framebuffer == -1)) { qWarning("EGLFS: Failed to open %s", fbDev.constData()); qFatal("EGLFS: Can't continue without a display"); } diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp index 2086ce56e2..001dd76803 100644 --- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp +++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp @@ -118,11 +118,11 @@ void QEglFSIntegration::initialize() qt_egl_device_integration()->platformInit(); m_display = qt_egl_device_integration()->createDisplay(nativeDisplay()); - if (m_display == EGL_NO_DISPLAY) + if (Q_UNLIKELY(m_display == EGL_NO_DISPLAY)) qFatal("Could not open egl display"); EGLint major, minor; - if (!eglInitialize(m_display, &major, &minor)) + if (Q_UNLIKELY(!eglInitialize(m_display, &major, &minor))) qFatal("Could not initialize egl display"); m_inputContext = QPlatformInputContextFactory::create(); diff --git a/src/plugins/platforms/eglfs/qeglfswindow.cpp b/src/plugins/platforms/eglfs/qeglfswindow.cpp index 8301be8c17..b29981bc98 100644 --- a/src/plugins/platforms/eglfs/qeglfswindow.cpp +++ b/src/plugins/platforms/eglfs/qeglfswindow.cpp @@ -102,17 +102,15 @@ void QEglFSWindow::create() QEglFSScreen *screen = this->screen(); QOpenGLCompositor *compositor = QOpenGLCompositor::instance(); if (screen->primarySurface() != EGL_NO_SURFACE) { - if (isRaster() && compositor->targetWindow()) { - m_format = compositor->targetWindow()->format(); - return; - } - + if (Q_UNLIKELY(!isRaster() || !compositor->targetWindow())) { #if !defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK) - // We can have either a single OpenGL window or multiple raster windows. - // Other combinations cannot work. - qFatal("EGLFS: OpenGL windows cannot be mixed with others."); + // We can have either a single OpenGL window or multiple raster windows. + // Other combinations cannot work. + qFatal("EGLFS: OpenGL windows cannot be mixed with others."); #endif - + return; + } + m_format = compositor->targetWindow()->format(); return; } @@ -122,7 +120,7 @@ void QEglFSWindow::create() resetSurface(); - if (m_surface == EGL_NO_SURFACE) { + if (Q_UNLIKELY(m_surface == EGL_NO_SURFACE)) { EGLint error = eglGetError(); eglTerminate(screen->display()); qFatal("EGL Error : Could not create the egl surface: error = 0x%x\n", error); @@ -135,7 +133,7 @@ void QEglFSWindow::create() context->setShareContext(qt_gl_global_share_context()); context->setFormat(m_format); context->setScreen(window()->screen()); - if (!context->create()) + if (Q_UNLIKELY(!context->create())) qFatal("EGLFS: Failed to create compositing context"); compositor->setTarget(context, window()); } diff --git a/src/plugins/platforms/haiku/qhaikuwindow.cpp b/src/plugins/platforms/haiku/qhaikuwindow.cpp index 9622d12111..1576e7c04e 100644 --- a/src/plugins/platforms/haiku/qhaikuwindow.cpp +++ b/src/plugins/platforms/haiku/qhaikuwindow.cpp @@ -127,7 +127,7 @@ QHaikuWindow::QHaikuWindow(QWindow *window) m_window = haikuWindow; - if (!m_window) + if (Q_UNLIKELY(!m_window)) qFatal("QHaikuWindow: failed to create window"); setGeometry(rect); diff --git a/src/plugins/platforms/ios/ios.pro b/src/plugins/platforms/ios/ios.pro index bf7849b740..236234628d 100644 --- a/src/plugins/platforms/ios/ios.pro +++ b/src/plugins/platforms/ios/ios.pro @@ -30,7 +30,8 @@ OBJECTIVE_SOURCES = \ qiostextresponder.mm \ qiosmenu.mm \ qiosfileengineassetslibrary.mm \ - qiosfiledialog.mm + qiosfiledialog.mm \ + qiosmessagedialog.mm HEADERS = \ qiosintegration.h \ @@ -54,7 +55,8 @@ HEADERS = \ qiosmenu.h \ qiosfileenginefactory.h \ qiosfileengineassetslibrary.h \ - qiosfiledialog.h + qiosfiledialog.h \ + qiosmessagedialog.h OTHER_FILES = \ quiview_textinput.mm \ diff --git a/src/plugins/platforms/ios/qioseventdispatcher.mm b/src/plugins/platforms/ios/qioseventdispatcher.mm index 0e9f176487..e1c6071c38 100644 --- a/src/plugins/platforms/ios/qioseventdispatcher.mm +++ b/src/plugins/platforms/ios/qioseventdispatcher.mm @@ -129,7 +129,7 @@ namespace // Which we verify, just in case struct rlimit stackLimit = {0, 0}; - if (getrlimit(RLIMIT_STACK, &stackLimit) == 0 && stackSize > stackLimit.rlim_cur) + if (Q_UNLIKELY(getrlimit(RLIMIT_STACK, &stackLimit) == 0 && stackSize > stackLimit.rlim_cur)) qFatal("Unexpectedly exceeded stack limit"); return stackSize; @@ -250,7 +250,7 @@ static void __attribute__((noinline, noreturn)) user_main_trampoline() unsigned int bufferSize = [arg lengthOfBytesUsingEncoding:cStringEncoding] + 1; argv[i] = reinterpret_cast<char *>(malloc(bufferSize)); - if (![arg getCString:argv[i] maxLength:bufferSize encoding:cStringEncoding]) + if (Q_UNLIKELY(![arg getCString:argv[i] maxLength:bufferSize encoding:cStringEncoding])) qFatal("Could not convert argv[%d] to C string", i); } diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm index 0e3da8dce8..72c9286f86 100644 --- a/src/plugins/platforms/ios/qiosintegration.mm +++ b/src/plugins/platforms/ios/qiosintegration.mm @@ -70,7 +70,7 @@ QIOSIntegration::QIOSIntegration() , m_accessibility(0) , m_debugWindowManagement(false) { - if (![UIApplication sharedApplication]) { + if (Q_UNLIKELY(![UIApplication sharedApplication])) { qFatal("Error: You are creating QApplication before calling UIApplicationMain.\n" \ "If you are writing a native iOS application, and only want to use Qt for\n" \ "parts of the application, a good place to create QApplication is from within\n" \ diff --git a/src/plugins/platforms/ios/qiosmenu.h b/src/plugins/platforms/ios/qiosmenu.h index ec23b55507..3beb58b503 100644 --- a/src/plugins/platforms/ios/qiosmenu.h +++ b/src/plugins/platforms/ios/qiosmenu.h @@ -74,9 +74,6 @@ public: bool m_separator; QIOSMenu *m_menu; QKeySequence m_shortcut; - -private: - QString removeMnemonics(const QString &original); }; typedef QList<QIOSMenuItem *> QIOSMenuItemList; diff --git a/src/plugins/platforms/ios/qiosmenu.mm b/src/plugins/platforms/ios/qiosmenu.mm index 7aea3729fd..f68321fb3b 100644 --- a/src/plugins/platforms/ios/qiosmenu.mm +++ b/src/plugins/platforms/ios/qiosmenu.mm @@ -33,6 +33,7 @@ #include <qglobal.h> #include <qguiapplication.h> +#include <qpa/qplatformtheme.h> #include "qiosglobal.h" #include "qiosmenu.h" @@ -254,7 +255,7 @@ quintptr QIOSMenuItem::tag() const void QIOSMenuItem::setText(const QString &text) { - m_text = removeMnemonics(text); + m_text = QPlatformTheme::removeMnemonics(text); } void QIOSMenuItem::setMenu(QPlatformMenu *menu) @@ -287,41 +288,6 @@ void QIOSMenuItem::setEnabled(bool enabled) m_enabled = enabled; } -QString QIOSMenuItem::removeMnemonics(const QString &original) -{ - // Copied from qcocoahelpers - QString returnText(original.size(), 0); - int finalDest = 0; - int currPos = 0; - int l = original.length(); - while (l) { - if (original.at(currPos) == QLatin1Char('&') - && (l == 1 || original.at(currPos + 1) != QLatin1Char('&'))) { - ++currPos; - --l; - if (l == 0) - break; - } else if (original.at(currPos) == QLatin1Char('(') && l >= 4 && - original.at(currPos + 1) == QLatin1Char('&') && - original.at(currPos + 2) != QLatin1Char('&') && - original.at(currPos + 3) == QLatin1Char(')')) { - /* remove mnemonics its format is "\s*(&X)" */ - int n = 0; - while (finalDest > n && returnText.at(finalDest - n - 1).isSpace()) - ++n; - finalDest -= n; - currPos += 4; - l -= 4; - continue; - } - returnText[finalDest] = original.at(currPos); - ++currPos; - ++finalDest; - --l; - } - returnText.truncate(finalDest); - return returnText; -} QIOSMenu::QIOSMenu() : QPlatformMenu() diff --git a/src/plugins/platforms/qnx/qqnxvirtualkeyboardbps.h b/src/plugins/platforms/ios/qiosmessagedialog.h index a720c5d894..a9bd42324e 100644 --- a/src/plugins/platforms/qnx/qqnxvirtualkeyboardbps.h +++ b/src/plugins/platforms/ios/qiosmessagedialog.h @@ -1,6 +1,6 @@ -/*************************************************************************** +/**************************************************************************** ** -** Copyright (C) 2012 Research In Motion +** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the plugins of the Qt Toolkit. @@ -31,38 +31,35 @@ ** ****************************************************************************/ -#ifndef QQNXVIRTUALKEYBOARDBPS_H -#define QQNXVIRTUALKEYBOARDBPS_H +#ifndef QIOSMESSAGEDIALOG_H +#define QIOSMESSAGEDIALOG_H -#include "qqnxabstractvirtualkeyboard.h" -#include <bps/virtualkeyboard.h> - -struct bps_event_t; +#include <QtCore/qeventloop.h> +#include <qpa/qplatformdialoghelper.h> QT_BEGIN_NAMESPACE -class QQnxVirtualKeyboardBps : public QQnxAbstractVirtualKeyboard +Q_FORWARD_DECLARE_OBJC_CLASS(UIAlertController); +Q_FORWARD_DECLARE_OBJC_CLASS(UIAlertAction); + +class QIOSMessageDialog : public QPlatformMessageDialogHelper { - Q_OBJECT public: - explicit QQnxVirtualKeyboardBps(QObject *parent = 0); - - bool handleEvent(bps_event_t *event); + QIOSMessageDialog(); + ~QIOSMessageDialog(); - bool showKeyboard(); - bool hideKeyboard(); - -protected: - void applyKeyboardOptions(); + void exec() Q_DECL_OVERRIDE; + bool show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent) Q_DECL_OVERRIDE; + void hide() Q_DECL_OVERRIDE; private: - bool handleLocaleEvent(bps_event_t *event); - bool handleVirtualKeyboardEvent(bps_event_t *event); - - virtualkeyboard_layout_t keyboardLayout() const; - virtualkeyboard_enter_t enterKey() const; + QEventLoop m_eventLoop; + UIAlertController *m_alertController; + QString messageTextPlain(); + UIAlertAction *createAction(StandardButton button); }; QT_END_NAMESPACE -#endif // QQNXVIRTUALKEYBOARDBPS_H +#endif // QIOSMESSAGEDIALOG_H + diff --git a/src/plugins/platforms/ios/qiosmessagedialog.mm b/src/plugins/platforms/ios/qiosmessagedialog.mm new file mode 100644 index 0000000000..39f7d4b1cd --- /dev/null +++ b/src/plugins/platforms/ios/qiosmessagedialog.mm @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#import <UIKit/UIKit.h> + +#include <QtGui/qwindow.h> +#include <QtGui/private/qguiapplication_p.h> +#include <qpa/qplatformtheme.h> + +#include "qiosglobal.h" +#include "quiview.h" +#include "qiosmessagedialog.h" + +QIOSMessageDialog::QIOSMessageDialog() + : m_alertController(Q_NULLPTR) +{ +} + +QIOSMessageDialog::~QIOSMessageDialog() +{ + hide(); +} + +inline QString QIOSMessageDialog::messageTextPlain() +{ + // Concatenate text fragments, and remove HTML tags + const QSharedPointer<QMessageDialogOptions> &opt = options(); + const QString &lineShift = QStringLiteral("\n\n"); + const QString &informativeText = opt->informativeText(); + const QString &detailedText = opt->detailedText(); + + QString text = opt->text(); + if (!informativeText.isEmpty()) + text += lineShift + informativeText; + if (!detailedText.isEmpty()) + text += lineShift + detailedText; + + text.replace(QLatin1String("<p>"), QStringLiteral("\n"), Qt::CaseInsensitive); + text.remove(QRegularExpression(QStringLiteral("<[^>]*>"))); + + return text; +} + +inline UIAlertAction *QIOSMessageDialog::createAction(StandardButton button) +{ + const StandardButton labelButton = button == NoButton ? Ok : button; + const QString &standardLabel = QGuiApplicationPrivate::platformTheme()->standardButtonText(labelButton); + const QString &label = QPlatformTheme::removeMnemonics(standardLabel); + + UIAlertActionStyle style = UIAlertActionStyleDefault; + if (button == Cancel) + style = UIAlertActionStyleCancel; + else if (button == Discard) + style = UIAlertActionStyleDestructive; + + return [UIAlertAction actionWithTitle:label.toNSString() style:style handler:^(UIAlertAction *) { + hide(); + if (button == NoButton) + emit reject(); + else + emit clicked(button, buttonRole(button)); + }]; +} + +void QIOSMessageDialog::exec() +{ + m_eventLoop.exec(QEventLoop::DialogExec); +} + +bool QIOSMessageDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent) +{ + Q_UNUSED(windowFlags); + if (m_alertController // Ensure that the dialog is not showing already + || !options() // Some message dialogs don't have options (QErrorMessage) + || windowModality != Qt::ApplicationModal // We can only do app modal dialogs + || QSysInfo::MacintoshVersion < QSysInfo::MV_IOS_8_0) // API limitation + return false; + + m_alertController = [[UIAlertController + alertControllerWithTitle:options()->windowTitle().toNSString() + message:messageTextPlain().toNSString() + preferredStyle:UIAlertControllerStyleAlert] retain]; + + if (StandardButtons buttons = options()->standardButtons()) { + for (int i = FirstButton; i < LastButton; i<<=1) { + if (i & buttons) + [m_alertController addAction:createAction(StandardButton(i))]; + } + } else { + // We need at least one button to allow the user close the dialog + [m_alertController addAction:createAction(NoButton)]; + } + + UIWindow *window = parent ? reinterpret_cast<UIView *>(parent->winId()).window : [UIApplication sharedApplication].keyWindow; + [window.rootViewController presentViewController:m_alertController animated:YES completion:nil]; + return true; +} + +void QIOSMessageDialog::hide() +{ + m_eventLoop.exit(); + [m_alertController dismissViewControllerAnimated:YES completion:nil]; + [m_alertController release]; + m_alertController = Q_NULLPTR; +} diff --git a/src/plugins/platforms/ios/qiostheme.mm b/src/plugins/platforms/ios/qiostheme.mm index bc40069670..dccacb2c0e 100644 --- a/src/plugins/platforms/ios/qiostheme.mm +++ b/src/plugins/platforms/ios/qiostheme.mm @@ -47,6 +47,7 @@ #include "qiosmenu.h" #include "qiosfiledialog.h" +#include "qiosmessagedialog.h" QT_BEGIN_NAMESPACE @@ -85,6 +86,7 @@ bool QIOSTheme::usePlatformNativeDialog(QPlatformTheme::DialogType type) const { switch (type) { case FileDialog: + case MessageDialog: return true; default: return false; @@ -97,6 +99,9 @@ QPlatformDialogHelper *QIOSTheme::createPlatformDialogHelper(QPlatformTheme::Dia case FileDialog: return new QIOSFileDialog(); break; + case MessageDialog: + return new QIOSMessageDialog(); + break; default: return 0; } diff --git a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp index 91708c0a47..45f66db75d 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp +++ b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp @@ -34,6 +34,7 @@ #include "qlinuxfbscreen.h" #include <QtPlatformSupport/private/qfbcursor_p.h> #include <QtPlatformSupport/private/qfbwindow_p.h> +#include <QtCore/QFile> #include <QtCore/QRegularExpression> #include <QtGui/QPainter> diff --git a/src/plugins/platforms/minimalegl/qminimaleglscreen.cpp b/src/plugins/platforms/minimalegl/qminimaleglscreen.cpp index 59062338cb..093a1c689c 100644 --- a/src/plugins/platforms/minimalegl/qminimaleglscreen.cpp +++ b/src/plugins/platforms/minimalegl/qminimaleglscreen.cpp @@ -74,19 +74,19 @@ QMinimalEglScreen::QMinimalEglScreen(EGLNativeDisplayType display) EGLint major, minor; - if (!eglBindAPI(EGL_OPENGL_ES_API)) { + if (Q_UNLIKELY(!eglBindAPI(EGL_OPENGL_ES_API))) { qWarning("Could not bind GL_ES API\n"); qFatal("EGL error"); } m_dpy = eglGetDisplay(display); - if (m_dpy == EGL_NO_DISPLAY) { + if (Q_UNLIKELY(m_dpy == EGL_NO_DISPLAY)) { qWarning("Could not open egl display\n"); qFatal("EGL error"); } qWarning("Opened display %p\n", m_dpy); - if (!eglInitialize(m_dpy, &major, &minor)) { + if (Q_UNLIKELY(!eglInitialize(m_dpy, &major, &minor))) { qWarning("Could not initialize egl display\n"); qFatal("EGL error"); } @@ -135,9 +135,9 @@ void QMinimalEglScreen::createAndSetPlatformContext() EGLNativeWindowType eglWindow = 0; #ifdef Q_OPENKODE - if (kdInitializeNV() == KD_ENOTINITIALIZED) { + if (Q_UNLIKELY(kdInitializeNV() == KD_ENOTINITIALIZED)) qFatal("Did not manage to initialize openkode"); - } + KDWindow *window = kdCreateWindow(m_dpy,config,0); kdRealizeWindow(window,&eglWindow); @@ -148,7 +148,7 @@ void QMinimalEglScreen::createAndSetPlatformContext() #endif m_surface = eglCreateWindowSurface(m_dpy, config, eglWindow, NULL); - if (m_surface == EGL_NO_SURFACE) { + if (Q_UNLIKELY(m_surface == EGL_NO_SURFACE)) { qWarning("Could not create the egl surface: error = 0x%x\n", eglGetError()); eglTerminate(m_dpy); qFatal("EGL error"); diff --git a/src/plugins/platforms/mirclient/qmirclientclipboard.cpp b/src/plugins/platforms/mirclient/qmirclientclipboard.cpp index aa2ddf2103..4494847b54 100644 --- a/src/plugins/platforms/mirclient/qmirclientclipboard.cpp +++ b/src/plugins/platforms/mirclient/qmirclientclipboard.cpp @@ -100,7 +100,7 @@ void QMirClientClipboard::onDBusClipboardGetContentsFinished(QDBusPendingCallWat Q_ASSERT(call == mPendingGetContentsCall.data()); QDBusPendingReply<QByteArray> reply = *call; - if (reply.isError()) { + if (Q_UNLIKELY(reply.isError())) { qCritical("QMirClientClipboard - Failed to get system clipboard contents via D-Bus. %s, %s", qPrintable(reply.error().name()), qPrintable(reply.error().message())); // TODO: Might try again later a number of times... @@ -114,7 +114,7 @@ void QMirClientClipboard::onDBusClipboardGetContentsFinished(QDBusPendingCallWat void QMirClientClipboard::onDBusClipboardSetContentsFinished(QDBusPendingCallWatcher *call) { QDBusPendingReply<void> reply = *call; - if (reply.isError()) { + if (Q_UNLIKELY(reply.isError())) { qCritical("QMirClientClipboard - Failed to set the system clipboard contents via D-Bus. %s, %s", qPrintable(reply.error().name()), qPrintable(reply.error().message())); // TODO: Might try again later a number of times... @@ -148,9 +148,8 @@ void QMirClientClipboard::setupDBus() "com.canonical.QtMir.Clipboard", "ContentsChanged", this, SLOT(updateMimeData(QByteArray))); - if (!ok) { + if (Q_UNLIKELY(!ok)) qCritical("QMirClientClipboard - Failed to connect to ContentsChanged signal form the D-Bus system clipboard."); - } mDBusClipboard = new QDBusInterface("com.canonical.QtMir", "/com/canonical/QtMir/Clipboard", diff --git a/src/plugins/platforms/mirclient/qmirclientglcontext.cpp b/src/plugins/platforms/mirclient/qmirclientglcontext.cpp index bfba5051e5..bbd7f5ee75 100644 --- a/src/plugins/platforms/mirclient/qmirclientglcontext.cpp +++ b/src/plugins/platforms/mirclient/qmirclientglcontext.cpp @@ -39,6 +39,7 @@ #include "qmirclientwindow.h" #include "qmirclientlogging.h" #include <QtPlatformSupport/private/qeglconvenience_p.h> +#include <QtGui/private/qopenglcontext_p.h> #if !defined(QT_NO_DEBUG) static void printOpenGLESConfig() { @@ -103,6 +104,15 @@ bool QMirClientOpenGLContext::makeCurrent(QPlatformSurface* surface) ASSERT(eglMakeCurrent(mEglDisplay, eglSurface, eglSurface, mEglContext) == EGL_TRUE); printOpenGLESConfig(); #endif + + // When running on the emulator, shaders will be compiled using a thin wrapper around the desktop drivers. + // These wrappers might not support the precision qualifiers, so set the workaround flag to true. + const char *rendererString = reinterpret_cast<const char *>(glGetString(GL_RENDERER)); + if (rendererString != 0 && qstrncmp(rendererString, "Android Emulator", 16) == 0) { + QOpenGLContextPrivate *ctx_d = QOpenGLContextPrivate::get(context()); + ctx_d->workaround_missingPrecisionQualifiers = true; + } + return true; } diff --git a/src/plugins/platforms/mirclient/qmirclientintegration.cpp b/src/plugins/platforms/mirclient/qmirclientintegration.cpp index a234f4eac6..87d2002c56 100644 --- a/src/plugins/platforms/mirclient/qmirclientintegration.cpp +++ b/src/plugins/platforms/mirclient/qmirclientintegration.cpp @@ -95,7 +95,7 @@ QMirClientClientIntegration::QMirClientClientIntegration() // Create new application instance mInstance = u_application_instance_new_from_description_with_options(mDesc, mOptions); - if (mInstance == nullptr) + if (Q_UNLIKELY(!mInstance)) qFatal("QMirClientClientIntegration: connection to Mir server failed. Check that a Mir server is\n" "running, and the correct socket is being used and is accessible. The shell may have\n" "rejected the incoming connection, so check its log file"); diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp index eb704f2dfa..dfaaa43c1d 100644 --- a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp +++ b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp @@ -143,7 +143,7 @@ static Window createDummyWindow(QOffscreenX11Info *x11, XVisualInfo *visualInfo) static Window createDummyWindow(QOffscreenX11Info *x11, GLXFBConfig config) { XVisualInfo *visualInfo = glXGetVisualFromFBConfig(x11->display(), config); - if (!visualInfo) + if (Q_UNLIKELY(!visualInfo)) qFatal("Could not initialize GLX"); Window window = createDummyWindow(x11, visualInfo); XFree(visualInfo); @@ -177,7 +177,7 @@ QOffscreenX11GLXContext::QOffscreenX11GLXContext(QOffscreenX11Info *x11, QOpenGL d->window = createDummyWindow(x11, config); } else { XVisualInfo *visualInfo = qglx_findVisualInfo(x11->display(), 0, &d->format); - if (!visualInfo) + if (Q_UNLIKELY(!visualInfo)) qFatal("Could not initialize GLX"); d->context = glXCreateContext(x11->display(), visualInfo, d->shareContext, true); if (!d->context && d->shareContext) { diff --git a/src/plugins/platforms/openwfd/qopenwfdport.cpp b/src/plugins/platforms/openwfd/qopenwfdport.cpp index 8da1e9bd34..c1646fbdf9 100644 --- a/src/plugins/platforms/openwfd/qopenwfdport.cpp +++ b/src/plugins/platforms/openwfd/qopenwfdport.cpp @@ -96,9 +96,8 @@ void QOpenWFDPort::attach() mPhysicalSize = QSizeF(physicalWFDSize[0],physicalWFDSize[1]); WFDint numAvailablePipelines = wfdGetPortAttribi(mDevice->handle(),mPort,WFD_PORT_PIPELINE_ID_COUNT); - if (!numAvailablePipelines) { + if (Q_UNLIKELY(!numAvailablePipelines)) qFatal("Not possible to make screen that is not possible to create WFPort with no pipline"); - } WFDint pipeIds[numAvailablePipelines]; wfdGetPortAttribiv(mDevice->handle(),mPort,WFD_PORT_BINDABLE_PIPELINE_IDS,numAvailablePipelines,pipeIds); @@ -109,9 +108,9 @@ void QOpenWFDPort::attach() mDevice-> addToUsedPipelineSet(mPipelineId,this); mPipeline = wfdCreatePipeline(mDevice->handle(),mPipelineId,WFD_NONE); - if (mPipeline == WFD_INVALID_HANDLE) { + if (Q_UNLIKELY(mPipeline == WFD_INVALID_HANDLE)) qFatal("Failed to create pipeline for port %p", this); - } + break; } } diff --git a/src/plugins/platforms/qnx/qblackberrytheme.cpp b/src/plugins/platforms/qnx/qblackberrytheme.cpp deleted file mode 100644 index f75e8f3766..0000000000 --- a/src/plugins/platforms/qnx/qblackberrytheme.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qblackberrytheme.h" - -#include "qqnxfiledialoghelper.h" -#include "qqnxsystemsettings.h" -#include "qqnxintegration.h" - -QT_BEGIN_NAMESPACE - -QBlackberryTheme::QBlackberryTheme(const QQnxIntegration *integration) : m_integration(integration) -{ - // Set the dark theme as default palette - QColor color = QColor(211, 211, 211); - m_defaultPalette.setBrush(QPalette::ButtonText, color); - m_defaultPalette.setBrush(QPalette::WindowText, color); - m_defaultPalette.setBrush(QPalette::Text, color); - - color.setAlpha(179); - m_defaultPalette.setBrush(QPalette::Disabled, QPalette::ButtonText, color); - m_defaultPalette.setBrush(QPalette::Disabled, QPalette::WindowText, color); - m_defaultPalette.setBrush(QPalette::Disabled, QPalette::Text, color); - - color.setRgb(18, 18, 18); - m_defaultPalette.setColor(QPalette::Window, color); - m_defaultPalette.setColor(QPalette::Base, color); - m_defaultPalette.setColor(QPalette::AlternateBase, QColor(50, 50, 50)); - m_defaultPalette.setColor(QPalette::Button, color); - - m_defaultPalette.setBrush(QPalette::Highlight, QColor(0, 168, 223)); - m_defaultPalette.setBrush(QPalette::HighlightedText, QColor(250, 250,250)); -} - -QBlackberryTheme::~QBlackberryTheme() -{ - qDeleteAll(m_fonts); -} - -bool QBlackberryTheme::usePlatformNativeDialog(DialogType type) const -{ - if (type == QPlatformTheme::FileDialog) - return true; -#if !defined(QT_NO_COLORDIALOG) - if (type == QPlatformTheme::ColorDialog) - return false; -#endif -#if !defined(QT_NO_FONTDIALOG) - if (type == QPlatformTheme::FontDialog) - return false; -#endif - return false; -} - -QPlatformDialogHelper *QBlackberryTheme::createPlatformDialogHelper(DialogType type) const -{ - switch (type) { - case QPlatformTheme::FileDialog: - return new QQnxFileDialogHelper(m_integration); -#if !defined(QT_NO_COLORDIALOG) - case QPlatformTheme::ColorDialog: -#endif -#if !defined(QT_NO_FONTDIALOG) - case QPlatformTheme::FontDialog: -#endif - default: - return 0; - } -} - -const QFont *QBlackberryTheme::font(Font type) const -{ - QPlatformFontDatabase *fontDatabase = m_integration->fontDatabase(); - - if (fontDatabase && m_fonts.isEmpty()) - m_fonts = qt_qnx_createRoleFonts(fontDatabase); - return m_fonts.value(type, 0); -} - -const QPalette *QBlackberryTheme::palette(Palette type) const -{ - // Return the default palette - if (type == SystemPalette) - return &m_defaultPalette; - - return QPlatformTheme::palette(type); -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qblackberrytheme.h b/src/plugins/platforms/qnx/qblackberrytheme.h deleted file mode 100644 index bcef4e5ef4..0000000000 --- a/src/plugins/platforms/qnx/qblackberrytheme.h +++ /dev/null @@ -1,73 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QBLACKBERRYTHEME_H -#define QBLACKBERRYTHEME_H - -#include <qpa/qplatformtheme.h> - -#include <QtGui/qfont.h> - -#include <QtCore/qhash.h> -#include <QtCore/qstring.h> - -#include <QtGui/QPalette> - -QT_BEGIN_NAMESPACE - -class QQnxIntegration; - -class QBlackberryTheme : public QPlatformTheme -{ -public: - explicit QBlackberryTheme(const QQnxIntegration *); - ~QBlackberryTheme(); - - static QString name() { return QStringLiteral("blackberry"); } - - bool usePlatformNativeDialog(DialogType type) const; - QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const; - - const QFont *font(Font type = SystemFont) const; - - const QPalette *palette(Palette type = SystemPalette) const; - -private: - mutable QHash<QPlatformTheme::Font, QFont*> m_fonts; - const QQnxIntegration *m_integration; - QPalette m_defaultPalette; -}; - -QT_END_NAMESPACE - -#endif // QBLACKBERRYTHEME_H diff --git a/src/plugins/platforms/qnx/qnx.pro b/src/plugins/platforms/qnx/qnx.pro index 95a8e44cb8..5a0f4f5c98 100644 --- a/src/plugins/platforms/qnx/qnx.pro +++ b/src/plugins/platforms/qnx/qnx.pro @@ -5,10 +5,9 @@ QT += platformsupport-private core-private gui-private # Uncomment this to build with support for IMF once it becomes available in the BBNDK #CONFIG += qqnx_imf -!blackberry:CONFIG += qqnx_screeneventthread +CONFIG += qqnx_screeneventthread # Uncomment these to enable debugging output for various aspects of the plugin -#DEFINES += QQNXBPSEVENTFILTER_DEBUG #DEFINES += QQNXBUFFER_DEBUG #DEFINES += QQNXBUTTON_DEBUG #DEFINES += QQNXCLIPBOARD_DEBUG @@ -86,52 +85,20 @@ contains(QT_CONFIG, opengles2) { LIBS += -lEGL } -CONFIG(blackberry) { - SOURCES += qqnxnavigatorbps.cpp \ - qqnxeventdispatcher_blackberry.cpp \ - qqnxbpseventfilter.cpp \ - qqnxvirtualkeyboardbps.cpp \ - qblackberrytheme.cpp \ - qqnxsystemsettings.cpp - - HEADERS += qqnxnavigatorbps.h \ - qqnxeventdispatcher_blackberry.h \ - qqnxbpseventfilter.h \ - qqnxvirtualkeyboardbps.h \ - qblackberrytheme.h \ - qqnxsystemsettings.h \ - qqnxfiledialoghelper.h - - LIBS += -lbps -} - -CONFIG(blackberry) { - SOURCES += qqnxfiledialoghelper_bb10.cpp \ - qqnxfilepicker.cpp \ - qqnxnavigatorcover.cpp - - HEADERS += qqnxfilepicker.h \ - qqnxnavigatorcover.h -} - CONFIG(qqnx_pps) { DEFINES += QQNX_PPS SOURCES += qqnxclipboard.cpp \ - qqnxbuttoneventnotifier.cpp + qqnxbuttoneventnotifier.cpp \ + qqnxnavigatorpps.cpp \ + qqnxnavigatoreventnotifier.cpp \ + qqnxvirtualkeyboardpps.cpp HEADERS += qqnxclipboard.h \ - qqnxbuttoneventnotifier.h - - !blackberry { - SOURCES += qqnxnavigatorpps.cpp \ - qqnxnavigatoreventnotifier.cpp \ - qqnxvirtualkeyboardpps.cpp - - HEADERS += qqnxnavigatorpps.h \ - qqnxnavigatoreventnotifier.h \ - qqnxvirtualkeyboardpps.h - } + qqnxbuttoneventnotifier.h \ + qqnxnavigatorpps.h \ + qqnxnavigatoreventnotifier.h \ + qqnxvirtualkeyboardpps.h LIBS += -lpps !contains(DEFINES, QT_NO_CLIPBOARD): LIBS += -lclipboard diff --git a/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp b/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp deleted file mode 100644 index 66843283b6..0000000000 --- a/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qqnxbpseventfilter.h" -#include "qqnxnavigatoreventhandler.h" -#include "qqnxscreen.h" -#include "qqnxscreeneventhandler.h" -#include "qqnxvirtualkeyboardbps.h" -#include "qqnxfiledialoghelper.h" - -#include <QCoreApplication> -#include <QAbstractEventDispatcher> -#include <QDebug> - -#include <bps/event.h> -#include <bps/navigator.h> -#include <bps/screen.h> - -#if defined(QQNXBPSEVENTFILTER_DEBUG) -#define qBpsEventFilterDebug qDebug -#else -#define qBpsEventFilterDebug QT_NO_QDEBUG_MACRO -#endif - -QT_BEGIN_NAMESPACE - -static QQnxBpsEventFilter *s_instance = 0; - -QQnxBpsEventFilter::QQnxBpsEventFilter(QQnxNavigatorEventHandler *navigatorEventHandler, - QQnxScreenEventHandler *screenEventHandler, - QQnxVirtualKeyboardBps *virtualKeyboard, QObject *parent) - : QObject(parent) - , m_navigatorEventHandler(navigatorEventHandler) - , m_screenEventHandler(screenEventHandler) - , m_virtualKeyboard(virtualKeyboard) -{ - Q_ASSERT(s_instance == 0); - - s_instance = this; -} - -QQnxBpsEventFilter::~QQnxBpsEventFilter() -{ - Q_ASSERT(s_instance == this); - - s_instance = 0; -} - -void QQnxBpsEventFilter::installOnEventDispatcher(QAbstractEventDispatcher *dispatcher) -{ - qBpsEventFilterDebug() << "dispatcher=" << dispatcher; - - if (navigator_request_events(NAVIGATOR_EXTENDED_DATA) != BPS_SUCCESS) - qWarning("QQNX: failed to register for navigator events"); - - dispatcher->installNativeEventFilter(this); -} - -void QQnxBpsEventFilter::registerForScreenEvents(QQnxScreen *screen) -{ - if (!m_screenEventHandler) { - qWarning("QQNX: trying to register for screen events, but no handler provided."); - return; - } - - int attached; - if (screen_get_display_property_iv(screen->nativeDisplay(), SCREEN_PROPERTY_ATTACHED, &attached) != BPS_SUCCESS) { - qWarning() << "QQNX: unable to query display attachment"; - return; - } - - if (!attached) { - qBpsEventFilterDebug() << "skipping event registration for non-attached screen"; - return; - } - - if (screen_request_events(screen->nativeContext()) != BPS_SUCCESS) - qWarning("QQNX: failed to register for screen events on screen %p", screen->nativeContext()); -} - -void QQnxBpsEventFilter::unregisterForScreenEvents(QQnxScreen *screen) -{ - if (!m_screenEventHandler) { - qWarning("QQNX: trying to unregister for screen events, but no handler provided."); - return; - } - - if (screen_stop_events(screen->nativeContext()) != BPS_SUCCESS) - qWarning("QQNX: failed to unregister for screen events on screen %p", screen->nativeContext()); -} - -bool QQnxBpsEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, long *result) -{ - Q_UNUSED(eventType); - Q_UNUSED(result); - bps_event_t *event = static_cast<bps_event_t *>(message); - const int eventDomain = bps_event_get_domain(event); - qBpsEventFilterDebug() << "event=" << event << "domain=" << eventDomain; - - if (eventDomain == screen_get_domain()) { - if (!m_screenEventHandler) { - qWarning("QQNX: registered for screen events, but no handler provided."); - return false; - } - - screen_event_t screenEvent = screen_event_get_event(event); - return m_screenEventHandler->handleEvent(screenEvent); - } - - if (eventDomain == navigator_get_domain()) - return handleNavigatorEvent(event); - - if (m_virtualKeyboard->handleEvent(event)) - return true; - - return false; -} - -bool QQnxBpsEventFilter::handleNavigatorEvent(bps_event_t *event) -{ - switch (bps_event_get_code(event)) { - case NAVIGATOR_ORIENTATION_CHECK: { - const int angle = navigator_event_get_orientation_angle(event); - qBpsEventFilterDebug() << "ORIENTATION CHECK event. angle=" << angle; - - const bool result = m_navigatorEventHandler->handleOrientationCheck(angle); - qBpsEventFilterDebug() << "ORIENTATION CHECK event. result=" << result; - - // reply to navigator whether orientation is acceptable - navigator_orientation_check_response(event, result); - break; - } - - case NAVIGATOR_ORIENTATION: { - const int angle = navigator_event_get_orientation_angle(event); - qBpsEventFilterDebug() << "ORIENTATION event. angle=" << angle; - m_navigatorEventHandler->handleOrientationChange(angle); - - navigator_done_orientation(event); - break; - } - - case NAVIGATOR_SWIPE_DOWN: - qBpsEventFilterDebug("SWIPE DOWN event"); - m_navigatorEventHandler->handleSwipeDown(); - break; - - case NAVIGATOR_EXIT: - qBpsEventFilterDebug("EXIT event"); - m_navigatorEventHandler->handleExit(); - break; - - case NAVIGATOR_WINDOW_STATE: { - qBpsEventFilterDebug("WINDOW STATE event"); - const navigator_window_state_t state = navigator_event_get_window_state(event); - const QByteArray id(navigator_event_get_groupid(event)); - - switch (state) { - case NAVIGATOR_WINDOW_FULLSCREEN: - m_navigatorEventHandler->handleWindowGroupStateChanged(id, Qt::WindowFullScreen); - break; - case NAVIGATOR_WINDOW_THUMBNAIL: - m_navigatorEventHandler->handleWindowGroupStateChanged(id, Qt::WindowMinimized); - break; - case NAVIGATOR_WINDOW_INVISIBLE: - break; - } - - break; - } - - case NAVIGATOR_WINDOW_ACTIVE: { - qBpsEventFilterDebug("WINDOW ACTIVE event"); - const QByteArray id(navigator_event_get_groupid(event)); - m_navigatorEventHandler->handleWindowGroupActivated(id); - break; - } - - case NAVIGATOR_WINDOW_INACTIVE: { - qBpsEventFilterDebug("WINDOW INACTIVE event"); - const QByteArray id(navigator_event_get_groupid(event)); - m_navigatorEventHandler->handleWindowGroupDeactivated(id); - break; - } - - case NAVIGATOR_LOW_MEMORY: - qWarning() << "QGuiApplication based process" << QCoreApplication::applicationPid() - << "received \"NAVIGATOR_LOW_MEMORY\" event"; - return false; - - default: - qBpsEventFilterDebug() << "Unhandled navigator event. code=" << bps_event_get_code(event); - return false; - } - - return true; -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxbpseventfilter.h b/src/plugins/platforms/qnx/qqnxbpseventfilter.h deleted file mode 100644 index f1d67848e8..0000000000 --- a/src/plugins/platforms/qnx/qqnxbpseventfilter.h +++ /dev/null @@ -1,82 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQNXBPSEVENTFILTER_H -#define QQNXBPSEVENTFILTER_H - -#include <QObject> -#include <QHash> -#include <QAbstractNativeEventFilter> - -#include <bps/dialog.h> - -struct bps_event_t; - -QT_BEGIN_NAMESPACE - -class QAbstractEventDispatcher; -class QQnxNavigatorEventHandler; -class QQnxFileDialogHelper; -class QQnxScreen; -class QQnxScreenEventHandler; -class QQnxVirtualKeyboardBps; - -class QQnxBpsEventFilter : public QObject, public QAbstractNativeEventFilter -{ - Q_OBJECT -public: - QQnxBpsEventFilter(QQnxNavigatorEventHandler *navigatorEventHandler, - QQnxScreenEventHandler *screenEventHandler, - QQnxVirtualKeyboardBps *virtualKeyboard, QObject *parent = 0); - ~QQnxBpsEventFilter(); - - void installOnEventDispatcher(QAbstractEventDispatcher *dispatcher); - - void registerForScreenEvents(QQnxScreen *screen); - void unregisterForScreenEvents(QQnxScreen *screen); - -private: - bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE; - - bool handleNavigatorEvent(bps_event_t *event); - -private: - QQnxNavigatorEventHandler *m_navigatorEventHandler; - QQnxScreenEventHandler *m_screenEventHandler; - QQnxVirtualKeyboardBps *m_virtualKeyboard; - QHash<dialog_instance_t, QQnxFileDialogHelper*> m_dialogMapper; -}; - -QT_END_NAMESPACE - -#endif // QQNXBPSEVENTFILTER_H diff --git a/src/plugins/platforms/qnx/qqnxbuffer.cpp b/src/plugins/platforms/qnx/qqnxbuffer.cpp index 7ee6664676..5d838ac189 100644 --- a/src/plugins/platforms/qnx/qqnxbuffer.cpp +++ b/src/plugins/platforms/qnx/qqnxbuffer.cpp @@ -76,7 +76,7 @@ QQnxBuffer::QQnxBuffer(screen_buffer_t buffer) screen_get_buffer_property_pv(buffer, SCREEN_PROPERTY_POINTER, (void **)&dataPtr), "Failed to query buffer pointer"); - if (dataPtr == 0) + if (Q_UNLIKELY(!dataPtr)) qFatal("QQNX: buffer pointer is NULL, errno=%d", errno); // Get format of buffer @@ -131,13 +131,13 @@ void QQnxBuffer::invalidateInCache() qBufferDebug(); // Verify native buffer exists - if (m_buffer == 0) + if (Q_UNLIKELY(!m_buffer)) qFatal("QQNX: can't invalidate cache for null buffer"); // Evict buffer's data from cache errno = 0; int result = msync(m_image.bits(), m_image.height() * m_image.bytesPerLine(), MS_INVALIDATE | MS_CACHE_ONLY); - if (result != 0) + if (Q_UNLIKELY(result != 0)) qFatal("QQNX: failed to invalidate cache, errno=%d", errno); } diff --git a/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp b/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp index 614bfc381f..ec30e79ab5 100644 --- a/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp +++ b/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp @@ -82,7 +82,7 @@ void QQnxButtonEventNotifier::start() errno = 0; m_fd = qt_safe_open(ppsPath, O_RDONLY); if (m_fd == -1) { -#if defined(Q_OS_BLACKBERRY) || defined (QQNXBUTTON_DEBUG) +#if defined (QQNXBUTTON_DEBUG) qWarning("QQNX: failed to open buttons pps, errno=%d", errno); #endif return; diff --git a/src/plugins/platforms/qnx/qqnxeglwindow.cpp b/src/plugins/platforms/qnx/qqnxeglwindow.cpp index 00eaf2bf03..5f80b39fe6 100644 --- a/src/plugins/platforms/qnx/qqnxeglwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxeglwindow.cpp @@ -59,7 +59,7 @@ QQnxEglWindow::QQnxEglWindow(QWindow *window, screen_context_t context, bool nee // Set window usage const int val = SCREEN_USAGE_OPENGL_ES2; const int result = screen_set_window_property_iv(nativeHandle(), SCREEN_PROPERTY_USAGE, &val); - if (result != 0) + if (Q_UNLIKELY(result != 0)) qFatal("QQnxEglWindow: failed to set window alpha usage, errno=%d", errno); m_requestedBufferSize = shouldMakeFullScreen() ? screen()->geometry().size() : window->geometry().size(); @@ -106,7 +106,7 @@ void QQnxEglWindow::destroyEGLSurface() // Destroy EGL surface if it exists if (m_eglSurface != EGL_NO_SURFACE) { EGLBoolean eglResult = eglDestroySurface(platformOpenGLContext()->getEglDisplay(), m_eglSurface); - if (eglResult != EGL_TRUE) + if (Q_UNLIKELY(eglResult != EGL_TRUE)) qFatal("QQNX: failed to destroy EGL surface, err=%d", eglGetError()); } @@ -118,12 +118,12 @@ void QQnxEglWindow::swapEGLBuffers() qEglWindowDebug(); // Set current rendering API EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API); - if (eglResult != EGL_TRUE) + if (Q_UNLIKELY(eglResult != EGL_TRUE)) qFatal("QQNX: failed to set EGL API, err=%d", eglGetError()); // Post EGL surface to window eglResult = eglSwapBuffers(m_platformOpenGLContext->getEglDisplay(), m_eglSurface); - if (eglResult != EGL_TRUE) + if (Q_UNLIKELY(eglResult != EGL_TRUE)) qFatal("QQNX: failed to swap EGL buffers, err=%d", eglGetError()); windowPosted(); @@ -178,15 +178,15 @@ int QQnxEglWindow::pixelFormat() const const QSurfaceFormat format = m_platformOpenGLContext->format(); // Extract size of color channels from window format const int redSize = format.redBufferSize(); - if (redSize == -1) + if (Q_UNLIKELY(redSize == -1)) qFatal("QQnxWindow: red size not defined"); const int greenSize = format.greenBufferSize(); - if (greenSize == -1) + if (Q_UNLIKELY(greenSize == -1)) qFatal("QQnxWindow: green size not defined"); const int blueSize = format.blueBufferSize(); - if (blueSize == -1) + if (Q_UNLIKELY(blueSize == -1)) qFatal("QQnxWindow: blue size not defined"); // select matching native format diff --git a/src/plugins/platforms/qnx/qqnxeventdispatcher_blackberry.cpp b/src/plugins/platforms/qnx/qqnxeventdispatcher_blackberry.cpp deleted file mode 100644 index 30596fe08f..0000000000 --- a/src/plugins/platforms/qnx/qqnxeventdispatcher_blackberry.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qqnxeventdispatcher_blackberry.h" - -#include <qpa/qwindowsysteminterface.h> -#include <private/qguiapplication_p.h> - -QT_BEGIN_NAMESPACE - - -QQnxEventDispatcherBlackberry::QQnxEventDispatcherBlackberry(QObject *parent) - : QEventDispatcherBlackberry(parent) -{ -} - -QQnxEventDispatcherBlackberry::~QQnxEventDispatcherBlackberry() -{ -} - -bool QQnxEventDispatcherBlackberry::processEvents(QEventLoop::ProcessEventsFlags flags) -{ - const bool didSendEvents = QEventDispatcherBlackberry::processEvents(flags); - return QWindowSystemInterface::sendWindowSystemEvents(flags) || didSendEvents; -} - -bool QQnxEventDispatcherBlackberry::hasPendingEvents() -{ - return QEventDispatcherBlackberry::hasPendingEvents() || QWindowSystemInterface::windowSystemEventsQueued(); -} - -void QQnxEventDispatcherBlackberry::flush() -{ - if (qApp) - qApp->sendPostedEvents(); -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxeventdispatcher_blackberry.h b/src/plugins/platforms/qnx/qqnxeventdispatcher_blackberry.h deleted file mode 100644 index 036bf126ab..0000000000 --- a/src/plugins/platforms/qnx/qqnxeventdispatcher_blackberry.h +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQNXEVENTDISPATCHER_BLACKBERRY_H -#define QQNXEVENTDISPATCHER_BLACKBERRY_H - -#include <qglobal.h> -#include <private/qeventdispatcher_blackberry_p.h> - -QT_BEGIN_NAMESPACE - -class QQnxEventDispatcherBlackberry : public QEventDispatcherBlackberry -{ - Q_OBJECT - -public: - explicit QQnxEventDispatcherBlackberry(QObject *parent = 0); - ~QQnxEventDispatcherBlackberry(); - - bool processEvents(QEventLoop::ProcessEventsFlags flags); - bool hasPendingEvents(); - - void flush(); -}; - -QT_END_NAMESPACE - -#endif // QQNXEVENTDISPATCHER_BLACKBERRY_H diff --git a/src/plugins/platforms/qnx/qqnxfiledialoghelper.h b/src/plugins/platforms/qnx/qqnxfiledialoghelper.h deleted file mode 100644 index 76cceafcfe..0000000000 --- a/src/plugins/platforms/qnx/qqnxfiledialoghelper.h +++ /dev/null @@ -1,87 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQNXFILEDIALOGHELPER_H -#define QQNXFILEDIALOGHELPER_H - -#include <qpa/qplatformdialoghelper.h> - - -QT_BEGIN_NAMESPACE - -class QQnxIntegration; - -class QQnxFilePicker; - -class QQnxFileDialogHelper : public QPlatformFileDialogHelper -{ - Q_OBJECT -public: - explicit QQnxFileDialogHelper(const QQnxIntegration *); - ~QQnxFileDialogHelper(); - - void exec(); - - bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent); - void hide(); - - bool defaultNameFilterDisables() const; - void setDirectory(const QUrl &directory) Q_DECL_OVERRIDE; - QUrl directory() const Q_DECL_OVERRIDE; - void selectFile(const QUrl &fileName) Q_DECL_OVERRIDE; - QList<QUrl> selectedFiles() const Q_DECL_OVERRIDE; - void setFilter(); - void selectNameFilter(const QString &filter); - QString selectedNameFilter() const; - - QQnxFilePicker *nativeDialog() const { return m_dialog; } - -Q_SIGNALS: - void dialogClosed(); - -private Q_SLOTS: - void emitSignals(); - -private: - void setNameFilter(const QString &filter); - void setNameFilters(const QStringList &filters); - - const QQnxIntegration *m_integration; - QQnxFilePicker *m_dialog; - QFileDialogOptions::AcceptMode m_acceptMode; - QString m_selectedFilter; -}; - -QT_END_NAMESPACE - -#endif // QQNXFILEDIALOGHELPER_H diff --git a/src/plugins/platforms/qnx/qqnxfiledialoghelper_bb10.cpp b/src/plugins/platforms/qnx/qqnxfiledialoghelper_bb10.cpp deleted file mode 100644 index 3bc84686e0..0000000000 --- a/src/plugins/platforms/qnx/qqnxfiledialoghelper_bb10.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2013 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qqnxfiledialoghelper.h" - -#include "qqnxfilepicker.h" -#include "qqnxbpseventfilter.h" -#include "qqnxscreen.h" -#include "qqnxintegration.h" - -#include <QDebug> -#include <QEventLoop> -#include <QScreen> -#include <QTimer> -#include <QWindow> - -#ifdef QQNXFILEDIALOGHELPER_DEBUG -#define qFileDialogHelperDebug qDebug -#else -#define qFileDialogHelperDebug QT_NO_QDEBUG_MACRO -#endif - -QT_BEGIN_NAMESPACE - -QQnxFileDialogHelper::QQnxFileDialogHelper(const QQnxIntegration *integration) - : QPlatformFileDialogHelper(), - m_integration(integration), - m_dialog(new QQnxFilePicker), - m_acceptMode(QFileDialogOptions::AcceptOpen), - m_selectedFilter() -{ - connect(m_dialog, &QQnxFilePicker::closed, this, &QQnxFileDialogHelper::emitSignals); -} - -QQnxFileDialogHelper::~QQnxFileDialogHelper() -{ - delete m_dialog; -} - -void QQnxFileDialogHelper::exec() -{ - qFileDialogHelperDebug(); - - // Clear any previous results - m_dialog->setDirectories(QStringList()); - - QEventLoop loop; - connect(m_dialog, SIGNAL(closed()), &loop, SLOT(quit())); - loop.exec(); -} - -bool QQnxFileDialogHelper::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) -{ - Q_UNUSED(flags); - Q_UNUSED(parent); - Q_UNUSED(modality); - - qFileDialogHelperDebug(); - - // Create dialog - const QSharedPointer<QFileDialogOptions> &opts = options(); - if (opts->acceptMode() == QFileDialogOptions::AcceptOpen) { - // Select one or many files? - const QQnxFilePicker::Mode mode = (opts->fileMode() == QFileDialogOptions::ExistingFiles) - ? QQnxFilePicker::PickerMultiple : QQnxFilePicker::Picker; - - m_dialog->setMode(mode); - - // Set the actual list of extensions - if (!opts->nameFilters().isEmpty()) - setNameFilters(opts->nameFilters()); - else - setNameFilter(tr("All files (*.*)")); - } else { - const QQnxFilePicker::Mode mode = (opts->initiallySelectedFiles().count() >= 2) - ? QQnxFilePicker::SaverMultiple : QQnxFilePicker::Saver; - - m_dialog->setMode(mode); - - if (!opts->initiallySelectedFiles().isEmpty()) { - QStringList files; - Q_FOREACH ( const QUrl &url, opts->initiallySelectedFiles() ) - files.append(url.toLocalFile()); - m_dialog->setDefaultSaveFileNames(files); - } - } - - // Cache the accept mode so we know which functions to use to get the results back - m_acceptMode = opts->acceptMode(); - m_dialog->setTitle(opts->windowTitle()); - m_dialog->open(); - - return true; -} - -void QQnxFileDialogHelper::hide() -{ - qFileDialogHelperDebug(); - m_dialog->close(); -} - -bool QQnxFileDialogHelper::defaultNameFilterDisables() const -{ - qFileDialogHelperDebug(); - return false; -} - -void QQnxFileDialogHelper::setDirectory(const QUrl &directory) -{ - m_dialog->addDirectory(directory.toLocalFile()); -} - -QUrl QQnxFileDialogHelper::directory() const -{ - qFileDialogHelperDebug(); - if (!m_dialog->directories().isEmpty()) - return QUrl::fromLocalFile(m_dialog->directories().first()); - - return QUrl(); -} - -void QQnxFileDialogHelper::selectFile(const QUrl &fileName) -{ - m_dialog->addDefaultSaveFileName(fileName.toLocalFile()); -} - -QList<QUrl> QQnxFileDialogHelper::selectedFiles() const -{ - qFileDialogHelperDebug(); - QList<QUrl> urls; - QStringList files = m_dialog->selectedFiles(); - Q_FOREACH (const QString &file, files) - urls.append(QUrl::fromLocalFile(file)); - return urls; -} - -void QQnxFileDialogHelper::setFilter() -{ - // No native api to support setting a filter from QDir::Filters - qFileDialogHelperDebug(); -} - -void QQnxFileDialogHelper::selectNameFilter(const QString &filter) -{ - qFileDialogHelperDebug() << "filter =" << filter; - setNameFilter(filter); -} - -QString QQnxFileDialogHelper::selectedNameFilter() const -{ - // For now there is no way for the user to change the selected filter - // so this just reflects what the developer has set programmatically. - qFileDialogHelperDebug(); - return m_selectedFilter; -} - -void QQnxFileDialogHelper::emitSignals() -{ - if (m_dialog->selectedFiles().isEmpty()) - Q_EMIT reject(); - else - Q_EMIT accept(); -} - -void QQnxFileDialogHelper::setNameFilter(const QString &filter) -{ - qFileDialogHelperDebug() << "filter =" << filter; - - setNameFilters(QPlatformFileDialogHelper::cleanFilterList(filter)); -} - -void QQnxFileDialogHelper::setNameFilters(const QStringList &filters) -{ - qFileDialogHelperDebug() << "filters =" << filters; - - Q_ASSERT(!filters.isEmpty()); - - m_dialog->setFilters(filters); - m_selectedFilter = filters.first(); -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxfilepicker.cpp b/src/plugins/platforms/qnx/qqnxfilepicker.cpp deleted file mode 100644 index ca8d731e66..0000000000 --- a/src/plugins/platforms/qnx/qqnxfilepicker.cpp +++ /dev/null @@ -1,322 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2013 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qqnxfilepicker.h" - -#include <QAbstractEventDispatcher> -#include <QCoreApplication> -#include <QDebug> -#include <QJsonDocument> -#include <QJsonObject> -#include <QJsonArray> -#include <QJsonParseError> -#include <QMimeDatabase> -#include <QUrl> -#include <private/qppsobject_p.h> - -#include <bps/navigator.h> -#include <bps/navigator_invoke.h> - -#include <errno.h> - -#ifdef QQNXFILEPICKER_DEBUG -#define qFilePickerDebug qDebug -#else -#define qFilePickerDebug QT_NO_QDEBUG_MACRO -#endif - -QT_BEGIN_NAMESPACE - -static const char s_filePickerTarget[] = "sys.filepicker.target"; - -QQnxFilePicker::QQnxFilePicker(QObject *parent) - : QObject(parent) - , m_invocationHandle(0) - , m_mode(QQnxFilePicker::Picker) - , m_title(tr("Pick a file")) -{ - QCoreApplication::eventDispatcher()->installNativeEventFilter(this); -} - -QQnxFilePicker::~QQnxFilePicker() -{ - cleanup(); - - QCoreApplication::eventDispatcher()->removeNativeEventFilter(this); -} - -void QQnxFilePicker::open() -{ - if (m_invocationHandle) - return; - - // Clear any previous results - m_selectedFiles.clear(); - - int errorCode = BPS_SUCCESS; - - errorCode = navigator_invoke_invocation_create(&m_invocationHandle); - if (errorCode != BPS_SUCCESS) { - qWarning() << "QQnxFilePicker: unable to create invocation:" << strerror(errno); - return; - } - - errorCode = navigator_invoke_invocation_set_target(m_invocationHandle, s_filePickerTarget); - - if (errorCode != BPS_SUCCESS) { - cleanup(); - qWarning() << "QQnxFilePicker: unable to set target:" << strerror(errno); - return; - } - - errorCode = navigator_invoke_invocation_set_action(m_invocationHandle, "bb.action.OPEN"); - if (errorCode != BPS_SUCCESS) { - cleanup(); - qWarning() << "QQnxFilePicker: unable to set action:" << strerror(errno); - return; - } - - errorCode = navigator_invoke_invocation_set_type(m_invocationHandle, "application/vnd.blackberry.file_picker"); - if (errorCode != BPS_SUCCESS) { - cleanup(); - qWarning() << "QQnxFilePicker: unable to set mime type:" << strerror(errno); - return; - } - - QVariantMap map; - map[QStringLiteral("Type")] = filePickerType(); - map[QStringLiteral("Mode")] = modeToString(m_mode); - map[QStringLiteral("Title")] = m_title; - map[QStringLiteral("ViewMode")] = QStringLiteral("Default"); - map[QStringLiteral("SortBy")] = QStringLiteral("Default"); - map[QStringLiteral("SortOrder")] = QStringLiteral("Default"); - map[QStringLiteral("ImageCrop")] = false; - map[QStringLiteral("AllowOverwrite")] = false; - - if (!m_defaultSaveFileNames.isEmpty()) - map[QStringLiteral("DefaultFileNames")] = m_defaultSaveFileNames.join(QLatin1Char(',')); - if (!m_filters.isEmpty()) - map[QStringLiteral("Filter")] = m_filters.join(QLatin1Char(';')); - - QByteArray ppsData; - ppsData = QPpsObject::encode(map); - - errorCode = navigator_invoke_invocation_set_data(m_invocationHandle, ppsData.constData(), ppsData.size()); - if (errorCode != BPS_SUCCESS) { - cleanup(); - qWarning() << "QQnxFilePicker: unable to set data:" << strerror(errno); - return; - } - - navigator_invoke_invocation_send(m_invocationHandle); -} - -void QQnxFilePicker::close() -{ - navigator_card_close_child(); - cleanup(); -} - -bool QQnxFilePicker::nativeEventFilter(const QByteArray&, void *message, long*) -{ - bps_event_t * const event = static_cast<bps_event_t*>(message); - if (!event) - return false; - - if (bps_event_get_code(event) == NAVIGATOR_INVOKE_TARGET_RESULT) { - const char *id = navigator_event_get_id(event); - const char *err = navigator_event_get_err(event); - qFilePickerDebug("received invocation response: id=%s err=%s", id, err); - } else if (bps_event_get_code(event) == NAVIGATOR_CHILD_CARD_CLOSED) { - const char *data = navigator_event_get_card_closed_data(event); - qFilePickerDebug("received data: data='%s'", data); - handleFilePickerResponse(data); - } - - return false; // do not drop the event -} - -void QQnxFilePicker::setMode(QQnxFilePicker::Mode mode) -{ - m_mode = mode; -} - -void QQnxFilePicker::setDefaultSaveFileNames(const QStringList &fileNames) -{ - m_defaultSaveFileNames = fileNames; -} - -void QQnxFilePicker::addDefaultSaveFileName(const QString &fileName) -{ - m_defaultSaveFileNames.append(fileName); -} - -void QQnxFilePicker::setDirectories(const QStringList &directories) -{ - m_directories = directories; -} - -void QQnxFilePicker::addDirectory(const QString &directory) -{ - m_directories.append(directory); -} - -void QQnxFilePicker::setFilters(const QStringList &filters) -{ - m_filters = filters; -} - -void QQnxFilePicker::setTitle(const QString &title) -{ - m_title = title; -} - -QQnxFilePicker::Mode QQnxFilePicker::mode() const -{ - return m_mode; -} - -QStringList QQnxFilePicker::defaultSaveFileNames() const -{ - return m_defaultSaveFileNames; -} - -QStringList QQnxFilePicker::directories() const -{ - return m_directories; -} - -QStringList QQnxFilePicker::filters() const -{ - return m_filters; -} - -QStringList QQnxFilePicker::selectedFiles() const -{ - return m_selectedFiles; -} - -QString QQnxFilePicker::title() const -{ - return m_title; -} - -void QQnxFilePicker::cleanup() -{ - if (m_invocationHandle) { - navigator_invoke_invocation_destroy(m_invocationHandle); - m_invocationHandle = 0; - } -} - -void QQnxFilePicker::handleFilePickerResponse(const char *data) -{ - QJsonParseError jsonError; - QJsonDocument document = QJsonDocument::fromJson(data, &jsonError); - - if (jsonError.error != QJsonParseError::NoError) { - qFilePickerDebug() << "Error parsing FilePicker response: " - << jsonError.errorString(); - Q_EMIT closed(); - cleanup(); - return; - } - - // The response is a list of Json objects. - const QVariantList array = document.array().toVariantList(); - - foreach (const QVariant &variant, array) { - const QJsonObject object = QJsonObject::fromVariantMap(variant.toMap()); - const QUrl url(object.value(QStringLiteral("uri")).toString()); - const QString localFile = url.toLocalFile(); // strip "file://" - - if (!localFile.isEmpty()) - m_selectedFiles << localFile; - - qFilePickerDebug() << "FilePicker uri response:" << localFile; - } - - Q_EMIT closed(); - cleanup(); -} - -QString QQnxFilePicker::filePickerType() const -{ - bool images = false; - bool video = false; - bool music = false; - QMimeDatabase mimeDb; - for (int i = 0; i < m_filters.count(); i++) { - QList<QMimeType> mimeTypes = mimeDb.mimeTypesForFileName(m_filters.at(i)); - if (mimeTypes.isEmpty()) - return QStringLiteral("Other"); - - if (mimeTypes.first().name().startsWith(QLatin1String("image"))) - images = true; - else if (mimeTypes.first().name().startsWith(QLatin1String("audio"))) - music = true; - else if (mimeTypes.first().name().startsWith(QLatin1String("video"))) - video = true; - else - return QStringLiteral("Other"); - } - - if (!video && !music) - return QStringLiteral("Picture"); - - if (!images && !music) - return QStringLiteral("Video"); - - if (!images && !video) - return QStringLiteral("Music"); - - return QStringLiteral("Other"); -} - -QString QQnxFilePicker::modeToString(QQnxFilePicker::Mode mode) const -{ - switch (mode) { - case Picker: - return QStringLiteral("Picker"); - case Saver: - return QStringLiteral("Saver"); - case PickerMultiple: - return QStringLiteral("PickerMultiple"); - case SaverMultiple: - return QStringLiteral("SaverMultiple"); - } - - return QStringLiteral("Picker"); -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxfilepicker.h b/src/plugins/platforms/qnx/qqnxfilepicker.h deleted file mode 100644 index 7e4f9010cc..0000000000 --- a/src/plugins/platforms/qnx/qqnxfilepicker.h +++ /dev/null @@ -1,107 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2013 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQNXFILEPICKER_H -#define QQNXFILEPICKER_H - -#include <QAbstractNativeEventFilter> -#include <QObject> -#include <QStringList> - -QT_BEGIN_NAMESPACE - -struct navigator_invoke_invocation_t; - -class QQnxFilePicker : public QObject, public QAbstractNativeEventFilter -{ - Q_OBJECT - -public: - explicit QQnxFilePicker(QObject *parent = 0); - ~QQnxFilePicker(); - - enum Mode { - Picker, - Saver, - PickerMultiple, - SaverMultiple - }; - - bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE; - - void setMode(Mode mode); - void setDefaultSaveFileNames(const QStringList &fileNames); - void addDefaultSaveFileName(const QString &fileName); - void setDirectories(const QStringList &directories); - void addDirectory(const QString &directory); - void setFilters(const QStringList &filters); - void setTitle(const QString &title); - - Mode mode() const; - - QStringList defaultSaveFileNames() const; - QStringList directories() const; - QStringList filters() const; - QStringList selectedFiles() const; - - QString title() const; - -Q_SIGNALS: - void closed(); - -public Q_SLOTS: - void open(); - void close(); - -private: - void cleanup(); - void handleFilePickerResponse(const char *data); - QString filePickerType() const; - - QString modeToString(Mode mode) const; - - navigator_invoke_invocation_t *m_invocationHandle; - - Mode m_mode; - - QStringList m_defaultSaveFileNames; - QStringList m_directories; - QStringList m_filters; - QStringList m_selectedFiles; - - QString m_title; -}; - -QT_END_NAMESPACE - -#endif // QQNXFILEPICKER_H diff --git a/src/plugins/platforms/qnx/qqnxglcontext.cpp b/src/plugins/platforms/qnx/qqnxglcontext.cpp index 5ef8d72926..20930af524 100644 --- a/src/plugins/platforms/qnx/qqnxglcontext.cpp +++ b/src/plugins/platforms/qnx/qqnxglcontext.cpp @@ -61,7 +61,7 @@ QQnxGLContext::QQnxGLContext(QOpenGLContext *glContext) // Set current rendering API EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API); - if (eglResult != EGL_TRUE) + if (Q_UNLIKELY(eglResult != EGL_TRUE)) qFatal("QQNX: failed to set EGL API, err=%d", eglGetError()); // Get colour channel sizes from window format @@ -113,7 +113,7 @@ QQnxGLContext::QQnxGLContext(QOpenGLContext *glContext) // Select EGL config based on requested window format m_eglConfig = q_configFromGLFormat(ms_eglDisplay, format); - if (m_eglConfig == 0) + if (Q_UNLIKELY(m_eglConfig == 0)) qFatal("QQnxGLContext: failed to find EGL config"); QQnxGLContext *glShareContext = static_cast<QQnxGLContext*>(m_glContext->shareHandle()); @@ -121,7 +121,7 @@ QQnxGLContext::QQnxGLContext(QOpenGLContext *glContext) m_eglContext = eglCreateContext(ms_eglDisplay, m_eglConfig, m_eglShareContext, contextAttrs(format)); - if (m_eglContext == EGL_NO_CONTEXT) { + if (Q_UNLIKELY(m_eglContext == EGL_NO_CONTEXT)) { checkEGLError("eglCreateContext"); qFatal("QQnxGLContext: failed to create EGL context, err=%d", eglGetError()); } @@ -170,13 +170,13 @@ void QQnxGLContext::initializeContext() // Initialize connection to EGL ms_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); - if (ms_eglDisplay == EGL_NO_DISPLAY) { + if (Q_UNLIKELY(ms_eglDisplay == EGL_NO_DISPLAY)) { checkEGLError("eglGetDisplay"); qFatal("QQnxGLContext: failed to obtain EGL display"); } EGLBoolean eglResult = eglInitialize(ms_eglDisplay, 0, 0); - if (eglResult != EGL_TRUE) { + if (Q_UNLIKELY(eglResult != EGL_TRUE)) { checkEGLError("eglInitialize"); qFatal("QQnxGLContext: failed to initialize EGL display, err=%d", eglGetError()); } @@ -198,7 +198,7 @@ bool QQnxGLContext::makeCurrent(QPlatformSurface *surface) // Set current rendering API EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API); - if (eglResult != EGL_TRUE) + if (Q_UNLIKELY(eglResult != EGL_TRUE)) qFatal("QQnxGLContext: failed to set EGL API, err=%d", eglGetError()); QQnxEglWindow *platformWindow = dynamic_cast<QQnxEglWindow*>(surface); @@ -227,12 +227,12 @@ void QQnxGLContext::doneCurrent() // set current rendering API EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API); - if (eglResult != EGL_TRUE) + if (Q_UNLIKELY(eglResult != EGL_TRUE)) qFatal("QQNX: failed to set EGL API, err=%d", eglGetError()); // clear curent EGL context and unbind EGL surface eglResult = eglMakeCurrent(ms_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - if (eglResult != EGL_TRUE) + if (Q_UNLIKELY(eglResult != EGL_TRUE)) qFatal("QQNX: failed to clear current EGL context, err=%d", eglGetError()); } @@ -252,7 +252,7 @@ QFunctionPointer QQnxGLContext::getProcAddress(const QByteArray &procName) // Set current rendering API EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API); - if (eglResult != EGL_TRUE) + if (Q_UNLIKELY(eglResult != EGL_TRUE)) qFatal("QQNX: failed to set EGL API, err=%d", eglGetError()); // Lookup EGL extension function pointer diff --git a/src/plugins/platforms/qnx/qqnxglobal.cpp b/src/plugins/platforms/qnx/qqnxglobal.cpp index 01e7675839..4d2599746e 100644 --- a/src/plugins/platforms/qnx/qqnxglobal.cpp +++ b/src/plugins/platforms/qnx/qqnxglobal.cpp @@ -44,8 +44,8 @@ void qScreenCheckError(int rc, const char *funcInfo, const char *message, bool c rc = screen_flush_context(QQnxIntegration::screenContext(), 0); } - if (rc) { - if (critical) + if (Q_UNLIKELY(rc)) { + if (Q_UNLIKELY(critical)) qCritical("%s - Screen: %s - Error: %s (%i)", funcInfo, message, strerror(errno), errno); else qWarning("%s - Screen: %s - Error: %s (%i)", funcInfo, message, strerror(errno), errno); diff --git a/src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp b/src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp index 3af481b991..5aa8b9bfee 100644 --- a/src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp +++ b/src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp @@ -530,29 +530,28 @@ static bool imfAvailable() if ( p_imf_client_init == 0 ) { void *handle = dlopen("libinput_client.so.1", 0); - if ( handle ) { - p_imf_client_init = (int32_t (*)()) dlsym(handle, "imf_client_init"); - p_imf_client_disconnect = (void (*)()) dlsym(handle, "imf_client_disconnect"); - p_ictrl_open_session = (const input_session_t *(*)(connection_interface_t *))dlsym(handle, "ictrl_open_session"); - p_ictrl_close_session = (void (*)(input_session_t *))dlsym(handle, "ictrl_close_session"); - p_ictrl_dispatch_event = (int32_t (*)(event_t *))dlsym(handle, "ictrl_dispatch_event"); - p_vkb_init_selection_service = (int32_t (*)())dlsym(handle, "vkb_init_selection_service"); - p_ictrl_get_num_active_sessions = (int32_t (*)())dlsym(handle, "ictrl_get_num_active_sessions"); - } else { + if (Q_UNLIKELY(!handle)) { qCritical("libinput_client.so.1 is not present - IMF services are disabled."); s_imfDisabled = true; return false; } - - if ( p_imf_client_init && p_ictrl_open_session && p_ictrl_dispatch_event ) { - s_imfReady = true; - } else { + p_imf_client_init = (int32_t (*)()) dlsym(handle, "imf_client_init"); + p_imf_client_disconnect = (void (*)()) dlsym(handle, "imf_client_disconnect"); + p_ictrl_open_session = (const input_session_t *(*)(connection_interface_t *))dlsym(handle, "ictrl_open_session"); + p_ictrl_close_session = (void (*)(input_session_t *))dlsym(handle, "ictrl_close_session"); + p_ictrl_dispatch_event = (int32_t (*)(event_t *))dlsym(handle, "ictrl_dispatch_event"); + p_vkb_init_selection_service = (int32_t (*)())dlsym(handle, "vkb_init_selection_service"); + p_ictrl_get_num_active_sessions = (int32_t (*)())dlsym(handle, "ictrl_get_num_active_sessions"); + + if (Q_UNLIKELY(!p_imf_client_init || !p_ictrl_open_session || !p_ictrl_dispatch_event)) { p_ictrl_open_session = 0; p_ictrl_dispatch_event = 0; s_imfDisabled = true; qCritical("libinput_client.so.1 did not contain the correct symbols, library mismatch? IMF services are disabled."); return false; } + + s_imfReady = true; } return s_imfReady; @@ -581,7 +580,7 @@ QQnxInputContext::QQnxInputContext(QQnxIntegration *integration, QQnxAbstractVir Q_ASSERT(sInputContextInstance == 0); sInputContextInstance = this; - if (p_imf_client_init() != 0) { + if (Q_UNLIKELY(p_imf_client_init() != 0)) { s_imfInitFailed = true; qCritical("imf_client_init failed - IMF services will be unavailable"); } diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp index 6548c82310..0616ac626f 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.cpp +++ b/src/plugins/platforms/qnx/qqnxintegration.cpp @@ -52,12 +52,7 @@ #include "qqnxeglwindow.h" #endif -#if defined(Q_OS_BLACKBERRY) -#include "qqnxbpseventfilter.h" -#include "qqnxnavigatorbps.h" -#include "qblackberrytheme.h" -#include "qqnxvirtualkeyboardbps.h" -#elif defined(QQNX_PPS) +#if defined(QQNX_PPS) #include "qqnxnavigatorpps.h" #include "qqnxnavigatoreventnotifier.h" #include "qqnxvirtualkeyboardpps.h" @@ -75,12 +70,7 @@ #endif #include "private/qgenericunixfontdatabase_p.h" - -#if defined(Q_OS_BLACKBERRY) -#include "qqnxeventdispatcher_blackberry.h" -#else #include "private/qgenericunixeventdispatcher_p.h" -#endif #include <qpa/qplatformwindow.h> #include <qpa/qwindowsysteminterface.h> @@ -120,16 +110,10 @@ static inline QQnxIntegration::Options parseOptions(const QStringList ¶mList options |= QQnxIntegration::AlwaysFlushScreenContext; } -// On Blackberry the first window is treated as a root window -#ifdef Q_OS_BLACKBERRY - if (!paramList.contains(QLatin1String("no-rootwindow"))) { - options |= QQnxIntegration::RootWindow; - } -#else if (paramList.contains(QLatin1String("rootwindow"))) { options |= QQnxIntegration::RootWindow; } -#endif + return options; } @@ -147,12 +131,7 @@ QQnxIntegration::QQnxIntegration(const QStringList ¶mList) #endif , m_services(0) , m_fontDatabase(new QGenericUnixFontDatabase()) -#if defined(Q_OS_BLACKBERRY) - , m_eventDispatcher(new QQnxEventDispatcherBlackberry()) - , m_bpsEventFilter(0) -#else , m_eventDispatcher(createUnixEventDispatcher()) -#endif , m_nativeInterface(new QQnxNativeInterface(this)) , m_screenEventHandler(new QQnxScreenEventHandler(this)) #if !defined(QT_NO_CLIPBOARD) @@ -169,8 +148,7 @@ QQnxIntegration::QQnxIntegration(const QStringList ¶mList) Q_SCREEN_CRITICALERROR(screen_create_context(&ms_screenContext, SCREEN_APPLICATION_CONTEXT), "Failed to create screen context"); - // Not on BlackBerry, it has specialized event dispatcher which also handles navigator events -#if !defined(Q_OS_BLACKBERRY) && defined(QQNX_PPS) +#if defined(QQNX_PPS) // Create/start navigator event notifier m_navigatorEventNotifier = new QQnxNavigatorEventNotifier(m_navigatorEventHandler); @@ -190,8 +168,7 @@ QQnxIntegration::QQnxIntegration(const QStringList ¶mList) m_screenEventThread->start(); #endif - // Not on BlackBerry, it has specialized event dispatcher which also handles virtual keyboard events -#if !defined(Q_OS_BLACKBERRY) && defined(QQNX_PPS) +#if defined(QQNX_PPS) // Create/start the keyboard class. m_virtualKeyboard = new QQnxVirtualKeyboardPps(); @@ -200,9 +177,7 @@ QQnxIntegration::QQnxIntegration(const QStringList ¶mList) QMetaObject::invokeMethod(m_virtualKeyboard, "start", Qt::QueuedConnection); #endif -#if defined(Q_OS_BLACKBERRY) - m_navigator = new QQnxNavigatorBps(); -#elif defined(QQNX_PPS) +#if defined(QQNX_PPS) m_navigator = new QQnxNavigatorPps(); #endif @@ -210,34 +185,8 @@ QQnxIntegration::QQnxIntegration(const QStringList ¶mList) if (m_navigator) m_services = new QQnxServices(m_navigator); -#if defined(Q_OS_BLACKBERRY) - QQnxVirtualKeyboardBps* virtualKeyboardBps = new QQnxVirtualKeyboardBps; - -#if defined(QQNX_SCREENEVENTTHREAD) - m_bpsEventFilter = new QQnxBpsEventFilter(m_navigatorEventHandler, 0, virtualKeyboardBps); -#else - m_bpsEventFilter = new QQnxBpsEventFilter(m_navigatorEventHandler, m_screenEventHandler, virtualKeyboardBps); -#endif - - m_bpsEventFilter->installOnEventDispatcher(m_eventDispatcher); - - m_virtualKeyboard = virtualKeyboardBps; -#endif - - // Create displays for all possible screens (which may not be attached). We have to do this - // *after* the call to m_bpsEventFilter->installOnEventDispatcher(m_eventDispatcher). The - // reason for this is that we have to be registered for NAVIGATOR events before we create the - // QQnxScreen objects, and hence the QQnxRootWindow's. It is when the NAVIGATOR service sees - // the window creation that it starts sending us messages which results in a race if we - // create the displays first. createDisplays(); -#if !defined(QQNX_SCREENEVENTTHREAD) && defined(Q_OS_BLACKBERRY) - // Register for screen domain events with bps - Q_FOREACH (QQnxScreen *screen, m_screens) - m_bpsEventFilter->registerForScreenEvents(screen); -#endif - if (m_virtualKeyboard) { // TODO check if we need to do this for all screens or only the primary one QObject::connect(m_virtualKeyboard, SIGNAL(heightChanged(int)), @@ -275,7 +224,7 @@ QQnxIntegration::~QQnxIntegration() #endif // Stop/destroy navigator event notifier -#if !defined(Q_OS_BLACKBERRY) && defined(QQNX_PPS) +#if defined(QQNX_PPS) delete m_navigatorEventNotifier; #endif delete m_navigatorEventHandler; @@ -283,13 +232,6 @@ QQnxIntegration::~QQnxIntegration() #if defined(QQNX_SCREENEVENTTHREAD) // Stop/destroy screen event thread delete m_screenEventThread; -#elif defined(Q_OS_BLACKBERRY) - Q_FOREACH (QQnxScreen *screen, m_screens) - m_bpsEventFilter->unregisterForScreenEvents(screen); -#endif - -#if defined(Q_OS_BLACKBERRY) - delete m_bpsEventFilter; #endif // In case the event-dispatcher was never transferred to QCoreApplication @@ -450,21 +392,6 @@ QPlatformServices * QQnxIntegration::services() const return m_services; } -#if defined(Q_OS_BLACKBERRY) -QStringList QQnxIntegration::themeNames() const -{ - return QStringList(QBlackberryTheme::name()); -} - -QPlatformTheme *QQnxIntegration::createPlatformTheme(const QString &name) const -{ - qIntegrationDebug() << "name =" << name; - if (name == QBlackberryTheme::name()) - return new QBlackberryTheme(this); - return 0; -} -#endif - QWindow *QQnxIntegration::window(screen_window_t qnxWindow) { qIntegrationDebug(); @@ -498,7 +425,7 @@ void QQnxIntegration::createDisplays() &displayCount); Q_SCREEN_CRITICALERROR(result, "Failed to query display count"); - if (displayCount < 1) { + if (Q_UNLIKELY(displayCount < 1)) { // Never happens, even if there's no display, libscreen returns 1 qFatal("QQnxIntegration: displayCount=%d", displayCount); } @@ -601,7 +528,7 @@ QQnxIntegration::Options QQnxIntegration::ms_options = 0; bool QQnxIntegration::supportsNavigatorEvents() const { - // If QQNX_PPS or Q_OS_BLACKBERRY is defined then we have navigator + // If QQNX_PPS is defined then we have navigator return m_navigator != 0; } diff --git a/src/plugins/platforms/qnx/qqnxintegration.h b/src/plugins/platforms/qnx/qqnxintegration.h index 04250cdba0..3a4a1380ab 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.h +++ b/src/plugins/platforms/qnx/qqnxintegration.h @@ -42,7 +42,6 @@ QT_BEGIN_NAMESPACE -class QQnxBpsEventFilter; #if defined(QQNX_SCREENEVENTTHREAD) class QQnxScreenEventThread; #endif @@ -117,12 +116,6 @@ public: QPlatformServices *services() const; -#if defined(Q_OS_BLACKBERRY) - QStringList themeNames() const; - QPlatformTheme *createPlatformTheme(const QString &name) const; - QQnxBpsEventFilter *bpsEventFilter() const { return m_bpsEventFilter; } -#endif - static QWindow *window(screen_window_t qnxWindow); QQnxScreen *screenForNative(screen_display_t qnxScreen) const; @@ -156,9 +149,6 @@ private: QQnxServices *m_services; QPlatformFontDatabase *m_fontDatabase; mutable QAbstractEventDispatcher *m_eventDispatcher; -#if defined(Q_OS_BLACKBERRY) - QQnxBpsEventFilter *m_bpsEventFilter; -#endif QQnxNativeInterface *m_nativeInterface; QList<QQnxScreen*> m_screens; QQnxScreenEventHandler *m_screenEventHandler; diff --git a/src/plugins/platforms/qnx/qqnxnativeinterface.cpp b/src/plugins/platforms/qnx/qqnxnativeinterface.cpp index 549e0209bf..8c22f7cea0 100644 --- a/src/plugins/platforms/qnx/qqnxnativeinterface.cpp +++ b/src/plugins/platforms/qnx/qqnxnativeinterface.cpp @@ -85,11 +85,6 @@ void *QQnxNativeInterface::nativeResourceForScreen(const QByteArray &resource, Q void *QQnxNativeInterface::nativeResourceForIntegration(const QByteArray &resource) { -#ifdef Q_OS_BLACKBERRY - if (resource == "navigatorEventHandler") - return m_integration->navigatorEventHandler(); -#endif - return 0; } diff --git a/src/plugins/platforms/qnx/qqnxnavigatorbps.cpp b/src/plugins/platforms/qnx/qqnxnavigatorbps.cpp deleted file mode 100644 index 0d730d6f57..0000000000 --- a/src/plugins/platforms/qnx/qqnxnavigatorbps.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qqnxnavigatorbps.h" - -#include <QDebug> - -#include <bps/navigator.h> - -QT_BEGIN_NAMESPACE - -QQnxNavigatorBps::QQnxNavigatorBps(QObject *parent) - : QQnxAbstractNavigator(parent) -{ - bps_initialize(); -} - -QQnxNavigatorBps::~QQnxNavigatorBps() -{ - bps_shutdown(); -} - -bool QQnxNavigatorBps::requestInvokeUrl(const QByteArray &encodedUrl) -{ - char *error = 0; - - int ret = navigator_invoke(encodedUrl, &error); - if (error) { - qWarning() << "error=" << error; - bps_free(error); - } - - return (ret == BPS_SUCCESS); -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxnavigatorbps.h b/src/plugins/platforms/qnx/qqnxnavigatorbps.h deleted file mode 100644 index b006695de6..0000000000 --- a/src/plugins/platforms/qnx/qqnxnavigatorbps.h +++ /dev/null @@ -1,54 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQNXNAVIGATORBPS_H -#define QQNXNAVIGATORBPS_H - -#include "qqnxabstractnavigator.h" - -QT_BEGIN_NAMESPACE - -class QQnxNavigatorBps : public QQnxAbstractNavigator -{ - Q_OBJECT -public: - explicit QQnxNavigatorBps(QObject *parent = 0); - ~QQnxNavigatorBps(); - -protected: - bool requestInvokeUrl(const QByteArray &encodedUrl); -}; - -QT_END_NAMESPACE - -#endif // QQNXNAVIGATORBPS_H diff --git a/src/plugins/platforms/qnx/qqnxnavigatorcover.cpp b/src/plugins/platforms/qnx/qqnxnavigatorcover.cpp deleted file mode 100644 index 6d30677b30..0000000000 --- a/src/plugins/platforms/qnx/qqnxnavigatorcover.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2013 BlackBerry Limited. All rights reserved. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qqnxnavigatorcover.h" - -QQnxNavigatorCover::QQnxNavigatorCover() -{ - navigator_window_cover_attribute_create(&m_coverAttribute); -} - -QQnxNavigatorCover::~QQnxNavigatorCover() -{ - if (m_coverAttribute) - navigator_window_cover_attribute_destroy(m_coverAttribute); - - navigator_window_cover_reset(); -} - -void QQnxNavigatorCover::updateCover() -{ - if (m_coverAttribute) { - navigator_window_cover_attribute_set_transition(m_coverAttribute, - NAVIGATOR_WINDOW_COVER_TRANSITION_NONE); - navigator_window_cover_attribute_set_alternate_window(m_coverAttribute); - navigator_window_cover_update(m_coverAttribute); - } -} diff --git a/src/plugins/platforms/qnx/qqnxnavigatorcover.h b/src/plugins/platforms/qnx/qqnxnavigatorcover.h deleted file mode 100644 index 5e9ed9f7bd..0000000000 --- a/src/plugins/platforms/qnx/qqnxnavigatorcover.h +++ /dev/null @@ -1,52 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2013 BlackBerry Limited. All rights reserved. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQNXNAVIGATORCOVER_H -#define QQNXNAVIGATORCOVER_H - -#include "qqnxabstractcover.h" -#include <bps/navigator.h> - -class QQnxNavigatorCover : public QQnxAbstractCover -{ -public: - QQnxNavigatorCover(); - ~QQnxNavigatorCover(); - - void updateCover(); - -private: - navigator_window_cover_attribute_t *m_coverAttribute; -}; - -#endif // QQNXNAVIGATORCOVER_H diff --git a/src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp b/src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp index 6199eb8e11..8098c9970e 100644 --- a/src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp +++ b/src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp @@ -102,7 +102,7 @@ void QQnxNavigatorEventNotifier::parsePPS(const QByteArray &ppsData, QByteArray QList<QByteArray> lines = ppsData.split('\n'); // validate pps object - if (lines.size() == 0 || lines.at(0) != "@control") + if (Q_UNLIKELY(lines.empty() || lines.at(0) != "@control")) qFatal("QQNX: unrecognized pps object, data=%s", ppsData.constData()); // parse pps object attributes and extract values @@ -160,7 +160,7 @@ void QQnxNavigatorEventNotifier::replyPPS(const QByteArray &res, const QByteArra // send pps message to navigator errno = 0; int bytes = write(m_fd, ppsData.constData(), ppsData.size()); - if (bytes == -1) + if (Q_UNLIKELY(bytes == -1)) qFatal("QQNX: failed to write navigator pps, errno=%d", errno); } @@ -198,7 +198,7 @@ void QQnxNavigatorEventNotifier::readData() // attempt to read pps data errno = 0; int bytes = qt_safe_read(m_fd, buffer, ppsBufferSize - 1); - if (bytes == -1) + if (Q_UNLIKELY(bytes == -1)) qFatal("QQNX: failed to read navigator pps, errno=%d", errno); // check if pps data was received diff --git a/src/plugins/platforms/qnx/qqnxnavigatorpps.cpp b/src/plugins/platforms/qnx/qqnxnavigatorpps.cpp index b139471669..ca8e2bd3ab 100644 --- a/src/plugins/platforms/qnx/qqnxnavigatorpps.cpp +++ b/src/plugins/platforms/qnx/qqnxnavigatorpps.cpp @@ -100,7 +100,7 @@ bool QQnxNavigatorPps::sendPpsMessage(const QByteArray &message, const QByteArra // send pps message to navigator errno = 0; int bytes = qt_safe_write(m_fd, ppsMessage.constData(), ppsMessage.size()); - if (bytes == -1) + if (Q_UNLIKELY(bytes == -1)) qFatal("QQNX: failed to write navigator pps, errno=%d", errno); // allocate buffer for pps data @@ -110,7 +110,7 @@ bool QQnxNavigatorPps::sendPpsMessage(const QByteArray &message, const QByteArra do { errno = 0; bytes = qt_safe_read(m_fd, buffer, ppsBufferSize - 1); - if (bytes == -1) + if (Q_UNLIKELY(bytes == -1)) qFatal("QQNX: failed to read navigator pps, errno=%d", errno); } while (bytes == 0); @@ -125,7 +125,7 @@ bool QQnxNavigatorPps::sendPpsMessage(const QByteArray &message, const QByteArra parsePPS(ppsData, responseFields); if (responseFields.contains("res") && responseFields.value("res") == message) { - if (responseFields.contains("err")) { + if (Q_UNLIKELY(responseFields.contains("err"))) { qCritical() << "navigator responded with error: " << responseFields.value("err"); return false; } @@ -142,7 +142,7 @@ void QQnxNavigatorPps::parsePPS(const QByteArray &ppsData, QHash<QByteArray, QBy QList<QByteArray> lines = ppsData.split('\n'); // validate pps object - if (lines.size() == 0 || lines.at(0) != "@control") + if (Q_UNLIKELY(lines.empty() || lines.at(0) != "@control")) qFatal("QQNX: unrecognized pps object, data=%s", ppsData.constData()); // parse pps object attributes and extract values diff --git a/src/plugins/platforms/qnx/qqnxrasterwindow.cpp b/src/plugins/platforms/qnx/qqnxrasterwindow.cpp index 933fce0e33..771986d763 100644 --- a/src/plugins/platforms/qnx/qqnxrasterwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxrasterwindow.cpp @@ -61,7 +61,7 @@ QQnxRasterWindow::QQnxRasterWindow(QWindow *window, screen_context_t context, bo const int val = SCREEN_USAGE_NATIVE | SCREEN_USAGE_READ | SCREEN_USAGE_WRITE; const int result = screen_set_window_property_iv(nativeHandle(), SCREEN_PROPERTY_USAGE, &val); - if (result != 0) + if (Q_UNLIKELY(result != 0)) qFatal("QQnxRasterWindow: failed to set window alpha usage, errno=%d", errno); } diff --git a/src/plugins/platforms/qnx/qqnxscreen.cpp b/src/plugins/platforms/qnx/qqnxscreen.cpp index c4125ef177..7eaf50318c 100644 --- a/src/plugins/platforms/qnx/qqnxscreen.cpp +++ b/src/plugins/platforms/qnx/qqnxscreen.cpp @@ -584,10 +584,6 @@ void QQnxScreen::addWindow(QQnxWindow *window) else m_childWindows.push_back(window); updateHierarchy(); - } else { -#if defined(Q_OS_BLACKBERRY) - m_coverWindow = window; -#endif } } diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp index 6c9532c428..781c6f28af 100644 --- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp +++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp @@ -254,13 +254,8 @@ void QQnxScreenEventHandler::handleKeyboardEvent(screen_event_t event) "Failed to query event cap"); int sequenceId = 0; -#if defined(Q_OS_BLACKBERRY) - Q_SCREEN_CHECKERROR( - screen_get_event_property_iv(event, SCREEN_PROPERTY_SEQUENCE_ID, &sequenceId), - "Failed to query event seqId"); -#endif - bool inject = true; + Q_FOREACH (QQnxScreenEventFilter *filter, m_eventFilters) { if (filter->handleKeyboardEvent(flags, sym, modifiers, scan, cap, sequenceId)) { inject = false; @@ -584,12 +579,12 @@ void QQnxScreenEventHandler::handlePropertyEvent(screen_event_t event) errno = 0; screen_window_t window = 0; - if (screen_get_event_property_pv(event, SCREEN_PROPERTY_WINDOW, (void**)&window) != 0) + if (Q_UNLIKELY(screen_get_event_property_pv(event, SCREEN_PROPERTY_WINDOW, (void**)&window) != 0)) qFatal("QQnx: failed to query window property, errno=%d", errno); errno = 0; int property; - if (screen_get_event_property_iv(event, SCREEN_PROPERTY_NAME, &property) != 0) + if (Q_UNLIKELY(screen_get_event_property_iv(event, SCREEN_PROPERTY_NAME, &property) != 0)) qFatal("QQnx: failed to query window property, errno=%d", errno); switch (property) { @@ -606,7 +601,7 @@ void QQnxScreenEventHandler::handleKeyboardFocusPropertyEvent(screen_window_t wi { errno = 0; int focus = 0; - if (window && screen_get_window_property_iv(window, SCREEN_PROPERTY_KEYBOARD_FOCUS, &focus) != 0) + if (Q_UNLIKELY(window && screen_get_window_property_iv(window, SCREEN_PROPERTY_KEYBOARD_FOCUS, &focus) != 0)) qFatal("QQnx: failed to query keyboard focus property, errno=%d", errno); QWindow *focusWindow = QQnxIntegration::window(window); diff --git a/src/plugins/platforms/qnx/qqnxsystemsettings.cpp b/src/plugins/platforms/qnx/qqnxsystemsettings.cpp deleted file mode 100644 index 243630ec85..0000000000 --- a/src/plugins/platforms/qnx/qqnxsystemsettings.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qqnxsystemsettings.h" - -#include <QFont> -#include <qpa/qplatformfontdatabase.h> - -QT_BEGIN_NAMESPACE - -QHash<QPlatformTheme::Font, QFont *> qt_qnx_createRoleFonts(QPlatformFontDatabase *fontDatabase) -{ - // See http://docs.blackberry.com/en/developers/deliverables/41577/typography.jsp - // which recommends using - // - small font size of 6 points - // - normal font size of 8 points - // - 11 points for titles (not covered by the theme system). - QFont baseFont = fontDatabase->defaultFont(); - baseFont.setPointSize(8); - - QHash<QPlatformTheme::Font, QFont *> fonts; - fonts.insert(QPlatformTheme::SystemFont, new QFont(baseFont)); - fonts.insert(QPlatformTheme::PushButtonFont, new QFont(baseFont)); - fonts.insert(QPlatformTheme::ListViewFont, new QFont(baseFont)); - fonts.insert(QPlatformTheme::ListBoxFont, new QFont(baseFont)); - fonts.insert(QPlatformTheme::TitleBarFont, new QFont(baseFont)); - fonts.insert(QPlatformTheme::MenuFont, new QFont(baseFont)); - fonts.insert(QPlatformTheme::ComboMenuItemFont, new QFont(baseFont)); - fonts.insert(QPlatformTheme::HeaderViewFont, new QFont(baseFont)); - fonts.insert(QPlatformTheme::TipLabelFont, new QFont(baseFont)); - fonts.insert(QPlatformTheme::LabelFont, new QFont(baseFont)); - fonts.insert(QPlatformTheme::ToolButtonFont, new QFont(baseFont)); - fonts.insert(QPlatformTheme::MenuItemFont, new QFont(baseFont)); - fonts.insert(QPlatformTheme::ComboLineEditFont, new QFont(baseFont)); - - QFont smallFont(baseFont); - smallFont.setPointSize(6); - fonts.insert(QPlatformTheme::SmallFont, new QFont(smallFont)); - fonts.insert(QPlatformTheme::MiniFont, new QFont(smallFont)); - - return fonts; -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxsystemsettings.h b/src/plugins/platforms/qnx/qqnxsystemsettings.h deleted file mode 100644 index 6a99d5a70c..0000000000 --- a/src/plugins/platforms/qnx/qqnxsystemsettings.h +++ /dev/null @@ -1,48 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQNXSYSTEMSETTINGS_H -#define QQNXSYSTEMSETTINGS_H - -#include <QtCore/qhash.h> -#include <qpa/qplatformtheme.h> - -QT_BEGIN_NAMESPACE - -class QPlatformFontDatabase; - -QHash<QPlatformTheme::Font, QFont *> qt_qnx_createRoleFonts(QPlatformFontDatabase *fontDatabase); - -QT_END_NAMESPACE - -#endif // QQNXSYSTEMSETTINGS_H diff --git a/src/plugins/platforms/qnx/qqnxvirtualkeyboardbps.cpp b/src/plugins/platforms/qnx/qqnxvirtualkeyboardbps.cpp deleted file mode 100644 index b55ae842ed..0000000000 --- a/src/plugins/platforms/qnx/qqnxvirtualkeyboardbps.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2013 BlackBerry Limited. All rights reserved. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qqnxvirtualkeyboardbps.h" - -#include <QDebug> - -#include <bps/event.h> -#include <bps/locale.h> -#include <bps/virtualkeyboard.h> -#if defined(Q_OS_BLACKBERRY) -#include <bbndk.h> -#endif - -#if defined(QQNXVIRTUALKEYBOARD_DEBUG) -#define qVirtualKeyboardDebug qDebug -#else -#define qVirtualKeyboardDebug QT_NO_QDEBUG_MACRO -#endif - -QT_BEGIN_NAMESPACE - -QQnxVirtualKeyboardBps::QQnxVirtualKeyboardBps(QObject *parent) - : QQnxAbstractVirtualKeyboard(parent) -{ - if (locale_request_events(0) != BPS_SUCCESS) - qWarning("QQNX: Failed to register for locale events"); - - if (virtualkeyboard_request_events(0) != BPS_SUCCESS) - qWarning("QQNX: Failed to register for virtual keyboard events"); - - int height = 0; - if (virtualkeyboard_get_height(&height) != BPS_SUCCESS) - qWarning("QQNX: Failed to get virtual keyboard height"); - - setHeight(height); -} - -bool QQnxVirtualKeyboardBps::handleEvent(bps_event_t *event) -{ - const int eventDomain = bps_event_get_domain(event); - if (eventDomain == locale_get_domain()) - return handleLocaleEvent(event); - - if (eventDomain == virtualkeyboard_get_domain()) - return handleVirtualKeyboardEvent(event); - - return false; -} - -bool QQnxVirtualKeyboardBps::showKeyboard() -{ - qVirtualKeyboardDebug() << "current visibility=" << isVisible(); - - // They keyboard's mode is global between applications, we have to set it each time - if ( !isVisible() ) - applyKeyboardOptions(); - - virtualkeyboard_show(); - return true; -} - -bool QQnxVirtualKeyboardBps::hideKeyboard() -{ - qVirtualKeyboardDebug() << "current visibility=" << isVisible(); - virtualkeyboard_hide(); - return true; -} - -void QQnxVirtualKeyboardBps::applyKeyboardOptions() -{ - virtualkeyboard_layout_t layout = keyboardLayout(); - virtualkeyboard_enter_t enter = enterKey(); - - qVirtualKeyboardDebug() << "mode=" << keyboardMode() << "enterKey=" << enterKeyType(); - - virtualkeyboard_change_options(layout, enter); -} - -virtualkeyboard_layout_t QQnxVirtualKeyboardBps::keyboardLayout() const -{ - switch (keyboardMode()) { - case Url: - return VIRTUALKEYBOARD_LAYOUT_URL; - case Email: - return VIRTUALKEYBOARD_LAYOUT_EMAIL; - case Web: - return VIRTUALKEYBOARD_LAYOUT_WEB; - case NumPunc: - return VIRTUALKEYBOARD_LAYOUT_NUM_PUNC; - case Number: - return VIRTUALKEYBOARD_LAYOUT_NUMBER; - case Symbol: - return VIRTUALKEYBOARD_LAYOUT_SYMBOL; - case Phone: - return VIRTUALKEYBOARD_LAYOUT_PHONE; - case Pin: - return VIRTUALKEYBOARD_LAYOUT_PIN; - case Password: - return VIRTUALKEYBOARD_LAYOUT_PASSWORD; -#if defined(Q_OS_BLACKBERRY) -#if BBNDK_VERSION_AT_LEAST(10, 2, 1) - case Alphanumeric: - return VIRTUALKEYBOARD_LAYOUT_ALPHANUMERIC; -#endif -#endif - case Default: // fall through - default: - return VIRTUALKEYBOARD_LAYOUT_DEFAULT; - } - - return VIRTUALKEYBOARD_LAYOUT_DEFAULT; -} - -virtualkeyboard_enter_t QQnxVirtualKeyboardBps::enterKey() const -{ - switch (enterKeyType()) { - case Connect: - return VIRTUALKEYBOARD_ENTER_CONNECT; - case Done: - return VIRTUALKEYBOARD_ENTER_DONE; - case Go: - return VIRTUALKEYBOARD_ENTER_GO; - case Join: - return VIRTUALKEYBOARD_ENTER_JOIN; - case Next: - return VIRTUALKEYBOARD_ENTER_NEXT; - case Search: - return VIRTUALKEYBOARD_ENTER_SEARCH; - case Send: - return VIRTUALKEYBOARD_ENTER_SEND; - case Submit: - return VIRTUALKEYBOARD_ENTER_SUBMIT; - case Default: // fall through - default: - return VIRTUALKEYBOARD_ENTER_DEFAULT; - } - - return VIRTUALKEYBOARD_ENTER_DEFAULT; -} - -bool QQnxVirtualKeyboardBps::handleLocaleEvent(bps_event_t *event) -{ - if (bps_event_get_code(event) == LOCALE_INFO) { - const QString language = QString::fromLatin1(locale_event_get_language(event)); - const QString country = QString::fromLatin1(locale_event_get_country(event)); - const QLocale newLocale(language + QLatin1Char('_') + country); - - qVirtualKeyboardDebug() << "current locale" << locale() << "new locale=" << newLocale; - setLocale(newLocale); - return true; - } - - qVirtualKeyboardDebug() << "Unhandled locale event. code=" << bps_event_get_code(event); - - return false; -} - -bool QQnxVirtualKeyboardBps::handleVirtualKeyboardEvent(bps_event_t *event) -{ - switch (bps_event_get_code(event)) { - case VIRTUALKEYBOARD_EVENT_VISIBLE: - qVirtualKeyboardDebug() << "EVENT VISIBLE: current visibility=" << isVisible(); - setVisible(true); - break; - - case VIRTUALKEYBOARD_EVENT_HIDDEN: - qVirtualKeyboardDebug() << "EVENT HIDDEN: current visibility=" << isVisible(); - setVisible(false); - break; - - case VIRTUALKEYBOARD_EVENT_INFO: { - const int newHeight = virtualkeyboard_event_get_height(event); - qVirtualKeyboardDebug() << "EVENT INFO: current height=" << height() << "new height=" << newHeight; - setHeight(newHeight); - break; - } - - default: - qVirtualKeyboardDebug() << "Unhandled virtual keyboard event. code=" << bps_event_get_code(event); - return false; - } - - return true; -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp b/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp index d5a9a49ac6..880a914c84 100644 --- a/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp +++ b/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp @@ -127,7 +127,7 @@ bool QQnxVirtualKeyboardPps::connect() } m_buffer = new char[ms_bufferSize]; - if (!m_buffer) { + if (Q_UNLIKELY(!m_buffer)) { qCritical("QQnxVirtualKeyboard: Unable to allocate buffer of %d bytes. " "Size is unavailable.", ms_bufferSize); return false; @@ -170,7 +170,7 @@ void QQnxVirtualKeyboardPps::ppsDataReady() return; // nread is the real space necessary, not the amount read. - if (static_cast<size_t>(nread) > ms_bufferSize - 1) { + if (Q_UNLIKELY(static_cast<size_t>(nread) > ms_bufferSize - 1)) { qCritical("QQnxVirtualKeyboard: Keyboard buffer size too short; need %u.", nread + 1); connect(); // reconnect return; @@ -184,7 +184,7 @@ void QQnxVirtualKeyboardPps::ppsDataReady() #endif const char *value; - if (pps_decoder_get_string(m_decoder, "error", &value) == PPS_DECODER_OK) { + if (Q_UNLIKELY(pps_decoder_get_string(m_decoder, "error", &value) == PPS_DECODER_OK)) { qCritical("QQnxVirtualKeyboard: Keyboard PPS decoder error: %s", value ? value : "[null]"); return; } @@ -214,11 +214,11 @@ void QQnxVirtualKeyboardPps::handleKeyboardInfoMessage() { int newHeight = 0; - if (pps_decoder_push(m_decoder, "dat") != PPS_DECODER_OK) { + if (Q_UNLIKELY(pps_decoder_push(m_decoder, "dat") != PPS_DECODER_OK)) { qCritical("QQnxVirtualKeyboard: Keyboard PPS dat object not found"); return; } - if (pps_decoder_get_int(m_decoder, "size", &newHeight) != PPS_DECODER_OK) { + if (Q_UNLIKELY(pps_decoder_get_int(m_decoder, "size", &newHeight) != PPS_DECODER_OK)) { qCritical("QQnxVirtualKeyboard: Keyboard PPS size field not found"); return; } diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp index 4dc1248bd1..47888178c4 100644 --- a/src/plugins/platforms/qnx/qqnxwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxwindow.cpp @@ -47,12 +47,6 @@ #include <QtCore/QDebug> -#if defined(Q_OS_BLACKBERRY) -#include "qqnxnavigatorcover.h" -#include <sys/pps.h> -#include <bps/navigator.h> -#endif - #include <errno.h> #if defined(QQNXWINDOW_DEBUG) @@ -378,7 +372,7 @@ void QQnxWindow::setBufferSize(const QSize &size) screen_get_window_property_iv(m_window, SCREEN_PROPERTY_RENDER_BUFFER_COUNT, &bufferCount), "Failed to query render buffer count"); - if (bufferCount != MAX_BUFFER_COUNT) { + if (Q_UNLIKELY(bufferCount != MAX_BUFFER_COUNT)) { qFatal("QQnxWindow: invalid buffer count. Expected = %d, got = %d.", MAX_BUFFER_COUNT, bufferCount); } @@ -456,10 +450,10 @@ void QQnxWindow::removeFromParent() qWindowDebug() << "window =" << window(); // Remove from old Hierarchy position if (m_parentWindow) { - if (m_parentWindow->m_childWindows.removeAll(this)) - m_parentWindow = 0; - else + if (Q_UNLIKELY(!m_parentWindow->m_childWindows.removeAll(this))) qFatal("QQnxWindow: Window Hierarchy broken; window has parent, but parent hasn't got child."); + else + m_parentWindow = 0; } else if (m_screen) { m_screen->removeWindow(this); } @@ -633,23 +627,7 @@ QQnxWindow *QQnxWindow::findWindow(screen_window_t windowHandle) void QQnxWindow::minimize() { -#if defined(Q_OS_BLACKBERRY) - qWindowDebug(); - - pps_encoder_t encoder; - - pps_encoder_initialize(&encoder, false); - pps_encoder_add_string(&encoder, "msg", "minimizeWindow"); - - if (navigator_raw_write(pps_encoder_buffer(&encoder), - pps_encoder_length(&encoder)) != BPS_SUCCESS) { - qWindowDebug() << "navigator_raw_write failed:" << strerror(errno); - } - - pps_encoder_cleanup(&encoder); -#else qWarning("Qt::WindowMinimized is not supported by this OS version"); -#endif } void QQnxWindow::setRotation(int rotation) @@ -686,18 +664,8 @@ void QQnxWindow::initWindow() QQnxScreen *platformScreen = static_cast<QQnxScreen *>(window()->screen()->handle()); setScreen(platformScreen); - if (window()->type() == Qt::CoverWindow) { -#if defined(Q_OS_BLACKBERRY) - if (platformScreen->rootWindow()) { - screen_set_window_property_pv(m_screen->rootWindow()->nativeHandle(), - SCREEN_PROPERTY_ALTERNATE_WINDOW, (void**)&m_window); - m_cover.reset(new QQnxNavigatorCover); - } else { - qWarning("No root window for cover window"); - } -#endif + if (window()->type() == Qt::CoverWindow) m_exposed = false; - } // Add window to plugin's window mapper QQnxIntegration::addWindow(m_window, window()); diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index f2f6402889..217444d129 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -188,7 +188,7 @@ void QWindowsUser32DLL::init() // MinGW (g++ 3.4.5) accepts only C casts. setLayeredWindowAttributes = (SetLayeredWindowAttributes)(library.resolve("SetLayeredWindowAttributes")); updateLayeredWindow = (UpdateLayeredWindow)(library.resolve("UpdateLayeredWindow")); - if (!setLayeredWindowAttributes || !updateLayeredWindow) + if (Q_UNLIKELY(!setLayeredWindowAttributes || !updateLayeredWindow)) qFatal("This version of Windows is not supported (User32.dll is missing the symbols 'SetLayeredWindowAttributes', 'UpdateLayeredWindow')."); updateLayeredWindowIndirect = (UpdateLayeredWindowIndirect)(library.resolve("UpdateLayeredWindowIndirect")); diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp index 021058fa33..c68f05b5bb 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.cpp +++ b/src/plugins/platforms/windows/qwindowsdrag.cpp @@ -230,8 +230,6 @@ private: }; typedef QMap<Qt::DropAction, CursorEntry> ActionCursorMap; - typedef ActionCursorMap::Iterator ActionCursorMapIt; - typedef ActionCursorMap::ConstIterator ActionCursorMapConstIt; const Mode m_mode; QWindowsDrag *m_drag; @@ -312,7 +310,7 @@ void QWindowsOleDropSource::createCursors() if (cursorPixmap.isNull() && platformCursor) cursorPixmap = static_cast<QWindowsCursor *>(platformCursor)->dragDefaultCursor(action); const qint64 cacheKey = cursorPixmap.cacheKey(); - const ActionCursorMapIt it = m_cursors.find(action); + const auto it = m_cursors.find(action); if (it != m_cursors.end() && it.value().cacheKey == cacheKey) continue; if (cursorPixmap.isNull()) { @@ -393,7 +391,7 @@ QWindowsOleDropSource::QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState) { HRESULT hr = S_OK; do { - if (fEscapePressed) { + if (fEscapePressed || QWindowsDrag::isCanceled()) { hr = ResultFromScode(DRAGDROP_S_CANCEL); break; } @@ -441,7 +439,7 @@ QWindowsOleDropSource::GiveFeedback(DWORD dwEffect) m_drag->updateAction(action); const qint64 currentCacheKey = m_drag->currentDrag()->dragCursor(action).cacheKey(); - ActionCursorMapConstIt it = m_cursors.constFind(action); + auto it = m_cursors.constFind(action); // If a custom drag cursor is set, check its cache key to detect changes. if (it == m_cursors.constEnd() || (currentCacheKey && currentCacheKey != it.value().cacheKey)) { createCursors(); @@ -673,6 +671,8 @@ QWindowsOleDropTarget::Drop(LPDATAOBJECT pDataObj, DWORD grfKeyState, \ingroup qt-lighthouse-win */ +bool QWindowsDrag::m_canceled = false; + QWindowsDrag::QWindowsDrag() : m_dropDataObject(0), m_cachedDropTargetHelper(0) { @@ -714,6 +714,7 @@ Qt::DropAction QWindowsDrag::drag(QDrag *drag) Qt::DropAction dragResult = Qt::IgnoreAction; DWORD resultEffect; + QWindowsDrag::m_canceled = false; QWindowsOleDropSource *windowDropSource = new QWindowsOleDropSource(this); windowDropSource->createCursors(); QWindowsOleDataObject *dropDataObject = new QWindowsOleDataObject(dropData); diff --git a/src/plugins/platforms/windows/qwindowsdrag.h b/src/plugins/platforms/windows/qwindowsdrag.h index 890ad6c142..ebe949a6af 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.h +++ b/src/plugins/platforms/windows/qwindowsdrag.h @@ -90,6 +90,8 @@ public: Qt::DropAction drag(QDrag *drag) Q_DECL_OVERRIDE; static QWindowsDrag *instance(); + void cancelDrag() Q_DECL_OVERRIDE { QWindowsDrag::m_canceled = true; } + static bool isCanceled() { return QWindowsDrag::m_canceled; } IDataObject *dropDataObject() const { return m_dropDataObject; } void setDropDataObject(IDataObject *dataObject) { m_dropDataObject = dataObject; } @@ -99,6 +101,8 @@ public: IDropTargetHelper* dropHelper(); private: + static bool m_canceled; + QWindowsDropMimeData m_dropData; IDataObject *m_dropDataObject; diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp index 8a2fbe1f6d..8d1bbc75a6 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp @@ -44,6 +44,7 @@ #include <QtCore/qmath.h> #include <QtCore/QDebug> +#include <QtCore/QFile> #include <QtCore/QtEndian> #include <QtCore/QThreadStorage> #include <QtCore/private/qsystemlibrary_p.h> @@ -1062,7 +1063,7 @@ QSharedPointer<QWindowsFontEngineData> sharedFontData() { FontEngineThreadLocalData *data = fontEngineThreadLocalData(); if (!data->hasLocalData()) - data->setLocalData(QSharedPointer<QWindowsFontEngineData>(new QWindowsFontEngineData)); + data->setLocalData(QSharedPointer<QWindowsFontEngineData>::create()); return data->localData(); } #else // !QT_NO_THREAD @@ -1072,7 +1073,7 @@ QWindowsFontEngineDataPtr sharedFontData() { QWindowsFontEngineDataPtr *data = fontEngineData(); if (data->isNull()) - *data = QWindowsFontEngineDataPtr(new QWindowsFontEngineData); + *data = QWindowsFontEngineDataPtr::create(); return *data; } #endif // QT_NO_THREAD @@ -1605,7 +1606,7 @@ LOGFONT QWindowsFontDatabase::fontDefToLOGFONT(const QFontDef &request) lf.lfPitchAndFamily = DEFAULT_PITCH | hint; QString fam = request.family; - if (fam.size() >= LF_FACESIZE) { + if (Q_UNLIKELY(fam.size() >= LF_FACESIZE)) { qCritical("%s: Family name '%s' is too long.", __FUNCTION__, qPrintable(fam)); fam.truncate(LF_FACESIZE - 1); } diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp index 16cc2afef6..361e7f4445 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp @@ -145,10 +145,8 @@ static FontKeys &fontKeys() static const FontKey *findFontKey(const QString &name, int *indexIn = Q_NULLPTR) { - typedef FontKeys::ConstIterator ConstIt; - const FontKeys &keys = fontKeys(); - for (ConstIt it = keys.constBegin(), cend = keys.constEnd(); it != cend; ++it) { + for (auto it = keys.constBegin(), cend = keys.constEnd(); it != cend; ++it) { const int index = it->fontNames.indexOf(name); if (index >= 0) { if (indexIn) diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp index 30417f7cee..41fa8c015d 100644 --- a/src/plugins/platforms/windows/qwindowsfontengine.cpp +++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp @@ -54,6 +54,7 @@ #include <QtGui/private/qpaintengine_raster_p.h> #include <QtCore/QtEndian> +#include <QtCore/QFile> #include <QtCore/qmath.h> #include <QtCore/QThreadStorage> #include <QtCore/private/qsystemlibrary_p.h> @@ -196,7 +197,7 @@ void QWindowsFontEngine::getCMap() designToDevice = QFixed((int)otm->otmEMSquare)/QFixed::fromReal(fontDef.pixelSize); unitsPerEm = otm->otmEMSquare; x_height = (int)otm->otmsXHeight; - loadKerningPairs(QFixed((int)otm->otmEMSquare)/int(otm->otmTextMetrics.tmHeight)); + loadKerningPairs(designToDevice); _faceId.filename = QFile::encodeName(QString::fromWCharArray((wchar_t *)((char *)otm + (quintptr)otm->otmpFullName))); lineWidth = otm->otmsUnderscoreSize; fsType = otm->otmfsType; diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 55e6d55e5b..5f22ca1887 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -61,6 +61,7 @@ #if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER) # include "qwindowssessionmanager.h" #endif +#include <QtGui/qtouchdevice.h> #include <QtGui/private/qguiapplication_p.h> #include <QtGui/private/qhighdpiscaling_p.h> #include <QtGui/qpa/qplatforminputcontextfactory_p.h> @@ -220,11 +221,13 @@ QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList ¶mL if (tabletAbsoluteRange >= 0) m_context.setTabletAbsoluteRange(tabletAbsoluteRange); if (!dpiAwarenessSet) { // Set only once in case of repeated instantiations of QGuiApplication. - m_context.setProcessDpiAwareness(dpiAwareness); + if (!QCoreApplication::testAttribute(Qt::AA_PluginApplication)) { + m_context.setProcessDpiAwareness(dpiAwareness); + qCDebug(lcQpaWindows) + << __FUNCTION__ << "DpiAwareness=" << dpiAwareness; + } dpiAwarenessSet = true; } - qCDebug(lcQpaWindows) - << __FUNCTION__ << "DpiAwareness=" << dpiAwareness; m_context.initTouch(m_options); } diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index e26010b5c4..80f3d3e2b8 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -41,6 +41,7 @@ #include <qpa/qwindowsysteminterface.h> #include <QtGui/QGuiApplication> #include <QtGui/QScreen> +#include <QtGui/QTouchDevice> #include <QtGui/QWindow> #include <QtGui/QCursor> diff --git a/src/plugins/platforms/windows/qwindowsnativeimage.cpp b/src/plugins/platforms/windows/qwindowsnativeimage.cpp index 66e64e64b4..56e18e20d7 100644 --- a/src/plugins/platforms/windows/qwindowsnativeimage.cpp +++ b/src/plugins/platforms/windows/qwindowsnativeimage.cpp @@ -96,7 +96,7 @@ static inline HBITMAP createDIB(HDC hdc, int width, int height, void *bits = 0; HBITMAP bitmap = CreateDIBSection(hdc, reinterpret_cast<BITMAPINFO *>(&bmi), DIB_RGB_COLORS, &bits, 0, 0); - if (!bitmap || !bits) + if (Q_UNLIKELY(!bitmap || !bits)) qFatal("%s: CreateDIBSection failed.", __FUNCTION__); *bitsIn = (uchar*)bits; diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp b/src/plugins/platforms/windows/qwindowstabletsupport.cpp index b27811df9e..d5aae9746d 100644 --- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp +++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp @@ -391,6 +391,7 @@ bool QWindowsTabletSupport::translateTabletPacketEvent() const int currentDevice = m_devices.at(m_currentDevice).currentDevice; const int currentPointer = m_devices.at(m_currentDevice).currentPointerType; + const qint64 uniqueId = m_devices.at(m_currentDevice).uniqueId; // The tablet can be used in 2 different modes, depending on it settings: // 1) Absolute (pen) mode: @@ -407,7 +408,7 @@ bool QWindowsTabletSupport::translateTabletPacketEvent() const QRect virtualDesktopArea = QGuiApplication::primaryScreen()->virtualGeometry(); qCDebug(lcQpaTablet) << __FUNCTION__ << "processing " << packetCount - << "target:" << QGuiApplicationPrivate::tabletPressTarget; + << "target:" << QGuiApplicationPrivate::tabletDevicePoint(uniqueId).target; const Qt::KeyboardModifiers keyboardModifiers = QWindowsKeyMapper::queryKeyboardModifiers(); @@ -420,7 +421,7 @@ bool QWindowsTabletSupport::translateTabletPacketEvent() QPointF globalPosF = m_oldGlobalPosF; m_oldGlobalPosF = m_devices.at(m_currentDevice).scaleCoordinates(packet.pkX, packet.pkY, virtualDesktopArea); - QWindow *target = QGuiApplicationPrivate::tabletPressTarget; // Pass to window that grabbed it. + QWindow *target = QGuiApplicationPrivate::tabletDevicePoint(uniqueId).target; // Pass to window that grabbed it. QPoint globalPos = globalPosF.toPoint(); // Get Mouse Position and compare to tablet info @@ -484,7 +485,7 @@ bool QWindowsTabletSupport::translateTabletPacketEvent() static_cast<Qt::MouseButtons>(packet.pkButtons), pressureNew, tiltX, tiltY, tangentialPressure, rotation, z, - m_devices.at(m_currentDevice).uniqueId, + uniqueId, keyboardModifiers); } return true; diff --git a/src/plugins/platforms/winrt/qwinrteglcontext.cpp b/src/plugins/platforms/winrt/qwinrteglcontext.cpp index 3fd0278360..1008e1c5e8 100644 --- a/src/plugins/platforms/winrt/qwinrteglcontext.cpp +++ b/src/plugins/platforms/winrt/qwinrteglcontext.cpp @@ -55,7 +55,7 @@ struct WinRTEGLDisplay { WinRTEGLDisplay() { eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); - if (eglDisplay == EGL_NO_DISPLAY) + if (Q_UNLIKELY(eglDisplay == EGL_NO_DISPLAY)) qCritical("Failed to initialize EGL display: 0x%x", eglGetError()); } ~WinRTEGLDisplay() { @@ -114,10 +114,10 @@ void QWinRTEGLContext::initialize() EGL_NONE, }; g->eglDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, displayAttributes); - if (g->eglDisplay == EGL_NO_DISPLAY) + if (Q_UNLIKELY(g->eglDisplay == EGL_NO_DISPLAY)) qCritical("Failed to initialize EGL display: 0x%x", eglGetError()); - if (!eglInitialize(g->eglDisplay, nullptr, nullptr)) + if (Q_UNLIKELY(!eglInitialize(g->eglDisplay, nullptr, nullptr))) qCritical("Failed to initialize EGL: 0x%x", eglGetError()); d->eglConfig = q_configFromGLFormat(g->eglDisplay, d->format); diff --git a/src/plugins/platforms/winrt/qwinrtwindow.cpp b/src/plugins/platforms/winrt/qwinrtwindow.cpp index bec94c1e51..8a53047d1e 100644 --- a/src/plugins/platforms/winrt/qwinrtwindow.cpp +++ b/src/plugins/platforms/winrt/qwinrtwindow.cpp @@ -180,7 +180,7 @@ QWinRTWindow::~QWinRTWindow() EGLBoolean value = eglDestroySurface(d->display, d->surface); d->surface = EGL_NO_SURFACE; - if (value == EGL_FALSE) + if (Q_UNLIKELY(value == EGL_FALSE)) qCritical("Failed to destroy EGL window surface: 0x%x", eglGetError()); } @@ -321,7 +321,7 @@ void QWinRTWindow::createEglSurface(EGLDisplay display, EGLConfig config) d->surface = eglCreateWindowSurface(display, config, reinterpret_cast<EGLNativeWindowType>(winId()), nullptr); - if (d->surface == EGL_NO_SURFACE) + if (Q_UNLIKELY(d->surface == EGL_NO_SURFACE)) qCritical("Failed to create EGL window surface: 0x%x", eglGetError()); return S_OK; }); 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 37f01d4eed..e1fb63fbc4 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp @@ -99,7 +99,7 @@ static Window createDummyWindow(Display *dpy, XVisualInfo *visualInfo, int scree static Window createDummyWindow(Display *dpy, GLXFBConfig config, int screenNumber, Window rootWin) { XVisualInfo *visualInfo = glXGetVisualFromFBConfig(dpy, config); - if (!visualInfo) + if (Q_UNLIKELY(!visualInfo)) qFatal("Could not initialize GLX"); Window window = createDummyWindow(dpy, visualInfo, screenNumber, rootWin); XFree(visualInfo); @@ -301,7 +301,7 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share) // Note that m_format gets updated with the used surface format visualInfo = qglx_findVisualInfo(m_display, screen->screenNumber(), &m_format); - if (!visualInfo) + if (Q_UNLIKELY(!visualInfo)) qFatal("Could not initialize GLX"); m_context = glXCreateContext(m_display, visualInfo, m_shareContext, true); if (!m_context && m_shareContext) { diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 50d49ca798..ff39b24e93 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -521,7 +521,7 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra m_connection = xcb_connect(m_displayName.constData(), &m_primaryScreenNumber); #endif //XCB_USE_XLIB - if (!m_connection || xcb_connection_has_error(m_connection)) + if (Q_UNLIKELY(!m_connection || xcb_connection_has_error(m_connection))) qFatal("QXcbConnection: Could not connect to display %s", m_displayName.constData()); @@ -553,7 +553,7 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra initializeXFixes(); initializeScreens(); - if (m_screens.isEmpty()) + if (Q_UNLIKELY(m_screens.isEmpty())) qFatal("QXcbConnection: no screens available"); initializeXRender(); diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp index 2e088d3ca5..0bfefc962e 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp @@ -1511,11 +1511,13 @@ void QXcbKeyboard::handleKeyEvent(xcb_window_t sourceWindow, QEvent::Type type, QWindow *window = targetWindow->window(); if (!filtered) { +#ifndef QT_NO_CONTEXTMENU if (type == QEvent::KeyPress && qtcode == Qt::Key_Menu) { const QPoint globalPos = window->screen()->handle()->cursor()->pos(); const QPoint pos = window->mapFromGlobal(globalPos); QWindowSystemInterface::handleContextMenuEvent(window, false, pos, globalPos, modifiers); } +#endif // QT_NO_CONTEXTMENU QWindowSystemInterface::handleExtendedKeyEvent(window, time, type, qtcode, modifiers, code, sym, state, string, isAutoRepeat); } diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 0e99d58679..db7d837e01 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -182,8 +182,6 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, QXcbVirtualDesktop *virtualDe updateRefreshRate(crtc->mode); free(crtc); } - } else { - updateGeometry(output ? output->timestamp : 0); } if (m_geometry.isEmpty()) { diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 6023ee6b29..3e01a90402 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -395,7 +395,7 @@ void QXcbWindow::create() if (!visualInfo) visualInfo = static_cast<XVisualInfo *>(createVisual()); - if (!visualInfo && window()->surfaceType() == QSurface::OpenGLSurface) + if (Q_UNLIKELY(!visualInfo && window()->surfaceType() == QSurface::OpenGLSurface)) qFatal("Could not initialize OpenGL"); if (!visualInfo && window()->surfaceType() == QSurface::RasterGLSurface) { @@ -1096,6 +1096,7 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags) } setWmWindowType(wmWindowTypes, flags); + setNetWmStateWindowFlags(flags); setMotifWindowFlags(flags); setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput); @@ -1331,6 +1332,15 @@ void QXcbWindow::updateNetWmStateBeforeMap() setNetWmStates(states); } +void QXcbWindow::setNetWmStateWindowFlags(Qt::WindowFlags flags) +{ + changeNetWmState(flags & Qt::WindowStaysOnTopHint, + atom(QXcbAtom::_NET_WM_STATE_ABOVE), + atom(QXcbAtom::_NET_WM_STATE_STAYS_ON_TOP)); + changeNetWmState(flags & Qt::WindowStaysOnBottomHint, + atom(QXcbAtom::_NET_WM_STATE_BELOW)); +} + void QXcbWindow::updateNetWmUserTime(xcb_timestamp_t timestamp) { xcb_window_t wid = m_window; diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index 43e66a774d..c42c98c205 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -184,6 +184,7 @@ protected: void setNetWmStates(NetWmStates); void setMotifWindowFlags(Qt::WindowFlags flags); + void setNetWmStateWindowFlags(Qt::WindowFlags flags); void updateMotifWmHintsBeforeMap(); void updateNetWmStateBeforeMap(); |