Changeset 27012 in vbox for trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineWindowSeamless.cpp
- Timestamp:
- Mar 4, 2010 11:47:23 AM (15 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless
- Files:
-
- 1 added
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineWindowSeamless.cpp
r27006 r27012 3 3 * 4 4 * VBox frontends: Qt GUI ("VirtualBox"): 5 * UIMachineWindow Normalclass implementation5 * UIMachineWindowSeamless class implementation 6 6 */ 7 7 … … 24 24 /* Global includes */ 25 25 #include <QDesktopWidget> 26 #i nclude <QMenuBar>27 # include <QTimer>28 # include <QContextMenuEvent>26 #ifdef Q_WS_MAC 27 # include <QMenuBar> 28 #endif /* Q_WS_MAC */ 29 29 30 30 /* Local includes */ 31 31 #include "VBoxGlobal.h" 32 32 33 #i nclude "UISession.h"34 # include "UIActionsPool.h"35 # include "UIIndicatorsPool.h"33 #ifdef Q_WS_MAC 34 # include "UISession.h" 35 #endif /* Q_WS_MAC */ 36 36 #include "UIMachineLogic.h" 37 37 #include "UIMachineView.h" 38 #include "UIMachineWindowNormal.h" 39 40 #include "QIStatusBar.h" 41 #include "QIStateIndicator.h" 42 #include "QIHotKeyEdit.h" 43 44 UIMachineWindowNormal::UIMachineWindowNormal(UIMachineLogic *pMachineLogic, ulong uScreenId) 45 : QIWithRetranslateUI<QIMainDialog>(0) 38 #include "UIMachineWindowSeamless.h" 39 40 UIMachineWindowSeamless::UIMachineWindowSeamless(UIMachineLogic *pMachineLogic, ulong uScreenId) 41 : QIWithRetranslateUI2<QIMainDialog>(0, Qt::FramelessWindowHint) 46 42 , UIMachineWindow(pMachineLogic, uScreenId) 47 , m_pIndicatorsPool(new UIIndicatorsPool(pMachineLogic->uisession()->session(), this))48 , m_pIdleTimer(0)49 43 { 50 44 /* "This" is machine window: */ … … 57 51 prepareConsoleConnections(); 58 52 53 /* Prepare seamless window: */ 54 prepareSeamless(); 55 56 #ifdef Q_WS_MAC 59 57 /* Prepare menu: */ 60 58 prepareMenu(); 61 62 /* Prepare status bar: */ 63 prepareStatusBar(); 64 65 /* Prepare connections: */ 66 prepareConnections(); 67 68 /* Retranslate normal window finally: */ 59 #endif /* Q_WS_MAC */ 60 61 /* Retranslate seamless window finally: */ 69 62 retranslateUi(); 70 63 … … 75 68 prepareMachineView(); 76 69 70 #ifdef Q_WS_MAC 77 71 /* Load normal window settings: */ 78 72 loadWindowSettings(); 73 #endif /* Q_WS_MAC */ 79 74 80 75 /* Update all the elements: */ … … 85 80 } 86 81 87 UIMachineWindowNormal::~UIMachineWindowNormal() 88 { 89 /* Save normal window settings: */ 90 saveWindowSettings(); 91 82 UIMachineWindowSeamless::~UIMachineWindowSeamless() 83 { 92 84 /* Cleanup normal machine view: */ 93 85 cleanupMachineView(); 94 95 /* Cleanup status-bar: */ 96 cleanupStatusBar(); 97 } 98 99 void UIMachineWindowNormal::sltMachineStateChanged() 86 } 87 88 void UIMachineWindowSeamless::sltMachineStateChanged() 100 89 { 101 90 UIMachineWindow::sltMachineStateChanged(); 102 91 } 103 92 104 void UIMachineWindowNormal::sltMediumChange(const CMediumAttachment &attachment) 105 { 106 KDeviceType type = attachment.GetType(); 107 if (type == KDeviceType_HardDisk) 108 updateAppearanceOf(UIVisualElement_HDStuff); 109 if (type == KDeviceType_DVD) 110 updateAppearanceOf(UIVisualElement_CDStuff); 111 if (type == KDeviceType_Floppy) 112 updateAppearanceOf(UIVisualElement_FDStuff); 113 } 114 115 void UIMachineWindowNormal::sltUSBControllerChange() 116 { 117 updateAppearanceOf(UIVisualElement_USBStuff); 118 } 119 120 void UIMachineWindowNormal::sltUSBDeviceStateChange() 121 { 122 updateAppearanceOf(UIVisualElement_USBStuff); 123 } 124 125 void UIMachineWindowNormal::sltNetworkAdapterChange() 126 { 127 updateAppearanceOf(UIVisualElement_NetworkStuff); 128 } 129 130 void UIMachineWindowNormal::sltSharedFolderChange() 131 { 132 updateAppearanceOf(UIVisualElement_SharedFolderStuff); 133 } 134 135 void UIMachineWindowNormal::sltTryClose() 93 void UIMachineWindowSeamless::sltTryClose() 136 94 { 137 95 UIMachineWindow::sltTryClose(); 138 96 } 139 97 140 void UIMachineWindowNormal::sltUpdateIndicators() 141 { 142 CConsole console = session().GetConsole(); 143 QIStateIndicator *pStateIndicator = 0; 144 145 pStateIndicator = indicatorsPool()->indicator(UIIndicatorIndex_HardDisks); 146 if (pStateIndicator->state() != KDeviceActivity_Null) 147 { 148 int state = console.GetDeviceActivity(KDeviceType_HardDisk); 149 if (pStateIndicator->state() != state) 150 pStateIndicator->setState(state); 151 } 152 pStateIndicator = indicatorsPool()->indicator(UIIndicatorIndex_OpticalDisks); 153 if (pStateIndicator->state() != KDeviceActivity_Null) 154 { 155 int state = console.GetDeviceActivity(KDeviceType_DVD); 156 if (pStateIndicator->state() != state) 157 pStateIndicator->setState(state); 158 } 159 pStateIndicator = indicatorsPool()->indicator(UIIndicatorIndex_USBDevices); 160 if (pStateIndicator->state() != KDeviceActivity_Null) 161 { 162 int state = console.GetDeviceActivity(KDeviceType_USB); 163 if (pStateIndicator->state() != state) 164 pStateIndicator->setState(state); 165 } 166 pStateIndicator = indicatorsPool()->indicator(UIIndicatorIndex_NetworkAdapters); 167 if (pStateIndicator->state() != KDeviceActivity_Null) 168 { 169 int state = console.GetDeviceActivity(KDeviceType_Network); 170 if (pStateIndicator->state() != state) 171 pStateIndicator->setState(state); 172 } 173 pStateIndicator = indicatorsPool()->indicator(UIIndicatorIndex_SharedFolders); 174 if (pStateIndicator->state() != KDeviceActivity_Null) 175 { 176 int state = console.GetDeviceActivity(KDeviceType_SharedFolder); 177 if (pStateIndicator->state() != state) 178 pStateIndicator->setState(state); 179 } 180 } 181 182 void UIMachineWindowNormal::sltShowIndicatorsContextMenu(QIStateIndicator *pIndicator, QContextMenuEvent *pEvent) 183 { 184 if (pIndicator == indicatorsPool()->indicator(UIIndicatorIndex_OpticalDisks)) 185 { 186 if (machineLogic()->actionsPool()->action(UIActionIndex_Menu_OpticalDevices)->isEnabled()) 187 machineLogic()->actionsPool()->action(UIActionIndex_Menu_OpticalDevices)->menu()->exec(pEvent->globalPos()); 188 } 189 else if (pIndicator == indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)) 190 { 191 if (machineLogic()->actionsPool()->action(UIActionIndex_Menu_USBDevices)->isEnabled()) 192 machineLogic()->actionsPool()->action(UIActionIndex_Menu_USBDevices)->menu()->exec(pEvent->globalPos()); 193 } 194 else if (pIndicator == indicatorsPool()->indicator(UIIndicatorIndex_NetworkAdapters)) 195 { 196 if (machineLogic()->actionsPool()->action(UIActionIndex_Menu_NetworkAdapters)->isEnabled()) 197 machineLogic()->actionsPool()->action(UIActionIndex_Menu_NetworkAdapters)->menu()->exec(pEvent->globalPos()); 198 } 199 else if (pIndicator == indicatorsPool()->indicator(UIIndicatorIndex_SharedFolders)) 200 { 201 if (machineLogic()->actionsPool()->action(UIActionIndex_Menu_SharedFolders)->isEnabled()) 202 machineLogic()->actionsPool()->action(UIActionIndex_Menu_SharedFolders)->menu()->exec(pEvent->globalPos()); 203 } 204 else if (pIndicator == indicatorsPool()->indicator(UIIndicatorIndex_Mouse)) 205 { 206 if (machineLogic()->actionsPool()->action(UIActionIndex_Menu_MouseIntegration)->isEnabled()) 207 machineLogic()->actionsPool()->action(UIActionIndex_Menu_MouseIntegration)->menu()->exec(pEvent->globalPos()); 208 } 209 } 210 211 void UIMachineWindowNormal::sltProcessGlobalSettingChange(const char * /* aPublicName */, const char * /* aName */) 212 { 213 m_pNameHostkey->setText(QIHotKeyEdit::keyName(vboxGlobal().settings().hostKey())); 214 } 215 216 void UIMachineWindowNormal::retranslateUi() 98 void UIMachineWindowSeamless::retranslateUi() 217 99 { 218 100 /* Translate parent class: */ … … 225 107 // m_pDockEnablePreviewMonitor->setText(tr("Show Monitor Preview")); 226 108 #endif /* Q_WS_MAC */ 227 228 m_pNameHostkey->setToolTip(229 tr("Shows the currently assigned Host key.<br>"230 "This key, when pressed alone, toggles the keyboard and mouse "231 "capture state. It can also be used in combination with other keys "232 "to quickly perform actions from the main menu."));233 m_pNameHostkey->setText(QIHotKeyEdit::keyName(vboxGlobal().settings().hostKey()));234 }235 236 void UIMachineWindowNormal::updateAppearanceOf(int iElement)237 {238 /* Update parent-class window: */239 UIMachineWindow::updateAppearanceOf(iElement);240 241 /* Update that machine window: */242 if (iElement & UIVisualElement_HDStuff)243 indicatorsPool()->indicator(UIIndicatorIndex_HardDisks)->updateAppearance();244 if (iElement & UIVisualElement_CDStuff)245 indicatorsPool()->indicator(UIIndicatorIndex_OpticalDisks)->updateAppearance();246 if (iElement & UIVisualElement_USBStuff &&247 !indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->isHidden())248 indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->updateAppearance();249 if (iElement & UIVisualElement_NetworkStuff)250 indicatorsPool()->indicator(UIIndicatorIndex_NetworkAdapters)->updateAppearance();251 if (iElement & UIVisualElement_SharedFolderStuff)252 indicatorsPool()->indicator(UIIndicatorIndex_SharedFolders)->updateAppearance();253 if (iElement & UIVisualElement_VirtualizationStuff)254 indicatorsPool()->indicator(UIIndicatorIndex_Virtualization)->updateAppearance();255 }256 257 bool UIMachineWindowNormal::event(QEvent *pEvent)258 {259 switch (pEvent->type())260 {261 case QEvent::Resize:262 {263 QResizeEvent *pResizeEvent = static_cast<QResizeEvent*>(pEvent);264 if (!isMaximized())265 {266 m_normalGeometry.setSize(pResizeEvent->size());267 #ifdef VBOX_WITH_DEBUGGER_GUI268 // TODO: Update debugger window size!269 //dbgAdjustRelativePos();270 #endif271 }272 break;273 }274 case QEvent::Move:275 {276 if (!isMaximized())277 {278 m_normalGeometry.moveTo(geometry().x(), geometry().y());279 #ifdef VBOX_WITH_DEBUGGER_GUI280 // TODO: Update debugger window position!281 //dbgAdjustRelativePos();282 #endif283 }284 break;285 }286 default:287 break;288 }289 return QIWithRetranslateUI<QIMainDialog>::event(pEvent);290 109 } 291 110 292 111 #ifdef Q_WS_X11 293 bool UIMachineWindow Normal::x11Event(XEvent *pEvent)112 bool UIMachineWindowSeamless::x11Event(XEvent *pEvent) 294 113 { 295 114 /* Qt bug: when the console view grabs the keyboard, FocusIn, FocusOut, … … 312 131 #endif 313 132 314 void UIMachineWindow Normal::closeEvent(QCloseEvent *pEvent)133 void UIMachineWindowSeamless::closeEvent(QCloseEvent *pEvent) 315 134 { 316 135 return UIMachineWindow::closeEvent(pEvent); 317 136 } 318 137 319 void UIMachineWindowNormal::prepareConsoleConnections() 320 { 321 /* Base-class connections: */ 322 UIMachineWindow::prepareConsoleConnections(); 323 324 /* Medium change updater: */ 325 connect(machineLogic()->uisession(), SIGNAL(sigMediumChange(const CMediumAttachment &)), 326 this, SLOT(sltMediumChange(const CMediumAttachment &))); 327 328 /* USB controller change updater: */ 329 connect(machineLogic()->uisession(), SIGNAL(sigUSBControllerChange()), 330 this, SLOT(sltUSBControllerChange())); 331 332 /* USB device state-change updater: */ 333 connect(machineLogic()->uisession(), SIGNAL(sigUSBDeviceStateChange(const CUSBDevice &, bool, const CVirtualBoxErrorInfo &)), 334 this, SLOT(sltUSBDeviceStateChange())); 335 336 /* Network adapter change updater: */ 337 connect(machineLogic()->uisession(), SIGNAL(sigNetworkAdapterChange(const CNetworkAdapter &)), 338 this, SLOT(sltNetworkAdapterChange())); 339 340 /* Shared folder change updater: */ 341 connect(machineLogic()->uisession(), SIGNAL(sigSharedFolderChange()), 342 this, SLOT(sltSharedFolderChange())); 343 } 344 345 void UIMachineWindowNormal::prepareMenu() 138 void UIMachineWindowSeamless::prepareSeamless() 139 { 140 /* Move & resize seamless frameless window: */ 141 QRect geometry = QApplication::desktop()->availableGeometry(); 142 #ifdef Q_WS_WIN 143 m_prevRegion = geometry; 144 #endif 145 move(geometry.topLeft()); 146 resize(geometry.size()); 147 /* Perform these events: */ 148 qApp->processEvents(); 149 } 150 151 #ifdef Q_WS_MAC 152 void UIMachineWindowSeamless::prepareMenu() 346 153 { 347 154 setMenuBar(uisession()->newMenuBar()); 348 155 } 349 350 void UIMachineWindowNormal::prepareStatusBar() 351 { 352 /* Common setup: */ 353 setStatusBar(new QIStatusBar(this)); 354 QWidget *pIndicatorBox = new QWidget; 355 QHBoxLayout *pIndicatorBoxHLayout = new QHBoxLayout(pIndicatorBox); 356 VBoxGlobal::setLayoutMargin(pIndicatorBoxHLayout, 0); 357 pIndicatorBoxHLayout->setSpacing(5); 358 359 /* Hard Disks: */ 360 pIndicatorBoxHLayout->addWidget(indicatorsPool()->indicator(UIIndicatorIndex_HardDisks)); 361 362 /* Optical Disks: */ 363 QIStateIndicator *pLedOpticalDisks = indicatorsPool()->indicator(UIIndicatorIndex_OpticalDisks); 364 pIndicatorBoxHLayout->addWidget(pLedOpticalDisks); 365 connect(pLedOpticalDisks, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)), 366 this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*))); 367 368 /* USB Devices: */ 369 QIStateIndicator *pLedUSBDevices = indicatorsPool()->indicator(UIIndicatorIndex_USBDevices); 370 pIndicatorBoxHLayout->addWidget(pLedUSBDevices); 371 connect(pLedUSBDevices, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)), 372 this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*))); 373 374 /* Network Adapters: */ 375 QIStateIndicator *pLedNetworkAdapters = indicatorsPool()->indicator(UIIndicatorIndex_NetworkAdapters); 376 pIndicatorBoxHLayout->addWidget(pLedNetworkAdapters); 377 connect(pLedNetworkAdapters, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)), 378 this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*))); 379 380 /* Shared Folders: */ 381 QIStateIndicator *pLedSharedFolders = indicatorsPool()->indicator(UIIndicatorIndex_SharedFolders); 382 pIndicatorBoxHLayout->addWidget(pLedSharedFolders); 383 connect(pLedSharedFolders, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)), 384 this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*))); 385 386 /* Virtualization: */ 387 pIndicatorBoxHLayout->addWidget(indicatorsPool()->indicator(UIIndicatorIndex_Virtualization)); 388 389 /* Separator: */ 390 QFrame *pSeparator = new QFrame; 391 pSeparator->setFrameStyle(QFrame::VLine | QFrame::Sunken); 392 pIndicatorBoxHLayout->addWidget(pSeparator); 393 394 /* Mouse: */ 395 QIStateIndicator *pLedMouse = indicatorsPool()->indicator(UIIndicatorIndex_Mouse); 396 pIndicatorBoxHLayout->addWidget(pLedMouse); 397 connect(pLedMouse, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)), 398 this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*))); 399 400 /* Host Key: */ 401 m_pCntHostkey = new QWidget; 402 QHBoxLayout *pHostkeyLedContainerLayout = new QHBoxLayout(m_pCntHostkey); 403 VBoxGlobal::setLayoutMargin(pHostkeyLedContainerLayout, 0); 404 pHostkeyLedContainerLayout->setSpacing(3); 405 pIndicatorBoxHLayout->addWidget(m_pCntHostkey); 406 pHostkeyLedContainerLayout->addWidget(indicatorsPool()->indicator(UIIndicatorIndex_Hostkey)); 407 m_pNameHostkey = new QLabel(QIHotKeyEdit::keyName(vboxGlobal().settings().hostKey())); 408 pHostkeyLedContainerLayout->addWidget(m_pNameHostkey); 409 410 /* Add to statusbar: */ 411 statusBar()->addPermanentWidget(pIndicatorBox, 0); 412 413 /* Create & start timer to update LEDs: */ 414 m_pIdleTimer = new QTimer(this); 415 connect(m_pIdleTimer, SIGNAL(timeout()), this, SLOT(sltUpdateIndicators())); 416 m_pIdleTimer->start(50); 417 418 #ifdef Q_WS_MAC 419 /* For the status bar on Cocoa: */ 420 setUnifiedTitleAndToolBarOnMac(true); 421 #endif 422 } 423 424 void UIMachineWindowNormal::prepareConnections() 425 { 426 /* Setup global settings change updater: */ 427 connect(&vboxGlobal().settings(), SIGNAL(propertyChanged(const char *, const char *)), 428 this, SLOT(sltProcessGlobalSettingChange(const char *, const char *))); 429 } 430 431 void UIMachineWindowNormal::prepareMachineView() 156 #endif 157 158 void UIMachineWindowSeamless::prepareMachineView() 432 159 { 433 160 #ifdef VBOX_WITH_VIDEOHWACCEL … … 452 179 /* Add machine view into layout: */ 453 180 m_pMachineViewContainer->addWidget(m_pMachineView, 1, 1); 454 455 /* Setup machine view connections: */ 456 if (machineView()) 457 { 458 /* Keyboard state-change updater: */ 459 connect(machineView(), SIGNAL(keyboardStateChanged(int)), indicatorsPool()->indicator(UIIndicatorIndex_Hostkey), SLOT(setState(int))); 460 461 /* Mouse state-change updater: */ 462 connect(machineView(), SIGNAL(mouseStateChanged(int)), indicatorsPool()->indicator(UIIndicatorIndex_Mouse), SLOT(setState(int))); 463 464 /* Early initialize required connections: */ 465 indicatorsPool()->indicator(UIIndicatorIndex_Hostkey)->setState(machineView()->keyboardState()); 466 indicatorsPool()->indicator(UIIndicatorIndex_Mouse)->setState(machineView()->mouseState()); 467 } 468 } 469 470 void UIMachineWindowNormal::loadWindowSettings() 471 { 472 /* Load normal window settings: */ 473 CMachine machine = session().GetMachine(); 474 475 /* Load extra-data settings: */ 476 { 477 QString strPositionSettings = machine.GetExtraData(VBoxDefs::GUI_LastWindowPosition); 478 479 bool ok = false, max = false; 480 int x = 0, y = 0, w = 0, h = 0; 481 x = strPositionSettings.section(',', 0, 0).toInt(&ok); 482 if (ok) 483 y = strPositionSettings.section(',', 1, 1).toInt(&ok); 484 if (ok) 485 w = strPositionSettings.section(',', 2, 2).toInt(&ok); 486 if (ok) 487 h = strPositionSettings.section(',', 3, 3).toInt(&ok); 488 if (ok) 489 max = strPositionSettings.section(',', 4, 4) == VBoxDefs::GUI_LastWindowPosition_Max; 490 491 QRect ar = ok ? QApplication::desktop()->availableGeometry(QPoint(x, y)) : 492 QApplication::desktop()->availableGeometry(machineWindow()); 493 494 if (ok /* if previous parameters were read correctly */) 495 { 496 m_normalGeometry = QRect(x, y, w, h); 497 setGeometry(m_normalGeometry); 498 499 /* Normalize view to the optimal size */ 500 if (machineView()) 501 machineView()->normalizeGeometry(true /* adjust position? */); 502 503 /* Maximize if needed: */ 504 if (max) 505 setWindowState(windowState() | Qt::WindowMaximized); 506 } 507 else 508 { 509 /* Normalize to the optimal size */ 510 if (machineView()) 511 machineView()->normalizeGeometry(true /* adjust position? */); 512 513 /* Move newly created window to the screen center: */ 514 m_normalGeometry = geometry(); 515 m_normalGeometry.moveCenter(ar.center()); 516 setGeometry(m_normalGeometry); 517 } 518 } 519 520 /* Load availability settings: */ 521 { 522 /* USB Stuff: */ 523 CUSBController usbController = machine.GetUSBController(); 524 if (usbController.isNull()) 525 { 526 /* Hide USB Menu: */ 527 indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->setHidden(true); 528 } 529 else 530 { 531 /* Toggle USB LED: */ 532 indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->setState( 533 usbController.GetEnabled() ? KDeviceActivity_Idle : KDeviceActivity_Null); 534 } 535 } 536 181 } 182 183 #ifdef Q_WS_MAC 184 void UIMachineWindowSeamless::loadWindowSettings() 185 { 537 186 /* Load global settings: */ 538 187 { 539 188 VBoxGlobalSettings settings = vboxGlobal().settings(); 540 189 menuBar()->setHidden(settings.isFeatureActive("noMenuBar")); 541 statusBar()->setHidden(settings.isFeatureActive("noStatusBar")); 542 } 543 } 544 545 void UIMachineWindowNormal::saveWindowSettings() 546 { 547 CMachine machine = session().GetMachine(); 548 549 /* Save extra-data settings: */ 550 { 551 QString strWindowPosition = QString("%1,%2,%3,%4") 552 .arg(m_normalGeometry.x()).arg(m_normalGeometry.y()) 553 .arg(m_normalGeometry.width()).arg(m_normalGeometry.height()); 554 if (isMaximized()) 555 strWindowPosition += QString(",%1").arg(VBoxDefs::GUI_LastWindowPosition_Max); 556 machine.SetExtraData(VBoxDefs::GUI_LastWindowPosition, strWindowPosition); 557 } 558 } 559 560 void UIMachineWindowNormal::cleanupMachineView() 190 } 191 } 192 #endif 193 194 void UIMachineWindowSeamless::cleanupMachineView() 561 195 { 562 196 /* Do not cleanup machine view if it is not present: */ … … 568 202 } 569 203 570 void UIMachineWindowNormal::cleanupStatusBar() 571 { 572 /* Stop LED-update timer: */ 573 m_pIdleTimer->stop(); 574 m_pIdleTimer->disconnect(SIGNAL(timeout()), this, SLOT(sltUpdateIndicators())); 575 } 576 204 void UIMachineWindowSeamless::setMask(const QRegion &constRegion) 205 { 206 QRegion region = constRegion; 207 208 #if 0 // TODO: Is it really needed now? 209 /* The global mask shift cause of toolbars and such things. */ 210 region.translate(mMaskShift.width(), mMaskShift.height()); 211 #endif 212 213 #if 0 // TODO: Add mini-toolbar support! 214 /* Including mini toolbar area */ 215 QRegion toolBarRegion(mMiniToolBar->mask()); 216 toolBarRegion.translate(mMiniToolBar->mapToGlobal (toolBarRegion.boundingRect().topLeft()) - QPoint (1, 0)); 217 region += toolBarRegion; 218 #endif 219 220 #if 0 // TODO: Is it really needed now? 221 /* Restrict the drawing to the available space on the screen. 222 * (The &operator is better than the previous used -operator, 223 * because this excludes space around the real screen also. 224 * This is necessary for the mac.) */ 225 region &= mStrictedRegion; 226 #endif 227 228 #ifdef Q_WS_WIN 229 QRegion difference = m_prevRegion.subtract(region); 230 231 /* Region offset calculation */ 232 int fleft = 0, ftop = 0; 233 234 /* Visible region calculation */ 235 HRGN newReg = CreateRectRgn(0, 0, 0, 0); 236 CombineRgn(newReg, region.handle(), 0, RGN_COPY); 237 OffsetRgn(newReg, fleft, ftop); 238 239 /* Invisible region calculation */ 240 HRGN diffReg = CreateRectRgn(0, 0, 0, 0); 241 CombineRgn(diffReg, difference.handle(), 0, RGN_COPY); 242 OffsetRgn(diffReg, fleft, ftop); 243 244 /* Set the current visible region and clean the previous */ 245 SetWindowRgn(winId(), newReg, FALSE); 246 RedrawWindow(0, 0, diffReg, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN); 247 RedrawWindow(mConsole->viewport()->winId(), 0, 0, RDW_INVALIDATE); 248 249 m_prevRegion = region; 250 #elif defined (Q_WS_MAC) 251 # if defined (VBOX_GUI_USE_QUARTZ2D) 252 if (vboxGlobal().vmRenderMode() == VBoxDefs::Quartz2DMode) 253 { 254 /* If we are using the Quartz2D backend we have to trigger 255 * an repaint only. All the magic clipping stuff is done 256 * in the paint engine. */ 257 ::darwinWindowInvalidateShape (mConsole->viewport()); 258 } 259 else 260 # endif 261 { 262 /* This is necessary to avoid the flicker by an mask update. 263 * See http://lists.apple.com/archives/Carbon-development/2001/Apr/msg01651.html 264 * for the hint. 265 * There *must* be a better solution. */ 266 if (!region.isEmpty()) 267 region |= QRect (0, 0, 1, 1); 268 // /* Save the current region for later processing in the darwin event handler. */ 269 // mCurrRegion = region; 270 // /* We repaint the screen before the ReshapeCustomWindow command. Unfortunately 271 // * this command flushes a copy of the backbuffer to the screen after the new 272 // * mask is set. This leads into a missplaced drawing of the content. Currently 273 // * no alternative to this and also this is not 100% perfect. */ 274 // repaint(); 275 // qApp->processEvents(); 276 // /* Now force the reshaping of the window. This is definitly necessary. */ 277 // ReshapeCustomWindow (reinterpret_cast <WindowPtr> (winId())); 278 QMainWindow::setMask (region); 279 // HIWindowInvalidateShadow (::darwinToWindowRef (mConsole->viewport())); 280 } 281 #else 282 QMainWindow::setMask(region); 283 #endif 284 } 285 286 void UIMachineWindowSeamless::clearMask() 287 { 288 #ifdef Q_WS_WIN 289 SetWindowRgn(winId(), 0, TRUE); 290 #else 291 QMainWindow::clearMask(); 292 #endif 293 } 294
Note:
See TracChangeset
for help on using the changeset viewer.