VirtualBox

Changeset 15493 in vbox


Ignore:
Timestamp:
Dec 15, 2008 11:00:58 AM (16 years ago)
Author:
vboxsync
Message:

FE/Qt4-OSX: dock icon handling updates

Location:
trunk/src/VBox/Frontends/VirtualBox4
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox4/include/VBoxUtils.h

    r14977 r15493  
    211211/* Special routines for the dock handling */
    212212CGImageRef darwinCreateDockBadge (const char *aSource);
    213 void darwinUpdateDockPreview (CGImageRef aVMImage, CGImageRef aOverlayImage, CGImageRef aStateImage = NULL);
    214 void darwinUpdateDockPreview (VBoxFrameBuffer *aFrameBuffer, CGImageRef aOverlayImage);
     213void darwinUpdateDockPreview (QWidget *aMainWindow, CGImageRef aVMImage, CGImageRef aOverlayImage, CGImageRef aStateImage = NULL);
     214void darwinUpdateDockPreview (QWidget *aMainWindow, VBoxFrameBuffer *aFrameBuffer, CGImageRef aOverlayImage);
    215215
    216216/* Icons in the menu of an mac application are unusual. */
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxConsoleView.cpp

    r15467 r15493  
    30853085#ifdef VBOX_GUI_USE_QUARTZ2D
    30863086    if (mode == VBoxDefs::Quartz2DMode && mFrameBuf)
     3087    {
    30873088        mFrameBuf->paintEvent (pe);
     3089        ::darwinUpdateDockPreview (mMainWnd,
     3090                                   ::darwinToCGImageRef (&mPausedShot),
     3091                                   mVirtualBoxLogo,
     3092                                   mMainWnd->dockImageState());
     3093    }
    30883094    else
    30893095#endif
     
    31013107        viewport()->setAttribute (Qt::WA_PaintOnScreen, paintOnScreen);
    31023108#ifdef Q_WS_MAC
    3103         ::darwinUpdateDockPreview (::darwinToCGImageRef (&mPausedShot),
     3109        ::darwinUpdateDockPreview (mMainWnd,
     3110                                   ::darwinToCGImageRef (&mPausedShot),
    31043111                                   mVirtualBoxLogo,
    31053112                                   mMainWnd->dockImageState());
     
    38853892            CGImageRef ir =
    38863893                static_cast <VBoxQuartz2DFrameBuffer *> (mFrameBuf)->imageRef();
    3887             ::darwinUpdateDockPreview (ir, mVirtualBoxLogo);
     3894            ::darwinUpdateDockPreview (mMainWnd, ir, mVirtualBoxLogo);
    38883895        }
    38893896        else
    38903897# endif
    3891             ::darwinUpdateDockPreview (mFrameBuf, mVirtualBoxLogo);
    3892     }
    3893 }
    3894 #endif
    3895 
     3898            ::darwinUpdateDockPreview (mMainWnd, mFrameBuf, mVirtualBoxLogo);
     3899    }
     3900}
     3901#endif
     3902
  • trunk/src/VBox/Frontends/VirtualBox4/src/darwin/VBoxUtils-darwin.cpp

    r14977 r15493  
    187187 * @param   aStateImage   an optional state overlay image to add at the center of the icon
    188188 */
    189 void darwinUpdateDockPreview (CGImageRef aVMImage, CGImageRef aOverlayImage, CGImageRef aStateImage /*= NULL*/)
     189void darwinUpdateDockPreview (QWidget *aMainWindow, CGImageRef aVMImage, CGImageRef aOverlayImage, CGImageRef aStateImage /*= NULL*/)
    190190{
    191191    Assert (aVMImage);
     
    237237    CGContextDrawImage (context, iconRect, aVMImage);
    238238    /* Process the content of any external OpenGL windows. */
    239     WindowRef w = FrontNonFloatingWindow();
     239    WindowRef w = darwinToWindowRef (aMainWindow);
    240240    WindowGroupRef g = GetWindowGroup (w);
    241241    WindowGroupContentOptions wgco = kWindowGroupContentsReturnWindows | kWindowGroupContentsRecurse | kWindowGroupContentsVisible;
     
    254254            wc != w)
    255255        {
    256             Rect tmpR1;
    257             GetWindowBounds (wc, kWindowContentRgn, &tmpR1);
    258             HIRect rect;
    259             rect.size.width = (tmpR1.right-tmpR1.left) * a1;
    260             rect.size.height = (tmpR1.bottom-tmpR1.top) * a2;
    261             rect.origin.x = iconRect.origin.x + (tmpR1.left - mainRect.origin.x) * a1;
    262             rect.origin.y = targetHeight - (iconRect.origin.y + (tmpR1.top - mainRect.origin.y) * a2) - rect.size.height;
    263             /* This is a big, bad hack. The following functions aren't
    264              * documented nor official supported by apple. But its the only way
    265              * to capture the OpenGL content of a window without fiddling
    266              * around with gPixelRead or something like that. */
    267             CGSWindowID wid = GetNativeWindowFromWindowRef(wc);
    268             CGContextCopyWindowCaptureContentsToRect(context, rect, CGSMainConnectionID(), wid, 0);
     256            WindowClass winClass;
     257            status = GetWindowClass (wc, &winClass);
     258            if (status == noErr &&
     259                winClass == kOverlayWindowClass)
     260            {
     261                Rect tmpR1;
     262                GetWindowBounds (wc, kWindowContentRgn, &tmpR1);
     263                HIRect rect;
     264                rect.size.width = (tmpR1.right-tmpR1.left) * a1;
     265                rect.size.height = (tmpR1.bottom-tmpR1.top) * a2;
     266                rect.origin.x = iconRect.origin.x + (tmpR1.left - mainRect.origin.x) * a1;
     267                rect.origin.y = targetHeight - (iconRect.origin.y + (tmpR1.top - mainRect.origin.y) * a2) - rect.size.height;
     268                /* This is a big, bad hack. The following functions aren't
     269                 * documented nor official supported by apple. But its the only way
     270                 * to capture the OpenGL content of a window without fiddling
     271                 * around with gPixelRead or something like that. */
     272                CGSWindowID wid = GetNativeWindowFromWindowRef(wc);
     273                CGContextCopyWindowCaptureContentsToRect(context, rect, CGSMainConnectionID(), wid, 0);
     274            }
    269275        }
    270276    }
     
    304310 * @param   aOverlayImage   an optional icon overlay image to add at the bottom right of the icon
    305311 */
    306 void darwinUpdateDockPreview (VBoxFrameBuffer *aFrameBuffer, CGImageRef aOverlayImage)
     312void darwinUpdateDockPreview (QWidget *aMainWindow, VBoxFrameBuffer *aFrameBuffer, CGImageRef aOverlayImage)
    307313{
    308314    CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
     
    315321                                   kCGRenderingIntentDefault);
    316322    /* Update the dock preview icon */
    317     ::darwinUpdateDockPreview (ir, aOverlayImage);
     323    ::darwinUpdateDockPreview (aMainWindow, ir, aOverlayImage);
    318324    /* Release the temp data and image */
    319325    CGDataProviderRelease (dp);
Note: See TracChangeset for help on using the changeset viewer.

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