From b2a0a1437000c6cd78de4bf960993732457a8e92 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Tue, 28 May 2013 13:09:20 +0200 Subject: Fix issue when QKeyEvent::text() was returning empty string MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The code that sets 'text' variable was executed only for KeyPress events. This patch moves 'text' initialization higher up where it will be run for both - KeyPress and KeyRelease events. Task-number: QTBUG-31285 Change-Id: I140de9ef5d29beedad276d348bed964ecdf46f9d Reviewed-by: Tor Arne Vestbø Reviewed-by: Andy Shaw --- src/plugins/platforms/cocoa/qnsview.mm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 5c5da830ac..10fb293ec0 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -917,13 +917,13 @@ static QTouchDevice *touchDevice = 0; // we will send a key event unless the input method sets m_sendKeyEvent to false m_sendKeyEvent = true; - QString text; + // ignore text for the U+F700-U+F8FF range. This is used by Cocoa when + // delivering function keys (e.g. arrow keys, backspace, F1-F35, etc.) + if (ch.unicode() < 0xf700 || ch.unicode() > 0xf8ff) + text = QCFString::toQString(characters); + if (eventType == QEvent::KeyPress) { - // ignore text for the U+F700-U+F8FF range. This is used by Cocoa when - // delivering function keys (e.g. arrow keys, backspace, F1-F35, etc.) - if (ch.unicode() < 0xf700 || ch.unicode() > 0xf8ff) - text = QCFString::toQString(characters); if (m_composingText.isEmpty()) m_sendKeyEvent = !QWindowSystemInterface::tryHandleShortcutEvent(m_window, timestamp, keyCode, modifiers, text); -- cgit v1.2.3 From 3b5954e405cfbc3dcf1564d0e9e397825c5c1e5a Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 3 Jun 2013 18:28:03 +0200 Subject: Cocoa: Remove compilation warning Change-Id: Ib530e7ef4643de07aec91c4af0de8bbedef9882a Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm | 1 + 1 file changed, 1 insertion(+) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm index c40ae3d81d..3ec6ad7a20 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm @@ -113,6 +113,7 @@ static void cleanupCocoaApplicationDelegate() - (void)updateScreens:(NSNotification *)notification { + Q_UNUSED(notification); if (QCocoaIntegration *ci = dynamic_cast(QGuiApplicationPrivate::platformIntegration())) ci->updateScreens(); } -- cgit v1.2.3 From 7ee15bfbb815df87ae0526f105a13a591b192c76 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 3 Jun 2013 18:29:56 +0200 Subject: Cocoa: Make sure we update internal window fullscreen state We update the internal/synched state by assigning it its QWindow's state. Since that one is not a flag, it can only be in one state at a time, meaning that we may lose the maximized state (but we've been losing it for some time). Task-number: QTBUG-30139 Change-Id: Idf30713c6ae912cafe3bbdd7be18214cf4de34f7 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/cocoa/qcocoawindow.h | 2 ++ src/plugins/platforms/cocoa/qcocoawindow.mm | 6 ++++++ src/plugins/platforms/cocoa/qnsview.mm | 13 +++++++++---- 3 files changed, 17 insertions(+), 4 deletions(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 91eaea21b6..b82d096bb5 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -136,6 +136,8 @@ public: bool windowShouldClose(); bool windowIsPopupType(Qt::WindowType type = Qt::Widget) const; + void setSynchedWindowStateFromWindow(); + NSInteger windowLevel(Qt::WindowFlags flags); NSUInteger windowStyleMask(Qt::WindowFlags flags); void setWindowShadow(Qt::WindowFlags flags); diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index f8d0eafcb3..d9043979d6 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -725,6 +725,12 @@ bool QCocoaWindow::windowShouldClose() return accepted; } +void QCocoaWindow::setSynchedWindowStateFromWindow() +{ + if (QWindow *w = window()) + m_synchedWindowState = w->windowState(); +} + bool QCocoaWindow::windowIsPopupType(Qt::WindowType type) const { if (type == Qt::Widget) diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 10fb293ec0..529a0ccfe7 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -290,10 +290,15 @@ static QTouchDevice *touchDevice = 0; #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); + if (notificationName == NSWindowDidEnterFullScreenNotification + || notificationName == NSWindowDidExitFullScreenNotification) { + Qt::WindowState newState = notificationName == NSWindowDidEnterFullScreenNotification ? + Qt::WindowFullScreen : Qt::WindowNoState; + QWindowSystemInterface::handleWindowStateChanged(m_window, newState); + // We want to read the window state back from the window, + // but the event we just sent may be asynchronous. + QWindowSystemInterface::flushWindowSystemEvents(); + m_platformWindow->setSynchedWindowStateFromWindow(); } } #endif -- cgit v1.2.3 From b8c007ede01360594ec5399532f2229e82715cc3 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 3 Jun 2013 18:33:03 +0200 Subject: Cocoa: Update window state when maximizing from the title bar There's no NSWindow notification we can listen to, but we can override behavior from its delegate. Change-Id: I61cebf4119f83c770fe4e7f45ff0d4e8bf9d0df9 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/cocoa/qnsview.h | 1 + src/plugins/platforms/cocoa/qnsview.mm | 10 ++++++++++ src/plugins/platforms/cocoa/qnswindowdelegate.h | 1 + src/plugins/platforms/cocoa/qnswindowdelegate.mm | 8 ++++++++ 4 files changed, 20 insertions(+) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index 85f72a4dbb..d28e38886b 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -82,6 +82,7 @@ QT_END_NAMESPACE - (void)drawRect:(NSRect)dirtyRect; - (void)updateGeometry; - (void)windowNotification : (NSNotification *) windowNotification; +- (void)notifyWindowWillZoom:(BOOL)willZoom; - (void)viewDidHide; - (void)viewDidUnhide; diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 529a0ccfe7..ec53fc6a7e 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -306,6 +306,16 @@ static QTouchDevice *touchDevice = 0; } } +- (void)notifyWindowWillZoom:(BOOL)willZoom +{ + Qt::WindowState newState = willZoom ? Qt::WindowMaximized : Qt::WindowNoState; + QWindowSystemInterface::handleWindowStateChanged(m_window, newState); + // We want to read the window state back from the window, + // but the event we just sent may be asynchronous. + QWindowSystemInterface::flushWindowSystemEvents(); + m_platformWindow->setSynchedWindowStateFromWindow(); +} + - (void)viewDidHide { m_platformWindow->obscureWindow(); diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.h b/src/plugins/platforms/cocoa/qnswindowdelegate.h index 9a616ba8e8..06e11fffbb 100644 --- a/src/plugins/platforms/cocoa/qnswindowdelegate.h +++ b/src/plugins/platforms/cocoa/qnswindowdelegate.h @@ -57,6 +57,7 @@ - (void)windowDidMove:(NSNotification *)notification; - (void)windowWillMove:(NSNotification *)notification; - (BOOL)windowShouldClose:(NSNotification *)notification; +- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame; @end diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.mm b/src/plugins/platforms/cocoa/qnswindowdelegate.mm index 8e17936a78..10536bd5f4 100644 --- a/src/plugins/platforms/cocoa/qnswindowdelegate.mm +++ b/src/plugins/platforms/cocoa/qnswindowdelegate.mm @@ -90,4 +90,12 @@ return YES; } +- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame +{ + Q_UNUSED(newFrame); + if (m_cocoaWindow && m_cocoaWindow->m_qtView) + [m_cocoaWindow->m_qtView notifyWindowWillZoom:![window isZoomed]]; + return YES; +} + @end -- cgit v1.2.3 From bfab741cb7ed24d2decfab4cffdcdbf14f6317ca Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 4 Jun 2013 13:54:07 +0200 Subject: Cocoa: Make sure internal minimized state is up to date Refactors some code from previous changes addressing the same issue for maximized and fullscreen states. Change-Id: I8a27274a90e6610b424ea7af3269369a1d724c48 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/cocoa/qnsview.h | 1 + src/plugins/platforms/cocoa/qnsview.mm | 30 ++++++++++++++++-------------- 2 files changed, 17 insertions(+), 14 deletions(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index d28e38886b..92215b9e67 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -81,6 +81,7 @@ QT_END_NAMESPACE - (void)invalidateWindowShadowIfNeeded; - (void)drawRect:(NSRect)dirtyRect; - (void)updateGeometry; +- (void)notifyWindowStateChanged:(Qt::WindowState)newState; - (void)windowNotification : (NSNotification *) windowNotification; - (void)notifyWindowWillZoom:(BOOL)willZoom; - (void)viewDidHide; diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index ec53fc6a7e..ab3f495a60 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -251,6 +251,15 @@ static QTouchDevice *touchDevice = 0; } } +- (void)notifyWindowStateChanged:(Qt::WindowState)newState +{ + QWindowSystemInterface::handleWindowStateChanged(m_window, newState); + // We want to read the window state back from the window, + // but the event we just sent may be asynchronous. + QWindowSystemInterface::flushWindowSystemEvents(); + m_platformWindow->setSynchedWindowStateFromWindow(); +} + - (void)windowNotification : (NSNotification *) windowNotification { //qDebug() << "windowNotification" << QCFString::toQString([windowNotification name]); @@ -269,10 +278,11 @@ static QTouchDevice *touchDevice = 0; 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); + } else if (notificationName == NSWindowDidMiniaturizeNotification + || notificationName == NSWindowDidDeminiaturizeNotification) { + Qt::WindowState newState = notificationName == NSWindowDidMiniaturizeNotification ? + Qt::WindowMinimized : Qt::WindowNoState; + [self notifyWindowStateChanged:newState]; } else if ([notificationName isEqualToString: @"NSWindowDidOrderOffScreenNotification"]) { m_platformWindow->obscureWindow(); } else if ([notificationName isEqualToString: @"NSWindowDidOrderOnScreenAndFinishAnimatingNotification"]) { @@ -294,11 +304,7 @@ static QTouchDevice *touchDevice = 0; || notificationName == NSWindowDidExitFullScreenNotification) { Qt::WindowState newState = notificationName == NSWindowDidEnterFullScreenNotification ? Qt::WindowFullScreen : Qt::WindowNoState; - QWindowSystemInterface::handleWindowStateChanged(m_window, newState); - // We want to read the window state back from the window, - // but the event we just sent may be asynchronous. - QWindowSystemInterface::flushWindowSystemEvents(); - m_platformWindow->setSynchedWindowStateFromWindow(); + [self notifyWindowStateChanged:newState]; } } #endif @@ -309,11 +315,7 @@ static QTouchDevice *touchDevice = 0; - (void)notifyWindowWillZoom:(BOOL)willZoom { Qt::WindowState newState = willZoom ? Qt::WindowMaximized : Qt::WindowNoState; - QWindowSystemInterface::handleWindowStateChanged(m_window, newState); - // We want to read the window state back from the window, - // but the event we just sent may be asynchronous. - QWindowSystemInterface::flushWindowSystemEvents(); - m_platformWindow->setSynchedWindowStateFromWindow(); + [self notifyWindowStateChanged:newState]; } - (void)viewDidHide -- cgit v1.2.3 From d8f4abec711d7af4013209fd8b0c9edcedb44ab6 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 5 Jun 2013 15:47:55 +0200 Subject: Cocoa: Make QWidget::showNormal() work on minimized windows Cocoa sets the NSWindow hidden when it's minimized, and we don't propagate that further to QWindow or QWidget (QWidget's 'visible' documentation is quite ambiguous about that state). The obvious fix is to check for QWindow's visibility. However, this might need to be corrected later if we truly want the visible state to be in sync. Task-number: QTBUG-31117 Change-Id: I457452eff75e6ea746a0ef5351104f8bbb65f98b Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/cocoa/qcocoawindow.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index d9043979d6..19c4faf369 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -486,7 +486,7 @@ void QCocoaWindow::setWindowFlags(Qt::WindowFlags flags) void QCocoaWindow::setWindowState(Qt::WindowState state) { - if ([m_nsWindow isVisible]) + if (window()->isVisible()) syncWindowState(state); // Window state set for hidden windows take effect when show() is called. } -- cgit v1.2.3 From 570cf51919515c4e49b3dfa3723ea154ae04fd73 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Thu, 6 Jun 2013 11:55:56 +0200 Subject: Fix for OS X QFileDialog showing bundle as directory Also check if the selectedFile is a bundle to correctly set currentDir. Patch for Qt 4.8 has been submitted Task-number: QTBUG-31562 Change-Id: I72b0e8484b3c3a610932c03cd7fdab4ddee70277 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm index 071edb5b60..a2001b0c05 100644 --- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm @@ -168,7 +168,7 @@ typedef QSharedPointer SharedPointerFileDialogOptions; mSelectedNameFilter = new QStringList([self findStrippedFilterWithVisualFilterName:selectedVisualNameFilter]); QFileInfo sel(selectFile); - if (sel.isDir()){ + if (sel.isDir() && !sel.isBundle()){ mCurrentDir = [QCFString::toNSString(sel.absoluteFilePath()) retain]; mCurrentSelection = new QString; } else { -- cgit v1.2.3 From 3ac5499a9e2fe76e12f7b9adc9865bfdcb2d77aa Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sat, 8 Jun 2013 00:33:10 +0200 Subject: Cocoa save file dialog behavior fix Currently, in save mode, if selectFile has not been called, the native cocoa file dialog puts the folder name in the line edit. This patch restores the old behavior where the line edit is presented empty to the user. Task-number: QTBUG-31619 Change-Id: I938eb6d968e0e2c343e70bc19f29663e112d0496 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm index a2001b0c05..76cd235514 100644 --- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm @@ -244,15 +244,15 @@ static QString strippedText(QString s) - (void)showModelessPanel { if (mOpenPanel){ - QFileInfo info(!mCurrentSelection->isEmpty() ? *mCurrentSelection : QT_PREPEND_NAMESPACE(QCFString::toQString)(mCurrentDir)); + QFileInfo info(*mCurrentSelection); NSString *filepath = QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.filePath()); bool selectable = (mOptions->acceptMode() == QFileDialogOptions::AcceptSave) || [self panel:nil shouldShowFilename:filepath]; [self updateProperties]; [mOpenPanel setAllowedFileTypes:nil]; - [mOpenPanel setDirectoryURL:selectable ? [NSURL fileURLWithPath:QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.filePath())] - : [NSURL fileURLWithPath:QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.path())]]; + [mSavePanel setNameFieldStringValue:selectable ? QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.fileName()) : @""]; + [mOpenPanel beginWithCompletionHandler:^(NSInteger result){ mReturnCode = result; if (mHelper) @@ -263,13 +263,12 @@ static QString strippedText(QString s) - (BOOL)runApplicationModalPanel { - QFileInfo info(!mCurrentSelection->isEmpty() ? *mCurrentSelection : QT_PREPEND_NAMESPACE(QCFString::toQString)(mCurrentDir)); + QFileInfo info(*mCurrentSelection); NSString *filepath = QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.filePath()); bool selectable = (mOptions->acceptMode() == QFileDialogOptions::AcceptSave) || [self panel:nil shouldShowFilename:filepath]; - [mSavePanel setDirectoryURL:selectable ? [NSURL fileURLWithPath:QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.filePath())] - : [NSURL fileURLWithPath:QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.path())]]; + [mSavePanel setDirectoryURL: [NSURL fileURLWithPath:mCurrentDir]]; [mSavePanel setNameFieldStringValue:selectable ? QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.fileName()) : @""]; // Call processEvents in case the event dispatcher has been interrupted, and needs to do @@ -289,14 +288,14 @@ static QString strippedText(QString s) - (void)showWindowModalSheet:(QWindow *)parent { - QFileInfo info(!mCurrentSelection->isEmpty() ? *mCurrentSelection : QT_PREPEND_NAMESPACE(QCFString::toQString)(mCurrentDir)); + QFileInfo info(*mCurrentSelection); NSString *filepath = QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.filePath()); bool selectable = (mOptions->acceptMode() == QFileDialogOptions::AcceptSave) || [self panel:nil shouldShowFilename:filepath]; [self updateProperties]; - [mSavePanel setDirectoryURL:selectable ? [NSURL fileURLWithPath:QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.filePath())] - : [NSURL fileURLWithPath:QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.path())]]; + [mSavePanel setDirectoryURL: [NSURL fileURLWithPath:mCurrentDir]]; + [mSavePanel setNameFieldStringValue:selectable ? QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.fileName()) : @""]; NSWindow *nsparent = static_cast(qGuiApp->platformNativeInterface()->nativeResourceForWindow("nswindow", parent)); -- cgit v1.2.3