summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2014-12-18 12:12:58 +0100
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2014-12-18 12:12:58 +0100
commite281537f2049af0b96fd87158f2b7212afe8ab5f (patch)
tree7f9e3b14a2456cc779aa165457192094507dd257 /src/plugins/platforms
parente0a8b5ce88bc50440dcec2fe3a86d83e2a7dc7b0 (diff)
parent84569773db68408704193268bc42a200bb25a924 (diff)
Merge remote-tracking branch 'origin/5.4' into dev
Conflicts: src/corelib/global/qglobal.h src/platformsupport/platformcompositor/qopenglcompositor.cpp src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp tests/auto/gui/kernel/qwindow/tst_qwindow.cpp Change-Id: I5422868500be695584a496dbbbc719d146bc572d
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/android/qandroidplatformintegration.cpp5
-rw-r--r--src/plugins/platforms/android/qandroidplatformtheme.cpp18
-rw-r--r--src/plugins/platforms/android/qandroidplatformtheme.h2
-rw-r--r--src/plugins/platforms/ios/qiosinputcontext.h1
-rw-r--r--src/plugins/platforms/ios/qiosinputcontext.mm52
-rw-r--r--src/plugins/platforms/ios/qiostextresponder.mm10
-rw-r--r--src/plugins/platforms/windows/qwindowsfontengine.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowskeymapper.cpp5
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp10
-rw-r--r--src/plugins/platforms/xcb/qxcbclipboard.cpp3
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.cpp2
11 files changed, 68 insertions, 42 deletions
diff --git a/src/plugins/platforms/android/qandroidplatformintegration.cpp b/src/plugins/platforms/android/qandroidplatformintegration.cpp
index 07bdf95bf4..d94da65dde 100644
--- a/src/plugins/platforms/android/qandroidplatformintegration.cpp
+++ b/src/plugins/platforms/android/qandroidplatformintegration.cpp
@@ -79,8 +79,11 @@ void *QAndroidPlatformNativeInterface::nativeResourceForIntegration(const QByteA
if (resource == "QtActivity")
return QtAndroid::activity();
if (resource == "AndroidStyleData") {
- if (m_androidStyle)
+ if (m_androidStyle) {
+ if (m_androidStyle->m_styleData.isEmpty())
+ m_androidStyle->m_styleData = AndroidStyle::loadStyleData();
return &m_androidStyle->m_styleData;
+ }
else
return Q_NULLPTR;
}
diff --git a/src/plugins/platforms/android/qandroidplatformtheme.cpp b/src/plugins/platforms/android/qandroidplatformtheme.cpp
index e729309ad9..f1ddcefef6 100644
--- a/src/plugins/platforms/android/qandroidplatformtheme.cpp
+++ b/src/plugins/platforms/android/qandroidplatformtheme.cpp
@@ -176,7 +176,7 @@ static void setPaletteColor(const QVariantMap &object,
}
}
-static std::shared_ptr<AndroidStyle> loadAndroidStyle(QPalette *defaultPalette)
+QJsonObject AndroidStyle::loadStyleData()
{
QString stylePath(QLatin1String(qgetenv("MINISTRO_ANDROID_STYLE_PATH")));
const QLatin1Char slashChar('/');
@@ -198,21 +198,29 @@ static std::shared_ptr<AndroidStyle> loadAndroidStyle(QPalette *defaultPalette)
QFile f(stylePath + QLatin1String("style.json"));
if (!f.open(QIODevice::ReadOnly))
- return std::shared_ptr<AndroidStyle>();
+ return QJsonObject();
QJsonParseError error;
QJsonDocument document = QJsonDocument::fromJson(f.readAll(), &error);
if (document.isNull()) {
qCritical() << error.errorString();
- return std::shared_ptr<AndroidStyle>();
+ return QJsonObject();
}
if (!document.isObject()) {
qCritical() << "Style.json does not contain a valid style.";
- return std::shared_ptr<AndroidStyle>();
+ return QJsonObject();
}
+ return document.object();
+}
+
+static std::shared_ptr<AndroidStyle> loadAndroidStyle(QPalette *defaultPalette)
+{
std::shared_ptr<AndroidStyle> style(new AndroidStyle);
- style->m_styleData = document.object();
+ style->m_styleData = AndroidStyle::loadStyleData();
+ if (style->m_styleData.isEmpty())
+ return std::shared_ptr<AndroidStyle>();
+
for (QJsonObject::const_iterator objectIterator = style->m_styleData.constBegin();
objectIterator != style->m_styleData.constEnd();
++objectIterator) {
diff --git a/src/plugins/platforms/android/qandroidplatformtheme.h b/src/plugins/platforms/android/qandroidplatformtheme.h
index e842e672d6..2069910136 100644
--- a/src/plugins/platforms/android/qandroidplatformtheme.h
+++ b/src/plugins/platforms/android/qandroidplatformtheme.h
@@ -46,12 +46,12 @@ QT_BEGIN_NAMESPACE
struct AndroidStyle
{
+ static QJsonObject loadStyleData();
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;
diff --git a/src/plugins/platforms/ios/qiosinputcontext.h b/src/plugins/platforms/ios/qiosinputcontext.h
index 863e503c3b..498db45ef2 100644
--- a/src/plugins/platforms/ios/qiosinputcontext.h
+++ b/src/plugins/platforms/ios/qiosinputcontext.h
@@ -96,7 +96,6 @@ public:
void setFocusObject(QObject *object) Q_DECL_OVERRIDE;
void focusWindowChanged(QWindow *focusWindow);
- void cursorRectangleChanged();
void scrollToCursor();
void scroll(int y);
diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm
index fe9ee18155..76c02d939f 100644
--- a/src/plugins/platforms/ios/qiosinputcontext.mm
+++ b/src/plugins/platforms/ios/qiosinputcontext.mm
@@ -68,6 +68,7 @@ static QUIView *focusView()
@private
QIOSInputContext *m_context;
}
+@property BOOL hasDeferredScrollToCursor;
@end
@implementation QIOSKeyboardListener
@@ -80,6 +81,8 @@ static QUIView *focusView()
m_context = context;
+ self.hasDeferredScrollToCursor = NO;
+
// UIGestureRecognizer
self.enabled = NO;
self.cancelsTouchesInView = NO;
@@ -159,6 +162,18 @@ static QUIView *focusView()
// -------------------------------------------------------------------------
+- (BOOL)canPreventGestureRecognizer:(UIGestureRecognizer *)other
+{
+ Q_UNUSED(other);
+ return NO;
+}
+
+- (BOOL)canBePreventedByGestureRecognizer:(UIGestureRecognizer *)other
+{
+ Q_UNUSED(other);
+ return NO;
+}
+
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesBegan:touches withEvent:event];
@@ -231,9 +246,14 @@ static QUIView *focusView()
qImDebug() << "keyboard was hidden, disabling hide-keyboard gesture";
self.enabled = NO;
} else {
- qImDebug() << "gesture completed without triggering, scrolling view to cursor";
- m_context->scrollToCursor();
+ qImDebug() << "gesture completed without triggering";
+ if (self.hasDeferredScrollToCursor) {
+ qImDebug() << "applying deferred scroll to cursor";
+ m_context->scrollToCursor();
+ }
}
+
+ self.hasDeferredScrollToCursor = NO;
}
@end
@@ -281,8 +301,6 @@ QIOSInputContext::QIOSInputContext()
if (isQtApplication()) {
QIOSScreen *iosScreen = static_cast<QIOSScreen*>(QGuiApplication::primaryScreen()->handle());
[iosScreen->uiWindow() addGestureRecognizer:m_keyboardHideGesture];
-
- connect(qGuiApp->inputMethod(), &QInputMethod::cursorRectangleChanged, this, &QIOSInputContext::cursorRectangleChanged);
}
connect(qGuiApp, &QGuiApplication::focusWindowChanged, this, &QIOSInputContext::focusWindowChanged);
@@ -400,23 +418,6 @@ QRectF QIOSInputContext::keyboardRect() const
// -------------------------------------------------------------------------
-void QIOSInputContext::cursorRectangleChanged()
-{
- if (!isInputPanelVisible() || !qApp->focusObject())
- return;
-
- // Check if the cursor has changed position inside the input item. Since
- // qApp->inputMethod()->cursorRectangle() will also change when the input item
- // itself moves, we need to ask the focus object for ImCursorRectangle:
- static QPoint prevCursor;
- QInputMethodQueryEvent queryEvent(Qt::ImCursorRectangle);
- QCoreApplication::sendEvent(qApp->focusObject(), &queryEvent);
- QPoint cursor = queryEvent.value(Qt::ImCursorRectangle).toRect().topLeft();
- if (cursor != prevCursor)
- scrollToCursor();
- prevCursor = cursor;
-}
-
UIView *QIOSInputContext::scrollableRootView()
{
if (!m_keyboardHideGesture.view)
@@ -437,7 +438,8 @@ void QIOSInputContext::scrollToCursor()
if (m_keyboardHideGesture.state == UIGestureRecognizerStatePossible && m_keyboardHideGesture.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";
+ qImDebug() << "deferring scrolling to cursor as we're still waiting for a possible gesture";
+ m_keyboardHideGesture.hasDeferredScrollToCursor = YES;
return;
}
@@ -524,7 +526,8 @@ void QIOSInputContext::setFocusObject(QObject *focusObject)
qImDebug() << "new focus object =" << focusObject;
- if (m_keyboardHideGesture.state == UIGestureRecognizerStateChanged) {
+ if (QPlatformInputContext::inputMethodAccepted()
+ && m_keyboardHideGesture.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
@@ -598,6 +601,9 @@ void QIOSInputContext::update(Qt::InputMethodQueries updatedProperties)
} else {
[m_textResponder notifyInputDelegate:changedProperties];
}
+
+ if (changedProperties & Qt::ImCursorRectangle)
+ scrollToCursor();
}
bool QIOSInputContext::inputMethodAccepted() const
diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm
index 2fcc7258f7..bebc7577f8 100644
--- a/src/plugins/platforms/ios/qiostextresponder.mm
+++ b/src/plugins/platforms/ios/qiostextresponder.mm
@@ -263,10 +263,14 @@
// 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
+ // We have resigned the keyboard, and transferred first responder back to the parent view
Q_ASSERT(!FirstResponderCandidate::currentCandidate());
- qImDebug() << "keyboard was closed, clearing focus object";
- m_inputContext->clearCurrentFocusObject();
+ if ([self imValue:Qt::ImEnabled].toBool()) {
+ // The current focus object expects text input, but there
+ // is no keyboard to get input from. So we clear focus.
+ qImDebug() << "no keyboard available, 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
diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp
index 6b13d93259..a182987e3f 100644
--- a/src/plugins/platforms/windows/qwindowsfontengine.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp
@@ -1017,7 +1017,7 @@ QFontEngine::Properties QWindowsFontEngine::properties() const
void QWindowsFontEngine::getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics)
{
LOGFONT lf = m_logfont;
- lf.lfHeight = unitsPerEm;
+ lf.lfHeight = -unitsPerEm;
int flags = synthesized();
if(flags & SynthesizedItalic)
lf.lfItalic = false;
diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp
index a99a6a5dc7..25d6937d8f 100644
--- a/src/plugins/platforms/windows/qwindowskeymapper.cpp
+++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp
@@ -833,7 +833,10 @@ bool QWindowsKeyMapper::translateMultimediaKeyEventInternal(QWindow *window, con
const int qtKey = CmdTbl[cmd];
sendExtendedPressRelease(receiver, qtKey, Qt::KeyboardModifier(state), 0, 0, 0);
- return true;
+ // QTBUG-43343: Make sure to return false if Qt does not handle the key, otherwise,
+ // the keys are not passed to the active media player.
+ const QKeySequence sequence(Qt::Modifier(state) + qtKey);
+ return QGuiApplicationPrivate::instance()->shortcutMap.hasShortcutForKeySequence(sequence);
#else
Q_UNREACHABLE();
return false;
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 5768800947..7d67aa0d09 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -559,10 +559,11 @@ QWindowsWindowData
Q_ASSERT(result.hwnd);
const LONG_PTR style = GetWindowLongPtr(result.hwnd, GWL_STYLE);
const LONG_PTR exStyle = GetWindowLongPtr(result.hwnd, GWL_EXSTYLE);
- result.geometry = frameGeometry(result.hwnd, !GetParent(result.hwnd));
- result.frame = QWindowsGeometryHint::frame(style, exStyle);
result.embedded = false;
- qCDebug(lcQpaWindows) << "Foreign window: " << w << result.hwnd << result.geometry << result.frame;
+ result.frame = QWindowsGeometryHint::frame(style, exStyle);
+ result.geometry = frameGeometry(result.hwnd, !GetParent(result.hwnd))
+ .marginsRemoved(result.frame);
+ qCDebug(lcQpaWindows) << "Foreign window: " << w << result.hwnd << result.geometry;
return result;
}
@@ -889,7 +890,8 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const QWindowsWindowData &data)
updateDropSite();
#ifndef Q_OS_WINCE
- if (QWindowsContext::instance()->systemInfo() & QWindowsContext::SI_SupportsTouch) {
+ if ((QWindowsContext::instance()->systemInfo() & QWindowsContext::SI_SupportsTouch)
+ && aWindow->type() != Qt::ForeignWindow) {
if (QWindowsContext::user32dll.registerTouchWindow(m_data.hwnd, 0)) {
setFlag(TouchRegistered);
} else {
diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp
index 4c070a3d6c..61e9860802 100644
--- a/src/plugins/platforms/xcb/qxcbclipboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp
@@ -742,7 +742,8 @@ void QXcbClipboard::handleXFixesSelectionRequest(xcb_xfixes_selection_notify_eve
m_xClipboard[mode]->reset();
}
emitChanged(mode);
- }
+ } else if (event->subtype == XCB_XFIXES_SELECTION_EVENT_SELECTION_CLIENT_CLOSE)
+ emitChanged(mode);
}
diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp
index 1a10a865ab..0335cc0fec 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.cpp
+++ b/src/plugins/platforms/xcb/qxcbintegration.cpp
@@ -165,7 +165,7 @@ QXcbIntegration::QXcbIntegration(const QStringList &parameters, int &argc, char
"\t Use the -dograb option to enforce grabbing.");
}
#endif
- m_canGrab = (!underDebugger && noGrabArg) || (underDebugger && doGrabArg);
+ m_canGrab = (!underDebugger && !noGrabArg) || (underDebugger && doGrabArg);
static bool canNotGrabEnv = qEnvironmentVariableIsSet("QT_XCB_NO_GRAB_SERVER");
if (canNotGrabEnv)