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 QCocoaAutoReleasePool pool;
215 clearNSWindow(m_nsWindow);
216 [m_contentView release];
217 [m_nsWindow release];
220 void QCocoaWindow::setGeometry(const QRect &rect)
222 if (geometry() == rect)
224 #ifdef QT_COCOA_ENABLE_WINDOW_DEBUG
225 qDebug() << "QCocoaWindow::setGeometry" << this << rect;
227 QPlatformWindow::setGeometry(rect);
228 setCocoaGeometry(rect);
231 void QCocoaWindow::setCocoaGeometry(const QRect &rect)
233 QCocoaAutoReleasePool pool;
235 NSRect bounds = qt_mac_flipRect(rect, window());
236 [m_nsWindow setContentSize : bounds.size];
237 [m_nsWindow setFrameOrigin : bounds.origin];
239 [m_contentView setFrame : NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height())];
243 void QCocoaWindow::setVisible(bool visible)
245 QCocoaAutoReleasePool pool;
246 #ifdef QT_COCOA_ENABLE_WINDOW_DEBUG
247 qDebug() << "QCocoaWindow::setVisible" << window() << visible;
250 QCocoaWindow *parentCocoaWindow = 0;
251 if (window()->transientParent()) {
252 parentCocoaWindow = static_cast<QCocoaWindow *>(window()->transientParent()->handle());
254 // The parent window might have moved while this window was hidden,
255 // update the window geometry if there is a parent.
256 setGeometry(window()->geometry());
258 // Register popup windows so that the parent window can
259 // close them when needed.
260 if (window()->windowType() == Qt::Popup) {
261 // qDebug() << "transientParent and popup" << window()->windowType() << Qt::Popup << (window()->windowType() & Qt::Popup);
262 parentCocoaWindow->m_activePopupWindow = window();
267 // Make sure the QWindow has a frame ready before we show the NSWindow.
268 QWindowSystemInterface::handleSynchronousExposeEvent(window(), QRect(QPoint(), geometry().size()));
271 // setWindowState might have been called while the window was hidden and
272 // will not change the NSWindow state in that case. Sync up here:
273 syncWindowState(window()->windowState());
275 if (window()->windowState() != Qt::WindowMinimized) {
276 if ((window()->windowModality() == Qt::WindowModal
277 || window()->windowType() == Qt::Sheet)
278 && parentCocoaWindow) {
279 // show the window as a sheet
280 [NSApp beginSheet:m_nsWindow modalForWindow:parentCocoaWindow->m_nsWindow modalDelegate:nil didEndSelector:nil contextInfo:nil];
281 } else if (window()->windowModality() != Qt::NonModal) {
282 // show the window as application modal
283 QCocoaEventDispatcher *cocoaEventDispatcher = qobject_cast<QCocoaEventDispatcher *>(QGuiApplication::instance()->eventDispatcher());
284 Q_ASSERT(cocoaEventDispatcher != 0);
285 QCocoaEventDispatcherPrivate *cocoaEventDispatcherPrivate = static_cast<QCocoaEventDispatcherPrivate *>(QObjectPrivate::get(cocoaEventDispatcher));
286 cocoaEventDispatcherPrivate->beginModalSession(window());
287 m_hasModalSession = true;
288 } else if ([m_nsWindow canBecomeKeyWindow]) {
289 [m_nsWindow makeKeyAndOrderFront:nil];
291 [m_nsWindow orderFront: nil];
296 // qDebug() << "close" << this;
298 if (m_hasModalSession) {
299 QCocoaEventDispatcher *cocoaEventDispatcher = qobject_cast<QCocoaEventDispatcher *>(QGuiApplication::instance()->eventDispatcher());
300 Q_ASSERT(cocoaEventDispatcher != 0);
301 QCocoaEventDispatcherPrivate *cocoaEventDispatcherPrivate = static_cast<QCocoaEventDispatcherPrivate *>(QObjectPrivate::get(cocoaEventDispatcher));
302 cocoaEventDispatcherPrivate->endModalSession(window());
303 m_hasModalSession = false;
305 if ([m_nsWindow isSheet])
306 [NSApp endSheet:m_nsWindow];
308 [m_nsWindow orderOut:m_nsWindow];
310 if (!QCoreApplication::closingDown())
311 QWindowSystemInterface::handleExposeEvent(window(), QRegion());
315 NSInteger QCocoaWindow::windowLevel(Qt::WindowFlags flags)
317 Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
319 NSInteger windowLevel = NSNormalWindowLevel;
321 if (type == Qt::Tool) {
322 windowLevel = NSFloatingWindowLevel;
323 } else if ((type & Qt::Popup) == Qt::Popup) {
324 windowLevel = NSPopUpMenuWindowLevel;
326 // Popup should be in at least the same level as its parent.
327 const QWindow * const transientParent = window()->transientParent();
328 const QCocoaWindow * const transientParentWindow = transientParent ? static_cast<QCocoaWindow *>(transientParent->handle()) : 0;
329 if (transientParentWindow)
330 windowLevel = qMax([transientParentWindow->m_nsWindow level], windowLevel);
333 // StayOnTop window should appear above Tool windows.
334 if (flags & Qt::WindowStaysOnTopHint)
335 windowLevel = NSPopUpMenuWindowLevel;
336 // Tooltips should appear above StayOnTop windows.
337 if (type == Qt::ToolTip)
338 windowLevel = NSScreenSaverWindowLevel;
343 NSUInteger QCocoaWindow::windowStyleMask(Qt::WindowFlags flags)
345 Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
346 NSInteger styleMask = NSBorderlessWindowMask;
348 if ((type & Qt::Popup) == Qt::Popup) {
349 if (!windowIsPopupType(type))
350 styleMask = (NSUtilityWindowMask | NSResizableWindowMask | NSClosableWindowMask |
351 NSMiniaturizableWindowMask | NSTitledWindowMask);
353 // Filter flags for supported properties
354 flags &= Qt::WindowType_Mask | Qt::FramelessWindowHint | Qt::WindowTitleHint |
355 Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint;
356 if (flags == Qt::Window) {
357 styleMask = (NSResizableWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSTitledWindowMask);
358 } else if (!(flags & Qt::FramelessWindowHint)) {
359 if (flags & Qt::WindowMaximizeButtonHint)
360 styleMask |= NSResizableWindowMask;
361 if (flags & Qt::WindowTitleHint)
362 styleMask |= NSTitledWindowMask;
363 if (flags & Qt::WindowCloseButtonHint)
364 styleMask |= NSClosableWindowMask;
365 if (flags & Qt::WindowMinimizeButtonHint)
366 styleMask |= NSMiniaturizableWindowMask;
373 Qt::WindowFlags QCocoaWindow::setWindowFlags(Qt::WindowFlags flags)
376 NSUInteger styleMask = windowStyleMask(flags);
377 NSInteger level = this->windowLevel(flags);
378 [m_nsWindow setStyleMask:styleMask];
379 [m_nsWindow setLevel:level];
382 m_windowFlags = flags;
383 return m_windowFlags;
386 Qt::WindowState QCocoaWindow::setWindowState(Qt::WindowState state)
388 if ([m_nsWindow isVisible])
389 syncWindowState(state); // Window state set for hidden windows take effect when show() is called.
394 void QCocoaWindow::setWindowTitle(const QString &title)
396 QCocoaAutoReleasePool pool;
400 CFStringRef windowTitle = QCFString::toCFStringRef(title);
401 [m_nsWindow setTitle: const_cast<NSString *>(reinterpret_cast<const NSString *>(windowTitle))];
402 CFRelease(windowTitle);
405 void QCocoaWindow::raise()
407 //qDebug() << "raise" << this;
408 // ### handle spaces (see Qt 4 raise_sys in qwidget_mac.mm)
411 if ([m_nsWindow isVisible])
412 [m_nsWindow orderFront: m_nsWindow];
415 void QCocoaWindow::lower()
419 if ([m_nsWindow isVisible])
420 [m_nsWindow orderBack: m_nsWindow];
423 void QCocoaWindow::propagateSizeHints()
425 QCocoaAutoReleasePool pool;
429 #ifdef QT_COCOA_ENABLE_WINDOW_DEBUG
430 qDebug() << "QCocoaWindow::propagateSizeHints" << this;
431 qDebug() << " min/max " << window()->minimumSize() << window()->maximumSize();
432 qDebug() << "size increment" << window()->sizeIncrement();
433 qDebug() << " basesize" << window()->baseSize();
434 qDebug() << " geometry" << geometry();
437 // Set the minimum content size.
438 const QSize minimumSize = window()->minimumSize();
439 if (!minimumSize.isValid()) // minimumSize is (-1, -1) when not set. Make that (0, 0) for Cocoa.
440 [m_nsWindow setContentMinSize : NSMakeSize(0.0, 0.0)];
441 [m_nsWindow setContentMinSize : NSMakeSize(minimumSize.width(), minimumSize.height())];
443 // Set the maximum content size.
444 const QSize maximumSize = window()->maximumSize();
445 [m_nsWindow setContentMaxSize : NSMakeSize(maximumSize.width(), maximumSize.height())];
447 // sizeIncrement is observed to take values of (-1, -1) and (0, 0) for windows that should be
448 // resizable and that have no specific size increment set. Cocoa expects (1.0, 1.0) in this case.
449 if (!window()->sizeIncrement().isEmpty())
450 [m_nsWindow setResizeIncrements : qt_mac_toNSSize(window()->sizeIncrement())];
452 [m_nsWindow setResizeIncrements : NSMakeSize(1.0, 1.0)];
454 QRect rect = geometry();
455 QSize baseSize = window()->baseSize();
456 if (!baseSize.isNull() && baseSize.isValid()) {
457 [m_nsWindow setFrame:NSMakeRect(rect.x(), rect.y(), baseSize.width(), baseSize.height()) display:YES];
461 void QCocoaWindow::setOpacity(qreal level)
464 [m_nsWindow setAlphaValue:level];
467 bool QCocoaWindow::setKeyboardGrabEnabled(bool grab)
472 if (grab && ![m_nsWindow isKeyWindow])
473 [m_nsWindow makeKeyWindow];
474 else if (!grab && [m_nsWindow isKeyWindow])
475 [m_nsWindow resignKeyWindow];
479 bool QCocoaWindow::setMouseGrabEnabled(bool grab)
484 if (grab && ![m_nsWindow isKeyWindow])
485 [m_nsWindow makeKeyWindow];
486 else if (!grab && [m_nsWindow isKeyWindow])
487 [m_nsWindow resignKeyWindow];
491 WId QCocoaWindow::winId() const
493 return WId(m_contentView);
496 void QCocoaWindow::setParent(const QPlatformWindow *parentWindow)
498 // recreate the window for compatibility
499 recreateWindow(parentWindow);
500 setCocoaGeometry(geometry());
503 NSView *QCocoaWindow::contentView() const
505 return m_contentView;
508 void QCocoaWindow::windowWillMove()
510 // Close any open popups on window move
511 if (m_activePopupWindow) {
512 QWindowSystemInterface::handleSynchronousCloseEvent(m_activePopupWindow);
513 m_activePopupWindow = 0;
517 void QCocoaWindow::windowDidMove()
519 [m_contentView updateGeometry];
522 void QCocoaWindow::windowDidResize()
527 NSRect rect = [[m_nsWindow contentView]frame];
528 // Call setFrameSize which will trigger a frameDidChangeNotification on QNSView.
529 [[m_nsWindow contentView] setFrameSize:rect.size];
532 void QCocoaWindow::windowWillClose()
534 QWindowSystemInterface::handleSynchronousCloseEvent(window());
537 bool QCocoaWindow::windowIsPopupType(Qt::WindowType type) const
539 if (type == Qt::Widget)
540 type = window()->windowType();
541 if (type == Qt::Tool)
542 return false; // Qt::Tool has the Popup bit set but isn't, at least on Mac.
544 return ((type & Qt::Popup) == Qt::Popup);
547 void QCocoaWindow::setCurrentContext(QCocoaGLContext *context)
549 m_glContext = context;
552 QCocoaGLContext *QCocoaWindow::currentContext() const
557 void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
559 // Remove current window (if any)
561 clearNSWindow(m_nsWindow);
563 [m_nsWindow release];
568 // Create a new NSWindow if this is a top-level window.
569 m_nsWindow = createNSWindow();
570 setNSWindow(m_nsWindow);
572 // QPlatformWindow subclasses must sync up with QWindow on creation:
573 propagateSizeHints();
574 setWindowFlags(window()->windowFlags());
575 setWindowTitle(window()->windowTitle());
576 setWindowState(window()->windowState());
578 if (window()->transientParent()) {
579 // keep this window on the same level as its transient parent (which may be a modal dialog, for example)
580 QCocoaWindow *parentCocoaWindow = static_cast<QCocoaWindow *>(window()->transientParent()->handle());
581 [m_nsWindow setLevel:[parentCocoaWindow->m_nsWindow level]];
584 // Child windows have no NSWindow, link the NSViews instead.
585 const QCocoaWindow *parentCococaWindow = static_cast<const QCocoaWindow *>(parentWindow);
586 [parentCococaWindow->m_contentView addSubview : m_contentView];
590 NSWindow * QCocoaWindow::createNSWindow()
592 QCocoaAutoReleasePool pool;
594 NSRect frame = qt_mac_flipRect(window()->geometry(), window());
596 Qt::WindowType type = window()->windowType();
597 Qt::WindowFlags flags = window()->windowFlags();
599 NSUInteger styleMask = windowStyleMask(flags);
600 NSWindow *createdWindow = 0;
602 // Use NSPanel for popup-type windows. (Popup, Tool, ToolTip, SplashScreen)
603 if ((type & Qt::Popup) == Qt::Popup) {
605 window = [[QNSPanel alloc] initWithContentRect:frame
607 backing:NSBackingStoreBuffered
608 defer:NO]; // Deferring window creation breaks OpenGL (the GL context is set up
609 // before the window is shown and needs a proper window.).
610 [window setHasShadow:YES];
612 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
613 if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
614 // Make popup winows show on the same desktop as the parent full-screen window.
615 [window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary];
618 window->m_cocoaPlatformWindow = this;
619 createdWindow = window;
622 window = [[QNSWindow alloc] initWithContentRect:frame
624 backing:NSBackingStoreBuffered
625 defer:NO]; // Deferring window creation breaks OpenGL (the GL context is set up
626 // before the window is shown and needs a proper window.).
627 window->m_cocoaPlatformWindow = this;
629 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
630 if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
631 // All windows with the WindowMaximizeButtonHint set also get a full-screen button.
632 if (flags & Qt::WindowMaximizeButtonHint)
633 [window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
637 createdWindow = window;
640 NSInteger level = windowLevel(flags);
641 [createdWindow setLevel:level];
643 return createdWindow;
646 void QCocoaWindow::setNSWindow(NSWindow *window)
648 QNSWindowDelegate *delegate = [[QNSWindowDelegate alloc] initWithQCocoaWindow:this];
649 [window setDelegate:delegate];
650 [window setAcceptsMouseMovedEvents:YES];
652 // Prevent Cocoa from releasing the window on close. Qt
653 // handles the close event asynchronously and we want to
654 // make sure that m_nsWindow stays valid until the
655 // QCocoaWindow is deleted by Qt.
656 [window setReleasedWhenClosed : NO];
659 [[NSNotificationCenter defaultCenter] addObserver:m_contentView
660 selector:@selector(windowNotification:)
661 name:nil // Get all notifications
664 // ### Accept touch events by default.
665 // Beware that enabling touch events has a negative impact on the overall performance.
666 // We probably need a QWindowSystemInterface API to enable/disable touch events.
667 [m_contentView setAcceptsTouchEvents:YES];
669 [window setContentView:m_contentView];
672 void QCocoaWindow::clearNSWindow(NSWindow *window)
674 [window setDelegate:nil];
675 [window clearPlatformWindow];
676 [[NSNotificationCenter defaultCenter] removeObserver:m_contentView];
679 // Returns the current global screen geometry for the nswindow associated with this window.
680 QRect QCocoaWindow::windowGeometry() const
685 NSRect rect = [m_nsWindow frame];
686 QPlatformScreen *onScreen = QPlatformScreen::platformScreenForWindow(window());
687 int flippedY = onScreen->geometry().height() - rect.origin.y - rect.size.height; // account for nswindow inverted y.
688 QRect qRect = QRect(rect.origin.x, flippedY, rect.size.width, rect.size.height);
692 // Returns a pointer to the parent QCocoaWindow for this window, or 0 if there is none.
693 QCocoaWindow *QCocoaWindow::parentCocoaWindow() const
695 if (window() && window()->transientParent()) {
696 return static_cast<QCocoaWindow*>(window()->transientParent()->handle());
701 // Syncs the NSWindow minimize/maximize/fullscreen state with the current QWindow state
702 void QCocoaWindow::syncWindowState(Qt::WindowState newState)
707 if ((m_synchedWindowState & Qt::WindowMaximized) != (newState & Qt::WindowMaximized)) {
708 [m_nsWindow performZoom : m_nsWindow]; // toggles
711 if ((m_synchedWindowState & Qt::WindowMinimized) != (newState & Qt::WindowMinimized)) {
712 if (newState & Qt::WindowMinimized) {
713 [m_nsWindow performMiniaturize : m_nsWindow];
715 [m_nsWindow deminiaturize : m_nsWindow];
719 if ((m_synchedWindowState & Qt::WindowFullScreen) != (newState & Qt::WindowFullScreen)) {
720 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
721 if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
722 [m_nsWindow toggleFullScreen : m_nsWindow];
724 // TODO: "normal" fullscreen
729 // New state is now the current synched state
730 m_synchedWindowState = newState;
733 bool QCocoaWindow::setWindowModified(bool modified)
737 [m_nsWindow setDocumentEdited:(modified?YES:NO)];
741 void QCocoaWindow::setMenubar(QCocoaMenuBar *mb)
746 QCocoaMenuBar *QCocoaWindow::menubar() const
751 QMargins QCocoaWindow::frameMargins() const
753 NSRect frameW = [m_nsWindow frame];
754 NSRect frameC = [m_nsWindow contentRectForFrameRect:frameW];
756 return QMargins(frameW.origin.x - frameC.origin.x,
757 (frameW.origin.y + frameW.size.height) - (frameC.origin.y + frameC.size.height),
758 (frameW.origin.x + frameW.size.width) - (frameC.origin.x + frameC.size.width),
759 frameC.origin.y - frameW.origin.y);
762 void QCocoaWindow::setFrameStrutEventsEnabled(bool enabled)
764 m_frameStrutEventsEnabled = enabled;