summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-05-06 01:00:13 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-05-06 01:00:13 +0200
commite4e5a1f0b7f85b4c8b593a06a67d83f5be09004e (patch)
treedac64fe28e21f02938be5c726002b379750fe7ad /src/plugins
parent615b02bfa2fb861f362c511087e6962660c25ea3 (diff)
parenta50b29d65bddae44aedfd9372502f656656803d5 (diff)
Merge remote-tracking branch 'origin/5.12' into 5.13
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/android/qandroidinputcontext.cpp26
-rw-r--r--src/plugins/platforms/cocoa/qcocoasystemtrayicon.h3
-rw-r--r--src/plugins/platforms/cocoa/qnsview_dragging.mm19
3 files changed, 43 insertions, 5 deletions
diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp
index c31e43e0bb..00ab3409d3 100644
--- a/src/plugins/platforms/android/qandroidinputcontext.cpp
+++ b/src/plugins/platforms/android/qandroidinputcontext.cpp
@@ -978,15 +978,25 @@ jboolean QAndroidInputContext::deleteSurroundingText(jint leftLength, jint right
m_composingText.clear();
m_composingTextStart = -1;
- QString text = query->value(Qt::ImSurroundingText).toString();
- if (text.isEmpty())
- return JNI_TRUE;
-
if (leftLength < 0) {
rightLength += -leftLength;
leftLength = 0;
}
+ QVariant textBeforeCursor = query->value(Qt::ImTextBeforeCursor);
+ QVariant textAfterCursor = query->value(Qt::ImTextAfterCursor);
+ if (textBeforeCursor.isValid() && textAfterCursor.isValid()) {
+ leftLength = qMin(leftLength, textBeforeCursor.toString().length());
+ rightLength = qMin(rightLength, textAfterCursor.toString().length());
+ } else {
+ int cursorPos = query->value(Qt::ImCursorPosition).toInt();
+ leftLength = qMin(leftLength, cursorPos);
+ rightLength = qMin(rightLength, query->value(Qt::ImSurroundingText).toString().length() - cursorPos);
+ }
+
+ if (leftLength == 0 && rightLength == 0)
+ return JNI_TRUE;
+
QInputMethodEvent event;
event.setCommitString(QString(), -leftLength, leftLength+rightLength);
sendInputMethodEvent(&event);
@@ -1075,6 +1085,14 @@ const QAndroidInputContext::ExtractedText &QAndroidInputContext::getExtractedTex
int cpos = localPos + composeLength; //actual cursor pos relative to the current block
int localOffset = 0; // start of extracted text relative to the current block
+ if (blockPos > 0) {
+ QString prevBlockEnding = query->value(Qt::ImTextBeforeCursor).toString();
+ prevBlockEnding.chop(localPos);
+ if (prevBlockEnding.endsWith(QLatin1Char('\n'))) {
+ localOffset = -qMin(20, prevBlockEnding.length());
+ blockText = prevBlockEnding.right(-localOffset) + blockText;
+ }
+ }
// It is documented that we should try to return hintMaxChars
// characters, but that's not what the standard Android controls do, and
diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.h b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.h
index d831612c22..6779bda491 100644
--- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.h
+++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.h
@@ -42,8 +42,9 @@
#define QCOCOASYSTEMTRAYICON_P_H
#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
-#ifndef QT_NO_SYSTEMTRAYICON
+#if QT_CONFIG(systemtrayicon)
#include "QtCore/qstring.h"
#include "QtGui/qpa/qplatformsystemtrayicon.h"
diff --git a/src/plugins/platforms/cocoa/qnsview_dragging.mm b/src/plugins/platforms/cocoa/qnsview_dragging.mm
index 002cb3279e..37e972dba9 100644
--- a/src/plugins/platforms/cocoa/qnsview_dragging.mm
+++ b/src/plugins/platforms/cocoa/qnsview_dragging.mm
@@ -293,7 +293,26 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag();
nativeDrag->setAcceptedAction(qt_mac_mapNSDragOperation(operation));
+ // Qt starts drag-and-drop on a mouse button press event. Cococa in
+ // this case won't send the matching release event, so we have to
+ // synthesize it here.
m_buttons = currentlyPressedMouseButtons();
+ const auto modifiers = [QNSView convertKeyModifiers:NSApp.currentEvent.modifierFlags];
+
+ NSPoint windowPoint = [self.window convertRectFromScreen:NSMakeRect(screenPoint.x, screenPoint.y, 1, 1)].origin;
+ NSPoint nsViewPoint = [self convertPoint: windowPoint fromView: nil];
+
+ QPoint qtWindowPoint(nsViewPoint.x, nsViewPoint.y);
+ QPoint qtScreenPoint = QCocoaScreen::mapFromNative(screenPoint).toPoint();
+
+ QWindowSystemInterface::handleMouseEvent(
+ target,
+ mapWindowCoordinates(m_platformWindow->window(), target, qtWindowPoint),
+ qtScreenPoint,
+ m_buttons,
+ Qt::NoButton,
+ QEvent::MouseButtonRelease,
+ modifiers);
qCDebug(lcQpaMouse) << "Drag session" << session << "ended, with" << m_buttons;
}