summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/android/androidjniaccessibility.cpp7
-rw-r--r--src/plugins/platforms/android/androidjnimain.cpp4
-rw-r--r--src/plugins/platforms/android/androidjnimenu.cpp9
-rw-r--r--src/plugins/platforms/android/qandroideventdispatcher.cpp18
-rw-r--r--src/plugins/platforms/android/qandroideventdispatcher.h3
-rw-r--r--src/plugins/platforms/android/qandroidinputcontext.cpp20
-rw-r--r--src/plugins/platforms/android/qandroidplatformfontdatabase.cpp2
-rw-r--r--src/plugins/platforms/android/qandroidplatformintegration.cpp6
-rw-r--r--src/plugins/platforms/android/qandroidplatformopenglwindow.cpp2
-rw-r--r--src/plugins/platforms/android/qandroidplatformtheme.cpp6
-rw-r--r--src/plugins/platforms/cocoa/cocoa.pro2
-rw-r--r--src/plugins/platforms/cocoa/main.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibility.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibility.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplication.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoabackingstore.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm6
-rw-r--r--src/plugins/platforms/cocoa/qcocoacursor.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoadrag.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm6
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.h5
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.mm257
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.h5
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm9
-rw-r--r--src/plugins/platforms/cocoa/qcocoakeymapper.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenubar.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenuitem.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenuloader.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoanativeinterface.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoanativeinterface.mm7
-rw-r--r--src/plugins/platforms/cocoa/qcocoaservices.mm6
-rw-r--r--src/plugins/platforms/cocoa/qcocoasystemsettings.mm29
-rw-r--r--src/plugins/platforms/cocoa/qcocoatheme.h5
-rw-r--r--src/plugins/platforms/cocoa/qcocoatheme.mm59
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm17
-rw-r--r--src/plugins/platforms/cocoa/qmacclipboard.h2
-rw-r--r--src/plugins/platforms/cocoa/qmacdefines_mac.h2
-rw-r--r--src/plugins/platforms/cocoa/qmultitouch_mac_p.h2
-rw-r--r--src/plugins/platforms/cocoa/qnsview.h2
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm1
-rw-r--r--src/plugins/platforms/cocoa/qnsviewaccessibility.mm2
-rw-r--r--src/plugins/platforms/cocoa/qnswindowdelegate.h2
-rw-r--r--src/plugins/platforms/cocoa/qprintengine_mac.mm2
-rw-r--r--src/plugins/platforms/cocoa/qt_mac_p.h32
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2ddevicecontext.cpp2
-rw-r--r--src/plugins/platforms/directfb/qdirectfbblitter.cpp4
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsdevice.cpp10
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.cpp4
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp24
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp2
-rw-r--r--src/plugins/platforms/eglfs/qeglfscursor.cpp1
-rw-r--r--src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp19
-rw-r--r--src/plugins/platforms/eglfs/qeglfsdeviceintegration.h4
-rw-r--r--src/plugins/platforms/eglfs/qeglfsintegration.cpp4
-rw-r--r--src/plugins/platforms/eglfs/qeglfswindow.cpp20
-rw-r--r--src/plugins/platforms/haiku/qhaikuwindow.cpp2
-rw-r--r--src/plugins/platforms/ios/ios.pro8
-rw-r--r--src/plugins/platforms/ios/qiosbackingstore.h21
-rw-r--r--src/plugins/platforms/ios/qiosbackingstore.mm111
-rw-r--r--src/plugins/platforms/ios/qioseventdispatcher.mm4
-rw-r--r--src/plugins/platforms/ios/qiosintegration.h2
-rw-r--r--src/plugins/platforms/ios/qiosintegration.mm11
-rw-r--r--src/plugins/platforms/ios/qiosmenu.h3
-rw-r--r--src/plugins/platforms/ios/qiosmenu.mm38
-rw-r--r--src/plugins/platforms/ios/qiosmessagedialog.h (renamed from src/plugins/platforms/qnx/qqnxvirtualkeyboardbps.h)45
-rw-r--r--src/plugins/platforms/ios/qiosmessagedialog.mm135
-rw-r--r--src/plugins/platforms/ios/qiostheme.mm5
-rw-r--r--src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp5
-rw-r--r--src/plugins/platforms/minimalegl/qminimaleglscreen.cpp12
-rw-r--r--src/plugins/platforms/mirclient/qmirclientclipboard.cpp7
-rw-r--r--src/plugins/platforms/mirclient/qmirclientglcontext.cpp10
-rw-r--r--src/plugins/platforms/mirclient/qmirclientintegration.cpp2
-rw-r--r--src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp4
-rw-r--r--src/plugins/platforms/openwfd/qopenwfdport.cpp7
-rw-r--r--src/plugins/platforms/qnx/qblackberrytheme.cpp119
-rw-r--r--src/plugins/platforms/qnx/qblackberrytheme.h73
-rw-r--r--src/plugins/platforms/qnx/qnx.pro51
-rw-r--r--src/plugins/platforms/qnx/qqnxbpseventfilter.cpp229
-rw-r--r--src/plugins/platforms/qnx/qqnxbpseventfilter.h82
-rw-r--r--src/plugins/platforms/qnx/qqnxbuffer.cpp6
-rw-r--r--src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp2
-rw-r--r--src/plugins/platforms/qnx/qqnxeglwindow.cpp14
-rw-r--r--src/plugins/platforms/qnx/qqnxeventdispatcher_blackberry.cpp68
-rw-r--r--src/plugins/platforms/qnx/qqnxeventdispatcher_blackberry.h58
-rw-r--r--src/plugins/platforms/qnx/qqnxfiledialoghelper.h87
-rw-r--r--src/plugins/platforms/qnx/qqnxfiledialoghelper_bb10.cpp212
-rw-r--r--src/plugins/platforms/qnx/qqnxfilepicker.cpp322
-rw-r--r--src/plugins/platforms/qnx/qqnxfilepicker.h107
-rw-r--r--src/plugins/platforms/qnx/qqnxglcontext.cpp18
-rw-r--r--src/plugins/platforms/qnx/qqnxglobal.cpp4
-rw-r--r--src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp27
-rw-r--r--src/plugins/platforms/qnx/qqnxintegration.cpp89
-rw-r--r--src/plugins/platforms/qnx/qqnxintegration.h10
-rw-r--r--src/plugins/platforms/qnx/qqnxnativeinterface.cpp5
-rw-r--r--src/plugins/platforms/qnx/qqnxnavigatorbps.cpp66
-rw-r--r--src/plugins/platforms/qnx/qqnxnavigatorbps.h54
-rw-r--r--src/plugins/platforms/qnx/qqnxnavigatorcover.cpp57
-rw-r--r--src/plugins/platforms/qnx/qqnxnavigatorcover.h52
-rw-r--r--src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp6
-rw-r--r--src/plugins/platforms/qnx/qqnxnavigatorpps.cpp8
-rw-r--r--src/plugins/platforms/qnx/qqnxrasterwindow.cpp2
-rw-r--r--src/plugins/platforms/qnx/qqnxscreen.cpp4
-rw-r--r--src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp13
-rw-r--r--src/plugins/platforms/qnx/qqnxsystemsettings.cpp74
-rw-r--r--src/plugins/platforms/qnx/qqnxsystemsettings.h48
-rw-r--r--src/plugins/platforms/qnx/qqnxvirtualkeyboardbps.cpp217
-rw-r--r--src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp10
-rw-r--r--src/plugins/platforms/qnx/qqnxwindow.cpp42
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowscursor.cpp15
-rw-r--r--src/plugins/platforms/windows/qwindowscursor.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsdrag.cpp11
-rw-r--r--src/plugins/platforms/windows/qwindowsdrag.h4
-rw-r--r--src/plugins/platforms/windows/qwindowsfontdatabase.cpp7
-rw-r--r--src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp4
-rw-r--r--src/plugins/platforms/windows/qwindowsfontengine.cpp3
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.cpp16
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsmousehandler.cpp1
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeimage.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeinterface.cpp21
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeinterface.h6
-rw-r--r--src/plugins/platforms/windows/qwindowstabletsupport.cpp7
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.cpp53
-rw-r--r--src/plugins/platforms/winrt/qwinrteglcontext.cpp2
-rw-r--r--src/plugins/platforms/winrt/qwinrtwindow.cpp4
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.cpp17
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationplugin.h3
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp4
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp26
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h16
-rw-r--r--src/plugins/platforms/xcb/qxcbcursor.h5
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.cpp13
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.h2
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.cpp2
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.cpp41
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.h4
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp12
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.h1
146 files changed, 947 insertions, 2706 deletions
diff --git a/src/plugins/platforms/android/androidjniaccessibility.cpp b/src/plugins/platforms/android/androidjniaccessibility.cpp
index 69f8bdbad7..385ad3b672 100644
--- a/src/plugins/platforms/android/androidjniaccessibility.cpp
+++ b/src/plugins/platforms/android/androidjniaccessibility.cpp
@@ -68,10 +68,6 @@ namespace QtAndroidAccessibility
void initialize()
{
- // API level > 16 is required.
- if (QtAndroidPrivate::androidSdkVersion() < 16)
- return;
-
QJNIObjectPrivate::callStaticMethod<void>(QtAndroid::applicationClass(),
"initializeAccessibility");
}
@@ -299,9 +295,6 @@ if (!clazz) { \
bool registerNatives(JNIEnv *env)
{
- if (QtAndroidPrivate::androidSdkVersion() < 16)
- return true; // We need API level 16 or higher
-
jclass clazz;
FIND_AND_CHECK_CLASS("org/qtproject/qt5/android/accessibility/QtNativeAccessibility");
jclass appClass = static_cast<jclass>(env->NewGlobalRef(clazz));
diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp
index dd9154f8d2..7045533fca 100644
--- a/src/plugins/platforms/android/androidjnimain.cpp
+++ b/src/plugins/platforms/android/androidjnimain.cpp
@@ -494,7 +494,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;
}
@@ -504,7 +504,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/androidjnimenu.cpp b/src/plugins/platforms/android/androidjnimenu.cpp
index 8018cef1dc..3f44a3c4b9 100644
--- a/src/plugins/platforms/android/androidjnimenu.cpp
+++ b/src/plugins/platforms/android/androidjnimenu.cpp
@@ -87,14 +87,7 @@ namespace QtAndroidMenu
void showContextMenu(QAndroidPlatformMenu *menu, const QRect &anchorRect, JNIEnv *env)
{
QMutexLocker lock(&visibleMenuMutex);
- if (QtAndroidPrivate::androidSdkVersion() > 10 &&
- QtAndroidPrivate::androidSdkVersion() < 14 &&
- anchorRect.isValid()) {
- pendingContextMenus.clear();
- } else if (visibleMenu) {
- pendingContextMenus.append(visibleMenu);
- }
-
+ pendingContextMenus.append(visibleMenu);
visibleMenu = menu;
menu->aboutToShow();
env->CallStaticVoidMethod(applicationClass(), openContextMenuMethodID, anchorRect.x(), anchorRect.y(), anchorRect.width(), anchorRect.height());
diff --git a/src/plugins/platforms/android/qandroideventdispatcher.cpp b/src/plugins/platforms/android/qandroideventdispatcher.cpp
index aecea0d4e1..3f1cfe18b9 100644
--- a/src/plugins/platforms/android/qandroideventdispatcher.cpp
+++ b/src/plugins/platforms/android/qandroideventdispatcher.cpp
@@ -77,8 +77,11 @@ void QAndroidEventDispatcher::goingToStop(bool stop)
wakeUp();
}
-int QAndroidEventDispatcher::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, timespec *timeout)
+bool QAndroidEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
{
+ if (m_goingToStop.load())
+ flags |= QEventLoop::ExcludeSocketNotifiers | QEventLoop::X11ExcludeTimers;
+
{
AndroidDeadlockProtector protector;
if (protector.acquire() && m_stopRequest.testAndSetAcquire(StopRequest, Stopping)) {
@@ -86,21 +89,10 @@ int QAndroidEventDispatcher::select(int nfds, fd_set *readfds, fd_set *writefds,
wakeUp();
}
}
- return QUnixEventDispatcherQPA::select(nfds, readfds, writefds, exceptfds, timeout);
-}
-bool QAndroidEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
-{
- if (m_goingToStop.load()) {
- return QUnixEventDispatcherQPA::processEvents(flags /*| QEventLoop::ExcludeUserInputEvents*/
- | QEventLoop::ExcludeSocketNotifiers
- | QEventLoop::X11ExcludeTimers);
- } else {
- return QUnixEventDispatcherQPA::processEvents(flags);
- }
+ return QUnixEventDispatcherQPA::processEvents(flags);
}
-
QAndroidEventDispatcherStopper *QAndroidEventDispatcherStopper::instance()
{
static QAndroidEventDispatcherStopper androidEventDispatcherStopper;
diff --git a/src/plugins/platforms/android/qandroideventdispatcher.h b/src/plugins/platforms/android/qandroideventdispatcher.h
index 946bae5b20..e2c4770467 100644
--- a/src/plugins/platforms/android/qandroideventdispatcher.h
+++ b/src/plugins/platforms/android/qandroideventdispatcher.h
@@ -50,9 +50,6 @@ public:
void goingToStop(bool stop);
protected:
- int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
- timespec *timeout);
-
bool processEvents(QEventLoop::ProcessEventsFlags flags);
private:
diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp
index 0eddb26959..2e4c3d71ab 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 5725f5793e..a21aac51b4 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 &para
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 723c341e59..e8d69e9dbb 100644
--- a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
+++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
@@ -336,6 +336,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;
@@ -347,6 +348,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..b83977c7d8 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.h
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.h
@@ -46,6 +46,7 @@
//
#include "qt_mac_p.h"
#include <private/qguiapplication_p.h>
+#include <QtGui/qpalette.h>
#include <QtGui/qscreen.h>
QT_BEGIN_NAMESPACE
@@ -66,6 +67,7 @@ NSImage *qt_mac_create_nsimage(const QIcon &icon);
CGImageRef qt_mac_toCGImage(const QImage &qImage);
CGImageRef qt_mac_toCGImageMask(const QImage &qImage);
QImage qt_mac_toQImage(CGImageRef image);
+QPixmap qt_mac_toQPixmap(const NSImage *image, const QSizeF &size);
NSSize qt_mac_toNSSize(const QSize &qtSize);
NSRect qt_mac_toNSRect(const QRect &rect);
@@ -74,6 +76,8 @@ QRect qt_mac_toQRect(const NSRect &rect);
QColor qt_mac_toQColor(const NSColor *color);
QColor qt_mac_toQColor(CGColorRef color);
+QBrush qt_mac_toQBrush(CGColorRef color);
+QBrush qt_mac_toQBrush(const NSColor *color, QPalette::ColorGroup colorGroup = QPalette::Normal);
// Creates a mutable shape, it's the caller's responsibility to release.
HIMutableShapeRef qt_mac_QRegionToHIMutableShape(const QRegion &region);
@@ -90,7 +94,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 7bc8d6585b..de27175bbd 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,27 @@
#include <algorithm>
+#include <Carbon/Carbon.h>
+
+@interface NSGraphicsContext (QtAdditions)
+
++ (NSGraphicsContext *)qt_graphicsContextWithCGContext:(CGContextRef)graphicsPort flipped:(BOOL)initialFlippedState;
+
+@end
+
+@implementation NSGraphicsContext (QtAdditions)
+
++ (NSGraphicsContext *)qt_graphicsContextWithCGContext:(CGContextRef)graphicsPort flipped:(BOOL)initialFlippedState
+{
+#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_10, __IPHONE_NA)
+ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_10)
+ return [self graphicsContextWithCGContext:graphicsPort flipped:initialFlippedState];
+#endif
+ return [self graphicsContextWithGraphicsPort:graphicsPort flipped:initialFlippedState];
+}
+
+@end
+
QT_BEGIN_NAMESPACE
//
@@ -236,6 +259,125 @@ QColor qt_mac_toQColor(CGColorRef color)
return qtColor;
}
+QBrush qt_mac_toQBrush(CGColorRef color)
+{
+ QBrush qtBrush;
+ CGColorSpaceModel model = CGColorSpaceGetModel(CGColorGetColorSpace(color));
+ if (model == kCGColorSpaceModelPattern) {
+ // Colorspace we can't deal with; the color is drawn directly using a callback.
+ qWarning("Qt: qt_mac_toQBrush: cannot convert from colorspace model: %d", model);
+ Q_ASSERT(false);
+ } else {
+ qtBrush.setStyle(Qt::SolidPattern);
+ qtBrush.setColor(qt_mac_toQColor(color));
+ }
+ return qtBrush;
+}
+
+static bool qt_mac_isSystemColorOrInstance(const NSColor *color, NSString *colorNameComponent, NSString *className)
+{
+ // We specifically do not want isKindOfClass: here
+ if ([color.className isEqualToString:className]) // NSPatternColorSpace
+ return true;
+ if ([color.catalogNameComponent isEqualToString:@"System"] &&
+ [color.colorNameComponent isEqualToString:colorNameComponent] &&
+ [color.colorSpaceName isEqualToString:NSNamedColorSpace])
+ return true;
+ return false;
+}
+
+QBrush qt_mac_toQBrush(const NSColor *color, QPalette::ColorGroup colorGroup)
+{
+ QBrush qtBrush;
+
+ // QTBUG-49773: This calls NSDrawMenuItemBackground to render a 1 by n gradient; could use HITheme
+ if ([color.className isEqualToString:@"NSMenuItemHighlightColor"]) {
+ qWarning("Qt: qt_mac_toQBrush: cannot convert from NSMenuItemHighlightColor");
+ return qtBrush;
+ }
+
+ // Not a catalog color or a manifestation of System.windowBackgroundColor;
+ // only retrieved from NSWindow.backgroundColor directly
+ if ([color.className isEqualToString:@"NSMetalPatternColor"]) {
+ // NSTexturedBackgroundWindowMask, could theoretically handle this without private API by
+ // creating a window with the appropriate properties and then calling NSWindow.backgroundColor.patternImage,
+ // which returns a texture sized 1 by (window height, including frame), backed by a CGPattern
+ // which follows the window key state... probably need to allow QBrush to store a function pointer
+ // like CGPattern does
+ qWarning("Qt: qt_mac_toQBrush: cannot convert from NSMetalPatternColor");
+ return qtBrush;
+ }
+
+ // No public API to get these colors/stops;
+ // both accurately obtained through runtime object inspection on OS X 10.11
+ // (the NSColor object has NSGradient i-vars for both color groups)
+ if (qt_mac_isSystemColorOrInstance(color, @"_sourceListBackgroundColor", @"NSSourceListBackgroundColor")) {
+ QLinearGradient gradient;
+ if (colorGroup == QPalette::Active) {
+ gradient.setColorAt(0, QColor(233, 237, 242));
+ gradient.setColorAt(0.5, QColor(225, 229, 235));
+ gradient.setColorAt(1, QColor(209, 216, 224));
+ } else {
+ gradient.setColorAt(0, QColor(248, 248, 248));
+ gradient.setColorAt(0.5, QColor(240, 240, 240));
+ gradient.setColorAt(1, QColor(235, 235, 235));
+ }
+ return QBrush(gradient);
+ }
+
+ // A couple colors are special... they are actually instances of NSGradientPatternColor, which
+ // override set/setFill/setStroke to instead initialize an internal color
+ // ([NSColor colorWithCalibratedWhite:0.909804 alpha:1.000000]) while still returning the
+ // ruled lines pattern image (from OS X 10.4) to the user from -[NSColor patternImage]
+ // (and providing no public API to get the underlying color without this insanity)
+ if (qt_mac_isSystemColorOrInstance(color, @"controlColor", @"NSGradientPatternColor") ||
+ qt_mac_isSystemColorOrInstance(color, @"windowBackgroundColor", @"NSGradientPatternColor")) {
+ static QColor newColor;
+ if (!newColor.isValid()) {
+#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_8, __IPHONE_NA)
+ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_8) {
+ newColor = qt_mac_toQColor(color.CGColor);
+ } else
+#endif
+ {
+ NSBitmapImageRep *offscreenRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:nil
+ pixelsWide:1
+ pixelsHigh:1
+ bitsPerSample:8
+ samplesPerPixel:4
+ hasAlpha:YES
+ isPlanar:NO
+ colorSpaceName:NSDeviceRGBColorSpace
+ bytesPerRow:4
+ bitsPerPixel:32];
+ [NSGraphicsContext saveGraphicsState];
+ [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithBitmapImageRep:offscreenRep]];
+ NSEraseRect(NSMakeRect(0, 0, 1, 1));
+ [color drawSwatchInRect:NSMakeRect(0, 0, 1, 1)];
+ [NSGraphicsContext restoreGraphicsState];
+ NSUInteger pixel[4];
+ [offscreenRep getPixel:pixel atX:0 y:0];
+ [offscreenRep release];
+ newColor = QColor(pixel[0], pixel[1], pixel[2], pixel[3]);
+ }
+ }
+
+ qtBrush.setStyle(Qt::SolidPattern);
+ qtBrush.setColor(newColor);
+ return qtBrush;
+ }
+
+ if (NSColor *patternColor = [color colorUsingColorSpaceName:NSPatternColorSpace]) {
+ NSImage *patternImage = patternColor.patternImage;
+ const QSizeF sz(patternImage.size.width, patternImage.size.height);
+ qtBrush.setTexture(qt_mac_toQPixmap(patternImage, sz)); // QTBUG-49774
+ } else {
+ qtBrush.setStyle(Qt::SolidPattern);
+ qtBrush.setColor(qt_mac_toQColor(color));
+ }
+ return qtBrush;
+}
+
// Use this method to keep all the information in the TextSegment. As long as it is ordered
// we are in OK shape, and we can influence that ourselves.
struct KeyPair
@@ -439,88 +581,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;
@@ -775,7 +878,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
@@ -821,6 +924,26 @@ CGContextRef qt_mac_cg_context(QPaintDevice *pdev)
return ret;
}
+QPixmap qt_mac_toQPixmap(const NSImage *image, const QSizeF &size)
+{
+ const NSSize pixmapSize = NSMakeSize(size.width(), size.height());
+ QPixmap pixmap(pixmapSize.width, pixmapSize.height);
+ pixmap.fill(Qt::transparent);
+ [image setSize:pixmapSize];
+ const NSRect iconRect = NSMakeRect(0, 0, pixmapSize.width, pixmapSize.height);
+ QMacCGContext ctx(&pixmap);
+ if (!ctx)
+ return QPixmap();
+ NSGraphicsContext *gc = [NSGraphicsContext qt_graphicsContextWithCGContext:ctx flipped:YES];
+ if (!gc)
+ return QPixmap();
+ [NSGraphicsContext saveGraphicsState];
+ [NSGraphicsContext setCurrentContext:gc];
+ [image drawInRect:iconRect fromRect:iconRect operation:NSCompositeSourceOver fraction:1.0 respectFlipped:YES hints:nil];
+ [NSGraphicsContext restoreGraphicsState];
+ return pixmap;
+}
+
QImage qt_mac_toQImage(CGImageRef image)
{
const size_t w = CGImageGetWidth(image),
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h
index e7e21c356a..7943926ba3 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"
@@ -148,6 +148,9 @@ public:
QList<QCocoaWindow *> *popupWindowStack();
void setApplicationIcon(const QIcon &icon) const Q_DECL_OVERRIDE;
+
+ void beep() const Q_DECL_OVERRIDE;
+
private:
static QCocoaIntegration *mInstance;
Options mOptions;
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index 6bec6b191d..245cfe33be 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -317,7 +317,7 @@ QCocoaIntegration::QCocoaIntegration(const QStringList &paramList)
// ### 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];
@@ -614,4 +614,9 @@ void QCocoaIntegration::setApplicationIcon(const QIcon &icon) const
[image release];
}
+void QCocoaIntegration::beep() const
+{
+ NSBeep();
+}
+
QT_END_NAMESPACE
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.h b/src/plugins/platforms/cocoa/qcocoanativeinterface.h
index d018c05635..e46a622d3a 100644
--- a/src/plugins/platforms/cocoa/qcocoanativeinterface.h
+++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.h
@@ -60,8 +60,6 @@ public:
NativeResourceForIntegrationFunction nativeResourceFunctionForIntegration(const QByteArray &resource) Q_DECL_OVERRIDE;
- Q_INVOKABLE void beep();
-
#ifndef QT_NO_OPENGL
static void *cglContextForContext(QOpenGLContext *context);
static void *nsOpenGLContextForContext(QOpenGLContext* context);
diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
index baee451903..542a26d409 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
@@ -139,11 +139,6 @@ QPlatformNativeInterface::NativeResourceForIntegrationFunction QCocoaNativeInter
return 0;
}
-void QCocoaNativeInterface::beep()
-{
- NSBeep();
-}
-
QPlatformPrinterSupport *QCocoaNativeInterface::createPlatformPrinterSupport()
{
#if !defined(QT_NO_WIDGETS) && !defined(QT_NO_PRINTER)
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/qcocoasystemsettings.mm b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm
index 93f8b2ba6f..91a3214da3 100644
--- a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm
+++ b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm
@@ -42,13 +42,13 @@
QT_BEGIN_NAMESPACE
-QColor qt_mac_colorForTheme(ThemeBrush brush)
+QBrush qt_mac_brushForTheme(ThemeBrush brush)
{
QMacAutoReleasePool pool;
QCFType<CGColorRef> cgClr = 0;
HIThemeBrushCreateCGColor(brush, &cgClr);
- return qt_mac_toQColor(cgClr);
+ return qt_mac_toQBrush(cgClr);
}
QColor qt_mac_colorForThemeTextColor(ThemeTextColor themeColor)
@@ -86,25 +86,29 @@ QPalette * qt_mac_createSystemPalette()
QColor qc;
// Standard palette initialization (copied from Qt 4 styles)
- QColor background = QColor(237, 237, 237);
+ QBrush backgroundBrush = qt_mac_toQBrush([NSColor windowBackgroundColor]);
+ QColor background = backgroundBrush.color();
QColor light(background.lighter(110));
QColor dark(background.darker(160));
QColor mid(background.darker(140));
QPalette *palette = new QPalette(Qt::black, background, light, dark, mid, Qt::black, Qt::white);
+ palette->setBrush(QPalette::Window, backgroundBrush);
+
palette->setBrush(QPalette::Disabled, QPalette::WindowText, dark);
palette->setBrush(QPalette::Disabled, QPalette::Text, dark);
palette->setBrush(QPalette::Disabled, QPalette::ButtonText, dark);
- palette->setBrush(QPalette::Disabled, QPalette::Base, background);
+ palette->setBrush(QPalette::Disabled, QPalette::Base, backgroundBrush);
palette->setColor(QPalette::Disabled, QPalette::Dark, QColor(191, 191, 191));
palette->setColor(QPalette::Active, QPalette::Dark, QColor(191, 191, 191));
palette->setColor(QPalette::Inactive, QPalette::Dark, QColor(191, 191, 191));
// System palette initialization:
- palette->setBrush(QPalette::Active, QPalette::Highlight, qt_mac_colorForTheme(kThemeBrushPrimaryHighlightColor));
- qc = qt_mac_colorForTheme(kThemeBrushSecondaryHighlightColor);
- palette->setBrush(QPalette::Inactive, QPalette::Highlight, qc);
- palette->setBrush(QPalette::Disabled, QPalette::Highlight, qc);
+ palette->setBrush(QPalette::Active, QPalette::Highlight,
+ qt_mac_toQBrush([NSColor selectedControlColor]));
+ QBrush br = qt_mac_toQBrush([NSColor secondarySelectedControlColor]);
+ palette->setBrush(QPalette::Inactive, QPalette::Highlight, br);
+ palette->setBrush(QPalette::Disabled, QPalette::Highlight, br);
palette->setBrush(QPalette::Shadow, background.darker(170));
@@ -168,8 +172,7 @@ QHash<QPlatformTheme::Palette, QPalette*> qt_mac_createRolePalettes()
pal.setColor(QPalette::Disabled, QPalette::HighlightedText, qc);
}
if (mac_widget_colors[i].paletteRole == QPlatformTheme::MenuPalette) {
- qc = qt_mac_colorForTheme(kThemeBrushMenuBackground);
- pal.setBrush(QPalette::Background, qc);
+ pal.setBrush(QPalette::Background, qt_mac_brushForTheme(kThemeBrushMenuBackground));
qc = qt_mac_colorForThemeTextColor(kThemeTextColorMenuItemActive);
pal.setBrush(QPalette::ButtonText, qc);
qc = qt_mac_colorForThemeTextColor(kThemeTextColorMenuItemSelected);
@@ -186,9 +189,9 @@ QHash<QPlatformTheme::Palette, QPalette*> qt_mac_createRolePalettes()
pal.color(QPalette::Active, QPalette::Text));
} else if (mac_widget_colors[i].paletteRole == QPlatformTheme::ItemViewPalette) {
pal.setBrush(QPalette::Active, QPalette::Highlight,
- qt_mac_colorForTheme(kThemeBrushAlternatePrimaryHighlightColor));
- qc = qt_mac_colorForThemeTextColor(kThemeTextColorMenuItemSelected);
- pal.setBrush(QPalette::Active, QPalette::HighlightedText, qc);
+ qt_mac_toQBrush([NSColor alternateSelectedControlColor]));
+ pal.setBrush(QPalette::Active, QPalette::HighlightedText,
+ qt_mac_toQBrush([NSColor alternateSelectedControlTextColor]));
pal.setBrush(QPalette::Inactive, QPalette::Text,
pal.brush(QPalette::Active, QPalette::Text));
pal.setBrush(QPalette::Inactive, QPalette::HighlightedText,
diff --git a/src/plugins/platforms/cocoa/qcocoatheme.h b/src/plugins/platforms/cocoa/qcocoatheme.h
index 0cd7b7d4c8..31340c7781 100644
--- a/src/plugins/platforms/cocoa/qcocoatheme.h
+++ b/src/plugins/platforms/cocoa/qcocoatheme.h
@@ -37,6 +37,8 @@
#include <QtCore/QHash>
#include <qpa/qplatformtheme.h>
+Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QCocoaThemeNotificationReceiver));
+
QT_BEGIN_NAMESPACE
class QPalette;
@@ -46,6 +48,8 @@ public:
QCocoaTheme();
~QCocoaTheme();
+ void reset();
+
QPlatformMenuItem* createPlatformMenuItem() const Q_DECL_OVERRIDE;
QPlatformMenu* createPlatformMenu() const Q_DECL_OVERRIDE;
QPlatformMenuBar* createPlatformMenuBar() const Q_DECL_OVERRIDE;
@@ -73,6 +77,7 @@ private:
mutable QPalette *m_systemPalette;
mutable QHash<QPlatformTheme::Palette, QPalette*> m_palettes;
mutable QHash<QPlatformTheme::Font, QFont*> m_fonts;
+ mutable QT_MANGLE_NAMESPACE(QCocoaThemeNotificationReceiver) *m_notificationReceiver;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm
index 4b73d0af08..1fd40c49f1 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,33 @@
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformnativeinterface.h>
+#include <Carbon/Carbon.h>
+
+@interface QT_MANGLE_NAMESPACE(QCocoaThemeNotificationReceiver) : NSObject {
+QCocoaTheme *mPrivate;
+}
+- (id)initWithPrivate:(QCocoaTheme *)priv;
+- (void)systemColorsDidChange:(NSNotification *)notification;
+@end
+
+QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaThemeNotificationReceiver);
+
+@implementation QCocoaThemeNotificationReceiver
+- (id)initWithPrivate:(QCocoaTheme *)priv
+{
+ self = [super init];
+ mPrivate = priv;
+ return self;
+}
+
+- (void)systemColorsDidChange:(NSNotification *)notification
+{
+ Q_UNUSED(notification);
+ mPrivate->reset();
+ QWindowSystemInterface::handleThemeChange(Q_NULLPTR);
+}
+@end
+
QT_BEGIN_NAMESPACE
const char *QCocoaTheme::name = "cocoa";
@@ -62,14 +89,27 @@ const char *QCocoaTheme::name = "cocoa";
QCocoaTheme::QCocoaTheme()
:m_systemPalette(0)
{
-
+ m_notificationReceiver = [[QT_MANGLE_NAMESPACE(QCocoaThemeNotificationReceiver) alloc] initWithPrivate:this];
+ [[NSNotificationCenter defaultCenter] addObserver:m_notificationReceiver
+ selector:@selector(systemColorsDidChange:)
+ name:NSSystemColorsDidChangeNotification
+ object:nil];
}
QCocoaTheme::~QCocoaTheme()
{
+ [[NSNotificationCenter defaultCenter] removeObserver:m_notificationReceiver];
+ [m_notificationReceiver release];
+ reset();
+ qDeleteAll(m_fonts);
+}
+
+void QCocoaTheme::reset()
+{
delete m_systemPalette;
+ m_systemPalette = Q_NULLPTR;
qDeleteAll(m_palettes);
- qDeleteAll(m_fonts);
+ m_palettes.clear();
}
bool QCocoaTheme::usePlatformNativeDialog(DialogType dialogType) const
@@ -257,18 +297,7 @@ QPixmap QCocoaTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &siz
NSImage *iconImage = [[NSWorkspace sharedWorkspace] iconForFile:QCFString::toNSString(fileInfo.canonicalFilePath())];
if (!iconImage)
return QPixmap();
- NSSize pixmapSize = NSMakeSize(size.width(), size.height());
- QPixmap pixmap(pixmapSize.width, pixmapSize.height);
- pixmap.fill(Qt::transparent);
- [iconImage setSize:pixmapSize];
- NSRect iconRect = NSMakeRect(0, 0, pixmapSize.width, pixmapSize.height);
- CGContextRef ctx = qt_mac_cg_context(&pixmap);
- NSGraphicsContext *gc = [NSGraphicsContext graphicsContextWithGraphicsPort:ctx flipped:YES];
- [NSGraphicsContext saveGraphicsState];
- [NSGraphicsContext setCurrentContext:gc];
- [iconImage drawInRect:iconRect fromRect:iconRect operation:NSCompositeSourceOver fraction:1.0 respectFlipped:YES hints:nil];
- [NSGraphicsContext restoreGraphicsState];
- return pixmap;
+ return qt_mac_toQPixmap(iconImage, size);
}
QVariant QCocoaTheme::themeHint(ThemeHint hint) const
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 3b5909a37e..2d8abba189 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>
@@ -689,7 +688,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 {
@@ -1345,6 +1353,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 0d80333e65..7f13961897 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/qprintengine_mac.mm b/src/plugins/platforms/cocoa/qprintengine_mac.mm
index edd1d656f0..6edfd75a14 100644
--- a/src/plugins/platforms/cocoa/qprintengine_mac.mm
+++ b/src/plugins/platforms/cocoa/qprintengine_mac.mm
@@ -251,7 +251,7 @@ void QMacPrintEnginePrivate::initialize()
setPageSize(m_pageLayout.pageSize());
QHash<QMacPrintEngine::PrintEnginePropertyKey, QVariant>::const_iterator propC;
- for (propC = valueCache.constBegin(); propC != valueCache.constEnd(); propC++) {
+ for (propC = valueCache.constBegin(); propC != valueCache.constEnd(); ++propC) {
q->setProperty(propC.key(), propC.value());
}
}
diff --git a/src/plugins/platforms/cocoa/qt_mac_p.h b/src/plugins/platforms/cocoa/qt_mac_p.h
index 576e0f9729..9a20c31720 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:
@@ -127,8 +105,8 @@ class QMacCGContext
public:
QMacCGContext(QPainter *p); //qpaintengine_mac.mm
inline QMacCGContext() { context = 0; }
- inline QMacCGContext(const QPaintDevice *pdev) {
- extern CGContextRef qt_mac_cg_context(const QPaintDevice *);
+ inline QMacCGContext(QPaintDevice *pdev) {
+ extern CGContextRef qt_mac_cg_context(QPaintDevice *);
context = qt_mac_cg_context(pdev);
}
inline QMacCGContext(CGContextRef cg, bool takeOwnership=false) {
@@ -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/directfb/qdirectfbblitter.cpp b/src/plugins/platforms/directfb/qdirectfbblitter.cpp
index b87310ed76..3d8ffa9bf7 100644
--- a/src/plugins/platforms/directfb/qdirectfbblitter.cpp
+++ b/src/plugins/platforms/directfb/qdirectfbblitter.cpp
@@ -65,7 +65,7 @@ QDirectFbBlitter::QDirectFbBlitter(const QSize &rect, IDirectFBSurface *surface)
DFBSurfaceCapabilities surfaceCaps;
m_surface->GetCapabilities(m_surface.data(), &surfaceCaps);
m_premult = (surfaceCaps & DSCAPS_PREMULTIPLIED);
- if (qgetenv("QT_DIRECTFB_BLITTER_DEBUGPAINT").toInt())
+ if (qEnvironmentVariableIntValue("QT_DIRECTFB_BLITTER_DEBUGPAINT"))
m_debugPaint = true;
}
@@ -92,7 +92,7 @@ QDirectFbBlitter::QDirectFbBlitter(const QSize &rect, bool alpha)
surfaceDesc.pixelformat = QDirectFbBlitter::pixmapFormat();
}
- if (qgetenv("QT_DIRECTFB_BLITTER_DEBUGPAINT").toInt())
+ if (qEnvironmentVariableIntValue("QT_DIRECTFB_BLITTER_DEBUGPAINT"))
m_debugPaint = true;
IDirectFB *dfb = QDirectFbConvenience::dfbInterface();
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsdevice.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsdevice.cpp
index c29d64c06d..38b61f8f8b 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsdevice.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsdevice.cpp
@@ -280,12 +280,18 @@ QEglFSKmsScreen *QEglFSKmsDevice::screenForConnector(drmModeResPtr resources, dr
qCDebug(qLcEglfsKmsDebug) << "Selected mode" << selected_mode << ":" << width << "x" << height
<< '@' << refresh << "hz for output" << connectorName;
}
-
+ static const int width = qEnvironmentVariableIntValue("QT_QPA_EGLFS_PHYSICAL_WIDTH");
+ static const int height = qEnvironmentVariableIntValue("QT_QPA_EGLFS_PHYSICAL_HEIGHT");
+ QSizeF size(width, height);
+ if (size.isEmpty()) {
+ size.setWidth(connector->mmWidth);
+ size.setHeight(connector->mmHeight);
+ }
QEglFSKmsOutput output = {
QString::fromUtf8(connectorName),
connector->connector_id,
crtc_id,
- QSizeF(connector->mmWidth, connector->mmHeight),
+ size,
selected_mode,
false,
drmModeGetCrtc(m_dri_fd, crtc_id),
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 f7450708ab..03cfea72b8 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp
@@ -53,20 +53,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");
@@ -101,14 +101,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;
@@ -267,8 +267,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;
@@ -310,7 +310,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");
}
}
@@ -379,7 +379,7 @@ bool QEglFSKmsEglDeviceIntegration::setup_kms()
}
}
- if (crtc == 0)
+ if (Q_UNLIKELY(crtc == 0))
qFatal("No suitable CRTC available");
m_drm_connector = connector;
@@ -399,7 +399,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 8af48a893b..963c1604fc 100644
--- a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp
+++ b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp
@@ -65,19 +65,6 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader,
(QEGLDeviceIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
-static inline QEGLDeviceIntegration *loadIntegration(QFactoryLoader *loader, const QString &key)
-{
- const int index = loader->indexOf(key);
- if (index != -1) {
- QObject *plugin = loader->instance(index);
- if (QEGLDeviceIntegrationPlugin *factory = qobject_cast<QEGLDeviceIntegrationPlugin *>(plugin)) {
- if (QEGLDeviceIntegration *result = factory->create())
- return result;
- }
- }
- return Q_NULLPTR;
-}
-
#endif // QT_NO_LIBRARY
QStringList QEGLDeviceIntegrationFactory::keys(const QString &pluginPath)
@@ -111,10 +98,10 @@ QEGLDeviceIntegration *QEGLDeviceIntegrationFactory::create(const QString &key,
#ifndef QT_NO_LIBRARY
if (!pluginPath.isEmpty()) {
QCoreApplication::addLibraryPath(pluginPath);
- integration = loadIntegration(directLoader(), key);
+ integration = qLoadPlugin<QEGLDeviceIntegration, QEGLDeviceIntegrationPlugin>(directLoader(), key);
}
if (!integration)
- integration = loadIntegration(loader(), key);
+ integration = qLoadPlugin<QEGLDeviceIntegration, QEGLDeviceIntegrationPlugin>(loader(), key);
if (integration)
qCDebug(qLcEglDevDebug) << "Using EGL device integration" << key;
else
@@ -155,7 +142,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/qeglfsdeviceintegration.h b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h
index 5ec98b37d1..ba47b3693e 100644
--- a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h
+++ b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h
@@ -108,6 +108,10 @@ class Q_EGLFS_EXPORT QEGLDeviceIntegrationPlugin : public QObject
public:
virtual QEGLDeviceIntegration *create() = 0;
+
+ // the pattern expected by qLoadPlugin calls for a QString argument.
+ // we don't need it, so don't bother subclasses with it:
+ QEGLDeviceIntegration *create(const QString &) { return create(); }
};
class Q_EGLFS_EXPORT QEGLDeviceIntegrationFactory
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..b1075d3c0f 100644
--- a/src/plugins/platforms/ios/ios.pro
+++ b/src/plugins/platforms/ios/ios.pro
@@ -6,7 +6,7 @@ PLUGIN_CLASS_NAME = QIOSIntegrationPlugin
load(qt_plugin)
QT += core-private gui-private platformsupport-private
-LIBS += -framework Foundation -framework UIKit -framework QuartzCore -framework AssetsLibrary
+LIBS += -framework Foundation -framework UIKit -framework QuartzCore -framework AssetsLibrary -framework AudioToolbox
OBJECTIVE_SOURCES = \
plugin.mm \
@@ -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/qiosbackingstore.h b/src/plugins/platforms/ios/qiosbackingstore.h
index 5d2ae429f1..387a286447 100644
--- a/src/plugins/platforms/ios/qiosbackingstore.h
+++ b/src/plugins/platforms/ios/qiosbackingstore.h
@@ -36,34 +36,31 @@
#include <qpa/qplatformbackingstore.h>
+#include <QtPlatformSupport/private/qrasterbackingstore_p.h>
+
QT_BEGIN_NAMESPACE
class QOpenGLPaintDevice;
-class QOpenGLFramebufferObject;
-class QOffscreenSurface;
-class QIOSBackingStore : public QPlatformBackingStore
+class QIOSBackingStore : public QRasterBackingStore
{
public:
QIOSBackingStore(QWindow *window);
~QIOSBackingStore();
- QPaintDevice *paintDevice();
+ QPaintDevice *paintDevice() Q_DECL_OVERRIDE;
- void beginPaint(const QRegion &);
- void endPaint();
+ void beginPaint(const QRegion &) Q_DECL_OVERRIDE;
+ void endPaint() Q_DECL_OVERRIDE;
- void flush(QWindow *window, const QRegion &region, const QPoint &offset);
- void resize(const QSize &size, const QRegion &staticContents);
- GLuint toTexture(const QRegion &dirtyRegion, QSize *textureSize, TextureFlags *flags) const;
+ void flush(QWindow *window, const QRegion &region, const QPoint &offset) Q_DECL_OVERRIDE;
+ void resize(const QSize &size, const QRegion &staticContents) Q_DECL_OVERRIDE;
void makeCurrent();
private:
QOpenGLContext *m_context;
- QOpenGLPaintDevice *m_device;
- QOpenGLFramebufferObject *m_fbo;
- QOffscreenSurface *m_surface;
+ QOpenGLPaintDevice *m_glDevice;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/ios/qiosbackingstore.mm b/src/plugins/platforms/ios/qiosbackingstore.mm
index 875d06dc80..f408c13af3 100644
--- a/src/plugins/platforms/ios/qiosbackingstore.mm
+++ b/src/plugins/platforms/ios/qiosbackingstore.mm
@@ -38,6 +38,7 @@
#include <QtGui/QOpenGLPaintDevice>
#include <QtGui/QOpenGLFramebufferObject>
#include <QtGui/QOffscreenSurface>
+#include <QtGui/qpainter.h>
#include <QtGui/private/qwindow_p.h>
#include <QtDebug>
@@ -58,13 +59,12 @@ void QIOSPaintDevice::ensureActiveTarget()
}
QIOSBackingStore::QIOSBackingStore(QWindow *window)
- : QPlatformBackingStore(window)
+ : QRasterBackingStore(window)
, m_context(new QOpenGLContext)
- , m_device(0)
- , m_fbo(0)
- , m_surface(0)
+ , m_glDevice(nullptr)
{
QSurfaceFormat fmt = window->requestedFormat();
+
// Due to sharing QIOSContext redirects our makeCurrent on window() attempts to
// the global share context. Hence it is essential to have a compatible format.
fmt.setDepthBufferSize(QSurfaceFormat::defaultFormat().depthBufferSize());
@@ -73,8 +73,10 @@ QIOSBackingStore::QIOSBackingStore(QWindow *window)
if (fmt.depthBufferSize() == 0)
qWarning("No depth in default format, expect rendering errors");
+ // We use the surface both for raster operations and for GL drawing (when
+ // we blit the raster image), so the type needs to cover both use cases.
if (window->surfaceType() == QSurface::RasterSurface)
- window->setSurfaceType(QSurface::OpenGLSurface);
+ window->setSurfaceType(QSurface::RasterGLSurface);
m_context->setFormat(fmt);
m_context->setScreen(window->screen());
@@ -85,75 +87,44 @@ QIOSBackingStore::QIOSBackingStore(QWindow *window)
QIOSBackingStore::~QIOSBackingStore()
{
- delete m_fbo;
- delete m_surface;
delete m_context;
- delete m_device;
+ delete m_glDevice;
}
void QIOSBackingStore::makeCurrent()
{
- QSurface *surface = m_surface ? m_surface : static_cast<QSurface *>(window());
- if (!m_context->makeCurrent(surface))
+ if (!m_context->makeCurrent(window()))
qWarning("QIOSBackingStore: makeCurrent() failed");
- if (m_fbo)
- m_fbo->bind();
}
-void QIOSBackingStore::beginPaint(const QRegion &)
+void QIOSBackingStore::beginPaint(const QRegion &region)
{
- if (qt_window_private(window())->compositing) {
- if (!m_fbo) {
- delete m_device;
- m_device = 0;
- }
- if (!m_surface) {
- m_surface = new QOffscreenSurface;
- m_surface->setFormat(m_context->format());
- m_surface->create();
- }
- if (!m_context->makeCurrent(m_surface))
- qWarning("QIOSBackingStore: Failed to make offscreen surface current");
- const QSize size = window()->size() * window()->devicePixelRatio();
- if (m_fbo && m_fbo->size() != size) {
- delete m_fbo;
- m_fbo = 0;
- }
- if (!m_fbo)
- m_fbo = new QOpenGLFramebufferObject(size, QOpenGLFramebufferObject::CombinedDepthStencil);
- } else if (m_fbo) {
- delete m_fbo;
- m_fbo = 0;
- delete m_surface;
- m_surface = 0;
- delete m_device;
- m_device = 0;
- }
-
makeCurrent();
- if (!m_device)
- m_device = new QIOSPaintDevice(this);
+ if (!m_glDevice)
+ m_glDevice = new QIOSPaintDevice(this);
+
+ if (window()->surfaceType() == QSurface::RasterGLSurface)
+ QRasterBackingStore::beginPaint(region);
}
void QIOSBackingStore::endPaint()
{
- if (m_fbo) {
- m_fbo->release();
- glFlush();
- }
}
QPaintDevice *QIOSBackingStore::paintDevice()
{
- Q_ASSERT(m_device);
+ Q_ASSERT(m_glDevice);
// Keep paint device size and device pixel ratio in sync with window
qreal devicePixelRatio = window()->devicePixelRatio();
- m_device->setSize(window()->size() * devicePixelRatio);
- m_device->setDevicePixelRatio(devicePixelRatio);
+ m_glDevice->setSize(window()->size() * devicePixelRatio);
+ m_glDevice->setDevicePixelRatio(devicePixelRatio);
- return m_device;
+ if (window()->surfaceType() == QSurface::RasterGLSurface)
+ return QRasterBackingStore::paintDevice();
+ else
+ return m_glDevice;
}
void QIOSBackingStore::flush(QWindow *window, const QRegion &region, const QPoint &offset)
@@ -171,6 +142,11 @@ void QIOSBackingStore::flush(QWindow *window, const QRegion &region, const QPoin
return;
}
+ if (window->surfaceType() == QSurface::RasterGLSurface) {
+ QPainter painter(m_glDevice);
+ painter.drawImage(QPoint(), m_image);
+ }
+
m_context->makeCurrent(window);
m_context->swapBuffers(window);
}
@@ -179,31 +155,20 @@ void QIOSBackingStore::resize(const QSize &size, const QRegion &staticContents)
{
Q_UNUSED(staticContents);
- // Resizing the backing store would in our case mean resizing the QWindow,
- // as we cheat and use an QOpenGLPaintDevice that we target at the window.
- // That's probably not what the user intended, so we ignore resizes of the
- // backing store and always keep the paint device's size in sync with the
- // window size in beginPaint().
+ if (window()->surfaceType() == QSurface::OpenGLSurface) {
+ // Resizing the backing store would in this case mean resizing the QWindow,
+ // as we use an QOpenGLPaintDevice that we target at the window. That's
+ // probably not what the user intended, so we ignore resizes of the backing
+ // store and always keep the paint device's size in sync with the window
+ // size in beginPaint().
- if (size != window()->size() && !window()->inherits("QWidgetWindow"))
- qWarning() << "QIOSBackingStore needs to have the same size as its window";
-}
-
-GLuint QIOSBackingStore::toTexture(const QRegion &dirtyRegion, QSize *textureSize, TextureFlags *flags) const
-{
- Q_ASSERT(qt_window_private(window())->compositing);
- Q_UNUSED(dirtyRegion);
-
- if (flags)
- *flags = TextureFlip;
+ if (size != window()->size() && !window()->inherits("QWidgetWindow"))
+ qWarning() << "QIOSBackingStore needs to have the same size as its window";
- if (!m_fbo)
- return 0;
-
- if (textureSize)
- *textureSize = m_fbo->size();
+ return;
+ }
- return m_fbo->texture();
+ QRasterBackingStore::resize(size, staticContents);
}
QT_END_NAMESPACE
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.h b/src/plugins/platforms/ios/qiosintegration.h
index 7d23fe1d62..e670d83a8d 100644
--- a/src/plugins/platforms/ios/qiosintegration.h
+++ b/src/plugins/platforms/ios/qiosintegration.h
@@ -82,6 +82,8 @@ public:
void addScreen(QPlatformScreen *screen) { screenAdded(screen); }
void destroyScreen(QPlatformScreen *screen) { QPlatformIntegration::destroyScreen(screen); }
+ void beep() const Q_DECL_OVERRIDE;
+
static QIOSIntegration *instance();
// -- QPlatformNativeInterface --
diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm
index 85b5c477cc..21248ddb86 100644
--- a/src/plugins/platforms/ios/qiosintegration.mm
+++ b/src/plugins/platforms/ios/qiosintegration.mm
@@ -53,6 +53,8 @@
#include <QtPlatformSupport/private/qmacmime_p.h>
#include <QDir>
+#import <AudioToolbox/AudioServices.h>
+
#include <QtDebug>
QT_BEGIN_NAMESPACE
@@ -70,7 +72,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" \
@@ -268,6 +270,13 @@ QPlatformNativeInterface *QIOSIntegration::nativeInterface() const
return const_cast<QIOSIntegration *>(this);
}
+void QIOSIntegration::beep() const
+{
+#if !TARGET_IPHONE_SIMULATOR
+ AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
+#endif
+}
+
// ---------------------------------------------------------
void *QIOSIntegration::nativeResourceForWindow(const QByteArray &resource, QWindow *window)
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 612f8c43a2..5f9346816a 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"
@@ -271,7 +272,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)
@@ -304,41 +305,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..b4481ce5a2 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>
@@ -291,10 +292,8 @@ QLinuxFbScreen::~QLinuxFbScreen()
close(mFbFd);
}
- if (mTtyFd != -1) {
+ if (mTtyFd != -1)
resetTty(mTtyFd, mOldTtyMode);
- close(mTtyFd);
- }
delete mBlitter;
}
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 &paramList
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 &paramList)
#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 &paramList)
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 &paramList)
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 &paramList)
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 &paramList)
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 4934b6c6e4..c954e0a96d 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/qwindowscursor.cpp b/src/plugins/platforms/windows/qwindowscursor.cpp
index c769eb04a4..b946c34a2b 100644
--- a/src/plugins/platforms/windows/qwindowscursor.cpp
+++ b/src/plugins/platforms/windows/qwindowscursor.cpp
@@ -780,6 +780,21 @@ QPixmap QWindowsCursor::dragDefaultCursor(Qt::DropAction action) const
return m_ignoreDragCursor;
}
+HCURSOR QWindowsCursor::hCursor(const QCursor &c) const
+{
+ const Qt::CursorShape shape = c.shape();
+ if (shape == Qt::BitmapCursor) {
+ const auto pit = m_pixmapCursorCache.constFind(QWindowsPixmapCursorCacheKey(c));
+ if (pit != m_pixmapCursorCache.constEnd())
+ return pit.value()->handle();
+ } else {
+ const auto sit = m_standardCursorCache.constFind(shape);
+ if (sit != m_standardCursorCache.constEnd())
+ return sit.value()->handle();
+ }
+ return HCURSOR(0);
+}
+
/*!
\class QWindowsWindowCursor
\brief Per-Window cursor. Contains a QCursor and manages its associated system
diff --git a/src/plugins/platforms/windows/qwindowscursor.h b/src/plugins/platforms/windows/qwindowscursor.h
index e93f779f94..0e080f725a 100644
--- a/src/plugins/platforms/windows/qwindowscursor.h
+++ b/src/plugins/platforms/windows/qwindowscursor.h
@@ -115,6 +115,8 @@ public:
QPixmap dragDefaultCursor(Qt::DropAction action) const;
+ HCURSOR hCursor(const QCursor &c) const;
+
private:
typedef QHash<Qt::CursorShape, CursorHandlePtr> StandardCursorCache;
typedef QHash<QWindowsPixmapCursorCacheKey, CursorHandlePtr> PixmapCursorCache;
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 684c44acf2..08ef555441 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 bd2014b8f2..b2781c8212 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,12 +221,14 @@ QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList &paramL
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
+ << "effective process DPI awareness=" << QWindowsContext::processDpiAwareness();
+ }
dpiAwarenessSet = true;
}
- qCDebug(lcQpaWindows)
- << __FUNCTION__ << "DpiAwareness=" << dpiAwareness
- << "effective process DPI awareness=" << QWindowsContext::processDpiAwareness();
m_context.initTouch(m_options);
}
@@ -594,4 +597,9 @@ QPlatformServices *QWindowsIntegration::services() const
return &d->m_services;
}
+void QWindowsIntegration::beep() const
+{
+ MessageBeep(MB_OK); // For QApplication
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowsintegration.h b/src/plugins/platforms/windows/qwindowsintegration.h
index cb10bf08f5..a93e2c9856 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.h
+++ b/src/plugins/platforms/windows/qwindowsintegration.h
@@ -96,6 +96,8 @@ public:
unsigned options() const;
+ void beep() const Q_DECL_OVERRIDE;
+
#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
QPlatformSessionManager *createPlatformSessionManager(const QString &id, const QString &key) const Q_DECL_OVERRIDE;
#endif
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/qwindowsnativeinterface.cpp b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
index 659ef79c18..c5c60aa882 100644
--- a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
+++ b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
@@ -34,6 +34,7 @@
#include "qwindowsnativeinterface.h"
#include "qwindowswindow.h"
#include "qwindowscontext.h"
+#include "qwindowscursor.h"
#include "qwindowsfontdatabase.h"
#include "qwindowsopenglcontext.h"
#include "qwindowsopengltester.h"
@@ -42,6 +43,8 @@
#include <QtGui/QWindow>
#include <QtGui/QOpenGLContext>
+#include <QtGui/QScreen>
+#include <qpa/qplatformscreen.h>
QT_BEGIN_NAMESPACE
@@ -102,6 +105,19 @@ void *QWindowsNativeInterface::nativeResourceForWindow(const QByteArray &resourc
return 0;
}
+#ifndef QT_NO_CURSOR
+void *QWindowsNativeInterface::nativeResourceForCursor(const QByteArray &resource, const QCursor &cursor)
+{
+ if (resource == QByteArrayLiteral("hcursor")) {
+ if (const QScreen *primaryScreen = QGuiApplication::primaryScreen()) {
+ if (const QPlatformCursor *pCursor= primaryScreen->handle()->cursor())
+ return static_cast<const QWindowsCursor *>(pCursor)->hCursor(cursor);
+ }
+ }
+ return Q_NULLPTR;
+}
+#endif // !QT_NO_CURSOR
+
static const char customMarginPropertyC[] = "WindowsCustomMargins";
QVariant QWindowsNativeInterface::windowProperty(QPlatformWindow *window, const QString &name) const
@@ -195,11 +211,6 @@ QString QWindowsNativeInterface::registerWindowClass(const QString &classNameIn,
return QWindowsContext::instance()->registerWindowClass(classNameIn, (WNDPROC)eventProc);
}
-void QWindowsNativeInterface::beep()
-{
- MessageBeep(MB_OK); // For QApplication
-}
-
bool QWindowsNativeInterface::asyncExpose() const
{
return QWindowsContext::instance()->asyncExpose();
diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.h b/src/plugins/platforms/windows/qwindowsnativeinterface.h
index 97839ae1ae..48de0f514d 100644
--- a/src/plugins/platforms/windows/qwindowsnativeinterface.h
+++ b/src/plugins/platforms/windows/qwindowsnativeinterface.h
@@ -66,15 +66,15 @@ public:
void *nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) Q_DECL_OVERRIDE;
#endif
void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) Q_DECL_OVERRIDE;
-
+#ifndef QT_NO_CURSOR
+ void *nativeResourceForCursor(const QByteArray &resource, const QCursor &cursor) Q_DECL_OVERRIDE;
+#endif
Q_INVOKABLE void *createMessageWindow(const QString &classNameTemplate,
const QString &windowName,
void *eventProc) const;
Q_INVOKABLE QString registerWindowClass(const QString &classNameIn, void *eventProc) const;
- Q_INVOKABLE void beep();
-
Q_INVOKABLE void registerWindowsMime(void *mimeIn);
Q_INVOKABLE void unregisterWindowsMime(void *mime);
Q_INVOKABLE int registerMimeType(const QString &mimeType);
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/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp
index cc367ff801..08eb5c02e2 100644
--- a/src/plugins/platforms/windows/qwindowstheme.cpp
+++ b/src/plugins/platforms/windows/qwindowstheme.cpp
@@ -501,28 +501,43 @@ QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) con
const int scaleFactor = primaryScreen ? qRound(QHighDpiScaling::factor(primaryScreen)) : 1;
const QSizeF pixmapSize = size * scaleFactor;
int resourceId = -1;
+ int stockId = SIID_INVALID;
+ UINT stockFlags = 0;
LPCTSTR iconName = 0;
switch (sp) {
case DriveCDIcon:
+ stockId = SIID_DRIVECD;
+ resourceId = 12;
+ break;
case DriveDVDIcon:
+ stockId = SIID_DRIVEDVD;
resourceId = 12;
break;
case DriveNetIcon:
+ stockId = SIID_DRIVENET;
resourceId = 10;
break;
case DriveHDIcon:
+ stockId = SIID_DRIVEFIXED;
resourceId = 9;
break;
case DriveFDIcon:
+ stockId = SIID_DRIVE35;
resourceId = 7;
break;
- case FileIcon:
case FileLinkIcon:
+ stockFlags = SHGSI_LINKOVERLAY;
+ // Fall through
+ case FileIcon:
+ stockId = SIID_DOCNOASSOC;
resourceId = 1;
break;
- case DirIcon:
case DirLinkIcon:
+ stockFlags = SHGSI_LINKOVERLAY;
+ // Fall through
case DirClosedIcon:
+ case DirIcon:
+ stockId = SIID_FOLDER;
resourceId = 4;
break;
case DesktopIcon:
@@ -531,54 +546,68 @@ QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) con
case ComputerIcon:
resourceId = 16;
break;
- case DirOpenIcon:
case DirLinkOpenIcon:
+ stockFlags = SHGSI_LINKOVERLAY;
+ // Fall through
+ case DirOpenIcon:
+ stockId = SIID_FOLDEROPEN;
resourceId = 5;
break;
case FileDialogNewFolder:
+ stockId = SIID_FOLDER;
resourceId = 319;
break;
case DirHomeIcon:
resourceId = 235;
break;
case TrashIcon:
+ stockId = SIID_RECYCLER;
resourceId = 191;
break;
#ifndef Q_OS_WINCE
case MessageBoxInformation:
+ stockId = SIID_INFO;
iconName = IDI_INFORMATION;
break;
case MessageBoxWarning:
+ stockId = SIID_WARNING;
iconName = IDI_WARNING;
break;
case MessageBoxCritical:
+ stockId = SIID_ERROR;
iconName = IDI_ERROR;
break;
case MessageBoxQuestion:
+ stockId = SIID_HELP;
iconName = IDI_QUESTION;
break;
case VistaShield:
+ stockId = SIID_SHIELD;
+ break;
+#endif
+ default:
+ break;
+ }
+
+#ifndef Q_OS_WINCE
+ if (stockId != SIID_INVALID) {
if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
- && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) {
- if (!QWindowsContext::shell32dll.sHGetStockIconInfo)
- return QPixmap();
+ && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)
+ && QWindowsContext::shell32dll.sHGetStockIconInfo) {
QPixmap pixmap;
SHSTOCKICONINFO iconInfo;
memset(&iconInfo, 0, sizeof(iconInfo));
iconInfo.cbSize = sizeof(iconInfo);
- const int iconSize = pixmapSize.width() > 16 ? SHGFI_LARGEICON : SHGFI_SMALLICON;
- if (QWindowsContext::shell32dll.sHGetStockIconInfo(SIID_SHIELD, SHGFI_ICON | iconSize, &iconInfo) == S_OK) {
+ stockFlags |= (pixmapSize.width() > 16 ? SHGFI_LARGEICON : SHGFI_SMALLICON);
+ if (QWindowsContext::shell32dll.sHGetStockIconInfo(stockId, SHGFI_ICON | stockFlags, &iconInfo) == S_OK) {
pixmap = qt_pixmapFromWinHICON(iconInfo.hIcon);
pixmap.setDevicePixelRatio(scaleFactor);
DestroyIcon(iconInfo.hIcon);
return pixmap;
}
}
- break;
-#endif
- default:
- break;
}
+#endif
if (resourceId != -1) {
QPixmap pixmap = loadIconFromShell32(resourceId, pixmapSize);
diff --git a/src/plugins/platforms/winrt/qwinrteglcontext.cpp b/src/plugins/platforms/winrt/qwinrteglcontext.cpp
index bc77df566e..8ca669141e 100644
--- a/src/plugins/platforms/winrt/qwinrteglcontext.cpp
+++ b/src/plugins/platforms/winrt/qwinrteglcontext.cpp
@@ -112,7 +112,7 @@ 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());
// eglInitialize checks for EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE
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/qxcbglintegrationfactory.cpp b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.cpp
index 508f5e82e6..4e63e1ef66 100644
--- a/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.cpp
+++ b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.cpp
@@ -46,17 +46,6 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
(QXcbGlIntegrationFactoryInterface_iid, QLatin1String("/xcbglintegrations"), Qt::CaseInsensitive))
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader,
(QXcbGlIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
-
-static inline QXcbGlIntegration *loadIntegration(QFactoryLoader *loader, const QString &key)
-{
- const int index = loader->indexOf(key);
- if (index != -1) {
- if (QXcbGlIntegrationPlugin *factory = qobject_cast<QXcbGlIntegrationPlugin *>(loader->instance(index)))
- if (QXcbGlIntegration *result = factory->create())
- return result;
- }
- return Q_NULLPTR;
-}
#endif // !QT_NO_LIBRARY
QStringList QXcbGlIntegrationFactory::keys(const QString &pluginPath)
@@ -86,13 +75,13 @@ QStringList QXcbGlIntegrationFactory::keys(const QString &pluginPath)
QXcbGlIntegration *QXcbGlIntegrationFactory::create(const QString &platform, const QString &pluginPath)
{
#ifndef QT_NO_LIBRARY
- // Try loading the plugin from platformPluginPath first:
+ // Try loading the plugin from pluginPath first:
if (!pluginPath.isEmpty()) {
QCoreApplication::addLibraryPath(pluginPath);
- if (QXcbGlIntegration *ret = loadIntegration(directLoader(), platform))
+ if (QXcbGlIntegration *ret = qLoadPlugin<QXcbGlIntegration, QXcbGlIntegrationPlugin>(directLoader(), platform))
return ret;
}
- if (QXcbGlIntegration *ret = loadIntegration(loader(), platform))
+ if (QXcbGlIntegration *ret = qLoadPlugin<QXcbGlIntegration, QXcbGlIntegrationPlugin>(loader(), platform))
return ret;
#else
Q_UNUSED(platform);
diff --git a/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationplugin.h b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationplugin.h
index f9a25cc12a..a61a7036a8 100644
--- a/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationplugin.h
+++ b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationplugin.h
@@ -53,6 +53,9 @@ public:
{ }
virtual QXcbGlIntegration *create() = 0;
+ // the pattern expected by qLoadPlugin calls for a QString argument.
+ // we don't need it, so don't bother subclasses with it:
+ QXcbGlIntegration *create(const QString &) { return create(); }
};
QT_END_NAMESPACE
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 4cb220a02f..208170de37 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);
@@ -305,7 +305,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 abb48034cd..7348eaac20 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -577,7 +577,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());
@@ -990,17 +990,20 @@ void QXcbConnection::handleXcbError(xcb_generic_error_t *error)
int i = 0;
for (; i < m_callLog.size(); ++i) {
if (m_callLog.at(i).sequence == error->sequence) {
- qDebug("Caused by: %s:%d", qPrintable(m_callLog.at(i).file), m_callLog.at(i).line);
+ qDebug("Caused by: %s:%d", m_callLog.at(i).file.constData(), m_callLog.at(i).line);
break;
} else if (m_callLog.at(i).sequence > error->sequence) {
- qDebug("Caused some time before: %s:%d", qPrintable(m_callLog.at(i).file), m_callLog.at(i).line);
+ qDebug("Caused some time before: %s:%d", m_callLog.at(i).file.constData(),
+ m_callLog.at(i).line);
if (i > 0)
- qDebug("and after: %s:%d", qPrintable(m_callLog.at(i-1).file), m_callLog.at(i-1).line);
+ qDebug("and after: %s:%d", m_callLog.at(i-1).file.constData(),
+ m_callLog.at(i-1).line);
break;
}
}
if (i == m_callLog.size() && !m_callLog.isEmpty())
- qDebug("Caused some time after: %s:%d", qPrintable(m_callLog.first().file), m_callLog.first().line);
+ qDebug("Caused some time after: %s:%d", m_callLog.first().file.constData(),
+ m_callLog.first().line);
#endif
}
@@ -1688,15 +1691,14 @@ void QXcbConnection::processXcbEvents()
if (accepted)
continue;
- QVector<PeekFunc>::iterator it = m_peekFuncs.begin();
- while (it != m_peekFuncs.end()) {
+ auto isWaitingFor = [=](PeekFunc peekFunc) {
// These callbacks return true if the event is what they were
// waiting for, remove them from the list in that case.
- if ((*it)(this, event))
- it = m_peekFuncs.erase(it);
- else
- ++it;
- }
+ return peekFunc(this, event);
+ };
+ m_peekFuncs.erase(std::remove_if(m_peekFuncs.begin(), m_peekFuncs.end(),
+ isWaitingFor),
+ m_peekFuncs.end());
m_reader->unlock();
handleXcbEvent(event);
m_reader->lock();
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h
index a6a7b9e7ca..6fa7532555 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.h
+++ b/src/plugins/platforms/xcb/qxcbconnection.h
@@ -631,7 +631,11 @@ private:
QMutex m_callLogMutex;
void log(const char *file, int line, int sequence);
template <typename cookie_t>
- friend cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection, const char *file, int line);
+ friend cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection,
+ const char *file, int line);
+ template <typename reply_t>
+ friend reply_t *q_xcb_call_template(reply_t *reply, QXcbConnection *connection,
+ const char *file, int line);
#endif
WindowMapper m_mapper;
@@ -696,11 +700,19 @@ private:
#ifdef Q_XCB_DEBUG
template <typename cookie_t>
-cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection, const char *file, int line)
+cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection, const char *file,
+ int line)
{
connection->log(file, line, cookie.sequence);
return cookie;
}
+
+template <typename reply_t>
+reply_t *q_xcb_call_template(reply_t *reply, QXcbConnection *connection, const char *file, int line)
+{
+ connection->log(file, line, reply->sequence);
+ return reply;
+}
#define Q_XCB_CALL(x) q_xcb_call_template(x, connection(), __FILE__, __LINE__)
#define Q_XCB_CALL2(x, connection) q_xcb_call_template(x, connection, __FILE__, __LINE__)
#define Q_XCB_NOOP(c) q_xcb_call_template(xcb_no_operation(c->xcb_connection()), c, __FILE__, __LINE__);
diff --git a/src/plugins/platforms/xcb/qxcbcursor.h b/src/plugins/platforms/xcb/qxcbcursor.h
index 3c6dece1f2..f6c1d9db90 100644
--- a/src/plugins/platforms/xcb/qxcbcursor.h
+++ b/src/plugins/platforms/xcb/qxcbcursor.h
@@ -77,6 +77,11 @@ public:
static void queryPointer(QXcbConnection *c, QXcbVirtualDesktop **virtualDesktop, QPoint *pos, int *keybMask = 0);
+#ifndef QT_NO_CURSOR
+ xcb_cursor_t xcbCursor(const QCursor &c) const
+ { return m_cursorHash.value(QXcbCursorCacheKey(c), xcb_cursor_t(0)); }
+#endif
+
private:
#ifndef QT_NO_CURSOR
typedef QHash<QXcbCursorCacheKey, xcb_cursor_t> CursorHash;
diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp
index 19e8b1de7d..c42ea627a8 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.cpp
+++ b/src/plugins/platforms/xcb/qxcbintegration.cpp
@@ -454,4 +454,17 @@ void QXcbIntegration::sync()
}
}
+// For QApplication::beep()
+void QXcbIntegration::beep() const
+{
+ QScreen *priScreen = QGuiApplication::primaryScreen();
+ if (!priScreen)
+ return;
+ QPlatformScreen *screen = priScreen->handle();
+ if (!screen)
+ return;
+ xcb_connection_t *connection = static_cast<QXcbScreen *>(screen)->xcb_connection();
+ xcb_bell(connection, 0);
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/qxcbintegration.h b/src/plugins/platforms/xcb/qxcbintegration.h
index 4e2a3c2bbd..f833015596 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.h
+++ b/src/plugins/platforms/xcb/qxcbintegration.h
@@ -104,6 +104,8 @@ public:
void sync() Q_DECL_OVERRIDE;
+ void beep() const Q_DECL_OVERRIDE;
+
static QXcbIntegration *instance() { return m_instance; }
private:
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/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
index dfb0a125e2..1403cee622 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
@@ -33,6 +33,7 @@
#include "qxcbnativeinterface.h"
+#include "qxcbcursor.h"
#include "qxcbscreen.h"
#include "qxcbwindow.h"
#include "qxcbintegration.h"
@@ -91,18 +92,6 @@ QXcbNativeInterface::QXcbNativeInterface() :
{
}
-void QXcbNativeInterface::beep() // For QApplication::beep()
-{
- QScreen *priScreen = QGuiApplication::primaryScreen();
- if (!priScreen)
- return;
- QPlatformScreen *screen = priScreen->handle();
- if (!screen)
- return;
- xcb_connection_t *connection = static_cast<QXcbScreen *>(screen)->xcb_connection();
- xcb_bell(connection, 0);
-}
-
static inline QXcbSystemTrayTracker *systemTrayTracker(const QScreen *s)
{
if (!s)
@@ -288,6 +277,20 @@ void *QXcbNativeInterface::nativeResourceForBackingStore(const QByteArray &resou
return result;
}
+#ifndef QT_NO_CURSOR
+void *QXcbNativeInterface::nativeResourceForCursor(const QByteArray &resource, const QCursor &cursor)
+{
+ if (resource == QByteArrayLiteral("xcbcursor")) {
+ if (const QScreen *primaryScreen = QGuiApplication::primaryScreen()) {
+ if (const QPlatformCursor *pCursor= primaryScreen->handle()->cursor()) {
+ xcb_cursor_t xcbCursor = static_cast<const QXcbCursor *>(pCursor)->xcbCursor(cursor);
+ return reinterpret_cast<void *>(quintptr(xcbCursor));
+ }
+ }
+ }
+ return Q_NULLPTR;
+}
+#endif // !QT_NO_CURSOR
QPlatformNativeInterface::NativeResourceForIntegrationFunction QXcbNativeInterface::nativeResourceFunctionForIntegration(const QByteArray &resource)
{
@@ -444,11 +447,15 @@ void *QXcbNativeInterface::atspiBus()
QXcbConnection *defaultConnection = integration->defaultConnection();
if (defaultConnection) {
xcb_atom_t atspiBusAtom = defaultConnection->internAtom("AT_SPI_BUS");
- xcb_get_property_cookie_t cookie = Q_XCB_CALL(xcb_get_property(defaultConnection->xcb_connection(), false,
- defaultConnection->rootWindow(),
- atspiBusAtom,
- XCB_ATOM_STRING, 0, 128));
- xcb_get_property_reply_t *reply = Q_XCB_CALL(xcb_get_property_reply(defaultConnection->xcb_connection(), cookie, 0));
+ xcb_get_property_cookie_t cookie = Q_XCB_CALL2(xcb_get_property(
+ defaultConnection->xcb_connection(),
+ false, defaultConnection->rootWindow(),
+ atspiBusAtom, XCB_ATOM_STRING, 0, 128),
+ defaultConnection);
+ xcb_get_property_reply_t *reply = Q_XCB_CALL2(xcb_get_property_reply(
+ defaultConnection->xcb_connection(),
+ cookie, 0),
+ defaultConnection);
Q_ASSERT(!reply->bytes_after);
char *data = (char *)xcb_get_property_value(reply);
int length = xcb_get_property_value_length(reply);
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h
index f88b710864..fdda10e307 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.h
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h
@@ -78,6 +78,9 @@ public:
void *nativeResourceForScreen(const QByteArray &resource, QScreen *screen) Q_DECL_OVERRIDE;
void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) Q_DECL_OVERRIDE;
void *nativeResourceForBackingStore(const QByteArray &resource, QBackingStore *backingStore) Q_DECL_OVERRIDE;
+#ifndef QT_NO_CURSOR
+ void *nativeResourceForCursor(const QByteArray &resource, const QCursor &cursor) Q_DECL_OVERRIDE;
+#endif
NativeResourceForIntegrationFunction nativeResourceFunctionForIntegration(const QByteArray &resource) Q_DECL_OVERRIDE;
NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource) Q_DECL_OVERRIDE;
@@ -105,7 +108,6 @@ public:
static void setAppTime(QScreen *screen, xcb_timestamp_t time);
static void setAppUserTime(QScreen *screen, xcb_timestamp_t time);
- Q_INVOKABLE void beep();
Q_INVOKABLE bool systemTrayAvailable(const QScreen *screen) const;
Q_INVOKABLE void setParentRelativeBackPixmap(QWindow *window);
Q_INVOKABLE bool systrayVisualHasAlphaChannel();
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index 4e4a0cdaef..f030252865 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -393,7 +393,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) {
@@ -1090,6 +1090,7 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
}
setWmWindowType(wmWindowTypes, flags);
+ setNetWmStateWindowFlags(flags);
setMotifWindowFlags(flags);
setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
@@ -1323,6 +1324,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 3cfa71c9e0..8d3aef8e07 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.h
+++ b/src/plugins/platforms/xcb/qxcbwindow.h
@@ -182,6 +182,7 @@ protected:
void setNetWmStates(NetWmStates);
void setMotifWindowFlags(Qt::WindowFlags flags);
+ void setNetWmStateWindowFlags(Qt::WindowFlags flags);
void updateMotifWmHintsBeforeMap();
void updateNetWmStateBeforeMap();