diff options
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/android/androidjnimain.cpp | 5 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qmacclipboard.h | 1 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qmacclipboard.mm | 19 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview.mm | 14 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowsintegration.cpp | 7 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowstheme.cpp | 9 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowswindow.cpp | 10 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.cpp | 5 |
8 files changed, 44 insertions, 26 deletions
diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index 52f34166eb..6419ba2c51 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -840,6 +840,11 @@ QT_END_NAMESPACE Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void */*reserved*/) { + static bool initialized = false; + if (initialized) + return JNI_VERSION_1_6; + initialized = true; + QT_USE_NAMESPACE typedef union { JNIEnv *nativeEnvironment; diff --git a/src/plugins/platforms/cocoa/qmacclipboard.h b/src/plugins/platforms/cocoa/qmacclipboard.h index a4b5cf00d6..a3abacf849 100644 --- a/src/plugins/platforms/cocoa/qmacclipboard.h +++ b/src/plugins/platforms/cocoa/qmacclipboard.h @@ -75,6 +75,7 @@ private: uchar mime_type; mutable QPointer<QMimeData> mime; mutable bool mac_mime_source; + bool resolvingBeforeDestruction; static OSStatus promiseKeeper(PasteboardRef, PasteboardItemID, CFStringRef, void *); void clear_helper(); public: diff --git a/src/plugins/platforms/cocoa/qmacclipboard.mm b/src/plugins/platforms/cocoa/qmacclipboard.mm index 70d1170edb..721b0fb4d1 100644 --- a/src/plugins/platforms/cocoa/qmacclipboard.mm +++ b/src/plugins/platforms/cocoa/qmacclipboard.mm @@ -87,6 +87,7 @@ QMacPasteboard::QMacPasteboard(PasteboardRef p, uchar mt) mime_type = mt ? mt : uchar(QMacInternalPasteboardMime::MIME_ALL); paste = p; CFRetain(paste); + resolvingBeforeDestruction = false; } QMacPasteboard::QMacPasteboard(uchar mt) @@ -100,6 +101,7 @@ QMacPasteboard::QMacPasteboard(uchar mt) } else { qDebug("PasteBoard: Error creating pasteboard: [%d]", (int)err); } + resolvingBeforeDestruction = false; } QMacPasteboard::QMacPasteboard(CFStringRef name, uchar mt) @@ -113,23 +115,14 @@ QMacPasteboard::QMacPasteboard(CFStringRef name, uchar mt) } else { qDebug("PasteBoard: Error creating pasteboard: %s [%d]", QCFString::toQString(name).toLatin1().constData(), (int)err); } + resolvingBeforeDestruction = false; } QMacPasteboard::~QMacPasteboard() { // commit all promises for paste after exit close - for (int i = 0; i < promises.count(); ++i) { - const Promise &promise = promises.at(i); - // At this point app teardown has started and control is somewhere in the Q[Core]Application - // destructor. Skip "lazy" promises where the application has not provided data; - // the application will generally not be in a state to provide it. - if (promise.dataRequestType == LazyRequest) - continue; - QCFString flavor = QCFString(promise.convertor->flavorFor(promise.mime)); - NSInteger pbItemId = promise.itemId; - promiseKeeper(paste, reinterpret_cast<PasteboardItemID>(pbItemId), flavor, this); - } - + resolvingBeforeDestruction = true; + PasteboardResolvePromises(paste); if (paste) CFRelease(paste); } @@ -181,7 +174,7 @@ OSStatus QMacPasteboard::promiseKeeper(PasteboardRef paste, PasteboardItemID id, // to request the data from the application. QVariant promiseData; if (promise.dataRequestType == LazyRequest) { - if (!promise.mimeData.isNull()) + if (!qpaste->resolvingBeforeDestruction && !promise.mimeData.isNull()) promiseData = promise.mimeData->variantData(promise.mime); } else { promiseData = promise.variantData; diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index a72cbd010a..500049a504 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -1625,12 +1625,18 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) const bool accepted = [self handleKeyEvent:nsevent eventType:int(QEvent::KeyPress)]; - // Track keyDown acceptance state for later acceptance of the keyUp. - if (accepted) + // When Qt is used to implement a plugin for a native application we + // want to propagate unhandled events to other native views. However, + // Qt does not always set the accepted state correctly (in particular + // for return key events), so do this for plugin applications only + // to prevent incorrect forwarding in the general case. + const bool shouldPropagate = QCoreApplication::testAttribute(Qt::AA_PluginApplication) && !accepted; + + // Track keyDown acceptance/forward state for later acceptance of the keyUp. + if (!shouldPropagate) m_acceptedKeyDowns.insert([nsevent keyCode]); - // Propagate the keyDown to the next responder if Qt did not accept it. - if (!accepted) + if (shouldPropagate) [super keyDown:nsevent]; } diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 5b8cc7893a..90aa3fef16 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -302,7 +302,12 @@ QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) cons } if (window->type() == Qt::ForeignWindow) { - QWindowsForeignWindow *result = new QWindowsForeignWindow(window, reinterpret_cast<HWND>(window->winId())); + const HWND hwnd = reinterpret_cast<HWND>(window->winId()); + if (!IsWindow(hwnd)) { + qWarning("Windows QPA: Invalid foreign window ID %p."); + return nullptr; + } + QWindowsForeignWindow *result = new QWindowsForeignWindow(window, hwnd); const QRect obtainedGeometry = result->geometry(); QScreen *screen = Q_NULLPTR; if (const QPlatformScreen *pScreen = result->screenForGeometry(obtainedGeometry)) diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index e84033f5e4..2c3ffd45d9 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -389,8 +389,13 @@ QVariant QWindowsTheme::themeHint(ThemeHint hint) const return QVariant(booleanSystemParametersInfo(SPI_GETSNAPTODEFBUTTON, false)); case ContextMenuOnMouseRelease: return QVariant(true); - case WheelScrollLines: - return QVariant(int(dWordSystemParametersInfo(SPI_GETWHEELSCROLLLINES, 3))); + case WheelScrollLines: { + int result = 3; + const DWORD scrollLines = dWordSystemParametersInfo(SPI_GETWHEELSCROLLLINES, DWORD(result)); + if (scrollLines != DWORD(-1)) // Special value meaning "scroll one screen", unimplemented in Qt. + result = int(scrollLines); + return QVariant(result); + } default: break; } diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 29f0af4621..7289f8de6d 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1504,7 +1504,7 @@ void QWindowsWindow::handleGeometryChange() QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->screen()); } if (testFlag(SynchronousGeometryChangeEvent)) - QWindowSystemInterface::flushWindowSystemEvents(); + QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents); qCDebug(lcQpaEvents) << __FUNCTION__ << this << window() << m_data.geometry; } @@ -1596,7 +1596,7 @@ bool QWindowsWindow::handleWmPaint(HWND hwnd, UINT message, // Our tests depend on it. fireExpose(QRegion(qrectFromRECT(ps.rcPaint)), true); if (!QWindowsContext::instance()->asyncExpose()) - QWindowSystemInterface::flushWindowSystemEvents(); + QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents); EndPaint(hwnd, &ps); return true; @@ -1656,7 +1656,7 @@ void QWindowsWindow::handleWindowStateChange(Qt::WindowState state) switch (state) { case Qt::WindowMinimized: handleHidden(); - QWindowSystemInterface::flushWindowSystemEvents(); // Tell QQuickWindow to stop rendering now. + QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents); // Tell QQuickWindow to stop rendering now. break; case Qt::WindowMaximized: case Qt::WindowFullScreen: @@ -1679,7 +1679,7 @@ void QWindowsWindow::handleWindowStateChange(Qt::WindowState state) } } if (exposeEventsSent && !QWindowsContext::instance()->asyncExpose()) - QWindowSystemInterface::flushWindowSystemEvents(); + QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents); } break; default: @@ -1769,7 +1769,7 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState) if (!wasSync) clearFlag(SynchronousGeometryChangeEvent); QWindowSystemInterface::handleGeometryChange(window(), r); - QWindowSystemInterface::flushWindowSystemEvents(); + QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents); } else if (newState != Qt::WindowMinimized) { // Restore saved state. unsigned newStyle = m_savedStyle ? m_savedStyle : style(); diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index c5cc2cd790..10c8c8a2d8 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -2195,8 +2195,11 @@ void QXcbWindow::handleButtonPressEvent(int event_x, int event_y, int root_x, in const bool isWheel = detail >= 4 && detail <= 7; if (!isWheel && window() != QGuiApplication::focusWindow()) { QWindow *w = static_cast<QWindowPrivate *>(QObjectPrivate::get(window()))->eventReceiver(); - if (!(w->flags() & Qt::WindowDoesNotAcceptFocus)) + if (!(w->flags() & (Qt::WindowDoesNotAcceptFocus | Qt::BypassWindowManagerHint)) + && w->type() != Qt::ToolTip + && w->type() != Qt::Popup) { w->requestActivate(); + } } updateNetWmUserTime(timestamp); |