Changeset 6462 in vbox
- Timestamp:
- Jan 23, 2008 3:06:27 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 27455
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleWnd.h
r6442 r6462 182 182 void onExitFullscreen(); 183 183 184 void setViewInSeamlessMode (const QRect& targetRect);184 void setViewInSeamlessMode (const QRect &aTargetRect); 185 185 186 186 private: -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxUtils.h
r6443 r6462 255 255 CGImageRef DarwinQPixmapFromMimeSourceToCGImage (const char *aSource); 256 256 CGImageRef DarwinCreateDockBadge (const char *aSource); 257 CGImageRef DarwinCreateDockPreview (VBoxFrameBuffer *aFrameBuffer);257 CGImageRef DarwinCreateDockPreview (VBoxFrameBuffer *aFrameBuffer); 258 258 #endif /* Q_WS_MAC */ 259 259 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
r6456 r6462 1067 1067 /* emit a signal about guest was resized */ 1068 1068 emit resizeHintDone(); 1069 1069 1070 1070 return true; 1071 1071 } … … 2795 2795 #ifdef Q_WS_MAC 2796 2796 /* Update the dock icon if we are in the running state */ 2797 if (isRunning())2797 if (isRunning()) 2798 2798 SetApplicationDockTileImage(::DarwinCreateDockPreview(mFrameBuf)); 2799 2799 #endif 2800 2801 2800 return; 2802 2801 } … … 2978 2977 } 2979 2978 2980 /** 2979 /** 2981 2980 * Send the KEY BREAK code to the VM for all currently pressed keys. 2982 * 2981 * 2983 2982 * @param aReleaseHostKey @c true to set the host key state to unpressed. 2984 2983 */ -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp
r6442 r6462 632 632 setCentralWidget (new QWidget (this, "centralWidget")); 633 633 QGridLayout *pMainLayout = new QGridLayout(centralWidget(), 3, 3, 0, 0); 634 mShiftingSpacerLeft = new QSpacerItem (0, 0, 634 mShiftingSpacerLeft = new QSpacerItem (0, 0, 635 635 QSizePolicy::Fixed, 636 636 QSizePolicy::Fixed); 637 mShiftingSpacerTop = new QSpacerItem (0, 0, 637 mShiftingSpacerTop = new QSpacerItem (0, 0, 638 638 QSizePolicy::Fixed, 639 639 QSizePolicy::Fixed); 640 mShiftingSpacerRight = new QSpacerItem (0, 0, 640 mShiftingSpacerRight = new QSpacerItem (0, 0, 641 641 QSizePolicy::Fixed, 642 642 QSizePolicy::Fixed); 643 mShiftingSpacerBottom = new QSpacerItem (0, 0, 643 mShiftingSpacerBottom = new QSpacerItem (0, 0, 644 644 QSizePolicy::Fixed, 645 645 QSizePolicy::Fixed); … … 663 663 664 664 static_cast<QGridLayout*>(centralWidget()->layout())->addWidget(console, 1, 1, AlignVCenter | AlignHCenter); 665 665 666 666 CMachine cmachine = csession.GetMachine(); 667 667 … … 1007 1007 { 1008 1008 disconnect (console, SIGNAL (resizeHintDone()), 0, 0); 1009 #ifndef Q_WS_MAC 1009 #ifndef Q_WS_MAC 1010 1010 /* 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 1012 1012 * 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); 1021 1021 } 1022 1022 #endif … … 1033 1033 { 1034 1034 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); 1041 1041 } 1042 1042 #endif … … 1931 1931 if (!aSeamless) 1932 1932 { 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); 1936 1936 } 1937 1937 #endif … … 2038 2038 2039 2039 /* 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 2041 2041 * mask and the spacing shifter to the corresponding values. */ 2042 setViewInSeamlessMode (dtw->availableGeometry(this));2042 setViewInSeamlessMode (dtw->availableGeometry (this)); 2043 2043 2044 2044 #ifdef Q_WS_WIN32 … … 2070 2070 LogRel (("Error: Failed to change UI mode (rc=%#x) when changing to fullscreen mode. (=> menu bar trouble)\n", orc)); 2071 2071 } 2072 #endif 2072 #endif 2073 2073 2074 2074 /* Adjust colors and appearance. */ … … 2088 2088 // maskRect.setBottom (maskRect.bottom() + 1); 2089 2089 // setMask (maskRect); 2090 2091 2090 #else 2092 2091 // setMask (dtw->screenGeometry (this)); … … 2156 2155 // Private slots 2157 2156 ///////////////////////////////////////////////////////////////////////////// 2158 void VBoxConsoleWnd::setViewInSeamlessMode (const QRect& targetRect)2157 void VBoxConsoleWnd::setViewInSeamlessMode (const QRect &aTargetRect) 2159 2158 { 2160 2159 if (mIsSeamless) 2161 2160 { 2162 2161 /* 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 2164 2163 * mask and the spacing shifter to the corresponding values. */ 2165 2164 QDesktopWidget *dtw = QApplication::desktop(); 2166 2165 QRect sRect = dtw->screenGeometry (this); 2167 QRect aRect (targetRect);2168 QRect a1Rect (targetRect);2166 QRect aRect (aTargetRect); 2167 QRect a1Rect (aTargetRect); 2169 2168 #ifdef Q_WS_MAC 2170 2169 /* On mac os x this isn't necessary cause the screen starts 2171 2170 * 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()); 2174 2173 #endif // Q_WS_MAC 2175 2174 /* Set the clipping mask */ 2176 mStrictedRegion = QRegion (sRect) - a1Rect;2175 mStrictedRegion = QRegion (sRect) - a1Rect; 2177 2176 /* 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, 2183 2178 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); 2186 2185 } 2187 2186 } … … 2579 2578 { 2580 2579 QRegion region = aRegion; 2581 region.translate (mShiftingSpacerLeft->sizeHint().width(), mShiftingSpacerTop->sizeHint().height());2580 region.translate (mShiftingSpacerLeft->sizeHint().width(), mShiftingSpacerTop->sizeHint().height()); 2582 2581 region -= mStrictedRegion; 2583 2582 2584 2583 #ifdef Q_WS_MAC 2585 2584 /* This is necessary to avoid the flicker by 2586 * an mask update. 2585 * an mask update. 2587 2586 * See http://lists.apple.com/archives/Carbon-development/2001/Apr/msg01651.html 2588 2587 * for the hint. … … 2590 2589 if(!region.isEmpty()) 2591 2590 region |= QRect(0, 0, 1, 1); 2592 #endif 2591 #endif 2593 2592 2594 2593 #ifdef Q_WS_WIN … … 3114 3113 vmAutoresizeGuestAction->setEnabled (aActive); 3115 3114 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. */3117 3115 mIsSeamlessSupported = aSeamlessSupported; 3118 //#endif3119 3116 /* If seamless mode should be enabled then check if it is enabled 3120 3117 * 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: $ */ 1 2 /** @file 2 3 * Qt GUI - Utility Classes and Functions specific to Darwin. … … 23 24 24 25 #include <iprt/assert.h> 26 #include <iprt/mem.h> 25 27 26 28 27 29 /** 28 * Callback for deleting the QImage object when CGImageCreate is done 30 * Callback for deleting the QImage object when CGImageCreate is done 29 31 * with it (which is probably not until the returned CFGImageRef is released). 30 * 32 * 31 33 * @param info Pointer to the QImage. 32 34 */ … … 39 41 /** 40 42 * 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.) 43 45 * @param aPixmap Pointer to the QPixmap instance to convert. 44 46 */ … … 57 59 bmpInfo |= kCGBitmapByteOrder32Host; 58 60 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 */, 60 62 kCGRenderingIntentDefault); 61 63 CGColorSpaceRelease (cs); … … 68 70 /** 69 71 * 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.) 72 74 * @param aPixmap Pointer to the QPixmap instance to convert. 73 75 */ … … 81 83 /** 82 84 * 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.) 85 87 * @param aSource The source name. 86 88 */ … … 94 96 /** 95 97 * Creates a dock badge image. 96 * 98 * 97 99 * The badge will be placed on the right hand size and vertically centered 98 100 * 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.) 101 103 * @param aSource The source name. 102 104 */ 103 105 CGImageRef DarwinCreateDockBadge (const char *aSource) 104 106 { 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 106 108 just created one that I can load. The Qt gurus can fix this if they like :-) */ 107 109 QPixmap back (QPixmap::fromMimeSource ("dock_128x128_transparent.png")); … … 128 130 /** 129 131 * Creates a dock preview image. 130 * 131 * Use this method to create a 128x128 preview image of the vmwindow.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. 135 137 */ 136 CGImageRef DarwinCreateDockPreview (VBoxFrameBuffer *aFrameBuffer)138 CGImageRef DarwinCreateDockPreview (VBoxFrameBuffer *aFrameBuffer) 137 139 { 138 140 CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB(); 141 139 142 /* 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); 144 147 145 Assert(cs); 146 Assert(dp); 147 Assert(ir); 148 Assert (cs); 149 Assert (dp); 150 Assert (ir); 151 148 152 /* Calc the size of the dock icon image and fit it into 128x128 */ 149 153 int targetWidth = 128; … … 151 155 float aspect = static_cast<float>(aFrameBuffer->width()) / aFrameBuffer->height(); 152 156 CGRect rect; 153 if (aspect > 1.0)157 if (aspect > 1.0) 154 158 { 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 160 165 { 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; 165 170 } 171 166 172 /* Create a bitmap context to draw on */ 167 int bitmapBytesPerRow = (targetWidth * 4);168 int bitmapByteCount = (bitmapBytesPerRow * targetHeight);169 void *bitmapData = malloc(bitmapByteCount);170 173 CGImageRef dockImage = NULL; 174 int bitmapBytesPerRow = targetWidth * 4; 175 int bitmapByteCount = bitmapBytesPerRow * targetHeight; 176 void *bitmapData = RTMemAlloc (bitmapByteCount); 171 177 if (bitmapData) 172 178 { 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); 180 188 } 181 CGColorSpaceRelease(cs); 182 CGDataProviderRelease(dp); 183 CGImageRelease(ir); 189 190 CGColorSpaceRelease (cs); 191 CGDataProviderRelease (dp); 192 CGImageRelease (ir); 184 193 185 194 Assert (dockImage); 186 195 return dockImage; 187 196 } 197
Note:
See TracChangeset
for help on using the changeset viewer.