VirtualBox

Changeset 6462 in vbox


Ignore:
Timestamp:
Jan 23, 2008 3:06:27 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
27455
Message:

Attempt at fixing the style before dmik notices... :-)

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
5 edited

Legend:

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

    r6442 r6462  
    182182    void onExitFullscreen();
    183183
    184     void setViewInSeamlessMode(const QRect& targetRect);
     184    void setViewInSeamlessMode (const QRect &aTargetRect);
    185185
    186186private:
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxUtils.h

    r6443 r6462  
    255255CGImageRef DarwinQPixmapFromMimeSourceToCGImage (const char *aSource);
    256256CGImageRef DarwinCreateDockBadge (const char *aSource);
    257 CGImageRef DarwinCreateDockPreview(VBoxFrameBuffer *aFrameBuffer);
     257CGImageRef DarwinCreateDockPreview (VBoxFrameBuffer *aFrameBuffer);
    258258#endif /* Q_WS_MAC */
    259259
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp

    r6456 r6462  
    10671067                /* emit a signal about guest was resized */
    10681068                emit resizeHintDone();
    1069              
     1069
    10701070                return true;
    10711071            }
     
    27952795#ifdef Q_WS_MAC
    27962796            /* Update the dock icon if we are in the running state */
    2797             if(isRunning())
     2797            if (isRunning())
    27982798                SetApplicationDockTileImage(::DarwinCreateDockPreview(mFrameBuf));
    27992799#endif
    2800 
    28012800            return;
    28022801        }
     
    29782977}
    29792978
    2980 /** 
     2979/**
    29812980 * Send the KEY BREAK code to the VM for all currently pressed keys.
    2982  * 
     2981 *
    29832982 * @param aReleaseHostKey @c true to set the host key state to unpressed.
    29842983 */
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp

    r6442 r6462  
    632632        setCentralWidget (new QWidget (this, "centralWidget"));
    633633        QGridLayout *pMainLayout = new QGridLayout(centralWidget(), 3, 3, 0, 0);
    634         mShiftingSpacerLeft = new QSpacerItem (0, 0, 
     634        mShiftingSpacerLeft = new QSpacerItem (0, 0,
    635635                                               QSizePolicy::Fixed,
    636636                                               QSizePolicy::Fixed);
    637         mShiftingSpacerTop = new QSpacerItem (0, 0, 
     637        mShiftingSpacerTop = new QSpacerItem (0, 0,
    638638                                              QSizePolicy::Fixed,
    639639                                              QSizePolicy::Fixed);
    640         mShiftingSpacerRight = new QSpacerItem (0, 0, 
     640        mShiftingSpacerRight = new QSpacerItem (0, 0,
    641641                                                QSizePolicy::Fixed,
    642642                                                QSizePolicy::Fixed);
    643         mShiftingSpacerBottom = new QSpacerItem (0, 0, 
     643        mShiftingSpacerBottom = new QSpacerItem (0, 0,
    644644                                                 QSizePolicy::Fixed,
    645645                                                 QSizePolicy::Fixed);
     
    663663
    664664    static_cast<QGridLayout*>(centralWidget()->layout())->addWidget(console, 1, 1, AlignVCenter | AlignHCenter);
    665    
     665
    666666    CMachine cmachine = csession.GetMachine();
    667667
     
    10071007{
    10081008    disconnect (console, SIGNAL (resizeHintDone()), 0, 0);
    1009 #ifndef Q_WS_MAC 
     1009#ifndef Q_WS_MAC
    10101010    /* It isn't guaranteed that the guest os set the video mode that
    1011      * we requested. So after all the resizing stuff set the clipping 
     1011     * we requested. So after all the resizing stuff set the clipping
    10121012     * mask and the spacing shifter to the corresponding values. */
    1013     setViewInSeamlessMode(QRect(console->mapToGlobal(QPoint(0, 0)), console->size()));
    1014 #endif
    1015 #ifdef Q_WS_MAC 
    1016     if(!mIsSeamless)
    1017     {
    1018       /* Fade back to the normal gamma */
    1019       CGDisplayFade(mFadeToken, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, false);
    1020       CGReleaseDisplayFadeReservation(mFadeToken);
     1013    setViewInSeamlessMode (QRect(console->mapToGlobal (QPoint(0, 0)), console->size()));
     1014#endif
     1015#ifdef Q_WS_MAC
     1016    if (!mIsSeamless)
     1017    {
     1018        /* Fade back to the normal gamma */
     1019        CGDisplayFade (mFadeToken, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, false);
     1020        CGReleaseDisplayFadeReservation (mFadeToken);
    10211021    }
    10221022#endif
     
    10331033{
    10341034    disconnect (console, SIGNAL (resizeHintDone()), 0, 0);
    1035 #ifdef Q_WS_MAC 
    1036     if(!mIsSeamless)
    1037     {
    1038       /* Fade back to the normal gamma */
    1039       CGDisplayFade(mFadeToken, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, false);
    1040       CGReleaseDisplayFadeReservation(mFadeToken);
     1035#ifdef Q_WS_MAC
     1036    if (!mIsSeamless)
     1037    {
     1038        /* Fade back to the normal gamma */
     1039        CGDisplayFade (mFadeToken, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, false);
     1040        CGReleaseDisplayFadeReservation (mFadeToken);
    10411041    }
    10421042#endif
     
    19311931    if (!aSeamless)
    19321932    {
    1933       /* Fade to black */
    1934       CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &mFadeToken);
    1935       CGDisplayFade(mFadeToken, 0.3, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0.0, 0.0, 0.0, true);
     1933        /* Fade to black */
     1934        CGAcquireDisplayFadeReservation (kCGMaxDisplayReservationInterval, &mFadeToken);
     1935        CGDisplayFade (mFadeToken, 0.3, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0.0, 0.0, 0.0, true);
    19361936    }
    19371937#endif
     
    20382038
    20392039        /* It isn't guaranteed that the guest os set the video mode that
    2040          * we requested. So after all the resizing stuff set the clipping 
     2040         * we requested. So after all the resizing stuff set the clipping
    20412041         * mask and the spacing shifter to the corresponding values. */
    2042         setViewInSeamlessMode(dtw->availableGeometry(this));
     2042        setViewInSeamlessMode (dtw->availableGeometry (this));
    20432043
    20442044#ifdef Q_WS_WIN32
     
    20702070                LogRel (("Error: Failed to change UI mode (rc=%#x) when changing to fullscreen mode. (=> menu bar trouble)\n", orc));
    20712071        }
    2072 #endif 
     2072#endif
    20732073
    20742074        /* Adjust colors and appearance. */
     
    20882088//        maskRect.setBottom (maskRect.bottom() + 1);
    20892089//        setMask (maskRect);
    2090 
    20912090#else
    20922091//        setMask (dtw->screenGeometry (this));
     
    21562155// Private slots
    21572156/////////////////////////////////////////////////////////////////////////////
    2158 void VBoxConsoleWnd::setViewInSeamlessMode(const QRect& targetRect)
     2157void VBoxConsoleWnd::setViewInSeamlessMode (const QRect &aTargetRect)
    21592158{
    21602159    if (mIsSeamless)
    21612160    {
    21622161        /* It isn't guaranteed that the guest os set the video mode that
    2163          * we requested. So after all the resizing stuff set the clipping 
     2162         * we requested. So after all the resizing stuff set the clipping
    21642163         * mask and the spacing shifter to the corresponding values. */
    21652164        QDesktopWidget *dtw = QApplication::desktop();
    21662165        QRect sRect = dtw->screenGeometry (this);
    2167         QRect aRect(targetRect);
    2168         QRect a1Rect(targetRect);
     2166        QRect aRect (aTargetRect);
     2167        QRect a1Rect (aTargetRect);
    21692168#ifdef Q_WS_MAC
    21702169        /* On mac os x this isn't necessary cause the screen starts
    21712170         * by y=0 always regardless if there is the global menubar or not. */
    2172         aRect.setRect(aRect.left(), 0, aRect.width(), aRect.height()+aRect.top());
    2173         a1Rect.setRect(a1Rect.left(), 0, a1Rect.width(), a1Rect.height());
     2171        aRect.setRect (aRect.left(), 0, aRect.width(), aRect.height() + aRect.top());
     2172        a1Rect.setRect (a1Rect.left(), 0, a1Rect.width(), a1Rect.height());
    21742173#endif // Q_WS_MAC
    21752174        /* Set the clipping mask */
    2176         mStrictedRegion = QRegion(sRect) - a1Rect;
     2175        mStrictedRegion = QRegion (sRect) - a1Rect;
    21772176        /* Set the shifting spacer */
    2178         mShiftingSpacerLeft->changeSize(RT_ABS(sRect.left() - aRect.left()), 0,
    2179                                         QSizePolicy::Fixed, QSizePolicy::Preferred);
    2180         mShiftingSpacerTop->changeSize(0, RT_ABS(sRect.top() - aRect.top()),
    2181                                        QSizePolicy::Preferred, QSizePolicy::Fixed);
    2182         mShiftingSpacerRight->changeSize(RT_ABS(sRect.right() - aRect.right()), 0,
     2177        mShiftingSpacerLeft->changeSize (RT_ABS (sRect.left() - aRect.left()), 0,
    21832178                                         QSizePolicy::Fixed, QSizePolicy::Preferred);
    2184         mShiftingSpacerBottom->changeSize(0, RT_ABS(sRect.bottom() - aRect.bottom()),
    2185                                           QSizePolicy::Preferred, QSizePolicy::Fixed);
     2179        mShiftingSpacerTop->changeSize (0, RT_ABS (sRect.top() - aRect.top()),
     2180                                        QSizePolicy::Preferred, QSizePolicy::Fixed);
     2181        mShiftingSpacerRight->changeSize (RT_ABS (sRect.right() - aRect.right()), 0,
     2182                                          QSizePolicy::Fixed, QSizePolicy::Preferred);
     2183        mShiftingSpacerBottom->changeSize (0, RT_ABS (sRect.bottom() - aRect.bottom()),
     2184                                           QSizePolicy::Preferred, QSizePolicy::Fixed);
    21862185    }
    21872186}
     
    25792578{
    25802579    QRegion region = aRegion;
    2581     region.translate(mShiftingSpacerLeft->sizeHint().width(), mShiftingSpacerTop->sizeHint().height());
     2580    region.translate (mShiftingSpacerLeft->sizeHint().width(), mShiftingSpacerTop->sizeHint().height());
    25822581    region -= mStrictedRegion;
    25832582
    25842583#ifdef Q_WS_MAC
    25852584    /* This is necessary to avoid the flicker by
    2586      * an mask update. 
     2585     * an mask update.
    25872586     * See http://lists.apple.com/archives/Carbon-development/2001/Apr/msg01651.html
    25882587     * for the hint.
     
    25902589    if(!region.isEmpty())
    25912590      region |= QRect(0, 0, 1, 1);
    2592 #endif 
     2591#endif
    25932592
    25942593#ifdef Q_WS_WIN
     
    31143113    vmAutoresizeGuestAction->setEnabled (aActive);
    31153114    vmSeamlessAction->setEnabled (aSeamlessSupported);
    3116 //#ifndef Q_WS_MAC /** @todo fix seamless mode on Mac OS X. It is temporarily disabled to prevent bogus bugreports for the beta 3 / beta 2 leopard update. */
    31173115    mIsSeamlessSupported = aSeamlessSupported;
    3118 //#endif
    31193116    /* If seamless mode should be enabled then check if it is enabled
    31203117     * currently and re-enable it if open-view procedure is finished */
  • trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin.cpp

    r6443 r6462  
     1/* $Id: $ */
    12/** @file
    23 * Qt GUI - Utility Classes and Functions specific to Darwin.
     
    2324
    2425#include <iprt/assert.h>
     26#include <iprt/mem.h>
    2527
    2628
    2729/**
    28  * Callback for deleting the QImage object when CGImageCreate is done 
     30 * Callback for deleting the QImage object when CGImageCreate is done
    2931 * with it (which is probably not until the returned CFGImageRef is released).
    30  * 
     32 *
    3133 * @param   info        Pointer to the QImage.
    3234 */
     
    3941/**
    4042 * Converts a QPixmap to a CGImage.
    41  * 
    42  * @returns CGImageRef for the new image. (Remember to release it when finished with it.) 
     43 *
     44 * @returns CGImageRef for the new image. (Remember to release it when finished with it.)
    4345 * @param   aPixmap     Pointer to the QPixmap instance to convert.
    4446 */
     
    5759    bmpInfo |= kCGBitmapByteOrder32Host;
    5860    CGImageRef ir = CGImageCreate (imageCopy->width(), imageCopy->height(), 8, 32, imageCopy->bytesPerLine(), cs,
    59                                    bmpInfo, dp, 0 /*decode */, 0 /* shouldInterpolate */, 
     61                                   bmpInfo, dp, 0 /*decode */, 0 /* shouldInterpolate */,
    6062                                   kCGRenderingIntentDefault);
    6163    CGColorSpaceRelease (cs);
     
    6870/**
    6971 * Converts a QPixmap to a CGImage.
    70  * 
    71  * @returns CGImageRef for the new image. (Remember to release it when finished with it.) 
     72 *
     73 * @returns CGImageRef for the new image. (Remember to release it when finished with it.)
    7274 * @param   aPixmap     Pointer to the QPixmap instance to convert.
    7375 */
     
    8183/**
    8284 * Loads an image using Qt and converts it to a CGImage.
    83  * 
    84  * @returns CGImageRef for the new image. (Remember to release it when finished with it.) 
     85 *
     86 * @returns CGImageRef for the new image. (Remember to release it when finished with it.)
    8587 * @param   aSource     The source name.
    8688 */
     
    9496/**
    9597 * Creates a dock badge image.
    96  * 
     98 *
    9799 * The badge will be placed on the right hand size and vertically centered
    98100 * after having been scaled up to 32x32.
    99  * 
    100  * @returns CGImageRef for the new image. (Remember to release it when finished with it.) 
     101 *
     102 * @returns CGImageRef for the new image. (Remember to release it when finished with it.)
    101103 * @param   aSource     The source name.
    102104 */
    103105CGImageRef DarwinCreateDockBadge (const char *aSource)
    104106{
    105     /* instead of figuring out how to create a transparent 128x128 pixmap I've 
     107    /* instead of figuring out how to create a transparent 128x128 pixmap I've
    106108       just created one that I can load. The Qt gurus can fix this if they like :-) */
    107109    QPixmap back (QPixmap::fromMimeSource ("dock_128x128_transparent.png"));
     
    128130/**
    129131 * Creates a dock preview image.
    130  * 
    131  * Use this method to create a 128x128 preview image of the vm window.
    132  * 
    133  * @returns CGImageRef for the new image. (Remember to release it when finished with it.) 
    134  * @param   aFrameBuffer    The source name.
     132 *
     133 * This method is a callback that creates a 128x128 preview image of the VM window.
     134 *
     135 * @returns CGImageRef for the new image. (Remember to release it when finished with it.)
     136 * @param   aFrameBuffer    The guest frame buffer.
    135137 */
    136 CGImageRef DarwinCreateDockPreview(VBoxFrameBuffer *aFrameBuffer)
     138CGImageRef DarwinCreateDockPreview (VBoxFrameBuffer *aFrameBuffer)
    137139{
    138140    CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
     141
    139142    /* Create the image copy of the framebuffer */
    140     CGDataProviderRef dp = CGDataProviderCreateWithData(aFrameBuffer, aFrameBuffer->address(), aFrameBuffer->bitsPerPixel() / 8 * aFrameBuffer->width() * aFrameBuffer->height() , NULL);
    141     CGImageRef ir = CGImageCreate(aFrameBuffer->width(), aFrameBuffer->height(), 8, 32, aFrameBuffer->bytesPerLine(), cs,
    142                                   kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host, dp, 0 /*decode */, 0 /* shouldInterpolate */,
    143                                   kCGRenderingIntentDefault);
     143    CGDataProviderRef dp = CGDataProviderCreateWithData (aFrameBuffer, aFrameBuffer->address(), aFrameBuffer->bitsPerPixel() / 8 * aFrameBuffer->width() * aFrameBuffer->height() , NULL);
     144    CGImageRef ir = CGImageCreate (aFrameBuffer->width(), aFrameBuffer->height(), 8, 32, aFrameBuffer->bytesPerLine(), cs,
     145                                   kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host, dp, 0 /* decode */, 0 /* shouldInterpolate */,
     146                                   kCGRenderingIntentDefault);
    144147
    145     Assert(cs);
    146     Assert(dp);
    147     Assert(ir);
     148    Assert (cs);
     149    Assert (dp);
     150    Assert (ir);
     151
    148152    /* Calc the size of the dock icon image and fit it into 128x128 */
    149153    int targetWidth = 128;
     
    151155    float aspect = static_cast<float>(aFrameBuffer->width()) / aFrameBuffer->height();
    152156    CGRect rect;
    153     if(aspect > 1.0)
     157    if (aspect > 1.0)
    154158    {
    155       rect.origin.x = 0;
    156       rect.origin.y = (targetHeight-targetHeight/aspect)/2;
    157       rect.size.width = targetWidth;
    158       rect.size.height = targetHeight/aspect;
    159     }else
     159        rect.origin.x = 0;
     160        rect.origin.y = (targetHeight - targetHeight / aspect) / 2;
     161        rect.size.width = targetWidth;
     162        rect.size.height = targetHeight / aspect;
     163    }
     164    else
    160165    {
    161       rect.origin.x = (targetWidth-targetWidth*aspect)/2;
    162       rect.origin.y = 0;
    163       rect.size.width = targetWidth*aspect;
    164       rect.size.height = targetHeight;
     166        rect.origin.x = (targetWidth - targetWidth * aspect) / 2;
     167        rect.origin.y = 0;
     168        rect.size.width = targetWidth*aspect;
     169        rect.size.height = targetHeight;
    165170    }
     171
    166172    /* Create a bitmap context to draw on */
    167     int bitmapBytesPerRow = (targetWidth * 4);
    168     int bitmapByteCount = (bitmapBytesPerRow * targetHeight);
    169     void *bitmapData = malloc(bitmapByteCount);
    170173    CGImageRef dockImage = NULL;
     174    int bitmapBytesPerRow = targetWidth * 4;
     175    int bitmapByteCount = bitmapBytesPerRow * targetHeight;
     176    void *bitmapData = RTMemAlloc (bitmapByteCount);
    171177    if (bitmapData)
    172178    {
    173       CGContextRef context = CGBitmapContextCreate(bitmapData, targetWidth, targetHeight, 8, bitmapBytesPerRow, cs, kCGImageAlphaPremultipliedLast);
    174       /* Draw on the bitmap */
    175       CGContextDrawImage(context, rect, ir);
    176       /* Create the preview image ref from the bitmap */
    177       dockImage = CGBitmapContextCreateImage(context);
    178       CGContextRelease(context);
    179       free(bitmapData);
     179        CGContextRef context = CGBitmapContextCreate (bitmapData, targetWidth, targetHeight, 8, bitmapBytesPerRow, cs, kCGImageAlphaPremultipliedLast);
     180
     181        /* Draw on the bitmap */
     182        CGContextDrawImage (context, rect, ir);
     183
     184        /* Create the preview image ref from the bitmap */
     185        dockImage = CGBitmapContextCreateImage (context);
     186        CGContextRelease (context);
     187        RTMemFree (bitmapData);
    180188    }
    181     CGColorSpaceRelease(cs);
    182     CGDataProviderRelease(dp);
    183     CGImageRelease(ir);
     189
     190    CGColorSpaceRelease (cs);
     191    CGDataProviderRelease (dp);
     192    CGImageRelease (ir);
    184193
    185194    Assert (dockImage);
    186195    return dockImage;
    187196}
     197
Note: See TracChangeset for help on using the changeset viewer.

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