diff options
Diffstat (limited to 'src/plugins/platforms/cocoa/qnsview.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview.mm | 95 |
1 files changed, 52 insertions, 43 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index e76c02704f..a8372f754f 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -144,29 +144,40 @@ static QTouchDevice *touchDevice = 0; QWindowSystemInterface::handleSynchronousGeometryChange(m_window, geo); } -- (void)windowDidBecomeKey -{ - if (!m_platformWindow->windowIsPopupType()) - QWindowSystemInterface::handleWindowActivated(m_window); -} - -- (void)windowDidResignKey -{ - if (!m_platformWindow->windowIsPopupType()) - QWindowSystemInterface::handleWindowActivated(0); -} +- (void)windowNotification : (NSNotification *) windowNotification +{ + //qDebug() << "windowNotification" << QCFString::toQString([windowNotification name]); + + NSString *notificationName = [windowNotification name]; + if (notificationName == NSWindowDidBecomeKeyNotification) { + if (!m_platformWindow->windowIsPopupType()) + QWindowSystemInterface::handleWindowActivated(m_window); + } else if (notificationName == NSWindowDidResignKeyNotification) { + if (!m_platformWindow->windowIsPopupType()) + QWindowSystemInterface::handleWindowActivated(0); + } else if (notificationName == NSWindowDidMiniaturizeNotification) { + QWindowSystemInterface::handleWindowStateChanged(m_window, Qt::WindowMinimized); + } else if (notificationName == NSWindowDidDeminiaturizeNotification) { + QWindowSystemInterface::handleWindowStateChanged(m_window, Qt::WindowNoState); + // Qt expects an expose event after restore/deminiaturize. This also needs + // to be a non-synchronous event to make sure it gets processed after + // the state change event sent above. + QWindowSystemInterface::handleExposeEvent(m_window, QRegion(m_window->geometry())); + } else { -- (void)windowDidBecomeMain -{ -// qDebug() << "window did become main" << m_window; -} +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 + if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) { + if (notificationName == NSWindowDidEnterFullScreenNotification) { + QWindowSystemInterface::handleWindowStateChanged(m_window, Qt::WindowFullScreen); + } else if (notificationName == NSWindowDidExitFullScreenNotification) { + QWindowSystemInterface::handleWindowStateChanged(m_window, Qt::WindowNoState); + } + } +#endif -- (void)windowDidResignMain -{ -// qDebug() << "window did resign main" << m_window; + } } - - (void) setImage:(QImage *)image { CGImageRelease(m_cgImage); @@ -681,8 +692,9 @@ static QTouchDevice *touchDevice = 0; [self tryToPerform:aSelector with:self]; } -- (void) insertText:(id)aString +- (void) insertText:(id)aString replacementRange:(NSRange)replacementRange { + Q_UNUSED(replacementRange) QString commitString; if ([aString length]) { if ([aString isKindOfClass:[NSAttributedString class]]) { @@ -707,12 +719,13 @@ static QTouchDevice *touchDevice = 0; m_composingText.clear(); } -- (void) setMarkedText:(id)aString selectedRange:(NSRange)selRange +- (void) setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replacementRange:(NSRange)replacementRange { + Q_UNUSED(replacementRange) QString preeditString; QList<QInputMethodEvent::Attribute> attrs; - attrs<<QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, selRange.location + selRange.length, 1, QVariant()); + attrs<<QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, selectedRange.location + selectedRange.length, 1, QVariant()); if ([aString isKindOfClass:[NSAttributedString class]]) { // Preedit string has attribution @@ -793,13 +806,9 @@ static QTouchDevice *touchDevice = 0; return (m_composingText.isEmpty() ? NO: YES); } -- (NSInteger) conversationIdentifier -{ - return (NSInteger)self; -} - -- (NSAttributedString *) attributedSubstringFromRange:(NSRange)theRange +- (NSAttributedString *) attributedSubstringForProposedRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange { + Q_UNUSED(actualRange) QObject *fo = QGuiApplication::focusObject(); if (!fo) return nil; @@ -813,7 +822,7 @@ static QTouchDevice *touchDevice = 0; if (selectedText.isEmpty()) return nil; - QCFString string(selectedText.mid(theRange.location, theRange.length)); + QCFString string(selectedText.mid(aRange.location, aRange.length)); const NSString *tmpString = reinterpret_cast<const NSString *>((CFStringRef)string); return [[[NSAttributedString alloc] initWithString:const_cast<NSString *>(tmpString)] autorelease]; } @@ -831,34 +840,34 @@ static QTouchDevice *touchDevice = 0; return range; } - - (NSRange) selectedRange { - NSRange selRange = {NSNotFound, 0}; - selRange.location = NSNotFound; - selRange.length = 0; + NSRange selectedRange = {NSNotFound, 0}; + selectedRange.location = NSNotFound; + selectedRange.length = 0; QObject *fo = QGuiApplication::focusObject(); if (!fo) - return selRange; + return selectedRange; QInputMethodQueryEvent queryEvent(Qt::ImEnabled | Qt::ImCurrentSelection); if (!QCoreApplication::sendEvent(fo, &queryEvent)) - return selRange; + return selectedRange; if (!queryEvent.value(Qt::ImEnabled).toBool()) - return selRange; + return selectedRange; QString selectedText = queryEvent.value(Qt::ImCurrentSelection).toString(); if (!selectedText.isEmpty()) { - selRange.location = 0; - selRange.length = selectedText.length(); + selectedRange.location = 0; + selectedRange.length = selectedText.length(); } - return selRange; + return selectedRange; } -- (NSRect) firstRectForCharacterRange:(NSRange)theRange +- (NSRect) firstRectForCharacterRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange { - Q_UNUSED(theRange); + Q_UNUSED(aRange) + Q_UNUSED(actualRange) QObject *fo = QGuiApplication::focusObject(); if (!fo) return NSZeroRect; @@ -884,10 +893,10 @@ static QTouchDevice *touchDevice = 0; return rect; } -- (NSUInteger)characterIndexForPoint:(NSPoint)thePoint +- (NSUInteger)characterIndexForPoint:(NSPoint)aPoint { // We dont support cursor movements using mouse while composing. - Q_UNUSED(thePoint); + Q_UNUSED(aPoint); return NSNotFound; } |