summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/android/qandroidinputcontext.cpp16
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.mm10
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp6
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.h4
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.cpp4
-rw-r--r--src/plugins/platforms/windows/qwindowspointerhandler.cpp49
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h2
7 files changed, 82 insertions, 9 deletions
diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp
index ea3e9c1441..c5cd0b92d9 100644
--- a/src/plugins/platforms/android/qandroidinputcontext.cpp
+++ b/src/plugins/platforms/android/qandroidinputcontext.cpp
@@ -58,6 +58,7 @@
#include <private/qhighdpiscaling_p.h>
#include <QTextCharFormat>
+#include <QTextBoundaryFinder>
#include <QDebug>
@@ -1020,8 +1021,19 @@ jint QAndroidInputContext::getCursorCapsMode(jint /*reqModes*/)
return res;
const uint qtInputMethodHints = query->value(Qt::ImHints).toUInt();
-
- if (!(qtInputMethodHints & Qt::ImhLowercaseOnly) && !(qtInputMethodHints & Qt::ImhNoAutoUppercase))
+ const int localPos = query->value(Qt::ImCursorPosition).toInt();
+
+ bool atWordBoundary = (localPos == 0);
+ if (!atWordBoundary) {
+ QString surroundingText = query->value(Qt::ImSurroundingText).toString();
+ surroundingText.truncate(localPos);
+ // Add a character to see if it is at the end of the sentence or not
+ QTextBoundaryFinder finder(QTextBoundaryFinder::Sentence, surroundingText + QLatin1Char('A'));
+ finder.setPosition(localPos);
+ if (finder.isAtBoundary())
+ atWordBoundary = finder.isAtBoundary();
+ }
+ if (atWordBoundary && !(qtInputMethodHints & Qt::ImhLowercaseOnly) && !(qtInputMethodHints & Qt::ImhNoAutoUppercase))
res |= CAP_MODE_SENTENCES;
if (qtInputMethodHints & Qt::ImhUppercaseOnly)
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
index f11016679a..069429796e 100644
--- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
@@ -393,8 +393,10 @@ bool QCocoaGLContext::setDrawable(QPlatformSurface *surface)
return true;
}
-// NSOpenGLContext is not re-entrant (https://openradar.appspot.com/37064579)
-static QMutex s_contextMutex;
+// NSOpenGLContext is not re-entrant. Even when using separate contexts per thread,
+// view, and window, calls into the API will still deadlock. For more information
+// see https://openradar.appspot.com/37064579
+static QMutex s_reentrancyMutex;
void QCocoaGLContext::update()
{
@@ -403,7 +405,7 @@ void QCocoaGLContext::update()
// render-loop that doesn't return to one of the outer pools.
QMacAutoReleasePool pool;
- QMutexLocker locker(&s_contextMutex);
+ QMutexLocker locker(&s_reentrancyMutex);
qCInfo(lcQpaOpenGLContext) << "Updating" << m_context << "for" << m_context.view;
[m_context update];
}
@@ -422,7 +424,7 @@ void QCocoaGLContext::swapBuffers(QPlatformSurface *surface)
return;
}
- QMutexLocker locker(&s_contextMutex);
+ QMutexLocker locker(&s_reentrancyMutex);
[m_context flushBuffer];
}
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index 03bb1bee48..373758b49e 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -201,7 +201,9 @@ void QWindowsUser32DLL::init()
getPointerDeviceRects = (GetPointerDeviceRects)library.resolve("GetPointerDeviceRects");
getPointerTouchInfo = (GetPointerTouchInfo)library.resolve("GetPointerTouchInfo");
getPointerFrameTouchInfo = (GetPointerFrameTouchInfo)library.resolve("GetPointerFrameTouchInfo");
+ getPointerFrameTouchInfoHistory = (GetPointerFrameTouchInfoHistory)library.resolve("GetPointerFrameTouchInfoHistory");
getPointerPenInfo = (GetPointerPenInfo)library.resolve("GetPointerPenInfo");
+ getPointerPenInfoHistory = (GetPointerPenInfoHistory)library.resolve("GetPointerPenInfoHistory");
skipPointerFrameMessages = (SkipPointerFrameMessages)library.resolve("SkipPointerFrameMessages");
}
@@ -216,8 +218,8 @@ void QWindowsUser32DLL::init()
bool QWindowsUser32DLL::supportsPointerApi()
{
return enableMouseInPointer && getPointerType && getPointerInfo && getPointerDeviceRects
- && getPointerTouchInfo && getPointerFrameTouchInfo && getPointerPenInfo
- && skipPointerFrameMessages;
+ && getPointerTouchInfo && getPointerFrameTouchInfo && getPointerFrameTouchInfoHistory
+ && getPointerPenInfo && getPointerPenInfoHistory && skipPointerFrameMessages;
}
void QWindowsShcoreDLL::init()
diff --git a/src/plugins/platforms/windows/qwindowscontext.h b/src/plugins/platforms/windows/qwindowscontext.h
index 8102e0bf19..622c729a10 100644
--- a/src/plugins/platforms/windows/qwindowscontext.h
+++ b/src/plugins/platforms/windows/qwindowscontext.h
@@ -92,7 +92,9 @@ struct QWindowsUser32DLL
typedef BOOL (WINAPI *GetPointerDeviceRects)(HANDLE, RECT *, RECT *);
typedef BOOL (WINAPI *GetPointerTouchInfo)(UINT32, PVOID);
typedef BOOL (WINAPI *GetPointerFrameTouchInfo)(UINT32, UINT32 *, PVOID);
+ typedef BOOL (WINAPI *GetPointerFrameTouchInfoHistory)(UINT32, UINT32 *, UINT32 *, PVOID);
typedef BOOL (WINAPI *GetPointerPenInfo)(UINT32, PVOID);
+ typedef BOOL (WINAPI *GetPointerPenInfoHistory)(UINT32, UINT32 *, PVOID);
typedef BOOL (WINAPI *SkipPointerFrameMessages)(UINT32);
typedef BOOL (WINAPI *SetProcessDPIAware)();
typedef BOOL (WINAPI *AddClipboardFormatListener)(HWND);
@@ -110,7 +112,9 @@ struct QWindowsUser32DLL
GetPointerDeviceRects getPointerDeviceRects = nullptr;
GetPointerTouchInfo getPointerTouchInfo = nullptr;
GetPointerFrameTouchInfo getPointerFrameTouchInfo = nullptr;
+ GetPointerFrameTouchInfoHistory getPointerFrameTouchInfoHistory = nullptr;
GetPointerPenInfo getPointerPenInfo = nullptr;
+ GetPointerPenInfoHistory getPointerPenInfoHistory = nullptr;
SkipPointerFrameMessages skipPointerFrameMessages = nullptr;
// Windows Vista onwards
diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp
index 0694435427..7d621126b9 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.cpp
+++ b/src/plugins/platforms/windows/qwindowsintegration.cpp
@@ -236,7 +236,9 @@ QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList &paramL
m_options = parseOptions(paramList, &tabletAbsoluteRange, &dpiAwareness);
QWindowsFontDatabase::setFontOptions(m_options);
- if (!m_context.initPointer(m_options)) {
+ if (m_context.initPointer(m_options)) {
+ QCoreApplication::setAttribute(Qt::AA_CompressHighFrequencyEvents);
+ } else {
m_context.initTablet(m_options);
if (tabletAbsoluteRange >= 0)
m_context.setTabletAbsoluteRange(tabletAbsoluteRange);
diff --git a/src/plugins/platforms/windows/qwindowspointerhandler.cpp b/src/plugins/platforms/windows/qwindowspointerhandler.cpp
index d8918d1b3d..7ead14822a 100644
--- a/src/plugins/platforms/windows/qwindowspointerhandler.cpp
+++ b/src/plugins/platforms/windows/qwindowspointerhandler.cpp
@@ -106,6 +106,32 @@ bool QWindowsPointerHandler::translatePointerEvent(QWindow *window, HWND hwnd, Q
qWarning() << "GetPointerFrameTouchInfo() failed:" << qt_error_string();
return false;
}
+
+ if (!pointerCount)
+ return false;
+
+ // The history count is the same for all the touchpoints in touchInfo
+ quint32 historyCount = touchInfo[0].pointerInfo.historyCount;
+ // dispatch any skipped frames if event compression is disabled by the app
+ if (historyCount > 1 && !QCoreApplication::testAttribute(Qt::AA_CompressHighFrequencyEvents)) {
+ touchInfo.resize(pointerCount * historyCount);
+ if (!QWindowsContext::user32dll.getPointerFrameTouchInfoHistory(pointerId,
+ &historyCount,
+ &pointerCount,
+ touchInfo.data())) {
+ qWarning() << "GetPointerFrameTouchInfoHistory() failed:" << qt_error_string();
+ return false;
+ }
+
+ // history frames are returned with the most recent frame first so we iterate backwards
+ bool result = true;
+ for (auto it = touchInfo.rbegin(), end = touchInfo.rend(); it != end; it += pointerCount) {
+ result &= translateTouchEvent(window, hwnd, et, msg,
+ &(*(it + (pointerCount - 1))), pointerCount);
+ }
+ return result;
+ }
+
return translateTouchEvent(window, hwnd, et, msg, touchInfo.data(), pointerCount);
}
case QT_PT_PEN: {
@@ -114,6 +140,29 @@ bool QWindowsPointerHandler::translatePointerEvent(QWindow *window, HWND hwnd, Q
qWarning() << "GetPointerPenInfo() failed:" << qt_error_string();
return false;
}
+
+ quint32 historyCount = penInfo.pointerInfo.historyCount;
+ // dispatch any skipped frames if generic or tablet event compression is disabled by the app
+ if (historyCount > 1
+ && (!QCoreApplication::testAttribute(Qt::AA_CompressHighFrequencyEvents)
+ || !QCoreApplication::testAttribute(Qt::AA_CompressTabletEvents))) {
+ QVarLengthArray<POINTER_PEN_INFO, 10> penInfoHistory(historyCount);
+
+ if (!QWindowsContext::user32dll.getPointerPenInfoHistory(pointerId,
+ &historyCount,
+ penInfoHistory.data())) {
+ qWarning() << "GetPointerPenInfoHistory() failed:" << qt_error_string();
+ return false;
+ }
+
+ // history frames are returned with the most recent frame first so we iterate backwards
+ bool result = true;
+ for (auto it = penInfoHistory.rbegin(), end = penInfoHistory.rend(); it != end; ++it) {
+ result &= translatePenEvent(window, hwnd, et, msg, &(*(it)));
+ }
+ return result;
+ }
+
return translatePenEvent(window, hwnd, et, msg, &penInfo);
}
}
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h
index b0c36e61b0..94f8a8876a 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.h
+++ b/src/plugins/platforms/xcb/qxcbconnection.h
@@ -414,6 +414,8 @@ public:
bool imageNeedsEndianSwap() const
{
+ if (!hasShm())
+ return false; // The non-Shm path does its own swapping
#if Q_BYTE_ORDER == Q_BIG_ENDIAN
return m_setup->image_byte_order != XCB_IMAGE_ORDER_MSB_FIRST;
#else