summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoawindow.mm
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoawindow.mm')
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 4f95489798..de58842772 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -96,8 +96,8 @@
QCocoaWindow::QCocoaWindow(QWindow *tlw)
: QPlatformWindow(tlw)
, m_nsWindow(0)
- , m_glContext(0)
, m_inConstructor(true)
+ , m_glContext(0)
{
QCocoaAutoReleasePool pool;
@@ -231,9 +231,10 @@ void QCocoaWindow::propagateSizeHints()
if (!window()->sizeIncrement().isNull())
[m_nsWindow setResizeIncrements : qt_mac_toNSSize(window()->sizeIncrement())];
+ QRect rect = geometry();
QSize baseSize = window()->baseSize();
if (!baseSize.isNull() && baseSize.isValid()) {
- [m_nsWindow setFrameSize : NSMakeSize(baseSize.width(), baseSize.height()) display : YES];
+ [m_nsWindow setFrame:NSMakeRect(rect.x(), rect.y(), baseSize.width(), baseSize.height()) display:YES];
}
}
@@ -364,6 +365,30 @@ NSWindow * QCocoaWindow::createNSWindow()
NSUInteger styleMask;
NSWindow *createdWindow = 0;
+ NSInteger windowLevel = -1;
+
+ if (type == Qt::Tool) {
+ windowLevel = NSFloatingWindowLevel;
+ } else if ((type & Qt::Popup) == Qt::Popup) {
+ // styleMask = NSBorderlessWindowMask;
+ windowLevel = NSPopUpMenuWindowLevel;
+
+ // Popup should be in at least the same level as its parent.
+ const QWindow * const transientParent = window()->transientParent();
+ const QCocoaWindow * const transientParentWindow = transientParent ? static_cast<QCocoaWindow *>(transientParent->handle()) : 0;
+ if (transientParentWindow)
+ windowLevel = qMax([transientParentWindow->m_nsWindow level], windowLevel);
+ }
+
+ // StayOnTop window should appear above Tool windows.
+ if (flags & Qt::WindowStaysOnTopHint)
+ windowLevel = NSPopUpMenuWindowLevel;
+ // Tooltips should appear above StayOnTop windows.
+ if (type == Qt::ToolTip)
+ windowLevel = NSScreenSaverWindowLevel;
+ // All other types are Normal level.
+ if (windowLevel == -1)
+ windowLevel = NSNormalWindowLevel;
// Use NSPanel for popup-type windows. (Popup, Tool, ToolTip, SplashScreen)
if ((type & Qt::Popup) == Qt::Popup) {
@@ -403,6 +428,9 @@ NSWindow * QCocoaWindow::createNSWindow()
createdWindow = window;
}
+
+ [createdWindow setLevel:windowLevel];
+
return createdWindow;
}