VirtualBox

Changeset 6474 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jan 24, 2008 10:28:59 AM (17 years ago)
Author:
vboxsync
Message:
  • Mac OS X: The seamless mode is hopefully fixed for the mac. All the masking stuff is done without the help of qt.
  • As from now the available space for seamless mode is in that size which the quest allow.
Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleWnd.h

    r6462 r6474  
    254254    QSpacerItem *mShiftingSpacerRight;
    255255    QSpacerItem *mShiftingSpacerBottom;
     256    QSize mMaskShift;
    256257
    257258#ifdef VBOX_WITH_DEBUGGER_GUI
     
    300301#ifdef Q_WS_WIN32
    301302    QRegion mPrevRegion;
     303#endif
     304
     305#ifdef Q_WS_MAC
     306    QRegion mCurrRegion;
     307    EventHandlerRef mDarwinRegionEventHandlerRef;
    302308#endif
    303309
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxUtils.h

    r6462 r6474  
    256256CGImageRef DarwinCreateDockBadge (const char *aSource);
    257257CGImageRef DarwinCreateDockPreview (VBoxFrameBuffer *aFrameBuffer);
     258OSStatus DarwinRegionHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData);
    258259#endif /* Q_WS_MAC */
    259260
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp

    r6462 r6474  
    583583    OverlayApplicationDockTileImage (dockImgStateRunning);
    584584#endif
     585    mMaskShift.scale (0, 0, QSize::ScaleFree);
    585586}
    586587
     
    10071008{
    10081009    disconnect (console, SIGNAL (resizeHintDone()), 0, 0);
    1009 #ifndef Q_WS_MAC
    10101010    /* It isn't guaranteed that the guest os set the video mode that
    10111011     * we requested. So after all the resizing stuff set the clipping
    10121012     * mask and the spacing shifter to the corresponding values. */
    10131013    setViewInSeamlessMode (QRect(console->mapToGlobal (QPoint(0, 0)), console->size()));
    1014 #endif
    10151014#ifdef Q_WS_MAC
    10161015    if (!mIsSeamless)
     
    20882087//        maskRect.setBottom (maskRect.bottom() + 1);
    20892088//        setMask (maskRect);
     2089        if (aSeamless)
     2090        {
     2091            OSStatus status;
     2092            WindowPtr WindowRef = reinterpret_cast<WindowPtr>(winId());
     2093            EventTypeSpec wNonCompositingEvent = { kEventClassWindow, kEventWindowGetRegion };
     2094            status = InstallWindowEventHandler (WindowRef, DarwinRegionHandler, GetEventTypeCount (wNonCompositingEvent), &wNonCompositingEvent, &mCurrRegion, &mDarwinRegionEventHandlerRef);
     2095            Assert (status == noErr);
     2096            status = ReshapeCustomWindow (WindowRef);
     2097            Assert (status == noErr);
     2098            UInt32 features;
     2099            status = GetWindowFeatures (WindowRef, &features);
     2100            Assert (status == noErr);
     2101            if (( features & kWindowIsOpaque ) != 0)
     2102            {
     2103                status = HIWindowChangeFeatures (WindowRef, 0, kWindowIsOpaque);
     2104                Assert(status == noErr);
     2105            }
     2106            status = SetWindowAlpha(WindowRef, 0.999);
     2107            Assert (status == noErr);
     2108        }
    20902109#else
    20912110//        setMask (dtw->screenGeometry (this));
     
    21182137        if (!aSeamless)
    21192138            SetSystemUIMode (kUIModeNormal, 0);
     2139
     2140        if (aSeamless)
     2141        {
     2142            /* Undo all mac specific installations */
     2143            OSStatus status;
     2144            WindowPtr WindowRef = reinterpret_cast<WindowPtr>(winId());
     2145            status = RemoveEventHandler (mDarwinRegionEventHandlerRef);
     2146            Assert (status == noErr);
     2147            status = ReshapeCustomWindow (WindowRef);
     2148            Assert (status == noErr);
     2149            status = SetWindowAlpha (WindowRef, 1);
     2150            Assert (status == noErr);
     2151        }
    21202152#endif
    21212153
     
    21622194         * we requested. So after all the resizing stuff set the clipping
    21632195         * mask and the spacing shifter to the corresponding values. */
    2164         QDesktopWidget *dtw = QApplication::desktop();
     2196        QDesktopWidget *dtw = QApplication::desktop ();
    21652197        QRect sRect = dtw->screenGeometry (this);
    21662198        QRect aRect (aTargetRect);
    2167         QRect a1Rect (aTargetRect);
     2199        mMaskShift.scale (aTargetRect.left(), aTargetRect.top(), QSize::ScaleFree);
    21682200#ifdef Q_WS_MAC
    21692201        /* On mac os x this isn't necessary cause the screen starts
    21702202         * by y=0 always regardless if there is the global menubar or not. */
    21712203        aRect.setRect (aRect.left(), 0, aRect.width(), aRect.height() + aRect.top());
    2172         a1Rect.setRect (a1Rect.left(), 0, a1Rect.width(), a1Rect.height());
    21732204#endif // Q_WS_MAC
    21742205        /* Set the clipping mask */
    2175         mStrictedRegion = QRegion (sRect) - a1Rect;
     2206        mStrictedRegion = aRect;
    21762207        /* Set the shifting spacer */
    21772208        mShiftingSpacerLeft->changeSize (RT_ABS (sRect.left() - aRect.left()), 0,
     
    25782609{
    25792610    QRegion region = aRegion;
    2580     region.translate (mShiftingSpacerLeft->sizeHint().width(), mShiftingSpacerTop->sizeHint().height());
    2581     region -= mStrictedRegion;
    2582 
    2583 #ifdef Q_WS_MAC
    2584     /* This is necessary to avoid the flicker by
    2585      * an mask update.
    2586      * See http://lists.apple.com/archives/Carbon-development/2001/Apr/msg01651.html
    2587      * for the hint.
    2588      * There *must* be a better solution. */
    2589     if(!region.isEmpty())
    2590       region |= QRect(0, 0, 1, 1);
    2591 #endif
     2611    /* The global mask shift cause of toolbars and such thinks. */
     2612    region.translate (mMaskShift.width(), mMaskShift.height());
     2613    /* Restrict the drawing to the available space on the screen.
     2614     * (The &operator is better than the previous used -operator,
     2615     * because this excludes space around the real screen also.
     2616     * This is necessary for the mac.) */
     2617    region &= mStrictedRegion;
    25922618
    25932619#ifdef Q_WS_WIN
     
    26202646
    26212647    mPrevRegion = region;
     2648#elif defined(Q_WS_MAC)
     2649    /* This is necessary to avoid the flicker by an mask update.
     2650     * See http://lists.apple.com/archives/Carbon-development/2001/Apr/msg01651.html
     2651     * for the hint.
     2652     * There *must* be a better solution. */
     2653    if(!region.isEmpty ())
     2654      region |= QRect (0, 0, 1, 1);
     2655    /* Save the current region for later processing in the darwin event handler. */
     2656    mCurrRegion = region;
     2657    /* We repaint the screen before the ReshapeCustomWindow command. Unfortunately
     2658     * this command flushes a copy of the backbuffer to the screen after the new
     2659     * mask is set. This leads into a missplaced drawing of the content. Currently
     2660     * no alternative to this and also this is not 100% perfect. */
     2661    repaint ();
     2662    qApp->processEvents ();
     2663    /* Now force the reshaping of the window. This is definitly necessary. */
     2664    ReshapeCustomWindow (reinterpret_cast<WindowPtr>(winId()));
    26222665#else
    26232666    QMainWindow::setMask (region);
  • trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin.cpp

    r6462 r6474  
    196196}
    197197
     198OSStatus DarwinRegionHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData)
     199{
     200    NOREF(aInHandlerCallRef);
     201
     202        OSStatus status = eventNotHandledErr;
     203       
     204        switch(GetEventKind (aInEvent))
     205        {
     206                case kEventWindowGetRegion:
     207                {
     208                        WindowRegionCode code;
     209                        RgnHandle rgn;
     210                       
     211                        /* which region code is being queried? */
     212                        GetEventParameter (aInEvent, kEventParamWindowRegionCode, typeWindowRegionCode, NULL, sizeof(code), NULL, &code);
     213
     214                        /* if it is the opaque region code then set the region to Empty and return noErr to stop the propagation */
     215                        if (code == kWindowOpaqueRgn)
     216                        {
     217                                GetEventParameter (aInEvent, kEventParamRgnHandle, typeQDRgnHandle, NULL, sizeof(rgn), NULL, &rgn);
     218                                SetEmptyRgn (rgn);
     219                                status = noErr;
     220                        }
     221            /* if the content of the whole window is queried return a copy of our saved region. */
     222            else if (code == (kWindowStructureRgn))// || kWindowGlobalPortRgn || kWindowUpdateRgn))
     223            {
     224                                GetEventParameter (aInEvent, kEventParamRgnHandle, typeQDRgnHandle, NULL, sizeof(rgn), NULL, &rgn);
     225                QRegion *pRegion = static_cast<QRegion*>(aInUserData);
     226                if(!pRegion->isNull () && pRegion)
     227                {
     228                    CopyRgn (pRegion->handle(), rgn);
     229                    status = noErr;
     230                }
     231            }
     232            break;
     233                }
     234        }
     235       
     236        return status;
     237}
     238
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette