- Timestamp:
- Dec 4, 2008 1:00:48 PM (16 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox4
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxConsoleView.h
r14913 r14977 126 126 void requestToResize (const QSize &aSize); 127 127 128 #if defined(Q_WS_MAC) 129 void updateDockIcon(); 130 void setDockIconEnabled (bool aOn) { mDockIconEnabled = aOn; }; 131 #endif 132 128 133 signals: 129 134 … … 317 322 #if defined(Q_WS_MAC) 318 323 CGImageRef mVirtualBoxLogo; 324 bool mDockIconEnabled; 319 325 #endif 320 326 DesktopGeo mDesktopGeo; -
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxConsoleWnd.h
r14941 r14977 57 57 class VBoxSwitchMenu; 58 58 59 class VBoxChangeDockIconUpdateEvent; 60 59 61 class VBoxConsoleWnd : public QIWithRetranslateUI2<QMainWindow> 60 62 { … … 86 88 void clearMask(); 87 89 88 #if def Q_WS_MAC90 #if defined (Q_WS_MAC) 89 91 CGImageRef dockImageState () const; 90 92 #endif 91 93 92 94 public slots: 95 void changeDockIconUpdate (const VBoxChangeDockIconUpdateEvent &e); 93 96 94 97 protected: -
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxDefs.h
r14908 r14977 124 124 MainWindowCountChangeEventType, 125 125 #endif 126 AddVDMUrlsEventType 126 AddVDMUrlsEventType, 127 ChangeDockIconUpdateEventType 127 128 }; 128 129 … … 159 160 static const char* GUI_MainWindowCount; 160 161 #endif 162 #ifdef Q_WS_MAC 163 static const char* GUI_RealtimeDockIconUpdateEnabled; 164 #endif 161 165 }; 162 166 -
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxGlobal.h
r14908 r14977 436 436 #endif 437 437 438 class VBoxChangeDockIconUpdateEvent : public QEvent 439 { 440 public: 441 VBoxChangeDockIconUpdateEvent (bool aChanged) 442 : QEvent ((QEvent::Type) VBoxDefs::ChangeDockIconUpdateEventType) 443 , mChanged (aChanged) 444 {} 445 446 const bool mChanged; 447 }; 448 438 449 class Process : public QProcess 439 450 { … … 984 995 void trayIconChanged (const VBoxChangeTrayIconEvent &e); 985 996 #endif 997 void dockIconUpdateChanged (const VBoxChangeDockIconUpdateEvent &e); 986 998 987 999 void canShowRegDlg (bool aCanShow); -
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxUtils.h
r14397 r14977 229 229 kEventVBoxMoveWindow = 'mwin', 230 230 kEventVBoxResizeWindow = 'rwin', 231 kEventVBoxUpdateDock = 'udck' 231 232 }; 232 233 OSStatus darwinOverlayWindowHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData); -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxConsoleView.cpp
r14913 r14977 670 670 , mDarwinKeyModifiers (0) 671 671 , mVirtualBoxLogo (NULL) 672 , mDockIconEnabled (true) 672 673 #endif 673 674 , mDesktopGeo (DesktopGeo_Invalid) … … 688 689 { kEventClassVBox, kEventVBoxShowWindow }, 689 690 { kEventClassVBox, kEventVBoxMoveWindow }, 690 { kEventClassVBox, kEventVBoxResizeWindow } 691 { kEventClassVBox, kEventVBoxResizeWindow }, 692 { kEventClassVBox, kEventVBoxUpdateDock } 691 693 }; 692 694 … … 3067 3069 /* Update the dock icon if we are in the running state */ 3068 3070 if (isRunning()) 3069 { 3070 # if defined (VBOX_GUI_USE_QUARTZ2D) 3071 if (mode == VBoxDefs::Quartz2DMode) 3072 { 3073 /* If the render mode is Quartz2D we could use the 3074 * CGImageRef of the framebuffer for the dock icon creation. 3075 * This saves some conversion time. */ 3076 CGImageRef ir = 3077 static_cast <VBoxQuartz2DFrameBuffer *> (mFrameBuf)->imageRef(); 3078 ::darwinUpdateDockPreview (ir, mVirtualBoxLogo); 3079 } 3080 else 3081 # endif 3082 ::darwinUpdateDockPreview (mFrameBuf, mVirtualBoxLogo); 3083 } 3071 updateDockIcon(); 3084 3072 #endif 3085 3073 return; … … 3875 3863 } 3876 3864 3865 #if defined(Q_WS_MAC) 3866 void VBoxConsoleView::updateDockIcon() 3867 { 3868 if (mDockIconEnabled) 3869 { 3870 # if defined (VBOX_GUI_USE_QUARTZ2D) 3871 if (mode == VBoxDefs::Quartz2DMode) 3872 { 3873 /* If the render mode is Quartz2D we could use the 3874 * CGImageRef of the framebuffer for the dock icon creation. 3875 * This saves some conversion time. */ 3876 CGImageRef ir = 3877 static_cast <VBoxQuartz2DFrameBuffer *> (mFrameBuf)->imageRef(); 3878 ::darwinUpdateDockPreview (ir, mVirtualBoxLogo); 3879 } 3880 else 3881 # endif 3882 ::darwinUpdateDockPreview (mFrameBuf, mVirtualBoxLogo); 3883 } 3884 } 3885 #endif 3886 -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxConsoleWnd.cpp
r14941 r14977 666 666 connect (&vboxGlobal().settings(), SIGNAL (propertyChanged (const char *, const char *)), 667 667 this, SLOT (processGlobalSettingChange (const char *, const char *))); 668 #ifdef Q_WS_MAC 669 connect (&vboxGlobal(), SIGNAL (dockIconUpdateChanged (const VBoxChangeDockIconUpdateEvent &)), 670 this, SLOT (changeDockIconUpdate (const VBoxChangeDockIconUpdateEvent &))); 671 #endif 668 672 669 673 #ifdef VBOX_WITH_DEBUGGER_GUI … … 928 932 929 933 #ifdef Q_WS_MAC 930 QString osTypeId = cmachine.GetOSTypeId(); 931 QImage osImg100x75 = vboxGlobal().vmGuestOSTypeIcon (osTypeId).toImage().scaled (100, 75, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); 932 QImage osImg = QImage (":/dock_1.png"); 933 QImage VBoxOverlay = QImage (":/VirtualBox_cube_42px.png"); 934 QPainter painter (&osImg); 935 painter.drawImage (QPoint (14, 22), osImg100x75); 936 painter.drawImage (QPoint (osImg.width() - VBoxOverlay.width(), osImg.height() - VBoxOverlay.height()), VBoxOverlay); 937 painter.end(); 938 if (dockImgOS) 939 CGImageRelease (dockImgOS); 940 dockImgOS = ::darwinToCGImageRef (&osImg); 941 SetApplicationDockTileImage (dockImgOS); 934 bool b = (vboxGlobal().virtualBox().GetExtraData (VBoxDefs::GUI_RealtimeDockIconUpdateEnabled) == "true") ? true : false; 935 console->setDockIconEnabled (b); 936 if (b) 937 { 938 QString osTypeId = cmachine.GetOSTypeId(); 939 QImage osImg100x75 = vboxGlobal().vmGuestOSTypeIcon (osTypeId).toImage().scaled (100, 75, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); 940 QImage osImg = QImage (":/dock_1.png"); 941 QImage VBoxOverlay = QImage (":/VirtualBox_cube_42px.png"); 942 QPainter painter (&osImg); 943 painter.drawImage (QPoint (14, 22), osImg100x75); 944 painter.drawImage (QPoint (osImg.width() - VBoxOverlay.width(), osImg.height() - VBoxOverlay.height()), VBoxOverlay); 945 painter.end(); 946 if (dockImgOS) 947 CGImageRelease (dockImgOS); 948 dockImgOS = ::darwinToCGImageRef (&osImg); 949 SetApplicationDockTileImage (dockImgOS); 950 } 942 951 #endif 943 952 … … 2408 2417 #endif 2409 2418 2419 void VBoxConsoleWnd::changeDockIconUpdate (const VBoxChangeDockIconUpdateEvent &e) 2420 { 2421 #ifdef Q_WS_MAC 2422 if (console) 2423 { 2424 console->setDockIconEnabled (e.mChanged); 2425 if (e.mChanged) 2426 console->updateDockIcon(); 2427 else 2428 RestoreApplicationDockTileImage(); 2429 } 2430 #else 2431 Q_UNUSED (e); 2432 #endif 2433 } 2434 2410 2435 // 2411 2436 // Private slots -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxDefs.cpp
r14706 r14977 49 49 const char* VBoxDefs::GUI_MainWindowCount = "GUI/MainWindowCount"; 50 50 #endif 51 #ifdef Q_WS_MAC 52 const char* VBoxDefs::GUI_RealtimeDockIconUpdateEnabled = "GUI/RealtimeDockIconUpdateEnabled"; 53 #endif -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxGlobal.cpp
r14908 r14977 885 885 QApplication::postEvent (&mGlobal, new VBoxChangeTrayIconEvent ((sVal.toLower() == "true") ? true : false)); 886 886 #endif 887 #ifdef Q_WS_MAC 888 if (sKey == VBoxDefs::GUI_RealtimeDockIconUpdateEnabled) 889 QApplication::postEvent (&mGlobal, new VBoxChangeDockIconUpdateEvent ((sVal.toLower() == "true") ? true : false)); 890 #endif 887 891 888 892 mMutex.lock(); … … 5253 5257 { 5254 5258 emit trayIconChanged (*(VBoxChangeTrayIconEvent *) e); 5259 return true; 5260 } 5261 #endif 5262 #if defined(Q_WS_MAC) 5263 case VBoxDefs::ChangeDockIconUpdateEventType: 5264 { 5265 emit dockIconUpdateChanged (*(VBoxChangeDockIconUpdateEvent *) e); 5255 5266 return true; 5256 5267 } -
trunk/src/VBox/Frontends/VirtualBox4/src/darwin/VBoxUtils-darwin.cpp
r14453 r14977 24 24 #include "VBoxUtils.h" 25 25 #include "VBoxFrameBuffer.h" 26 #include "VBoxConsoleView.h" 26 27 27 28 #include <iprt/assert.h> … … 167 168 return ::darwinToCGImageRef (&transImage); 168 169 } 170 171 /* Import private function to capture the window content of any given window. */ 172 CG_EXTERN_C_BEGIN 173 typedef int CGSWindowID; 174 typedef void *CGSConnectionID; 175 CG_EXTERN CGSWindowID GetNativeWindowFromWindowRef(WindowRef ref); 176 CG_EXTERN CGSConnectionID CGSMainConnectionID(void); 177 CG_EXTERN void CGContextCopyWindowCaptureContentsToRect(CGContextRef c, CGRect dstRect, CGSConnectionID connection, CGSWindowID window, int zero); 178 CG_EXTERN_C_END 169 179 170 180 /** … … 226 236 iconRect = CGRectInset (iconRect, 1, 1); 227 237 CGContextDrawImage (context, iconRect, aVMImage); 238 /* Process the content of any external OpenGL windows. */ 239 WindowRef w = FrontNonFloatingWindow(); 240 WindowGroupRef g = GetWindowGroup (w); 241 WindowGroupContentOptions wgco = kWindowGroupContentsReturnWindows | kWindowGroupContentsRecurse | kWindowGroupContentsVisible; 242 ItemCount c = CountWindowGroupContents (g, wgco); 243 float a1 = iconRect.size.width / static_cast <float> (CGImageGetWidth (aVMImage)); 244 float a2 = iconRect.size.height / static_cast <float> (CGImageGetHeight (aVMImage)); 245 HIViewRef mainView = HIViewGetRoot (w); 246 Rect tmpR; 247 GetWindowBounds (w, kWindowContentRgn, &tmpR); 248 HIRect mainRect = CGRectMake (tmpR.left, tmpR.top, tmpR.right-tmpR.left, tmpR.bottom-tmpR.top); 249 for (ItemCount i = 0; i <= c; ++i) 250 { 251 WindowRef wc; 252 OSStatus status = GetIndexedWindow (g, i, wgco, &wc); 253 if (status == noErr && 254 wc != w) 255 { 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); 269 } 270 } 271 228 272 /* the state image at center */ 229 273 if (aStateImage) … … 386 430 ::darwinDebugPrintEvent ("view: ", aInEvent); 387 431 */ 388 QWidget *view = static_cast<QWidget*> (aInUserData);432 VBoxConsoleView *view = static_cast<VBoxConsoleView *> (aInUserData); 389 433 390 434 if (eventClass == kEventClassVBox) … … 429 473 return noErr; 430 474 } 475 if (eventKind == kEventVBoxUpdateDock) 476 { 477 // printf ("UpdateDock requested\n"); 478 view->updateDockIcon(); 479 return noErr; 480 } 431 481 } 432 482 … … 436 486 437 487 438 /* Event debugging stuff. Borrowed from theKnuts Qt patch. */488 /* Event debugging stuff. Borrowed from Knuts Qt patch. */ 439 489 #ifdef DEBUG 440 490
Note:
See TracChangeset
for help on using the changeset viewer.