diff options
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm | 2 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview.mm | 9 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiosinputcontext.h | 1 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiosmenu.mm | 1 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiostextresponder.mm | 11 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbclipboard.cpp | 12 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbclipboard.h | 2 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbcursor.cpp | 24 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.cpp | 22 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.h | 3 |
10 files changed, 66 insertions, 21 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm index 5f54110777..5c27cf8059 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm @@ -348,7 +348,7 @@ static inline void qt_mac_waitForMoreEvents(NSString *runLoopMode = NSDefaultRun bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) { Q_D(QCocoaEventDispatcher); - d->interrupt = false; + QBoolBlocker interruptBlocker(d->interrupt, false); bool interruptLater = false; QtCocoaInterruptDispatcher::cancelInterruptLater(); diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 641be50156..7ac3cafc3c 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -739,7 +739,10 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)handleMouseEvent:(NSEvent *)theEvent { - bool isTabletEvent = [self handleTabletEvent: theEvent]; + // Tablet events may come in via the mouse event handlers, + // check if this is a valid tablet event first. + if ([self handleTabletEvent: theEvent]) + return; QPointF qtWindowPoint; QPointF qtScreenPoint; @@ -768,8 +771,8 @@ static bool _q_dontOverrideCtrlLMB = false; nativeDrag->setLastMouseEvent(theEvent, self); Qt::KeyboardModifiers keyboardModifiers = [QNSView convertKeyModifiers:[theEvent modifierFlags]]; - QWindowSystemInterface::handleMouseEvent(targetView->m_window, timestamp, qtWindowPoint, qtScreenPoint, m_buttons, keyboardModifiers, - isTabletEvent ? Qt::MouseEventSynthesizedByQt : Qt::MouseEventNotSynthesized); + QWindowSystemInterface::handleMouseEvent(targetView->m_window, timestamp, qtWindowPoint, qtScreenPoint, + m_buttons, keyboardModifiers, Qt::MouseEventNotSynthesized); } - (void)handleFrameStrutMouseEvent:(NSEvent *)theEvent diff --git a/src/plugins/platforms/ios/qiosinputcontext.h b/src/plugins/platforms/ios/qiosinputcontext.h index 9fdf021d07..966d1a7e80 100644 --- a/src/plugins/platforms/ios/qiosinputcontext.h +++ b/src/plugins/platforms/ios/qiosinputcontext.h @@ -49,6 +49,7 @@ const char kImePlatformDataInputView[] = "inputView"; const char kImePlatformDataInputAccessoryView[] = "inputAccessoryView"; +const char kImePlatformDataHideShortcutsBar[] = "hideShortcutsBar"; const char kImePlatformDataReturnKeyType[] = "returnKeyType"; @class QIOSLocaleListener; diff --git a/src/plugins/platforms/ios/qiosmenu.mm b/src/plugins/platforms/ios/qiosmenu.mm index 02deab59b5..01cb3badea 100644 --- a/src/plugins/platforms/ios/qiosmenu.mm +++ b/src/plugins/platforms/ios/qiosmenu.mm @@ -521,6 +521,7 @@ bool QIOSMenu::eventFilter(QObject *obj, QEvent *event) QVariantMap imPlatformData = queryEvent->value(Qt::ImPlatformData).toMap(); imPlatformData.insert(kImePlatformDataInputView, QVariant::fromValue(static_cast<void *>(m_pickerView))); imPlatformData.insert(kImePlatformDataInputAccessoryView, QVariant::fromValue(static_cast<void *>(m_pickerView.toolbar))); + imPlatformData.insert(kImePlatformDataHideShortcutsBar, true); queryEvent->setValue(Qt::ImPlatformData, imPlatformData); queryEvent->setValue(Qt::ImEnabled, true); diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm index 3c95083e45..d7b0a323ad 100644 --- a/src/plugins/platforms/ios/qiostextresponder.mm +++ b/src/plugins/platforms/ios/qiostextresponder.mm @@ -236,6 +236,17 @@ self.inputView = [[[WrapperView alloc] initWithView:inputView] autorelease]; if (UIView *accessoryView = static_cast<UIView *>(platformData.value(kImePlatformDataInputAccessoryView).value<void *>())) self.inputAccessoryView = [[[WrapperView alloc] initWithView:accessoryView] autorelease]; + if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_9_0) { + 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]; + } + } self.undoManager.groupsByEvent = NO; [self rebuildUndoStack]; diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp index b95ad4b5c9..f9c32cd0a4 100644 --- a/src/plugins/platforms/xcb/qxcbclipboard.cpp +++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp @@ -275,8 +275,6 @@ QXcbClipboard::QXcbClipboard(QXcbConnection *c) { Q_ASSERT(QClipboard::Clipboard == 0); Q_ASSERT(QClipboard::Selection == 1); - m_xClipboard[QClipboard::Clipboard] = 0; - m_xClipboard[QClipboard::Selection] = 0; m_clientClipboard[QClipboard::Clipboard] = 0; m_clientClipboard[QClipboard::Selection] = 0; m_timestamp[QClipboard::Clipboard] = XCB_CURRENT_TIME; @@ -329,6 +327,10 @@ QXcbClipboard::~QXcbClipboard() } free(reply); } + + if (m_clientClipboard[QClipboard::Clipboard] != m_clientClipboard[QClipboard::Selection]) + delete m_clientClipboard[QClipboard::Clipboard]; + delete m_clientClipboard[QClipboard::Selection]; } void QXcbClipboard::incrTransactionPeeker(xcb_generic_event_t *ge, bool &accepted) @@ -378,9 +380,9 @@ QMimeData * QXcbClipboard::mimeData(QClipboard::Mode mode) return m_clientClipboard[mode]; } else { if (!m_xClipboard[mode]) - m_xClipboard[mode] = new QXcbClipboardMime(mode, this); + m_xClipboard[mode].reset(new QXcbClipboardMime(mode, this)); - return m_xClipboard[mode]; + return m_xClipboard[mode].data(); } } @@ -730,7 +732,7 @@ void QXcbClipboard::handleXFixesSelectionRequest(xcb_xfixes_selection_notify_eve // here we care only about the xfixes events that come from non Qt processes if (event->owner != XCB_NONE && event->owner != owner()) { if (!m_xClipboard[mode]) { - m_xClipboard[mode] = new QXcbClipboardMime(mode, this); + m_xClipboard[mode].reset(new QXcbClipboardMime(mode, this)); } else { m_xClipboard[mode]->reset(); } diff --git a/src/plugins/platforms/xcb/qxcbclipboard.h b/src/plugins/platforms/xcb/qxcbclipboard.h index 58c7f32c4c..ffd565c56f 100644 --- a/src/plugins/platforms/xcb/qxcbclipboard.h +++ b/src/plugins/platforms/xcb/qxcbclipboard.h @@ -98,7 +98,7 @@ private: QClipboard::Mode modeForAtom(xcb_atom_t atom) const; // Selection and Clipboard - QXcbClipboardMime *m_xClipboard[2]; + QScopedPointer<QXcbClipboardMime> m_xClipboard[2]; QMimeData *m_clientClipboard[2]; xcb_timestamp_t m_timestamp[2]; diff --git a/src/plugins/platforms/xcb/qxcbcursor.cpp b/src/plugins/platforms/xcb/qxcbcursor.cpp index 11e0c998b1..4de4be43d1 100644 --- a/src/plugins/platforms/xcb/qxcbcursor.cpp +++ b/src/plugins/platforms/xcb/qxcbcursor.cpp @@ -359,17 +359,27 @@ void QXcbCursor::changeCursor(QCursor *cursor, QWindow *widget) return; xcb_cursor_t c = XCB_CURSOR_NONE; + bool isBitmapCursor = false; + if (cursor) { - const QXcbCursorCacheKey key(*cursor); - CursorHash::iterator it = m_cursorHash.find(key); - if (it == m_cursorHash.end()) { - const Qt::CursorShape shape = cursor->shape(); - it = m_cursorHash.insert(key, shape == Qt::BitmapCursor ? createBitmapCursor(cursor) : createFontCursor(shape)); + const Qt::CursorShape shape = cursor->shape(); + isBitmapCursor = shape == Qt::BitmapCursor; + + if (!isBitmapCursor) { + const QXcbCursorCacheKey key(*cursor); + CursorHash::iterator it = m_cursorHash.find(key); + if (it == m_cursorHash.end()) { + it = m_cursorHash.insert(key, createFontCursor(shape)); + } + c = it.value(); + } else { + // Do not cache bitmap cursors, as otherwise they have unclear + // lifetime (we effectively leak xcb_cursor_t). + c = createBitmapCursor(cursor); } - c = it.value(); } - w->setCursor(c); + w->setCursor(c, isBitmapCursor); } static int cursorIdForShape(int cshape) diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index c703fbef22..d22ea00d8a 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -326,6 +326,7 @@ QXcbWindow::QXcbWindow(QWindow *window) , m_lastWindowStateEvent(-1) , m_syncState(NoSyncNeeded) , m_pendingSyncRequest(0) + , m_currentBitmapCursor(XCB_CURSOR_NONE) { setConnection(xcbScreen()->connection()); } @@ -600,6 +601,9 @@ void QXcbWindow::create() QXcbWindow::~QXcbWindow() { + if (m_currentBitmapCursor != XCB_CURSOR_NONE) { + xcb_free_cursor(xcb_connection(), m_currentBitmapCursor); + } if (window()->type() != Qt::ForeignWindow) destroy(); else { @@ -2679,10 +2683,22 @@ bool QXcbWindow::setMouseGrabEnabled(bool grab) return result; } -void QXcbWindow::setCursor(xcb_cursor_t cursor) +void QXcbWindow::setCursor(xcb_cursor_t cursor, bool isBitmapCursor) { - xcb_change_window_attributes(xcb_connection(), m_window, XCB_CW_CURSOR, &cursor); - xcb_flush(xcb_connection()); + xcb_connection_t *conn = xcb_connection(); + + xcb_change_window_attributes(conn, m_window, XCB_CW_CURSOR, &cursor); + xcb_flush(conn); + + if (m_currentBitmapCursor != XCB_CURSOR_NONE) { + xcb_free_cursor(conn, m_currentBitmapCursor); + } + + if (isBitmapCursor) { + m_currentBitmapCursor = cursor; + } else { + m_currentBitmapCursor = XCB_CURSOR_NONE; + } } void QXcbWindow::windowEvent(QEvent *event) diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index 41dccbe4af..92f3f7a67c 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -103,7 +103,7 @@ public: bool setKeyboardGrabEnabled(bool grab) Q_DECL_OVERRIDE; bool setMouseGrabEnabled(bool grab) Q_DECL_OVERRIDE; - void setCursor(xcb_cursor_t cursor); + void setCursor(xcb_cursor_t cursor, bool isBitmapCursor); QSurfaceFormat format() const Q_DECL_OVERRIDE; @@ -272,6 +272,7 @@ protected: SyncState m_syncState; QXcbSyncWindowRequest *m_pendingSyncRequest; + xcb_cursor_t m_currentBitmapCursor; }; QT_END_NAMESPACE |