diff options
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/android/androidjniclipboard.cpp | 23 | ||||
-rw-r--r-- | src/plugins/platforms/android/androidjniclipboard.h | 5 | ||||
-rw-r--r-- | src/plugins/platforms/android/qandroidplatformclipboard.cpp | 2 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoawindow.mm | 12 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview.mm | 60 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiostextresponder.mm | 11 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowswindow.cpp | 27 |
7 files changed, 91 insertions, 49 deletions
diff --git a/src/plugins/platforms/android/androidjniclipboard.cpp b/src/plugins/platforms/android/androidjniclipboard.cpp index 17ff0e0bbb..833996403c 100644 --- a/src/plugins/platforms/android/androidjniclipboard.cpp +++ b/src/plugins/platforms/android/androidjniclipboard.cpp @@ -38,7 +38,6 @@ ****************************************************************************/ #include "androidjniclipboard.h" -#include "androidjnimain.h" #include <QtCore/private/qjni_p.h> QT_BEGIN_NAMESPACE @@ -46,10 +45,23 @@ QT_BEGIN_NAMESPACE using namespace QtAndroid; namespace QtAndroidClipboard { - void setClipboardListener(QAndroidPlatformClipboard *listener) + QAndroidPlatformClipboard *m_manager = nullptr; + + static char const *const QtNativeClassName = "org/qtproject/qt5/android/QtNative"; + static JNINativeMethod methods[] = { + {"onClipboardDataChanged", "()V", (void *)onClipboardDataChanged} + }; + + void setClipboardManager(QAndroidPlatformClipboard *manager) { - Q_UNUSED(listener); + m_manager = manager; QJNIObjectPrivate::callStaticMethod<void>(applicationClass(), "registerClipboardManager"); + jclass appClass = QtAndroid::applicationClass(); + QJNIEnvironmentPrivate env; + if (env->RegisterNatives(appClass, methods, sizeof(methods) / sizeof(methods[0])) < 0) { + __android_log_print(ANDROID_LOG_FATAL,"Qt", "RegisterNatives failed"); + return; + } } void setClipboardText(const QString &text) @@ -73,6 +85,11 @@ namespace QtAndroidClipboard "()Ljava/lang/String;"); return text.toString(); } + + void onClipboardDataChanged(JNIEnv */*env*/, jobject /*thiz*/) + { + m_manager->emitChanged(QClipboard::Clipboard); + } } QT_END_NAMESPACE diff --git a/src/plugins/platforms/android/androidjniclipboard.h b/src/plugins/platforms/android/androidjniclipboard.h index 9de6dc1f44..2ec566e729 100644 --- a/src/plugins/platforms/android/androidjniclipboard.h +++ b/src/plugins/platforms/android/androidjniclipboard.h @@ -41,6 +41,8 @@ #define ANDROIDJNICLIPBOARD_H #include <QString> +#include "qandroidplatformclipboard.h" +#include "androidjnimain.h" QT_BEGIN_NAMESPACE @@ -48,10 +50,11 @@ class QAndroidPlatformClipboard; namespace QtAndroidClipboard { // Clipboard support - void setClipboardListener(QAndroidPlatformClipboard *listener); + void setClipboardManager(QAndroidPlatformClipboard *manager); void setClipboardText(const QString &text); bool hasClipboardText(); QString clipboardText(); + void onClipboardDataChanged(JNIEnv */*env*/, jobject /*thiz*/); // Clipboard support } diff --git a/src/plugins/platforms/android/qandroidplatformclipboard.cpp b/src/plugins/platforms/android/qandroidplatformclipboard.cpp index a2bc802680..dc5147b259 100644 --- a/src/plugins/platforms/android/qandroidplatformclipboard.cpp +++ b/src/plugins/platforms/android/qandroidplatformclipboard.cpp @@ -45,7 +45,7 @@ QT_BEGIN_NAMESPACE QAndroidPlatformClipboard::QAndroidPlatformClipboard() { - QtAndroidClipboard::setClipboardListener(this); + QtAndroidClipboard::setClipboardManager(this); } QMimeData *QAndroidPlatformClipboard::mimeData(QClipboard::Mode mode) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index b85fb97f67..5ff5d01a99 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -291,6 +291,8 @@ static void qt_closePopups() - (void)closeAndRelease { + qCDebug(lcQpaCocoaWindow) << "closeAndRelease" << self; + [self close]; if (self.helper.grabbingMouse) { @@ -361,6 +363,8 @@ static void qt_closePopups() - (void)closeAndRelease { + qCDebug(lcQpaCocoaWindow) << "closeAndRelease" << self; + [self.helper detachFromPlatformWindow]; [self close]; [self release]; @@ -1584,7 +1588,7 @@ void QCocoaWindow::recreateWindowIfNeeded() if (isChildNSWindow() != shouldBeChildNSWindow) recreateReason |= ChildNSWindowChanged; - const bool shouldBeContentView = !parentWindow || shouldBeChildNSWindow; + const bool shouldBeContentView = (!parentWindow && !m_viewIsEmbedded) || shouldBeChildNSWindow; if (isContentView() != shouldBeContentView) recreateReason |= ContentViewChanged; @@ -1601,7 +1605,7 @@ void QCocoaWindow::recreateWindowIfNeeded() return; } - qCDebug(lcQpaCocoaWindow) << "Recreating NSWindow due to" << recreateReason; + qCDebug(lcQpaCocoaWindow) << "Reconfiguring NSWindow due to" << recreateReason; QCocoaWindow *parentCocoaWindow = static_cast<QCocoaWindow *>(parentWindow); @@ -1616,6 +1620,7 @@ void QCocoaWindow::recreateWindowIfNeeded() // Remove current window (if any) if ((isContentView() && !shouldBeContentView) || (recreateReason & PanelChanged)) { + qCDebug(lcQpaCocoaWindow) << "Getting rid of existing window" << m_nsWindow; [m_nsWindow closeAndRelease]; if (isChildNSWindow()) [m_view.window.parentWindow removeChildWindow:m_view.window]; @@ -1642,6 +1647,7 @@ void QCocoaWindow::recreateWindowIfNeeded() // Move view to new NSWindow if needed if (m_nsWindow.contentView != m_view) { + qCDebug(lcQpaCocoaWindow) << "Ensuring that view is content view for" << m_nsWindow; [m_view setPostsFrameChangedNotifications:NO]; [m_view retain]; if (m_view.superview) // m_view comes from another NSWindow @@ -1723,6 +1729,8 @@ void QCocoaWindow::requestActivateWindow() QCocoaNSWindow *QCocoaWindow::createNSWindow(bool shouldBeChildNSWindow, bool shouldBePanel) { + qCDebug(lcQpaCocoaWindow) << "createNSWindow" << shouldBeChildNSWindow << shouldBePanel; + QMacAutoReleasePool pool; QRect rect = geometry(); diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 6494dd3386..72e90a5363 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -237,7 +237,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)viewDidMoveToSuperview { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; if (!(m_platformWindow->m_viewIsToBeEmbedded)) @@ -260,7 +260,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (QWindow *)topLevelWindow { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return nullptr; QWindow *focusWindow = m_platformWindow->window(); @@ -278,7 +278,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)updateGeometry { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; QRect geometry; @@ -437,8 +437,11 @@ static bool _q_dontOverrideCtrlLMB = false; } } -- (void) drawRect:(NSRect)dirtyRect +- (void)drawRect:(NSRect)dirtyRect { + if (!m_platformWindow) + return; + qCDebug(lcQpaCocoaWindow) << "[QNSView drawRect:]" << m_platformWindow->window() << QRectF::fromCGRect(NSRectToCGRect(dirtyRect)); #ifndef QT_NO_OPENGL @@ -627,7 +630,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)handleMouseEvent:(NSEvent *)theEvent { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; // Tablet events may come in via the mouse event handlers, @@ -644,7 +647,7 @@ static bool _q_dontOverrideCtrlLMB = false; else m_platformWindow->m_forwardWindow.clear(); } - if (targetView->m_platformWindow.isNull()) + if (!targetView.platformWindow) return; // Popups implicitly grap mouse events; forward to the active popup if there is one @@ -670,7 +673,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)handleFrameStrutMouseEvent:(NSEvent *)theEvent { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; // get m_buttons in sync @@ -955,7 +958,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)mouseMovedImpl:(NSEvent *)theEvent { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; if ([self isTransparentForUserInput]) @@ -989,7 +992,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)mouseEnteredImpl:(NSEvent *)theEvent { Q_UNUSED(theEvent) - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; m_platformWindow->m_windowUnderMouse = true; @@ -1011,7 +1014,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)mouseExitedImpl:(NSEvent *)theEvent { Q_UNUSED(theEvent); - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; m_platformWindow->m_windowUnderMouse = false; @@ -1040,7 +1043,7 @@ Q_GLOBAL_STATIC(QCocoaTabletDeviceDataHash, tabletDeviceDataHash) - (bool)handleTabletEvent: (NSEvent *)theEvent { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return false; NSEventType eventType = [theEvent type]; @@ -1200,7 +1203,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (bool)shouldSendSingleTouch { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return true; // QtWidgets expects single-point touch events, QtDeclarative does not. @@ -1210,7 +1213,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)touchesBeganWithEvent:(NSEvent *)event { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; const NSTimeInterval timestamp = [event timestamp]; @@ -1221,7 +1224,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)touchesMovedWithEvent:(NSEvent *)event { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; const NSTimeInterval timestamp = [event timestamp]; @@ -1232,7 +1235,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)touchesEndedWithEvent:(NSEvent *)event { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; const NSTimeInterval timestamp = [event timestamp]; @@ -1243,7 +1246,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)touchesCancelledWithEvent:(NSEvent *)event { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; const NSTimeInterval timestamp = [event timestamp]; @@ -1273,7 +1276,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) } - (void)magnifyWithEvent:(NSEvent *)event { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; if ([self handleGestureAsBeginEnd:event]) @@ -1290,7 +1293,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)smartMagnifyWithEvent:(NSEvent *)event { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; static bool zoomIn = true; @@ -1306,7 +1309,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)rotateWithEvent:(NSEvent *)event { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; if ([self handleGestureAsBeginEnd:event]) @@ -1322,7 +1325,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)swipeWithEvent:(NSEvent *)event { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; qCDebug(lcQpaGestures) << "swipeWithEvent" << [event deltaX] << [event deltaY]; @@ -1347,7 +1350,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)beginGestureWithEvent:(NSEvent *)event { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; const NSTimeInterval timestamp = [event timestamp]; @@ -1361,7 +1364,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)endGestureWithEvent:(NSEvent *)event { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; qCDebug(lcQpaGestures) << "endGestureWithEvent"; @@ -1377,7 +1380,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) #ifndef QT_NO_WHEELEVENT - (void)scrollWheel:(NSEvent *)theEvent { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; if ([self isTransparentForUserInput]) @@ -1879,6 +1882,9 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (NSArray*)validAttributesForMarkedText { + if (!m_platformWindow) + return nil; + if (m_platformWindow->window() != QGuiApplication::focusWindow()) return nil; @@ -2050,7 +2056,7 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin // Sends drag update to Qt, return the action - (NSDragOperation)handleDrag:(id <NSDraggingInfo>)sender { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return NSDragOperationNone; NSPoint windowPoint = [self convertPoint: [sender draggingLocation] fromView: nil]; @@ -2080,7 +2086,7 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin - (void)draggingExited:(id <NSDraggingInfo>)sender { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; QWindow *target = findEventTargetWindow(m_platformWindow->window()); @@ -2097,7 +2103,7 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin // called on drop, send the drop to Qt and return if it was accepted. - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender { - if (m_platformWindow.isNull()) + if (!m_platformWindow) return false; QWindow *target = findEventTargetWindow(m_platformWindow->window()); @@ -2131,7 +2137,7 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin Q_UNUSED(session); Q_UNUSED(operation); - if (m_platformWindow.isNull()) + if (!m_platformWindow) return; QWindow *target = findEventTargetWindow(m_platformWindow->window()); diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm index eab6792266..001985a128 100644 --- a/src/plugins/platforms/ios/qiostextresponder.mm +++ b/src/plugins/platforms/ios/qiostextresponder.mm @@ -242,11 +242,12 @@ if (platformData.value(kImePlatformDataHideShortcutsBar).toBool()) { // According to the docs, leadingBarButtonGroups/trailingBarButtonGroups should be set to nil to hide the shortcuts bar. // However, starting with iOS 10, the API has been surrounded with NS_ASSUME_NONNULL, which contradicts this and causes - // compiler warnings. And assigning just an empty array causes layout asserts. Hence, we assign empty button groups instead. - UIBarButtonItemGroup *leading = [[[UIBarButtonItemGroup alloc] initWithBarButtonItems:@[] representativeItem:nil] autorelease]; - UIBarButtonItemGroup *trailing = [[[UIBarButtonItemGroup alloc] initWithBarButtonItems:@[] representativeItem:nil] autorelease]; - self.inputAssistantItem.leadingBarButtonGroups = @[leading]; - self.inputAssistantItem.trailingBarButtonGroups = @[trailing]; + // compiler warnings. Still it is the way to go to really hide the space reserved for that. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnonnull" + self.inputAssistantItem.leadingBarButtonGroups = nil; + self.inputAssistantItem.trailingBarButtonGroups = nil; +#pragma clang diagnostic pop } } #endif diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 2875463e62..077511d4e1 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -870,13 +870,15 @@ void QWindowsBaseWindow::hide_sys() // Normal hide, do not activate other window void QWindowsBaseWindow::raise_sys() { qCDebug(lcQpaWindows) << __FUNCTION__ << this << window(); - SetWindowPos(handle(), HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); + if ((window()->flags() & (Qt::WindowStaysOnTopHint | Qt::WindowStaysOnBottomHint)) == 0) + SetWindowPos(handle(), HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); } void QWindowsBaseWindow::lower_sys() { qCDebug(lcQpaWindows) << __FUNCTION__ << this << window(); - SetWindowPos(handle(), HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); + if ((window()->flags() & (Qt::WindowStaysOnTopHint | Qt::WindowStaysOnBottomHint)) == 0) + SetWindowPos(handle(), HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); } void QWindowsBaseWindow::setWindowTitle_sys(const QString &title) @@ -1616,6 +1618,16 @@ static inline bool dwmIsCompositionEnabled() return SUCCEEDED(DwmIsCompositionEnabled(&dWmCompositionEnabled)) && dWmCompositionEnabled == TRUE; } +static inline bool isSoftwareGl() +{ +#if QT_CONFIG(dynamicgl) + return QOpenGLStaticContext::opengl32.moduleIsNotOpengl32() + && QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL; +#else + return false; +#endif // dynamicgl +} + bool QWindowsWindow::handleWmPaint(HWND hwnd, UINT message, WPARAM, LPARAM) { @@ -1627,15 +1639,10 @@ bool QWindowsWindow::handleWmPaint(HWND hwnd, UINT message, return false; PAINTSTRUCT ps; -#if QT_CONFIG(dynamicgl) - // QTBUG-58178: GL software rendering needs InvalidateRect() to suppress - // artifacts while resizing. - if (testFlag(OpenGLSurface) - && QOpenGLStaticContext::opengl32.moduleIsNotOpengl32() - && QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) { + // GL software rendering (QTBUG-58178) and Windows 7/Aero off with some AMD cards + // (QTBUG-60527) need InvalidateRect() to suppress artifacts while resizing. + if (testFlag(OpenGLSurface) && (isSoftwareGl() || !dwmIsCompositionEnabled())) InvalidateRect(hwnd, 0, false); - } -#endif // dynamicgl BeginPaint(hwnd, &ps); |