1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the plugins of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
41 #include "qcocoawindow.h"
42 #include "qnswindowdelegate.h"
43 #include "qcocoaautoreleasepool.h"
44 #include "qcocoaeventdispatcher.h"
45 #include "qcocoaglcontext.h"
46 #include "qcocoahelpers.h"
48 #include <QtCore/private/qcore_mac_p.h>
50 #include <qpa/qwindowsysteminterface.h>
51 #include <qpa/qplatformscreen.h>
53 #include <Cocoa/Cocoa.h>
54 #include <Carbon/Carbon.h>
58 static bool isMouseEvent(NSEvent *ev)
63 case NSRightMouseDown:
66 case NSLeftMouseDragged:
67 case NSRightMouseDragged:
74 @interface NSWindow (CocoaWindowCategory)
75 - (void) clearPlatformWindow;
76 - (NSRect) legacyConvertRectFromScreen:(NSRect) rect;
79 @implementation NSWindow (CocoaWindowCategory)
80 - (void) clearPlatformWindow
84 - (NSRect) legacyConvertRectFromScreen:(NSRect) rect
86 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
87 if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
88 return [self convertRectFromScreen: rect];
92 r.origin = [self convertScreenToBase:rect.origin];
97 @implementation QNSWindow
99 - (BOOL)canBecomeKeyWindow
101 // The default implementation returns NO for title-bar less windows,
102 // override and return yes here to make sure popup windows such as
103 // the combobox popup can become the key window.
107 - (BOOL)canBecomeMainWindow
109 BOOL canBecomeMain = YES; // By default, windows can become the main window
111 // Windows with a transient parent (such as combobox popup windows)
112 // cannot become the main window:
113 if (m_cocoaPlatformWindow->window()->transientParent())
116 return canBecomeMain;
119 - (void) sendEvent: (NSEvent*) theEvent
121 [super sendEvent: theEvent];
123 if (!m_cocoaPlatformWindow)
126 if (m_cocoaPlatformWindow->frameStrutEventsEnabled() && isMouseEvent(theEvent)) {
127 NSPoint loc = [theEvent locationInWindow];
128 NSRect windowFrame = [self legacyConvertRectFromScreen:[self frame]];
129 NSRect contentFrame = [[self contentView] frame];
130 if (NSMouseInRect(loc, windowFrame, NO) &&
131 !NSMouseInRect(loc, contentFrame, NO))
133 QNSView *contentView = (QNSView *) m_cocoaPlatformWindow->contentView();
134 [contentView handleFrameStrutMouseEvent: theEvent];
139 - (void)clearPlatformWindow
141 m_cocoaPlatformWindow = 0;
146 @implementation QNSPanel
148 - (BOOL)canBecomeKeyWindow
150 // Most panels can be come the key window. Exceptions are:
151 if (m_cocoaPlatformWindow->window()->windowType() == Qt::ToolTip)
153 if (m_cocoaPlatformWindow->window()->windowType() == Qt::SplashScreen)
158 - (void) sendEvent: (NSEvent*) theEvent
160 [super sendEvent: theEvent];
162 if (!m_cocoaPlatformWindow)
165 if (m_cocoaPlatformWindow->frameStrutEventsEnabled() && isMouseEvent(theEvent)) {
166 NSPoint loc = [theEvent locationInWindow];
167 NSRect windowFrame = [self legacyConvertRectFromScreen:[self frame]];
168 NSRect contentFrame = [[self contentView] frame];
169 if (NSMouseInRect(loc, windowFrame, NO) &&
170 !NSMouseInRect(loc, contentFrame, NO))
172 QNSView *contentView = (QNSView *) m_cocoaPlatformWindow->contentView();
173 [contentView handleFrameStrutMouseEvent: theEvent];
178 - (void)clearPlatformWindow
180 m_cocoaPlatformWindow = 0;
185 QCocoaWindow::QCocoaWindow(QWindow *tlw)
186 : QPlatformWindow(tlw)
188 , m_synchedWindowState(Qt::WindowActive)
189 , m_inConstructor(true)
192 , m_hasModalSession(false)
193 , m_frameStrutEventsEnabled(false)
195 #ifdef QT_COCOA_ENABLE_WINDOW_DEBUG
196 qDebug() << "QCocoaWindow::QCocoaWindow" << this;
198 QCocoaAutoReleasePool pool;
200 m_contentView = [[QNSView alloc] initWithQWindow:tlw platformWindow:this];
201 setGeometry(tlw->geometry());
203 recreateWindow(parent());
205 m_inConstructor = false;
208 QCocoaWindow::~QCocoaWindow()
210 #ifdef QT_COCOA_ENABLE_WINDOW_DEBUG
211 qDebug() << "QCocoaWindow::~QCocoaWindow" << this;
214 clearNSWindow(m_nsWindow);
215 [m_contentView release];
216 [m_nsWindow release];
219 void QCocoaWindow::setGeometry(const QRect &rect)
221 if (geometry() == rect)
223 #ifdef QT_COCOA_ENABLE_WINDOW_DEBUG
224 qDebug() << "QCocoaWindow::setGeometry" << this << rect;
226 QPlatformWindow::setGeometry(rect);
227 setCocoaGeometry(rect);
230 void QCocoaWindow::setCocoaGeometry(const QRect &rect)
233 NSRect bounds = qt_mac_flipRect(rect, window());
234 [m_nsWindow setContentSize : bounds.size];
235 [m_nsWindow setFrameOrigin : bounds.origin];
237 [m_contentView setFrame : NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height())];
241 void QCocoaWindow::setVisible(bool visible)
243 QCocoaAutoReleasePool pool;
244 #ifdef QT_COCOA_ENABLE_WINDOW_DEBUG
245 qDebug() << "QCocoaWindow::setVisible" << window() << visible;
248 QCocoaWindow *parentCocoaWindow = 0;
249 if (window()->transientParent()) {
250 parentCocoaWindow = static_cast<QCocoaWindow *>(window()->transientParent()->handle());
252 // The parent window might have moved while this window was hidden,
253 // update the window geometry if there is a parent.
254 setGeometry(window()->geometry());
256 // Register popup windows so that the parent window can
257 // close them when needed.
258 if (window()->windowType() == Qt::Popup) {
259 // qDebug() << "transientParent and popup" << window()->windowType() << Qt::Popup << (window()->windowType() & Qt::Popup);
260 parentCocoaWindow->m_activePopupWindow = window();
265 // Make sure the QWindow has a frame ready before we show the NSWindow.
266 QWindowSystemInterface::handleSynchronousExposeEvent(window(), QRect(QPoint(), geometry().size()));
269 // setWindowState might have been called while the window was hidden and
270 // will not change the NSWindow state in that case. Sync up here:
271 syncWindowState(window()->windowState());
273 if (window()->windowState() != Qt::WindowMinimized) {
274 if ((window()->windowModality() == Qt::WindowModal
275 || window()->windowType() == Qt::Sheet)
276 && parentCocoaWindow) {
277 // show the window as a sheet
278 [NSApp beginSheet:m_nsWindow modalForWindow:parentCocoaWindow->m_nsWindow modalDelegate:nil didEndSelector:nil contextInfo:nil];
279 } else if (window()->windowModality() != Qt::NonModal) {
280 // show the window as application modal
281 QCocoaEventDispatcher *cocoaEventDispatcher = qobject_cast<QCocoaEventDispatcher *>(QGuiApplication::instance()->eventDispatcher());
282 Q_ASSERT(cocoaEventDispatcher != 0);
283 QCocoaEventDispatcherPrivate *cocoaEventDispatcherPrivate = static_cast<QCocoaEventDispatcherPrivate *>(QObjectPrivate::get(cocoaEventDispatcher));
284 cocoaEventDispatcherPrivate->beginModalSession(window());
285 m_hasModalSession = true;
286 } else if ([m_nsWindow canBecomeKeyWindow]) {
287 [m_nsWindow makeKeyAndOrderFront:nil];
289 [m_nsWindow orderFront: nil];
294 // qDebug() << "close" << this;
296 if (m_hasModalSession) {
297 QCocoaEventDispatcher *cocoaEventDispatcher = qobject_cast<QCocoaEventDispatcher *>(QGuiApplication::instance()->eventDispatcher());
298 Q_ASSERT(cocoaEventDispatcher != 0);
299 QCocoaEventDispatcherPrivate *cocoaEventDispatcherPrivate = static_cast<QCocoaEventDispatcherPrivate *>(QObjectPrivate::get(cocoaEventDispatcher));
300 cocoaEventDispatcherPrivate->endModalSession(window());
301 m_hasModalSession = false;
303 if ([m_nsWindow isSheet])
304 [NSApp endSheet:m_nsWindow];
306 [m_nsWindow orderOut:m_nsWindow];
308 if (!QCoreApplication::closingDown())
309 QWindowSystemInterface::handleExposeEvent(window(), QRegion());
313 NSInteger QCocoaWindow::windowLevel(Qt::WindowFlags flags)
315 Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
317 NSInteger windowLevel = NSNormalWindowLevel;
319 if (type == Qt::Tool) {
320 windowLevel = NSFloatingWindowLevel;
321 } else if ((type & Qt::Popup) == Qt::Popup) {
322 windowLevel = NSPopUpMenuWindowLevel;
324 // Popup should be in at least the same level as its parent.
325 const QWindow * const transientParent = window()->transientParent();
326 const QCocoaWindow * const transientParentWindow = transientParent ? static_cast<QCocoaWindow *>(transientParent->handle()) : 0;
327 if (transientParentWindow)
328 windowLevel = qMax([transientParentWindow->m_nsWindow level], windowLevel);
331 // StayOnTop window should appear above Tool windows.
332 if (flags & Qt::WindowStaysOnTopHint)
333 windowLevel = NSPopUpMenuWindowLevel;
334 // Tooltips should appear above StayOnTop windows.
335 if (type == Qt::ToolTip)
336 windowLevel = NSScreenSaverWindowLevel;
341 NSUInteger QCocoaWindow::windowStyleMask(Qt::WindowFlags flags)
343 Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
344 NSInteger styleMask = NSBorderlessWindowMask;
346 if ((type & Qt::Popup) == Qt::Popup) {
347 if (!windowIsPopupType(type))
348 styleMask = (NSUtilityWindowMask | NSResizableWindowMask | NSClosableWindowMask |
349 NSMiniaturizableWindowMask | NSTitledWindowMask);
351 // Filter flags for supported properties
352 flags &= Qt::WindowType_Mask | Qt::FramelessWindowHint | Qt::WindowTitleHint |
353 Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint;
354 if (flags == Qt::Window) {
355 styleMask = (NSResizableWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSTitledWindowMask);
356 } else if (!(flags & Qt::FramelessWindowHint)) {
357 if (flags & Qt::WindowMaximizeButtonHint)
358 styleMask |= NSResizableWindowMask;
359 if (flags & Qt::WindowTitleHint)
360 styleMask |= NSTitledWindowMask;
361 if (flags & Qt::WindowCloseButtonHint)
362 styleMask |= NSClosableWindowMask;
363 if (flags & Qt::WindowMinimizeButtonHint)
364 styleMask |= NSMiniaturizableWindowMask;
371 Qt::WindowFlags QCocoaWindow::setWindowFlags(Qt::WindowFlags flags)
374 NSUInteger styleMask = windowStyleMask(flags);
375 NSInteger level = this->windowLevel(flags);
376 [m_nsWindow setStyleMask:styleMask];
377 [m_nsWindow setLevel:level];
380 m_windowFlags = flags;
381 return m_windowFlags;
384 Qt::WindowState QCocoaWindow::setWindowState(Qt::WindowState state)
386 if ([m_nsWindow isVisible])
387 syncWindowState(state); // Window state set for hidden windows take effect when show() is called.
392 void QCocoaWindow::setWindowTitle(const QString &title)
394 QCocoaAutoReleasePool pool;
398 CFStringRef windowTitle = QCFString::toCFStringRef(title);
399 [m_nsWindow setTitle: const_cast<NSString *>(reinterpret_cast<const NSString *>(windowTitle))];
400 CFRelease(windowTitle);
403 void QCocoaWindow::raise()
405 //qDebug() << "raise" << this;
406 // ### handle spaces (see Qt 4 raise_sys in qwidget_mac.mm)
409 if ([m_nsWindow isVisible])
410 [m_nsWindow orderFront: m_nsWindow];
413 void QCocoaWindow::lower()
417 if ([m_nsWindow isVisible])
418 [m_nsWindow orderBack: m_nsWindow];
421 void QCocoaWindow::propagateSizeHints()
423 QCocoaAutoReleasePool pool;
427 #ifdef QT_COCOA_ENABLE_WINDOW_DEBUG
428 qDebug() << "QCocoaWindow::propagateSizeHints" << this;
429 qDebug() << " min/max " << window()->minimumSize() << window()->maximumSize();
430 qDebug() << "size increment" << window()->sizeIncrement();
431 qDebug() << " basesize" << window()->baseSize();
432 qDebug() << " geometry" << geometry();
435 // Set the minimum content size.
436 const QSize minimumSize = window()->minimumSize();
437 if (!minimumSize.isValid()) // minimumSize is (-1, -1) when not set. Make that (0, 0) for Cocoa.
438 [m_nsWindow setContentMinSize : NSMakeSize(0.0, 0.0)];
439 [m_nsWindow setContentMinSize : NSMakeSize(minimumSize.width(), minimumSize.height())];
441 // Set the maximum content size.
442 const QSize maximumSize = window()->maximumSize();
443 [m_nsWindow setContentMaxSize : NSMakeSize(maximumSize.width(), maximumSize.height())];
445 // sizeIncrement is observed to take values of (-1, -1) and (0, 0) for windows that should be
446 // resizable and that have no specific size increment set. Cocoa expects (1.0, 1.0) in this case.
447 if (!window()->sizeIncrement().isEmpty())
448 [m_nsWindow setResizeIncrements : qt_mac_toNSSize(window()->sizeIncrement())];
450 [m_nsWindow setResizeIncrements : NSMakeSize(1.0, 1.0)];
452 QRect rect = geometry();
453 QSize baseSize = window()->baseSize();
454 if (!baseSize.isNull() && baseSize.isValid()) {
455 [m_nsWindow setFrame:NSMakeRect(rect.x(), rect.y(), baseSize.width(), baseSize.height()) display:YES];
459 void QCocoaWindow::setOpacity(qreal level)
462 [m_nsWindow setAlphaValue:level];
465 bool QCocoaWindow::setKeyboardGrabEnabled(bool grab)
470 if (grab && ![m_nsWindow isKeyWindow])
471 [m_nsWindow makeKeyWindow];
472 else if (!grab && [m_nsWindow isKeyWindow])
473 [m_nsWindow resignKeyWindow];
477 bool QCocoaWindow::setMouseGrabEnabled(bool grab)
482 if (grab && ![m_nsWindow isKeyWindow])
483 [m_nsWindow makeKeyWindow];
484 else if (!grab && [m_nsWindow isKeyWindow])
485 [m_nsWindow resignKeyWindow];
489 WId QCocoaWindow::winId() const
491 return WId(m_contentView);
494 void QCocoaWindow::setParent(const QPlatformWindow *parentWindow)
496 // recreate the window for compatibility
497 recreateWindow(parentWindow);
498 setCocoaGeometry(geometry());
501 NSView *QCocoaWindow::contentView() const
503 return m_contentView;
506 void QCocoaWindow::windowWillMove()
508 // Close any open popups on window move
509 if (m_activePopupWindow) {
510 QWindowSystemInterface::handleSynchronousCloseEvent(m_activePopupWindow);
511 m_activePopupWindow = 0;
515 void QCocoaWindow::windowDidMove()
517 [m_contentView updateGeometry];
520 void QCocoaWindow::windowDidResize()
525 NSRect rect = [[m_nsWindow contentView]frame];
526 // Call setFrameSize which will trigger a frameDidChangeNotification on QNSView.
527 [[m_nsWindow contentView] setFrameSize:rect.size];
530 void QCocoaWindow::windowWillClose()
532 QWindowSystemInterface::handleSynchronousCloseEvent(window());
535 bool QCocoaWindow::windowIsPopupType(Qt::WindowType type) const
537 if (type == Qt::Widget)
538 type = window()->windowType();
539 if (type == Qt::Tool)
540 return false; // Qt::Tool has the Popup bit set but isn't, at least on Mac.
542 return ((type & Qt::Popup) == Qt::Popup);
545 void QCocoaWindow::setCurrentContext(QCocoaGLContext *context)
547 m_glContext = context;
550 QCocoaGLContext *QCocoaWindow::currentContext() const
555 void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
557 // Remove current window (if any)
559 clearNSWindow(m_nsWindow);
561 [m_nsWindow release];
566 // Create a new NSWindow if this is a top-level window.
567 m_nsWindow = createNSWindow();
568 setNSWindow(m_nsWindow);
570 // QPlatformWindow subclasses must sync up with QWindow on creation:
571 propagateSizeHints();
572 setWindowFlags(window()->windowFlags());
573 setWindowTitle(window()->windowTitle());
574 setWindowState(window()->windowState());
576 if (window()->transientParent()) {
577 // keep this window on the same level as its transient parent (which may be a modal dialog, for example)
578 QCocoaWindow *parentCocoaWindow = static_cast<QCocoaWindow *>(window()->transientParent()->handle());
579 [m_nsWindow setLevel:[parentCocoaWindow->m_nsWindow level]];
582 // Child windows have no NSWindow, link the NSViews instead.
583 const QCocoaWindow *parentCococaWindow = static_cast<const QCocoaWindow *>(parentWindow);
584 [parentCococaWindow->m_contentView addSubview : m_contentView];
588 NSWindow * QCocoaWindow::createNSWindow()
590 QCocoaAutoReleasePool pool;
592 NSRect frame = qt_mac_flipRect(window()->geometry(), window());
594 Qt::WindowType type = window()->windowType();
595 Qt::WindowFlags flags = window()->windowFlags();
597 NSUInteger styleMask = windowStyleMask(flags);
598 NSWindow *createdWindow = 0;
600 // Use NSPanel for popup-type windows. (Popup, Tool, ToolTip, SplashScreen)
601 if ((type & Qt::Popup) == Qt::Popup) {
603 window = [[QNSPanel alloc] initWithContentRect:frame
605 backing:NSBackingStoreBuffered
606 defer:NO]; // Deferring window creation breaks OpenGL (the GL context is set up
607 // before the window is shown and needs a proper window.).
608 [window setHasShadow:YES];
610 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
611 if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
612 // Make popup winows show on the same desktop as the parent full-screen window.
613 [window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary];
616 window->m_cocoaPlatformWindow = this;
617 createdWindow = window;
620 window = [[QNSWindow alloc] initWithContentRect:frame
622 backing:NSBackingStoreBuffered
623 defer:NO]; // Deferring window creation breaks OpenGL (the GL context is set up
624 // before the window is shown and needs a proper window.).
625 window->m_cocoaPlatformWindow = this;
627 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
628 if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
629 // All windows with the WindowMaximizeButtonHint set also get a full-screen button.
630 if (flags & Qt::WindowMaximizeButtonHint)
631 [window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
635 createdWindow = window;
638 NSInteger level = windowLevel(flags);
639 [createdWindow setLevel:level];
641 return createdWindow;
644 void QCocoaWindow::setNSWindow(NSWindow *window)
646 QNSWindowDelegate *delegate = [[QNSWindowDelegate alloc] initWithQCocoaWindow:this];
647 [window setDelegate:delegate];
648 [window setAcceptsMouseMovedEvents:YES];
650 // Prevent Cocoa from releasing the window on close. Qt
651 // handles the close event asynchronously and we want to
652 // make sure that m_nsWindow stays valid until the
653 // QCocoaWindow is deleted by Qt.
654 [window setReleasedWhenClosed : NO];
657 [[NSNotificationCenter defaultCenter] addObserver:m_contentView
658 selector:@selector(windowNotification:)
659 name:nil // Get all notifications
662 // ### Accept touch events by default.
663 // Beware that enabling touch events has a negative impact on the overall performance.
664 // We probably need a QWindowSystemInterface API to enable/disable touch events.
665 [m_contentView setAcceptsTouchEvents:YES];
667 [window setContentView:m_contentView];
670 void QCocoaWindow::clearNSWindow(NSWindow *window)
672 [window setDelegate:nil];
673 [window clearPlatformWindow];
674 [[NSNotificationCenter defaultCenter] removeObserver:m_contentView];
677 // Returns the current global screen geometry for the nswindow associated with this window.
678 QRect QCocoaWindow::windowGeometry() const
683 NSRect rect = [m_nsWindow frame];
684 QPlatformScreen *onScreen = QPlatformScreen::platformScreenForWindow(window());
685 int flippedY = onScreen->geometry().height() - rect.origin.y - rect.size.height; // account for nswindow inverted y.
686 QRect qRect = QRect(rect.origin.x, flippedY, rect.size.width, rect.size.height);
690 // Returns a pointer to the parent QCocoaWindow for this window, or 0 if there is none.
691 QCocoaWindow *QCocoaWindow::parentCocoaWindow() const
693 if (window() && window()->transientParent()) {
694 return static_cast<QCocoaWindow*>(window()->transientParent()->handle());
699 // Syncs the NSWindow minimize/maximize/fullscreen state with the current QWindow state
700 void QCocoaWindow::syncWindowState(Qt::WindowState newState)
705 if ((m_synchedWindowState & Qt::WindowMaximized) != (newState & Qt::WindowMaximized)) {
706 [m_nsWindow performZoom : m_nsWindow]; // toggles
709 if ((m_synchedWindowState & Qt::WindowMinimized) != (newState & Qt::WindowMinimized)) {
710 if (newState & Qt::WindowMinimized) {
711 [m_nsWindow performMiniaturize : m_nsWindow];
713 [m_nsWindow deminiaturize : m_nsWindow];
717 if ((m_synchedWindowState & Qt::WindowFullScreen) != (newState & Qt::WindowFullScreen)) {
718 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
719 if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
720 [m_nsWindow toggleFullScreen : m_nsWindow];
722 // TODO: "normal" fullscreen
727 // New state is now the current synched state
728 m_synchedWindowState = newState;
731 bool QCocoaWindow::setWindowModified(bool modified)
735 [m_nsWindow setDocumentEdited:(modified?YES:NO)];
739 void QCocoaWindow::setMenubar(QCocoaMenuBar *mb)
744 QCocoaMenuBar *QCocoaWindow::menubar() const
749 QMargins QCocoaWindow::frameMargins() const
751 NSRect frameW = [m_nsWindow frame];
752 NSRect frameC = [m_nsWindow contentRectForFrameRect:frameW];
754 return QMargins(frameW.origin.x - frameC.origin.x,
755 (frameW.origin.y + frameW.size.height) - (frameC.origin.y + frameC.size.height),
756 (frameW.origin.x + frameW.size.width) - (frameC.origin.x + frameC.size.width),
757 frameC.origin.y - frameW.origin.y);
760 void QCocoaWindow::setFrameStrutEventsEnabled(bool enabled)
762 m_frameStrutEventsEnabled = enabled;