diff options
Diffstat (limited to 'src/plugins/platforms/cocoa/qnswindowdelegate.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qnswindowdelegate.mm | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.mm b/src/plugins/platforms/cocoa/qnswindowdelegate.mm index 1224d138d9..6e5623d679 100644 --- a/src/plugins/platforms/cocoa/qnswindowdelegate.mm +++ b/src/plugins/platforms/cocoa/qnswindowdelegate.mm @@ -44,6 +44,8 @@ #include <qpa/qplatformscreen.h> #include <qpa/qwindowsysteminterface.h> +static QRegExp whitespaceRegex = QRegExp(QStringLiteral("\\s*")); + @implementation QNSWindowDelegate - (id)initWithQCocoaWindow:(QCocoaWindow *)cocoaWindow @@ -78,27 +80,14 @@ return NSRectFromCGRect(m_cocoaWindow->screen()->availableGeometry().toCGRect()); } -#if QT_MACOS_DEPLOYMENT_TARGET_BELOW(__MAC_10_11) -/* - AppKit on OS X 10.10 wrongly calls windowWillUseStandardFrame:defaultFrame - from -[NSWindow _frameForFullScreenMode] when going into fullscreen, resulting - in black bars on top and bottom of the window. By implementing the following - method, AppKit will choose that instead, and resolve the right fullscreen - geometry. -*/ -- (NSSize)window:(NSWindow *)window willUseFullScreenContentSize:(NSSize)proposedSize -{ - Q_UNUSED(proposedSize); - Q_ASSERT(window == m_cocoaWindow->nativeWindow()); - return NSSizeFromCGSize(m_cocoaWindow->screen()->geometry().size().toCGSize()); -} -#endif - - (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu *)menu { Q_UNUSED(window); Q_UNUSED(menu); - return m_cocoaWindow && m_cocoaWindow->m_hasWindowFilePath; + + // Only pop up document path if the filename is non-empty. We allow whitespace, to + // allow faking a window icon by setting the file path to a single space character. + return !whitespaceRegex.exactMatch(m_cocoaWindow->window()->filePath()); } - (BOOL)window:(NSWindow *)window shouldDragDocumentWithEvent:(NSEvent *)event from:(NSPoint)dragImageLocation withPasteboard:(NSPasteboard *)pasteboard @@ -107,6 +96,9 @@ Q_UNUSED(event); Q_UNUSED(dragImageLocation); Q_UNUSED(pasteboard); - return m_cocoaWindow && m_cocoaWindow->m_hasWindowFilePath; + + // Only allow drag if the filename is non-empty. We allow whitespace, to + // allow faking a window icon by setting the file path to a single space. + return !whitespaceRegex.exactMatch(m_cocoaWindow->window()->filePath()); } @end |