1910 wclass = kDrawerWindowClass; |
1916 wclass = kDrawerWindowClass; |
1911 else if (q->testAttribute(Qt::WA_ShowModal) && flags & Qt::CustomizeWindowHint) |
1917 else if (q->testAttribute(Qt::WA_ShowModal) && flags & Qt::CustomizeWindowHint) |
1912 wclass = kDocumentWindowClass; |
1918 wclass = kDocumentWindowClass; |
1913 else if(popup || (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5 && type == Qt::SplashScreen)) |
1919 else if(popup || (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5 && type == Qt::SplashScreen)) |
1914 wclass = kModalWindowClass; |
1920 wclass = kModalWindowClass; |
1915 else if(q->testAttribute(Qt::WA_ShowModal) || type == Qt::Dialog) |
1921 else if(type == Qt::Dialog) |
1916 wclass = kMovableModalWindowClass; |
1922 wclass = kMovableModalWindowClass; |
1917 else if(type == Qt::ToolTip) |
1923 else if(type == Qt::ToolTip) |
1918 wclass = kHelpWindowClass; |
1924 wclass = kHelpWindowClass; |
1919 else if(type == Qt::Tool || (QSysInfo::MacintoshVersion < QSysInfo::MV_10_5 |
1925 else if(type == Qt::Tool || (QSysInfo::MacintoshVersion < QSysInfo::MV_10_5 |
1920 && type == Qt::SplashScreen)) |
1926 && type == Qt::SplashScreen)) |
1921 wclass = kFloatingWindowClass; |
1927 wclass = kFloatingWindowClass; |
|
1928 else if(q->testAttribute(Qt::WA_ShowModal)) |
|
1929 wclass = kMovableModalWindowClass; |
1922 else |
1930 else |
1923 wclass = kDocumentWindowClass; |
1931 wclass = kDocumentWindowClass; |
1924 |
1932 |
1925 WindowAttributes wattr = NSBorderlessWindowMask; |
1933 WindowAttributes wattr = NSBorderlessWindowMask; |
1926 if(qt_mac_is_macsheet(q)) { |
1934 if(qt_mac_is_macsheet(q)) { |
2020 WindowAttributes tmp_wattr = wattr; |
2028 WindowAttributes tmp_wattr = wattr; |
2021 qDebug("Qt: internal: ** Attributes:"); |
2029 qDebug("Qt: internal: ** Attributes:"); |
2022 for(int i = 0; tmp_wattr && known_attribs[i].name; i++) { |
2030 for(int i = 0; tmp_wattr && known_attribs[i].name; i++) { |
2023 if((tmp_wattr & known_attribs[i].tag) == known_attribs[i].tag) { |
2031 if((tmp_wattr & known_attribs[i].tag) == known_attribs[i].tag) { |
2024 tmp_wattr ^= known_attribs[i].tag; |
2032 tmp_wattr ^= known_attribs[i].tag; |
2025 qDebug("Qt: internal: * %s %s", known_attribs[i].name, |
|
2026 (GetAvailableWindowAttributes(wclass) & known_attribs[i].tag) ? "" : "(*)"); |
|
2027 } |
2033 } |
2028 } |
2034 } |
2029 if(tmp_wattr) |
2035 if(tmp_wattr) |
2030 qDebug("Qt: internal: !! Attributes: Unknown (%d)", (int)tmp_wattr); |
2036 qDebug("Qt: internal: !! Attributes: Unknown (%d)", (int)tmp_wattr); |
2031 } |
2037 } |
2216 updateFrameStrut(); |
2222 updateFrameStrut(); |
2217 qt_mac_update_sizer(q); |
2223 qt_mac_update_sizer(q); |
2218 applyMaxAndMinSizeOnWindow(); |
2224 applyMaxAndMinSizeOnWindow(); |
2219 } |
2225 } |
2220 #else // QT_MAC_USE_COCOA |
2226 #else // QT_MAC_USE_COCOA |
|
2227 |
|
2228 void QWidgetPrivate::setWindowLevel() |
|
2229 { |
|
2230 Q_Q(QWidget); |
|
2231 const QWidget * const windowParent = q->window()->parentWidget(); |
|
2232 const QWidget * const primaryWindow = windowParent ? windowParent->window() : 0; |
|
2233 NSInteger winLevel = -1; |
|
2234 |
|
2235 if (q->windowType() == Qt::Popup) { |
|
2236 winLevel = NSPopUpMenuWindowLevel; |
|
2237 // Popup should be in at least the same level as its parent. |
|
2238 if (primaryWindow) { |
|
2239 OSWindowRef parentRef = qt_mac_window_for(primaryWindow); |
|
2240 winLevel = qMax([parentRef level], winLevel); |
|
2241 } |
|
2242 } else if (q->windowType() == Qt::Tool) { |
|
2243 winLevel = NSFloatingWindowLevel; |
|
2244 } else if (q->windowType() == Qt::Dialog) { |
|
2245 // Correct modality level (NSModalPanelWindowLevel) will be |
|
2246 // set by cocoa when creating a modal session later. |
|
2247 winLevel = NSNormalWindowLevel; |
|
2248 } |
|
2249 |
|
2250 // StayOnTop window should appear above Tool windows. |
|
2251 if (data.window_flags & Qt::WindowStaysOnTopHint) |
|
2252 winLevel = NSPopUpMenuWindowLevel; |
|
2253 // Tooltips should appear above StayOnTop windows. |
|
2254 if (q->windowType() == Qt::ToolTip) |
|
2255 winLevel = NSScreenSaverWindowLevel; |
|
2256 // All other types are Normal level. |
|
2257 if (winLevel == -1) |
|
2258 winLevel = NSNormalWindowLevel; |
|
2259 [qt_mac_window_for(q) setLevel:winLevel]; |
|
2260 } |
|
2261 |
2221 void QWidgetPrivate::finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ voidWindowRef) |
2262 void QWidgetPrivate::finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ voidWindowRef) |
2222 { |
2263 { |
2223 Q_Q(QWidget); |
2264 Q_Q(QWidget); |
2224 QMacCocoaAutoReleasePool pool; |
2265 QMacCocoaAutoReleasePool pool; |
2225 NSWindow *windowRef = static_cast<NSWindow *>(voidWindowRef); |
2266 NSWindow *windowRef = static_cast<NSWindow *>(voidWindowRef); |
2257 [nsview setFrame:bounds]; |
2298 [nsview setFrame:bounds]; |
2258 [nsview setHidden:NO]; |
2299 [nsview setHidden:NO]; |
2259 if (q->testAttribute(Qt::WA_DropSiteRegistered)) |
2300 if (q->testAttribute(Qt::WA_DropSiteRegistered)) |
2260 registerDropSite(true); |
2301 registerDropSite(true); |
2261 transferChildren(); |
2302 transferChildren(); |
|
2303 |
|
2304 // Tell Cocoa explicit that we wan't the view to receive key events |
|
2305 // (regardless of focus policy) because this is how it works on other |
|
2306 // platforms (and in the carbon port): |
|
2307 if (!qApp->focusWidget()) |
|
2308 [windowRef makeFirstResponder:nsview]; |
2262 } |
2309 } |
2263 |
2310 |
2264 if (topExtra->posFromMove) { |
2311 if (topExtra->posFromMove) { |
2265 updateFrameStrut(); |
2312 updateFrameStrut(); |
2266 |
2313 |
2288 // make sure that we don't report a faulty opacity: |
2335 // make sure that we don't report a faulty opacity: |
2289 q->setWindowOpacity(1.0f); |
2336 q->setWindowOpacity(1.0f); |
2290 q->setAttribute(Qt::WA_WState_WindowOpacitySet, false); |
2337 q->setAttribute(Qt::WA_WState_WindowOpacitySet, false); |
2291 } |
2338 } |
2292 |
2339 |
|
2340 if (qApp->overrideCursor()) |
|
2341 [windowRef disableCursorRects]; |
|
2342 |
|
2343 setWindowLevel(); |
2293 macUpdateHideOnSuspend(); |
2344 macUpdateHideOnSuspend(); |
2294 macUpdateOpaqueSizeGrip(); |
2345 macUpdateOpaqueSizeGrip(); |
2295 macUpdateIgnoreMouseEvents(); |
2346 macUpdateIgnoreMouseEvents(); |
2296 setWindowTitle_helper(extra->topextra->caption); |
2347 setWindowTitle_helper(extra->topextra->caption); |
2297 setWindowIconText_helper(extra->topextra->iconText); |
2348 setWindowIconText_helper(extra->topextra->iconText); |
2562 #endif |
2613 #endif |
2563 setWinId((WId)osview); |
2614 setWinId((WId)osview); |
2564 } |
2615 } |
2565 } else { |
2616 } else { |
2566 data.fstrut_dirty = false; // non-toplevel widgets don't have a frame, so no need to update the strut |
2617 data.fstrut_dirty = false; // non-toplevel widgets don't have a frame, so no need to update the strut |
2567 if(OSViewRef osview = qt_mac_create_widget(q, this, qt_mac_nativeview_for(parentWidget))) { |
2618 |
|
2619 #ifdef QT_MAC_USE_COCOA |
|
2620 if (q->testAttribute(Qt::WA_NativeWindow) == false || |
|
2621 q->internalWinId() != 0) { |
|
2622 #ifdef ALIEN_DEBUG |
|
2623 qDebug() << "Skipping native widget creation for" << this; |
|
2624 #endif |
|
2625 } else |
|
2626 #endif |
|
2627 if (OSViewRef osview = qt_mac_create_widget(q, this, qt_mac_nativeview_for(parentWidget))) { |
2568 #ifndef QT_MAC_USE_COCOA |
2628 #ifndef QT_MAC_USE_COCOA |
2569 HIRect bounds = CGRectMake(data.crect.x(), data.crect.y(), data.crect.width(), data.crect.height()); |
2629 HIRect bounds = CGRectMake(data.crect.x(), data.crect.y(), data.crect.width(), data.crect.height()); |
2570 HIViewSetFrame(osview, &bounds); |
2630 HIViewSetFrame(osview, &bounds); |
2571 setWinId((WId)osview); |
2631 setWinId((WId)osview); |
2572 #else |
2632 #else |
2718 } |
2778 } |
2719 } |
2779 } |
2720 } |
2780 } |
2721 } |
2781 } |
2722 |
2782 |
|
2783 #ifdef QT_MAC_USE_COCOA |
|
2784 void QWidgetPrivate::setSubWindowStacking(bool set) |
|
2785 { |
|
2786 Q_Q(QWidget); |
|
2787 if (!q->isWindow() || !q->testAttribute(Qt::WA_WState_Created)) |
|
2788 return; |
|
2789 |
|
2790 if (QWidget *parent = q->parentWidget()) { |
|
2791 if (parent->testAttribute(Qt::WA_WState_Created)) { |
|
2792 if (set) |
|
2793 [qt_mac_window_for(parent) addChildWindow:qt_mac_window_for(q) ordered:NSWindowAbove]; |
|
2794 else |
|
2795 [qt_mac_window_for(parent) removeChildWindow:qt_mac_window_for(q)]; |
|
2796 } |
|
2797 } |
|
2798 |
|
2799 QList<QWidget *> widgets = q->findChildren<QWidget *>(); |
|
2800 for (int i=0; i<widgets.size(); ++i) { |
|
2801 QWidget *child = widgets.at(i); |
|
2802 if (child->isWindow() && child->testAttribute(Qt::WA_WState_Created)) { |
|
2803 if (set) |
|
2804 [qt_mac_window_for(q) addChildWindow:qt_mac_window_for(child) ordered:NSWindowAbove]; |
|
2805 else |
|
2806 [qt_mac_window_for(q) removeChildWindow:qt_mac_window_for(child)]; |
|
2807 } |
|
2808 } |
|
2809 } |
|
2810 #endif |
|
2811 |
2723 void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f) |
2812 void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f) |
2724 { |
2813 { |
2725 Q_Q(QWidget); |
2814 Q_Q(QWidget); |
2726 QMacCocoaAutoReleasePool pool; |
2815 QMacCocoaAutoReleasePool pool; |
2727 QTLWExtra *topData = maybeTopData(); |
2816 QTLWExtra *topData = maybeTopData(); |
2778 if (q->testAttribute(Qt::WA_DropSiteRegistered)) |
2867 if (q->testAttribute(Qt::WA_DropSiteRegistered)) |
2779 q->setAttribute(Qt::WA_DropSiteRegistered, false); |
2868 q->setAttribute(Qt::WA_DropSiteRegistered, false); |
2780 |
2869 |
2781 //recreate and setup flags |
2870 //recreate and setup flags |
2782 QObjectPrivate::setParent_helper(parent); |
2871 QObjectPrivate::setParent_helper(parent); |
2783 QPoint pt = q->pos(); |
|
2784 bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide); |
2872 bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide); |
2785 if (wasCreated && !qt_isGenuineQWidget(q)) |
2873 if (wasCreated && !qt_isGenuineQWidget(q)) |
2786 return; |
2874 return; |
2787 |
2875 |
2788 if ((data.window_flags & Qt::Sheet) && topData && topData->opacity == 242) |
2876 if (!q->testAttribute(Qt::WA_WState_WindowOpacitySet)) { |
2789 q->setWindowOpacity(1.0f); |
2877 q->setWindowOpacity(1.0f); |
|
2878 q->setAttribute(Qt::WA_WState_WindowOpacitySet, false); |
|
2879 } |
2790 |
2880 |
2791 setWinId(0); //do after the above because they may want the id |
2881 setWinId(0); //do after the above because they may want the id |
2792 |
2882 |
2793 data.window_flags = f; |
2883 data.window_flags = f; |
2794 q->setAttribute(Qt::WA_WState_Created, false); |
2884 q->setAttribute(Qt::WA_WState_Created, false); |
2795 q->setAttribute(Qt::WA_WState_Visible, false); |
2885 q->setAttribute(Qt::WA_WState_Visible, false); |
2796 q->setAttribute(Qt::WA_WState_Hidden, false); |
2886 q->setAttribute(Qt::WA_WState_Hidden, false); |
2797 adjustFlags(data.window_flags, q); |
2887 adjustFlags(data.window_flags, q); |
2798 // keep compatibility with previous versions, we need to preserve the created state |
2888 // keep compatibility with previous versions, we need to preserve the created state. |
2799 // (but we recreate the winId for the widget being reparented, again for compatibility) |
2889 // (but we recreate the winId for the widget being reparented, again for compatibility, |
2800 if (wasCreated || (!q->isWindow() && parent->testAttribute(Qt::WA_WState_Created))) { |
2890 // unless this is an alien widget. ) |
|
2891 const bool nonWindowWithCreatedParent = !q->isWindow() && parent->testAttribute(Qt::WA_WState_Created); |
|
2892 const bool nativeWidget = q->internalWinId() != 0; |
|
2893 if (wasCreated || nativeWidget && nonWindowWithCreatedParent) { |
2801 createWinId(); |
2894 createWinId(); |
2802 if (q->isWindow()) { |
2895 if (q->isWindow()) { |
2803 #ifndef QT_MAC_USE_COCOA |
2896 #ifndef QT_MAC_USE_COCOA |
2804 // We do this down below for wasCreated, so avoid doing this twice |
2897 // We do this down below for wasCreated, so avoid doing this twice |
2805 // (only for performance, it gets called a lot anyway). |
2898 // (only for performance, it gets called a lot anyway). |
2872 if (current->isWindow()) |
2965 if (current->isWindow()) |
2873 break; |
2966 break; |
2874 current = current->parentWidget(); |
2967 current = current->parentWidget(); |
2875 } |
2968 } |
2876 } |
2969 } |
2877 |
|
2878 invalidateBuffer(q->rect()); |
2970 invalidateBuffer(q->rect()); |
2879 qt_event_request_window_change(q); |
2971 qt_event_request_window_change(q); |
2880 } |
2972 } |
2881 |
2973 |
2882 QPoint QWidget::mapToGlobal(const QPoint &pos) const |
2974 QPoint QWidget::mapToGlobal(const QPoint &pos) const |
2883 { |
2975 { |
2884 Q_D(const QWidget); |
2976 Q_D(const QWidget); |
2885 if (!testAttribute(Qt::WA_WState_Created)) { |
2977 if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) { |
2886 QPoint p = pos + data->crect.topLeft(); |
2978 QPoint p = pos + data->crect.topLeft(); |
2887 return isWindow() ? p : parentWidget()->mapToGlobal(p); |
2979 return isWindow() ? p : parentWidget()->mapToGlobal(p); |
2888 } |
2980 } |
2889 #ifndef QT_MAC_USE_COCOA |
2981 #ifndef QT_MAC_USE_COCOA |
2890 QPoint tmp = d->mapToWS(pos); |
2982 QPoint tmp = d->mapToWS(pos); |
3178 || (tlw->windowType() == Qt::Tool) |
3270 || (tlw->windowType() == Qt::Tool) |
3179 || qt_mac_is_macdrawer(tlw) |
3271 || qt_mac_is_macdrawer(tlw) |
3180 || windowActive) { |
3272 || windowActive) { |
3181 #ifndef QT_MAC_USE_COCOA |
3273 #ifndef QT_MAC_USE_COCOA |
3182 ActivateWindow(win, true); |
3274 ActivateWindow(win, true); |
|
3275 qApp->setActiveWindow(tlw); |
3183 #else |
3276 #else |
3184 [win makeKeyWindow]; |
3277 [win makeKeyWindow]; |
3185 #endif |
3278 #endif |
3186 qApp->setActiveWindow(tlw); |
|
3187 } else if(!isMinimized()) { |
3279 } else if(!isMinimized()) { |
3188 #ifndef QT_MAC_USE_COCOA |
3280 #ifndef QT_MAC_USE_COCOA |
3189 SelectWindow(win); |
3281 SelectWindow(win); |
3190 #else |
3282 #else |
3191 [win makeKeyAndOrderFront:win]; |
3283 [win makeKeyAndOrderFront:win]; |
3244 HIViewSetNeedsDisplayInRegion(qt_mac_nativeview_for(q), QMacSmartQuickDrawRegion(rgnHandle), true); |
3336 HIViewSetNeedsDisplayInRegion(qt_mac_nativeview_for(q), QMacSmartQuickDrawRegion(rgnHandle), true); |
3245 else { |
3337 else { |
3246 HIViewSetNeedsDisplay(qt_mac_nativeview_for(q), true); // do a complete repaint on overflow. |
3338 HIViewSetNeedsDisplay(qt_mac_nativeview_for(q), true); // do a complete repaint on overflow. |
3247 } |
3339 } |
3248 #else |
3340 #else |
3249 // Cocoa doesn't do regions, it seems more efficient to just update the bounding rect instead of a potential number of message passes for each rect. |
3341 // Alien support: get the first native ancestor widget (will be q itself in the non-alien case), |
3250 const QRect &boundingRect = rgn.boundingRect(); |
3342 // map the coordinates from q space to NSView space and invalidate the rect. |
3251 [qt_mac_nativeview_for(q) setNeedsDisplayInRect:NSMakeRect(boundingRect.x(), |
3343 QWidget *nativeParent = q->internalWinId() ? q : q->nativeParentWidget(); |
3252 boundingRect.y(), boundingRect.width(), |
3344 if (nativeParent == 0) |
3253 boundingRect.height())]; |
3345 return; |
|
3346 |
|
3347 QVector<QRect> rects = rgn.rects(); |
|
3348 for (int i = 0; i < rects.count(); ++i) { |
|
3349 const QRect &rect = rects.at(i); |
|
3350 |
|
3351 const QRect nativeBoundingRect = QRect( |
|
3352 QPoint(q->mapTo(nativeParent, rect.topLeft())), |
|
3353 QSize(rect.size())); |
|
3354 |
|
3355 [qt_mac_nativeview_for(nativeParent) setNeedsDisplayInRect:NSMakeRect(nativeBoundingRect.x(), |
|
3356 nativeBoundingRect.y(), nativeBoundingRect.width(), |
|
3357 nativeBoundingRect.height())]; |
|
3358 } |
3254 #endif |
3359 #endif |
3255 } |
3360 } |
3256 |
3361 |
3257 bool QWidgetPrivate::isRealWindow() const |
3362 bool QWidgetPrivate::isRealWindow() const |
3258 { |
3363 { |
3272 q->setAttribute(Qt::WA_Mapped); |
3377 q->setAttribute(Qt::WA_Mapped); |
3273 if (q->testAttribute(Qt::WA_DontShowOnScreen)) |
3378 if (q->testAttribute(Qt::WA_DontShowOnScreen)) |
3274 return; |
3379 return; |
3275 |
3380 |
3276 bool realWindow = isRealWindow(); |
3381 bool realWindow = isRealWindow(); |
|
3382 #ifndef QT_MAC_USE_COCOA |
3277 if (realWindow && !q->testAttribute(Qt::WA_Moved)) { |
3383 if (realWindow && !q->testAttribute(Qt::WA_Moved)) { |
|
3384 if (qt_mac_is_macsheet(q)) |
|
3385 recreateMacWindow(); |
3278 q->createWinId(); |
3386 q->createWinId(); |
3279 if (QWidget *p = q->parentWidget()) { |
3387 if (QWidget *p = q->parentWidget()) { |
3280 p->createWinId(); |
3388 p->createWinId(); |
3281 #ifndef QT_MAC_USE_COCOA |
|
3282 RepositionWindow(qt_mac_window_for(q), qt_mac_window_for(p), kWindowCenterOnParentWindow); |
3389 RepositionWindow(qt_mac_window_for(q), qt_mac_window_for(p), kWindowCenterOnParentWindow); |
3283 #else |
|
3284 CGRect parentFrame = NSRectToCGRect([qt_mac_window_for(p) frame]); |
|
3285 OSWindowRef windowRef = qt_mac_window_for(q); |
|
3286 NSRect windowFrame = [windowRef frame]; |
|
3287 NSPoint parentCenter = NSMakePoint(CGRectGetMidX(parentFrame), CGRectGetMidY(parentFrame)); |
|
3288 [windowRef setFrameTopLeftPoint:NSMakePoint(parentCenter.x - (windowFrame.size.width / 2), |
|
3289 (parentCenter.y + (windowFrame.size.height / 2)))]; |
|
3290 #endif |
|
3291 } else { |
3390 } else { |
3292 #ifndef QT_MAC_USE_COCOA |
|
3293 RepositionWindow(qt_mac_window_for(q), 0, kWindowCenterOnMainScreen); |
3391 RepositionWindow(qt_mac_window_for(q), 0, kWindowCenterOnMainScreen); |
3294 #else |
3392 } |
3295 // Ideally we would do a "center" here, but NSWindow's center is more equivalent to |
3393 } |
3296 // kWindowAlertPositionOnMainScreen instead of kWindowCenterOnMainScreen. |
3394 #endif |
3297 QRect availGeo = QApplication::desktop()->availableGeometry(q); |
3395 |
3298 // Center the content only. |
|
3299 data.crect.moveCenter(availGeo.center()); |
|
3300 QRect fStrut = frameStrut(); |
|
3301 QRect frameRect(data.crect.x() - fStrut.left(), data.crect.y() - fStrut.top(), |
|
3302 fStrut.left() + fStrut.right() + data.crect.width(), |
|
3303 fStrut.top() + fStrut.bottom() + data.crect.height()); |
|
3304 NSRect cocoaFrameRect = NSMakeRect(frameRect.x(), flipYCoordinate(frameRect.bottom() + 1), frameRect.width(), frameRect.height()); |
|
3305 [qt_mac_window_for(q) setFrame:cocoaFrameRect display:NO]; |
|
3306 #endif |
|
3307 } |
|
3308 } |
|
3309 data.fstrut_dirty = true; |
3396 data.fstrut_dirty = true; |
3310 if (realWindow) { |
3397 if (realWindow) { |
3311 // Delegates can change window state, so record some things earlier. |
3398 // Delegates can change window state, so record some things earlier. |
3312 bool isCurrentlyMinimized = (q->windowState() & Qt::WindowMinimized); |
3399 bool isCurrentlyMinimized = (q->windowState() & Qt::WindowMinimized); |
3313 setModal_sys(); |
3400 setModal_sys(); |
3334 #ifndef QT_MAC_USE_COCOA |
3421 #ifndef QT_MAC_USE_COCOA |
3335 ShowHide(window, true); |
3422 ShowHide(window, true); |
3336 #else |
3423 #else |
3337 // sync the opacity value back (in case of a fade). |
3424 // sync the opacity value back (in case of a fade). |
3338 [window setAlphaValue:q->windowOpacity()]; |
3425 [window setAlphaValue:q->windowOpacity()]; |
3339 [window makeKeyAndOrderFront:window]; |
3426 setSubWindowStacking(true); |
3340 |
3427 |
3341 // If this window is app modal, we need to start spinning |
3428 QWidget *top = 0; |
3342 // a modal session for it. Interrupting |
3429 if (QApplicationPrivate::tryModalHelper(q, &top)) { |
3343 // the event dispatcher will make this happend: |
3430 [window makeKeyAndOrderFront:window]; |
3344 if (data.window_modality == Qt::ApplicationModal) |
3431 // If this window is app modal, we need to start spinning |
3345 QEventDispatcherMac::instance()->interrupt(); |
3432 // a modal session for it. Interrupting |
|
3433 // the event dispatcher will make this happend: |
|
3434 if (data.window_modality == Qt::ApplicationModal) |
|
3435 QEventDispatcherMac::instance()->interrupt(); |
|
3436 } else { |
|
3437 // The window is modally shaddowed, so we need to make |
|
3438 // sure that we don't pop in front of the modal window: |
|
3439 [window orderFront:window]; |
|
3440 if (!top->testAttribute(Qt::WA_DontShowOnScreen)) { |
|
3441 if (NSWindow *modalWin = qt_mac_window_for(top)) |
|
3442 [modalWin orderFront:window]; |
|
3443 } |
|
3444 } |
3346 #endif |
3445 #endif |
3347 if (q->windowType() == Qt::Popup) { |
3446 if (q->windowType() == Qt::Popup) { |
3348 if (q->focusWidget()) |
3447 if (q->focusWidget()) |
3349 q->focusWidget()->d_func()->setFocus_sys(); |
3448 q->focusWidget()->d_func()->setFocus_sys(); |
3350 else |
3449 else |
3359 [window miniaturize:window]; |
3458 [window miniaturize:window]; |
3360 #endif |
3459 #endif |
3361 } else if (!q->testAttribute(Qt::WA_ShowWithoutActivating)) { |
3460 } else if (!q->testAttribute(Qt::WA_ShowWithoutActivating)) { |
3362 #ifndef QT_MAC_USE_COCOA |
3461 #ifndef QT_MAC_USE_COCOA |
3363 qt_event_request_activate(q); |
3462 qt_event_request_activate(q); |
3364 #else |
|
3365 [qt_mac_window_for(q) makeKeyWindow]; |
|
3366 #endif |
3463 #endif |
3367 } |
3464 } |
3368 } else if(topData()->embedded || !q->parentWidget() || q->parentWidget()->isVisible()) { |
3465 } else if(topData()->embedded || !q->parentWidget() || q->parentWidget()->isVisible()) { |
3369 #ifndef QT_MAC_USE_COCOA |
3466 #ifndef QT_MAC_USE_COCOA |
3370 HIViewSetVisible(qt_mac_nativeview_for(q), true); |
3467 HIViewSetVisible(qt_mac_nativeview_for(q), true); |
3402 Q_Q(QWidget); |
3499 Q_Q(QWidget); |
3403 if((q->windowType() == Qt::Desktop)) //you can't hide the desktop! |
3500 if((q->windowType() == Qt::Desktop)) //you can't hide the desktop! |
3404 return; |
3501 return; |
3405 QMacCocoaAutoReleasePool pool; |
3502 QMacCocoaAutoReleasePool pool; |
3406 if(q->isWindow()) { |
3503 if(q->isWindow()) { |
|
3504 #ifdef QT_MAC_USE_COCOA |
|
3505 setSubWindowStacking(false); |
|
3506 #endif |
3407 OSWindowRef window = qt_mac_window_for(q); |
3507 OSWindowRef window = qt_mac_window_for(q); |
3408 if(qt_mac_is_macsheet(q)) { |
3508 if(qt_mac_is_macsheet(q)) { |
3409 #ifndef QT_MAC_USE_COCOA |
3509 #ifndef QT_MAC_USE_COCOA |
3410 WindowRef parent = 0; |
3510 WindowRef parent = 0; |
3411 if(GetSheetWindowParent(window, &parent) != noErr || !parent) |
3511 if(GetSheetWindowParent(window, &parent) != noErr || !parent) |
3467 SetWindowModality(window, kWindowModalityNone, |
3567 SetWindowModality(window, kWindowModalityNone, |
3468 q->parentWidget() ? qt_mac_window_for(q->parentWidget()->window()) : 0); |
3568 q->parentWidget() ? qt_mac_window_for(q->parentWidget()->window()) : 0); |
3469 } |
3569 } |
3470 #endif |
3570 #endif |
3471 } |
3571 } |
3472 if(q->isActiveWindow() && !(q->windowType() == Qt::Popup)) { |
3572 #ifndef QT_MAC_USE_COCOA |
|
3573 // If the window we now hide was the active window, we need |
|
3574 // to find, and activate another window on screen. NB: Cocoa takes care of this |
|
3575 // logic for us (and distinquishes between main windows and key windows) |
|
3576 if (q->isActiveWindow() && !(q->windowType() == Qt::Popup)) { |
3473 QWidget *w = 0; |
3577 QWidget *w = 0; |
3474 if(q->parentWidget()) |
3578 if(q->parentWidget()) |
3475 w = q->parentWidget()->window(); |
3579 w = q->parentWidget()->window(); |
3476 if(!w || (!w->isVisible() && !w->isMinimized())) { |
3580 if(!w || (!w->isVisible() && !w->isMinimized())) { |
3477 #ifndef QT_MAC_USE_COCOA |
|
3478 for (WindowPtr wp = GetFrontWindowOfClass(kMovableModalWindowClass, true); |
3581 for (WindowPtr wp = GetFrontWindowOfClass(kMovableModalWindowClass, true); |
3479 wp; wp = GetNextWindowOfClass(wp, kMovableModalWindowClass, true)) { |
3582 wp; wp = GetNextWindowOfClass(wp, kMovableModalWindowClass, true)) { |
3480 if((w = qt_mac_find_window(wp))) |
3583 if((w = qt_mac_find_window(wp))) |
3481 break; |
3584 break; |
3482 } |
3585 } |
3492 wp; wp = GetNextWindowOfClass(wp, kSimpleWindowClass, true)) { |
3595 wp; wp = GetNextWindowOfClass(wp, kSimpleWindowClass, true)) { |
3493 if((w = qt_mac_find_window(wp))) |
3596 if((w = qt_mac_find_window(wp))) |
3494 break; |
3597 break; |
3495 } |
3598 } |
3496 } |
3599 } |
3497 #else |
|
3498 NSArray *windows = [NSApp windows]; |
|
3499 NSUInteger totalWindows = [windows count]; |
|
3500 for (NSUInteger i = 0; i < totalWindows; ++i) { |
|
3501 OSWindowRef wp = [windows objectAtIndex:i]; |
|
3502 if ((w = qt_mac_find_window(wp))) |
|
3503 break; |
|
3504 } |
|
3505 #endif |
|
3506 } |
3600 } |
3507 if(w && w->isVisible() && !w->isMinimized()) { |
3601 if(w && w->isVisible() && !w->isMinimized()) { |
3508 #ifndef QT_MAC_USE_COCOA |
3602 qt_event_request_activate(w); |
3509 qt_event_request_activate(w); |
3603 } |
3510 #else |
3604 } |
3511 [qt_mac_window_for(w) makeKeyWindow]; |
3605 #endif |
3512 #endif |
|
3513 } |
|
3514 } |
|
3515 } else { |
3606 } else { |
3516 invalidateBuffer(q->rect()); |
3607 invalidateBuffer(q->rect()); |
3517 #ifndef QT_MAC_USE_COCOA |
3608 #ifndef QT_MAC_USE_COCOA |
3518 HIViewSetVisible(qt_mac_nativeview_for(q), false); |
3609 HIViewSetVisible(qt_mac_nativeview_for(q), false); |
3519 #else |
3610 #else |
3731 return; |
3822 return; |
3732 |
3823 |
3733 #if QT_MAC_USE_COCOA |
3824 #if QT_MAC_USE_COCOA |
3734 QMacCocoaAutoReleasePool pool; |
3825 QMacCocoaAutoReleasePool pool; |
3735 if (isRealWindow()) { |
3826 if (isRealWindow()) { |
3736 // Calling orderFront shows the window on Cocoa too. |
3827 // With the introduction of spaces it is not as simple as just raising the window. |
|
3828 // First we need to check if we are in the right space. If we are, then we just continue |
|
3829 // as usual. The problem comes when we are not in the active space. There are two main cases: |
|
3830 // 1. Our parent was moved to a new space. In this case we want the window to be raised |
|
3831 // in the same space as its parent. |
|
3832 // 2. We don't have a parent. For this case we will just raise the window and let Cocoa |
|
3833 // switch to the corresponding space. |
|
3834 // NOTICE: There are a lot of corner cases here. We are keeping this simple for now, if |
|
3835 // required we will introduce special handling for some of them. |
3737 if (!q->testAttribute(Qt::WA_DontShowOnScreen) && q->isVisible()) { |
3836 if (!q->testAttribute(Qt::WA_DontShowOnScreen) && q->isVisible()) { |
3738 [qt_mac_window_for(q) orderFront:qt_mac_window_for(q)]; |
3837 OSWindowRef window = qt_mac_window_for(q); |
|
3838 // isOnActiveSpace is available only from 10.6 onwards, so we need to check if it is |
|
3839 // available before calling it. |
|
3840 if([window respondsToSelector:@selector(isOnActiveSpace)]) { |
|
3841 if(![window performSelector:@selector(isOnActiveSpace)]) { |
|
3842 QWidget *parentWidget = q->parentWidget(); |
|
3843 if(parentWidget) { |
|
3844 OSWindowRef parentWindow = qt_mac_window_for(parentWidget); |
|
3845 if(parentWindow && [parentWindow isOnActiveSpace]) { |
|
3846 // The window was created in a different space. Therefore if we want |
|
3847 // to show it in the current space we need to recreate it in the new |
|
3848 // space. |
|
3849 recreateMacWindow(); |
|
3850 window = qt_mac_window_for(q); |
|
3851 } |
|
3852 } |
|
3853 } |
|
3854 } |
|
3855 [window orderFront:window]; |
3739 } |
3856 } |
3740 if (qt_mac_raise_process) { //we get to be the active process now |
3857 if (qt_mac_raise_process) { //we get to be the active process now |
3741 ProcessSerialNumber psn; |
3858 ProcessSerialNumber psn; |
3742 GetCurrentProcess(&psn); |
3859 GetCurrentProcess(&psn); |
3743 SetFrontProcessWithOptions(&psn, kSetFrontProcessFrontWindowOnly); |
3860 SetFrontProcessWithOptions(&psn, kSetFrontProcessFrontWindowOnly); |
3846 /* |
3963 /* |
3847 Modifies the bounds for a widgets backing HIView during moves and resizes. Also updates the |
3964 Modifies the bounds for a widgets backing HIView during moves and resizes. Also updates the |
3848 widget, either by scrolling its contents or repainting, depending on the WA_StaticContents |
3965 widget, either by scrolling its contents or repainting, depending on the WA_StaticContents |
3849 flag |
3966 flag |
3850 */ |
3967 */ |
3851 static void qt_mac_update_widget_posisiton(QWidget *q, QRect oldRect, QRect newRect) |
3968 static void qt_mac_update_widget_position(QWidget *q, QRect oldRect, QRect newRect) |
3852 { |
3969 { |
3853 #ifndef QT_MAC_USE_COCOA |
3970 #ifndef QT_MAC_USE_COCOA |
3854 HIRect bounds = CGRectMake(newRect.x(), newRect.y(), |
3971 HIRect bounds = CGRectMake(newRect.x(), newRect.y(), |
3855 newRect.width(), newRect.height()); |
3972 newRect.width(), newRect.height()); |
3856 |
3973 |
3943 const HIRect horizontalSlice = CGRectMake(0, starty, startx, stopy); |
4060 const HIRect horizontalSlice = CGRectMake(0, starty, startx, stopy); |
3944 HIViewSetNeedsDisplayInRect(view, &horizontalSlice, true); |
4061 HIViewSetNeedsDisplayInRect(view, &horizontalSlice, true); |
3945 #else |
4062 #else |
3946 Q_UNUSED(oldRect); |
4063 Q_UNUSED(oldRect); |
3947 NSRect bounds = NSMakeRect(newRect.x(), newRect.y(), |
4064 NSRect bounds = NSMakeRect(newRect.x(), newRect.y(), |
3948 newRect.width(), newRect.height()); |
4065 newRect.width(), newRect.height()); |
3949 [qt_mac_nativeview_for(q) setFrame:bounds]; |
4066 [qt_mac_nativeview_for(q) setFrame:bounds]; |
3950 #endif |
4067 #endif |
3951 } |
4068 } |
3952 |
4069 |
3953 /* |
4070 /* |
3980 QRect wrect; |
4097 QRect wrect; |
3981 //xrect is the X geometry of my X widget. (starts out in parent's Qt coord sys, and ends up in parent's X coord sys) |
4098 //xrect is the X geometry of my X widget. (starts out in parent's Qt coord sys, and ends up in parent's X coord sys) |
3982 QRect xrect = data.crect; |
4099 QRect xrect = data.crect; |
3983 |
4100 |
3984 QRect parentWRect; |
4101 QRect parentWRect; |
3985 if (q->isWindow() && topData()->embedded) { |
4102 bool isEmbeddedWindow = (q->isWindow() && topData()->embedded); |
|
4103 if (isEmbeddedWindow) { |
3986 #ifndef QT_MAC_USE_COCOA |
4104 #ifndef QT_MAC_USE_COCOA |
3987 HIViewRef parentView = HIViewGetSuperview(qt_mac_nativeview_for(q)); |
4105 HIViewRef parentView = HIViewGetSuperview(qt_mac_nativeview_for(q)); |
3988 #else |
4106 #else |
3989 NSView *parentView = [qt_mac_nativeview_for(q) superview]; |
4107 NSView *parentView = [qt_mac_nativeview_for(q) superview]; |
3990 #endif |
4108 #endif |
4005 parentWRect = q->parentWidget()->data->wrect; |
4123 parentWRect = q->parentWidget()->data->wrect; |
4006 } |
4124 } |
4007 |
4125 |
4008 if (parentWRect.isValid()) { |
4126 if (parentWRect.isValid()) { |
4009 // parent is clipped, and we have to clip to the same limit as parent |
4127 // parent is clipped, and we have to clip to the same limit as parent |
4010 if (!parentWRect.contains(xrect)) { |
4128 if (!parentWRect.contains(xrect) && !isEmbeddedWindow) { |
4011 xrect &= parentWRect; |
4129 xrect &= parentWRect; |
4012 wrect = xrect; |
4130 wrect = xrect; |
4013 //translate from parent's to my Qt coord sys |
4131 //translate from parent's to my Qt coord sys |
4014 wrect.translate(-data.crect.topLeft()); |
4132 wrect.translate(-data.crect.topLeft()); |
4015 } |
4133 } |
4179 if(q->windowType() == Qt::Desktop) |
4297 if(q->windowType() == Qt::Desktop) |
4180 return; |
4298 return; |
4181 |
4299 |
4182 QMacCocoaAutoReleasePool pool; |
4300 QMacCocoaAutoReleasePool pool; |
4183 bool realWindow = isRealWindow(); |
4301 bool realWindow = isRealWindow(); |
|
4302 BOOL needDisplay = realWindow ? YES : NO; |
4184 |
4303 |
4185 if (realWindow && !q->testAttribute(Qt::WA_DontShowOnScreen)){ |
4304 if (realWindow && !q->testAttribute(Qt::WA_DontShowOnScreen)){ |
4186 adjustWithinMaxAndMinSize(w, h); |
4305 adjustWithinMaxAndMinSize(w, h); |
4187 #ifndef QT_MAC_USE_COCOA |
4306 #ifndef QT_MAC_USE_COCOA |
4188 if (w != 0 && h != 0) { |
4307 if (w != 0 && h != 0) { |
4193 topData()->isSetGeometry = 0; |
4312 topData()->isSetGeometry = 0; |
4194 } else { |
4313 } else { |
4195 setGeometry_sys_helper(x, y, w, h, isMove); |
4314 setGeometry_sys_helper(x, y, w, h, isMove); |
4196 } |
4315 } |
4197 #else |
4316 #else |
|
4317 if (!isMove && !q->testAttribute(Qt::WA_Moved) && !q->isVisible()) { |
|
4318 // INVARIANT: The location of the window has not yet been set. The default will |
|
4319 // instead be to center it on the desktop, or over the parent, if any. Since we now |
|
4320 // resize the window, we need to adjust the top left position to keep the window |
|
4321 // centeralized. And we need to to this now (and before show) in case the positioning |
|
4322 // of other windows (e.g. sub-windows) depend on this position: |
|
4323 if (QWidget *p = q->parentWidget()) { |
|
4324 x = p->geometry().center().x() - (w / 2); |
|
4325 y = p->geometry().center().y() - (h / 2); |
|
4326 } else { |
|
4327 QRect availGeo = QApplication::desktop()->availableGeometry(q); |
|
4328 x = availGeo.center().x() - (w / 2); |
|
4329 y = availGeo.center().y() - (h / 2); |
|
4330 } |
|
4331 } |
|
4332 |
4198 QSize olds = q->size(); |
4333 QSize olds = q->size(); |
4199 const bool isResize = (olds != QSize(w, h)); |
4334 const bool isResize = (olds != QSize(w, h)); |
4200 NSWindow *window = qt_mac_window_for(q); |
4335 NSWindow *window = qt_mac_window_for(q); |
4201 const QRect &fStrut = frameStrut(); |
4336 const QRect &fStrut = frameStrut(); |
4202 const QRect frameRect(QPoint(x - fStrut.left(), y - fStrut.top()), |
4337 const QRect frameRect(QPoint(x - fStrut.left(), y - fStrut.top()), |
4210 q->setAttribute(Qt::WA_PendingResizeEvent); |
4345 q->setAttribute(Qt::WA_PendingResizeEvent); |
4211 QPoint currTopLeft = data.crect.topLeft(); |
4346 QPoint currTopLeft = data.crect.topLeft(); |
4212 if (currTopLeft.x() == x && currTopLeft.y() == y |
4347 if (currTopLeft.x() == x && currTopLeft.y() == y |
4213 && cocoaFrameRect.size.width != 0 |
4348 && cocoaFrameRect.size.width != 0 |
4214 && cocoaFrameRect.size.height != 0) { |
4349 && cocoaFrameRect.size.height != 0) { |
4215 [window setFrame:cocoaFrameRect display:NO]; |
4350 [window setFrame:cocoaFrameRect display:needDisplay]; |
4216 } else { |
4351 } else { |
4217 // The window is moved and resized (or resized to zero). |
4352 // The window is moved and resized (or resized to zero). |
4218 // Since Cocoa usually only sends us a resize callback after |
4353 // Since Cocoa usually only sends us a resize callback after |
4219 // setting a window frame, we issue an explicit move as |
4354 // setting a window frame, we issue an explicit move as |
4220 // well. To stop Cocoa from optimize away the move (since the move |
4355 // well. To stop Cocoa from optimize away the move (since the move |
4221 // would have the same origin as the setFrame call) we shift the |
4356 // would have the same origin as the setFrame call) we shift the |
4222 // window back and forth inbetween. |
4357 // window back and forth inbetween. |
4223 cocoaFrameRect.origin.y += 1; |
4358 cocoaFrameRect.origin.y += 1; |
4224 [window setFrame:cocoaFrameRect display:NO]; |
4359 [window setFrame:cocoaFrameRect display:needDisplay]; |
4225 cocoaFrameRect.origin.y -= 1; |
4360 cocoaFrameRect.origin.y -= 1; |
4226 [window setFrameOrigin:cocoaFrameRect.origin]; |
4361 [window setFrameOrigin:cocoaFrameRect.origin]; |
4227 } |
4362 } |
4228 #endif |
4363 #endif |
4229 } else { |
4364 } else { |
4609 if (!q->testAttribute(Qt::WA_WState_Created)) |
4744 if (!q->testAttribute(Qt::WA_WState_Created)) |
4610 return; |
4745 return; |
4611 #ifndef QT_MAC_USE_COCOA |
4746 #ifndef QT_MAC_USE_COCOA |
4612 SetControlDragTrackingEnabled(qt_mac_nativeview_for(q), on); |
4747 SetControlDragTrackingEnabled(qt_mac_nativeview_for(q), on); |
4613 #else |
4748 #else |
4614 NSView *view = qt_mac_nativeview_for(q); |
4749 NSWindow *win = qt_mac_window_for(q); |
4615 if (on && [view isKindOfClass:[QT_MANGLE_NAMESPACE(QCocoaView) class]]) { |
4750 if (on) { |
4616 [static_cast<QT_MANGLE_NAMESPACE(QCocoaView) *>(view) registerDragTypes]; |
4751 if ([win isKindOfClass:[QT_MANGLE_NAMESPACE(QCocoaWindow) class]]) |
|
4752 [static_cast<QT_MANGLE_NAMESPACE(QCocoaWindow) *>(win) registerDragTypes]; |
|
4753 else if ([win isKindOfClass:[QT_MANGLE_NAMESPACE(QCocoaPanel) class]]) |
|
4754 [static_cast<QT_MANGLE_NAMESPACE(QCocoaPanel) *>(win) registerDragTypes]; |
4617 } |
4755 } |
4618 #endif |
4756 #endif |
4619 } |
4757 } |
4620 |
4758 |
4621 void QWidgetPrivate::registerTouchWindow() |
4759 void QWidgetPrivate::registerTouchWindow() |
4767 #ifdef QT_MAC_USE_COCOA |
4905 #ifdef QT_MAC_USE_COCOA |
4768 QMacCocoaAutoReleasePool pool; |
4906 QMacCocoaAutoReleasePool pool; |
4769 bool alreadySheet = [windowRef styleMask] & NSDocModalWindowMask; |
4907 bool alreadySheet = [windowRef styleMask] & NSDocModalWindowMask; |
4770 |
4908 |
4771 if (windowParent && q->windowModality() == Qt::WindowModal){ |
4909 if (windowParent && q->windowModality() == Qt::WindowModal){ |
4772 // Window should be window-modal, which implies a sheet. |
4910 // INVARIANT: Window should be window-modal (which implies a sheet). |
4773 if (!alreadySheet) { |
4911 if (!alreadySheet) { |
4774 // NB: the following call will call setModal_sys recursivly: |
4912 // NB: the following call will call setModal_sys recursivly: |
4775 recreateMacWindow(); |
4913 recreateMacWindow(); |
4776 windowRef = qt_mac_window_for(q); |
4914 windowRef = qt_mac_window_for(q); |
4777 } |
4915 } |
4784 bool worksWhenModal = isDialog ? [static_cast<NSPanel *>(ref) worksWhenModal] : false; |
4922 bool worksWhenModal = isDialog ? [static_cast<NSPanel *>(ref) worksWhenModal] : false; |
4785 if (worksWhenModal) |
4923 if (worksWhenModal) |
4786 [static_cast<NSPanel *>(windowRef) setWorksWhenModal:YES]; |
4924 [static_cast<NSPanel *>(windowRef) setWorksWhenModal:YES]; |
4787 } |
4925 } |
4788 } else { |
4926 } else { |
4789 // Window shold not be window-modal, and as such, not a sheet. |
4927 // INVARIANT: Window shold _not_ be window-modal (and as such, not a sheet). |
4790 if (alreadySheet){ |
4928 if (alreadySheet){ |
4791 // NB: the following call will call setModal_sys recursivly: |
4929 // NB: the following call will call setModal_sys recursivly: |
4792 recreateMacWindow(); |
4930 recreateMacWindow(); |
4793 windowRef = qt_mac_window_for(q); |
4931 windowRef = qt_mac_window_for(q); |
4794 } |
4932 } |
4795 if (q->windowModality() == Qt::ApplicationModal) { |
4933 if (q->windowModality() == Qt::NonModal |
4796 [windowRef setLevel:NSModalPanelWindowLevel]; |
4934 && primaryWindow && primaryWindow->windowModality() == Qt::ApplicationModal) { |
4797 } else if (primaryWindow && primaryWindow->windowModality() == Qt::ApplicationModal) { |
4935 // INVARIANT: Our window has a parent that is application modal. |
4798 // INVARIANT: Our window is a dialog that has a dialog parent that is |
4936 // This means that q is supposed to be on top of this window and |
4799 // application modal, or . This means that q is supposed to be on top of this |
4937 // not be modally shaddowed: |
4800 // dialog and not be modally shaddowed: |
|
4801 [windowRef setLevel:NSModalPanelWindowLevel]; |
|
4802 if ([windowRef isKindOfClass:[NSPanel class]]) |
4938 if ([windowRef isKindOfClass:[NSPanel class]]) |
4803 [static_cast<NSPanel *>(windowRef) setWorksWhenModal:YES]; |
4939 [static_cast<NSPanel *>(windowRef) setWorksWhenModal:YES]; |
4804 } else { |
|
4805 // INVARIANT: q should not be modal. |
|
4806 NSInteger winLevel = -1; |
|
4807 if (q->windowType() == Qt::Popup) { |
|
4808 winLevel = NSPopUpMenuWindowLevel; |
|
4809 // Popup should be in at least the same level as its parent. |
|
4810 if (primaryWindow) { |
|
4811 OSWindowRef parentRef = qt_mac_window_for(primaryWindow); |
|
4812 winLevel = qMax([parentRef level], winLevel); |
|
4813 } |
|
4814 } else if (q->windowType() == Qt::Tool) { |
|
4815 winLevel = NSFloatingWindowLevel; |
|
4816 } else if (q->windowType() == Qt::Dialog) { |
|
4817 winLevel = NSModalPanelWindowLevel; |
|
4818 } |
|
4819 |
|
4820 // StayOnTop window should appear above Tool windows. |
|
4821 if (data.window_flags & Qt::WindowStaysOnTopHint) |
|
4822 winLevel = NSPopUpMenuWindowLevel; |
|
4823 // Tooltips should appear above StayOnTop windows. |
|
4824 if (q->windowType() == Qt::ToolTip) |
|
4825 winLevel = NSScreenSaverWindowLevel; |
|
4826 // All other types are Normal level. |
|
4827 if (winLevel == -1) |
|
4828 winLevel = NSNormalWindowLevel; |
|
4829 [windowRef setLevel:winLevel]; |
|
4830 } |
4940 } |
4831 } |
4941 } |
4832 |
4942 |
4833 #else |
4943 #else |
4834 const bool primaryWindowModal = primaryWindow ? primaryWindow->testAttribute(Qt::WA_ShowModal) : false; |
4944 const bool primaryWindowModal = primaryWindow ? primaryWindow->testAttribute(Qt::WA_ShowModal) : false; |