summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/android/androidjniinput.cpp59
-rw-r--r--src/plugins/platforms/android/androidjnimain.cpp29
-rw-r--r--src/plugins/platforms/android/androidjnimain.h23
-rw-r--r--src/plugins/platforms/android/androidjnimenu.cpp27
-rw-r--r--src/plugins/platforms/android/androidjnimenu.h2
-rw-r--r--src/plugins/platforms/android/qandroidplatformclipboard.cpp5
-rw-r--r--src/plugins/platforms/android/qandroidplatformintegration.cpp22
-rw-r--r--src/plugins/platforms/android/qandroidplatformintegration.h6
-rw-r--r--src/plugins/platforms/android/qandroidplatformmenu.cpp3
-rw-r--r--src/plugins/platforms/android/qandroidplatformtheme.cpp297
-rw-r--r--src/plugins/platforms/android/qandroidplatformtheme.h16
-rw-r--r--src/plugins/platforms/cocoa/qcocoabackingstore.h5
-rw-r--r--src/plugins/platforms/cocoa/qcocoabackingstore.mm13
-rw-r--r--src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm7
-rw-r--r--src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm6
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm13
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintrospection.mm52
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenuitem.mm19
-rw-r--r--src/plugins/platforms/cocoa/qcocoamimetypes.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoaprintdevice.mm12
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm142
-rw-r--r--src/plugins/platforms/cocoa/qnsview.h3
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm209
-rw-r--r--src/plugins/platforms/cocoa/qpaintengine_mac.mm280
-rw-r--r--src/plugins/platforms/cocoa/qprintengine_mac.mm16
-rw-r--r--src/plugins/platforms/cocoa/qprintengine_mac_p.h3
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp16
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dintegration.h1
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp3
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp9
-rw-r--r--src/plugins/platforms/directfb/directfb.pro2
-rw-r--r--src/plugins/platforms/eglfs/qeglfshooks_stub.cpp2
-rw-r--r--src/plugins/platforms/eglfs/qeglfsscreen.h1
-rw-r--r--src/plugins/platforms/eglfs/qeglfswindow.cpp2
-rw-r--r--src/plugins/platforms/ios/qioseventdispatcher.mm15
-rw-r--r--src/plugins/platforms/ios/qiosglobal.h22
-rw-r--r--src/plugins/platforms/ios/qiosglobal.mm45
-rw-r--r--src/plugins/platforms/ios/qiosinputcontext.h10
-rw-r--r--src/plugins/platforms/ios/qiosinputcontext.mm223
-rw-r--r--src/plugins/platforms/ios/qiosmenu.mm23
-rw-r--r--src/plugins/platforms/ios/qiosplatformaccessibility.mm20
-rw-r--r--src/plugins/platforms/ios/qiostextresponder.h6
-rw-r--r--src/plugins/platforms/ios/qiostextresponder.mm80
-rw-r--r--src/plugins/platforms/ios/quiview.mm66
-rw-r--r--src/plugins/platforms/ios/quiview_accessibility.mm11
-rw-r--r--src/plugins/platforms/kms/kms.pro1
-rw-r--r--src/plugins/platforms/linuxfb/linuxfb.pro1
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp11
-rw-r--r--src/plugins/platforms/windows/qwindowsdialoghelpers.cpp13
-rw-r--r--src/plugins/platforms/windows/qwindowseglcontext.cpp4
-rw-r--r--src/plugins/platforms/windows/qwindowsfontdatabase.h4
-rw-r--r--src/plugins/platforms/windows/qwindowsfontengine.cpp4
-rw-r--r--src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h14
-rw-r--r--src/plugins/platforms/windows/qwindowskeymapper.cpp11
-rw-r--r--src/plugins/platforms/windows/qwindowsmousehandler.cpp37
-rw-r--r--src/plugins/platforms/windows/qwindowsmousehandler.h2
-rw-r--r--src/plugins/platforms/winrt/qwinrteglcontext.cpp4
-rw-r--r--src/plugins/platforms/winrt/qwinrteglcontext.h2
-rw-r--r--src/plugins/platforms/winrt/qwinrtintegration.cpp2
-rw-r--r--src/plugins/platforms/winrt/qwinrtscreen.cpp87
-rw-r--r--src/plugins/platforms/winrt/qwinrtscreen.h1
-rw-r--r--src/plugins/platforms/winrt/qwinrtwindow.cpp27
-rw-r--r--src/plugins/platforms/winrt/qwinrtwindow.h1
-rw-r--r--src/plugins/platforms/xcb/qglxintegration.h1
-rw-r--r--src/plugins/platforms/xcb/qxcbclipboard.cpp2
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp20
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h7
-rw-r--r--src/plugins/platforms/xcb/qxcbdrag.cpp2
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.cpp49
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.h1
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.cpp190
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.h5
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.cpp2
-rw-r--r--src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp7
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp15
-rw-r--r--src/plugins/platforms/xcb/qxcbwmsupport.cpp4
-rw-r--r--src/plugins/platforms/xcb/qxcbxsettings.cpp6
-rw-r--r--src/plugins/platforms/xcb/qxcbxsettings.h1
-rw-r--r--src/plugins/platforms/xcb/xcb-plugin.pro2
80 files changed, 1438 insertions, 933 deletions
diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp
index 536415339f..62da60ab92 100644
--- a/src/plugins/platforms/android/androidjniinput.cpp
+++ b/src/plugins/platforms/android/androidjniinput.cpp
@@ -48,10 +48,6 @@ using namespace QtAndroid;
namespace QtAndroidInput
{
- static jmethodID m_showSoftwareKeyboardMethodID = 0;
- static jmethodID m_resetSoftwareKeyboardMethodID = 0;
- static jmethodID m_hideSoftwareKeyboardMethodID = 0;
- static jmethodID m_updateSelectionMethodID = 0;
static bool m_ignoreMouseEvents = false;
static bool m_softwareKeyboardVisible = false;
@@ -62,30 +58,28 @@ namespace QtAndroidInput
void updateSelection(int selStart, int selEnd, int candidatesStart, int candidatesEnd)
{
- AttachedJNIEnv env;
- if (!env.jniEnv)
- return;
-
#ifdef QT_DEBUG_ANDROID_IM_PROTOCOL
qDebug() << ">>> UPDATESELECTION" << selStart << selEnd << candidatesStart << candidatesEnd;
#endif
- env.jniEnv->CallStaticVoidMethod(applicationClass(), m_updateSelectionMethodID,
- selStart, selEnd, candidatesStart, candidatesEnd);
+ QJNIObjectPrivate::callStaticMethod<void>(applicationClass(),
+ "updateSelection",
+ "(IIII)V",
+ selStart,
+ selEnd,
+ candidatesStart,
+ candidatesEnd);
}
void showSoftwareKeyboard(int left, int top, int width, int height, int inputHints)
{
- AttachedJNIEnv env;
- if (!env.jniEnv)
- return;
-
- env.jniEnv->CallStaticVoidMethod(applicationClass(),
- m_showSoftwareKeyboardMethodID,
- left,
- top,
- width,
- height,
- inputHints);
+ QJNIObjectPrivate::callStaticMethod<void>(applicationClass(),
+ "showSoftwareKeyboard",
+ "(IIIII)V",
+ left,
+ top,
+ width,
+ height,
+ inputHints);
#ifdef QT_DEBUG_ANDROID_IM_PROTOCOL
qDebug() << "@@@ SHOWSOFTWAREKEYBOARD" << left << top << width << height << inputHints;
#endif
@@ -93,11 +87,7 @@ namespace QtAndroidInput
void resetSoftwareKeyboard()
{
- AttachedJNIEnv env;
- if (!env.jniEnv)
- return;
-
- env.jniEnv->CallStaticVoidMethod(applicationClass(), m_resetSoftwareKeyboardMethodID);
+ QJNIObjectPrivate::callStaticMethod<void>(applicationClass(), "resetSoftwareKeyboard");
#ifdef QT_DEBUG_ANDROID_IM_PROTOCOL
qDebug() << "@@@ RESETSOFTWAREKEYBOARD";
#endif
@@ -105,11 +95,7 @@ namespace QtAndroidInput
void hideSoftwareKeyboard()
{
- AttachedJNIEnv env;
- if (!env.jniEnv)
- return;
-
- env.jniEnv->CallStaticVoidMethod(applicationClass(), m_hideSoftwareKeyboardMethodID);
+ QJNIObjectPrivate::callStaticMethod<void>(applicationClass(), "hideSoftwareKeyboard");
#ifdef QT_DEBUG_ANDROID_IM_PROTOCOL
qDebug() << "@@@ HIDESOFTWAREKEYBOARD";
#endif
@@ -722,13 +708,6 @@ namespace QtAndroidInput
{"keyboardVisibilityChanged", "(Z)V", (void *)keyboardVisibilityChanged}
};
-#define GET_AND_CHECK_STATIC_METHOD(VAR, CLASS, METHOD_NAME, METHOD_SIGNATURE) \
- VAR = env->GetStaticMethodID(CLASS, METHOD_NAME, METHOD_SIGNATURE); \
- if (!VAR) { \
- __android_log_print(ANDROID_LOG_FATAL, qtTagText(), methodErrorMsgFmt(), METHOD_NAME, METHOD_SIGNATURE); \
- return false; \
- }
-
bool registerNatives(JNIEnv *env)
{
jclass appClass = QtAndroid::applicationClass();
@@ -738,10 +717,6 @@ namespace QtAndroidInput
return false;
}
- GET_AND_CHECK_STATIC_METHOD(m_showSoftwareKeyboardMethodID, appClass, "showSoftwareKeyboard", "(IIIII)V");
- GET_AND_CHECK_STATIC_METHOD(m_resetSoftwareKeyboardMethodID, appClass, "resetSoftwareKeyboard", "()V");
- GET_AND_CHECK_STATIC_METHOD(m_hideSoftwareKeyboardMethodID, appClass, "hideSoftwareKeyboard", "()V");
- GET_AND_CHECK_STATIC_METHOD(m_updateSelectionMethodID, appClass, "updateSelection", "(IIII)V");
return true;
}
}
diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp
index 235e004904..df0a8c56cb 100644
--- a/src/plugins/platforms/android/androidjnimain.cpp
+++ b/src/plugins/platforms/android/androidjnimain.cpp
@@ -80,7 +80,6 @@ static jmethodID m_createBitmapMethodID = Q_NULLPTR;
static jobject m_ARGB_8888_BitmapConfigValue = Q_NULLPTR;
static jobject m_RGB_565_BitmapConfigValue = Q_NULLPTR;
-jmethodID m_setFullScreenMethodID = Q_NULLPTR;
static bool m_statusBarShowing = true;
static jclass m_bitmapDrawableClass = Q_NULLPTR;
@@ -182,13 +181,7 @@ namespace QtAndroid
if (m_statusBarShowing)
return;
- QtAndroid::AttachedJNIEnv env;
- if (!env.jniEnv) {
- qWarning("Failed to get JNI Environment.");
- return;
- }
-
- env.jniEnv->CallStaticVoidMethod(m_applicationClass, m_setFullScreenMethodID, false);
+ QJNIObjectPrivate::callStaticMethod<void>(m_applicationClass, "setFullScreen", "(Z)V", false);
m_statusBarShowing = true;
}
@@ -197,13 +190,7 @@ namespace QtAndroid
if (!m_statusBarShowing)
return;
- QtAndroid::AttachedJNIEnv env;
- if (!env.jniEnv) {
- qWarning("Failed to get JNI Environment.");
- return;
- }
-
- env.jniEnv->CallStaticVoidMethod(m_applicationClass, m_setFullScreenMethodID, true);
+ QJNIObjectPrivate::callStaticMethod<void>(m_applicationClass, "setFullScreen", "(Z)V", true);
m_statusBarShowing = false;
}
@@ -453,16 +440,9 @@ static void *startMainMethod(void */*data*/)
if (res < 0)
qWarning() << "dlclose failed:" << dlerror();
}
- m_mainLibraryHnd = Q_NULLPTR;
- m_main = Q_NULLPTR;
- QtAndroid::AttachedJNIEnv env;
- if (!env.jniEnv)
- return 0;
- if (m_applicationClass) {
- jmethodID quitApp = env.jniEnv->GetStaticMethodID(m_applicationClass, "quitApp", "()V");
- env.jniEnv->CallStaticVoidMethod(m_applicationClass, quitApp);
- }
+ if (m_applicationClass)
+ QJNIObjectPrivate::callStaticMethod<void>(m_applicationClass, "quitApp", "()V");
return 0;
}
@@ -723,7 +703,6 @@ static int registerNatives(JNIEnv *env)
jclass clazz;
FIND_AND_CHECK_CLASS("org/qtproject/qt5/android/QtNative");
m_applicationClass = static_cast<jclass>(env->NewGlobalRef(clazz));
- GET_AND_CHECK_STATIC_METHOD(m_setFullScreenMethodID, m_applicationClass, "setFullScreen", "(Z)V");
if (env->RegisterNatives(m_applicationClass, methods, sizeof(methods) / sizeof(methods[0])) < 0) {
__android_log_print(ANDROID_LOG_FATAL,"Qt", "RegisterNatives failed");
diff --git a/src/plugins/platforms/android/androidjnimain.h b/src/plugins/platforms/android/androidjnimain.h
index 01330ce283..8cf9274857 100644
--- a/src/plugins/platforms/android/androidjnimain.h
+++ b/src/plugins/platforms/android/androidjnimain.h
@@ -85,29 +85,6 @@ namespace QtAndroid
jobject createBitmap(int width, int height, QImage::Format format, JNIEnv *env);
jobject createBitmapDrawable(jobject bitmap, JNIEnv *env = 0);
- struct AttachedJNIEnv
- {
- AttachedJNIEnv()
- {
- attached = false;
- if (QtAndroid::javaVM()->GetEnv((void**)&jniEnv, JNI_VERSION_1_6) < 0) {
- if (QtAndroid::javaVM()->AttachCurrentThread(&jniEnv, NULL) < 0) {
- __android_log_print(ANDROID_LOG_ERROR, "Qt", "AttachCurrentThread failed");
- jniEnv = Q_NULLPTR;
- return;
- }
- attached = true;
- }
- }
-
- ~AttachedJNIEnv()
- {
- if (attached)
- QtAndroid::javaVM()->DetachCurrentThread();
- }
- bool attached;
- JNIEnv *jniEnv;
- };
const char *classErrorMsgFmt();
const char *methodErrorMsgFmt();
const char *qtTagText();
diff --git a/src/plugins/platforms/android/androidjnimenu.cpp b/src/plugins/platforms/android/androidjnimenu.cpp
index 1251bbf193..36c349f6b4 100644
--- a/src/plugins/platforms/android/androidjnimenu.cpp
+++ b/src/plugins/platforms/android/androidjnimenu.cpp
@@ -44,6 +44,7 @@
#include <QSet>
#include <QWindow>
#include <QtCore/private/qjnihelpers_p.h>
+#include <QtCore/private/qjni_p.h>
QT_BEGIN_NAMESPACE
@@ -61,9 +62,6 @@ namespace QtAndroidMenu
static QMutex menuBarMutex(QMutex::Recursive);
static jmethodID openContextMenuMethodID = 0;
- static jmethodID closeContextMenuMethodID = 0;
- static jmethodID resetOptionsMenuMethodID = 0;
- static jmethodID openOptionsMenuMethodID = 0;
static jmethodID clearMenuMethodID = 0;
static jmethodID addMenuItemMethodID = 0;
@@ -78,16 +76,12 @@ namespace QtAndroidMenu
void resetMenuBar()
{
- AttachedJNIEnv env;
- if (env.jniEnv)
- env.jniEnv->CallStaticVoidMethod(applicationClass(), resetOptionsMenuMethodID);
+ QJNIObjectPrivate::callStaticMethod<void>(applicationClass(), "resetOptionsMenu");
}
void openOptionsMenu()
{
- AttachedJNIEnv env;
- if (env.jniEnv)
- env.jniEnv->CallStaticVoidMethod(applicationClass(), openOptionsMenuMethodID);
+ QJNIObjectPrivate::callStaticMethod<void>(applicationClass(), "openOptionsMenu");
}
void showContextMenu(QAndroidPlatformMenu *menu, const QRect &anchorRect, JNIEnv *env)
@@ -103,22 +97,14 @@ namespace QtAndroidMenu
visibleMenu = menu;
menu->aboutToShow();
- if (env) {
- env->CallStaticVoidMethod(applicationClass(), openContextMenuMethodID, anchorRect.x(), anchorRect.y(), anchorRect.width(), anchorRect.height());
- } else {
- AttachedJNIEnv aenv;
- if (aenv.jniEnv)
- aenv.jniEnv->CallStaticVoidMethod(applicationClass(), openContextMenuMethodID, anchorRect.x(), anchorRect.y(), anchorRect.width(), anchorRect.height());
- }
+ env->CallStaticVoidMethod(applicationClass(), openContextMenuMethodID, anchorRect.x(), anchorRect.y(), anchorRect.width(), anchorRect.height());
}
void hideContextMenu(QAndroidPlatformMenu *menu)
{
QMutexLocker lock(&visibleMenuMutex);
if (visibleMenu == menu) {
- AttachedJNIEnv env;
- if (env.jniEnv)
- env.jniEnv->CallStaticVoidMethod(applicationClass(), closeContextMenuMethodID);
+ QJNIObjectPrivate::callStaticMethod<void>(applicationClass(), "closeContextMenu");
pendingContextMenus.clear();
} else {
pendingContextMenus.removeOne(menu);
@@ -430,9 +416,6 @@ namespace QtAndroidMenu
}
GET_AND_CHECK_STATIC_METHOD(openContextMenuMethodID, appClass, "openContextMenu", "(IIII)V");
- GET_AND_CHECK_STATIC_METHOD(closeContextMenuMethodID, appClass, "closeContextMenu", "()V");
- GET_AND_CHECK_STATIC_METHOD(resetOptionsMenuMethodID, appClass, "resetOptionsMenu", "()V");
- GET_AND_CHECK_STATIC_METHOD(openOptionsMenuMethodID, appClass, "openOptionsMenu", "()V");
jclass clazz;
FIND_AND_CHECK_CLASS("android/view/Menu");
diff --git a/src/plugins/platforms/android/androidjnimenu.h b/src/plugins/platforms/android/androidjnimenu.h
index c54eb37f37..f85db9ff86 100644
--- a/src/plugins/platforms/android/androidjnimenu.h
+++ b/src/plugins/platforms/android/androidjnimenu.h
@@ -50,7 +50,7 @@ namespace QtAndroidMenu
{
// Menu support
void openOptionsMenu();
- void showContextMenu(QAndroidPlatformMenu *menu, const QRect &anchorRect, JNIEnv *env = 0);
+ void showContextMenu(QAndroidPlatformMenu *menu, const QRect &anchorRect, JNIEnv *env);
void hideContextMenu(QAndroidPlatformMenu *menu);
void syncMenu(QAndroidPlatformMenu *menu);
void androidPlatformMenuDestroyed(QAndroidPlatformMenu *menu);
diff --git a/src/plugins/platforms/android/qandroidplatformclipboard.cpp b/src/plugins/platforms/android/qandroidplatformclipboard.cpp
index fb73db8455..2605ec9901 100644
--- a/src/plugins/platforms/android/qandroidplatformclipboard.cpp
+++ b/src/plugins/platforms/android/qandroidplatformclipboard.cpp
@@ -44,6 +44,7 @@ QAndroidPlatformClipboard::QAndroidPlatformClipboard()
QMimeData *QAndroidPlatformClipboard::mimeData(QClipboard::Mode mode)
{
+ Q_UNUSED(mode);
Q_ASSERT(supportsMode(mode));
m_mimeData.setText(QtAndroidClipboard::hasClipboardText()
? QtAndroidClipboard::clipboardText()
@@ -53,8 +54,8 @@ QMimeData *QAndroidPlatformClipboard::mimeData(QClipboard::Mode mode)
void QAndroidPlatformClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
{
- Q_ASSERT(supportsMode(mode));
- QtAndroidClipboard::setClipboardText(data != 0 && data->hasText() ? data->text() : QString());
+ if (supportsMode(mode))
+ QtAndroidClipboard::setClipboardText(data != 0 && data->hasText() ? data->text() : QString());
if (data != 0)
data->deleteLater();
}
diff --git a/src/plugins/platforms/android/qandroidplatformintegration.cpp b/src/plugins/platforms/android/qandroidplatformintegration.cpp
index 8a3a958d3b..07bdf95bf4 100644
--- a/src/plugins/platforms/android/qandroidplatformintegration.cpp
+++ b/src/plugins/platforms/android/qandroidplatformintegration.cpp
@@ -78,10 +78,24 @@ void *QAndroidPlatformNativeInterface::nativeResourceForIntegration(const QByteA
return QtAndroid::javaVM();
if (resource == "QtActivity")
return QtAndroid::activity();
- if (resource == "AndroidStylePalettes")
- return &m_palettes;
- if (resource == "AndroidStyleFonts")
- return &m_fonts;
+ if (resource == "AndroidStyleData") {
+ if (m_androidStyle)
+ return &m_androidStyle->m_styleData;
+ else
+ return Q_NULLPTR;
+ }
+ if (resource == "AndroidStandardPalette") {
+ if (m_androidStyle)
+ return &m_androidStyle->m_standardPalette;
+ else
+ return Q_NULLPTR;
+ }
+ if (resource == "AndroidQWidgetFonts") {
+ if (m_androidStyle)
+ return &m_androidStyle->m_QWidgetsFonts;
+ else
+ return Q_NULLPTR;
+ }
if (resource == "AndroidDeviceName") {
static QString deviceName = QtAndroid::deviceName();
return &deviceName;
diff --git a/src/plugins/platforms/android/qandroidplatformintegration.h b/src/plugins/platforms/android/qandroidplatformintegration.h
index 13c98442e9..7b4ab08847 100644
--- a/src/plugins/platforms/android/qandroidplatformintegration.h
+++ b/src/plugins/platforms/android/qandroidplatformintegration.h
@@ -44,6 +44,8 @@
#include "qandroidplatformscreen.h"
+#include <memory>
+
QT_BEGIN_NAMESPACE
class QDesktopWidget;
@@ -51,12 +53,12 @@ class QAndroidPlatformServices;
class QAndroidSystemLocale;
class QPlatformAccessibility;
+struct AndroidStyle;
class QAndroidPlatformNativeInterface: public QPlatformNativeInterface
{
public:
void *nativeResourceForIntegration(const QByteArray &resource);
- QHash<int, QPalette> m_palettes;
- QHash<int, QFont> m_fonts;
+ std::shared_ptr<AndroidStyle> m_androidStyle;
};
class QAndroidPlatformIntegration : public QPlatformIntegration
diff --git a/src/plugins/platforms/android/qandroidplatformmenu.cpp b/src/plugins/platforms/android/qandroidplatformmenu.cpp
index f3505fac3c..8f992f6bea 100644
--- a/src/plugins/platforms/android/qandroidplatformmenu.cpp
+++ b/src/plugins/platforms/android/qandroidplatformmenu.cpp
@@ -34,6 +34,7 @@
#include "qandroidplatformmenu.h"
#include "qandroidplatformmenuitem.h"
#include "androidjnimenu.h"
+#include <QtCore/private/qjni_p.h>
QT_BEGIN_NAMESPACE
@@ -140,7 +141,7 @@ void QAndroidPlatformMenu::showPopup(const QWindow *parentWindow, const QRect &t
Q_UNUSED(parentWindow);
Q_UNUSED(item);
setVisible(true);
- QtAndroidMenu::showContextMenu(this, targetRect);
+ QtAndroidMenu::showContextMenu(this, targetRect, QJNIEnvironmentPrivate());
}
QPlatformMenuItem *QAndroidPlatformMenu::menuItemAt(int position) const
diff --git a/src/plugins/platforms/android/qandroidplatformtheme.cpp b/src/plugins/platforms/android/qandroidplatformtheme.cpp
index 914de9d270..b955cff44d 100644
--- a/src/plugins/platforms/android/qandroidplatformtheme.cpp
+++ b/src/plugins/platforms/android/qandroidplatformtheme.cpp
@@ -37,17 +37,281 @@
#include "qandroidplatformmenu.h"
#include "qandroidplatformmenuitem.h"
#include "qandroidplatformdialoghelpers.h"
-#include <QVariant>
-#include <QFileInfo>
+
#include <QCoreApplication>
+#include <QDebug>
+#include <QFileInfo>
+#include <QJsonDocument>
+#include <QVariant>
+
#include <private/qguiapplication_p.h>
#include <qandroidplatformintegration.h>
QT_BEGIN_NAMESPACE
+namespace {
+ const int textStyle_bold = 1;
+ const int textStyle_italic = 2;
+
+ const int typeface_sans = 1;
+ const int typeface_serif = 2;
+ const int typeface_monospace = 3;
+}
+
+static int fontType(const QString &androidControl)
+{
+ if (androidControl == QLatin1String("defaultStyle"))
+ return QPlatformTheme::SystemFont;
+ if (androidControl == QLatin1String("textViewStyle"))
+ return QPlatformTheme::LabelFont;
+ else if (androidControl == QLatin1String("buttonStyle"))
+ return QPlatformTheme::PushButtonFont;
+ else if (androidControl == QLatin1String("checkboxStyle"))
+ return QPlatformTheme::CheckBoxFont;
+ else if (androidControl == QLatin1String("radioButtonStyle"))
+ return QPlatformTheme::RadioButtonFont;
+ else if (androidControl == QLatin1String("simple_list_item_single_choice"))
+ return QPlatformTheme::ItemViewFont;
+ else if (androidControl == QLatin1String("simple_spinner_dropdown_item"))
+ return QPlatformTheme::ComboMenuItemFont;
+ else if (androidControl == QLatin1String("spinnerStyle"))
+ return QPlatformTheme::ComboLineEditFont;
+ else if (androidControl == QLatin1String("simple_list_item"))
+ return QPlatformTheme::ListViewFont;
+ return -1;
+}
+
+static int paletteType(const QString &androidControl)
+{
+ if (androidControl == QLatin1String("defaultStyle"))
+ return QPlatformTheme::SystemPalette;
+ if (androidControl == QLatin1String("textViewStyle"))
+ return QPlatformTheme::LabelPalette;
+ else if (androidControl == QLatin1String("buttonStyle"))
+ return QPlatformTheme::ButtonPalette;
+ else if (androidControl == QLatin1String("checkboxStyle"))
+ return QPlatformTheme::CheckBoxPalette;
+ else if (androidControl == QLatin1String("radioButtonStyle"))
+ return QPlatformTheme::RadioButtonPalette;
+ else if (androidControl == QLatin1String("simple_list_item_single_choice"))
+ return QPlatformTheme::ItemViewPalette;
+ else if (androidControl == QLatin1String("editTextStyle"))
+ return QPlatformTheme::TextLineEditPalette;
+ else if (androidControl == QLatin1String("spinnerStyle"))
+ return QPlatformTheme::ComboBoxPalette;
+ return -1;
+}
+
+static void setPaletteColor(const QVariantMap &object,
+ QPalette &palette,
+ QPalette::ColorRole role)
+{
+ // QPalette::Active -> ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET
+ palette.setColor(QPalette::Active,
+ role,
+ QRgb(object.value(QLatin1String("ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET")).toInt()));
+
+ // QPalette::Inactive -> ENABLED_STATE_SET
+ palette.setColor(QPalette::Inactive,
+ role,
+ QRgb(object.value(QLatin1String("ENABLED_STATE_SET")).toInt()));
+
+ // QPalette::Disabled -> EMPTY_STATE_SET
+ palette.setColor(QPalette::Disabled,
+ role,
+ QRgb(object.value(QLatin1String("EMPTY_STATE_SET")).toInt()));
+
+ palette.setColor(QPalette::Current, role, palette.color(QPalette::Active, role));
+
+ if (role == QPalette::WindowText) {
+ // QPalette::BrightText -> PRESSED
+ // QPalette::Active -> PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET
+ palette.setColor(QPalette::Active,
+ QPalette::BrightText,
+ QRgb(object.value(QLatin1String("PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET")).toInt()));
+
+ // QPalette::Inactive -> PRESSED_ENABLED_STATE_SET
+ palette.setColor(QPalette::Inactive,
+ QPalette::BrightText,
+ QRgb(object.value(QLatin1String("PRESSED_ENABLED_STATE_SET")).toInt()));
+
+ // QPalette::Disabled -> PRESSED_STATE_SET
+ palette.setColor(QPalette::Disabled,
+ QPalette::BrightText,
+ QRgb(object.value(QLatin1String("PRESSED_STATE_SET")).toInt()));
+
+ palette.setColor(QPalette::Current, QPalette::BrightText, palette.color(QPalette::Active, QPalette::BrightText));
+
+ // QPalette::HighlightedText -> SELECTED
+ // QPalette::Active -> ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET
+ palette.setColor(QPalette::Active,
+ QPalette::HighlightedText,
+ QRgb(object.value(QLatin1String("ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET")).toInt()));
+
+ // QPalette::Inactive -> ENABLED_SELECTED_STATE_SET
+ palette.setColor(QPalette::Inactive,
+ QPalette::HighlightedText,
+ QRgb(object.value(QLatin1String("ENABLED_SELECTED_STATE_SET")).toInt()));
+
+ // QPalette::Disabled -> SELECTED_STATE_SET
+ palette.setColor(QPalette::Disabled,
+ QPalette::HighlightedText,
+ QRgb(object.value(QLatin1String("SELECTED_STATE_SET")).toInt()));
+
+ palette.setColor(QPalette::Current,
+ QPalette::HighlightedText,
+ palette.color(QPalette::Active, QPalette::HighlightedText));
+
+ // Same colors for Text
+ palette.setColor(QPalette::Active, QPalette::Text, palette.color(QPalette::Active, role));
+ palette.setColor(QPalette::Inactive, QPalette::Text, palette.color(QPalette::Inactive, role));
+ palette.setColor(QPalette::Disabled, QPalette::Text, palette.color(QPalette::Disabled, role));
+ palette.setColor(QPalette::Current, QPalette::Text, palette.color(QPalette::Current, role));
+
+ // And for ButtonText
+ palette.setColor(QPalette::Active, QPalette::ButtonText, palette.color(QPalette::Active, role));
+ palette.setColor(QPalette::Inactive, QPalette::ButtonText, palette.color(QPalette::Inactive, role));
+ palette.setColor(QPalette::Disabled, QPalette::ButtonText, palette.color(QPalette::Disabled, role));
+ palette.setColor(QPalette::Current, QPalette::ButtonText, palette.color(QPalette::Current, role));
+ }
+}
+
+static std::shared_ptr<AndroidStyle> loadAndroidStyle(QPalette *defaultPalette)
+{
+ QString stylePath(QLatin1String(qgetenv("MINISTRO_ANDROID_STYLE_PATH")));
+ const QLatin1Char slashChar('/');
+ if (!stylePath.isEmpty() && !stylePath.endsWith(slashChar))
+ stylePath += slashChar;
+
+ QString androidTheme = QLatin1String(qgetenv("QT_ANDROID_THEME"));
+ if (!androidTheme.isEmpty() && !androidTheme.endsWith(slashChar))
+ androidTheme += slashChar;
+
+ if (stylePath.isEmpty()) {
+ stylePath = QLatin1String("/data/data/org.kde.necessitas.ministro/files/dl/style/")
+ + QLatin1String(qgetenv("QT_ANDROID_THEME_DISPLAY_DPI")) + slashChar;
+ }
+ Q_ASSERT(!stylePath.isEmpty());
+
+ if (!androidTheme.isEmpty() && QFileInfo(stylePath + androidTheme + QLatin1String("style.json")).exists())
+ stylePath += androidTheme;
+
+ QFile f(stylePath + QLatin1String("style.json"));
+ if (!f.open(QIODevice::ReadOnly))
+ return std::shared_ptr<AndroidStyle>();
+
+ QJsonParseError error;
+ QJsonDocument document = QJsonDocument::fromJson(f.readAll(), &error);
+ if (document.isNull()) {
+ qCritical() << error.errorString();
+ return std::shared_ptr<AndroidStyle>();
+ }
+
+ if (!document.isObject()) {
+ qCritical() << "Style.json does not contain a valid style.";
+ return std::shared_ptr<AndroidStyle>();
+ }
+ std::shared_ptr<AndroidStyle> style(new AndroidStyle);
+ style->m_styleData = document.object();
+ for (QJsonObject::const_iterator objectIterator = style->m_styleData.constBegin();
+ objectIterator != style->m_styleData.constEnd();
+ ++objectIterator) {
+ QString key = objectIterator.key();
+ QJsonValue value = objectIterator.value();
+ if (!value.isObject()) {
+ qWarning("Style.json structure is unrecognized.");
+ continue;
+ }
+ QJsonObject item = value.toObject();
+ QJsonObject::const_iterator attributeIterator = item.find(QLatin1String("qtClass"));
+ QByteArray qtClassName;
+ if (attributeIterator != item.constEnd()) {
+ // The item has palette and font information for a specific Qt Class (e.g. QWidget, QPushButton, etc.)
+ qtClassName = attributeIterator.value().toString().toLatin1();
+ }
+ const int ft = fontType(key);
+ if (ft > -1 || !qtClassName.isEmpty()) {
+ // Extract font information
+ QFont font;
+
+ // Font size (in pixels)
+ attributeIterator = item.find(QLatin1String("TextAppearance_textSize"));
+ if (attributeIterator != item.constEnd())
+ font.setPixelSize(int(attributeIterator.value().toDouble()));
+
+ // Font style
+ attributeIterator = item.find(QLatin1String("TextAppearance_textStyle"));
+ if (attributeIterator != item.constEnd()) {
+ const int style = int(attributeIterator.value().toDouble());
+ font.setBold(style & textStyle_bold);
+ font.setItalic(style & textStyle_italic);
+ }
+
+ // Font typeface
+ attributeIterator = item.find(QLatin1String("TextAppearance_typeface"));
+ if (attributeIterator != item.constEnd()) {
+ QFont::StyleHint styleHint = QFont::AnyStyle;
+ switch (int(attributeIterator.value().toDouble())) {
+ case typeface_sans:
+ styleHint = QFont::SansSerif;
+ break;
+ case typeface_serif:
+ styleHint = QFont::Serif;
+ break;
+ case typeface_monospace:
+ styleHint = QFont::Monospace;
+ break;
+ }
+ font.setStyleHint(styleHint, QFont::PreferMatch);
+ }
+ if (!qtClassName.isEmpty())
+ style->m_QWidgetsFonts.insert(qtClassName, font);
+
+ if (ft > -1) {
+ style->m_fonts.insert(ft, font);
+ if (ft == QPlatformTheme::SystemFont)
+ QGuiApplication::setFont(font);
+ }
+ // Extract font information
+ }
+
+ const int pt = paletteType(key);
+ if (pt > -1 || !qtClassName.isEmpty()) {
+ // Extract palette information
+ QPalette palette;
+ attributeIterator = item.find(QLatin1String("defaultTextColorPrimary"));
+ if (attributeIterator != item.constEnd())
+ palette.setColor(QPalette::WindowText, QRgb(int(attributeIterator.value().toDouble())));
+
+ attributeIterator = item.find(QLatin1String("defaultBackgroundColor"));
+ if (attributeIterator != item.constEnd())
+ palette.setColor(QPalette::Background, QRgb(int(attributeIterator.value().toDouble())));
+
+ attributeIterator = item.find(QLatin1String("TextAppearance_textColor"));
+ if (attributeIterator != item.constEnd())
+ setPaletteColor(attributeIterator.value().toObject().toVariantMap(), palette, QPalette::WindowText);
+
+ attributeIterator = item.find(QLatin1String("TextAppearance_textColorLink"));
+ if (attributeIterator != item.constEnd())
+ setPaletteColor(attributeIterator.value().toObject().toVariantMap(), palette, QPalette::Link);
+
+ attributeIterator = item.find(QLatin1String("TextAppearance_textColorHighlight"));
+ if (attributeIterator != item.constEnd())
+ palette.setColor(QPalette::Highlight, QRgb(int(attributeIterator.value().toDouble())));
+
+ if (pt == QPlatformTheme::SystemPalette)
+ *defaultPalette = style->m_standardPalette = palette;
+
+ if (pt > -1)
+ style->m_palettes.insert(pt, palette);
+ // Extract palette information
+ }
+ }
+ return style;
+}
+
QAndroidPlatformTheme::QAndroidPlatformTheme(QAndroidPlatformNativeInterface *androidPlatformNativeInterface)
{
- m_androidPlatformNativeInterface = androidPlatformNativeInterface;
QColor background(229, 229, 229);
QColor light = background.lighter(150);
QColor mid(background.darker(130));
@@ -80,6 +344,9 @@ QAndroidPlatformTheme::QAndroidPlatformTheme(QAndroidPlatformNativeInterface *an
m_defaultPalette.setBrush(QPalette::Active, QPalette::Highlight, highlight);
m_defaultPalette.setBrush(QPalette::Inactive, QPalette::Highlight, highlight);
m_defaultPalette.setBrush(QPalette::Disabled, QPalette::Highlight, highlight.lighter(150));
+ m_androidStyleData = loadAndroidStyle(&m_defaultPalette);
+ QGuiApplication::setPalette(m_defaultPalette);
+ androidPlatformNativeInterface->m_androidStyle = m_androidStyleData;
}
QPlatformMenuBar *QAndroidPlatformTheme::createPlatformMenuBar() const
@@ -132,9 +399,11 @@ static inline int paletteType(QPlatformTheme::Palette type)
const QPalette *QAndroidPlatformTheme::palette(Palette type) const
{
- QHash<int, QPalette>::const_iterator it = m_androidPlatformNativeInterface->m_palettes.find(paletteType(type));
- if (it != m_androidPlatformNativeInterface->m_palettes.end())
- return &(it.value());
+ if (m_androidStyleData) {
+ auto it = m_androidStyleData->m_palettes.find(paletteType(type));
+ if (it != m_androidStyleData->m_palettes.end())
+ return &(it.value());
+ }
return &m_defaultPalette;
}
@@ -154,9 +423,11 @@ static inline int fontType(QPlatformTheme::Font type)
const QFont *QAndroidPlatformTheme::font(Font type) const
{
- QHash<int, QFont>::const_iterator it = m_androidPlatformNativeInterface->m_fonts.find(fontType(type));
- if (it != m_androidPlatformNativeInterface->m_fonts.end())
- return &(it.value());
+ if (m_androidStyleData) {
+ auto it = m_androidStyleData->m_fonts.find(fontType(type));
+ if (it != m_androidStyleData->m_fonts.end())
+ return &(it.value());
+ }
// default in case the style has not set a font
static QFont systemFont("Roboto", 14.0 * 100 / 72); // keep default size the same after changing from 100 dpi to 72 dpi
@@ -165,18 +436,12 @@ const QFont *QAndroidPlatformTheme::font(Font type) const
return 0;
}
-static const QLatin1String STYLES_PATH("/data/data/org.kde.necessitas.ministro/files/dl/style/");
-static const QLatin1String STYLE_FILE("/style.json");
-
QVariant QAndroidPlatformTheme::themeHint(ThemeHint hint) const
{
switch (hint) {
case StyleNames:
if (qEnvironmentVariableIntValue("QT_USE_ANDROID_NATIVE_STYLE")
- && (!qgetenv("MINISTRO_ANDROID_STYLE_PATH").isEmpty()
- || QFileInfo(STYLES_PATH
- + QLatin1String(qgetenv("QT_ANDROID_THEME_DISPLAY_DPI"))
- + STYLE_FILE).exists())) {
+ && m_androidStyleData) {
return QStringList("android");
}
return QStringList("fusion");
diff --git a/src/plugins/platforms/android/qandroidplatformtheme.h b/src/plugins/platforms/android/qandroidplatformtheme.h
index 01611bf9d4..334e86ad7a 100644
--- a/src/plugins/platforms/android/qandroidplatformtheme.h
+++ b/src/plugins/platforms/android/qandroidplatformtheme.h
@@ -37,8 +37,22 @@
#include <qpa/qplatformtheme.h>
#include <QtGui/qpalette.h>
+#include <QJsonObject>
+
+#include <memory>
+
QT_BEGIN_NAMESPACE
+struct AndroidStyle
+{
+ QJsonObject m_styleData;
+ QPalette m_standardPalette;
+ QHash<int, QPalette> m_palettes;
+ QHash<int, QFont> m_fonts;
+ QHash<QByteArray, QFont> m_QWidgetsFonts;
+ QHash<QByteArray, QFont> m_QWidgetsPalettes;
+};
+
class QAndroidPlatformNativeInterface;
class QAndroidPlatformTheme: public QPlatformTheme
{
@@ -57,7 +71,7 @@ public:
private:
- QAndroidPlatformNativeInterface * m_androidPlatformNativeInterface;
+ std::shared_ptr<AndroidStyle> m_androidStyleData;
QPalette m_defaultPalette;
};
diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.h b/src/plugins/platforms/cocoa/qcocoabackingstore.h
index bfff5c3266..917f020132 100644
--- a/src/plugins/platforms/cocoa/qcocoabackingstore.h
+++ b/src/plugins/platforms/cocoa/qcocoabackingstore.h
@@ -51,12 +51,9 @@ public:
QPaintDevice *paintDevice();
void flush(QWindow *widget, const QRegion &region, const QPoint &offset);
-#ifndef QT_NO_OPENGL
- QImage toImage() const Q_DECL_OVERRIDE;
-#endif
+ QImage toImage() const;
void resize (const QSize &size, const QRegion &);
bool scroll(const QRegion &area, int dx, int dy);
- CGImageRef getBackingStoreCGImage();
qreal getBackingStoreDevicePixelRatio();
private:
diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
index e13e295511..ba1198c19c 100644
--- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm
+++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
@@ -96,12 +96,10 @@ void QCocoaBackingStore::flush(QWindow *win, const QRegion &region, const QPoint
}
}
-#ifndef QT_NO_OPENGL
QImage QCocoaBackingStore::toImage() const
{
return m_qImage;
}
-#endif
void QCocoaBackingStore::resize(const QSize &size, const QRegion &)
{
@@ -121,17 +119,6 @@ bool QCocoaBackingStore::scroll(const QRegion &area, int dx, int dy)
return true;
}
-CGImageRef QCocoaBackingStore::getBackingStoreCGImage()
-{
- if (!m_cgImage)
- m_cgImage = qt_mac_toCGImage(m_qImage);
-
- // Warning: do not retain/release/cache the returned image from
- // outside the backingstore since it shares data with a QImage and
- // needs special memory considerations.
- return m_cgImage;
-}
-
qreal QCocoaBackingStore::getBackingStoreDevicePixelRatio()
{
return m_qImage.devicePixelRatio();
diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
index 8158c244ab..7d99f566bf 100644
--- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -106,10 +106,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
mResultSet = false;
mClosingDueToKnownButton = false;
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7)
- [mColorPanel setRestorable:NO];
-#endif
+ [mColorPanel setRestorable:NO];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(colorChanged:)
diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
index c37bb63916..f5e22d1125 100644
--- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
@@ -149,11 +149,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
mDialogIsExecuting = false;
mResultSet = false;
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7)
- [mFontPanel setRestorable:NO];
-#endif
-
+ [mFontPanel setRestorable:NO];
[mFontPanel setDelegate:self];
[[NSFontManager sharedFontManager] setDelegate:self];
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index e0838cb342..72bd09625a 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the plugins of the Qt Toolkit.
@@ -144,15 +144,8 @@ void QCocoaScreen::updateGeometry()
qreal QCocoaScreen::devicePixelRatio() const
{
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
- NSScreen * screen = osScreen();
- return qreal(screen ? [screen backingScaleFactor] : 1.0);
- } else
-#endif
- {
- return 1.0;
- }
+ NSScreen * screen = osScreen();
+ return qreal(screen ? [screen backingScaleFactor] : 1.0);
}
QWindow *QCocoaScreen::topLevelAt(const QPoint &point) const
diff --git a/src/plugins/platforms/cocoa/qcocoaintrospection.mm b/src/plugins/platforms/cocoa/qcocoaintrospection.mm
index 806effc929..84b16813dc 100644
--- a/src/plugins/platforms/cocoa/qcocoaintrospection.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintrospection.mm
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the plugins of the Qt Toolkit.
@@ -79,43 +79,33 @@ QT_BEGIN_NAMESPACE
void qt_cocoa_change_implementation(Class baseClass, SEL originalSel, Class proxyClass, SEL replacementSel, SEL backupSel)
{
-#ifndef QT_MAC_USE_COCOA
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5)
-#endif
- {
- // The following code replaces the _implementation_ for the selector we want to hack
- // (originalSel) with the implementation found in proxyClass. Then it creates
- // a new 'backup' method inside baseClass containing the old, original,
- // implementation (fakeSel). You can let the proxy implementation of originalSel
- // call fakeSel if needed (similar approach to calling a super class implementation).
- // fakeSel must also be implemented in proxyClass, as the signature is used
- // as template for the method one we add into baseClass.
- // NB: You will typically never create any instances of proxyClass; we use it
- // only for stealing its contents and put it into baseClass.
- if (!replacementSel)
- replacementSel = originalSel;
+ // The following code replaces the _implementation_ for the selector we want to hack
+ // (originalSel) with the implementation found in proxyClass. Then it creates
+ // a new 'backup' method inside baseClass containing the old, original,
+ // implementation (fakeSel). You can let the proxy implementation of originalSel
+ // call fakeSel if needed (similar approach to calling a super class implementation).
+ // fakeSel must also be implemented in proxyClass, as the signature is used
+ // as template for the method one we add into baseClass.
+ // NB: You will typically never create any instances of proxyClass; we use it
+ // only for stealing its contents and put it into baseClass.
+ if (!replacementSel)
+ replacementSel = originalSel;
- Method originalMethod = class_getInstanceMethod(baseClass, originalSel);
- Method replacementMethod = class_getInstanceMethod(proxyClass, replacementSel);
- IMP originalImp = method_setImplementation(originalMethod, method_getImplementation(replacementMethod));
+ Method originalMethod = class_getInstanceMethod(baseClass, originalSel);
+ Method replacementMethod = class_getInstanceMethod(proxyClass, replacementSel);
+ IMP originalImp = method_setImplementation(originalMethod, method_getImplementation(replacementMethod));
- if (backupSel) {
- Method backupMethod = class_getInstanceMethod(proxyClass, backupSel);
- class_addMethod(baseClass, backupSel, originalImp, method_getTypeEncoding(backupMethod));
- }
+ if (backupSel) {
+ Method backupMethod = class_getInstanceMethod(proxyClass, backupSel);
+ class_addMethod(baseClass, backupSel, originalImp, method_getTypeEncoding(backupMethod));
}
}
void qt_cocoa_change_back_implementation(Class baseClass, SEL originalSel, SEL backupSel)
{
-#ifndef QT_MAC_USE_COCOA
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5)
-#endif
- {
- Method originalMethod = class_getInstanceMethod(baseClass, originalSel);
- Method backupMethodInBaseClass = class_getInstanceMethod(baseClass, backupSel);
- method_setImplementation(originalMethod, method_getImplementation(backupMethodInBaseClass));
- }
+ Method originalMethod = class_getInstanceMethod(baseClass, originalSel);
+ Method backupMethodInBaseClass = class_getInstanceMethod(baseClass, backupSel);
+ method_setImplementation(originalMethod, method_getImplementation(backupMethodInBaseClass));
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm
index 791b0805d0..251fe9485c 100644
--- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm
@@ -323,17 +323,22 @@ NSMenuItem *QCocoaMenuItem::sync()
text += QLatin1String(" (") + accel.toString(QKeySequence::NativeText) + QLatin1String(")");
QString finalString = qt_mac_removeMnemonics(text);
+ bool useAttributedTitle = false;
// Cocoa Font and title
if (m_font.resolve()) {
NSFont *customMenuFont = [NSFont fontWithName:QCFString::toNSString(m_font.family())
size:m_font.pointSize()];
- NSArray *keys = [NSArray arrayWithObjects:NSFontAttributeName, nil];
- NSArray *objects = [NSArray arrayWithObjects:customMenuFont, nil];
- NSDictionary *attributes = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
- NSAttributedString *str = [[[NSAttributedString alloc] initWithString:QCFString::toNSString(finalString)
- attributes:attributes] autorelease];
- [m_native setAttributedTitle: str];
- } else {
+ if (customMenuFont) {
+ NSArray *keys = [NSArray arrayWithObjects:NSFontAttributeName, nil];
+ NSArray *objects = [NSArray arrayWithObjects:customMenuFont, nil];
+ NSDictionary *attributes = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
+ NSAttributedString *str = [[[NSAttributedString alloc] initWithString:QCFString::toNSString(finalString)
+ attributes:attributes] autorelease];
+ [m_native setAttributedTitle: str];
+ useAttributedTitle = true;
+ }
+ }
+ if (!useAttributedTitle) {
[m_native setTitle: QCFString::toNSString(finalString)];
}
diff --git a/src/plugins/platforms/cocoa/qcocoamimetypes.mm b/src/plugins/platforms/cocoa/qcocoamimetypes.mm
index 421d934fa7..b657ef9a82 100644
--- a/src/plugins/platforms/cocoa/qcocoamimetypes.mm
+++ b/src/plugins/platforms/cocoa/qcocoamimetypes.mm
@@ -88,9 +88,9 @@ QVariant QMacPasteboardMimeTraditionalMacPlainText::convertToMime(const QString
const QByteArray &firstData = data.first();
QVariant ret;
if (flavor == QLatin1String("com.apple.traditional-mac-plain-text")) {
- return QString::fromCFString(CFStringCreateWithBytes(kCFAllocatorDefault,
+ return QString(QCFString(CFStringCreateWithBytes(kCFAllocatorDefault,
reinterpret_cast<const UInt8 *>(firstData.constData()),
- firstData.size(), CFStringGetSystemEncoding(), false));
+ firstData.size(), CFStringGetSystemEncoding(), false)));
} else {
qWarning("QMime::convertToMime: unhandled mimetype: %s", qPrintable(mimetype));
}
diff --git a/src/plugins/platforms/cocoa/qcocoaprintdevice.mm b/src/plugins/platforms/cocoa/qcocoaprintdevice.mm
index 2101b68769..c26a2b22fd 100644
--- a/src/plugins/platforms/cocoa/qcocoaprintdevice.mm
+++ b/src/plugins/platforms/cocoa/qcocoaprintdevice.mm
@@ -466,17 +466,13 @@ bool QCocoaPrintDevice::openPpdFile()
ppdClose(m_ppd);
m_ppd = 0;
CFURLRef ppdURL = NULL;
-#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
- char ppdPath[PATH_MAX];
-#else
char ppdPath[MAXPATHLEN];
-#endif
if (PMPrinterCopyDescriptionURL(m_printer, kPMPPDDescriptionType, &ppdURL) == noErr
- && ppdURL != NULL
- && CFURLGetFileSystemRepresentation(ppdURL, true, (UInt8*)ppdPath, sizeof(ppdPath))) {
- m_ppd = ppdOpenFile(ppdPath);
+ && ppdURL != NULL) {
+ if (CFURLGetFileSystemRepresentation(ppdURL, true, (UInt8*)ppdPath, sizeof(ppdPath)))
+ m_ppd = ppdOpenFile(ppdPath);
+ CFRelease(ppdURL);
}
- CFRelease(ppdURL);
return m_ppd ? true : false;
}
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
index a43cf73d34..b232c7a4d3 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.h
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -268,6 +268,7 @@ public: // for QNSView
bool m_inConstructor;
bool m_inSetVisible;
+ bool m_inSetGeometry;
#ifndef QT_NO_OPENGL
QCocoaGLContext *m_glContext;
#endif
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 3366e5bc3c..6656212457 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the plugins of the Qt Toolkit.
@@ -107,26 +107,6 @@ static void selectNextKeyWindow(NSWindow *currentKeyWindow)
}
}
-
-@interface NSWindow (CocoaWindowCategory)
-- (NSRect) legacyConvertRectFromScreen:(NSRect) rect;
-@end
-
-@implementation NSWindow (CocoaWindowCategory)
-- (NSRect) legacyConvertRectFromScreen:(NSRect) rect
-{
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
- return [self convertRectFromScreen: rect];
- }
-#endif
- NSRect r = rect;
- r.origin = [self convertScreenToBase:rect.origin];
- return r;
-}
-@end
-
-
@implementation QNSWindowHelper
@synthesize window = _window;
@@ -197,7 +177,7 @@ static void selectNextKeyWindow(NSWindow *currentKeyWindow)
if (pw && pw->frameStrutEventsEnabled() && isMouseEvent(theEvent)) {
NSPoint loc = [theEvent locationInWindow];
- NSRect windowFrame = [self.window legacyConvertRectFromScreen:[self.window frame]];
+ NSRect windowFrame = [self.window convertRectFromScreen:[self.window frame]];
NSRect contentFrame = [[self.window contentView] frame];
if (NSMouseInRect(loc, windowFrame, NO) &&
!NSMouseInRect(loc, contentFrame, NO))
@@ -401,6 +381,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
, m_windowUnderMouse(false)
, m_inConstructor(true)
, m_inSetVisible(false)
+ , m_inSetGeometry(false)
#ifndef QT_NO_OPENGL
, m_glContext(0)
#endif
@@ -432,19 +413,16 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
} else {
m_qtView = [[QNSView alloc] initWithQWindow:tlw platformWindow:this];
m_contentView = m_qtView;
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
// Enable high-dpi OpenGL for retina displays. Enabling has the side
// effect that Cocoa will start calling glViewport(0, 0, width, height),
// overriding any glViewport calls in application code. This is usually not a
// problem, except if the appilcation wants to have a "custom" viewport.
// (like the hellogl example)
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7
- && tlw->supportsOpenGL()) {
+ if (tlw->supportsOpenGL()) {
BOOL enable = qt_mac_resolveOption(YES, tlw, "_q_mac_wantsBestResolutionOpenGLSurface",
"QT_MAC_WANTS_BEST_RESOLUTION_OPENGL_SURFACE");
[m_contentView setWantsBestResolutionOpenGLSurface:enable];
}
-#endif
BOOL enable = qt_mac_resolveOption(NO, tlw, "_q_mac_wantsLayer",
"QT_MAC_WANTS_LAYER");
[m_contentView setWantsLayer:enable];
@@ -493,6 +471,8 @@ QSurfaceFormat QCocoaWindow::format() const
void QCocoaWindow::setGeometry(const QRect &rectIn)
{
+ QBoolBlocker inSetGeometry(m_inSetGeometry, true);
+
QRect rect = rectIn;
// This means it is a call from QWindow::setFramePosition() and
// the coordinates include the frame (size is still the contents rectangle).
@@ -516,7 +496,8 @@ QRect QCocoaWindow::geometry() const
// of view. Embedded QWindows get global (screen) geometry.
if (m_contentViewIsEmbedded) {
NSPoint windowPoint = [m_contentView convertPoint:NSMakePoint(0, 0) toView:nil];
- NSPoint screenPoint = [[m_contentView window] convertBaseToScreen:windowPoint]; // ### use convertRectToScreen after 10.6 removal
+ NSRect screenRect = [[m_contentView window] convertRectToScreen:NSMakeRect(windowPoint.x, windowPoint.y, 1, 1)];
+ NSPoint screenPoint = screenRect.origin;
QPoint position = qt_mac_flipPoint(screenPoint).toPoint();
QSize size = qt_mac_toQRect([m_contentView bounds]).size();
return QRect(position, size);
@@ -681,11 +662,7 @@ void QCocoaWindow::setVisible(bool visible)
// Since this isn't a native popup, the window manager doesn't close the popup when you click outside
NSUInteger parentStyleMask = [parentCocoaWindow->m_nsWindow styleMask];
if ((m_resizableTransientParent = (parentStyleMask & NSResizableWindowMask))
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- && QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7
- && !([parentCocoaWindow->m_nsWindow styleMask] & NSFullScreenWindowMask)
-#endif
- )
+ && !([parentCocoaWindow->m_nsWindow styleMask] & NSFullScreenWindowMask))
[parentCocoaWindow->m_nsWindow setStyleMask:parentStyleMask & ~NSResizableWindowMask];
}
@@ -784,11 +761,7 @@ void QCocoaWindow::setVisible(bool visible)
if (parentCocoaWindow && window()->type() == Qt::Popup) {
parentCocoaWindow->m_activePopupWindow = 0;
if (m_resizableTransientParent
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- && QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7
- && !([parentCocoaWindow->m_nsWindow styleMask] & NSFullScreenWindowMask)
-#endif
- )
+ && !([parentCocoaWindow->m_nsWindow styleMask] & NSFullScreenWindowMask))
// QTBUG-30266: a window should not be resizable while a transient popup is open
[parentCocoaWindow->m_nsWindow setStyleMask:[parentCocoaWindow->m_nsWindow styleMask] | NSResizableWindowMask];
}
@@ -903,19 +876,15 @@ void QCocoaWindow::setWindowFlags(Qt::WindowFlags flags)
setWindowTitle(window()->title());
}
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
- Qt::WindowType type = window()->type();
- if ((type & Qt::Popup) != Qt::Popup && (type & Qt::Dialog) != Qt::Dialog) {
- NSWindowCollectionBehavior behavior = [m_nsWindow collectionBehavior];
- if (flags & Qt::WindowFullscreenButtonHint)
- behavior |= NSWindowCollectionBehaviorFullScreenPrimary;
- else
- behavior &= ~NSWindowCollectionBehaviorFullScreenPrimary;
- [m_nsWindow setCollectionBehavior:behavior];
- }
+ Qt::WindowType type = window()->type();
+ if ((type & Qt::Popup) != Qt::Popup && (type & Qt::Dialog) != Qt::Dialog) {
+ NSWindowCollectionBehavior behavior = [m_nsWindow collectionBehavior];
+ if (flags & Qt::WindowFullscreenButtonHint)
+ behavior |= NSWindowCollectionBehaviorFullScreenPrimary;
+ else
+ behavior &= ~NSWindowCollectionBehaviorFullScreenPrimary;
+ [m_nsWindow setCollectionBehavior:behavior];
}
-#endif
setWindowZoomButton(flags);
}
@@ -1340,13 +1309,9 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
m_nsWindow.hasShadow = NO;
m_nsWindow.level = NSNormalWindowLevel;
NSWindowCollectionBehavior collectionBehavior =
- NSWindowCollectionBehaviorManaged | NSWindowCollectionBehaviorIgnoresCycle;
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
- collectionBehavior |= NSWindowCollectionBehaviorFullScreenAuxiliary;
- m_nsWindow.animationBehavior = NSWindowAnimationBehaviorNone;
- }
-#endif
+ NSWindowCollectionBehaviorManaged | NSWindowCollectionBehaviorIgnoresCycle
+ | NSWindowCollectionBehaviorFullScreenAuxiliary;
+ m_nsWindow.animationBehavior = NSWindowAnimationBehaviorNone;
m_nsWindow.collectionBehavior = collectionBehavior;
setCocoaGeometry(window()->geometry());
@@ -1438,17 +1403,17 @@ QCocoaNSWindow * QCocoaWindow::createNSWindow()
if ((type & Qt::Popup) == Qt::Popup)
[window setHasShadow:YES];
- [window setHidesOnDeactivate:(type & Qt::Tool) == Qt::Tool];
+ // Qt::Tool windows hide on app deactivation, unless Qt::WA_MacAlwaysShowToolWindow is set.
+ QVariant showWithoutActivating = QPlatformWindow::window()->property("_q_macAlwaysShowToolWindow");
+ bool shouldHideOnDeactivate = ((type & Qt::Tool) == Qt::Tool) &&
+ !(showWithoutActivating.isValid() && showWithoutActivating.toBool());
+ [window setHidesOnDeactivate: shouldHideOnDeactivate];
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
- // Make popup winows show on the same desktop as the parent full-screen window.
- [window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary];
+ // Make popup windows show on the same desktop as the parent full-screen window.
+ [window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary];
+ if ((type & Qt::Popup) == Qt::Popup)
+ [window setAnimationBehavior:NSWindowAnimationBehaviorUtilityWindow];
- if ((type & Qt::Popup) == Qt::Popup)
- [window setAnimationBehavior:NSWindowAnimationBehaviorUtilityWindow];
- }
-#endif
createdWindow = window;
} else {
QNSWindow *window;
@@ -1458,10 +1423,8 @@ QCocoaNSWindow * QCocoaWindow::createNSWindow()
createdWindow = window;
}
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
if ([createdWindow respondsToSelector:@selector(setRestorable:)])
[createdWindow setRestorable: NO];
-#endif
NSInteger level = windowLevel(flags);
[createdWindow setLevel:level];
@@ -1562,18 +1525,11 @@ void QCocoaWindow::syncWindowState(Qt::WindowState newState)
}
if ((m_synchedWindowState & Qt::WindowFullScreen) != (newState & Qt::WindowFullScreen)) {
- bool fakeFullScreen = true;
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
- if (window()->flags() & Qt::WindowFullscreenButtonHint) {
- fakeFullScreen = false;
- if (m_effectivelyMaximized && m_synchedWindowState == Qt::WindowFullScreen)
- predictedState = Qt::WindowMaximized;
- [m_nsWindow toggleFullScreen : m_nsWindow];
- }
- }
-#endif
- if (fakeFullScreen) {
+ if (window()->flags() & Qt::WindowFullscreenButtonHint) {
+ if (m_effectivelyMaximized && m_synchedWindowState == Qt::WindowFullScreen)
+ predictedState = Qt::WindowMaximized;
+ [m_nsWindow toggleFullScreen : m_nsWindow];
+ } else {
if (newState & Qt::WindowFullScreen) {
QScreen *screen = window()->screen();
if (screen) {
@@ -1747,20 +1703,13 @@ bool QCocoaWindow::testContentBorderAreaPosition(int position) const
qreal QCocoaWindow::devicePixelRatio() const
{
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
- // The documented way to observe the relationship between device-independent
- // and device pixels is to use one for the convertToBacking functions. Other
- // methods such as [NSWindow backingScaleFacor] might not give the correct
- // result, for example if setWantsBestResolutionOpenGLSurface is not set or
- // or ignored by the OpenGL driver.
- NSSize backingSize = [m_contentView convertSizeToBacking:NSMakeSize(1.0, 1.0)];
- return backingSize.height;
- } else
-#endif
- {
- return 1.0;
- }
+ // The documented way to observe the relationship between device-independent
+ // and device pixels is to use one for the convertToBacking functions. Other
+ // methods such as [NSWindow backingScaleFacor] might not give the correct
+ // result, for example if setWantsBestResolutionOpenGLSurface is not set or
+ // or ignored by the OpenGL driver.
+ NSSize backingSize = [m_contentView convertSizeToBacking:NSMakeSize(1.0, 1.0)];
+ return backingSize.height;
}
// Returns whether the window can be expose, which it can
@@ -1808,10 +1757,15 @@ void QCocoaWindow::updateExposedGeometry()
if (!m_geometryUpdateExposeAllowed)
return;
+ // Do not send incorrect exposes in case the window is not even visible yet.
+ // We might get here as a result of a resize() from QWidget's show(), for instance.
+ if (!window()->isVisible())
+ return;
+
if (!isWindowExposable())
return;
- if (m_exposedGeometry == geometry() && m_exposedDevicePixelRatio == devicePixelRatio())
+ if (m_exposedGeometry.size() == geometry().size() && m_exposedDevicePixelRatio == devicePixelRatio())
return;
m_isExposed = true;
diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h
index 8b23f84a25..8d8df13dc3 100644
--- a/src/plugins/platforms/cocoa/qnsview.h
+++ b/src/plugins/platforms/cocoa/qnsview.h
@@ -51,7 +51,8 @@ QT_END_NAMESPACE
Q_FORWARD_DECLARE_OBJC_CLASS(QNSViewMouseMoveHelper);
@interface QT_MANGLE_NAMESPACE(QNSView) : NSView <NSTextInputClient> {
- QCocoaBackingStore* m_backingStore;
+ QImage m_backingStore;
+ qreal m_pixelRatio;
QPoint m_backingStoreOffset;
CGImageRef m_maskImage;
uchar *m_maskData;
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 1f58a0457f..0ce5b3b332 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -143,7 +143,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
{
self = [super initWithFrame : NSMakeRect(0,0, 300,300)];
if (self) {
- m_backingStore = 0;
+ m_pixelRatio = 1.;
m_maskImage = 0;
m_shouldInvalidateWindowShadow = false;
m_window = 0;
@@ -361,12 +361,11 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
// Send a geometry change event to Qt, if it's ready to handle events
if (!m_platformWindow->m_inConstructor) {
QWindowSystemInterface::handleGeometryChange(m_window, geometry);
- // Do not send incorrect exposes in case the window is not even visible yet.
- // We might get here as a result of a resize() from QWidget's show(), for instance.
- if (m_platformWindow->window()->isVisible()) {
- m_platformWindow->updateExposedGeometry();
+ m_platformWindow->updateExposedGeometry();
+ // Guard against processing window system events during QWindow::setGeometry
+ // calles, which Qt and Qt applications do not excpect.
+ if (!m_platformWindow->m_inSetGeometry)
QWindowSystemInterface::flushWindowSystemEvents();
- }
}
}
@@ -408,10 +407,6 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
Qt::WindowState newState = notificationName == NSWindowDidMiniaturizeNotification ?
Qt::WindowMinimized : Qt::WindowNoState;
[self notifyWindowStateChanged:newState];
- // NSWindowDidOrderOnScreenAndFinishAnimatingNotification is private API, and not
- // emitted in 10.6, so we bring back the old behavior for that case alone.
- if (newState == Qt::WindowNoState && QSysInfo::QSysInfo::MacintoshVersion == QSysInfo::MV_10_6)
- m_platformWindow->exposeWindow();
} else if ([notificationName isEqualToString: @"NSWindowDidOrderOffScreenNotification"]) {
m_platformWindow->obscureWindow();
} else if ([notificationName isEqualToString: @"NSWindowDidOrderOnScreenAndFinishAnimatingNotification"]) {
@@ -424,12 +419,17 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
#pragma clang diagnostic ignored "-Wobjc-method-access"
enum { NSWindowOcclusionStateVisible = 1UL << 1 };
#endif
- // Older versions managed in -[QNSView viewDidMoveToWindow].
- // Support QWidgetAction in NSMenu. Mavericks only sends this notification.
- // Ideally we should support this in Qt as well, in order to disable animations
- // when the window is occluded.
- if ((NSUInteger)[self.window occlusionState] & NSWindowOcclusionStateVisible)
+ if ((NSUInteger)[self.window occlusionState] & NSWindowOcclusionStateVisible) {
m_platformWindow->exposeWindow();
+ } else {
+ // Send Obscure events on window occlusion to stop animations. Several
+ // unit tests expect paint and/or expose events for windows that are
+ // sometimes (unpredictably) occlouded: Don't send Obscure events when
+ // running under QTestLib.
+ static bool onTestLib = qt_mac_resolveOption(false, "QT_QTESTLIB_RUNNING");
+ if (!onTestLib)
+ m_platformWindow->obscureWindow();
+ }
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9
#pragma clang diagnostic pop
#endif
@@ -437,24 +437,16 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
if (m_window) {
NSUInteger screenIndex = [[NSScreen screens] indexOfObject:self.window.screen];
if (screenIndex != NSNotFound) {
- m_platformWindow->updateExposedGeometry();
QCocoaScreen *cocoaScreen = QCocoaIntegration::instance()->screenAtIndex(screenIndex);
QWindowSystemInterface::handleWindowScreenChanged(m_window, cocoaScreen->screen());
+ m_platformWindow->updateExposedGeometry();
}
}
- } else {
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
- if (notificationName == NSWindowDidEnterFullScreenNotification
- || notificationName == NSWindowDidExitFullScreenNotification) {
- Qt::WindowState newState = notificationName == NSWindowDidEnterFullScreenNotification ?
- Qt::WindowFullScreen : Qt::WindowNoState;
- [self notifyWindowStateChanged:newState];
- }
- }
-#endif
-
+ } else if (notificationName == NSWindowDidEnterFullScreenNotification
+ || notificationName == NSWindowDidExitFullScreenNotification) {
+ Qt::WindowState newState = notificationName == NSWindowDidEnterFullScreenNotification ?
+ Qt::WindowFullScreen : Qt::WindowNoState;
+ [self notifyWindowStateChanged:newState];
}
}
@@ -478,8 +470,9 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
- (void) flushBackingStore:(QCocoaBackingStore *)backingStore region:(const QRegion &)region offset:(QPoint)offset
{
- m_backingStore = backingStore;
- m_backingStoreOffset = offset * m_backingStore->getBackingStoreDevicePixelRatio();
+ m_backingStore = backingStore->toImage();
+ m_pixelRatio = backingStore->getBackingStoreDevicePixelRatio();
+ m_backingStoreOffset = offset * m_pixelRatio;
foreach (QRect rect, region.rects()) {
[self setNeedsDisplayInRect:NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height())];
}
@@ -543,7 +536,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
if (m_platformWindow->m_drawContentBorderGradient)
NSDrawWindowBackground(dirtyRect);
- if (!m_backingStore)
+ if (m_backingStore.isNull())
return;
// Calculate source and target rects. The target rect is the dirtyRect:
@@ -551,11 +544,10 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
// The backing store source rect will be larger on retina displays.
// Scale dirtyRect by the device pixel ratio:
- const qreal devicePixelRatio = m_backingStore->getBackingStoreDevicePixelRatio();
- CGRect dirtyBackingRect = CGRectMake(dirtyRect.origin.x * devicePixelRatio,
- dirtyRect.origin.y * devicePixelRatio,
- dirtyRect.size.width * devicePixelRatio,
- dirtyRect.size.height * devicePixelRatio);
+ CGRect dirtyBackingRect = CGRectMake(dirtyRect.origin.x * m_pixelRatio,
+ dirtyRect.origin.y * m_pixelRatio,
+ dirtyRect.size.width * m_pixelRatio,
+ dirtyRect.size.height * m_pixelRatio);
NSGraphicsContext *nsGraphicsContext = [NSGraphicsContext currentContext];
CGContextRef cgContext = (CGContextRef) [nsGraphicsContext graphicsPort];
@@ -581,7 +573,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
dirtyBackingRect.size.width,
dirtyBackingRect.size.height
);
- CGImageRef bsCGImage = m_backingStore->getBackingStoreCGImage();
+ CGImageRef bsCGImage = qt_mac_toCGImage(m_backingStore);
CGImageRef cleanImg = CGImageCreateWithImageInRect(bsCGImage, backingStoreRect);
// Optimization: Copy frame buffer content instead of blending for
@@ -596,10 +588,9 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
CGContextRestoreGState(cgContext);
CGImageRelease(cleanImg);
CGImageRelease(subMask);
+ CGImageRelease(bsCGImage);
[self invalidateWindowShadowIfNeeded];
-
- m_backingStore = 0;
}
- (BOOL) isFlipped
@@ -611,7 +602,8 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
{
if (m_window->flags() & Qt::WindowTransparentForInput)
return NO;
- QWindowSystemInterface::handleWindowActivated([self topLevelWindow]);
+ if (!m_platformWindow->windowIsPopupType())
+ QWindowSystemInterface::handleWindowActivated([self topLevelWindow]);
return YES;
}
@@ -656,16 +648,8 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
NSWindow *window = [self window];
NSPoint nsWindowPoint;
- // Use convertRectToScreen if available (added in 10.7).
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- if ([window respondsToSelector:@selector(convertRectFromScreen:)]) {
- NSRect windowRect = [window convertRectFromScreen:NSMakeRect(mouseLocation.x, mouseLocation.y, 1, 1)];
- nsWindowPoint = windowRect.origin; // NSWindow coordinates
- } else
-#endif
- {
- nsWindowPoint = [window convertScreenToBase:mouseLocation]; // NSWindow coordinates
- }
+ NSRect windowRect = [window convertRectFromScreen:NSMakeRect(mouseLocation.x, mouseLocation.y, 1, 1)];
+ nsWindowPoint = windowRect.origin; // NSWindow coordinates
NSPoint nsViewPoint = [self convertPoint: nsWindowPoint fromView: nil]; // NSView/QWindow coordinates
*qtWindowPoint = QPointF(nsViewPoint.x, nsViewPoint.y); // NSView/QWindow coordinates
@@ -678,6 +662,19 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
m_frameStrutButtons = Qt::NoButton;
}
+- (NSPoint) screenMousePoint:(NSEvent *)theEvent
+{
+ NSPoint screenPoint;
+ if (theEvent) {
+ NSPoint windowPoint = [theEvent locationInWindow];
+ NSRect screenRect = [[theEvent window] convertRectToScreen:NSMakeRect(windowPoint.x, windowPoint.y, 1, 1)];
+ screenPoint = screenRect.origin;
+ } else {
+ screenPoint = [NSEvent mouseLocation];
+ }
+ return screenPoint;
+}
+
- (void)handleMouseEvent:(NSEvent *)theEvent
{
[self handleTabletEvent: theEvent];
@@ -692,23 +689,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
m_platformWindow->m_forwardWindow = 0;
}
- NSPoint globalPos = [NSEvent mouseLocation];
-
- if ([self.window parentWindow]
- && (theEvent.type == NSLeftMouseDragged || theEvent.type == NSLeftMouseUp)) {
- // QToolBar can be implemented as a child window on top of its main window
- // (with a borderless NSWindow). If an option "unified toolbar" set on the main window,
- // it's possible to drag such a window using this toolbar.
- // While handling mouse drag events, QToolBar moves the window (QWidget::move).
- // In such a combination [NSEvent mouseLocation] is very different from the
- // real event location and as a result a window will move chaotically.
- NSPoint winPoint = [theEvent locationInWindow];
- NSRect tmpRect = NSMakeRect(winPoint.x, winPoint.y, 1., 1.);
- tmpRect = [[theEvent window] convertRectToScreen:tmpRect];
- globalPos = tmpRect.origin;
- }
-
- [targetView convertFromScreen:globalPos toWindowPoint:&qtWindowPoint andScreenPoint:&qtScreenPoint];
+ [targetView convertFromScreen:[self screenMousePoint:theEvent] toWindowPoint:&qtWindowPoint andScreenPoint:&qtScreenPoint];
ulong timestamp = [theEvent timestamp] * 1000;
QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag();
@@ -881,7 +862,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
QPointF windowPoint;
QPointF screenPoint;
- [self convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
+ [self convertFromScreen:[self screenMousePoint:theEvent] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
QWindow *childWindow = m_platformWindow->childWindowAt(windowPoint.toPoint());
// Top-level windows generate enter-leave events for sub-windows.
@@ -1296,18 +1277,8 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
// It looks like 1/4 degrees per pixel behaves most native.
// (NB: Qt expects the unit for delta to be 8 per degree):
const int pixelsToDegrees = 2; // 8 * 1/4
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- if ([theEvent respondsToSelector:@selector(scrollingDeltaX)]) {
- angleDelta.setX([theEvent scrollingDeltaX] * pixelsToDegrees);
- angleDelta.setY([theEvent scrollingDeltaY] * pixelsToDegrees);
- } else
-#endif
- {
- angleDelta.setX([theEvent deviceDeltaX] * pixelsToDegrees);
- angleDelta.setY([theEvent deviceDeltaY] * pixelsToDegrees);
- }
-
+ angleDelta.setX([theEvent scrollingDeltaX] * pixelsToDegrees);
+ angleDelta.setY([theEvent scrollingDeltaY] * pixelsToDegrees);
} else {
// carbonEventKind == kEventMouseWheelMoved
// Remove acceleration, and use either -120 or 120 as delta:
@@ -1316,20 +1287,16 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
}
QPoint pixelDelta;
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- if ([theEvent respondsToSelector:@selector(scrollingDeltaX)]) {
- if ([theEvent hasPreciseScrollingDeltas]) {
- pixelDelta.setX([theEvent scrollingDeltaX]);
- pixelDelta.setY([theEvent scrollingDeltaY]);
- } else {
- // docs: "In the case of !hasPreciseScrollingDeltas, multiply the delta with the line width."
- // scrollingDeltaX seems to return a minimum value of 0.1 in this case, map that to two pixels.
- const CGFloat lineWithEstimate = 20.0;
- pixelDelta.setX([theEvent scrollingDeltaX] * lineWithEstimate);
- pixelDelta.setY([theEvent scrollingDeltaY] * lineWithEstimate);
- }
+ if ([theEvent hasPreciseScrollingDeltas]) {
+ pixelDelta.setX([theEvent scrollingDeltaX]);
+ pixelDelta.setY([theEvent scrollingDeltaY]);
+ } else {
+ // docs: "In the case of !hasPreciseScrollingDeltas, multiply the delta with the line width."
+ // scrollingDeltaX seems to return a minimum value of 0.1 in this case, map that to two pixels.
+ const CGFloat lineWithEstimate = 20.0;
+ pixelDelta.setX([theEvent scrollingDeltaX] * lineWithEstimate);
+ pixelDelta.setY([theEvent scrollingDeltaY] * lineWithEstimate);
}
-#endif
QPointF qt_windowPoint;
QPointF qt_screenPoint;
@@ -1337,44 +1304,36 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
NSTimeInterval timestamp = [theEvent timestamp];
ulong qt_timestamp = timestamp * 1000;
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- if ([theEvent respondsToSelector:@selector(scrollingDeltaX)]) {
- // Prevent keyboard modifier state from changing during scroll event streams.
- // A two-finger trackpad flick generates a stream of scroll events. We want
- // the keyboard modifier state to be the state at the beginning of the
- // flick in order to avoid changing the interpretation of the events
- // mid-stream. One example of this happening would be when pressing cmd
- // after scrolling in Qt Creator: not taking the phase into account causes
- // the end of the event stream to be interpreted as font size changes.
- NSEventPhase momentumPhase = [theEvent momentumPhase];
- if (momentumPhase == NSEventPhaseNone) {
- currentWheelModifiers = [QNSView convertKeyModifiers:[theEvent modifierFlags]];
- }
+ // Prevent keyboard modifier state from changing during scroll event streams.
+ // A two-finger trackpad flick generates a stream of scroll events. We want
+ // the keyboard modifier state to be the state at the beginning of the
+ // flick in order to avoid changing the interpretation of the events
+ // mid-stream. One example of this happening would be when pressing cmd
+ // after scrolling in Qt Creator: not taking the phase into account causes
+ // the end of the event stream to be interpreted as font size changes.
+ NSEventPhase momentumPhase = [theEvent momentumPhase];
+ if (momentumPhase == NSEventPhaseNone) {
+ currentWheelModifiers = [QNSView convertKeyModifiers:[theEvent modifierFlags]];
+ }
- NSEventPhase phase = [theEvent phase];
- Qt::ScrollPhase ph = Qt::ScrollUpdate;
+ NSEventPhase phase = [theEvent phase];
+ Qt::ScrollPhase ph = Qt::ScrollUpdate;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
- if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_8) {
- // On 10.8 and above, MayBegin is likely to happen. We treat it the same as an actual begin.
- if (phase == NSEventPhaseMayBegin)
- ph = Qt::ScrollBegin;
- } else
+ if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_8) {
+ // On 10.8 and above, MayBegin is likely to happen. We treat it the same as an actual begin.
+ if (phase == NSEventPhaseMayBegin)
+ ph = Qt::ScrollBegin;
+ } else
#endif
if (phase == NSEventPhaseBegan) {
// On 10.7, MayBegin will not happen, so Began is the actual beginning.
ph = Qt::ScrollBegin;
}
- if (phase == NSEventPhaseEnded || phase == NSEventPhaseCancelled) {
- ph = Qt::ScrollEnd;
- }
-
- QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_screenPoint, pixelDelta, angleDelta, currentWheelModifiers, ph);
- } else
-#endif
- {
- QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_screenPoint, pixelDelta, angleDelta,
- [QNSView convertKeyModifiers:[theEvent modifierFlags]]);
+ if (phase == NSEventPhaseEnded || phase == NSEventPhaseCancelled) {
+ ph = Qt::ScrollEnd;
}
+
+ QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_screenPoint, pixelDelta, angleDelta, currentWheelModifiers, ph);
}
#endif //QT_NO_WHEELEVENT
@@ -1432,7 +1391,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
QString text;
// ignore text for the U+F700-U+F8FF range. This is used by Cocoa when
// delivering function keys (e.g. arrow keys, backspace, F1-F35, etc.)
- if (ch.unicode() < 0xf700 || ch.unicode() > 0xf8ff)
+ if (!(modifiers & (Qt::ControlModifier | Qt::MetaModifier)) && (ch.unicode() < 0xf700 || ch.unicode() > 0xf8ff))
text = QCFString::toQString(characters);
QWindow *focusWindow = [self topLevelWindow];
diff --git a/src/plugins/platforms/cocoa/qpaintengine_mac.mm b/src/plugins/platforms/cocoa/qpaintengine_mac.mm
index d48cbdfac8..7b77c9f1a8 100644
--- a/src/plugins/platforms/cocoa/qpaintengine_mac.mm
+++ b/src/plugins/platforms/cocoa/qpaintengine_mac.mm
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the plugins of the Qt Toolkit.
@@ -90,20 +90,13 @@ static void qt_mac_clip_cg(CGContextRef hd, const QRegion &rgn, CGAffineTransfor
if (rgn.isEmpty()) {
CGContextAddRect(hd, CGRectMake(0, 0, 0, 0));
} else {
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
- QCFType<HIMutableShapeRef> shape = qt_mac_QRegionToHIMutableShape(rgn);
- Q_ASSERT(!HIShapeIsEmpty(shape));
- HIShapeReplacePathInCGContext(shape, hd);
- } else {
- QVector<QRect> rects = rgn.rects();
- const int count = rects.size();
- for (int i = 0; i < count; i++) {
- const QRect &r = rects[i];
- CGRect mac_r = CGRectMake(r.x(), r.y(), r.width(), r.height());
- CGContextAddRect(hd, mac_r);
- }
+ QVector<QRect> rects = rgn.rects();
+ const int count = rects.size();
+ for (int i = 0; i < count; i++) {
+ const QRect &r = rects[i];
+ CGRect mac_r = CGRectMake(r.x(), r.y(), r.width(), r.height());
+ CGContextAddRect(hd, mac_r);
}
-
}
CGContextClip(hd);
@@ -1137,184 +1130,85 @@ extern "C" {
void
QCoreGraphicsPaintEngine::updateCompositionMode(QPainter::CompositionMode mode)
{
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
- int cg_mode = kCGBlendModeNormal;
- switch (mode) {
- case QPainter::CompositionMode_Multiply:
- cg_mode = kCGBlendModeMultiply;
- break;
- case QPainter::CompositionMode_Screen:
- cg_mode = kCGBlendModeScreen;
- break;
- case QPainter::CompositionMode_Overlay:
- cg_mode = kCGBlendModeOverlay;
- break;
- case QPainter::CompositionMode_Darken:
- cg_mode = kCGBlendModeDarken;
- break;
- case QPainter::CompositionMode_Lighten:
- cg_mode = kCGBlendModeLighten;
- break;
- case QPainter::CompositionMode_ColorDodge:
- cg_mode = kCGBlendModeColorDodge;
- break;
- case QPainter::CompositionMode_ColorBurn:
- cg_mode = kCGBlendModeColorBurn;
- break;
- case QPainter::CompositionMode_HardLight:
- cg_mode = kCGBlendModeHardLight;
- break;
- case QPainter::CompositionMode_SoftLight:
- cg_mode = kCGBlendModeSoftLight;
- break;
- case QPainter::CompositionMode_Difference:
- cg_mode = kCGBlendModeDifference;
- break;
- case QPainter::CompositionMode_Exclusion:
- cg_mode = kCGBlendModeExclusion;
- break;
- case QPainter::CompositionMode_Plus:
- cg_mode = kCGBlendModePlusLighter;
- break;
- case QPainter::CompositionMode_SourceOver:
- cg_mode = kCGBlendModeNormal;
- break;
- case QPainter::CompositionMode_DestinationOver:
- cg_mode = kCGBlendModeDestinationOver;
- break;
- case QPainter::CompositionMode_Clear:
- cg_mode = kCGBlendModeClear;
- break;
- case QPainter::CompositionMode_Source:
- cg_mode = kCGBlendModeCopy;
- break;
- case QPainter::CompositionMode_Destination:
- cg_mode = -1;
- break;
- case QPainter::CompositionMode_SourceIn:
- cg_mode = kCGBlendModeSourceIn;
- break;
- case QPainter::CompositionMode_DestinationIn:
- cg_mode = kCGCompositeModeDestinationIn;
- break;
- case QPainter::CompositionMode_SourceOut:
- cg_mode = kCGBlendModeSourceOut;
- break;
- case QPainter::CompositionMode_DestinationOut:
- cg_mode = kCGBlendModeDestinationOver;
- break;
- case QPainter::CompositionMode_SourceAtop:
- cg_mode = kCGBlendModeSourceAtop;
- break;
- case QPainter::CompositionMode_DestinationAtop:
- cg_mode = kCGBlendModeDestinationAtop;
- break;
- case QPainter::CompositionMode_Xor:
- cg_mode = kCGBlendModeXOR;
- break;
- default:
- break;
- }
- if (cg_mode > -1) {
- CGContextSetBlendMode(d_func()->hd, CGBlendMode(cg_mode));
- }
- } else if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_3
- && mode <= QPainter::CompositionMode_Xor) {
- // The standard porter duff ops.
- int cg_mode = kCGCompositeModeCopy;
- switch (mode) {
- case QPainter::CompositionMode_SourceOver:
- cg_mode = kCGCompositeModeSourceOver;
- break;
- case QPainter::CompositionMode_DestinationOver:
- cg_mode = kCGCompositeModeDestinationOver;
- break;
- case QPainter::CompositionMode_Clear:
- cg_mode = kCGCompositeModeClear;
- break;
- default:
- qWarning("QCoreGraphicsPaintEngine: Unhandled composition mode %d", (int)mode);
- break;
- case QPainter::CompositionMode_Source:
- cg_mode = kCGCompositeModeCopy;
- break;
- case QPainter::CompositionMode_Destination:
- cg_mode = CGCompositeMode(-1);
- break;
- case QPainter::CompositionMode_SourceIn:
- cg_mode = kCGCompositeModeSourceIn;
- break;
- case QPainter::CompositionMode_DestinationIn:
- cg_mode = kCGCompositeModeDestinationIn;
- break;
- case QPainter::CompositionMode_SourceOut:
- cg_mode = kCGCompositeModeSourceOut;
- break;
- case QPainter::CompositionMode_DestinationOut:
- cg_mode = kCGCompositeModeDestinationOut;
- break;
- case QPainter::CompositionMode_SourceAtop:
- cg_mode = kCGCompositeModeSourceAtop;
- break;
- case QPainter::CompositionMode_DestinationAtop:
- cg_mode = kCGCompositeModeDestinationAtop;
- break;
- case QPainter::CompositionMode_Xor:
- cg_mode = kCGCompositeModeXOR;
- break;
- }
- if (cg_mode > -1)
- CGContextSetCompositeOperation(d_func()->hd, CGCompositeMode(cg_mode));
- } else {
- bool needPrivateAPI = false;
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) {
- int cg_mode = kCGBlendModeNormal;
- switch (mode) {
- case QPainter::CompositionMode_Multiply:
- cg_mode = kCGBlendModeMultiply;
- break;
- case QPainter::CompositionMode_Screen:
- cg_mode = kCGBlendModeScreen;
- break;
- case QPainter::CompositionMode_Overlay:
- cg_mode = kCGBlendModeOverlay;
- break;
- case QPainter::CompositionMode_Darken:
- cg_mode = kCGBlendModeDarken;
- break;
- case QPainter::CompositionMode_Lighten:
- cg_mode = kCGBlendModeLighten;
- break;
- case QPainter::CompositionMode_ColorDodge:
- cg_mode = kCGBlendModeColorDodge;
- break;
- case QPainter::CompositionMode_ColorBurn:
- cg_mode = kCGBlendModeColorBurn;
- break;
- case QPainter::CompositionMode_HardLight:
- cg_mode = kCGBlendModeHardLight;
- break;
- case QPainter::CompositionMode_SoftLight:
- cg_mode = kCGBlendModeSoftLight;
- break;
- case QPainter::CompositionMode_Difference:
- cg_mode = kCGBlendModeDifference;
- break;
- case QPainter::CompositionMode_Exclusion:
- cg_mode = kCGBlendModeExclusion;
- break;
- case QPainter::CompositionMode_Plus:
- needPrivateAPI = true;
- cg_mode = kCGCompositeModePlusLighter;
- break;
- default:
- break;
- }
- if (!needPrivateAPI)
- CGContextSetBlendMode(d_func()->hd, CGBlendMode(cg_mode));
- else
- CGContextSetCompositeOperation(d_func()->hd, CGCompositeMode(cg_mode));
- }
+ int cg_mode = kCGBlendModeNormal;
+ switch (mode) {
+ case QPainter::CompositionMode_Multiply:
+ cg_mode = kCGBlendModeMultiply;
+ break;
+ case QPainter::CompositionMode_Screen:
+ cg_mode = kCGBlendModeScreen;
+ break;
+ case QPainter::CompositionMode_Overlay:
+ cg_mode = kCGBlendModeOverlay;
+ break;
+ case QPainter::CompositionMode_Darken:
+ cg_mode = kCGBlendModeDarken;
+ break;
+ case QPainter::CompositionMode_Lighten:
+ cg_mode = kCGBlendModeLighten;
+ break;
+ case QPainter::CompositionMode_ColorDodge:
+ cg_mode = kCGBlendModeColorDodge;
+ break;
+ case QPainter::CompositionMode_ColorBurn:
+ cg_mode = kCGBlendModeColorBurn;
+ break;
+ case QPainter::CompositionMode_HardLight:
+ cg_mode = kCGBlendModeHardLight;
+ break;
+ case QPainter::CompositionMode_SoftLight:
+ cg_mode = kCGBlendModeSoftLight;
+ break;
+ case QPainter::CompositionMode_Difference:
+ cg_mode = kCGBlendModeDifference;
+ break;
+ case QPainter::CompositionMode_Exclusion:
+ cg_mode = kCGBlendModeExclusion;
+ break;
+ case QPainter::CompositionMode_Plus:
+ cg_mode = kCGBlendModePlusLighter;
+ break;
+ case QPainter::CompositionMode_SourceOver:
+ cg_mode = kCGBlendModeNormal;
+ break;
+ case QPainter::CompositionMode_DestinationOver:
+ cg_mode = kCGBlendModeDestinationOver;
+ break;
+ case QPainter::CompositionMode_Clear:
+ cg_mode = kCGBlendModeClear;
+ break;
+ case QPainter::CompositionMode_Source:
+ cg_mode = kCGBlendModeCopy;
+ break;
+ case QPainter::CompositionMode_Destination:
+ cg_mode = -1;
+ break;
+ case QPainter::CompositionMode_SourceIn:
+ cg_mode = kCGBlendModeSourceIn;
+ break;
+ case QPainter::CompositionMode_DestinationIn:
+ cg_mode = kCGCompositeModeDestinationIn;
+ break;
+ case QPainter::CompositionMode_SourceOut:
+ cg_mode = kCGBlendModeSourceOut;
+ break;
+ case QPainter::CompositionMode_DestinationOut:
+ cg_mode = kCGBlendModeDestinationOver;
+ break;
+ case QPainter::CompositionMode_SourceAtop:
+ cg_mode = kCGBlendModeSourceAtop;
+ break;
+ case QPainter::CompositionMode_DestinationAtop:
+ cg_mode = kCGBlendModeDestinationAtop;
+ break;
+ case QPainter::CompositionMode_Xor:
+ cg_mode = kCGBlendModeXOR;
+ break;
+ default:
+ break;
+ }
+ if (cg_mode > -1) {
+ CGContextSetBlendMode(d_func()->hd, CGBlendMode(cg_mode));
}
}
@@ -1645,8 +1539,6 @@ void QCoreGraphicsPaintEnginePrivate::drawPath(uchar ops, CGMutablePathRef path)
if (!(q->state->renderHints() & QPainter::Antialiasing)) {
if (current.pen.style() == Qt::SolidLine || current.pen.width() >= 3)
CGContextTranslateCTM(hd, double(pixelSize.x()) * 0.25, double(pixelSize.y()) * 0.25);
- else if (current.pen.style() == Qt::DotLine && QSysInfo::MacintoshVersion == QSysInfo::MV_10_3)
- ; // Do nothing.
else
CGContextTranslateCTM(hd, 0, double(pixelSize.y()) * 0.1);
}
diff --git a/src/plugins/platforms/cocoa/qprintengine_mac.mm b/src/plugins/platforms/cocoa/qprintengine_mac.mm
index f684fef233..a58514614b 100644
--- a/src/plugins/platforms/cocoa/qprintengine_mac.mm
+++ b/src/plugins/platforms/cocoa/qprintengine_mac.mm
@@ -412,7 +412,10 @@ void QMacPrintEngine::drawTextItem(const QPointF &p, const QTextItem &ti)
{
Q_D(QMacPrintEngine);
Q_ASSERT(d->state == QPrinter::Active);
- d->paintEngine->drawTextItem(p, ti);
+ if (!d->embedFonts)
+ QPaintEngine::drawTextItem(p, ti);
+ else
+ d->paintEngine->drawTextItem(p, ti);
}
void QMacPrintEngine::drawTiledPixmap(const QRectF &dr, const QPixmap &pixmap, const QPointF &sr)
@@ -457,8 +460,6 @@ void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va
break;
case PPK_CustomBase:
break;
- case PPK_FontEmbedding:
- break;
case PPK_PageOrder:
// TODO Check if can be supported via Cups Options
break;
@@ -471,6 +472,9 @@ void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va
break;
// The following keys are properties and settings that are supported by the Mac PrintEngine
+ case PPK_FontEmbedding:
+ d->embedFonts = value.toBool();
+ break;
case PPK_Resolution: {
// TODO It appears the old code didn't actually set the resolution??? Can we delete all this???
int bestResolution = 0;
@@ -622,9 +626,6 @@ QVariant QMacPrintEngine::property(PrintEnginePropertyKey key) const
case PPK_CustomBase:
// Special case, leave null
break;
- case PPK_FontEmbedding:
- ret = false;
- break;
case PPK_PageOrder:
// TODO Check if can be supported via Cups Options
ret = QPrinter::FirstPageFirst;
@@ -648,6 +649,9 @@ QVariant QMacPrintEngine::property(PrintEnginePropertyKey key) const
break;
// The following keys are properties and settings that are supported by the Mac PrintEngine
+ case PPK_FontEmbedding:
+ ret = d->embedFonts;
+ break;
case PPK_CollateCopies: {
Boolean status;
PMGetCollate(d->settings(), &status);
diff --git a/src/plugins/platforms/cocoa/qprintengine_mac_p.h b/src/plugins/platforms/cocoa/qprintengine_mac_p.h
index c7307688ae..c99069b7f7 100644
--- a/src/plugins/platforms/cocoa/qprintengine_mac_p.h
+++ b/src/plugins/platforms/cocoa/qprintengine_mac_p.h
@@ -124,10 +124,11 @@ public:
QString m_creator;
QPaintEngine *paintEngine;
QHash<QMacPrintEngine::PrintEnginePropertyKey, QVariant> valueCache;
+ uint embedFonts;
QMacPrintEnginePrivate() : mode(QPrinter::ScreenResolution), state(QPrinter::Idle),
m_pageLayout(QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF(0, 0, 0, 0))),
- printInfo(0), paintEngine(0) {}
+ printInfo(0), paintEngine(0), embedFonts(true) {}
~QMacPrintEnginePrivate();
void initialize();
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp
index 142362a065..351f94be2b 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp
@@ -39,6 +39,7 @@
#include "qwindowsdirect2dwindow.h"
#include "qwindowscontext.h"
+#include "qwindowsguieventdispatcher.h"
#include <qplatformdefs.h>
#include <QtCore/QCoreApplication>
@@ -47,6 +48,16 @@
QT_BEGIN_NAMESPACE
+class QWindowsDirect2DEventDispatcher : public QWindowsGuiEventDispatcher
+{
+public:
+ QWindowsDirect2DEventDispatcher(QObject *parent = 0)
+ : QWindowsGuiEventDispatcher(parent)
+ {
+ uninstallMessageHook(); // ### Workaround for QTBUG-42428
+ }
+};
+
class QWindowsDirect2DIntegrationPrivate
{
public:
@@ -237,6 +248,11 @@ QPlatformBackingStore *QWindowsDirect2DIntegration::createPlatformBackingStore(Q
return new QWindowsDirect2DBackingStore(window);
}
+QAbstractEventDispatcher *QWindowsDirect2DIntegration::createEventDispatcher() const
+{
+ return new QWindowsDirect2DEventDispatcher;
+}
+
QWindowsDirect2DContext *QWindowsDirect2DIntegration::direct2DContext() const
{
return &d->m_d2dContext;
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.h b/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.h
index b410464372..c72b22a6e8 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.h
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.h
@@ -56,6 +56,7 @@ public:
QPlatformNativeInterface *nativeInterface() const Q_DECL_OVERRIDE;
QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const Q_DECL_OVERRIDE;
QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const Q_DECL_OVERRIDE;
+ QAbstractEventDispatcher *createEventDispatcher() const Q_DECL_OVERRIDE;
QWindowsDirect2DContext *direct2DContext() const;
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp
index c13f0f333a..a86bb0ee04 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp
@@ -1471,7 +1471,8 @@ void QWindowsDirect2DPaintEngine::drawPixmap(const QRectF &r,
r.x(), r.y() + r.height()
};
const QVectorPath vp(points, 4, 0, QVectorPath::RectangleHint);
- const QBrush brush(sr.isValid() ? pm.copy(sr.toRect()) : pm);
+ QBrush brush(sr.isValid() ? pm.copy(sr.toRect()) : pm);
+ brush.setTransform(QTransform::fromTranslate(r.x(), r.y()));
rasterFill(vp, brush);
return;
}
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp
index ef02d77375..c89d293d1d 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp
@@ -199,12 +199,13 @@ void QWindowsDirect2DWindow::setupSwapChain()
void QWindowsDirect2DWindow::resizeSwapChain(const QSize &size)
{
- if (!m_swapChain)
- return;
-
m_pixmap.reset();
m_bitmap.reset();
m_deviceContext->SetTarget(Q_NULLPTR);
+ m_needsFullFlush = true;
+
+ if (!m_swapChain)
+ return;
HRESULT hr = m_swapChain->ResizeBuffers(0,
size.width(), size.height(),
@@ -212,8 +213,6 @@ void QWindowsDirect2DWindow::resizeSwapChain(const QSize &size)
0);
if (FAILED(hr))
qWarning("%s: Could not resize swap chain: %#x", __FUNCTION__, hr);
-
- m_needsFullFlush = true;
}
QSharedPointer<QWindowsDirect2DBitmap> QWindowsDirect2DWindow::copyBackBuffer() const
diff --git a/src/plugins/platforms/directfb/directfb.pro b/src/plugins/platforms/directfb/directfb.pro
index 89d8d42cea..13481f6198 100644
--- a/src/plugins/platforms/directfb/directfb.pro
+++ b/src/plugins/platforms/directfb/directfb.pro
@@ -29,6 +29,8 @@ HEADERS = qdirectfbintegration.h \
qdirectfbscreen.h \
qdirectfbeglhooks.h
+contains(QT_CONFIG, libudev): DEFINES += QDEVICEDISCOVERY_UDEV
+
# ### port the GL context
contains(QT_CONFIG, directfb_egl) {
HEADERS += qdirectfb_egl.h
diff --git a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp
index ddf19face6..1b042a0743 100644
--- a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp
+++ b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp
@@ -67,11 +67,13 @@ QByteArray QEglFSHooks::fbDeviceName() const
int QEglFSHooks::framebufferIndex() const
{
int fbIndex = 0;
+#ifndef QT_NO_REGULAREXPRESSION
QRegularExpression fbIndexRx(QLatin1String("fb(\\d+)"));
QRegularExpressionMatch match = fbIndexRx.match(fbDeviceName());
if (match.hasMatch())
fbIndex = match.captured(1).toInt();
+#endif
return fbIndex;
}
diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.h b/src/plugins/platforms/eglfs/qeglfsscreen.h
index c7d8b55b19..c5ab3b52f5 100644
--- a/src/plugins/platforms/eglfs/qeglfsscreen.h
+++ b/src/plugins/platforms/eglfs/qeglfsscreen.h
@@ -76,7 +76,6 @@ protected:
private:
friend class QEglFSWindow;
- EGLDisplay m_dpy;
EGLSurface m_surface;
QPlatformCursor *m_cursor;
QEGLPlatformWindow *m_rootWindow;
diff --git a/src/plugins/platforms/eglfs/qeglfswindow.cpp b/src/plugins/platforms/eglfs/qeglfswindow.cpp
index ef1f496b29..59c2014d66 100644
--- a/src/plugins/platforms/eglfs/qeglfswindow.cpp
+++ b/src/plugins/platforms/eglfs/qeglfswindow.cpp
@@ -103,7 +103,7 @@ void QEglFSWindow::create()
if (isRaster()) {
QOpenGLContext *context = new QOpenGLContext(QGuiApplication::instance());
- context->setFormat(window()->requestedFormat());
+ context->setFormat(m_format);
context->setScreen(window()->screen());
if (!context->create())
qFatal("EGLFS: Failed to create compositing context");
diff --git a/src/plugins/platforms/ios/qioseventdispatcher.mm b/src/plugins/platforms/ios/qioseventdispatcher.mm
index ce7dfe2606..ffffc4cbc4 100644
--- a/src/plugins/platforms/ios/qioseventdispatcher.mm
+++ b/src/plugins/platforms/ios/qioseventdispatcher.mm
@@ -241,11 +241,11 @@ enum SetJumpResult
kJumpedFromUserMainTrampoline,
};
-// We define qt_main so that user_main_trampoline() will not cause
+// We define qtmn so that user_main_trampoline() will not cause
// missing symbols in the case of hybrid applications that don't
-// user our main wrapper. Since the symbol is weak, it will not
+// use our main wrapper. Since the symbol is weak, it will not
// get used or cause a clash in the normal Qt application usecase,
-// where we rename main to qt_main.
+// where we rename main to qtmn before linking.
extern "C" int __attribute__((weak)) qtmn(int argc, char *argv[])
{
Q_UNUSED(argc);
@@ -317,11 +317,16 @@ static bool rootLevelRunLoopIntegration()
}
#if defined(Q_PROCESSOR_X86)
-# define SET_STACK_POINTER "mov %0, %%esp"
# define FUNCTION_CALL_ALIGNMENT 16
+# if defined(Q_PROCESSOR_X86_32)
+# define SET_STACK_POINTER "mov %0, %%esp"
+# elif defined(Q_PROCESSOR_X86_64)
+# define SET_STACK_POINTER "movq %0, %%rsp"
+# endif
#elif defined(Q_PROCESSOR_ARM)
-# define SET_STACK_POINTER "mov sp, %0"
+# // Valid for both 32 and 64-bit ARM
# define FUNCTION_CALL_ALIGNMENT 4
+# define SET_STACK_POINTER "mov sp, %0"
#else
# error "Unknown processor family"
#endif
diff --git a/src/plugins/platforms/ios/qiosglobal.h b/src/plugins/platforms/ios/qiosglobal.h
index c09987f9dc..f7b9cd7015 100644
--- a/src/plugins/platforms/ios/qiosglobal.h
+++ b/src/plugins/platforms/ios/qiosglobal.h
@@ -41,6 +41,16 @@
QT_BEGIN_NAMESPACE
+Q_DECLARE_LOGGING_CATEGORY(lcQpaInputMethods);
+
+#if !defined(QT_NO_DEBUG)
+#define qImDebug(...) \
+ for (bool qt_category_enabled = lcQpaInputMethods().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) \
+ QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC, lcQpaInputMethods().categoryName()).debug(__VA_ARGS__)
+#else
+#define qImDebug() QT_NO_QDEBUG_MACRO()
+#endif
+
class QPlatformScreen;
bool isQtApplication();
@@ -52,7 +62,7 @@ QPointF fromCGPoint(const CGPoint &point);
Qt::ScreenOrientation toQtScreenOrientation(UIDeviceOrientation uiDeviceOrientation);
UIDeviceOrientation fromQtScreenOrientation(Qt::ScreenOrientation qtOrientation);
-QRect fromPortraitToPrimary(const QRect &rect, QPlatformScreen *screen);
+
int infoPlistValue(NSString* key, int defaultValue);
QT_END_NAMESPACE
@@ -61,4 +71,14 @@ QT_END_NAMESPACE
+(id)currentFirstResponder;
@end
+class FirstResponderCandidate : public QScopedValueRollback<UIResponder *>
+{
+public:
+ FirstResponderCandidate(UIResponder *);
+ static UIResponder *currentCandidate() { return s_firstResponderCandidate; }
+
+private:
+ static UIResponder *s_firstResponderCandidate;
+};
+
#endif // QIOSGLOBAL_H
diff --git a/src/plugins/platforms/ios/qiosglobal.mm b/src/plugins/platforms/ios/qiosglobal.mm
index 7ff4950599..3ecd0ca61f 100644
--- a/src/plugins/platforms/ios/qiosglobal.mm
+++ b/src/plugins/platforms/ios/qiosglobal.mm
@@ -46,6 +46,8 @@
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(lcQpaInputMethods, "qt.qpa.input.methods");
+
bool isQtApplication()
{
// Returns \c true if the plugin is in full control of the whole application. This means
@@ -125,15 +127,6 @@ UIDeviceOrientation fromQtScreenOrientation(Qt::ScreenOrientation qtOrientation)
return uiOrientation;
}
-QRect fromPortraitToPrimary(const QRect &rect, QPlatformScreen *screen)
-{
- // UIScreen is always in portrait. Use this function to convert CGRects
- // aligned with UIScreen into whatever is the current orientation of QScreen.
- QRect geometry = screen->geometry();
- return geometry.width() < geometry.height() ? rect
- : QRect(rect.y(), geometry.height() - rect.width() - rect.x(), rect.height(), rect.width());
-}
-
int infoPlistValue(NSString* key, int defaultValue)
{
static NSBundle *bundle = [NSBundle mainBundle];
@@ -148,6 +141,27 @@ int infoPlistValue(NSString* key, int defaultValue)
@end
@implementation QtFirstResponderEvent
+- (void) dealloc
+{
+ self.firstResponder = 0;
+ [super dealloc];
+}
+@end
+
+
+@implementation UIView (QtFirstResponder)
+- (UIView*)qt_findFirstResponder
+{
+ if ([self isFirstResponder])
+ return self;
+
+ for (UIView *subview in self.subviews) {
+ if (UIView *firstResponder = [subview qt_findFirstResponder])
+ return firstResponder;
+ }
+
+ return nil;
+}
@end
@implementation UIResponder (QtFirstResponder)
@@ -162,9 +176,20 @@ int infoPlistValue(NSString* key, int defaultValue)
- (void)qt_findFirstResponder:(id)sender event:(QtFirstResponderEvent *)event
{
Q_UNUSED(sender);
- event.firstResponder = self;
+
+ if ([self isKindOfClass:[UIView class]])
+ event.firstResponder = [static_cast<UIView *>(self) qt_findFirstResponder];
+ else
+ event.firstResponder = [self isFirstResponder] ? self : nil;
}
@end
+FirstResponderCandidate::FirstResponderCandidate(UIResponder *responder)
+ : QScopedValueRollback<UIResponder *>(s_firstResponderCandidate, responder)
+{
+}
+
+UIResponder *FirstResponderCandidate::s_firstResponderCandidate = 0;
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/ios/qiosinputcontext.h b/src/plugins/platforms/ios/qiosinputcontext.h
index 8850bbf80e..d2a9c261ba 100644
--- a/src/plugins/platforms/ios/qiosinputcontext.h
+++ b/src/plugins/platforms/ios/qiosinputcontext.h
@@ -42,6 +42,7 @@
const char kImePlatformDataInputView[] = "inputView";
const char kImePlatformDataInputAccessoryView[] = "inputAccessoryView";
+const char kImePlatformDataReturnKeyType[] = "returnKeyType";
QT_BEGIN_NAMESPACE
@@ -50,9 +51,10 @@ QT_BEGIN_NAMESPACE
struct ImeState
{
- ImeState() : currentState(0) {}
+ ImeState() : currentState(0), focusObject(0) {}
Qt::InputMethodQueries update(Qt::InputMethodQueries properties);
QInputMethodQueryEvent currentState;
+ QObject *focusObject;
};
class QIOSInputContext : public QPlatformInputContext
@@ -65,7 +67,8 @@ public:
void showInputPanel();
void hideInputPanel();
- void hideVirtualKeyboard();
+
+ void clearCurrentFocusObject();
bool isInputPanelVisible() const;
void setFocusObject(QObject *object);
@@ -80,6 +83,9 @@ public:
void commit();
const ImeState &imeState() { return m_imeState; };
+ bool inputMethodAccepted() const;
+
+ static QIOSInputContext *instance();
private:
QIOSKeyboardListener *m_keyboardListener;
diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm
index b403154321..e417e9a1fb 100644
--- a/src/plugins/platforms/ios/qiosinputcontext.mm
+++ b/src/plugins/platforms/ios/qiosinputcontext.mm
@@ -44,26 +44,30 @@
#import <UIKit/UIGestureRecognizerSubclass.h>
#include "qiosglobal.h"
+#include "qiosintegration.h"
#include "qiostextresponder.h"
+#include "qiosviewcontroller.h"
#include "qioswindow.h"
#include "quiview.h"
#include <QGuiApplication>
#include <QtGui/private/qwindow_p.h>
+// -------------------------------------------------------------------------
+
static QUIView *focusView()
{
return qApp->focusWindow() ?
reinterpret_cast<QUIView *>(qApp->focusWindow()->winId()) : 0;
}
-@interface QIOSKeyboardListener : UIGestureRecognizer {
+// -------------------------------------------------------------------------
+
+@interface QIOSKeyboardListener : UIGestureRecognizer <UIGestureRecognizerDelegate> {
@public
QIOSInputContext *m_context;
BOOL m_keyboardVisible;
BOOL m_keyboardVisibleAndDocked;
- BOOL m_touchPressWhileKeyboardVisible;
- BOOL m_keyboardHiddenByGesture;
QRectF m_keyboardRect;
CGRect m_keyboardEndRect;
NSTimeInterval m_duration;
@@ -76,13 +80,11 @@ static QUIView *focusView()
- (id)initWithQIOSInputContext:(QIOSInputContext *)context
{
- self = [super initWithTarget:self action:@selector(gestureTriggered)];
+ self = [super initWithTarget:self action:@selector(gestureStateChanged:)];
if (self) {
m_context = context;
m_keyboardVisible = NO;
m_keyboardVisibleAndDocked = NO;
- m_touchPressWhileKeyboardVisible = NO;
- m_keyboardHiddenByGesture = NO;
m_duration = 0;
m_curve = UIViewAnimationCurveEaseOut;
m_viewController = 0;
@@ -98,10 +100,9 @@ static QUIView *focusView()
Q_ASSERT(m_viewController);
// Attach 'hide keyboard' gesture to the window, but keep it disabled when the
- // keyboard is not visible. Note that we never trigger the gesture the way it is intended
- // since we don't want to cancel touch events and interrupt flicking etc. Instead we use
- // the gesture framework more as an event filter and hide the keyboard silently.
+ // keyboard is not visible.
self.enabled = NO;
+ self.cancelsTouchesInView = NO;
self.delaysTouchesEnded = NO;
[m_viewController.view.window addGestureRecognizer:self];
}
@@ -155,11 +156,19 @@ static QUIView *focusView()
// Note that UIKeyboardWillShowNotification is only sendt when the keyboard is docked.
m_keyboardVisibleAndDocked = YES;
m_keyboardEndRect = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
- self.enabled = YES;
+
if (!m_duration) {
m_duration = [[notification.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
m_curve = UIViewAnimationCurve([[notification.userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey] integerValue]);
}
+
+ UIResponder *firstResponder = [UIResponder currentFirstResponder];
+ if (![firstResponder isKindOfClass:[QIOSTextInputResponder class]])
+ return;
+
+ // Enable hide-keyboard gesture
+ self.enabled = YES;
+
m_context->scrollToCursor();
}
@@ -168,7 +177,7 @@ static QUIView *focusView()
// Note that UIKeyboardWillHideNotification is also sendt when the keyboard is undocked.
m_keyboardVisibleAndDocked = NO;
m_keyboardEndRect = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
- if (!m_keyboardHiddenByGesture) {
+ if (self.state != UIGestureRecognizerStateBegan) {
// Only disable the gesture if the hiding of the keyboard was not caused by it.
// Otherwise we need to await the final touchEnd callback for doing some clean-up.
self.enabled = NO;
@@ -201,51 +210,81 @@ static QUIView *focusView()
}
}
-- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
+// -------------------------------------------------------------------------
+
+- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
- CGPoint p = [[touches anyObject] locationInView:m_viewController.view.window];
- if (CGRectContainsPoint(m_keyboardEndRect, p)) {
- m_keyboardHiddenByGesture = YES;
- m_context->hideVirtualKeyboard();
- }
+ [super touchesBegan:touches withEvent:event];
- [super touchesMoved:touches withEvent:event];
+ Q_ASSERT(m_keyboardVisibleAndDocked);
+
+ if ([touches count] != 1)
+ self.state = UIGestureRecognizerStateFailed;
}
-- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
+- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
- Q_ASSERT(m_keyboardVisibleAndDocked);
- m_touchPressWhileKeyboardVisible = YES;
- [super touchesBegan:touches withEvent:event];
+ [super touchesMoved:touches withEvent:event];
+
+ if (self.state != UIGestureRecognizerStatePossible)
+ return;
+
+ CGPoint touchPoint = [[touches anyObject] locationInView:m_viewController.view.window];
+ if (CGRectContainsPoint(m_keyboardEndRect, touchPoint))
+ self.state = UIGestureRecognizerStateBegan;
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
- m_touchPressWhileKeyboardVisible = NO;
- [self performSelectorOnMainThread:@selector(touchesEndedPostDelivery) withObject:nil waitUntilDone:NO];
[super touchesEnded:touches withEvent:event];
+
+ [self touchesEndedOrCancelled];
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
- m_touchPressWhileKeyboardVisible = NO;
- [self performSelectorOnMainThread:@selector(touchesEndedPostDelivery) withObject:nil waitUntilDone:NO];
[super touchesCancelled:touches withEvent:event];
+
+ [self touchesEndedOrCancelled];
+}
+
+- (void)touchesEndedOrCancelled
+{
+ // Defer final state change until next runloop iteration, so that Qt
+ // has a chance to process the final touch events first, before we eg.
+ // scroll the view.
+ dispatch_async(dispatch_get_main_queue (), ^{
+ // iOS will transition from began to changed by itself
+ Q_ASSERT(self.state != UIGestureRecognizerStateBegan);
+
+ if (self.state == UIGestureRecognizerStateChanged)
+ self.state = UIGestureRecognizerStateEnded;
+ else
+ self.state = UIGestureRecognizerStateFailed;
+ });
+}
+
+- (void)gestureStateChanged:(id)sender
+{
+ Q_UNUSED(sender);
+
+ if (self.state == UIGestureRecognizerStateBegan) {
+ qImDebug() << "hide keyboard gesture was triggered";
+ UIResponder *firstResponder = [UIResponder currentFirstResponder];
+ Q_ASSERT([firstResponder isKindOfClass:[QIOSTextInputResponder class]]);
+ [firstResponder resignFirstResponder];
+ }
}
-- (void)touchesEndedPostDelivery
+- (void)reset
{
- // Do some clean-up _after_ touchEnd has been delivered to QUIView
- m_keyboardHiddenByGesture = NO;
+ [super reset];
+
if (!m_keyboardVisibleAndDocked) {
+ qImDebug() << "keyboard was hidden, disabling hide-keyboard gesture";
self.enabled = NO;
- if (qApp->focusObject()) {
- // UI Controls are told to gain focus on touch release. So when the 'hide keyboard' gesture
- // finishes, the final touch end can trigger a control to gain focus. This is in conflict with
- // the gesture, so we clear focus once more as a work-around.
- static_cast<QWindowPrivate *>(QObjectPrivate::get(qApp->focusWindow()))->clearFocusObject();
- }
} else {
+ qImDebug() << "gesture completed without triggering, scrolling view to cursor";
m_context->scrollToCursor();
}
}
@@ -261,8 +300,11 @@ Qt::InputMethodQueries ImeState::update(Qt::InputMethodQueries properties)
QInputMethodQueryEvent newState(properties);
- if (qApp && qApp->focusObject())
- QCoreApplication::sendEvent(qApp->focusObject(), &newState);
+ // Update the focus object that the new state is based on
+ focusObject = qApp ? qApp->focusObject() : 0;
+
+ if (focusObject)
+ QCoreApplication::sendEvent(focusObject, &newState);
Qt::InputMethodQueries updatedProperties;
for (uint i = 0; i < (sizeof(Qt::ImQueryAll) * CHAR_BIT); ++i) {
@@ -279,6 +321,11 @@ Qt::InputMethodQueries ImeState::update(Qt::InputMethodQueries properties)
// -------------------------------------------------------------------------
+QIOSInputContext *QIOSInputContext::instance()
+{
+ return static_cast<QIOSInputContext *>(QIOSIntegration::instance()->inputContext());
+}
+
QIOSInputContext::QIOSInputContext()
: QPlatformInputContext()
, m_keyboardListener([[QIOSKeyboardListener alloc] initWithQIOSInputContext:this])
@@ -303,16 +350,29 @@ QRectF QIOSInputContext::keyboardRect() const
void QIOSInputContext::showInputPanel()
{
// No-op, keyboard controlled fully by platform based on focus
+ qImDebug() << "can't show virtual keyboard without a focus object, ignoring";
}
void QIOSInputContext::hideInputPanel()
{
- // No-op, keyboard controlled fully by platform based on focus
+ if (![m_textResponder isFirstResponder]) {
+ qImDebug() << "QIOSTextInputResponder is not first responder, ignoring";
+ return;
+ }
+
+ if (qGuiApp->focusObject() != m_imeState.focusObject) {
+ qImDebug() << "current focus object does not match IM state, likely hiding from focusOut event, so ignoring";
+ return;
+ }
+
+ qImDebug() << "hiding VKB as requested by QInputMethod::hide()";
+ [m_textResponder resignFirstResponder];
}
-void QIOSInputContext::hideVirtualKeyboard()
+void QIOSInputContext::clearCurrentFocusObject()
{
- static_cast<QWindowPrivate *>(QObjectPrivate::get(qApp->focusWindow()))->clearFocusObject();
+ if (QWindow *focusWindow = qApp->focusWindow())
+ static_cast<QWindowPrivate *>(QObjectPrivate::get(focusWindow))->clearFocusObject();
}
bool QIOSInputContext::isInputPanelVisible() const
@@ -342,10 +402,10 @@ void QIOSInputContext::scrollToCursor()
if (!isQtApplication())
return;
- if (m_keyboardListener->m_touchPressWhileKeyboardVisible) {
- // Don't scroll to the cursor if the user is touching the screen. This
- // interferes with selection and the 'hide keyboard' gesture. Instead
- // we update scrolling upon touchEnd.
+ if (m_keyboardListener.state == UIGestureRecognizerStatePossible && m_keyboardListener.numberOfTouches == 1) {
+ // Don't scroll to the cursor if the user is touching the screen and possibly
+ // trying to trigger the hide-keyboard gesture.
+ qImDebug() << "preventing scrolling to cursor as we're still waiting for a possible gesture";
return;
}
@@ -415,6 +475,18 @@ void QIOSInputContext::setFocusObject(QObject *focusObject)
{
Q_UNUSED(focusObject);
+ qImDebug() << "new focus object =" << focusObject;
+
+ if (m_keyboardListener.state == UIGestureRecognizerStateChanged) {
+ // A new focus object may be set as part of delivering touch events to
+ // application during the hide-keyboard gesture, but we don't want that
+ // to result in a new object getting focus and bringing the keyboard up
+ // again.
+ qImDebug() << "clearing focus object" << focusObject << "as hide-keyboard gesture is active";
+ clearCurrentFocusObject();
+ return;
+ }
+
reset();
if (m_keyboardListener->m_keyboardVisibleAndDocked)
@@ -425,6 +497,8 @@ void QIOSInputContext::focusWindowChanged(QWindow *focusWindow)
{
Q_UNUSED(focusWindow);
+ qImDebug() << "new focus window =" << focusWindow;
+
reset();
[m_keyboardListener handleKeyboardRectChanged];
@@ -443,17 +517,59 @@ void QIOSInputContext::update(Qt::InputMethodQueries updatedProperties)
// Mask for properties that we are interested in and see if any of them changed
updatedProperties &= (Qt::ImEnabled | Qt::ImHints | Qt::ImQueryInput | Qt::ImPlatformData);
+ if (updatedProperties & Qt::ImEnabled) {
+ // Switching on and off input-methods needs a re-fresh of hints and platform
+ // data when we turn them on again, as the IM state we have may have been
+ // invalidated when IM was switched off. We could defer this until we know
+ // if IM was turned on, to limit the extra query parameters, but for simplicity
+ // we always do the update.
+ updatedProperties |= (Qt::ImHints | Qt::ImPlatformData);
+ }
+
+ qImDebug() << "fw =" << qApp->focusWindow() << "fo =" << qApp->focusObject();
+
Qt::InputMethodQueries changedProperties = m_imeState.update(updatedProperties);
if (changedProperties & (Qt::ImEnabled | Qt::ImHints | Qt::ImPlatformData)) {
// Changes to enablement or hints require virtual keyboard reconfigure
- [m_textResponder release];
- m_textResponder = [[QIOSTextInputResponder alloc] initWithInputContext:this];
- [m_textResponder reloadInputViews];
+
+ qImDebug() << "changed IM properties" << changedProperties << "require keyboard reconfigure";
+
+ if (inputMethodAccepted()) {
+ qImDebug() << "replacing text responder with new text responder";
+ [m_textResponder autorelease];
+ m_textResponder = [[QIOSTextInputResponder alloc] initWithInputContext:this];
+ [m_textResponder becomeFirstResponder];
+ } else if ([UIResponder currentFirstResponder] == m_textResponder) {
+ qImDebug() << "IM not enabled, resigning text responder as first responder";
+ [m_textResponder resignFirstResponder];
+ } else {
+ qImDebug() << "IM not enabled. Text responder not first responder. Nothing to do";
+ }
} else {
[m_textResponder notifyInputDelegate:changedProperties];
}
}
+bool QIOSInputContext::inputMethodAccepted() const
+{
+ // The IM enablement state is based on the last call to update()
+ bool lastKnownImEnablementState = m_imeState.currentState.value(Qt::ImEnabled).toBool();
+
+#if !defined(QT_NO_DEBUG)
+ // QPlatformInputContext keeps a cached value of the current IM enablement state that is
+ // updated by QGuiApplication when the current focus object changes, or by QInputMethod's
+ // update() function. If the focus object changes, but the change is not propagated as
+ // a signal to QGuiApplication due to bugs in the widget/graphicsview/qml stack, we'll
+ // end up with a stale value for QPlatformInputContext::inputMethodAccepted(). To be on
+ // the safe side we always use our own cached value to decide if IM is enabled, and try
+ // to detect the case where the two values are out of sync.
+ if (lastKnownImEnablementState != QPlatformInputContext::inputMethodAccepted())
+ qWarning("QPlatformInputContext::inputMethodAccepted() does not match actual focus object IM enablement!");
+#endif
+
+ return lastKnownImEnablementState;
+}
+
/*!
Called by the input item to reset the input method state.
*/
@@ -478,16 +594,3 @@ void QIOSInputContext::commit()
[m_textResponder unmarkText];
[m_textResponder notifyInputDelegate:Qt::ImSurroundingText];
}
-
-// -------------------------------------------------------------------------
-
-@interface QUIView (InputMethods)
-- (void)reloadInputViews;
-@end
-
-@implementation QUIView (InputMethods)
-- (void)reloadInputViews
-{
- qApp->inputMethod()->reset();
-}
-@end
diff --git a/src/plugins/platforms/ios/qiosmenu.mm b/src/plugins/platforms/ios/qiosmenu.mm
index 005b06547e..0f351f785b 100644
--- a/src/plugins/platforms/ios/qiosmenu.mm
+++ b/src/plugins/platforms/ios/qiosmenu.mm
@@ -153,13 +153,29 @@ static NSString *const kSelectorPrefix = @"_qtMenuItem_";
[self setDelegate:self];
[self setDataSource:self];
[self selectRow:m_selectedRow inComponent:0 animated:false];
+ [self listenForKeyboardWillHideNotification:YES];
}
return self;
}
+-(void)listenForKeyboardWillHideNotification:(BOOL)listen
+{
+ if (listen) {
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self
+ selector:@selector(cancelMenu)
+ name:@"UIKeyboardWillHideNotification" object:nil];
+ } else {
+ [[NSNotificationCenter defaultCenter]
+ removeObserver:self
+ name:@"UIKeyboardWillHideNotification" object:nil];
+ }
+}
+
-(void)dealloc
{
+ [self listenForKeyboardWillHideNotification:NO];
self.toolbar = 0;
[super dealloc];
}
@@ -193,6 +209,7 @@ static NSString *const kSelectorPrefix = @"_qtMenuItem_";
- (void)closeMenu
{
+ [self listenForKeyboardWillHideNotification:NO];
if (!m_visibleMenuItems.isEmpty())
QIOSMenu::currentMenu()->handleItemSelected(m_visibleMenuItems.at(m_selectedRow));
else
@@ -201,6 +218,7 @@ static NSString *const kSelectorPrefix = @"_qtMenuItem_";
- (void)cancelMenu
{
+ [self listenForKeyboardWillHideNotification:NO];
QIOSMenu::currentMenu()->dismiss();
}
@@ -452,11 +470,11 @@ void QIOSMenu::toggleShowUsingUIPickerView(bool show)
Q_ASSERT(!focusObjectWithPickerView);
focusObjectWithPickerView = qApp->focusWindow()->focusObject();
focusObjectWithPickerView->installEventFilter(this);
- qApp->inputMethod()->update(Qt::ImPlatformData);
+ qApp->inputMethod()->update(Qt::ImEnabled | Qt::ImPlatformData);
} else {
Q_ASSERT(focusObjectWithPickerView);
focusObjectWithPickerView->removeEventFilter(this);
- qApp->inputMethod()->update(Qt::ImPlatformData);
+ qApp->inputMethod()->update(Qt::ImEnabled | Qt::ImPlatformData);
focusObjectWithPickerView = 0;
Q_ASSERT(m_pickerView);
@@ -477,6 +495,7 @@ bool QIOSMenu::eventFilter(QObject *obj, QEvent *event)
imPlatformData.insert(kImePlatformDataInputView, QVariant::fromValue(static_cast<void *>(m_pickerView)));
imPlatformData.insert(kImePlatformDataInputAccessoryView, QVariant::fromValue(static_cast<void *>(m_pickerView.toolbar)));
queryEvent->setValue(Qt::ImPlatformData, imPlatformData);
+ queryEvent->setValue(Qt::ImEnabled, true);
return true;
}
diff --git a/src/plugins/platforms/ios/qiosplatformaccessibility.mm b/src/plugins/platforms/ios/qiosplatformaccessibility.mm
index ad8bd9bdf4..705c626272 100644
--- a/src/plugins/platforms/ios/qiosplatformaccessibility.mm
+++ b/src/plugins/platforms/ios/qiosplatformaccessibility.mm
@@ -58,16 +58,16 @@ void invalidateCache(QAccessibleInterface *iface)
return;
}
- QWindow *win = 0;
- QAccessibleInterface *parent = iface;
- do {
- win = parent->window();
- parent = parent->parent();
- } while (!win && parent);
-
- if (win && win->handle()) {
- QIOSWindow *window = static_cast<QIOSWindow*>(win->handle());
- window->clearAccessibleCache();
+ // This will invalidate everything regardless of what window the
+ // interface belonged to. We might want to revisit this strategy later.
+ // (Therefore this function still takes the interface as argument)
+ // It is also responsible for the bug that focus gets temporary lost
+ // when items get added or removed from the screen
+ foreach (QWindow *win, QGuiApplication::topLevelWindows()) {
+ if (win && win->handle()) {
+ QIOSWindow *window = static_cast<QIOSWindow*>(win->handle());
+ window->clearAccessibleCache();
+ }
}
}
diff --git a/src/plugins/platforms/ios/qiostextresponder.h b/src/plugins/platforms/ios/qiostextresponder.h
index 2923feba3b..118ab8958a 100644
--- a/src/plugins/platforms/ios/qiostextresponder.h
+++ b/src/plugins/platforms/ios/qiostextresponder.h
@@ -47,12 +47,10 @@ class QIOSInputContext;
@interface QIOSTextInputResponder : UIResponder <UITextInputTraits, UIKeyInput, UITextInput>
{
- @public
- QString m_markedText;
- BOOL m_inSendEventToFocusObject;
-
@private
QIOSInputContext *m_inputContext;
+ QString m_markedText;
+ BOOL m_inSendEventToFocusObject;
}
- (id)initWithInputContext:(QIOSInputContext *)context;
diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm
index 54362cde7a..2fcc7258f7 100644
--- a/src/plugins/platforms/ios/qiostextresponder.mm
+++ b/src/plugins/platforms/ios/qiostextresponder.mm
@@ -173,9 +173,13 @@
m_inSendEventToFocusObject = NO;
m_inputContext = inputContext;
+ QVariantMap platformData = [self imValue:Qt::ImPlatformData].toMap();
Qt::InputMethodHints hints = Qt::InputMethodHints([self imValue:Qt::ImHints].toUInt());
- self.returnKeyType = (hints & Qt::ImhMultiLine) ? UIReturnKeyDefault : UIReturnKeyDone;
+ self.returnKeyType = platformData.value(kImePlatformDataReturnKeyType).isValid() ?
+ UIReturnKeyType(platformData.value(kImePlatformDataReturnKeyType).toInt()) :
+ (hints & Qt::ImhMultiLine) ? UIReturnKeyDefault : UIReturnKeyDone;
+
self.secureTextEntry = BOOL(hints & Qt::ImhHiddenText);
self.autocorrectionType = (hints & Qt::ImhNoPredictiveText) ?
UITextAutocorrectionTypeNo : UITextAutocorrectionTypeDefault;
@@ -202,7 +206,6 @@
else
self.keyboardType = UIKeyboardTypeDefault;
- QVariantMap platformData = [self imValue:Qt::ImPlatformData].toMap();
if (UIView *inputView = static_cast<UIView *>(platformData.value(kImePlatformDataInputView).value<void *>()))
self.inputView = [[[WrapperView alloc] initWithView:inputView] autorelease];
if (UIView *accessoryView = static_cast<UIView *>(platformData.value(kImePlatformDataInputAccessoryView).value<void *>()))
@@ -218,30 +221,68 @@
[super dealloc];
}
-- (BOOL)isFirstResponder
+- (BOOL)canBecomeFirstResponder
{
return YES;
}
-- (UIResponder*)nextResponder
+- (BOOL)becomeFirstResponder
{
- return qApp->focusWindow() ?
- reinterpret_cast<QUIView *>(qApp->focusWindow()->handle()->winId()) : 0;
+ FirstResponderCandidate firstResponderCandidate(self);
+
+ qImDebug() << "self:" << self << "first:" << [UIResponder currentFirstResponder];
+
+ if (![super becomeFirstResponder]) {
+ qImDebug() << self << "was not allowed to become first responder";
+ return NO;
+ }
+
+ qImDebug() << self << "became first responder";
+
+ return YES;
}
-/*!
- iOS uses [UIResponder(Internal) _requiresKeyboardWhenFirstResponder] to check if the
- current responder should bring up the keyboard, which in turn checks if the responder
- supports the UIKeyInput protocol. By dynamically reporting our protocol conformance
- we can control the keyboard visibility depending on whether or not we have a focus
- object with IME enabled.
-*/
-- (BOOL)conformsToProtocol:(Protocol *)protocol
+- (BOOL)resignFirstResponder
{
- if (protocol == @protocol(UIKeyInput))
- return m_inputContext->inputMethodAccepted();
+ qImDebug() << "self:" << self << "first:" << [UIResponder currentFirstResponder];
- return [super conformsToProtocol:protocol];
+ // Don't allow activation events of the window that we're doing text on behalf on
+ // to steal responder.
+ if (FirstResponderCandidate::currentCandidate() == [self nextResponder]) {
+ qImDebug() << "not allowing parent window to steal responder";
+ return NO;
+ }
+
+ if (![super resignFirstResponder])
+ return NO;
+
+ qImDebug() << self << "resigned first responder";
+
+ // Dismissing the keyboard will trigger resignFirstResponder, but so will
+ // a regular responder transfer to another window. In the former case, iOS
+ // will set the new first-responder to our next-responder, and in the latter
+ // case we'll have an active responder candidate.
+ if ([UIResponder currentFirstResponder] == [self nextResponder]) {
+ // We have resigned the keyboard, and transferred back to the parent view, so unset focus object
+ Q_ASSERT(!FirstResponderCandidate::currentCandidate());
+ qImDebug() << "keyboard was closed, clearing focus object";
+ m_inputContext->clearCurrentFocusObject();
+ } else {
+ // We've lost responder status because another Qt window was made active,
+ // another QIOSTextResponder was made first-responder, another UIView was
+ // made first-responder, or the first-responder was cleared globally. In
+ // either of these cases we don't have to do anything.
+ qImDebug() << "lost first responder, but not clearing focus object";
+ }
+
+ return YES;
+}
+
+
+- (UIResponder*)nextResponder
+{
+ return qApp->focusWindow() ?
+ reinterpret_cast<QUIView *>(qApp->focusWindow()->handle()->winId()) : 0;
}
// -------------------------------------------------------------------------
@@ -575,9 +616,8 @@
[self sendEventToFocusObject:press];
[self sendEventToFocusObject:release];
- Qt::InputMethodHints imeHints = static_cast<Qt::InputMethodHints>([self imValue:Qt::ImHints].toUInt());
- if (!(imeHints & Qt::ImhMultiLine))
- m_inputContext->hideVirtualKeyboard();
+ if (self.returnKeyType == UIReturnKeyDone)
+ [self resignFirstResponder];
return;
}
diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm
index c46ed4c0b1..c4b92618b1 100644
--- a/src/plugins/platforms/ios/quiview.mm
+++ b/src/plugins/platforms/ios/quiview.mm
@@ -44,6 +44,7 @@
#include "qiosglobal.h"
#include "qiosintegration.h"
#include "qiosviewcontroller.h"
+#include "qiostextresponder.h"
#include "qioswindow.h"
#include "qiosmenu.h"
@@ -191,33 +192,66 @@
- (BOOL)becomeFirstResponder
{
- if ([super becomeFirstResponder]) {
+ FirstResponderCandidate firstResponderCandidate(self);
+
+ qImDebug() << "win:" << m_qioswindow->window() << "self:" << self
+ << "first:" << [UIResponder currentFirstResponder];
+
+ if (![super becomeFirstResponder]) {
+ qImDebug() << m_qioswindow->window()
+ << "was not allowed to become first responder";
+ return NO;
+ }
+
+ qImDebug() << m_qioswindow->window() << "became first responder";
+
+ if (qGuiApp->focusWindow() != m_qioswindow->window()) {
QWindowSystemInterface::handleWindowActivated(m_qioswindow->window());
QWindowSystemInterface::flushWindowSystemEvents();
+ } else {
+ qImDebug() << m_qioswindow->window()
+ << "already active, not sending window activation";
+ }
+
+ return YES;
+}
- return YES;
+- (BOOL)responderShouldTriggerWindowDeactivation:(UIResponder *)responder
+{
+ // We don't want to send window deactivation in case the resign
+ // was a result of another Qt window becoming first responder.
+ if ([responder isKindOfClass:[QUIView class]])
+ return NO;
+
+ // Nor do we want to deactivate the Qt window if the new responder
+ // is temporarily handling text input on behalf of a Qt window.
+ if ([responder isKindOfClass:[QIOSTextInputResponder class]]) {
+ while ((responder = [responder nextResponder])) {
+ if ([responder isKindOfClass:[QUIView class]])
+ return NO;
+ }
}
- return NO;
+ return YES;
}
- (BOOL)resignFirstResponder
{
- if ([super resignFirstResponder]) {
- // We don't want to send window deactivation in case we're in the process
- // of activating another window. The handleWindowActivated of the activation
- // will take care of both.
- dispatch_async(dispatch_get_main_queue (), ^{
- if (![[UIResponder currentFirstResponder] isKindOfClass:[QUIView class]]) {
- QWindowSystemInterface::handleWindowActivated(0);
- QWindowSystemInterface::flushWindowSystemEvents();
- }
- });
-
- return YES;
+ qImDebug() << "win:" << m_qioswindow->window() << "self:" << self
+ << "first:" << [UIResponder currentFirstResponder];
+
+ if (![super resignFirstResponder])
+ return NO;
+
+ qImDebug() << m_qioswindow->window() << "resigned first responder";
+
+ UIResponder *newResponder = FirstResponderCandidate::currentCandidate();
+ if ([self responderShouldTriggerWindowDeactivation:newResponder]) {
+ QWindowSystemInterface::handleWindowActivated(0);
+ QWindowSystemInterface::flushWindowSystemEvents();
}
- return NO;
+ return YES;
}
// -------------------------------------------------------------------------
diff --git a/src/plugins/platforms/ios/quiview_accessibility.mm b/src/plugins/platforms/ios/quiview_accessibility.mm
index 6565e08302..7e1cb9a4fd 100644
--- a/src/plugins/platforms/ios/quiview_accessibility.mm
+++ b/src/plugins/platforms/ios/quiview_accessibility.mm
@@ -48,7 +48,7 @@
- (void)createAccessibleElement:(QAccessibleInterface *)iface
{
- if (!iface || iface->state().invisible)
+ if (!iface || iface->state().invisible || (iface->text(QAccessible::Name).isEmpty() && iface->text(QAccessible::Value).isEmpty() && iface->text(QAccessible::Description).isEmpty()))
return;
QAccessible::Id accessibleId = QAccessible::uniqueId(iface);
UIAccessibilityElement *elem = [[QMacAccessibilityElement alloc] initWithId: accessibleId withAccessibilityContainer: self];
@@ -60,12 +60,9 @@
if (!iface)
return;
- if (iface->childCount() == 0) {
- [self createAccessibleElement: iface];
- } else {
- for (int i = 0; i < iface->childCount(); ++i)
- [self createAccessibleContainer: iface->child(i)];
- }
+ [self createAccessibleElement: iface];
+ for (int i = 0; i < iface->childCount(); ++i)
+ [self createAccessibleContainer: iface->child(i)];
}
- (void)initAccessibility
diff --git a/src/plugins/platforms/kms/kms.pro b/src/plugins/platforms/kms/kms.pro
index baa8778153..948d986fc5 100644
--- a/src/plugins/platforms/kms/kms.pro
+++ b/src/plugins/platforms/kms/kms.pro
@@ -9,6 +9,7 @@ QT += core-private gui-private platformsupport-private
qtHaveModule(opengl):QT += opengl-private
DEFINES += MESA_EGL_NO_X11_HEADERS __GBM__
+contains(QT_CONFIG, libudev): DEFINES += QDEVICEDISCOVERY_UDEV
CONFIG += link_pkgconfig egl qpa/genericunixfontdatabase
diff --git a/src/plugins/platforms/linuxfb/linuxfb.pro b/src/plugins/platforms/linuxfb/linuxfb.pro
index 389d45c29c..5e185e357f 100644
--- a/src/plugins/platforms/linuxfb/linuxfb.pro
+++ b/src/plugins/platforms/linuxfb/linuxfb.pro
@@ -9,6 +9,7 @@ QT += core-private gui-private platformsupport-private
SOURCES = main.cpp qlinuxfbintegration.cpp qlinuxfbscreen.cpp
HEADERS = qlinuxfbintegration.h qlinuxfbscreen.h
+contains(QT_CONFIG, libudev): DEFINES += QDEVICEDISCOVERY_UDEV
CONFIG += qpa/genericunixfontdatabase
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index db48e0ed93..22a4dbb09f 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -102,15 +102,6 @@ static inline int componentVerbose(const char *v, const char *keyWord)
return 0;
}
-static inline bool hasTouchSupport(QSysInfo::WinVersion wv)
-{
- enum { QT_SM_DIGITIZER = 94, QT_NID_INTEGRATED_TOUCH = 0x1,
- QT_NID_EXTERNAL_TOUCH = 0x02, QT_NID_MULTI_INPUT = 0x40 };
-
- return wv < QSysInfo::WV_WINDOWS7 ? false :
- (GetSystemMetrics(QT_SM_DIGITIZER) & (QT_NID_INTEGRATED_TOUCH | QT_NID_EXTERNAL_TOUCH | QT_NID_MULTI_INPUT)) != 0;
-}
-
#if !defined(LANG_SYRIAC)
# define LANG_SYRIAC 0x5a
#endif
@@ -318,7 +309,7 @@ QWindowsContextPrivate::QWindowsContextPrivate()
QWindowsContext::shell32dll.init();
QWindowsContext::shcoredll.init();
- if (hasTouchSupport(ver) && QWindowsContext::user32dll.initTouch())
+ if (m_mouseHandler.touchDevice() && QWindowsContext::user32dll.initTouch())
m_systemInfo |= QWindowsContext::SI_SupportsTouch;
#endif // !Q_OS_WINCE
m_displayContext = GetDC(0);
diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
index 4cbead44c5..f1f472b3e2 100644
--- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
+++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
@@ -1224,16 +1224,21 @@ void QWindowsNativeFileDialogBase::setNameFilters(const QStringList &filters)
QScopedArrayPointer<WCHAR> buffer(new WCHAR[totalStringLength + 2 * size]);
QScopedArrayPointer<COMDLG_FILTERSPEC> comFilterSpec(new COMDLG_FILTERSPEC[size]);
- const QString matchesAll = QStringLiteral(" (*)");
WCHAR *ptr = buffer.data();
// Split filter specification as 'Texts (*.txt[;] *.doc)'
// into description and filters specification as '*.txt;*.doc'
for (int i = 0; i < size; ++i) {
- // Display glitch (CLSID only): 'All files (*)' shows up as 'All files (*) (*)'
+ // Display glitch (CLSID only): Any filter not filtering on suffix (such as
+ // '*', 'a.*') will be duplicated in combo: 'All files (*) (*)',
+ // 'AAA files (a.*) (a.*)'
QString description = specs[i].description;
- if (!m_hideFiltersDetails && description.endsWith(matchesAll))
- description.truncate(description.size() - matchesAll.size());
+ const QString &filter = specs[i].filter;
+ if (!m_hideFiltersDetails && !filter.startsWith(QLatin1String("*."))) {
+ const int pos = description.lastIndexOf(QLatin1Char('('));
+ if (pos > 0)
+ description.truncate(pos);
+ }
// Add to buffer.
comFilterSpec[i].pszName = ptr;
ptr += description.toWCharArray(ptr);
diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp
index 3b277c0b5a..c0d0c1f77c 100644
--- a/src/plugins/platforms/windows/qwindowseglcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp
@@ -360,10 +360,10 @@ QWindowsEGLStaticContext *QWindowsEGLStaticContext::create()
EGLDisplay display = EGL_NO_DISPLAY;
#ifdef EGL_ANGLE_platform_angle_opengl
if (libEGL.eglGetPlatformDisplayEXT && qEnvironmentVariableIsSet("QT_ANGLE_PLATFORM")) {
- const EGLint anglePlatformAttributes[][3] = {
+ const EGLint anglePlatformAttributes[][5] = {
{ EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, EGL_NONE },
{ EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE, EGL_NONE },
- { EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_WARP_ANGLE, EGL_NONE }
+ { EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, EGL_PLATFORM_ANGLE_USE_WARP_ANGLE, EGL_TRUE, EGL_NONE }
};
const EGLint *attributes = 0;
const QByteArray anglePlatform = qgetenv("QT_ANGLE_PLATFORM");
diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.h b/src/plugins/platforms/windows/qwindowsfontdatabase.h
index efef6f4ded..4abf2d703e 100644
--- a/src/plugins/platforms/windows/qwindowsfontdatabase.h
+++ b/src/plugins/platforms/windows/qwindowsfontdatabase.h
@@ -38,13 +38,13 @@
#include <QtCore/QSharedPointer>
#include "qtwindows_additional.h"
-QT_BEGIN_NAMESPACE
-
#if !defined(QT_NO_DIRECTWRITE)
struct IDWriteFactory;
struct IDWriteGdiInterop;
#endif
+QT_BEGIN_NAMESPACE
+
class QWindowsFontEngineData
{
Q_DISABLE_COPY(QWindowsFontEngineData)
diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp
index fd585ee683..e6f30f2c35 100644
--- a/src/plugins/platforms/windows/qwindowsfontengine.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp
@@ -804,10 +804,8 @@ static bool addGlyphToPath(glyph_t glyph, const QFixedPoint &position, HDC hdc,
uint format = GGO_METRICS;
if (ttf)
format |= GGO_GLYPH_INDEX;
- int res = GetGlyphOutline(hdc, glyph, format, &gMetric, 0, 0, &mat);
- if (res == GDI_ERROR) {
+ if (GetGlyphOutline(hdc, glyph, format, &gMetric, 0, 0, &mat) == GDI_ERROR)
return false;
- }
// #### obey scale
*metric = glyph_metrics_t(gMetric.gmptGlyphOrigin.x, -gMetric.gmptGlyphOrigin.y,
(int)gMetric.gmBlackBoxX, (int)gMetric.gmBlackBoxY,
diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h
index 76c5790554..2addb90de3 100644
--- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h
+++ b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h
@@ -41,16 +41,16 @@
#include <QtGui/private/qfontengine_p.h>
#include <QtCore/QSharedPointer>
-class QWindowsFontEngineData;
-
-struct IDWriteFont ;
-struct IDWriteFontFace ;
-struct IDWriteFactory ;
-struct IDWriteBitmapRenderTarget ;
-struct IDWriteGdiInterop ;
+struct IDWriteFont;
+struct IDWriteFontFace;
+struct IDWriteFactory;
+struct IDWriteBitmapRenderTarget;
+struct IDWriteGdiInterop;
QT_BEGIN_NAMESPACE
+class QWindowsFontEngineData;
+
class QWindowsFontEngineDirectWrite : public QFontEngine
{
public:
diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp
index 990dbaeba2..ff9ad1874a 100644
--- a/src/plugins/platforms/windows/qwindowskeymapper.cpp
+++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp
@@ -39,6 +39,7 @@
#include <QtGui/QWindow>
#include <qpa/qwindowsysteminterface.h>
+#include <private/qguiapplication_p.h>
#include <QtGui/QKeyEvent>
QT_BEGIN_NAMESPACE
@@ -1104,9 +1105,17 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
else {
const QString text = uch.isNull() ? QString() : QString(uch);
const char a = uch.row() ? 0 : uch.cell();
+ const Qt::KeyboardModifiers modifiers(state);
+#ifndef QT_NO_SHORTCUT
+ // Is Qt interested in the context menu key?
+ if (modifiers == Qt::SHIFT && code == Qt::Key_F10
+ && !QGuiApplicationPrivate::instance()->shortcutMap.hasShortcutForKeySequence(QKeySequence(Qt::SHIFT + Qt::Key_F10))) {
+ return false;
+ }
+#endif // !QT_NO_SHORTCUT
key_recorder.storeKey(msg.wParam, a, state, text);
QWindowSystemInterface::handleExtendedKeyEvent(receiver, QEvent::KeyPress, code,
- Qt::KeyboardModifier(state), scancode, msg.wParam, nModifiers, text, false);
+ modifiers, scancode, msg.wParam, nModifiers, text, false);
result =true;
bool store = true;
#ifndef Q_OS_WINCE
diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
index 39321c3460..acb692579b 100644
--- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp
+++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
@@ -109,6 +109,30 @@ static inline void compressMouseMove(MSG *msg)
}
}
+static inline QTouchDevice *createTouchDevice()
+{
+ enum { QT_SM_TABLETPC = 86, QT_SM_DIGITIZER = 94, QT_SM_MAXIMUMTOUCHES = 95,
+ QT_NID_INTEGRATED_TOUCH = 0x1, QT_NID_EXTERNAL_TOUCH = 0x02,
+ QT_NID_MULTI_INPUT = 0x40, QT_NID_READY = 0x80 };
+
+ if (QSysInfo::windowsVersion() < QSysInfo::WV_WINDOWS7)
+ return 0;
+ const int digitizers = GetSystemMetrics(QT_SM_DIGITIZER);
+ if (!(digitizers & (QT_NID_INTEGRATED_TOUCH | QT_NID_EXTERNAL_TOUCH)))
+ return 0;
+ const int tabletPc = GetSystemMetrics(QT_SM_TABLETPC);
+ const int maxTouchPoints = GetSystemMetrics(QT_SM_MAXIMUMTOUCHES);
+ qCDebug(lcQpaEvents) << "Digitizers:" << hex << showbase << (digitizers & ~QT_NID_READY)
+ << "Ready:" << (digitizers & QT_NID_READY) << dec << noshowbase
+ << "Tablet PC:" << tabletPc << "Max touch points:" << maxTouchPoints;
+ QTouchDevice *result = new QTouchDevice;
+ result->setType(digitizers & QT_NID_INTEGRATED_TOUCH
+ ? QTouchDevice::TouchScreen : QTouchDevice::TouchPad);
+ result->setCapabilities(QTouchDevice::Position | QTouchDevice::Area | QTouchDevice::NormalizedPosition);
+ result->setMaximumTouchPoints(maxTouchPoints);
+ return result;
+}
+
/*!
\class QWindowsMouseHandler
\brief Windows mouse handler
@@ -122,10 +146,12 @@ static inline void compressMouseMove(MSG *msg)
QWindowsMouseHandler::QWindowsMouseHandler() :
m_windowUnderMouse(0),
m_trackedWindow(0),
- m_touchDevice(0),
+ m_touchDevice(createTouchDevice()),
m_leftButtonDown(false),
m_previousCaptureWindow(0)
{
+ if (m_touchDevice)
+ QWindowSystemInterface::registerTouchDevice(m_touchDevice);
}
Qt::MouseButtons QWindowsMouseHandler::queryMouseButtons()
@@ -404,6 +430,7 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
typedef QWindowSystemInterface::TouchPoint QTouchPoint;
typedef QList<QWindowSystemInterface::TouchPoint> QTouchPointList;
+ Q_ASSERT(m_touchDevice);
const QRect screenGeometry = window->screen()->geometry();
const int winTouchPointCount = msg.wParam;
@@ -464,14 +491,6 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
if (allStates == Qt::TouchPointReleased)
m_touchInputIDToTouchPointID.clear();
- if (!m_touchDevice) {
- m_touchDevice = new QTouchDevice;
- // TODO: Device used to be hardcoded to screen in previous code.
- m_touchDevice->setType(QTouchDevice::TouchScreen);
- m_touchDevice->setCapabilities(QTouchDevice::Position | QTouchDevice::Area | QTouchDevice::NormalizedPosition);
- QWindowSystemInterface::registerTouchDevice(m_touchDevice);
- }
-
QWindowSystemInterface::handleTouchEvent(window,
m_touchDevice,
touchPoints);
diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.h b/src/plugins/platforms/windows/qwindowsmousehandler.h
index 967c64e597..6491de93b5 100644
--- a/src/plugins/platforms/windows/qwindowsmousehandler.h
+++ b/src/plugins/platforms/windows/qwindowsmousehandler.h
@@ -51,6 +51,8 @@ class QWindowsMouseHandler
public:
QWindowsMouseHandler();
+ QTouchDevice *touchDevice() const { return m_touchDevice; }
+
bool translateMouseEvent(QWindow *widget, HWND hwnd,
QtWindows::WindowsEventType t, MSG msg,
LRESULT *result);
diff --git a/src/plugins/platforms/winrt/qwinrteglcontext.cpp b/src/plugins/platforms/winrt/qwinrteglcontext.cpp
index 5daeee69c0..64aedb1b33 100644
--- a/src/plugins/platforms/winrt/qwinrteglcontext.cpp
+++ b/src/plugins/platforms/winrt/qwinrteglcontext.cpp
@@ -35,8 +35,8 @@
QT_BEGIN_NAMESPACE
-QWinRTEGLContext::QWinRTEGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display, EGLSurface surface)
- : QEGLPlatformContext(format, share, display), m_eglSurface(surface)
+QWinRTEGLContext::QWinRTEGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display, EGLSurface surface, EGLConfig config)
+ : QEGLPlatformContext(format, share, display, &config), m_eglSurface(surface)
{
}
diff --git a/src/plugins/platforms/winrt/qwinrteglcontext.h b/src/plugins/platforms/winrt/qwinrteglcontext.h
index fb1199a79e..142e204fc8 100644
--- a/src/plugins/platforms/winrt/qwinrteglcontext.h
+++ b/src/plugins/platforms/winrt/qwinrteglcontext.h
@@ -41,7 +41,7 @@ QT_BEGIN_NAMESPACE
class QWinRTEGLContext : public QEGLPlatformContext
{
public:
- explicit QWinRTEGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display, EGLSurface surface);
+ explicit QWinRTEGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display, EGLSurface surface, EGLConfig config);
QFunctionPointer getProcAddress(const QByteArray &procName) Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/winrt/qwinrtintegration.cpp b/src/plugins/platforms/winrt/qwinrtintegration.cpp
index b8ca9fdc66..4fa90b4b68 100644
--- a/src/plugins/platforms/winrt/qwinrtintegration.cpp
+++ b/src/plugins/platforms/winrt/qwinrtintegration.cpp
@@ -110,7 +110,7 @@ QPlatformBackingStore *QWinRTIntegration::createPlatformBackingStore(QWindow *wi
QPlatformOpenGLContext *QWinRTIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
{
QWinRTScreen *screen = static_cast<QWinRTScreen *>(context->screen()->handle());
- return new QWinRTEGLContext(context->format(), context->handle(), screen->eglDisplay(), screen->eglSurface());
+ return new QWinRTEGLContext(context->format(), context->handle(), screen->eglDisplay(), screen->eglSurface(), screen->eglConfig());
}
QPlatformFontDatabase *QWinRTIntegration::fontDatabase() const
diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp
index 3933902ae3..fadcd01b06 100644
--- a/src/plugins/platforms/winrt/qwinrtscreen.cpp
+++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp
@@ -33,6 +33,11 @@
#include "qwinrtscreen.h"
+#define EGL_EGLEXT_PROTOTYPES
+#include <EGL/eglext.h>
+#include <d3d11.h>
+#include <dxgi1_2.h>
+
#include "qwinrtbackingstore.h"
#include "qwinrtinputcontext.h"
#include "qwinrtcursor.h"
@@ -452,6 +457,7 @@ public:
EGLDisplay eglDisplay;
EGLSurface eglSurface;
+ EGLConfig eglConfig;
QHash<CoreApplicationCallbackRemover, EventRegistrationToken> applicationTokens;
QHash<CoreWindowCallbackRemover, EventRegistrationToken> windowTokens;
@@ -467,6 +473,7 @@ QWinRTScreen::QWinRTScreen()
Q_D(QWinRTScreen);
d->orientation = Qt::PrimaryOrientation;
d->touchDevice = Q_NULLPTR;
+ d->eglDisplay = EGL_NO_DISPLAY;
// Obtain the WinRT Application, view, and window
HRESULT hr;
@@ -525,8 +532,10 @@ QWinRTScreen::QWinRTScreen()
Q_ASSERT_SUCCEEDED(hr);
hr = d->coreWindow->add_PointerWheelChanged(Callback<PointerHandler>(this, &QWinRTScreen::onPointerUpdated).Get(), &d->windowTokens[&ICoreWindow::remove_PointerWheelChanged]);
Q_ASSERT_SUCCEEDED(hr);
+#ifndef Q_OS_WINPHONE
hr = d->coreWindow->add_SizeChanged(Callback<SizeChangedHandler>(this, &QWinRTScreen::onSizeChanged).Get(), &d->windowTokens[&ICoreWindow::remove_SizeChanged]);
Q_ASSERT_SUCCEEDED(hr);
+#endif
hr = d->coreWindow->add_Activated(Callback<ActivatedHandler>(this, &QWinRTScreen::onActivated).Get(), &d->windowTokens[&ICoreWindow::remove_Activated]);
Q_ASSERT_SUCCEEDED(hr);
hr = d->coreWindow->add_Closed(Callback<ClosedHandler>(this, &QWinRTScreen::onClosed).Get(), &d->windowTokens[&ICoreWindow::remove_Closed]);
@@ -575,7 +584,43 @@ QWinRTScreen::QWinRTScreen()
if (!eglInitialize(d->eglDisplay, NULL, NULL))
qCritical("Failed to initialize EGL: 0x%x", eglGetError());
- d->eglSurface = eglCreateWindowSurface(d->eglDisplay, q_configFromGLFormat(d->eglDisplay, d->surfaceFormat), d->coreWindow.Get(), NULL);
+ // Check that the device properly supports depth/stencil rendering, and disable them if not
+ ComPtr<ID3D11Device> d3dDevice;
+ const EGLBoolean ok = eglQuerySurfacePointerANGLE(d->eglDisplay, EGL_NO_SURFACE, EGL_DEVICE_EXT, (void **)d3dDevice.GetAddressOf());
+ if (ok && d3dDevice) {
+ ComPtr<IDXGIDevice> dxgiDevice;
+ hr = d3dDevice.As(&dxgiDevice);
+ if (SUCCEEDED(hr)) {
+ ComPtr<IDXGIAdapter> dxgiAdapter;
+ hr = dxgiDevice->GetAdapter(&dxgiAdapter);
+ if (SUCCEEDED(hr)) {
+ ComPtr<IDXGIAdapter2> dxgiAdapter2;
+ hr = dxgiAdapter.As(&dxgiAdapter2);
+ if (SUCCEEDED(hr)) {
+ DXGI_ADAPTER_DESC2 desc;
+ hr = dxgiAdapter2->GetDesc2(&desc);
+ if (SUCCEEDED(hr)) {
+ // The following GPUs do not render properly with depth/stencil
+ if ((desc.VendorId == 0x4d4f4351 && desc.DeviceId == 0x32303032)) { // Qualcomm Adreno 225
+ d->surfaceFormat.setDepthBufferSize(-1);
+ d->surfaceFormat.setStencilBufferSize(-1);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ d->eglConfig = q_configFromGLFormat(d->eglDisplay, d->surfaceFormat);
+ d->surfaceFormat = q_glFormatFromConfig(d->eglDisplay, d->eglConfig, d->surfaceFormat);
+ const QRect bounds = geometry();
+ EGLint windowAttributes[] = {
+ EGL_FIXED_SIZE_ANGLE, EGL_TRUE,
+ EGL_WIDTH, bounds.width(),
+ EGL_HEIGHT, bounds.height(),
+ EGL_NONE
+ };
+ d->eglSurface = eglCreateWindowSurface(d->eglDisplay, d->eglConfig, d->coreWindow.Get(), windowAttributes);
if (d->eglSurface == EGL_NO_SURFACE)
qCritical("Failed to create EGL window surface: 0x%x", eglGetError());
}
@@ -706,6 +751,12 @@ EGLSurface QWinRTScreen::eglSurface() const
return d->eglSurface;
}
+EGLConfig QWinRTScreen::eglConfig() const
+{
+ Q_D(const QWinRTScreen);
+ return d->eglConfig;
+}
+
QWindow *QWinRTScreen::topWindow() const
{
Q_D(const QWinRTScreen);
@@ -1010,26 +1061,33 @@ HRESULT QWinRTScreen::onAutomationProviderRequested(ICoreWindow *, IAutomationPr
return S_OK;
}
-HRESULT QWinRTScreen::onSizeChanged(ICoreWindow *, IWindowSizeChangedEventArgs *args)
+HRESULT QWinRTScreen::onSizeChanged(ICoreWindow *, IWindowSizeChangedEventArgs *)
{
Q_D(QWinRTScreen);
- Size size;
- HRESULT hr = args->get_Size(&size);
- RETURN_OK_IF_FAILED("Failed to get window size.");
-
+ Rect size;
+ HRESULT hr;
+ hr = d->coreWindow->get_Bounds(&size);
+ RETURN_OK_IF_FAILED("Failed to get window bounds");
QSizeF logicalSize = QSizeF(size.Width, size.Height);
+#ifndef Q_OS_WINPHONE // This handler is called from orientation changed, in which case we should always update the size
if (d->logicalSize == logicalSize)
return S_OK;
+#endif
- // Regardless of state, all top-level windows are viewport-sized - this might change if
- // a more advanced compositor is written.
d->logicalSize = logicalSize;
- const QRect newGeometry = geometry();
- QWindowSystemInterface::handleScreenGeometryChange(screen(), newGeometry, newGeometry);
- QPlatformScreen::resizeMaximizedWindows();
- handleExpose();
-
+ if (d->eglDisplay) {
+ const QRect newGeometry = geometry();
+#ifdef Q_OS_WINPHONE // Resize the EGL window
+ const int width = newGeometry.width() * (d->orientation == Qt::InvertedPortraitOrientation || d->orientation == Qt::LandscapeOrientation ? -1 : 1);
+ const int height = newGeometry.height() * (d->orientation == Qt::InvertedPortraitOrientation || d->orientation == Qt::InvertedLandscapeOrientation ? -1 : 1);
+ eglSurfaceAttrib(d->eglDisplay, d->eglSurface, EGL_WIDTH, width);
+ eglSurfaceAttrib(d->eglDisplay, d->eglSurface, EGL_HEIGHT, height);
+#endif
+ QWindowSystemInterface::handleScreenGeometryChange(screen(), newGeometry, newGeometry);
+ QPlatformScreen::resizeMaximizedWindows();
+ handleExpose();
+ }
return S_OK;
}
@@ -1099,6 +1157,9 @@ HRESULT QWinRTScreen::onOrientationChanged(IDisplayInformation *, IInspectable *
QWindowSystemInterface::handleScreenOrientationChange(screen(), d->orientation);
}
+#ifdef Q_OS_WINPHONE // The size changed handler is ignored in favor of this callback
+ onSizeChanged(Q_NULLPTR, Q_NULLPTR);
+#endif
return S_OK;
}
diff --git a/src/plugins/platforms/winrt/qwinrtscreen.h b/src/plugins/platforms/winrt/qwinrtscreen.h
index e70a998216..c95a2073ed 100644
--- a/src/plugins/platforms/winrt/qwinrtscreen.h
+++ b/src/plugins/platforms/winrt/qwinrtscreen.h
@@ -109,6 +109,7 @@ public:
ABI::Windows::UI::Core::ICoreWindow *coreWindow() const;
EGLDisplay eglDisplay() const; // To opengl context
EGLSurface eglSurface() const; // To window
+ EGLConfig eglConfig() const;
private:
void handleExpose();
diff --git a/src/plugins/platforms/winrt/qwinrtwindow.cpp b/src/plugins/platforms/winrt/qwinrtwindow.cpp
index 35d6b64008..8800db60d3 100644
--- a/src/plugins/platforms/winrt/qwinrtwindow.cpp
+++ b/src/plugins/platforms/winrt/qwinrtwindow.cpp
@@ -40,6 +40,14 @@
#include <QtGui/QWindow>
#include <QtGui/QOpenGLContext>
+#include <qfunctions_winrt.h>
+#include <windows.ui.viewmanagement.h>
+#include <wrl.h>
+
+using namespace ABI::Windows::UI::ViewManagement;
+using namespace Microsoft::WRL;
+using namespace Microsoft::WRL::Wrappers;
+
QT_BEGIN_NAMESPACE
QWinRTWindow::QWinRTWindow(QWindow *window)
@@ -48,6 +56,7 @@ QWinRTWindow::QWinRTWindow(QWindow *window)
{
setWindowFlags(window->flags());
setWindowState(window->windowState());
+ setWindowTitle(window->title());
handleContentOrientationChange(window->contentOrientation());
setGeometry(window->geometry());
}
@@ -94,6 +103,24 @@ void QWinRTWindow::setVisible(bool visible)
m_screen->removeWindow(window());
}
+void QWinRTWindow::setWindowTitle(const QString &title)
+{
+ ComPtr<IApplicationViewStatics2> statics;
+ HRESULT hr;
+
+ hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_UI_ViewManagement_ApplicationView).Get(),
+ IID_PPV_ARGS(&statics));
+ RETURN_VOID_IF_FAILED("Could not get ApplicationViewStatics");
+
+ ComPtr<IApplicationView> view;
+ hr = statics->GetForCurrentView(&view);
+ RETURN_VOID_IF_FAILED("Could not access currentView");
+
+ HStringReference str(reinterpret_cast<LPCWSTR>(title.utf16()), title.length());
+ hr = view->put_Title(str.Get());
+ RETURN_VOID_IF_FAILED("Unable to set window title");
+}
+
void QWinRTWindow::raise()
{
if (!window()->isTopLevel())
diff --git a/src/plugins/platforms/winrt/qwinrtwindow.h b/src/plugins/platforms/winrt/qwinrtwindow.h
index 85f3efab5d..7e01efa818 100644
--- a/src/plugins/platforms/winrt/qwinrtwindow.h
+++ b/src/plugins/platforms/winrt/qwinrtwindow.h
@@ -52,6 +52,7 @@ public:
bool isExposed() const;
void setGeometry(const QRect &rect);
void setVisible(bool visible);
+ void setWindowTitle(const QString &title);
void raise();
void lower();
diff --git a/src/plugins/platforms/xcb/qglxintegration.h b/src/plugins/platforms/xcb/qglxintegration.h
index 84910c4172..5777980093 100644
--- a/src/plugins/platforms/xcb/qglxintegration.h
+++ b/src/plugins/platforms/xcb/qglxintegration.h
@@ -75,7 +75,6 @@ private:
void init(QXcbScreen *screen, QPlatformOpenGLContext *share);
void init(QXcbScreen *screen, QPlatformOpenGLContext *share, const QVariant &nativeHandle);
- QXcbScreen *m_screen;
Display *m_display;
GLXFBConfig m_config;
GLXContext m_context;
diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp
index 45856f3e6c..8b3893ec2f 100644
--- a/src/plugins/platforms/xcb/qxcbclipboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp
@@ -276,7 +276,7 @@ QXcbClipboard::QXcbClipboard(QXcbConnection *c)
m_timestamp[QClipboard::Clipboard] = XCB_CURRENT_TIME;
m_timestamp[QClipboard::Selection] = XCB_CURRENT_TIME;
- m_screen = connection()->screens().at(connection()->primaryScreen());
+ m_screen = connection()->primaryScreen();
int x = 0, y = 0, w = 3, h = 3;
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index 835c414d85..5510c3b1b4 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -244,7 +244,7 @@ void QXcbConnection::updateScreens()
// the first or an exact match. An exact match isn't
// always available if primary->output is XCB_NONE
// or currently disconnected output.
- if (m_primaryScreen == xcbScreenNumber) {
+ if (m_primaryScreenNumber == xcbScreenNumber) {
if (!primaryScreen || (primary && outputs[i] == primary->output)) {
primaryScreen = screen;
siblings.prepend(siblings.takeLast());
@@ -306,7 +306,7 @@ void QXcbConnection::updateScreens()
QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGrabServer, const char *displayName)
: m_connection(0)
, m_canGrabServer(canGrabServer)
- , m_primaryScreen(0)
+ , m_primaryScreenNumber(0)
, m_displayName(displayName ? QByteArray(displayName) : qgetenv("DISPLAY"))
, m_nativeInterface(nativeInterface)
, xfixes_first_event(0)
@@ -331,7 +331,7 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
#ifdef XCB_USE_XLIB
dpy = XOpenDisplay(m_displayName.constData());
if (dpy) {
- m_primaryScreen = DefaultScreen(dpy);
+ m_primaryScreenNumber = DefaultScreen(dpy);
m_connection = XGetXCBConnection(dpy);
XSetEventQueueOwner(dpy, XCBOwnsEventQueue);
XSetErrorHandler(nullErrorHandler);
@@ -339,7 +339,7 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
m_xlib_display = dpy;
}
#else
- m_connection = xcb_connect(m_displayName.constData(), &m_primaryScreen);
+ m_connection = xcb_connect(m_displayName.constData(), &m_primaryScreenNumber);
#endif //XCB_USE_XLIB
if (!m_connection || xcb_connection_has_error(m_connection))
@@ -449,6 +449,16 @@ QXcbConnection::~QXcbConnection()
delete m_keyboard;
}
+QXcbScreen *QXcbConnection::primaryScreen() const
+{
+ if (!m_screens.isEmpty()) {
+ Q_ASSERT(m_screens.first()->screenNumber() == primaryScreenNumber());
+ return m_screens.first();
+ }
+
+ return Q_NULLPTR;
+}
+
void QXcbConnection::addWindowEventListener(xcb_window_t id, QXcbWindowEventListener *eventListener)
{
m_mapper.insert(id, eventListener);
@@ -1219,7 +1229,7 @@ xcb_timestamp_t QXcbConnection::getTimestamp()
xcb_window_t QXcbConnection::rootWindow()
{
- return screens().at(primaryScreen())->root();
+ return primaryScreen()->root();
}
void QXcbConnection::processXcbEvents()
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h
index 4a16e116c6..7286b6b89b 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.h
+++ b/src/plugins/platforms/xcb/qxcbconnection.h
@@ -324,6 +324,7 @@ private:
class QXcbWindowEventListener
{
public:
+ virtual ~QXcbWindowEventListener() {}
virtual bool handleGenericEvent(xcb_generic_event_t *, long *) { return false; }
virtual void handleExposeEvent(const xcb_expose_event_t *) {}
@@ -369,7 +370,8 @@ public:
QXcbConnection *connection() const { return const_cast<QXcbConnection *>(this); }
const QList<QXcbScreen *> &screens() const { return m_screens; }
- int primaryScreen() const { return m_primaryScreen; }
+ int primaryScreenNumber() const { return m_primaryScreenNumber; }
+ QXcbScreen *primaryScreen() const;
inline xcb_atom_t atom(QXcbAtom::Atom atom) const { return m_allAtoms[atom]; }
QXcbAtom::Atom qatom(xcb_atom_t atom) const;
@@ -469,6 +471,7 @@ public:
QXcbEventReader *eventReader() const { return m_reader; }
+ bool canGrab() const { return m_canGrabServer; }
protected:
bool event(QEvent *e) Q_DECL_OVERRIDE;
@@ -550,7 +553,7 @@ private:
bool m_canGrabServer;
QList<QXcbScreen *> m_screens;
- int m_primaryScreen;
+ int m_primaryScreenNumber;
xcb_atom_t m_allAtoms[QXcbAtom::NAtoms];
diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp
index 53437f24ae..7037e102e2 100644
--- a/src/plugins/platforms/xcb/qxcbdrag.cpp
+++ b/src/plugins/platforms/xcb/qxcbdrag.cpp
@@ -311,7 +311,7 @@ void QXcbDrag::move(const QMouseEvent *me)
return;
const QList<QXcbScreen *> &screens = connection()->screens();
- QXcbScreen *screen = screens.at(connection()->primaryScreen());
+ QXcbScreen *screen = connection()->primaryScreen();
for (int i = 0; i < screens.size(); ++i) {
if (screens.at(i)->geometry().contains(globalPos)) {
screen = screens.at(i);
diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp
index d3533b8e44..3818494d99 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.cpp
+++ b/src/plugins/platforms/xcb/qxcbintegration.cpp
@@ -92,11 +92,11 @@
QT_BEGIN_NAMESPACE
-#if defined(QT_DEBUG) && defined(Q_OS_LINUX)
// Find out if our parent process is gdb by looking at the 'exe' symlink under /proc,.
// or, for older Linuxes, read out 'cmdline'.
static bool runningUnderDebugger()
{
+#if defined(QT_DEBUG) && defined(Q_OS_LINUX)
const QString parentProc = QLatin1String("/proc/") + QString::number(getppid());
const QFileInfo parentProcExe(parentProc + QLatin1String("/exe"));
if (parentProcExe.isSymLink())
@@ -113,12 +113,15 @@ static bool runningUnderDebugger()
s += c;
}
return s == "gdb";
-}
+#else
+ return false;
#endif
+}
QXcbIntegration::QXcbIntegration(const QStringList &parameters, int &argc, char **argv)
: m_services(new QGenericUnixServices)
, m_instanceName(0)
+ , m_canGrab(true)
{
qRegisterMetaType<QXcbWindow*>();
#ifdef XCB_USE_XLIB
@@ -126,16 +129,10 @@ QXcbIntegration::QXcbIntegration(const QStringList &parameters, int &argc, char
#endif
m_nativeInterface.reset(new QXcbNativeInterface);
- bool canGrab = true;
- #if defined(QT_DEBUG) && defined(Q_OS_LINUX)
- canGrab = !runningUnderDebugger();
- #endif
- static bool canNotGrabEnv = qgetenv("QT_XCB_NO_GRAB_SERVER").length();
- if (canNotGrabEnv)
- canGrab = false;
-
// Parse arguments
const char *displayName = 0;
+ bool noGrabArg = false;
+ bool doGrabArg = false;
if (argc) {
int j = 1;
for (int i = 1; i < argc; i++) {
@@ -146,13 +143,35 @@ QXcbIntegration::QXcbIntegration(const QStringList &parameters, int &argc, char
displayName = argv[++i];
else if (arg == "-name" && i < argc - 1)
m_instanceName = argv[++i];
+ else if (arg == "-nograb")
+ noGrabArg = true;
+ else if (arg == "-dograb")
+ doGrabArg = true;
else
argv[j++] = argv[i];
}
argc = j;
} // argc
- m_connections << new QXcbConnection(m_nativeInterface.data(), canGrab, displayName);
+ bool underDebugger = runningUnderDebugger();
+ if (noGrabArg && doGrabArg && underDebugger) {
+ qWarning() << "Both -nograb and -dograb command line arguments specified. Please pick one. -nograb takes prcedence";
+ doGrabArg = false;
+ }
+
+#if defined(QT_DEBUG)
+ if (!noGrabArg && !doGrabArg && underDebugger) {
+ qDebug("Qt: gdb: -nograb added to command-line options.\n"
+ "\t Use the -dograb option to enforce grabbing.");
+ }
+#endif
+ m_canGrab = (!underDebugger && noGrabArg) || (underDebugger && doGrabArg);
+
+ static bool canNotGrabEnv = qEnvironmentVariableIsSet("QT_XCB_NO_GRAB_SERVER");
+ if (canNotGrabEnv)
+ m_canGrab = false;
+
+ m_connections << new QXcbConnection(m_nativeInterface.data(), m_canGrab, displayName);
for (int i = 0; i < parameters.size() - 1; i += 2) {
#ifdef Q_XCB_DEBUG
@@ -408,19 +427,19 @@ QVariant QXcbIntegration::styleHint(QPlatformIntegration::StyleHint hint) const
case QPlatformIntegration::StartDragTime:
case QPlatformIntegration::KeyboardAutoRepeatRate:
case QPlatformIntegration::PasswordMaskDelay:
- case QPlatformIntegration::FontSmoothingGamma:
case QPlatformIntegration::StartDragVelocity:
case QPlatformIntegration::UseRtlExtensions:
case QPlatformIntegration::PasswordMaskCharacter:
// TODO using various xcb, gnome or KDE settings
break; // Not implemented, use defaults
+ case QPlatformIntegration::FontSmoothingGamma:
+ // Match Qt 4.8 text rendering, and rendering of other X11 toolkits.
+ return qreal(1.0);
case QPlatformIntegration::StartDragDistance: {
// The default (in QPlatformTheme::defaultThemeHint) is 10 pixels, but
// on a high-resolution screen it makes sense to increase it.
- const QList<QXcbScreen *> &screens = defaultConnection()->screens();
qreal dpi = 100.0;
- if (screens.length() > 0) {
- const QXcbScreen *screen = screens.at(defaultConnection()->primaryScreen());
+ if (const QXcbScreen *screen = defaultConnection()->primaryScreen()) {
if (screen->logicalDpi().first > dpi)
dpi = screen->logicalDpi().first;
if (screen->logicalDpi().second > dpi)
diff --git a/src/plugins/platforms/xcb/qxcbintegration.h b/src/plugins/platforms/xcb/qxcbintegration.h
index ffb068ecb3..db6ad541ea 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.h
+++ b/src/plugins/platforms/xcb/qxcbintegration.h
@@ -117,6 +117,7 @@ private:
mutable QByteArray m_wmClass;
const char *m_instanceName;
+ bool m_canGrab;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
index dae3a79628..260fb46309 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
@@ -721,7 +721,7 @@ void QXcbKeyboard::updateKeymap()
if (xkb_keymap) {
new_state = xkb_state_new(xkb_keymap);
} else {
- printKeymapError("Failed to compile a keymap!");
+ printKeymapError("Qt: Failed to compile a keymap!");
m_config = false;
return;
}
@@ -737,6 +737,8 @@ void QXcbKeyboard::updateKeymap()
xkb_state = new_state;
if (!connection()->hasXKB())
updateXKBMods();
+
+ checkForLatinLayout();
}
#ifndef QT_NO_XKB
@@ -824,37 +826,137 @@ void QXcbKeyboard::updateXKBMods()
xkb_mods.mod5 = xkb_keymap_mod_get_index(xkb_keymap, "Mod5");
}
+static bool isLatin(xkb_keysym_t sym)
+{
+ return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
+}
+
+void QXcbKeyboard::checkForLatinLayout()
+{
+ m_hasLatinLayout = false;
+ const xkb_layout_index_t layoutCount = xkb_keymap_num_layouts(xkb_keymap);
+ const xcb_keycode_t minKeycode = connection()->setup()->min_keycode;
+ const xcb_keycode_t maxKeycode = connection()->setup()->max_keycode;
+ struct xkb_state *kb_state = xkb_state_new(xkb_keymap);
+ for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
+ xkb_state_update_mask(kb_state, 0, 0, 0, 0, 0, layout);
+ for (xcb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
+ xkb_keysym_t sym = xkb_state_key_get_one_sym(kb_state, code);
+ // if layout can produce any of these latin letters (chosen
+ // arbitrarily) then it must be a latin key based layout
+ if (sym == XK_q || sym == XK_a || sym == XK_e) {
+ m_hasLatinLayout = true;
+ xkb_state_unref(kb_state);
+ return;
+ }
+ }
+ }
+ xkb_state_unref(kb_state);
+}
+
+xkb_keysym_t QXcbKeyboard::lookupLatinKeysym(xkb_keycode_t keycode) const
+{
+ xkb_layout_index_t layout;
+ xkb_keysym_t sym = XKB_KEY_NoSymbol;
+ const xkb_layout_index_t layoutCount = xkb_keymap_num_layouts_for_key(xkb_keymap, keycode);
+ const xkb_layout_index_t currentLayout = xkb_state_key_get_layout(xkb_state, keycode);
+ // Look at user layouts in the order in which they are defined in system
+ // settings to find a latin keysym.
+ for (layout = 0; layout < layoutCount; ++layout) {
+ if (layout == currentLayout)
+ continue;
+ const xkb_keysym_t *syms;
+ xkb_level_index_t level = xkb_state_key_get_level(xkb_state, keycode, layout);
+ if (xkb_keymap_key_get_syms_by_level(xkb_keymap, keycode, layout, level, &syms) != 1)
+ continue;
+ if (isLatin(syms[0])) {
+ sym = syms[0];
+ break;
+ }
+ }
+ // If user layouts don't contain any layout that results in a latin key, we query a
+ // key from "US" layout, this allows for latin-key-based shorcuts to work even when
+ // users have only one (non-latin) layout set.
+ xkb_mod_mask_t latchedMods = xkb_state_serialize_mods(xkb_state, XKB_STATE_MODS_LATCHED);
+ xkb_mod_mask_t lockedMods = xkb_state_serialize_mods(xkb_state, XKB_STATE_MODS_LOCKED);
+ if (sym == XKB_KEY_NoSymbol && !m_hasLatinLayout) {
+ if (!latin_keymap) {
+ const struct xkb_rule_names names = { xkb_names.rules, xkb_names.model, "us", 0, 0 };
+ latin_keymap = xkb_keymap_new_from_names(xkb_context, &names, (xkb_keymap_compile_flags)0);
+ static bool printFailure = true;
+ if (!latin_keymap && printFailure) {
+ // print message about failure to compile US keymap only once,
+ // no need to do this on every key press.
+ printFailure = false;
+ printKeymapError("Qt: Failed to compile US keymap, shortcut handling with "
+ "non-Latin keyboard layouts may not be fully functional!");
+ }
+ }
+ if (latin_keymap) {
+ struct xkb_state *latin_state = xkb_state_new(latin_keymap);
+ if (latin_state) {
+ xkb_state_update_mask(latin_state, 0, latchedMods, lockedMods, 0, 0, 0);
+ sym = xkb_state_key_get_one_sym(latin_state, keycode);
+ xkb_state_unref(latin_state);
+ } else {
+ qWarning("QXcbKeyboard: failed to create a state for US keymap!");
+ }
+ }
+ }
+ if (sym == XKB_KEY_NoSymbol)
+ return sym;
+ // Check for uniqueness, consider the following setup:
+ // setxkbmap -layout us,ru,us -variant dvorak,, -option 'grp:ctrl_alt_toggle' (set 'ru' as active).
+ // In this setup, the user would expect to trigger a ctrl+q shortcut by pressing ctrl+<physical x key>,
+ // because "US dvorak" is higher up in the layout settings list. This check verifies that an obtained
+ // 'sym' can not be acquired by any other layout higher up in the user's layout list. If it can be acquired
+ // then the obtained key is not unique. This prevents ctrl+<physical q key> from generating a ctrl+q
+ // shortcut in the above described setup. We don't want ctrl+<physical x key> and ctrl+<physical q key> to
+ // generate the same shortcut event in this case.
+ const xcb_keycode_t minKeycode = connection()->setup()->min_keycode;
+ const xcb_keycode_t maxKeycode = connection()->setup()->max_keycode;
+ struct xkb_state *kb_state = xkb_state_new(xkb_keymap);
+ for (xkb_layout_index_t prevLayout = 0; prevLayout < layout; ++prevLayout) {
+ xkb_state_update_mask(kb_state, 0, latchedMods, lockedMods, 0, 0, prevLayout);
+ for (xcb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
+ xkb_keysym_t prevSym = xkb_state_key_get_one_sym(kb_state, code);
+ if (prevSym == sym) {
+ sym = XKB_KEY_NoSymbol;
+ break;
+ }
+ }
+ }
+ xkb_state_unref(kb_state);
+ return sym;
+}
+
QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
{
// turn off the modifier bits which doesn't participate in shortcuts
Qt::KeyboardModifiers notNeeded = Qt::MetaModifier | Qt::KeypadModifier | Qt::GroupSwitchModifier;
Qt::KeyboardModifiers modifiers = event->modifiers() &= ~notNeeded;
// create a fresh kb state and test against the relevant modifier combinations
- // NOTE: it should be possible to query the keymap directly, once it gets
- // supported by libxkbcommon
- struct xkb_state * kb_state = xkb_state_new(xkb_keymap);
+ struct xkb_state *kb_state = xkb_state_new(xkb_keymap);
if (!kb_state) {
- qWarning("QXcbKeyboard: failed to compile xkb keymap");
+ qWarning("QXcbKeyboard: failed to compile xkb keymap!");
return QList<int>();
}
// get kb state from the master xkb_state and update the temporary kb_state
- xkb_layout_index_t baseLayout = xkb_state_serialize_layout(xkb_state, XKB_STATE_LAYOUT_DEPRESSED);
- xkb_layout_index_t latchedLayout = xkb_state_serialize_layout(xkb_state, XKB_STATE_LAYOUT_LATCHED);
xkb_layout_index_t lockedLayout = xkb_state_serialize_layout(xkb_state, XKB_STATE_LAYOUT_LOCKED);
xkb_mod_mask_t latchedMods = xkb_state_serialize_mods(xkb_state, XKB_STATE_MODS_LATCHED);
xkb_mod_mask_t lockedMods = xkb_state_serialize_mods(xkb_state, XKB_STATE_MODS_LOCKED);
- xkb_state_update_mask(kb_state, 0, latchedMods, lockedMods,
- baseLayout, latchedLayout, lockedLayout);
+ xkb_state_update_mask(kb_state, 0, latchedMods, lockedMods, 0, 0, lockedLayout);
- xkb_keysym_t sym = xkb_state_key_get_one_sym(kb_state, event->nativeScanCode());
+ quint32 keycode = event->nativeScanCode();
+ xkb_keysym_t sym = xkb_state_key_get_one_sym(kb_state, keycode);
if (sym == XKB_KEY_NoSymbol) {
xkb_state_unref(kb_state);
return QList<int>();
}
QList<int> result;
- int baseQtKey = keysymToQtKey(sym, modifiers, lookupString(kb_state, event->nativeScanCode()));
+ int baseQtKey = keysymToQtKey(sym, modifiers, lookupString(kb_state, keycode));
result += (baseQtKey + modifiers); // The base key is _always_ valid, of course
xkb_mod_index_t shiftMod = xkb_keymap_mod_get_index(xkb_keymap, "Shift");
@@ -866,48 +968,33 @@ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
Q_ASSERT(controlMod < 32);
xkb_mod_mask_t depressed;
- struct xkb_keymap *fallback_keymap = 0;
int qtKey = 0;
- //obtain a list of possible shortcuts for the given key event
+ // obtain a list of possible shortcuts for the given key event
for (uint i = 1; i < sizeof(ModsTbl) / sizeof(*ModsTbl) ; ++i) {
Qt::KeyboardModifiers neededMods = ModsTbl[i];
if ((modifiers & neededMods) == neededMods) {
-
- depressed = 0;
- if (neededMods & Qt::AltModifier)
- depressed |= (1 << altMod);
- if (neededMods & Qt::ShiftModifier)
- depressed |= (1 << shiftMod);
- if (neededMods & Qt::ControlModifier)
- depressed |= (1 << controlMod);
-
- // update a keyboard state from a set of explicit masks
if (i == 8) {
- // Add a fall back key for layouts with non Latin-1 characters
- if (baseQtKey > 255) {
- struct xkb_rule_names names = { xkb_names.rules, xkb_names.model, "us", 0, 0 };
- fallback_keymap = xkb_keymap_new_from_names(xkb_context, &names, (xkb_keymap_compile_flags)0);
- if (!fallback_keymap)
- continue;
- xkb_state_unref(kb_state);
- kb_state = xkb_state_new(fallback_keymap);
- if (!kb_state)
- continue;
- } else
+ if (isLatin(baseQtKey))
continue;
+ // add a latin key as a fall back key
+ sym = lookupLatinKeysym(keycode);
} else {
- xkb_state_update_mask(kb_state, depressed, latchedMods, lockedMods,
- baseLayout, latchedLayout, lockedLayout);
+ depressed = 0;
+ if (neededMods & Qt::AltModifier)
+ depressed |= (1 << altMod);
+ if (neededMods & Qt::ShiftModifier)
+ depressed |= (1 << shiftMod);
+ if (neededMods & Qt::ControlModifier)
+ depressed |= (1 << controlMod);
+ xkb_state_update_mask(kb_state, depressed, latchedMods, lockedMods, 0, 0, lockedLayout);
+ sym = xkb_state_key_get_one_sym(kb_state, keycode);
}
- sym = xkb_state_key_get_one_sym(kb_state, event->nativeScanCode());
-
if (sym == XKB_KEY_NoSymbol)
continue;
Qt::KeyboardModifiers mods = modifiers & ~neededMods;
- qtKey = keysymToQtKey(sym, mods, lookupString(kb_state, event->nativeScanCode()));
-
- if (qtKey == baseQtKey || qtKey == 0)
+ qtKey = keysymToQtKey(sym, mods, lookupString(kb_state, keycode));
+ if (!qtKey || qtKey == baseQtKey)
continue;
// catch only more specific shortcuts, i.e. Ctrl+Shift+= also generates Ctrl++ and +,
@@ -926,8 +1013,6 @@ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
}
}
xkb_state_unref(kb_state);
- xkb_keymap_unref(fallback_keymap);
-
return result;
}
@@ -1002,6 +1087,8 @@ QXcbKeyboard::QXcbKeyboard(QXcbConnection *connection)
, xkb_context(0)
, xkb_keymap(0)
, xkb_state(0)
+ , latin_keymap(0)
+ , m_hasLatinLayout(false)
{
memset(&xkb_names, 0, sizeof(xkb_names));
#ifndef QT_NO_XKB
@@ -1029,6 +1116,7 @@ QXcbKeyboard::~QXcbKeyboard()
xkb_state_unref(xkb_state);
xkb_keymap_unref(xkb_keymap);
xkb_context_unref(xkb_context);
+ xkb_keymap_unref(latin_keymap);
if (!connection()->hasXKB())
xcb_key_symbols_free(m_key_symbols);
clearXKBConfig();
@@ -1324,7 +1412,6 @@ void QXcbKeyboard::handleKeyEvent(xcb_window_t sourceWindow, QEvent::Type type,
if (type == QEvent::KeyPress)
targetWindow->updateNetWmUserTime(time);
- // It is crucial the order of xkb_state_key_get_one_sym & xkb_state_update_key operations is not reversed!
xcb_keysym_t sym = xkb_state_key_get_one_sym(xkb_state, code);
QPlatformInputContext *inputContext = QGuiApplicationPrivate::platformIntegration()->inputContext();
@@ -1348,15 +1435,22 @@ void QXcbKeyboard::handleKeyEvent(xcb_window_t sourceWindow, QEvent::Type type,
return;
}
- Qt::KeyboardModifiers modifiers = translateModifiers(state);
-
QString string = lookupString(xkb_state, code);
int count = string.size();
string.truncate(count);
- int qtcode = keysymToQtKey(sym, modifiers, string);
- bool isAutoRepeat = false;
+ // Ιf control modifier is set we should prefer latin character, this is
+ // used for standard shortcuts in checks like "key == QKeySequence::Copy",
+ // users can still see the actual X11 keysym with QKeyEvent::nativeVirtualKey
+ Qt::KeyboardModifiers modifiers = translateModifiers(state);
+ xcb_keysym_t translatedSym = XKB_KEY_NoSymbol;
+ if (modifiers & Qt::ControlModifier && !isLatin(sym))
+ translatedSym = lookupLatinKeysym(code);
+ if (translatedSym == XKB_KEY_NoSymbol)
+ translatedSym = sym;
+ int qtcode = keysymToQtKey(translatedSym, modifiers, string);
+ bool isAutoRepeat = false;
if (type == QEvent::KeyPress) {
if (m_autorepeat_code == code) {
isAutoRepeat = true;
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.h b/src/plugins/platforms/xcb/qxcbkeyboard.h
index e71165d824..9f1cf165cb 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.h
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.h
@@ -91,6 +91,9 @@ protected:
void updateVModMapping();
void updateVModToRModMapping();
+ xkb_keysym_t lookupLatinKeysym(xkb_keycode_t keycode) const;
+ void checkForLatinLayout();
+
private:
bool m_config;
xcb_keycode_t m_autorepeat_code;
@@ -99,6 +102,7 @@ private:
struct xkb_keymap *xkb_keymap;
struct xkb_state *xkb_state;
struct xkb_rule_names xkb_names;
+ mutable struct xkb_keymap *latin_keymap;
struct _mod_masks {
uint alt;
@@ -128,6 +132,7 @@ private:
_mod_masks vmod_masks;
int core_device_id;
#endif
+ bool m_hasLatinLayout;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
index 0d75a7f032..3058b29f2d 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
@@ -367,7 +367,7 @@ void *QXcbNativeInterface::x11Screen()
QXcbIntegration *integration = static_cast<QXcbIntegration *>(QGuiApplicationPrivate::platformIntegration());
QXcbConnection *defaultConnection = integration->defaultConnection();
if (defaultConnection)
- return reinterpret_cast<void *>(defaultConnection->primaryScreen());
+ return reinterpret_cast<void *>(defaultConnection->primaryScreenNumber());
return 0;
}
diff --git a/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp b/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp
index 9ec4ea80ec..40a50f61ab 100644
--- a/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp
+++ b/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp
@@ -59,7 +59,7 @@ QXcbSystemTrayTracker *QXcbSystemTrayTracker::create(QXcbConnection *connection)
const xcb_atom_t trayAtom = connection->atom(QXcbAtom::_NET_SYSTEM_TRAY_OPCODE);
if (!trayAtom)
return 0;
- const QByteArray netSysTray = QByteArrayLiteral("_NET_SYSTEM_TRAY_S") + QByteArray::number(connection->primaryScreen());
+ const QByteArray netSysTray = QByteArrayLiteral("_NET_SYSTEM_TRAY_S") + QByteArray::number(connection->primaryScreenNumber());
const xcb_atom_t selection = connection->internAtom(netSysTray.constData());
if (!selection)
return 0;
@@ -145,11 +145,8 @@ QRect QXcbSystemTrayTracker::systemTrayWindowGlobalGeometry(xcb_window_t window)
inline void QXcbSystemTrayTracker::emitSystemTrayWindowChanged()
{
- const int screen = m_connection->primaryScreen();
- if (screen >= 0 && screen < m_connection->screens().size()) {
- const QPlatformScreen *ps = m_connection->screens().at(screen);
+ if (const QPlatformScreen *ps = m_connection->primaryScreen())
emit systemTrayWindowChanged(ps->screen());
- }
}
// Client messages with the "MANAGER" atom on the root window indicate creation of a new tray.
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index 0c2e9d047c..85af8ee1d2 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -2170,6 +2170,9 @@ void QXcbWindow::updateSyncRequestCounter()
bool QXcbWindow::setKeyboardGrabEnabled(bool grab)
{
+ if (grab && !connection()->canGrab())
+ return false;
+
if (!grab) {
xcb_ungrab_keyboard(xcb_connection(), XCB_TIME_CURRENT_TIME);
return true;
@@ -2185,6 +2188,9 @@ bool QXcbWindow::setKeyboardGrabEnabled(bool grab)
bool QXcbWindow::setMouseGrabEnabled(bool grab)
{
+ if (grab && !connection()->canGrab())
+ return false;
+
if (!grab) {
xcb_ungrab_pointer(xcb_connection(), XCB_TIME_CURRENT_TIME);
return true;
@@ -2380,13 +2386,10 @@ void QXcbWindow::setAlertState(bool enabled)
{
if (m_alertState == enabled)
return;
- const NetWmStates oldState = netWmStates();
+
m_alertState = enabled;
- if (enabled) {
- setNetWmStates(oldState | NetWmStateDemandsAttention);
- } else {
- setNetWmStates(oldState & ~NetWmStateDemandsAttention);
- }
+
+ changeNetWmState(enabled, atom(QXcbAtom::_NET_WM_STATE_DEMANDS_ATTENTION));
}
bool QXcbWindow::needsSync() const
diff --git a/src/plugins/platforms/xcb/qxcbwmsupport.cpp b/src/plugins/platforms/xcb/qxcbwmsupport.cpp
index 0458be32f6..1be9ab3e05 100644
--- a/src/plugins/platforms/xcb/qxcbwmsupport.cpp
+++ b/src/plugins/platforms/xcb/qxcbwmsupport.cpp
@@ -56,7 +56,7 @@ void QXcbWMSupport::updateNetWMAtoms()
{
net_wm_atoms.clear();
- xcb_window_t root = connection()->screens().at(connection()->primaryScreen())->root();
+ xcb_window_t root = connection()->primaryScreen()->root();
int offset = 0;
int remaining = 0;
do {
@@ -90,7 +90,7 @@ void QXcbWMSupport::updateVirtualRoots()
if (!isSupportedByWM(atom(QXcbAtom::_NET_VIRTUAL_ROOTS)))
return;
- xcb_window_t root = connection()->screens().at(connection()->primaryScreen())->root();
+ xcb_window_t root = connection()->primaryScreen()->root();
int offset = 0;
int remaining = 0;
do {
diff --git a/src/plugins/platforms/xcb/qxcbxsettings.cpp b/src/plugins/platforms/xcb/qxcbxsettings.cpp
index 6f2e60c9be..13d42832db 100644
--- a/src/plugins/platforms/xcb/qxcbxsettings.cpp
+++ b/src/plugins/platforms/xcb/qxcbxsettings.cpp
@@ -262,6 +262,12 @@ QXcbXSettings::QXcbXSettings(QXcbScreen *screen)
d_ptr->initialized = true;
}
+QXcbXSettings::~QXcbXSettings()
+{
+ delete d_ptr;
+ d_ptr = 0;
+}
+
bool QXcbXSettings::initialized() const
{
Q_D(const QXcbXSettings);
diff --git a/src/plugins/platforms/xcb/qxcbxsettings.h b/src/plugins/platforms/xcb/qxcbxsettings.h
index 717fe559c9..3496cedf36 100644
--- a/src/plugins/platforms/xcb/qxcbxsettings.h
+++ b/src/plugins/platforms/xcb/qxcbxsettings.h
@@ -45,6 +45,7 @@ class QXcbXSettings : public QXcbWindowEventListener
Q_DECLARE_PRIVATE(QXcbXSettings)
public:
QXcbXSettings(QXcbScreen *screen);
+ ~QXcbXSettings();
bool initialized() const;
QVariant setting(const QByteArray &property) const;
diff --git a/src/plugins/platforms/xcb/xcb-plugin.pro b/src/plugins/platforms/xcb/xcb-plugin.pro
index 9aaafadcad..f14fcde73f 100644
--- a/src/plugins/platforms/xcb/xcb-plugin.pro
+++ b/src/plugins/platforms/xcb/xcb-plugin.pro
@@ -60,7 +60,7 @@ contains(QT_CONFIG, xcb-xlib) {
# to support custom cursors with depth > 1
contains(QT_CONFIG, xcb-render) {
DEFINES += XCB_USE_RENDER
- LIBS += -lxcb-render -lxcb-render-util -lXrender
+ LIBS += -lxcb-render -lxcb-render-util
}
# build with session management support