VirtualBox

Ignore:
Timestamp:
Mar 9, 2010 1:34:53 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
58588
Message:

FE/Qt4: new core: dock icon preview with MM support added again

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
14 edited
4 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r27096 r27215  
    522522        src/runtime/seamless/UIMachineWindowSeamless.cpp \
    523523        src/runtime/seamless/UIMachineViewSeamless.cpp
     524VirtualBox_SOURCES.darwin += \
     525        src/darwin/UIAbstractDockIconPreview.cpp \
     526        src/darwin/UICocoaDockIconPreview.mm
    524527endif
    525528
     
    548551        src/win/VirtualBox.rc
    549552
    550 VirtualBox_SOURCES.darwin = \
     553VirtualBox_SOURCES.darwin += \
    551554        src/darwin/DarwinKeyboard.cpp \
    552555        src/darwin/VBoxUtils-darwin.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQuartz2D.cpp

    r26719 r27215  
    230230
    231231    /* We handle the seamless mode as a special case. */
    232     if (main->isTrueSeamless())
     232    if (   main
     233        && main->isTrueSeamless())
    233234    {
    234235        /* Here we paint the windows without any wallpaper.
  • trunk/src/VBox/Frontends/VirtualBox/src/darwin/DockIconPreview.h

    r25171 r27215  
    3535};
    3636
     37#include "UICocoaDockIconPreview.h"
     38class UIDockIconPreview: public UICocoaDockIconPreview
     39{
     40public:
     41    UIDockIconPreview(UISession *pSession, const QPixmap& overlayImage)
     42      : UICocoaDockIconPreview(pSession, overlayImage) {}
     43};
     44
    3745#else /* QT_MAC_USE_COCOA */
    3846
  • trunk/src/VBox/Frontends/VirtualBox/src/darwin/UIAbstractDockIconPreview.cpp

    r27154 r27215  
    2121
    2222/* VBox includes */
    23 #include "AbstractDockIconPreview.h"
    24 #include "VBoxConsoleWnd.h"
    25 #include "VBoxFrameBuffer.h"
     23#include "UIAbstractDockIconPreview.h"
     24#include "UISession.h"
     25#include "UIFrameBuffer.h"
    2626
    27 AbstractDockIconPreview::AbstractDockIconPreview (VBoxConsoleWnd * /* aMainWnd */, const QPixmap& /* aOverlayImage */)
     27UIAbstractDockIconPreview::UIAbstractDockIconPreview(UISession * /* pSession */, const QPixmap& /* overlayImage */)
    2828{
    2929}
    3030
    31 void AbstractDockIconPreview::updateDockPreview (VBoxFrameBuffer *aFrameBuffer)
     31void UIAbstractDockIconPreview::updateDockPreview(UIFrameBuffer *pFrameBuffer)
    3232{
    3333    CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
    34     Assert (cs);
     34    Assert(cs);
    3535    /* Create the image copy of the framebuffer */
    36     CGDataProviderRef dp = CGDataProviderCreateWithData (aFrameBuffer, aFrameBuffer->address(), aFrameBuffer->bitsPerPixel() / 8 * aFrameBuffer->width() * aFrameBuffer->height(), NULL);
    37     Assert (dp);
    38     CGImageRef ir = CGImageCreate (aFrameBuffer->width(), aFrameBuffer->height(), 8, 32, aFrameBuffer->bytesPerLine(), cs,
    39                                    kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host, dp, 0, false,
    40                                    kCGRenderingIntentDefault);
    41     Assert (ir);
     36    CGDataProviderRef dp = CGDataProviderCreateWithData(pFrameBuffer, pFrameBuffer->address(), pFrameBuffer->bitsPerPixel() / 8 * pFrameBuffer->width() * pFrameBuffer->height(), NULL);
     37    Assert(dp);
     38    CGImageRef ir = CGImageCreate(pFrameBuffer->width(), pFrameBuffer->height(), 8, 32, pFrameBuffer->bytesPerLine(), cs,
     39                                  kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host, dp, 0, false,
     40                                  kCGRenderingIntentDefault);
     41    Assert(ir);
    4242
    4343    /* Update the dock preview icon */
    44     updateDockPreview (ir);
     44    updateDockPreview(ir);
    4545
    4646    /* Release the temp data and image */
    47     CGImageRelease (ir);
    48     CGDataProviderRelease (dp);
    49     CGColorSpaceRelease (cs);
     47    CGImageRelease(ir);
     48    CGDataProviderRelease(dp);
     49    CGColorSpaceRelease(cs);
    5050}
    5151
    52 AbstractDockIconPreviewHelper::AbstractDockIconPreviewHelper (VBoxConsoleWnd *aMainWnd, const QPixmap& aOverlayImage)
    53     :  mMainWnd (aMainWnd)
    54      , mDockIconRect (CGRectMake (0, 0, 128, 128))
    55      , mDockMonitor (NULL)
    56      , mDockMonitorGlossy (NULL)
    57      , mUpdateRect (CGRectMake (0, 0, 0, 0))
    58      , mMonitorRect (CGRectMake (0, 0, 0, 0))
     52UIAbstractDockIconPreviewHelper::UIAbstractDockIconPreviewHelper(UISession *pSession, const QPixmap& overlayImage)
     53    : m_pSession(pSession)
     54    , m_dockIconRect(CGRectMake(0, 0, 128, 128))
     55    , m_dockMonitor(NULL)
     56    , m_dockMonitorGlossy(NULL)
     57    , m_updateRect(CGRectMake(0, 0, 0, 0))
     58    , m_monitorRect(CGRectMake(0, 0, 0, 0))
    5959{
    60     mOverlayImage   = ::darwinToCGImageRef (&aOverlayImage);
    61     Assert (mOverlayImage);
     60    m_overlayImage   = ::darwinToCGImageRef(&overlayImage);
     61    Assert(m_overlayImage);
    6262
    63     mStatePaused    = ::darwinToCGImageRef ("state_paused_16px.png");
    64     Assert (mStatePaused);
    65     mStateSaving    = ::darwinToCGImageRef ("state_saving_16px.png");
    66     Assert (mStateSaving);
    67     mStateRestoring = ::darwinToCGImageRef ("state_restoring_16px.png");
    68     Assert (mStateRestoring);
     63    m_statePaused    = ::darwinToCGImageRef("state_paused_16px.png");
     64    Assert(m_statePaused);
     65    m_stateSaving    = ::darwinToCGImageRef("state_saving_16px.png");
     66    Assert(m_stateSaving);
     67    m_stateRestoring = ::darwinToCGImageRef("state_restoring_16px.png");
     68    Assert(m_stateRestoring);
    6969}
    7070
    71 AbstractDockIconPreviewHelper::~AbstractDockIconPreviewHelper()
     71UIAbstractDockIconPreviewHelper::~UIAbstractDockIconPreviewHelper()
    7272{
    73     CGImageRelease (mOverlayImage);
    74     if (mDockMonitor)
    75         CGImageRelease (mDockMonitor);
    76     if (mDockMonitorGlossy)
    77         CGImageRelease (mDockMonitorGlossy);
     73    CGImageRelease(m_overlayImage);
     74    if (m_dockMonitor)
     75        CGImageRelease(m_dockMonitor);
     76    if (m_dockMonitorGlossy)
     77        CGImageRelease(m_dockMonitorGlossy);
    7878
    79     CGImageRelease (mStatePaused);
    80     CGImageRelease (mStateSaving);
    81     CGImageRelease (mStateRestoring);
     79    CGImageRelease(m_statePaused);
     80    CGImageRelease(m_stateSaving);
     81    CGImageRelease(m_stateRestoring);
    8282}
    8383
    84 void AbstractDockIconPreviewHelper::initPreviewImages()
     84void UIAbstractDockIconPreviewHelper::initPreviewImages()
    8585{
    86     if (!mDockMonitor)
     86    if (!m_dockMonitor)
    8787    {
    88         mDockMonitor = ::darwinToCGImageRef ("monitor.png");
    89         Assert (mDockMonitor);
     88        m_dockMonitor = ::darwinToCGImageRef("monitor.png");
     89        Assert(m_dockMonitor);
    9090        /* Center it on the dock icon context */
    91         mMonitorRect = centerRect (CGRectMake (0, 0,
    92                                                CGImageGetWidth (mDockMonitor),
    93                                                CGImageGetWidth (mDockMonitor)));
     91        m_monitorRect = centerRect(CGRectMake(0, 0,
     92                                              CGImageGetWidth(m_dockMonitor),
     93                                              CGImageGetWidth(m_dockMonitor)));
    9494    }
    9595
    96     if (!mDockMonitorGlossy)
     96    if (!m_dockMonitorGlossy)
    9797    {
    98         mDockMonitorGlossy = ::darwinToCGImageRef ("monitor_glossy.png");
    99         Assert (mDockMonitorGlossy);
     98        m_dockMonitorGlossy = ::darwinToCGImageRef("monitor_glossy.png");
     99        Assert(m_dockMonitorGlossy);
    100100        /* This depends on the content of monitor.png */
    101         mUpdateRect = CGRectMake (mMonitorRect.origin.x + 7 + 1,
    102                                   mMonitorRect.origin.y + 8 + 1,
     101        m_updateRect = CGRectMake(m_monitorRect.origin.x + 7 + 1,
     102                                  m_monitorRect.origin.y + 8 + 1,
    103103                                  118 - 7 - 2,
    104104                                  103 - 8 - 2);
     
    106106}
    107107
    108 CGImageRef AbstractDockIconPreviewHelper::stateImage() const
     108CGImageRef UIAbstractDockIconPreviewHelper::stateImage() const
    109109{
    110110    CGImageRef img;
    111     if (   mMainWnd->machineState() == KMachineState_Paused
    112         || mMainWnd->machineState() == KMachineState_TeleportingPausedVM)
    113         img = mStatePaused;
    114     else if (   mMainWnd->machineState() == KMachineState_Restoring
    115              || mMainWnd->machineState() == KMachineState_TeleportingIn)
    116         img = mStateRestoring;
    117     else if (   mMainWnd->machineState() == KMachineState_Saving
    118              || mMainWnd->machineState() == KMachineState_LiveSnapshotting)
    119         img = mStateSaving;
     111    if (   m_pSession->machineState() == KMachineState_Paused
     112        || m_pSession->machineState() == KMachineState_TeleportingPausedVM)
     113        img = m_statePaused;
     114    else if (   m_pSession->machineState() == KMachineState_Restoring
     115             || m_pSession->machineState() == KMachineState_TeleportingIn)
     116        img = m_stateRestoring;
     117    else if (   m_pSession->machineState() == KMachineState_Saving
     118             || m_pSession->machineState() == KMachineState_LiveSnapshotting)
     119        img = m_stateSaving;
    120120    else
    121121        img = NULL;
     
    123123}
    124124
    125 void AbstractDockIconPreviewHelper::drawOverlayIcons (CGContextRef aContext)
     125void UIAbstractDockIconPreviewHelper::drawOverlayIcons(CGContextRef context)
    126126{
    127     CGRect overlayRect = CGRectMake (0, 0, 0, 0);
     127    CGRect overlayRect = CGRectMake(0, 0, 0, 0);
    128128    /* The overlay image at bottom/right */
    129     if (mOverlayImage)
     129    if (m_overlayImage)
    130130    {
    131         overlayRect = CGRectMake (mDockIconRect.size.width - CGImageGetWidth (mOverlayImage),
    132                                   mDockIconRect.size.height - CGImageGetHeight (mOverlayImage),
    133                                   CGImageGetWidth (mOverlayImage),
    134                                   CGImageGetHeight (mOverlayImage));
    135         CGContextDrawImage (aContext, flipRect (overlayRect), mOverlayImage);
     131        overlayRect = CGRectMake(m_dockIconRect.size.width - CGImageGetWidth(m_overlayImage),
     132                                 m_dockIconRect.size.height - CGImageGetHeight(m_overlayImage),
     133                                 CGImageGetWidth(m_overlayImage),
     134                                 CGImageGetHeight(m_overlayImage));
     135        CGContextDrawImage(context, flipRect(overlayRect), m_overlayImage);
    136136    }
    137137    CGImageRef sImage = stateImage();
     
    139139    if (sImage)
    140140    {
    141         CGRect stateRect = CGRectMake (overlayRect.origin.x - CGImageGetWidth (sImage) / 2.0,
    142                                        overlayRect.origin.y - CGImageGetHeight (sImage) / 2.0,
    143                                        CGImageGetWidth (sImage),
    144                                        CGImageGetHeight (sImage));
    145         CGContextDrawImage (aContext, flipRect (stateRect), sImage);
     141        CGRect stateRect = CGRectMake(overlayRect.origin.x - CGImageGetWidth(sImage) / 2.0,
     142                                      overlayRect.origin.y - CGImageGetHeight(sImage) / 2.0,
     143                                      CGImageGetWidth(sImage),
     144                                      CGImageGetHeight(sImage));
     145        CGContextDrawImage(context, flipRect(stateRect), sImage);
    146146    }
    147147}
  • trunk/src/VBox/Frontends/VirtualBox/src/darwin/UIAbstractDockIconPreview.h

    r27154 r27215  
    2222 */
    2323
    24 #ifndef ___AbstractVBoxDockIconPreview_h___
    25 #define ___AbstractVBoxDockIconPreview_h___
     24#ifndef ___UIAbstractDockIconPreview_h___
     25#define ___UIAbstractDockIconPreview_h___
    2626
    2727/* System includes */
     
    3131#include "VBoxUtils-darwin.h"
    3232
    33 class VBoxConsoleWnd;
    34 class VBoxFrameBuffer;
     33class UISession;
     34class UIFrameBuffer;
    3535
    3636class QPixmap;
    3737
    38 class AbstractDockIconPreview
     38class UIAbstractDockIconPreview
    3939{
    4040public:
    41     AbstractDockIconPreview (VBoxConsoleWnd *aMainWnd, const QPixmap& aOverlayImage);
    42     virtual ~AbstractDockIconPreview() {};
     41    UIAbstractDockIconPreview(UISession *pSession, const QPixmap& overlayImage);
     42    virtual ~UIAbstractDockIconPreview() {};
    4343
    4444    virtual void updateDockOverlay() = 0;
    45     virtual void updateDockPreview (CGImageRef aVMImage) = 0;
    46     virtual void updateDockPreview (VBoxFrameBuffer *aFrameBuffer);
     45    virtual void updateDockPreview(CGImageRef VMImage) = 0;
     46    virtual void updateDockPreview(UIFrameBuffer *pFrameBuffer);
    4747
    48     virtual void setOriginalSize (int /* aWidth */, int /* aHeight */) {}
     48    virtual void setOriginalSize(int /* aWidth */, int /* aHeight */) {}
    4949};
    5050
    51 class AbstractDockIconPreviewHelper
     51class UIAbstractDockIconPreviewHelper
    5252{
    5353public:
    54     AbstractDockIconPreviewHelper (VBoxConsoleWnd *aMainWnd, const QPixmap& aOverlayImage);
    55     virtual ~AbstractDockIconPreviewHelper();
     54    UIAbstractDockIconPreviewHelper(UISession *pSession, const QPixmap& overlayImage);
     55    virtual ~UIAbstractDockIconPreviewHelper();
    5656    void initPreviewImages();
    5757    inline CGImageRef stateImage() const;
    58     void drawOverlayIcons (CGContextRef aContext);
     58    void drawOverlayIcons(CGContextRef context);
    5959
    6060    /* Flipping is necessary cause the drawing context in Carbon is flipped by 180 degree */
    61     inline CGRect flipRect (CGRect aRect) const { return ::darwinFlipCGRect (aRect, mDockIconRect); }
    62     inline CGRect centerRect (CGRect aRect) const { return ::darwinCenterRectTo (aRect, mDockIconRect); }
    63     inline CGRect centerRectTo (CGRect aRect, const CGRect& aToRect) const { return ::darwinCenterRectTo (aRect, aToRect); }
     61    inline CGRect flipRect(CGRect rect) const { return ::darwinFlipCGRect(rect, m_dockIconRect); }
     62    inline CGRect centerRect(CGRect rect) const { return ::darwinCenterRectTo(rect, m_dockIconRect); }
     63    inline CGRect centerRectTo(CGRect rect, const CGRect& toRect) const { return ::darwinCenterRectTo(rect, toRect); }
    6464
    6565    /* Private member vars */
    66     VBoxConsoleWnd *mMainWnd;
    67     const CGRect mDockIconRect;
     66    UISession *m_pSession;
     67    const CGRect m_dockIconRect;
    6868
    69     CGImageRef mOverlayImage;
    70     CGImageRef mDockMonitor;
    71     CGImageRef mDockMonitorGlossy;
     69    CGImageRef m_overlayImage;
     70    CGImageRef m_dockMonitor;
     71    CGImageRef m_dockMonitorGlossy;
    7272
    73     CGImageRef mStatePaused;
    74     CGImageRef mStateSaving;
    75     CGImageRef mStateRestoring;
     73    CGImageRef m_statePaused;
     74    CGImageRef m_stateSaving;
     75    CGImageRef m_stateRestoring;
    7676
    77     CGRect mUpdateRect;
    78     CGRect mMonitorRect;
     77    CGRect m_updateRect;
     78    CGRect m_monitorRect;
    7979};
    8080
    81 #endif /* ___AbstractVBoxDockIconPreview_h___ */
     81#endif /* ___UIAbstractDockIconPreview_h___ */
    8282
  • trunk/src/VBox/Frontends/VirtualBox/src/darwin/UICocoaDockIconPreview.h

    r27154 r27215  
    33 *
    44 * VBox frontends: Qt GUI ("VirtualBox"):
    5  * CocoaDockIconPreview class declaration
     5 * UICocoaDockIconPreview class declaration
    66 */
    77
     
    2222 */
    2323
    24 #ifndef ___CocoaDockIconPreview_h___
    25 #define ___CocoaDockIconPreview_h___
     24#ifndef ___UICocoaDockIconPreview_h___
     25#define ___UICocoaDockIconPreview_h___
    2626
    2727/* Qt includes */
    28 #include "AbstractDockIconPreview.h"
     28#include "UIAbstractDockIconPreview.h"
    2929
    30 class CocoaDockIconPreviewPrivate;
     30class UICocoaDockIconPreviewPrivate;
    3131
    32 class CocoaDockIconPreview: public AbstractDockIconPreview
     32class UICocoaDockIconPreview: public UIAbstractDockIconPreview
    3333{
    3434public:
    35     CocoaDockIconPreview (VBoxConsoleWnd *aMainWnd, const QPixmap& aOverlayImage);
    36     ~CocoaDockIconPreview();
     35    UICocoaDockIconPreview(UISession *pSession, const QPixmap& overlayImage);
     36    ~UICocoaDockIconPreview();
    3737
    3838    virtual void updateDockOverlay();
    39     virtual void updateDockPreview (CGImageRef aVMImage);
    40     virtual void updateDockPreview (VBoxFrameBuffer *aFrameBuffer);
     39    virtual void updateDockPreview(CGImageRef VMImage);
     40    virtual void updateDockPreview(UIFrameBuffer *pFrameBuffer);
    4141
    42     virtual void setOriginalSize (int aWidth, int aHeight);
     42    virtual void setOriginalSize(int aWidth, int aHeight);
    4343
    4444private:
    45     CocoaDockIconPreviewPrivate *d;
     45    UICocoaDockIconPreviewPrivate *d;
    4646};
    4747
    48 #endif /* ___CocoaDockIconPreview_h___ */
     48#endif /* ___UICocoaDockIconPreview_h___ */
    4949
  • trunk/src/VBox/Frontends/VirtualBox/src/darwin/UICocoaDockIconPreview.mm

    r27154 r27215  
    2323
    2424/* VBox includes */
    25 #include "CocoaDockIconPreview.h"
     25#include "UICocoaDockIconPreview.h"
    2626#include "VBoxCocoaHelper.h"
    2727
     
    2929#import <Cocoa/Cocoa.h>
    3030
    31 @interface DockTileMonitor: NSView
    32 {
    33     CocoaDockIconPreviewPrivate *p;
     31@interface UIDockTileMonitor: NSView
     32{
     33    UICocoaDockIconPreviewPrivate *p;
    3434
    3535    NSImageView *mScreenContent;
    3636    NSImageView *mMonitorGlossy;
    3737}
    38 - (id)initWithFrame:(NSRect)frame parent:(CocoaDockIconPreviewPrivate*)parent;
     38- (id)initWithFrame:(NSRect)frame parent:(UICocoaDockIconPreviewPrivate*)parent;
    3939- (NSImageView*)screenContent;
    4040- (void)resize:(NSSize)size;
    4141@end
    4242
    43 @interface DockTileOverlay: NSView
    44 {
    45     CocoaDockIconPreviewPrivate *p;
    46 }
    47 - (id)initWithFrame:(NSRect)frame parent:(CocoaDockIconPreviewPrivate*)parent;
    48 @end
    49 
    50 @interface DockTile: NSView
    51 {
    52     CocoaDockIconPreviewPrivate *p;
    53 
    54     DockTileMonitor *mMonitor;
     43@interface UIDockTileOverlay: NSView
     44{
     45    UICocoaDockIconPreviewPrivate *p;
     46}
     47- (id)initWithFrame:(NSRect)frame parent:(UICocoaDockIconPreviewPrivate*)parent;
     48@end
     49
     50@interface UIDockTile: NSView
     51{
     52    UICocoaDockIconPreviewPrivate *p;
     53
     54    UIDockTileMonitor *mMonitor;
    5555    NSImageView     *mAppIcon;
    5656
    57     DockTileOverlay *mOverlay;
    58 }
    59 - (id)initWithParent:(CocoaDockIconPreviewPrivate*)parent;
     57    UIDockTileOverlay *mOverlay;
     58}
     59- (id)initWithParent:(UICocoaDockIconPreviewPrivate*)parent;
    6060- (NSView*)screenContent;
    6161- (void)cleanup;
     
    7171 * from any Cocoa class.
    7272 */
    73 class CocoaDockIconPreviewPrivate: public AbstractDockIconPreviewHelper
     73class UICocoaDockIconPreviewPrivate: public UIAbstractDockIconPreviewHelper
    7474{
    7575public:
    76     inline CocoaDockIconPreviewPrivate (VBoxConsoleWnd *aMainWnd, const QPixmap& aOverlayImage)
    77       :AbstractDockIconPreviewHelper (aMainWnd, aOverlayImage)
    78     {
    79         mDockTile = [[DockTile alloc] initWithParent:this];
    80     }
    81 
    82     inline ~CocoaDockIconPreviewPrivate()
    83     {
    84         [mDockTile release];
     76    inline UICocoaDockIconPreviewPrivate(UISession *pSession, const QPixmap& overlayImage)
     77      :UIAbstractDockIconPreviewHelper(pSession, overlayImage)
     78    {
     79        mUIDockTile = [[UIDockTile alloc] initWithParent:this];
     80    }
     81
     82    inline ~UICocoaDockIconPreviewPrivate()
     83    {
     84        [mUIDockTile release];
    8585    }
    8686     
    87     DockTile *mDockTile;
     87    UIDockTile *mUIDockTile;
    8888};
    8989
     
    9191 * Cocoa wrapper for the abstract dock icon preview class
    9292 */
    93 CocoaDockIconPreview::CocoaDockIconPreview (VBoxConsoleWnd *aMainWnd, const QPixmap& aOverlayImage)
    94   : AbstractDockIconPreview (aMainWnd, aOverlayImage)
    95 {
    96     CocoaAutoreleasePool pool;
    97 
    98     d = new CocoaDockIconPreviewPrivate (aMainWnd, aOverlayImage);
    99 }
    100 
    101 CocoaDockIconPreview::~CocoaDockIconPreview()
     93UICocoaDockIconPreview::UICocoaDockIconPreview(UISession *pSession, const QPixmap& overlayImage)
     94  : UIAbstractDockIconPreview(pSession, overlayImage)
     95{
     96    CocoaAutoreleasePool pool;
     97
     98    d = new UICocoaDockIconPreviewPrivate(pSession, overlayImage);
     99}
     100
     101UICocoaDockIconPreview::~UICocoaDockIconPreview()
    102102{
    103103    CocoaAutoreleasePool pool;
     
    106106}
    107107
    108 void CocoaDockIconPreview::updateDockOverlay()
    109 {
    110     CocoaAutoreleasePool pool;
    111 
    112     [d->mDockTile updateAppIcon];
    113 }
    114 
    115 void CocoaDockIconPreview::updateDockPreview (CGImageRef aVMImage)
    116 {
    117     CocoaAutoreleasePool pool;
    118 
    119     [d->mDockTile updateMonitorWithImage:aVMImage];
    120 }
    121 
    122 void CocoaDockIconPreview::updateDockPreview (VBoxFrameBuffer *aFrameBuffer)
    123 {
    124     CocoaAutoreleasePool pool;
    125 
    126     AbstractDockIconPreview::updateDockPreview (aFrameBuffer);
    127 }
    128 
    129 
    130 void CocoaDockIconPreview::setOriginalSize (int aWidth, int aHeight)
    131 {
    132     CocoaAutoreleasePool pool;
    133 
    134     [d->mDockTile resizeMonitor:NSMakeSize (aWidth, aHeight)];
     108void UICocoaDockIconPreview::updateDockOverlay()
     109{
     110    CocoaAutoreleasePool pool;
     111
     112    [d->mUIDockTile updateAppIcon];
     113}
     114
     115void UICocoaDockIconPreview::updateDockPreview(CGImageRef VMImage)
     116{
     117    CocoaAutoreleasePool pool;
     118
     119    [d->mUIDockTile updateMonitorWithImage:VMImage];
     120}
     121
     122void UICocoaDockIconPreview::updateDockPreview(UIFrameBuffer *pFrameBuffer)
     123{
     124    CocoaAutoreleasePool pool;
     125
     126    UIAbstractDockIconPreview::updateDockPreview(pFrameBuffer);
     127}
     128
     129void UICocoaDockIconPreview::setOriginalSize(int width, int height)
     130{
     131    CocoaAutoreleasePool pool;
     132
     133    [d->mUIDockTile resizeMonitor:NSMakeSize(width, height)];
    135134}
    136135
     
    138137 * Class for arranging/updating the layers for the glossy monitor preview.
    139138 */
    140 @implementation DockTileMonitor;
    141 - (id)initWithFrame:(NSRect)frame parent:(CocoaDockIconPreviewPrivate*)parent
     139@implementation UIDockTileMonitor;
     140- (id)initWithFrame:(NSRect)frame parent:(UICocoaDockIconPreviewPrivate*)parent
    142141{
    143142    self = [super initWithFrame:frame];
     
    147146        p = parent;
    148147        /* The screen content view */
    149         mScreenContent = [[NSImageView alloc] initWithFrame:NSRectFromCGRect (p->flipRect (p->mUpdateRect))];
     148        mScreenContent = [[NSImageView alloc] initWithFrame:NSRectFromCGRect(p->flipRect(p->m_updateRect))];
    150149//        [mScreenContent setImageAlignment: NSImageAlignCenter];
    151150        [mScreenContent setImageAlignment: NSImageAlignTop| NSImageAlignLeft];
     
    153152        [self addSubview: mScreenContent];
    154153        /* The state view */
    155         mMonitorGlossy = [[NSImageView alloc] initWithFrame:NSRectFromCGRect (p->flipRect (p->mMonitorRect))];
    156         [mMonitorGlossy setImage: darwinCGImageToNSImage (p->mDockMonitorGlossy)];
     154        mMonitorGlossy = [[NSImageView alloc] initWithFrame:NSRectFromCGRect(p->flipRect(p->m_monitorRect))];
     155        [mMonitorGlossy setImage: darwinCGImageToNSImage (p->m_dockMonitorGlossy)];
    157156        [self addSubview: mMonitorGlossy];
    158157    }
     
    163162- (void)drawRect:(NSRect)aRect;
    164163{
    165     NSImage *dockMonitor = darwinCGImageToNSImage (p->mDockMonitor);
    166     [dockMonitor drawInRect:NSRectFromCGRect (p->flipRect (p->mMonitorRect)) fromRect:aRect operation:NSCompositeSourceOver fraction:1.0];
     164    NSImage *dockMonitor = darwinCGImageToNSImage(p->m_dockMonitor);
     165    [dockMonitor drawInRect:NSRectFromCGRect(p->flipRect(p->m_monitorRect)) fromRect:aRect operation:NSCompositeSourceOver fraction:1.0];
    167166    [dockMonitor release];
    168167}
     
    180179    if (size.width > size.height)
    181180    {
    182         w = p->mUpdateRect.size.width;
    183         h = ((float)size.height / size.width * p->mUpdateRect.size.height);
     181        w = p->m_updateRect.size.width;
     182        h = ((float)size.height / size.width * p->m_updateRect.size.height);
    184183    }
    185184    else
    186185    {
    187         w = ((float)size.width / size.height * p->mUpdateRect.size.width);
    188         h = p->mUpdateRect.size.height;
    189     }
    190     CGRect r = (p->flipRect (p->centerRectTo (CGRectMake (0, 0, (int)w, (int)h), p->mUpdateRect)));
     186        w = ((float)size.width / size.height * p->m_updateRect.size.width);
     187        h = p->m_updateRect.size.height;
     188    }
     189    CGRect r = (p->flipRect (p->centerRectTo (CGRectMake (0, 0, (int)w, (int)h), p->m_updateRect)));
    191190    r.origin.x = (int)r.origin.x;
    192191    r.origin.y = (int)r.origin.y;
     
    203202 * in the application icon & preview mode.
    204203 */
    205 @implementation DockTileOverlay
    206 - (id)initWithFrame:(NSRect)frame parent:(CocoaDockIconPreviewPrivate*)parent
     204@implementation UIDockTileOverlay
     205- (id)initWithFrame:(NSRect)frame parent:(UICocoaDockIconPreviewPrivate*)parent
    207206{
    208207    self = [super initWithFrame:frame];
     
    226225 * and preview mode & forwards all update request to the appropriate methods.
    227226 */
    228 @implementation DockTile
    229 - (id)initWithParent:(CocoaDockIconPreviewPrivate*)parent
     227@implementation UIDockTile
     228- (id)initWithParent:(UICocoaDockIconPreviewPrivate*)parent
    230229{
    231230    self = [super init];
     
    240239        [self restoreAppIcon];
    241240        /* The overlay */
    242         mOverlay = [[DockTileOverlay alloc] initWithFrame:NSRectFromCGRect(p->flipRect (p->mDockIconRect)) parent:p];
     241        mOverlay = [[UIDockTileOverlay alloc] initWithFrame:NSRectFromCGRect(p->flipRect (p->m_dockIconRect)) parent:p];
    243242        [self addSubview: mOverlay];
    244243    }
     
    273272    {
    274273        [self cleanup];
    275         mAppIcon = [[NSImageView alloc] initWithFrame:NSRectFromCGRect (p->flipRect (p->mDockIconRect))];
     274        mAppIcon = [[NSImageView alloc] initWithFrame:NSRectFromCGRect (p->flipRect (p->m_dockIconRect))];
    276275        [mAppIcon setImage: [NSImage imageNamed:@"NSApplicationIcon"]];
    277276        [self addSubview: mAppIcon positioned:NSWindowBelow relativeTo:mOverlay];
     
    291290        p->initPreviewImages();
    292291        [self cleanup];
    293         mMonitor = [[DockTileMonitor alloc] initWithFrame:NSRectFromCGRect (p->flipRect (p->mDockIconRect)) parent:p];
     292        mMonitor = [[UIDockTileMonitor alloc] initWithFrame:NSRectFromCGRect (p->flipRect (p->m_dockIconRect)) parent:p];
    294293        [self addSubview: mMonitor positioned:NSWindowBelow relativeTo:mOverlay];
    295294    }
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxDefs.cpp

    r26714 r27215  
    5656#ifdef Q_WS_MAC
    5757const char* VBoxDefs::GUI_RealtimeDockIconUpdateEnabled = "GUI/RealtimeDockIconUpdateEnabled";
     58const char* VBoxDefs::GUI_RealtimeDockIconUpdateMonitor = "GUI/RealtimeDockIconUpdateMonitor";
    5859const char* VBoxDefs::GUI_PresentationModeEnabled = "GUI/PresentationModeEnabled";
    5960#endif /* Q_WS_MAC */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxDefs.h

    r26790 r27215  
    174174#ifdef Q_WS_MAC
    175175    static const char* GUI_RealtimeDockIconUpdateEnabled;
     176    static const char* GUI_RealtimeDockIconUpdateMonitor;
    176177    static const char* GUI_PresentationModeEnabled;
    177178#endif /* Q_WS_MAC */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r27096 r27215  
    3535
    3636#ifdef VBOX_WITH_NEW_RUNTIME_CORE
    37 #include "UIMachine.h"
     37# include "UIMachine.h"
     38# include "UISession.h"
    3839#endif
    3940#ifdef VBOX_WITH_REGISTRATION
    40 #include "UIRegistrationWzd.h"
     41# include "UIRegistrationWzd.h"
    4142#endif
    4243#include "VBoxUpdateDlg.h"
     
    395396        else if (mGlobal.isVMConsoleProcess())
    396397        {
    397 #ifndef VBOX_WITH_NEW_RUNTIME_CORE
    398             /* TODO_NEW_CORE */
    399398            /* Check for the currently running machine */
    400             CMachine machine = mGlobal.consoleWnd().session().GetMachine();
    401             if (QString::fromUtf16(id) == machine.GetId())
     399            if (QString::fromUtf16(id) == mGlobal.vmUuid)
    402400            {
    403401                QString strKey = QString::fromUtf16(key);
    404402                QString strVal = QString::fromUtf16(value);
    405                 if (strKey == VBoxDefs::GUI_RealtimeDockIconUpdateEnabled)
     403                // TODO_NEW_CORE: we should cleanup
     404                // VBoxChangeDockIconUpdateEvent to have no parameters. So it
     405                // could really be use for both events and the consumer should
     406                // ask per GetExtraData how the current values are.
     407                if (   strKey == VBoxDefs::GUI_RealtimeDockIconUpdateEnabled
     408                    || strKey == VBoxDefs::GUI_RealtimeDockIconUpdateMonitor)
    406409                {
    407410                    /* Default to true if it is an empty value */
    408                     QString strTest = strVal.toLower();
    409                     bool f = (strTest.isEmpty() || strTest == "true");
     411                    bool f = strVal.toLower() == "false" ? false : true;
    410412                    QApplication::postEvent(&mGlobal, new VBoxChangeDockIconUpdateEvent(f));
    411413                }
    412414            }
    413 #endif /* VBOX_WITH_NEW_RUNTIME_CORE */
    414415        }
    415416#endif /* Q_WS_MAC */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h

    r26952 r27215  
    5252    /* Public getters: */
    5353    QWidget* mainWindow() const;
     54    UISession *uisession() const { return m_pSession; }
    5455
    5556private slots:
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r27132 r27215  
    3838#include "VBoxVMSettingsSF.h"
    3939#include "UIFirstRunWzd.h"
     40#ifdef Q_WS_MAC
     41# include "DockIconPreview.h"
     42#endif /* Q_WS_MAC */
    4043
    4144//#include "VBoxDownloaderWgt.h"
     
    5861#ifdef VBOX_WITH_DEBUGGER_GUI
    5962# include <iprt/ldr.h>
    60 #endif
     63#endif /* VBOX_WITH_DEBUGGER_GUI */
    6164
    6265#ifdef Q_WS_X11
    6366# include <XKeyboard.h>
    64 #endif
    65 
    66 #ifdef Q_WS_X11
    6767# include <QX11Info>
    68 #endif
     68#endif /* Q_WS_X11 */
    6969
    7070struct MediumTarget
     
    396396}
    397397
     398#ifdef Q_WS_MAC
     399void UIMachineLogic::updateDockIcon()
     400{
     401    if (!isMachineWindowsCreated())
     402        return;
     403
     404    if (   m_fIsDockIconEnabled
     405        && m_pDockIconPreview)
     406        if(UIMachineView *pView = machineWindows().at(m_DockIconPreviewMonitor)->machineView())
     407            if (CGImageRef image = pView->vmContentImage())
     408            {
     409                m_pDockIconPreview->updateDockPreview(image);
     410                CGImageRelease(image);
     411            }
     412}
     413#endif /* Q_WS_MAC */
     414
    398415UIMachineLogic::UIMachineLogic(QObject *pParent,
    399416                               UISession *pSession,
    400417                               UIActionsPool *pActionsPool,
    401418                               UIVisualStateType visualStateType)
    402     : QObject(pParent)
     419    : QIWithRetranslateUI3<QObject>(pParent)
    403420    , m_pSession(pSession)
    404421    , m_pActionsPool(pActionsPool)
     
    409426    , m_fIsPreventAutoStart(false)
    410427    , m_fIsPreventAutoClose(false)
     428#ifdef Q_WS_MAC
     429    , m_fIsDockIconEnabled(true)
     430    , m_pDockIconPreview(0)
     431    , m_pDockPreviewSelectMonitorGroup(0)
     432    , m_DockIconPreviewMonitor(0)
     433#endif /* Q_WS_MAC */
    411434{
    412435}
     
    418441    //dbgDestroy();
    419442#endif
     443
     444#ifdef Q_WS_MAC
     445    if (m_pDockIconPreview)
     446        delete m_pDockIconPreview;
     447#endif /* Q_WS_MAC */
    420448}
    421449
     
    429457    m_machineWindowsList << pMachineWindow;
    430458}
     459
     460void UIMachineLogic::retranslateUi()
     461{
     462#ifdef Q_WS_MAC
     463    if (m_pDockPreviewSelectMonitorGroup)
     464    {
     465        const QList<QAction*> &actions = m_pDockPreviewSelectMonitorGroup->actions();
     466        for (int i = 0; i < actions.size(); ++i)
     467        {
     468            QAction *pAction = actions.at(i);
     469            pAction->setText(tr("Preview Monitor %1").arg(pAction->data().toInt() + 1));
     470        }
     471    }
     472#endif /* Q_WS_MAC */
     473}
     474
     475#ifdef Q_WS_MAC
     476void UIMachineLogic::updateDockOverlay()
     477{
     478    /* Only to an update to the realtime preview if this is enabled by the user
     479     * & we are in an state where the framebuffer is likely valid. Otherwise to
     480     * the overlay stuff only. */
     481    KMachineState state = uisession()->machineState();
     482    if (m_fIsDockIconEnabled &&
     483        (state == KMachineState_Running ||
     484         state == KMachineState_Paused ||
     485         state == KMachineState_Teleporting ||
     486         state == KMachineState_LiveSnapshotting ||
     487         state == KMachineState_Restoring ||
     488         state == KMachineState_TeleportingPausedVM ||
     489         state == KMachineState_TeleportingIn ||
     490         state == KMachineState_Saving))
     491        updateDockIcon();
     492    else if (m_pDockIconPreview)
     493        m_pDockIconPreview->updateDockOverlay();
     494}
     495#endif /* Q_WS_MAC */
    431496
    432497void UIMachineLogic::prepareConsoleConnections()
     
    578643    QMenu *pDockSettingsMenu = actionsPool()->action(UIActionIndex_Menu_DockSettings)->menu();
    579644    QActionGroup *pDockPreviewModeGroup = new QActionGroup(this);
     645    QAction *pDockDisablePreview = actionsPool()->action(UIActionIndex_Toggle_DockDisableMonitor);
     646    pDockPreviewModeGroup->addAction(pDockDisablePreview);
    580647    QAction *pDockEnablePreviewMonitor = actionsPool()->action(UIActionIndex_Toggle_DockPreviewMonitor);
    581648    pDockPreviewModeGroup->addAction(pDockEnablePreviewMonitor);
    582     QAction *pDockDisablePreview = actionsPool()->action(UIActionIndex_Toggle_DockDisableMonitor);
    583     pDockPreviewModeGroup->addAction(pDockDisablePreview);
    584649    pDockSettingsMenu->addActions(pDockPreviewModeGroup->actions());
    585 
    586     pDockMenu->addMenu(pDockSettingsMenu);
    587650
    588651    connect(pDockPreviewModeGroup, SIGNAL(triggered(QAction*)),
    589652            this, SLOT(sltDockPreviewModeChanged(QAction*)));
     653    connect(&vboxGlobal(), SIGNAL(dockIconUpdateChanged(const VBoxChangeDockIconUpdateEvent &)),
     654            this, SLOT(sltChangeDockIconUpdate(const VBoxChangeDockIconUpdateEvent &)));
     655
     656    /* Monitor selection if there are more than one monitor */
     657    int cGuestScreens = uisession()->session().GetMachine().GetMonitorCount();
     658    if (cGuestScreens > 1)
     659    {
     660        pDockSettingsMenu->addSeparator();
     661        m_DockIconPreviewMonitor = session().GetMachine().GetExtraData(VBoxDefs::GUI_RealtimeDockIconUpdateMonitor).toInt();
     662        m_pDockPreviewSelectMonitorGroup = new QActionGroup(this);
     663        for (int i = 0; i < cGuestScreens; ++i)
     664        {
     665            QAction *pAction = new QAction(m_pDockPreviewSelectMonitorGroup);
     666            pAction->setCheckable(true);
     667            pAction->setData(i);
     668            if (m_DockIconPreviewMonitor == i)
     669                pAction->setChecked(true);
     670        }
     671        pDockSettingsMenu->addActions(m_pDockPreviewSelectMonitorGroup->actions());
     672        connect(m_pDockPreviewSelectMonitorGroup, SIGNAL(triggered(QAction*)),
     673                this, SLOT(sltDockPreviewMonitorChanged(QAction*)));
     674    }
     675
     676    pDockMenu->addMenu(pDockSettingsMenu);
    590677
    591678    /* Add it to the dock. */
    592679    extern void qt_mac_set_dock_menu(QMenu *);
    593680    qt_mac_set_dock_menu(pDockMenu);
     681
     682    /* Now the dock icon preview */
     683    QString osTypeId = session().GetConsole().GetGuest().GetOSTypeId();
     684    m_pDockIconPreview = new UIDockIconPreview(m_pSession, vboxGlobal().vmGuestOSTypeIcon(osTypeId));
     685
     686    QString strTest = session().GetMachine().GetExtraData(VBoxDefs::GUI_RealtimeDockIconUpdateEnabled).toLower();
     687    /* Default to true if it is an empty value */
     688    bool f = (strTest.isEmpty() || strTest == "true");
     689    if (f)
     690        pDockEnablePreviewMonitor->setChecked(true);
     691    else
     692        pDockDisablePreview->setChecked(true);
     693
     694    /* Default to true if it is an empty value */
     695    setDockIconPreviewEnabled(f);
     696    updateDockOverlay();
    594697}
    595698#endif /* Q_WS_MAC */
     
    741844            break;
    742845    }
     846
     847#ifdef Q_WS_MAC
     848    /* Update Dock Overlay: */
     849    updateDockOverlay();
     850#endif /* Q_WS_MAC */
    743851}
    744852
     
    14341542void UIMachineLogic::sltDockPreviewModeChanged(QAction *pAction)
    14351543{
    1436 //    if (mConsole)
    1437     {
    1438         CMachine machine = m_pSession->session().GetMachine();
    1439         if (!machine.isNull())
    1440         {
    1441             if (pAction == actionsPool()->action(UIActionIndex_Toggle_DockDisableMonitor))
    1442                 machine.SetExtraData(VBoxDefs::GUI_RealtimeDockIconUpdateEnabled, "false");
    1443             else if (pAction == actionsPool()->action(UIActionIndex_Toggle_DockPreviewMonitor))
    1444                 machine.SetExtraData(VBoxDefs::GUI_RealtimeDockIconUpdateEnabled, "true");
    1445 //            mConsole->updateDockOverlay();
    1446         }
     1544    CMachine machine = m_pSession->session().GetMachine();
     1545    if (!machine.isNull())
     1546    {
     1547        bool fEnabled = true;
     1548        if (pAction == actionsPool()->action(UIActionIndex_Toggle_DockDisableMonitor))
     1549            fEnabled = false;
     1550
     1551        machine.SetExtraData(VBoxDefs::GUI_RealtimeDockIconUpdateEnabled, fEnabled ? "true" : "false");
     1552        updateDockOverlay();
     1553    }
     1554}
     1555
     1556void UIMachineLogic::sltDockPreviewMonitorChanged(QAction *pAction)
     1557{
     1558    CMachine machine = m_pSession->session().GetMachine();
     1559    if (!machine.isNull())
     1560    {
     1561        int monitor = pAction->data().toInt();
     1562        machine.SetExtraData(VBoxDefs::GUI_RealtimeDockIconUpdateMonitor, QString::number(monitor));
     1563        updateDockOverlay();
     1564    }
     1565}
     1566
     1567void UIMachineLogic::sltChangeDockIconUpdate(const VBoxChangeDockIconUpdateEvent &event)
     1568{
     1569    if (isMachineWindowsCreated())
     1570    {
     1571        setDockIconPreviewEnabled(event.mChanged);
     1572        m_pDockPreviewSelectMonitorGroup->setEnabled(event.mChanged);
     1573        m_DockIconPreviewMonitor = session().GetMachine().GetExtraData(VBoxDefs::GUI_RealtimeDockIconUpdateMonitor).toInt();
     1574        updateDockOverlay();
    14471575    }
    14481576}
     
    16121740
    16131741#if 0 // TODO: Where to move that?
    1614 # ifdef Q_WS_MAC
    1615 void UIMachineLogic::fadeToBlack()
    1616 {
    1617     /* Fade to black */
    1618     CGAcquireDisplayFadeReservation (kCGMaxDisplayReservationInterval, &mFadeToken);
    1619     CGDisplayFade (mFadeToken, 0.3, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0.0, 0.0, 0.0, true);
    1620 }
    1621 void UIMachineLogic::fadeToNormal()
    1622 {
    1623     /* Fade back to the normal gamma */
    1624     CGDisplayFade (mFadeToken, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, false);
    1625     CGReleaseDisplayFadeReservation (mFadeToken);
    1626     mConsole->setMouseCoalescingEnabled (true);
    1627 }
    1628 # endif
    1629 bool UIMachineLogic::toggleFullscreenMode (bool fOn, bool fSeamless)
    1630 {
    1631     /* Please note: For some platforms like the Mac, the calling order of the
    1632      * functions in this methods is vital. So please be careful on changing
    1633      * this. */
    1634 
    1635     QSize initialSize = size();
    1636     if (fSeamless || mConsole->isAutoresizeGuestActive())
    1637     {
    1638         QRect screen = fSeamless ?
    1639             QApplication::desktop()->availableGeometry (this) :
    1640             QApplication::desktop()->screenGeometry (this);
    1641         ULONG64 availBits = mSession.GetMachine().GetVRAMSize() /* vram */
    1642                           * _1M /* mb to bytes */
    1643                           * 8; /* to bits */
    1644         ULONG guestBpp = mConsole->console().GetDisplay().GetBitsPerPixel();
    1645         ULONG64 usedBits = (screen.width() /* display width */
    1646                          * screen.height() /* display height */
    1647                          * guestBpp
    1648                          + _1M * 8) /* current cache per screen - may be changed in future */
    1649                          * mSession.GetMachine().GetMonitorCount() /**< @todo fix assumption that all screens have same resolution */
    1650                          + 4096 * 8; /* adapter info */
    1651         if (fOn && (availBits < usedBits))
    1652         {
    1653             if (fSeamless)
    1654             {
    1655                 vboxProblem().cannotEnterSeamlessMode (
    1656                     screen.width(), screen.height(), guestBpp,
    1657                     (((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M);
    1658                 return false;
    1659             }
    1660             else
    1661             {
    1662                 int result = vboxProblem().cannotEnterFullscreenMode (
    1663                     screen.width(), screen.height(), guestBpp,
    1664                     (((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M);
    1665                 if (result == QIMessageBox::Cancel)
    1666                     return false;
    1667             }
    1668         }
    1669     }
    1670 
    1671     AssertReturn (mConsole, false);
    1672     AssertReturn ((mHiddenChildren.empty() == fOn), false);
    1673     AssertReturn ((fSeamless && mIsSeamless != fOn) ||
    1674                   (!fSeamless && mIsFullscreen != fOn), false);
    1675     if (fOn)
    1676         AssertReturn ((fSeamless && !mIsFullscreen) ||
    1677                       (!fSeamless && !mIsSeamless), false);
    1678 
    1679     if (fOn)
    1680     {
    1681         /* Take the toggle hot key from the menu item. Since
    1682          * VBoxGlobal::extractKeyFromActionText gets exactly the
    1683          * linked key without the 'Host+' part we are adding it here. */
    1684         QString hotKey = QString ("Host+%1")
    1685             .arg (VBoxGlobal::extractKeyFromActionText (fSeamless ?
    1686                   mVmSeamlessAction->text() : mVmFullscreenAction->text()));
    1687 
    1688         Assert (!hotKey.isEmpty());
    1689 
    1690         /* Show the info message. */
    1691         bool ok = fSeamless ?
    1692             vboxProblem().confirmGoingSeamless (hotKey) :
    1693             vboxProblem().confirmGoingFullscreen (hotKey);
    1694         if (!ok)
    1695             return false;
    1696     }
    1697 
    1698 #ifdef Q_WS_MAC
    1699     if (!fSeamless)
    1700     {
    1701     }
    1702 #endif
    1703 
    1704     if (fSeamless)
    1705     {
    1706         /* Activate the auto-resize feature required for the seamless mode. */
    1707         if (!mVmAutoresizeGuestAction->isChecked())
    1708             mVmAutoresizeGuestAction->setChecked (true);
    1709 
    1710         /* Activate the mouse integration feature for the seamless mode. */
    1711         if (mVmDisableMouseIntegrAction->isChecked())
    1712             mVmDisableMouseIntegrAction->setChecked (false);
    1713 
    1714         mVmAdjustWindowAction->setEnabled (!fOn);
    1715         mVmFullscreenAction->setEnabled (!fOn);
    1716         mVmAutoresizeGuestAction->setEnabled (!fOn);
    1717         mVmDisableMouseIntegrAction->setEnabled (!fOn);
    1718 
    1719         mConsole->console().GetDisplay().SetSeamlessMode (fOn);
    1720         mIsSeamless = fOn;
    1721     }
    1722     else
    1723     {
    1724         mIsFullscreen = fOn;
    1725         mVmAdjustWindowAction->setEnabled (!fOn);
    1726         mVmSeamlessAction->setEnabled (!fOn && m_fIsGuestSupportsSeamless && m_fIsGuestSupportsGraphics);
    1727     }
    1728 
    1729     bool wasHidden = isHidden();
    1730 
    1731     /* Temporarily disable the mode-related action to make sure
    1732      * user can not leave the mode before he enter it and inside out. */
    1733     fSeamless ? mVmSeamlessAction->setEnabled (false) :
    1734                 mVmFullscreenAction->setEnabled (false);
    1735 
    1736     /* Calculate initial console size */
    1737     QSize consoleSize;
    1738 
    1739     if (fOn)
    1740     {
    1741         consoleSize = mConsole->frameSize();
    1742         consoleSize -= QSize (mConsole->frameWidth() * 2, mConsole->frameWidth() * 2);
    1743 
    1744         /* Toggle console to manual resize mode. */
    1745         mConsole->setIgnoreMainwndResize (true);
    1746 
    1747         /* Memorize the maximized state. */
    1748         QDesktopWidget *dtw = QApplication::desktop();
    1749         mWasMax = isWindowMaximized() &&
    1750                   dtw->availableGeometry().width()  == frameSize().width() &&
    1751                   dtw->availableGeometry().height() == frameSize().height();
    1752 
    1753         /* Save the previous scroll-view minimum size before entering
    1754          * fullscreen/seamless state to restore this minimum size before
    1755          * the exiting fullscreen. Required for correct scroll-view and
    1756          * guest display update in SDL mode. */
    1757         mPrevMinSize = mConsole->minimumSize();
    1758         mConsole->setMinimumSize (0, 0);
    1759 
    1760         /* let the widget take the whole available desktop space */
    1761         QRect scrGeo = fSeamless ?
    1762             dtw->availableGeometry (this) : dtw->screenGeometry (this);
    1763 
    1764         /* It isn't guaranteed that the guest os set the video mode that
    1765          * we requested. So after all the resizing stuff set the clipping
    1766          * mask and the spacing shifter to the corresponding values. */
    1767         if (fSeamless)
    1768             setViewInSeamlessMode (scrGeo);
    1769 
    1770 #ifdef Q_WS_WIN
    1771         mPrevRegion = dtw->screenGeometry (this);
    1772 #endif
    1773 
    1774         /* Hide all but the central widget containing the console view. */
    1775         QList <QWidget*> list (findChildren <QWidget*> ());
    1776         QList <QWidget*> excludes;
    1777         excludes << centralWidget() << centralWidget()->findChildren <QWidget*> ();
    1778         foreach (QWidget *w, list)
    1779         {
    1780             if (!excludes.contains (w))
    1781             {
    1782                 if (!w->isHidden())
    1783                 {
    1784                     w->hide();
    1785                     mHiddenChildren.append (w);
    1786                 }
    1787             }
    1788         }
    1789 
    1790         /* Adjust colors and appearance. */
    1791         mErasePalette = centralWidget()->palette();
    1792         QPalette palette(mErasePalette);
    1793         palette.setColor (centralWidget()->backgroundRole(), Qt::black);
    1794         centralWidget()->setPalette (palette);
    1795         centralWidget()->setAutoFillBackground (!fSeamless);
    1796         mConsoleStyle = mConsole->frameStyle();
    1797         mConsole->setFrameStyle (QFrame::NoFrame);
    1798         mConsole->setMaximumSize (scrGeo.size());
    1799         mConsole->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
    1800         mConsole->setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
    1801     }
    1802     else
    1803     {
    1804         /* Reset the shifting spacers. */
    1805         mShiftingSpacerLeft->changeSize (0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
    1806         mShiftingSpacerTop->changeSize (0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
    1807         mShiftingSpacerRight->changeSize (0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
    1808         mShiftingSpacerBottom->changeSize (0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
    1809 
    1810         /* Restore the previous scroll-view minimum size before the exiting
    1811          * fullscreen. Required for correct scroll-view and guest display
    1812          * update in SDL mode. */
    1813         mConsole->setMinimumSize (mPrevMinSize);
    1814 
    1815 #ifdef Q_WS_MAC
    1816         if (fSeamless)
    1817         {
    1818             /* Please note: All the stuff below has to be done before the
    1819              * window switch back to normal size. Qt changes the winId on the
    1820              * fullscreen switch and make this stuff useless with the old
    1821              * winId. So please be careful on rearrangement of the method
    1822              * calls. */
    1823             /* Undo all mac specific installations */
    1824             ::darwinSetShowsWindowTransparent (this, false);
    1825         }
    1826 #endif
    1827 
    1828         /* Adjust colors and appearance. */
    1829         clearMask();
    1830         centralWidget()->setPalette (mErasePalette);
    1831         centralWidget()->setAutoFillBackground (false);
    1832         mConsole->setFrameStyle (mConsoleStyle);
    1833         mConsole->setMaximumSize (mConsole->sizeHint());
    1834         mConsole->setHorizontalScrollBarPolicy (Qt::ScrollBarAsNeeded);
    1835         mConsole->setVerticalScrollBarPolicy (Qt::ScrollBarAsNeeded);
    1836 
    1837         /* Show everything hidden when going fullscreen. */
    1838         foreach (QPointer <QWidget> child, mHiddenChildren)
    1839             if (child) child->show();
    1840         mHiddenChildren.clear();
    1841     }
    1842 
    1843     /* Set flag for waiting host resize if it awaited during mode entering */
    1844     if ((mIsFullscreen || mIsSeamless) && (consoleSize != initialSize))
    1845         mIsWaitingModeResize = true;
    1846 
    1847     if (!fOn)
    1848     {
    1849         /* Animation takes a bit long, the mini toolbar is still disappearing
    1850          * when switched to normal mode so hide it completely */
    1851         mMiniToolBar->hide();
    1852         mMiniToolBar->updateDisplay (false, true);
    1853     }
    1854 
    1855     /* Toggle qt full-screen mode */
    1856     switchToFullscreen (fOn, fSeamless);
    1857 
    1858     if (fOn)
    1859     {
    1860         mMiniToolBar->setSeamlessMode (fSeamless);
    1861         mMiniToolBar->updateDisplay (true, true);
    1862     }
    1863 
    1864 #ifdef Q_WS_MAC
    1865     if (fOn && fSeamless)
    1866     {
    1867         /* Please note: All the stuff below has to be done after the window has
    1868          * switched to fullscreen. Qt changes the winId on the fullscreen
    1869          * switch and make this stuff useless with the old winId. So please be
    1870          * careful on rearrangement of the method calls. */
    1871         ::darwinSetShowsWindowTransparent (this, true);
    1872     }
    1873 #endif
    1874 
    1875     /* Send guest size hint */
    1876     mConsole->toggleFSMode (consoleSize);
    1877 
    1878     /* Process all console attributes changes and sub-widget hidings */
    1879     qApp->processEvents();
    1880 
    1881     if (!mIsWaitingModeResize)
    1882         onExitFullscreen();
    1883 
    1884     /* Unlock FS actions locked during modes toggling */
    1885     QTimer::singleShot (300, this, SLOT (unlockActionsSwitch()));
    1886 
    1887 #ifdef Q_WS_MAC /* wasHidden is wrong on the mac it seems. */
    1888     /** @todo figure out what is really wrong here... */
    1889     if (!wasHidden)
    1890         show();
    1891 #else
    1892     if (wasHidden)
    1893         hide();
    1894 #endif
    1895     return true;
    1896 }
    1897 void UIMachineLogic::switchToFullscreen (bool fOn, bool fSeamless)
    1898 {
    1899 #ifdef Q_WS_MAC
    1900 # ifndef QT_MAC_USE_COCOA
    1901     /* setWindowState removes the window group connection somehow. So save it
    1902      * temporary. */
    1903     WindowGroupRef g = GetWindowGroup (::darwinToNativeWindow (this));
    1904 # endif  /* !QT_MAC_USE_COCOA */
    1905     if (fSeamless)
    1906         if (fOn)
    1907         {
    1908             /* Save for later restoring */
    1909             mNormalGeometry = geometry();
    1910             mSavedFlags = windowFlags();
    1911             /* Remove the frame from the window */
    1912             const QRect fullscreen (qApp->desktop()->screenGeometry (qApp->desktop()->screenNumber (this)));
    1913             setParent (0, Qt::Window | Qt::FramelessWindowHint | (windowFlags() & 0xffff0000));
    1914             setGeometry (fullscreen);
    1915             /* Set it maximized */
    1916             setWindowState (windowState() ^ Qt::WindowMaximized);
    1917         }
    1918         else
    1919         {
    1920             /* Restore old values */
    1921             setParent (0, mSavedFlags);
    1922             setGeometry (mNormalGeometry);
    1923         }
    1924     else
    1925     {
    1926         /* Here we are going really fullscreen */
    1927         setWindowState (windowState() ^ Qt::WindowFullScreen);
    1928         sltChangePresentationMode (VBoxChangePresentationModeEvent(fOn));
    1929     }
    1930 
    1931 # ifndef QT_MAC_USE_COCOA
    1932     /* Reassign the correct window group. */
    1933     SetWindowGroup (::darwinToNativeWindow (this), g);
    1934 # endif /* !QT_MAC_USE_COCOA */
    1935 #else
    1936     NOREF (fOn);
    1937     NOREF (fSeamless);
    1938     setWindowState (windowState() ^ Qt::WindowFullScreen);
    1939 #endif
    1940 }
    19411742void UIMachineLogic::setViewInSeamlessMode (const QRect &aTargetRect)
    19421743{
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r27180 r27215  
    2424#define __UIMachineLogic_h__
    2525
    26 /* Global includes */
    27 #include <QObject>
    28 
    2926/* Local includes */
    3027#include "UIMachineDefs.h"
     28#include <QIWithRetranslateUI.h>
    3129#ifdef VBOX_WITH_DEBUGGER_GUI
    3230# include <VBox/dbggui.h>
     
    4644class UIActionsPool;
    4745class UIMachineWindow;
    48 
    49 class UIMachineLogic : public QObject
     46class UIDockIconPreview;
     47class VBoxChangeDockIconUpdateEvent;
     48
     49class UIMachineLogic : public QIWithRetranslateUI3<QObject>
    5050{
    5151    Q_OBJECT;
     
    7979    void setPreventAutoClose(bool fIsPreventAutoClose) { m_fIsPreventAutoClose = fIsPreventAutoClose; }
    8080
     81#ifdef Q_WS_MAC
     82    void updateDockIcon();
     83#endif /* Q_WS_MAC */
     84
    8185protected:
    8286
     
    97101    /* Protected members: */
    98102    void addMachineWindow(UIMachineWindow *pMachineWindow);
     103    void retranslateUi();
     104#ifdef Q_WS_MAC
     105    bool isDockIconPreviewEnabled() const { return m_fIsDockIconEnabled; }
     106    void setDockIconPreviewEnabled(bool fIsDockIconPreviewEnabled) { m_fIsDockIconEnabled = fIsDockIconPreviewEnabled; }
     107    void updateDockOverlay();
     108#endif /* Q_WS_MAC */
    99109
    100110    /* Prepare helpers: */
     
    161171#endif
    162172
    163 #ifdef Q_WS_MAC
     173#ifdef RT_OS_DARWIN /* Something is *really* broken in regards of the moc here */
    164174    void sltDockPreviewModeChanged(QAction *pAction);
    165 #endif /* Q_WS_MAC */
     175    void sltDockPreviewMonitorChanged(QAction *pAction);
     176    void sltChangeDockIconUpdate(const VBoxChangeDockIconUpdateEvent &event);
     177#endif /* RT_OS_DARWIN */
    166178
    167179private:
     
    197209#endif
    198210
     211#ifdef Q_WS_MAC
     212    bool m_fIsDockIconEnabled;
     213    UIDockIconPreview *m_pDockIconPreview;
     214    QActionGroup *m_pDockPreviewSelectMonitorGroup;
     215    int m_DockIconPreviewMonitor;
     216#endif /* Q_WS_MAC */
     217
    199218    /* Friend classes: */
    200219    friend class UIMachineWindow;
    201220
    202221#if 0 // TODO: Where to move that?
    203 # ifdef Q_WS_MAC
    204     void fadeToBlack();
    205     void fadeToNormal();
    206 # endif
    207     bool toggleFullscreenMode(bool aOn, bool aSeamless);
    208     void switchToFullscreen(bool aOn, bool aSeamless);
    209222    void setViewInSeamlessMode(const QRect &aTargetRect);
    210223#endif
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r27207 r27215  
    8282# include "DockIconPreview.h"
    8383# include "DarwinKeyboard.h"
    84 # ifdef QT_MAC_USE_COCOA
    85 #  include "darwin/VBoxCocoaApplication.h"
    86 # else /* QT_MAC_USE_COCOA */
    87 #  include <Carbon/Carbon.h>
    88 # endif /* !QT_MAC_USE_COCOA */
     84# include "darwin/VBoxCocoaApplication.h"
    8985# include <VBox/err.h>
    90 #endif /* defined (Q_WS_MAC) */
     86#endif /* Q_WS_MAC */
    9187
    9288class VBoxViewport: public QWidget
     
    216212#ifdef VBOX_WITH_VIDEOHWACCEL
    217213    , m_fAccelerate2DVideo(bAccelerate2DVideo)
    218 #endif
    219 #if defined(Q_WS_MAC)
    220 # ifndef QT_MAC_USE_COCOA
    221     , m_darwinEventHandlerRef(NULL)
    222 # endif /* !QT_MAC_USE_COCOA */
     214#endif /* VBOX_WITH_VIDEOHWACCEL */
     215#ifdef Q_WS_MAC
    223216    , m_darwinKeyModifiers(0)
    224217    , m_fKeyboardGrabbed (false)
    225     , mDockIconEnabled(true)
    226 #endif
     218#endif /* Q_WS_MAC */
    227219{
    228220}
     
    534526    NOREF(ok);
    535527#endif
    536 
    537 #if defined Q_WS_MAC
    538     /* Dock icon update connection */
    539     connect(&vboxGlobal(), SIGNAL(dockIconUpdateChanged(const VBoxChangeDockIconUpdateEvent &)),
    540             this, SLOT(sltChangeDockIconUpdate(const VBoxChangeDockIconUpdateEvent &)));
    541 
    542     /* Overlay logo for the dock icon */
    543     //mVirtualBoxLogo = ::darwinToCGImageRef("VirtualBox_cube_42px.png");
    544     QString osTypeId = session().GetConsole().GetGuest().GetOSTypeId();
    545 
    546     // TODO_NEW_CORE
    547 //    mDockIconPreview = new VBoxDockIconPreview(machineWindowWrapper(), vboxGlobal().vmGuestOSTypeIcon (osTypeId));
    548 
    549 # ifdef QT_MAC_USE_COCOA
    550     /** @todo Carbon -> Cocoa */
    551 # else /* !QT_MAC_USE_COCOA */
    552     /* Install the event handler which will proceed external window handling */
    553     EventHandlerUPP eventHandler = ::NewEventHandlerUPP(::darwinOverlayWindowHandler);
    554     EventTypeSpec eventTypes[] =
    555     {
    556         { kEventClassVBox, kEventVBoxShowWindow },
    557         { kEventClassVBox, kEventVBoxHideWindow },
    558         { kEventClassVBox, kEventVBoxMoveWindow },
    559         { kEventClassVBox, kEventVBoxResizeWindow },
    560         { kEventClassVBox, kEventVBoxDisposeWindow },
    561         { kEventClassVBox, kEventVBoxUpdateDock }
    562     };
    563 
    564     mDarwinWindowOverlayHandlerRef = NULL;
    565     ::InstallApplicationEventHandler(eventHandler, RT_ELEMENTS (eventTypes), &eventTypes[0], this, &mDarwinWindowOverlayHandlerRef);
    566     ::DisposeEventHandlerUPP(eventHandler);
    567 # endif /* !QT_MAC_USE_COCOA */
    568 #endif
    569528}
    570529
     
    628587            m_fPassCAD = true;
    629588    }
    630 
    631 #ifdef Q_WS_MAC
    632     QString strSettings = vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_RealtimeDockIconUpdateEnabled).toLower();
    633     /* Default to true if it is an empty value: */
    634     bool fIsDockIconEnabled = strSettings.isEmpty() || strSettings == "true";
    635     setDockIconEnabled(fIsDockIconEnabled);
    636     updateDockOverlay();
    637 #endif
    638589}
    639590
    640591void UIMachineView::cleanupCommon()
    641592{
    642 #if defined (Q_WS_PM)
     593#ifdef Q_WS_PM
    643594    bool ok = VBoxHlpUninstallKbdHook(0, winId(), UM_PREACCEL_CHAR);
    644595    Assert(ok);
    645596    NOREF(ok);
    646 #endif
    647 
    648 #if defined (Q_WS_WIN)
     597#endif /* Q_WS_PM */
     598
     599#ifdef Q_WS_WIN
    649600    if (gKbdHook)
    650601        UnhookWindowsHookEx(gKbdHook);
    651602    gView = 0;
    652 #endif
     603#endif /* Q_WS_WIN */
    653604
    654605#ifdef Q_WS_MAC
     
    657608    if (m_fKeyboardGrabbed)
    658609        darwinGrabKeyboardEvents (false);
    659 # ifndef QT_MAC_USE_COCOA
    660     if (mDarwinWindowOverlayHandlerRef)
    661     {
    662         ::RemoveEventHandler(mDarwinWindowOverlayHandlerRef);
    663         mDarwinWindowOverlayHandlerRef = NULL;
    664     }
    665 # endif /* !QT_MAC_USE_COCOA */
    666     // TODO_NEW_CORE
    667 //    delete mDockIconPreview;
    668     mDockIconPreview = NULL;
    669610#endif /* Q_WS_MAC */
    670611}
     
    1005946            }
    1006947#endif /* defined (Q_WS_WIN32) */
    1007 #if defined (Q_WS_MAC)
     948#ifdef Q_WS_MAC
    1008949            /* Install/remove the keyboard event handler: */
    1009950            case QEvent::WindowActivate:
     
    1013954                darwinGrabKeyboardEvents(false);
    1014955                break;
    1015 #endif /* defined (Q_WS_MAC) */
     956#endif /* Q_WS_MAC */
    1016957            default:
    1017958                break;
     
    10791020    }
    10801021
    1081 #ifdef Q_WS_MAC
    1082     /* Update Dock Overlay: */
    1083     updateDockOverlay();
    1084 #endif /* Q_WS_MAC */
    1085 
    10861022    m_previousState = state;
    10871023}
     
    11351071    }
    11361072}
    1137 
    1138 #ifdef Q_WS_MAC
    1139 void UIMachineView::sltChangeDockIconUpdate(const VBoxChangeDockIconUpdateEvent &event)
    1140 {
    1141     setDockIconEnabled(event.mChanged);
    1142     updateDockOverlay();
    1143 }
    1144 #endif
    11451073
    11461074void UIMachineView::focusEvent(bool fHasFocus, bool fReleaseHostKey /* = true */)
     
    14131341        }
    14141342#elif defined (Q_WS_MAC)
    1415         // TODO_NEW_CORE
    14161343        if (pUniKey && pUniKey[0] && !pUniKey[1])
    14171344            processed = machineWindowWrapper()->machineLogic()->actionsPool()->processHotKey(QKeySequence(Qt::UNICODE_ACCEL + QChar(pUniKey[0]).toUpper().unicode()));
     
    16891616{
    16901617    updateSliders();
    1691 #if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
    1692     QRect rectangle = viewport()->geometry();
    1693     PostBoundsChanged(rectangle);
    1694 #endif /* Q_WS_MAC */
    16951618    return QAbstractScrollArea::resizeEvent(pEvent);
    16961619}
     
    16981621void UIMachineView::moveEvent(QMoveEvent *pEvent)
    16991622{
    1700 #if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
    1701     QRect r = viewport()->geometry();
    1702     PostBoundsChanged (r);
    1703 #endif /* Q_WS_MAC */
    17041623    return QAbstractScrollArea::moveEvent(pEvent);
    17051624}
     
    17141633#ifdef Q_WS_MAC
    17151634        /* Update the dock icon if we are in the running state */
    1716             // TODO_NEW_CORE
    1717 //        if (uisession()->isRunning())
    1718 //            updateDockIcon();
    1719 #endif
     1635        if (uisession()->isRunning())
     1636            updateDockIcon();
     1637#endif /* Q_WS_MAC */
    17201638        return;
    17211639    }
     
    17251643    {
    17261644        m_pFrameBuffer->paintEvent(pPaintEvent);
    1727 //        updateDockIcon();
     1645        updateDockIcon();
    17281646    }
    17291647    else
    1730 #endif
     1648#endif /* VBOX_GUI_USE_QUARTZ2D */
    17311649    {
    17321650        /* We have a snapshot for the paused state: */
     
    17401658        viewport()->setAttribute(Qt::WA_PaintOnScreen, paintOnScreen);
    17411659#ifdef Q_WS_MAC
    1742 //        updateDockIcon();
    1743 #endif
     1660        updateDockIcon();
     1661#endif /* Q_WS_MAC */
    17441662    }
    17451663}
     
    25842502}
    25852503
    2586 #if defined(Q_WS_MAC)
     2504#ifdef Q_WS_MAC
     2505CGImageRef UIMachineView::vmContentImage()
     2506{
     2507    if (!m_pauseShot.isNull())
     2508    {
     2509        CGImageRef pauseImg = ::darwinToCGImageRef(&m_pauseShot);
     2510        /* Use the pause image as background */
     2511        return pauseImg;
     2512    }
     2513    else
     2514    {
     2515# ifdef VBOX_GUI_USE_QUARTZ2D
     2516        if (mode() == VBoxDefs::Quartz2DMode)
     2517        {
     2518            /* If the render mode is Quartz2D we could use the CGImageRef
     2519             * of the framebuffer for the dock icon creation. This saves
     2520             * some conversion time. */
     2521            CGImageRef image = static_cast<UIFrameBufferQuartz2D*>(m_pFrameBuffer)->imageRef();
     2522            CGImageRetain(image); /* Retain it, cause the consumer will release it. */
     2523            return image;
     2524        }
     2525        else
     2526# endif /* VBOX_GUI_USE_QUARTZ2D */
     2527            /* In image mode we have to create the image ref out of the
     2528             * framebuffer */
     2529            return frameBuffertoCGImageRef(m_pFrameBuffer);
     2530    }
     2531    return 0;
     2532}
     2533
     2534CGImageRef UIMachineView::frameBuffertoCGImageRef(UIFrameBuffer *pFrameBuffer)
     2535{
     2536    CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
     2537    Assert(cs);
     2538    /* Create the image copy of the framebuffer */
     2539    CGDataProviderRef dp = CGDataProviderCreateWithData(pFrameBuffer, pFrameBuffer->address(), pFrameBuffer->bitsPerPixel() / 8 * pFrameBuffer->width() * pFrameBuffer->height(), NULL);
     2540    Assert(dp);
     2541    CGImageRef ir = CGImageCreate(pFrameBuffer->width(), pFrameBuffer->height(), 8, 32, pFrameBuffer->bytesPerLine(), cs,
     2542                                  kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host, dp, 0, false,
     2543                                  kCGRenderingIntentDefault);
     2544    Assert(ir);
     2545    CGDataProviderRelease(dp);
     2546    CGColorSpaceRelease(cs);
     2547
     2548    return ir;
     2549}
     2550
    25872551void UIMachineView::updateDockIcon()
    25882552{
    2589     // TODO_NEW_CORE
    2590 //    if (mDockIconEnabled)
    2591 //    {
    2592 //        if (!m_pauseShot.isNull())
    2593 //        {
    2594 //            CGImageRef pauseImg = ::darwinToCGImageRef (&m_pauseShot);
    2595 //            /* Use the pause image as background */
    2596 //            mDockIconPreview->updateDockPreview (pauseImg);
    2597 //            CGImageRelease (pauseImg);
    2598 //        }
    2599 //        else
    2600 //        {
    2601 //# if defined (VBOX_GUI_USE_QUARTZ2D)
    2602 //            if (mode() == VBoxDefs::Quartz2DMode)
    2603 //            {
    2604 //                /* If the render mode is Quartz2D we could use the CGImageRef
    2605 //                 * of the framebuffer for the dock icon creation. This saves
    2606 //                 * some conversion time. */
    2607 //                mDockIconPreview->updateDockPreview(static_cast<UIFrameBufferQuartz2D*>(m_pFrameBuffer)->imageRef());
    2608 //            }
    2609 //            else
    2610 //# endif
    2611 //                /* In image mode we have to create the image ref out of the
    2612 //                 * framebuffer */
    2613 //                mDockIconPreview->updateDockPreview(m_pFrameBuffer);
    2614 //        }
    2615 //    }
    2616 }
    2617 
    2618 void UIMachineView::updateDockOverlay()
    2619 {
    2620     /* Only to an update to the realtime preview if this is enabled by the user
    2621      * & we are in an state where the framebuffer is likely valid. Otherwise to
    2622      * the overlay stuff only. */
    2623     // TODO_NEW_CORE
    2624 //    if (mDockIconEnabled &&
    2625 //        (machineState() == KMachineState_Running ||
    2626 //         machineState() == KMachineState_Paused ||
    2627 //         machineState() == KMachineState_Teleporting ||
    2628 //         machineState() == KMachineState_LiveSnapshotting ||
    2629 //         machineState() == KMachineState_Restoring ||
    2630 //         machineState() == KMachineState_TeleportingPausedVM ||
    2631 //         machineState() == KMachineState_TeleportingIn ||
    2632 //         machineState() == KMachineState_Saving))
    2633 //        updateDockIcon();
    2634 //    else
    2635 //        mDockIconPreview->updateDockOverlay();
     2553    machineLogic()->updateDockIcon();
    26362554}
    26372555
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h

    r27124 r27215  
    4242class UIMachineLogic;
    4343class VBoxGlobalSettings;
    44 #ifdef Q_WS_MAC
    45 class VBoxChangeDockIconUpdateEvent;
    46 class VBoxDockIconPreview;
    47 #endif /* Q_WS_MAC */
    4844
    4945class UIMachineView : public QAbstractScrollArea
     
    7672    /* Public members: */
    7773    virtual void normalizeGeometry(bool /* bAdjustPosition = false */) {}
    78 
    79 #if defined(Q_WS_MAC)
    80     void updateDockIcon();
    81     void updateDockOverlay();
    82     void setMouseCoalescingEnabled(bool fOn);
    83     void setDockIconEnabled(bool aOn) { mDockIconEnabled = aOn; };
    84 #endif
    8574
    8675signals:
     
    137126    void updateSliders();
    138127
     128#ifdef Q_WS_MAC
     129    void updateDockIcon();
     130    void setMouseCoalescingEnabled(bool fOn);
     131    CGImageRef vmContentImage();
     132    CGImageRef frameBuffertoCGImageRef(UIFrameBuffer *pFrameBuffer);
     133#endif /* Q_WS_MAC */
     134
    139135    /* Prepare routines: */
    140136    virtual void prepareFrameBuffer();
     
    165161    /* Session callback handlers: */
    166162    virtual void sltMouseCapturedStatusChanged();
    167 
    168 private slots:
    169 
    170 #ifdef Q_WS_MAC
    171     /* Dock icon update handler */
    172     void sltChangeDockIconUpdate(const VBoxChangeDockIconUpdateEvent &event);
    173 #endif
    174163
    175164private:
     
    254243#endif
    255244
    256 #if defined(Q_WS_MAC)
    257 # ifndef QT_MAC_USE_COCOA
    258     /** Event handler reference. NULL if the handler isn't installed. */
    259     EventHandlerRef m_darwinEventHandlerRef;
    260 # endif /* !QT_MAC_USE_COCOA */
     245#ifdef Q_WS_MAC
    261246    /** The current modifier key mask. Used to figure out which modifier
    262247     *  key was pressed when we get a kEventRawKeyModifiersChanged event. */
    263248    UInt32 m_darwinKeyModifiers;
    264249    bool m_fKeyboardGrabbed;
    265 #endif
     250#endif /* Q_WS_MAC */
    266251
    267252    QPixmap m_pauseShot;
    268 #if defined(Q_WS_MAC)
    269 # if !defined (QT_MAC_USE_COCOA)
    270     EventHandlerRef mDarwinWindowOverlayHandlerRef;
    271 # endif
    272     VBoxDockIconPreview *mDockIconPreview;
    273     bool mDockIconEnabled;
    274 #endif
    275253
    276254    /* Friend classes: */
     255    friend class UIMachineLogic;
    277256    friend class UIMachineWindowFullscreen;
    278257    friend class UIFrameBuffer;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp

    r27144 r27215  
    154154        sltAdditionsStateChanged();
    155155        sltMouseCapabilityChanged();
     156
     157        retranslateUi();
    156158    }
    157159}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.cpp

    r27132 r27215  
    7878        sltAdditionsStateChanged();
    7979        sltMouseCapabilityChanged();
     80
     81        retranslateUi();
    8082    }
    8183}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineLogicSeamless.cpp

    r27145 r27215  
    146146        sltAdditionsStateChanged();
    147147        sltMouseCapabilityChanged();
     148
     149        retranslateUi();
    148150    }
    149151}
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