5#include <AppKit/AppKit.h>
13#include <QtCore/private/qcore_mac_p.h>
14#include <qpa/qplatformscreen.h>
15#include <qpa/qwindowsysteminterface.h>
19 for (
int i = 0; i < s.size(); ++i)
20 if (!s.at(i).isSpace())
27 return qnswindow_cast(window).platformWindow;
30@implementation QNSWindowDelegate
32- (BOOL)windowShouldClose:(NSWindow *)window
34 if (QCocoaWindow *platformWindow = toPlatformWindow(window))
35 return platformWindow->windowShouldClose();
40
41
42
43
44
45
46- (NSRect)windowWillUseStandardFrame:(NSWindow *)window defaultFrame:(NSRect)proposedFrame
48 Q_UNUSED(proposedFrame);
50 QCocoaWindow *platformWindow = toPlatformWindow(window);
51 Q_ASSERT(platformWindow);
52 const QWindow *w = platformWindow->window();
55 QSizeF maximumSize = w->maximumSize() + QSize(0, w->frameMargins().top());
58 const QRectF screenGeometry = platformWindow->screen()->geometry();
59 maximumSize = maximumSize.boundedTo(screenGeometry.size());
64 QRectF maximizedFrame = QRectF(w->framePosition(), maximumSize);
69 maximizedFrame.translate(QPoint(
70 qMax(screenGeometry.left() - maximizedFrame.left(), 0.0) +
71 qMin(screenGeometry.right() - maximizedFrame.right(), 0.0),
72 qMax(screenGeometry.top() - maximizedFrame.top(), 0.0) +
73 qMin(screenGeometry.bottom() - maximizedFrame.bottom(), 0.0)));
75 return QCocoaScreen::mapToNative(maximizedFrame);
78- (BOOL)windowShouldZoom:(NSWindow*)window toFrame:(NSRect)newFrame
80 QCocoaWindow *platformWindow = toPlatformWindow(window);
81 Q_ASSERT(platformWindow);
82 platformWindow->windowWillZoom();
86- (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu *)menu
90 QCocoaWindow *platformWindow = toPlatformWindow(window);
91 Q_ASSERT(platformWindow);
95 return !isWhiteSpace(platformWindow->window()->filePath());
98- (BOOL)window:(NSWindow *)window shouldDragDocumentWithEvent:(NSEvent *)event from:(NSPoint)dragImageLocation withPasteboard:(NSPasteboard *)pasteboard
101 Q_UNUSED(dragImageLocation);
102 Q_UNUSED(pasteboard);
104 QCocoaWindow *platformWindow = toPlatformWindow(window);
105 Q_ASSERT(platformWindow);
109 return !isWhiteSpace(platformWindow->window()->filePath());
static bool isWhiteSpace(const QString &s)
static QCocoaWindow * toPlatformWindow(NSWindow *window)