- Timestamp:
- Feb 26, 2010 2:43:37 AM (15 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp
r26709 r26815 162 162 UIMachine::UIMachine(UIMachine **ppSelf, const CSession &session) 163 163 : QObject(0) 164 , m_pActionsPool(new UIActionsPool(this)) 164 165 , m_pSession(new UISession(this, session)) 165 , m_pActionsPool(new UIActionsPool(this))166 166 , m_pVisualState(0) 167 167 { -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h
r26709 r26815 58 58 /* Private getters: */ 59 59 UIMachineLogic* machineLogic() const; 60 UIActionsPool* actionsPool() const { return m_pActionsPool; } 60 61 61 62 /* Private variables: */ 63 UIActionsPool *m_pActionsPool; 62 64 UISession *m_pSession; 63 UIActionsPool *m_pActionsPool;64 65 UIVisualState *m_pVisualState; 65 66 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r26795 r26815 25 25 #include <QDir> 26 26 #include <QFileInfo> 27 #include <QProgressBar>28 27 #include <QDesktopWidget> 29 28 30 29 /* Local includes */ 31 #include " VBoxGlobal.h"30 #include "COMDefs.h" 32 31 #include "VBoxProblemReporter.h" 33 32 … … 40 39 41 40 #include "QIFileDialog.h" 42 #include "QIHttp.h"41 //#include "QIHttp.h" 43 42 44 43 #include "UISession.h" … … 51 50 #include "UIMachineView.h" 52 51 53 #include <iprt/param.h>54 52 #include <iprt/path.h> 55 53 #include <VBox/VMMDev.h> … … 87 85 { 88 86 USBTarget() : attach(false), id(QString()) {} 89 USBTarget(bool bAttach, const QString &strId)90 : attach( bAttach), id(strId) {}87 USBTarget(bool fAttach, const QString &strId) 88 : attach(fAttach), id(strId) {} 91 89 bool attach; 92 90 QString id; … … 372 370 , m_pSession(pSession) 373 371 , m_pActionsPool(pActionsPool) 374 , m_machineState(KMachineState_Null)375 372 , m_visualStateType(visualStateType) 376 373 , m_pMachineWindowWrapper(0) 377 374 , m_pRunningActions(0) 378 375 , m_pRunningOrPausedActions(0) 379 , m_fIsFirstTimeStarted(false)380 , m_fIsIgnoringRutimeMediums(false)381 , m_fIsAdditionsActive(false)382 , m_fIsGuestSupportsGraphics(false)383 , m_fIsGuestSupportsSeamless(false)384 , m_fIsMouseSupportsAbsolute(false)385 , m_fIsMouseSupportsRelative(false)386 , m_fIsHostCursorNeeded(false)387 376 , m_fIsPreventAutoClose(false) 388 377 { … … 399 388 CSession& UIMachineLogic::session() 400 389 { 401 return m_pSession->session();390 return uisession()->session(); 402 391 } 403 392 … … 405 394 { 406 395 /* Machine state-change updater: */ 407 connect(uisession(), SIGNAL(sig StateChange(KMachineState)), this, SLOT(sltMachineStateChanged(KMachineState)));396 connect(uisession(), SIGNAL(sigMachineStateChange()), this, SLOT(sltMachineStateChanged())); 408 397 409 398 /* Guest additions state-change updater: */ … … 411 400 412 401 /* Mouse capability state-change updater: */ 413 connect(uisession(), SIGNAL(sigMouseCapabilityChange( bool, bool, bool)), this, SLOT(sltMouseCapabilityChanged(bool, bool, bool)));402 connect(uisession(), SIGNAL(sigMouseCapabilityChange()), this, SLOT(sltMouseCapabilityChanged())); 414 403 415 404 /* USB devices state-change updater: */ … … 534 523 535 524 /* Check if the virtualization feature is required. */ 536 bool bIs64BitsGuest = vboxGlobal().virtualBox().GetGuestOSType(console.GetGuest().GetOSTypeId()).GetIs64Bit();525 bool fIs64BitsGuest = vboxGlobal().virtualBox().GetGuestOSType(console.GetGuest().GetOSTypeId()).GetIs64Bit(); 537 526 bool fRecommendVirtEx = vboxGlobal().virtualBox().GetGuestOSType(console.GetGuest().GetOSTypeId()).GetRecommendedVirtEx(); 538 AssertMsg(! bIs64BitsGuest || fRecommendVirtEx, ("Virtualization support missed for 64bit guest!\n"));539 bool bIsVirtEnabled = console.GetDebugger().GetHWVirtExEnabled();540 if (fRecommendVirtEx && ! bIsVirtEnabled)541 { 542 bool result;543 544 pause();527 AssertMsg(!fIs64BitsGuest || fRecommendVirtEx, ("Virtualization support missed for 64bit guest!\n")); 528 bool fIsVirtEnabled = console.GetDebugger().GetHWVirtExEnabled(); 529 if (fRecommendVirtEx && !fIsVirtEnabled) 530 { 531 bool fResult; 532 533 uisession()->pause(); 545 534 546 535 bool fVTxAMDVSupported = vboxGlobal().virtualBox().GetHost().GetProcessorFeature(KProcessorFeature_HWVirtEx); 547 536 548 if ( bIs64BitsGuest)549 result = vboxProblem().warnAboutVirtNotEnabled64BitsGuest(fVTxAMDVSupported);537 if (fIs64BitsGuest) 538 fResult = vboxProblem().warnAboutVirtNotEnabled64BitsGuest(fVTxAMDVSupported); 550 539 else 551 result = vboxProblem().warnAboutVirtNotEnabledGuestRequired(fVTxAMDVSupported);552 553 if ( result == true)540 fResult = vboxProblem().warnAboutVirtNotEnabledGuestRequired(fVTxAMDVSupported); 541 542 if (fResult == true) 554 543 sltClose(); 555 544 else 556 u npause();545 uisession()->unpause(); 557 546 } 558 547 … … 564 553 } 565 554 566 void UIMachineLogic::loadLogicSettings() 567 { 568 /* Get current machine: */ 569 CMachine machine = session().GetMachine(); 570 571 /* Extra-data settings: */ 572 { 573 QString strSettings; 574 575 strSettings = machine.GetExtraData(VBoxDefs::GUI_AutoresizeGuest); 576 if (strSettings != "off") 577 actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize)->setChecked(true); 578 579 strSettings = machine.GetExtraData(VBoxDefs::GUI_FirstRun); 580 if (strSettings == "yes") 581 m_fIsFirstTimeStarted = true; 582 583 strSettings = machine.GetExtraData(VBoxDefs::GUI_SaveMountedAtRuntime); 584 if (strSettings == "no") 585 m_fIsIgnoringRutimeMediums = true; 586 } 587 588 /* Initial settings: */ 589 { 590 /* Initialize storage stuff: */ 591 int iDevicesCountCD = 0; 592 int iDevicesCountFD = 0; 593 const CMediumAttachmentVector &attachments = machine.GetMediumAttachments(); 594 foreach (const CMediumAttachment &attachment, attachments) 595 { 596 if (attachment.GetType() == KDeviceType_DVD) 597 ++ iDevicesCountCD; 598 if (attachment.GetType() == KDeviceType_Floppy) 599 ++ iDevicesCountFD; 600 } 601 actionsPool()->action(UIActionIndex_Menu_OpticalDevices)->setData(iDevicesCountCD); 602 actionsPool()->action(UIActionIndex_Menu_FloppyDevices)->setData(iDevicesCountFD); 603 actionsPool()->action(UIActionIndex_Menu_OpticalDevices)->setVisible(iDevicesCountCD); 604 actionsPool()->action(UIActionIndex_Menu_FloppyDevices)->setVisible(iDevicesCountFD); 605 } 606 607 /* Availability settings: */ 608 { 609 /* USB Stuff: */ 610 CUSBController usbController = machine.GetUSBController(); 611 if (usbController.isNull()) 612 { 613 /* Hide USB menu if controller is NULL: */ 614 actionsPool()->action(UIActionIndex_Menu_USBDevices)->setVisible(false); 615 } 616 else 617 { 618 /* Enable/Disable USB menu depending on USB controller: */ 619 actionsPool()->action(UIActionIndex_Menu_USBDevices)->setEnabled(usbController.GetEnabled()); 620 } 621 622 /* VRDP Stuff: */ 623 CVRDPServer vrdpServer = machine.GetVRDPServer(); 624 if (vrdpServer.isNull()) 625 { 626 /* Hide VRDP Action: */ 627 actionsPool()->action(UIActionIndex_Toggle_VRDP)->setVisible(false); 628 } 629 } 630 631 #if 0 632 /* Dynamical property settings: */ 633 { 634 /* Load dynamical properties: */ 635 m_machineState = uisession()->property("MachineLogic/MachineState").value<KMachineState>(); 636 m_fIsAdditionsActive = uisession()->property("MachineLogic/IsAdditionsActive").toBool(); 637 m_fIsGuestSupportsGraphics = uisession()->property("MachineLogic/IsGuestSupportsGraphics").toBool(); 638 m_fIsGuestSupportsSeamless = uisession()->property("MachineLogic/IsGuestSupportsSeamless").toBool(); 639 m_fIsMouseSupportsAbsolute = uisession()->property("MachineLogic/IsMouseSupportsAbsolute").toBool(); 640 m_fIsMouseSupportsRelative = uisession()->property("MachineLogic/IsMouseSupportsRelative").toBool(); 641 m_fIsHostCursorNeeded = uisession()->property("MachineLogic/IsHostCursorNeeded").toBool(); 642 643 /* Update relative things: */ 644 updateMachineState(); 645 updateAdditionsState(); 646 updateMouseCapability(); 647 } 648 #endif 649 } 650 651 void UIMachineLogic::saveLogicSettings() 652 { 653 /* Get current machine: */ 654 CMachine machine = session().GetMachine(); 655 656 /* Extra-data settings: */ 657 { 658 machine.SetExtraData(VBoxDefs::GUI_AutoresizeGuest, 659 actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize)->isChecked() ? "on" : "off"); 660 661 machine.SetExtraData(VBoxDefs::GUI_FirstRun, QString()); 662 663 // TODO: Move to fullscreen/seamless logic: 664 //machine.SetExtraData(VBoxDefs::GUI_MiniToolBarAutoHide, mMiniToolBar->isAutoHide() ? "on" : "off"); 665 } 666 667 #if 0 668 /* Dynamical property settings: */ 669 { 670 /* Save dynamical properties: */ 671 uisession()->setProperty("MachineLogic/MachineState", QVariant::fromValue(machineState())); 672 uisession()->setProperty("MachineLogic/IsAdditionsActive", m_fIsAdditionsActive); 673 uisession()->setProperty("MachineLogic/IsGuestSupportsGraphics", m_fIsGuestSupportsGraphics); 674 uisession()->setProperty("MachineLogic/IsGuestSupportsSeamless", m_fIsGuestSupportsSeamless); 675 uisession()->setProperty("MachineLogic/IsMouseSupportsAbsolute", m_fIsMouseSupportsAbsolute); 676 uisession()->setProperty("MachineLogic/IsMouseSupportsRelative", m_fIsMouseSupportsRelative); 677 uisession()->setProperty("MachineLogic/IsHostCursorNeeded", m_fIsHostCursorNeeded); 678 } 679 #endif 680 } 681 682 void UIMachineLogic::updateMachineState() 683 { 684 /* State flags: */ 685 bool fIsRunning = machineState() == KMachineState_Running || 686 machineState() == KMachineState_Teleporting || 687 machineState() == KMachineState_LiveSnapshotting; 688 bool fIsRunningOrPaused = fIsRunning || 689 machineState() == KMachineState_Paused; 555 void UIMachineLogic::sltMachineStateChanged() 556 { 557 /* Get machine state: */ 558 KMachineState state = uisession()->machineState(); 690 559 691 560 /* Update action groups: */ 692 m_pRunningActions->setEnabled( fIsRunning);693 m_pRunningOrPausedActions->setEnabled( fIsRunningOrPaused);561 m_pRunningActions->setEnabled(uisession()->isRunning()); 562 m_pRunningOrPausedActions->setEnabled(uisession()->isRunning() || uisession()->isPaused()); 694 563 695 564 /* Do we have GURU? */ 696 565 bool fIsGuruMeditation = false; 697 566 698 switch ( machineState())567 switch (state) 699 568 { 700 569 case KMachineState_Stuck: 701 570 { 702 /* We will handleGURU later: */571 /* We will process GURU later: */ 703 572 fIsGuruMeditation = true; 704 573 break; 705 574 } 706 575 case KMachineState_Paused: 576 case KMachineState_TeleportingPausedVM: 707 577 { 708 578 QAction *pPauseAction = actionsPool()->action(UIActionIndex_Toggle_Pause); … … 746 616 747 617 /* Close VM if was closed someway: */ 748 if (machineState() == KMachineState_PoweredOff || machineState() == KMachineState_Saved || 749 machineState() == KMachineState_Teleported || machineState() == KMachineState_Aborted) 618 if (uisession()->isTurnedOff()) 750 619 { 751 620 /* VM has been powered off or saved or aborted, no matter internally or externally. … … 755 624 } 756 625 757 /* P rocess GURU: */626 /* Postprocess GURU: */ 758 627 if (fIsGuruMeditation) 759 628 { 760 if (machineWindowWrapper()->machineView()) 761 machineWindowWrapper()->machineView()->setIgnoreGuestResize(true); 629 uisession()->setGuestResizeIgnored(true); 762 630 763 631 CConsole console = session().GetConsole(); … … 780 648 } 781 649 } 782 783 #ifdef Q_WS_MAC 784 /* Update Dock Overlay: */ 785 if (machineWindowWrapper() && machineWindowWrapper()->machineView()) 786 machineWindowWrapper()->machineView()->updateDockOverlay(); 787 #endif /* Q_WS_MAC */ 788 } 789 790 void UIMachineLogic::updateAdditionsState() 791 { 792 /* Update action groups: */ 793 actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize)->setEnabled(m_fIsAdditionsActive && m_fIsGuestSupportsGraphics); 794 actionsPool()->action(UIActionIndex_Toggle_Seamless)->setEnabled(m_fIsAdditionsActive && m_fIsGuestSupportsGraphics && m_fIsGuestSupportsSeamless); 795 796 #if 0 // TODO: Enter seamless if necessary! 797 /* If seamless mode should be enabled then check if it is enabled currently and re-enable it if open-view procedure is finished */ 798 if (actionsPool()->action(UIActionIndex_Toggle_Seamless)->isChecked() && 799 m_fIsAdditionsActive && m_fIsGuestSupportsGraphics && m_fIsGuestSupportsSeamless) 800 toggleFullscreenMode(true, true); 801 #endif 650 } 651 652 void UIMachineLogic::sltAdditionsStateChanged() 653 { 654 /* Variable falgs: */ 655 bool fIsAdditionsActive = uisession()->isGuestAdditionsActive(); 656 bool fIsSupportsGraphics = fIsAdditionsActive && uisession()->isGuestSupportsGraphics(); 657 bool fIsSupportsSeamless = fIsSupportsGraphics && uisession()->isGuestSupportsSeamless(); 658 659 /* Update action states: */ 660 actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize)->setEnabled(fIsSupportsGraphics); 661 actionsPool()->action(UIActionIndex_Toggle_Seamless)->setEnabled(fIsSupportsSeamless); 802 662 803 663 /* Check the GA version only in case of additions are active: */ 804 if (! m_fIsAdditionsActive)664 if (!fIsAdditionsActive) 805 665 return; 806 807 666 /* Check the Guest Additions version and warn the user about possible compatibility issues in case if the installed version is outdated. */ 808 667 CGuest guest = session().GetConsole().GetGuest(); … … 826 685 } 827 686 828 void UIMachineLogic::updateMouseCapability() 829 { 830 /* Update related things: */ 687 void UIMachineLogic::sltMouseCapabilityChanged() 688 { 689 /* Variable falgs: */ 690 bool fIsMouseSupportsAbsolute = uisession()->isMouseSupportsAbsolute(); 691 /* bool fIsMouseSupportsRelative = uisession()->isMouseSupportsRelative(); */ 692 bool fIsMouseHostCursorNeeded = uisession()->isMouseHostCursorNeeded(); 693 694 /* Update action state: */ 831 695 QAction *pAction = actionsPool()->action(UIActionIndex_Toggle_MouseIntegration); 832 pAction->setEnabled(m_fIsMouseSupportsAbsolute && m_fIsMouseSupportsRelative && !m_fIsHostCursorNeeded); 833 pAction->setChecked(m_fIsHostCursorNeeded || pAction->isChecked()); 834 } 835 836 void UIMachineLogic::sltMachineStateChanged(KMachineState state) 837 { 838 /* Check if something had changed: */ 839 if (m_machineState != state) 840 { 841 /* Store new data: */ 842 m_machineState = state; 843 844 /* Update machine state: */ 845 updateMachineState(); 846 } 847 } 848 849 void UIMachineLogic::sltAdditionsStateChanged() 850 { 851 /* Get our guest: */ 852 CGuest guest = session().GetConsole().GetGuest(); 853 854 /* Variable flags: */ 855 bool fIsAdditionsActive = guest.GetAdditionsActive(); 856 bool fIsGuestSupportsGraphics = guest.GetSupportsGraphics(); 857 bool fIsGuestSupportsSeamless = guest.GetSupportsSeamless(); 858 859 /* Check if something had changed: */ 860 if (m_fIsAdditionsActive != fIsAdditionsActive || 861 m_fIsGuestSupportsGraphics != fIsGuestSupportsGraphics || 862 m_fIsGuestSupportsSeamless != fIsGuestSupportsSeamless) 863 { 864 /* Store new data: */ 865 m_fIsAdditionsActive = fIsAdditionsActive; 866 m_fIsGuestSupportsGraphics = fIsGuestSupportsGraphics; 867 m_fIsGuestSupportsSeamless = fIsGuestSupportsSeamless; 868 869 /* Update additions state: */ 870 updateAdditionsState(); 871 } 872 } 873 874 void UIMachineLogic::sltMouseCapabilityChanged(bool fIsSupportsAbsolute, bool fIsSupportsRelative, bool fIsHostCursorNeeded) 875 { 876 /* Check if something is changed: */ 877 if (m_fIsMouseSupportsAbsolute != fIsSupportsAbsolute || 878 m_fIsMouseSupportsRelative != fIsSupportsRelative || 879 m_fIsHostCursorNeeded != fIsHostCursorNeeded) 880 { 881 /* Store new data: */ 882 m_fIsMouseSupportsAbsolute = fIsSupportsAbsolute; 883 m_fIsMouseSupportsRelative = fIsSupportsRelative; 884 m_fIsHostCursorNeeded = fIsHostCursorNeeded; 885 886 /* Update mouse capability: */ 887 updateMouseCapability(); 888 } 889 } 890 891 void UIMachineLogic::sltUSBDeviceStateChange(const CUSBDevice &device, bool bIsAttached, const CVirtualBoxErrorInfo &error) 892 { 893 bool success = error.isNull(); 894 895 if (!success) 896 { 897 if (bIsAttached) 696 pAction->setEnabled(fIsMouseSupportsAbsolute /* && fIsMouseSupportsRelative */ && !fIsMouseHostCursorNeeded); 697 pAction->setChecked(fIsMouseHostCursorNeeded || pAction->isChecked()); 698 } 699 700 void UIMachineLogic::sltUSBDeviceStateChange(const CUSBDevice &device, bool fIsAttached, const CVirtualBoxErrorInfo &error) 701 { 702 bool fSuccess = error.isNull(); 703 704 if (!fSuccess) 705 { 706 if (fIsAttached) 898 707 vboxProblem().cannotAttachUSBDevice(session().GetConsole(), vboxGlobal().details(device), error); 899 708 else … … 902 711 } 903 712 904 void UIMachineLogic::sltRuntimeError(bool bIsFatal, const QString &strErrorId, const QString &strMessage)905 { 906 vboxProblem().showRuntimeError(session().GetConsole(), bIsFatal, strErrorId, strMessage);907 } 908 909 void UIMachineLogic::sltToggleGuestAutoresize(bool bEnabled)713 void UIMachineLogic::sltRuntimeError(bool fIsFatal, const QString &strErrorId, const QString &strMessage) 714 { 715 vboxProblem().showRuntimeError(session().GetConsole(), fIsFatal, strErrorId, strMessage); 716 } 717 718 void UIMachineLogic::sltToggleGuestAutoresize(bool fEnabled) 910 719 { 911 720 /* Do not process if window or view is missing! */ … … 913 722 return; 914 723 915 machineWindowWrapper()->machineView()->setGuestAutoresizeEnabled( bEnabled);724 machineWindowWrapper()->machineView()->setGuestAutoresizeEnabled(fEnabled); 916 725 } 917 726 … … 930 739 } 931 740 932 void UIMachineLogic::sltToggleMouseIntegration(bool aOff)741 void UIMachineLogic::sltToggleMouseIntegration(bool fOff) 933 742 { 934 743 /* Do not process if window or view is missing! */ … … 937 746 938 747 /* Disable/Enable mouse-integration for view: */ 939 machineWindowWrapper()->machineView()->setMouseIntegrationEnabled(! aOff);748 machineWindowWrapper()->machineView()->setMouseIntegrationEnabled(!fOff); 940 749 } 941 750 … … 972 781 973 782 /* Remember the paused state. */ 974 bool bWasPaused = machineState() == KMachineState_Paused;975 if (! bWasPaused)783 bool fWasPaused = uisession()->isPaused(); 784 if (!fWasPaused) 976 785 { 977 786 /* Suspend the VM and ignore the close event if failed to do so. 978 787 * pause() will show the error message to the user. */ 979 if (! pause())788 if (!uisession()->pause()) 980 789 return; 981 790 } … … 1012 821 1013 822 /* Restore the running state if needed. */ 1014 if (! bWasPaused)1015 u npause();823 if (!fWasPaused) 824 uisession()->unpause(); 1016 825 } 1017 826 … … 1023 832 1024 833 // TODO: Call for singleton information dialog for this machine! 1025 //VBoxVMInformationDlg::createInformationDlg(session(), machineWindowWrapper()->machineWindow());834 //VBoxVMInformationDlg::createInformationDlg(session(), machineWindowWrapper()->machineWindow()); 1026 835 } 1027 836 … … 1037 846 } 1038 847 1039 void UIMachineLogic::sltPause(bool aOn)1040 { 1041 pause(aOn);848 void UIMachineLogic::sltPause(bool fOn) 849 { 850 uisession()->setPause(fOn); 1042 851 } 1043 852 1044 853 void UIMachineLogic::sltACPIShutdown() 1045 854 { 855 /* Get console: */ 1046 856 CConsole console = session().GetConsole(); 1047 857 … … 1144 954 CMedium currentMedium = attachment.GetMedium(); 1145 955 QString currentId = currentMedium.isNull() ? QString::null : currentMedium.GetId(); 1146 bool currentUsed = false;956 bool fCurrentUsed = false; 1147 957 foreach (CMedium medium, mediums) 1148 958 { … … 1162 972 if (!isMediumUsed) 1163 973 { 1164 if (! currentUsed && !currentMedium.isNull() && mediumsToBeShown == maxMediumsToBeShown - 1)974 if (!fCurrentUsed && !currentMedium.isNull() && mediumsToBeShown == maxMediumsToBeShown - 1) 1165 975 medium = currentMedium; 1166 976 1167 977 if (medium.GetId() == currentId) 1168 currentUsed = true;978 fCurrentUsed = true; 1169 979 1170 980 QAction *mountMediumAction = new QAction(VBoxMedium(medium, mediumType).name(), pAttachmentMenu); … … 1269 1079 /* New mount-target attributes: */ 1270 1080 QString newId = QString(""); 1271 bool selectWithMediaManager = target.type != VBoxDefs::MediumType_Invalid;1081 bool fSelectWithMediaManager = target.type != VBoxDefs::MediumType_Invalid; 1272 1082 1273 1083 /* Open Virtual Media Manager to select image id: */ 1274 if ( selectWithMediaManager)1084 if (fSelectWithMediaManager) 1275 1085 { 1276 1086 /* Search for already used images: */ … … 1293 1103 newId = target.id; 1294 1104 1295 bool mount = !newId.isEmpty();1105 bool fMount = !newId.isEmpty(); 1296 1106 1297 1107 /* Remount medium to the predefined port/device: */ 1298 bool wasMounted = false;1108 bool fWasMounted = false; 1299 1109 machine.MountMedium(target.name, target.port, target.device, newId, false /* force */); 1300 1110 if (machine.isOk()) 1301 wasMounted = true;1111 fWasMounted = true; 1302 1112 else 1303 1113 { 1304 1114 /* Ask for force remounting: */ 1305 if (vboxProblem().cannotRemountMedium(machineWindowWrapper()->machineWindow(), machine, vboxGlobal().findMedium ( mount ? newId : currentId), mount, true /* retry? */) == QIMessageBox::Ok)1115 if (vboxProblem().cannotRemountMedium(machineWindowWrapper()->machineWindow(), machine, vboxGlobal().findMedium (fMount ? newId : currentId), fMount, true /* retry? */) == QIMessageBox::Ok) 1306 1116 { 1307 1117 /* Force remount medium to the predefined port/device: */ 1308 1118 machine.MountMedium(target.name, target.port, target.device, newId, true /* force */); 1309 1119 if (machine.isOk()) 1310 wasMounted = true;1120 fWasMounted = true; 1311 1121 else 1312 vboxProblem().cannotRemountMedium(machineWindowWrapper()->machineWindow(), machine, vboxGlobal().findMedium ( mount ? newId : currentId), mount, false /* retry? */);1122 vboxProblem().cannotRemountMedium(machineWindowWrapper()->machineWindow(), machine, vboxGlobal().findMedium (fMount ? newId : currentId), fMount, false /* retry? */); 1313 1123 } 1314 1124 } 1315 1125 1316 1126 /* Save medium mounted at runtime */ 1317 if ( wasMounted && !m_fIsIgnoringRutimeMediums)1127 if (fWasMounted && !uisession()->isIgnoreRuntimeMediumsChanging()) 1318 1128 { 1319 1129 machine.SaveSettings(); … … 1338 1148 1339 1149 /* Fill USB devices menu: */ 1340 bool bIsUSBListEmpty = devices.size() == 0;1341 if ( bIsUSBListEmpty)1150 bool fIsUSBListEmpty = devices.size() == 0; 1151 if (fIsUSBListEmpty) 1342 1152 { 1343 1153 /* Fill USB devices menu: */ … … 1423 1233 } 1424 1234 1425 void UIMachineLogic::sltSwitchVrdp(bool aOn)1235 void UIMachineLogic::sltSwitchVrdp(bool fOn) 1426 1236 { 1427 1237 /* Enable VRDP server if possible: */ 1428 1238 CVRDPServer server = session().GetMachine().GetVRDPServer(); 1429 1239 AssertMsg(!server.isNull(), ("VRDP server should not be null!\n")); 1430 server.SetEnabled( aOn);1240 server.SetEnabled(fOn); 1431 1241 } 1432 1242 … … 1513 1323 } 1514 1324 1515 void UIMachineLogic::sltLoggingToggled(bool bState)1516 { 1517 NOREF( bState);1325 void UIMachineLogic::sltLoggingToggled(bool fState) 1326 { 1327 NOREF(fState); 1518 1328 CConsole console = session().GetConsole(); 1519 1329 if (console.isOk()) … … 1521 1331 CMachineDebugger cdebugger = console.GetDebugger(); 1522 1332 if (console.isOk()) 1523 cdebugger.SetLogEnabled(bState); 1524 } 1525 } 1526 #endif 1527 1528 bool UIMachineLogic::pause(bool bOn) 1529 { 1530 if (isPaused() == bOn) 1531 return true; 1532 1533 CConsole console = session().GetConsole(); 1534 1535 if (bOn) 1536 console.Pause(); 1537 else 1538 console.Resume(); 1539 1540 bool ok = console.isOk(); 1541 if (!ok) 1542 { 1543 if (bOn) 1544 vboxProblem().cannotPauseMachine(console); 1545 else 1546 vboxProblem().cannotResumeMachine(console); 1547 } 1548 1549 return ok; 1550 } 1333 cdebugger.SetLogEnabled(fState); 1334 } 1335 } 1336 #endif 1551 1337 1552 1338 void UIMachineLogic::installGuestAdditionsFrom(const QString &strSource) … … 1602 1388 if (!strCntName.isNull()) 1603 1389 { 1604 bool isMounted = false;1390 bool fIsMounted = false; 1605 1391 1606 1392 /* Mount medium to the predefined port/device */ 1607 1393 machine.MountMedium(strCntName, iCntPort, iCntDevice, strUuid, false /* force */); 1608 1394 if (machine.isOk()) 1609 isMounted = true;1395 fIsMounted = true; 1610 1396 else 1611 1397 { … … 1617 1403 machine.MountMedium(strCntName, iCntPort, iCntDevice, strUuid, true /* force */); 1618 1404 if (machine.isOk()) 1619 isMounted = true;1405 fIsMounted = true; 1620 1406 else 1621 1407 vboxProblem().cannotRemountMedium(machineWindowWrapper()->machineWindow(), machine, VBoxMedium(image, VBoxDefs::MediumType_DVD), 1622 1408 true /* mount? */, false /* retry? */); 1623 1409 } 1624 }1625 1626 /* Save medium mounted at runtime */1627 if (isMounted && !m_fIsIgnoringRutimeMediums)1628 {1629 machine.SaveSettings();1630 if (!machine.isOk())1631 vboxProblem().cannotSaveMachineSettings(machine);1632 1410 } 1633 1411 } … … 1736 1514 } 1737 1515 # endif 1738 bool UIMachineLogic::toggleFullscreenMode (bool aOn, bool aSeamless)1516 bool UIMachineLogic::toggleFullscreenMode (bool fOn, bool fSeamless) 1739 1517 { 1740 1518 /* Please note: For some platforms like the Mac, the calling order of the … … 1743 1521 1744 1522 QSize initialSize = size(); 1745 if ( aSeamless || mConsole->isAutoresizeGuestActive())1746 { 1747 QRect screen = aSeamless ?1523 if (fSeamless || mConsole->isAutoresizeGuestActive()) 1524 { 1525 QRect screen = fSeamless ? 1748 1526 QApplication::desktop()->availableGeometry (this) : 1749 1527 QApplication::desktop()->screenGeometry (this); … … 1758 1536 * mSession.GetMachine().GetMonitorCount() /**< @todo fix assumption that all screens have same resolution */ 1759 1537 + 4096 * 8; /* adapter info */ 1760 if ( aOn && (availBits < usedBits))1761 { 1762 if ( aSeamless)1538 if (fOn && (availBits < usedBits)) 1539 { 1540 if (fSeamless) 1763 1541 { 1764 1542 vboxProblem().cannotEnterSeamlessMode ( … … 1779 1557 1780 1558 AssertReturn (mConsole, false); 1781 AssertReturn ((mHiddenChildren.empty() == aOn), false);1782 AssertReturn (( aSeamless && mIsSeamless != aOn) ||1783 (! aSeamless && mIsFullscreen != aOn), false);1784 if ( aOn)1785 AssertReturn (( aSeamless && !mIsFullscreen) ||1786 (! aSeamless && !mIsSeamless), false);1787 1788 if ( aOn)1559 AssertReturn ((mHiddenChildren.empty() == fOn), false); 1560 AssertReturn ((fSeamless && mIsSeamless != fOn) || 1561 (!fSeamless && mIsFullscreen != fOn), false); 1562 if (fOn) 1563 AssertReturn ((fSeamless && !mIsFullscreen) || 1564 (!fSeamless && !mIsSeamless), false); 1565 1566 if (fOn) 1789 1567 { 1790 1568 /* Take the toggle hot key from the menu item. Since … … 1792 1570 * linked key without the 'Host+' part we are adding it here. */ 1793 1571 QString hotKey = QString ("Host+%1") 1794 .arg (VBoxGlobal::extractKeyFromActionText ( aSeamless ?1572 .arg (VBoxGlobal::extractKeyFromActionText (fSeamless ? 1795 1573 mVmSeamlessAction->text() : mVmFullscreenAction->text())); 1796 1574 … … 1798 1576 1799 1577 /* Show the info message. */ 1800 bool ok = aSeamless ?1578 bool ok = fSeamless ? 1801 1579 vboxProblem().confirmGoingSeamless (hotKey) : 1802 1580 vboxProblem().confirmGoingFullscreen (hotKey); … … 1806 1584 1807 1585 #ifdef Q_WS_MAC 1808 if (! aSeamless)1809 { 1810 } 1811 #endif 1812 1813 if ( aSeamless)1586 if (!fSeamless) 1587 { 1588 } 1589 #endif 1590 1591 if (fSeamless) 1814 1592 { 1815 1593 /* Activate the auto-resize feature required for the seamless mode. */ … … 1821 1599 mVmDisableMouseIntegrAction->setChecked (false); 1822 1600 1823 mVmAdjustWindowAction->setEnabled (! aOn);1824 mVmFullscreenAction->setEnabled (! aOn);1825 mVmAutoresizeGuestAction->setEnabled (! aOn);1826 mVmDisableMouseIntegrAction->setEnabled (! aOn);1827 1828 mConsole->console().GetDisplay().SetSeamlessMode ( aOn);1829 mIsSeamless = aOn;1601 mVmAdjustWindowAction->setEnabled (!fOn); 1602 mVmFullscreenAction->setEnabled (!fOn); 1603 mVmAutoresizeGuestAction->setEnabled (!fOn); 1604 mVmDisableMouseIntegrAction->setEnabled (!fOn); 1605 1606 mConsole->console().GetDisplay().SetSeamlessMode (fOn); 1607 mIsSeamless = fOn; 1830 1608 } 1831 1609 else 1832 1610 { 1833 mIsFullscreen = aOn;1834 mVmAdjustWindowAction->setEnabled (! aOn);1835 mVmSeamlessAction->setEnabled (! aOn && m_fIsGuestSupportsSeamless && m_fIsGuestSupportsGraphics);1611 mIsFullscreen = fOn; 1612 mVmAdjustWindowAction->setEnabled (!fOn); 1613 mVmSeamlessAction->setEnabled (!fOn && m_fIsGuestSupportsSeamless && m_fIsGuestSupportsGraphics); 1836 1614 } 1837 1615 … … 1840 1618 /* Temporarily disable the mode-related action to make sure 1841 1619 * user can not leave the mode before he enter it and inside out. */ 1842 aSeamless ? mVmSeamlessAction->setEnabled (false) :1620 fSeamless ? mVmSeamlessAction->setEnabled (false) : 1843 1621 mVmFullscreenAction->setEnabled (false); 1844 1622 … … 1846 1624 QSize consoleSize; 1847 1625 1848 if ( aOn)1626 if (fOn) 1849 1627 { 1850 1628 consoleSize = mConsole->frameSize(); … … 1868 1646 1869 1647 /* let the widget take the whole available desktop space */ 1870 QRect scrGeo = aSeamless ?1648 QRect scrGeo = fSeamless ? 1871 1649 dtw->availableGeometry (this) : dtw->screenGeometry (this); 1872 1650 … … 1874 1652 * we requested. So after all the resizing stuff set the clipping 1875 1653 * mask and the spacing shifter to the corresponding values. */ 1876 if ( aSeamless)1654 if (fSeamless) 1877 1655 setViewInSeamlessMode (scrGeo); 1878 1656 … … 1902 1680 palette.setColor (centralWidget()->backgroundRole(), Qt::black); 1903 1681 centralWidget()->setPalette (palette); 1904 centralWidget()->setAutoFillBackground (! aSeamless);1682 centralWidget()->setAutoFillBackground (!fSeamless); 1905 1683 mConsoleStyle = mConsole->frameStyle(); 1906 1684 mConsole->setFrameStyle (QFrame::NoFrame); … … 1923 1701 1924 1702 #ifdef Q_WS_MAC 1925 if ( aSeamless)1703 if (fSeamless) 1926 1704 { 1927 1705 /* Please note: All the stuff below has to be done before the … … 1954 1732 mIsWaitingModeResize = true; 1955 1733 1956 if (! aOn)1734 if (!fOn) 1957 1735 { 1958 1736 /* Animation takes a bit long, the mini toolbar is still disappearing … … 1963 1741 1964 1742 /* Toggle qt full-screen mode */ 1965 switchToFullscreen ( aOn, aSeamless);1966 1967 if ( aOn)1968 { 1969 mMiniToolBar->setSeamlessMode ( aSeamless);1743 switchToFullscreen (fOn, fSeamless); 1744 1745 if (fOn) 1746 { 1747 mMiniToolBar->setSeamlessMode (fSeamless); 1970 1748 mMiniToolBar->updateDisplay (true, true); 1971 1749 } 1972 1750 1973 1751 #ifdef Q_WS_MAC 1974 if ( aOn && aSeamless)1752 if (fOn && fSeamless) 1975 1753 { 1976 1754 /* Please note: All the stuff below has to be done after the window has … … 2004 1782 return true; 2005 1783 } 2006 void UIMachineLogic::switchToFullscreen (bool aOn, bool aSeamless)1784 void UIMachineLogic::switchToFullscreen (bool fOn, bool fSeamless) 2007 1785 { 2008 1786 #ifdef Q_WS_MAC … … 2012 1790 WindowGroupRef g = GetWindowGroup (::darwinToNativeWindow (this)); 2013 1791 # endif /* !QT_MAC_USE_COCOA */ 2014 if ( aSeamless)2015 if ( aOn)1792 if (fSeamless) 1793 if (fOn) 2016 1794 { 2017 1795 /* Save for later restoring */ … … 2035 1813 /* Here we are going really fullscreen */ 2036 1814 setWindowState (windowState() ^ Qt::WindowFullScreen); 2037 sltChangePresentationMode (VBoxChangePresentationModeEvent( aOn));1815 sltChangePresentationMode (VBoxChangePresentationModeEvent(fOn)); 2038 1816 } 2039 1817 … … 2043 1821 # endif /* !QT_MAC_USE_COCOA */ 2044 1822 #else 2045 NOREF ( aOn);2046 NOREF ( aSeamless);1823 NOREF (fOn); 1824 NOREF (fSeamless); 2047 1825 setWindowState (windowState() ^ Qt::WindowFullScreen); 2048 1826 #endif -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h
r26795 r26815 24 24 #define __UIMachineLogic_h__ 25 25 26 /* Global includes */ 27 #include <QObject> 28 26 29 /* Local includes */ 27 #include "COMDefs.h"28 30 #include "UIMachineDefs.h" 29 31 #ifdef VBOX_WITH_DEBUGGER_GUI … … 35 37 36 38 /* Local forwards */ 39 class CSession; 40 class CMachine; 41 class CSnapshot; 42 class CUSBDevice; 43 class CVirtualBoxErrorInfo; 37 44 class UISession; 38 45 class UIActionsPool; … … 51 58 UIVisualStateType visualStateType); 52 59 53 /* Public getters: */60 /* Main getters/setters: */ 54 61 UISession* uisession() { return m_pSession; } 55 62 UIActionsPool* actionsPool() { return m_pActionsPool; } 56 63 UIVisualStateType visualStateType() const { return m_visualStateType; } 57 64 UIMachineWindow* machineWindowWrapper() { return m_pMachineWindowWrapper; } 58 KMachineState machineState() const { return m_machineState; } 59 bool isPaused() const { return machineState() == KMachineState_Paused || 60 machineState() == KMachineState_TeleportingPausedVM; } 65 66 /* Maintenance getters/setters: */ 61 67 bool isPreventAutoClose() const { return m_fIsPreventAutoClose; } 62 63 /* Public setters: */64 68 void setPreventAutoClose(bool fIsPreventAutoClose) { m_fIsPreventAutoClose = fIsPreventAutoClose; } 65 69 … … 73 77 virtual ~UIMachineLogic(); 74 78 75 /* Protected getters: */79 /* Protected wrappers: */ 76 80 CSession& session(); 77 bool isFirstTimeStarted() const { return m_fIsFirstTimeStarted; }78 81 79 82 /* Protected setters: */ 80 83 void setMachineWindowWrapper(UIMachineWindow *pMachineWindowWrapper) { m_pMachineWindowWrapper = pMachineWindowWrapper; } 81 82 /* Console related routines: */83 bool pause() { return pause(true); }84 bool unpause() { return pause(false); }85 84 86 85 /* Prepare helpers: */ … … 89 88 virtual void prepareActionConnections(); 90 89 virtual void prepareRequiredFeatures(); 91 virtual void loadLogicSettings();92 90 93 91 /* Cleanup helpers: */ 94 virtual void saveLogicSettings(); 95 virtual void cleanupRequiredFeatures() {} 96 virtual void cleanupActionConnections() {} 97 virtual void cleanupActionGroups() {} 98 virtual void cleanupConsoleConnections() {} 99 100 /* Update helpers: */ 101 virtual void updateMachineState(); 102 virtual void updateAdditionsState(); 103 virtual void updateMouseCapability(); 92 //virtual void cleanupRequiredFeatures() {} 93 //virtual void cleanupActionConnections() {} 94 //virtual void cleanupActionGroups() {} 95 //virtual void cleanupConsoleConnections() {} 104 96 105 97 protected slots: 106 98 107 99 /* Console callback handlers: */ 108 virtual void sltMachineStateChanged( KMachineState machineState);100 virtual void sltMachineStateChanged(); 109 101 virtual void sltAdditionsStateChanged(); 110 virtual void sltMouseCapabilityChanged( bool fIsSupportsAbsolute, bool fIsSupportsRelative, bool fNeedsHostCursor);111 virtual void sltUSBDeviceStateChange(const CUSBDevice &device, bool bIsAttached, const CVirtualBoxErrorInfo &error);112 virtual void sltRuntimeError(bool bIsFatal, const QString &strErrorId, const QString &strMessage);102 virtual void sltMouseCapabilityChanged(); 103 virtual void sltUSBDeviceStateChange(const CUSBDevice &device, bool fIsAttached, const CVirtualBoxErrorInfo &error); 104 virtual void sltRuntimeError(bool fIsFatal, const QString &strErrorId, const QString &strMessage); 113 105 114 106 private slots: 115 107 116 108 /* "Machine" menu funtionality */ 117 void sltToggleGuestAutoresize(bool bEnabled);109 void sltToggleGuestAutoresize(bool fEnabled); 118 110 void sltAdjustWindow(); 119 void sltToggleMouseIntegration(bool bDisabled);111 void sltToggleMouseIntegration(bool fDisabled); 120 112 void sltTypeCAD(); 121 113 #ifdef Q_WS_X11 … … 125 117 void sltShowInformationDialog(); 126 118 void sltReset(); 127 void sltPause(bool aOn);119 void sltPause(bool fOn); 128 120 void sltACPIShutdown(); 129 121 void sltClose(); … … 136 128 void sltOpenNetworkAdaptersDialog(); 137 129 void sltOpenSharedFoldersDialog(); 138 void sltSwitchVrdp(bool bOn);130 void sltSwitchVrdp(bool fOn); 139 131 void sltInstallGuestAdditions(); 140 132 … … 149 141 150 142 /* Utility functions: */ 151 bool pause(bool bPaused);152 143 void installGuestAdditionsFrom(const QString &strSource); 153 144 static int searchMaxSnapshotIndex(const CMachine &machine, … … 158 149 UISession *m_pSession; 159 150 UIActionsPool *m_pActionsPool; 160 KMachineState m_machineState;161 151 UIVisualStateType m_visualStateType; 162 152 UIMachineWindow *m_pMachineWindowWrapper; … … 165 155 QActionGroup *m_pRunningOrPausedActions; 166 156 167 bool m_fIsFirstTimeStarted : 1;168 bool m_fIsIgnoringRutimeMediums : 1;169 bool m_fIsAdditionsActive : 1;170 bool m_fIsGuestSupportsGraphics : 1;171 bool m_fIsGuestSupportsSeamless : 1;172 bool m_fIsMouseSupportsAbsolute : 1;173 bool m_fIsMouseSupportsRelative : 1;174 bool m_fIsHostCursorNeeded : 1;175 157 bool m_fIsPreventAutoClose : 1; 176 158 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
r26797 r26815 30 30 31 31 /* Local includes */ 32 #include "COMDefs.h" 32 33 #include "VBoxGlobal.h" 33 34 #include "VBoxProblemReporter.h" … … 71 72 # endif 72 73 # include "XKeyboard.h" 73 # ifndef VBOX_WITHOUT_XCURSOR74 # include <X11/Xcursor/Xcursor.h>75 # endif76 74 #endif 77 75 … … 157 155 int UIMachineView::mouseState() const 158 156 { 159 return ( m_bIsMouseCaptured? UIMouseStateType_MouseCaptured : 0) |160 ( m_fIsMouseSupportsAbsolute? UIMouseStateType_MouseAbsolute : 0) |161 ( m_bIsMouseIntegrated? 0 : UIMouseStateType_MouseAbsoluteDisabled);157 return (uisession()->isMouseCaptured() ? UIMouseStateType_MouseCaptured : 0) | 158 (uisession()->isMouseSupportsAbsolute() ? UIMouseStateType_MouseAbsolute : 0) | 159 (uisession()->isMouseIntegrated() ? 0 : UIMouseStateType_MouseAbsoluteDisabled); 162 160 } 163 161 164 162 void UIMachineView::setMouseIntegrationEnabled(bool bEnabled) 165 163 { 166 if ( m_bIsMouseIntegrated== bEnabled)164 if (uisession()->isMouseIntegrated() == bEnabled) 167 165 return; 168 166 169 if ( m_fIsMouseSupportsAbsolute)167 if (uisession()->isMouseSupportsAbsolute()) 170 168 captureMouse(!bEnabled, false); 171 169 172 170 /* Hiding host cursor in case we are entering mouse integration 173 * mode until it's shape is set to the guest cursor shape in 174 * OnMousePointerShapeChange event handler. 175 * 176 * This is necessary to avoid double-cursor issues where both the 177 * guest and the host cursors are displayed in one place, one above the 178 * other. 179 * 180 * This is a workaround because the correct decision would be to notify 181 * the Guest Additions about we are entering the mouse integration 182 * mode. The GuestOS should hide it's cursor to allow using of 183 * host cursor for the guest's manipulation. 184 * 185 * This notification is not always possible though, as not all guests 186 * support switching to a hardware pointer on demand. */ 171 * mode until it's shape is set to the guest cursor shape. */ 187 172 if (bEnabled) 188 173 viewport()->setCursor(QCursor(Qt::BlankCursor)); 189 174 190 m_bIsMouseIntegrated = bEnabled;175 uisession()->setMouseIntegrated(bEnabled); 191 176 192 177 emitMouseStateChanged(); … … 201 186 : QAbstractScrollArea(pMachineWindow->machineWindow()) 202 187 , m_pMachineWindow(pMachineWindow) 203 , m_console(pMachineWindow->machineLogic()->uisession()->session().GetConsole())204 188 , m_mode(renderMode) 205 189 , m_globalSettings(vboxGlobal().settings()) 206 , m_machineState(KMachineState_Null)207 190 , m_pFrameBuffer(0) 208 191 #if defined(Q_WS_WIN) … … 210 193 #endif 211 194 , m_iLastMouseWheelDelta(0) 212 , m_uNumLockAdaptionCnt(2)213 , m_uCapsLockAdaptionCnt(2)214 195 , m_bIsAutoCaptureDisabled(false) 215 196 , m_bIsKeyboardCaptured(false) 216 , m_bIsMouseCaptured(false)217 , m_fIsMouseSupportsAbsolute(false)218 , m_fIsMouseSupportsRelative(false)219 , m_bIsMouseIntegrated(true)220 , m_fIsHideHostPointer(true)221 197 , m_bIsHostkeyPressed(false) 222 198 , m_bIsHostkeyAlone (false) 223 199 , m_bIsHostkeyInCapture(false) 224 , m_bIsGuestSupportsGraphics(false)225 200 , m_bIsMachineWindowResizeIgnored(true) 226 201 , m_bIsFrameBufferResizeIgnored(false) 227 , m_bIsGuestResizeIgnored(false)228 , m_fNumLock(false)229 , m_fCapsLock(false)230 , m_fScrollLock(false)231 202 , m_fPassCAD(false) 232 203 #ifdef VBOX_WITH_VIDEOHWACCEL … … 251 222 UIMachineView::~UIMachineView() 252 223 { 224 } 225 226 UISession* UIMachineView::uisession() const 227 { 228 return machineWindowWrapper()->machineLogic()->uisession(); 229 } 230 231 CSession& UIMachineView::session() 232 { 233 return uisession()->session(); 253 234 } 254 235 … … 385 366 void UIMachineView::prepareFrameBuffer() 386 367 { 387 CDisplay display = m_console.GetDisplay();368 CDisplay display = session().GetConsole().GetDisplay(); 388 369 Assert(!display.isNull()); 389 370 m_pFrameBuffer = NULL; … … 527 508 /* Overlay logo for the dock icon */ 528 509 //mVirtualBoxLogo = ::darwinToCGImageRef("VirtualBox_cube_42px.png"); 529 QString osTypeId = m_console.GetGuest().GetOSTypeId();510 QString osTypeId = session().GetConsole().GetGuest().GetOSTypeId(); 530 511 531 512 // TODO_NEW_CORE … … 573 554 574 555 /* Machine state-change updater: */ 575 connect(sender, SIGNAL(sig StateChange(KMachineState)), this, SLOT(sltMachineStateChanged(KMachineState)));556 connect(sender, SIGNAL(sigMachineStateChange()), this, SLOT(sltMachineStateChanged())); 576 557 577 558 /* Guest additions state-change updater: */ 578 559 connect(sender, SIGNAL(sigAdditionsStateChange()), this, SLOT(sltAdditionsStateChanged())); 579 560 580 /* Keyboard LEDs state-change updater: */581 connect(sender, SIGNAL(sigKeyboardLedsChange(bool, bool, bool)), this, SLOT(sltKeyboardLedsChanged(bool, bool, bool)));582 583 561 /* Mouse pointer shape state-change updater: */ 584 connect(sender, SIGNAL(sigMousePointerShapeChange(bool, bool, uint, uint, uint, uint, const uchar *)), 585 this, SLOT(sltMousePointerShapeChanged(bool, bool, uint, uint, uint, uint, const uchar *))); 562 connect(sender, SIGNAL(sigMousePointerShapeChange()), this, SLOT(sltMousePointerShapeChanged())); 586 563 587 564 /* Mouse capability state-change updater: */ 588 connect(sender, SIGNAL(sigMouseCapabilityChange( bool, bool, bool)), this, SLOT(sltMouseCapabilityChanged(bool, bool, bool)));565 connect(sender, SIGNAL(sigMouseCapabilityChange()), this, SLOT(sltMouseCapabilityChanged())); 589 566 } 590 567 … … 617 594 { 618 595 /* CAD settings: */ 619 QString passCAD = m_console.GetMachine().GetExtraData(VBoxDefs::GUI_PassCAD);596 QString passCAD = session().GetConsole().GetMachine().GetExtraData(VBoxDefs::GUI_PassCAD); 620 597 if (!passCAD.isEmpty() && ((passCAD != "false") || (passCAD != "no"))) 621 598 m_fPassCAD = true; 622 599 } 623 600 624 #if 0 625 /* Dynamical property settings: */ 626 { 627 /* Get loader: */ 628 UISession *loader = machineWindowWrapper()->machineLogic()->uisession(); 629 630 /* Load dynamical properties: */ 631 m_machineState = loader->property("MachineView/MachineState").value<KMachineState>(); 632 m_uNumLockAdaptionCnt = loader->property("MachineView/NumLockAdaptionCnt").toUInt(); 633 m_uCapsLockAdaptionCnt = loader->property("MachineView/CapsLockAdaptionCnt").toUInt(); 634 m_bIsAutoCaptureDisabled = loader->property("MachineView/IsAutoCaptureDisabled").toBool(); 635 m_bIsKeyboardCaptured = loader->property("MachineView/IsKeyboardCaptured").toBool(); 636 m_bIsMouseCaptured = loader->property("MachineView/IsMouseCaptured").toBool(); 637 m_fIsMouseSupportsAbsolute = loader->property("MachineView/IsMouseSupportsAbsolute").toBool(); 638 m_fIsMouseSupportsRelative = loader->property("MachineView/IsMouseSupportsRelative").toBool(); 639 m_bIsMouseIntegrated = loader->property("MachineView/IsMouseIntegrated").toBool(); 640 m_fIsHideHostPointer = loader->property("MachineView/IsHideHostPointer").toBool(); 641 m_bIsHostkeyInCapture = loader->property("MachineView/IsHostkeyInCapture").toBool(); 642 m_bIsGuestSupportsGraphics = loader->property("MachineView/IsGuestSupportsGraphics").toBool(); 643 m_fNumLock = loader->property("MachineView/IsNumLock").toBool(); 644 m_fCapsLock = loader->property("MachineView/IsCapsLock").toBool(); 645 m_fScrollLock = loader->property("MachineView/IsScrollLock").toBool(); 646 647 /* Update related things: */ 648 updateMachineState(); 649 updateAdditionsState(); 650 updateMousePointerShape(); 651 updateMouseCapability(); 652 } 653 #endif 654 } 655 656 void UIMachineView::saveMachineViewSettings() 657 { 658 #if 0 659 /* Dynamical property settings: */ 660 { 661 /* Get saver: */ 662 UISession *saver = machineWindowWrapper()->machineLogic()->uisession(); 663 664 /* Save dynamical properties: */ 665 saver->setProperty("MachineView/MachineState", QVariant::fromValue(machineState())); 666 saver->setProperty("MachineView/NumLockAdaptionCnt", m_uNumLockAdaptionCnt); 667 saver->setProperty("MachineView/CapsLockAdaptionCnt", m_uCapsLockAdaptionCnt); 668 saver->setProperty("MachineView/IsAutoCaptureDisabled", m_bIsAutoCaptureDisabled); 669 saver->setProperty("MachineView/IsKeyboardCaptured", m_bIsKeyboardCaptured); 670 saver->setProperty("MachineView/IsMouseCaptured", m_bIsMouseCaptured); 671 saver->setProperty("MachineView/IsMouseSupportsAbsolute", m_fIsMouseSupportsAbsolute); 672 saver->setProperty("MachineView/IsMouseSupportsRelative", m_fIsMouseSupportsRelative); 673 saver->setProperty("MachineView/IsMouseIntegrated", m_bIsMouseIntegrated); 674 saver->setProperty("MachineView/IsHideHostPointer", m_fIsHideHostPointer); 675 saver->setProperty("MachineView/IsHostkeyInCapture", m_bIsHostkeyInCapture); 676 saver->setProperty("MachineView/IsGuestSupportsGraphics", m_bIsGuestSupportsGraphics); 677 saver->setProperty("MachineView/IsNumLock", m_fNumLock); 678 saver->setProperty("MachineView/IsCapsLock", m_fCapsLock); 679 saver->setProperty("MachineView/IsScrollLock", m_fScrollLock); 680 } 601 #ifdef Q_WS_MAC 602 QString strSettings = vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_RealtimeDockIconUpdateEnabled).toLower(); 603 /* Default to true if it is an empty value: */ 604 bool fIsDockIconEnabled = strSettings.isEmpty() || strSettings == "true"; 605 setDockIconEnabled(fIsDockIconEnabled); 606 updateDockOverlay(); 681 607 #endif 682 608 } … … 717 643 { 718 644 /* Detach framebuffer from Display: */ 719 CDisplay display = console().GetDisplay();645 CDisplay display = session().GetConsole().GetDisplay(); 720 646 display.SetFramebuffer(VBOX_VIDEO_PRIMARY_SCREEN, CFramebuffer(NULL)); 721 647 /* Release the reference: */ … … 725 651 } 726 652 727 void UIMachineView::updateMachineState() 728 { 729 switch (machineState()) 653 void UIMachineView::sltMachineStateChanged() 654 { 655 /* Get machine state: */ 656 KMachineState state = uisession()->machineState(); 657 switch (state) 730 658 { 731 659 case KMachineState_Paused: … … 733 661 { 734 662 if (mode() != VBoxDefs::TimerMode && m_pFrameBuffer && 735 ( machineState() != KMachineState_TeleportingPausedVM || machineState()!= KMachineState_Teleporting))663 (state != KMachineState_TeleportingPausedVM || state != KMachineState_Teleporting)) 736 664 { 737 665 /* Take a screen snapshot. Note that TakeScreenShot() always needs a 32bpp image: */ 738 666 QImage shot = QImage(m_pFrameBuffer->width(), m_pFrameBuffer->height(), QImage::Format_RGB32); 739 CDisplay dsp = m_console.GetDisplay();667 CDisplay dsp = session().GetConsole().GetDisplay(); 740 668 dsp.TakeScreenShot(shot.bits(), shot.width(), shot.height()); 741 669 /* TakeScreenShot() may fail if, e.g. the Paused notification was delivered … … 759 687 case KMachineState_Running: 760 688 { 761 if ( machineState() == KMachineState_Paused || machineState()== KMachineState_TeleportingPausedVM)689 if (state == KMachineState_Paused || state == KMachineState_TeleportingPausedVM) 762 690 { 763 691 if (mode() != VBoxDefs::TimerMode && m_pFrameBuffer) … … 767 695 /* Ask for full guest display update (it will also update 768 696 * the viewport through IFramebuffer::NotifyUpdate): */ 769 CDisplay dsp = m_console.GetDisplay();697 CDisplay dsp = session().GetConsole().GetDisplay(); 770 698 dsp.InvalidateAndUpdate(); 771 699 } … … 779 707 break; 780 708 } 781 } 782 783 void UIMachineView::updateAdditionsState() 709 710 #ifdef Q_WS_MAC 711 /* Update Dock Overlay: */ 712 updateDockOverlay(); 713 #endif /* Q_WS_MAC */ 714 } 715 716 void UIMachineView::sltAdditionsStateChanged() 784 717 { 785 718 /* Check if we should restrict minimum size: */ … … 795 728 } 796 729 797 void UIMachineView:: updateMousePointerShape()798 { 799 if ( m_fIsMouseSupportsAbsolute)730 void UIMachineView::sltMousePointerShapeChanged() 731 { 732 if (uisession()->isMouseSupportsAbsolute()) 800 733 { 801 734 /* Should we hide/show pointer? */ 802 if ( m_fIsHideHostPointer)735 if (uisession()->isHidingHostPointer()) 803 736 viewport()->setCursor(Qt::BlankCursor); 804 737 else 805 viewport()->setCursor( m_lastCursor);806 } 807 } 808 809 void UIMachineView:: updateMouseCapability()738 viewport()->setCursor(uisession()->cursor()); 739 } 740 } 741 742 void UIMachineView::sltMouseCapabilityChanged() 810 743 { 811 744 /* Correct the mouse capture state and reset the cursor to the default shape if necessary: */ 812 if ( m_fIsMouseSupportsAbsolute)813 { 814 CMouse mouse = m_console.GetMouse();815 mouse.PutMouseEventAbsolute(-1, -1, 0, 0 /* Horizontal wheel */, 0);745 if (uisession()->isMouseSupportsAbsolute()) 746 { 747 CMouse mouse = session().GetConsole().GetMouse(); 748 mouse.PutMouseEventAbsolute(-1, -1, 0, 0, 0); 816 749 captureMouse(false, false); 817 750 } … … 820 753 821 754 /* Notify user about mouse integration state: */ 822 vboxProblem().remindAboutMouseIntegration( m_fIsMouseSupportsAbsolute);823 824 /* Notify all watchers: */755 vboxProblem().remindAboutMouseIntegration(uisession()->isMouseSupportsAbsolute()); 756 757 /* Notify all listeners: */ 825 758 emitMouseStateChanged(); 826 }827 828 void UIMachineView::sltMachineStateChanged(KMachineState state)829 {830 /* Check if something had changed: */831 if (m_machineState != state)832 {833 /* Set new data: */834 m_machineState = state;835 836 /* Update depending things: */837 updateMachineState();838 }839 }840 841 void UIMachineView::sltAdditionsStateChanged()842 {843 /* Get new values: */844 CGuest guest = console().GetGuest();845 bool bIsGuestSupportsGraphics = guest.GetSupportsGraphics();846 847 /* Check if something had changed: */848 if (m_bIsGuestSupportsGraphics != bIsGuestSupportsGraphics)849 {850 /* Get new data: */851 m_bIsGuestSupportsGraphics = bIsGuestSupportsGraphics;852 853 /* Update depending things: */854 updateAdditionsState();855 }856 }857 858 void UIMachineView::sltKeyboardLedsChanged(bool bNumLock, bool bCapsLock, bool bScrollLock)859 {860 /* Update num lock status: */861 if (m_fNumLock != bNumLock)862 {863 m_fNumLock = bNumLock;864 m_uNumLockAdaptionCnt = 2;865 }866 867 /* Update caps lock status: */868 if (m_fCapsLock != bCapsLock)869 {870 m_fCapsLock = bCapsLock;871 m_uCapsLockAdaptionCnt = 2;872 }873 874 /* Update scroll lock status: */875 if (m_fScrollLock != bScrollLock)876 m_fScrollLock = bScrollLock;877 }878 879 void UIMachineView::sltMousePointerShapeChanged(bool fIsVisible, bool fHasAlpha,880 uint uXHot, uint uYHot, uint uWidth, uint uHeight,881 const uchar *pShapeData)882 {883 /* Should we show cursor anyway? */884 m_fIsHideHostPointer = !fIsVisible;885 886 /* Should we cache shape data? */887 if (pShapeData)888 setPointerShape(pShapeData, fHasAlpha, uXHot, uYHot, uWidth, uHeight);889 890 /* Perform cursor update: */891 updateMousePointerShape();892 }893 894 void UIMachineView::sltMouseCapabilityChanged(bool fIsMouseSupportsAbsolute, bool fIsMouseSupportsRelative, bool /* fIsMouseNeedsHostCursor */)895 {896 /* Check if something had changed: */897 if (m_fIsMouseSupportsAbsolute != fIsMouseSupportsAbsolute || m_fIsMouseSupportsRelative != fIsMouseSupportsRelative)898 {899 /* Get new data: */900 m_fIsMouseSupportsAbsolute = fIsMouseSupportsAbsolute;901 m_fIsMouseSupportsRelative = fIsMouseSupportsRelative;902 903 /* Update depending things: */904 updateMouseCapability();905 }906 759 } 907 760 … … 952 805 case QEvent::FocusIn: 953 806 { 954 if ( isRunning())807 if (uisession()->isRunning()) 955 808 focusEvent(true); 956 809 break; … … 958 811 case QEvent::FocusOut: 959 812 { 960 if ( isRunning())813 if (uisession()->isRunning()) 961 814 focusEvent(false); 962 815 else … … 975 828 * to be ignored at all, leaving previous framebuffer, 976 829 * machine view and machine window sizes preserved: */ 977 if ( m_bIsGuestResizeIgnored)830 if (uisession()->isGuestResizeIgnored()) 978 831 return true; 979 832 … … 991 844 * Moreover the current cursor, which could be set by the guest, should be restored after resize: */ 992 845 QCursor cursor; 993 if ( shouldHideHostPointer())846 if (uisession()->isHidingHostPointer()) 994 847 cursor = QCursor(Qt::BlankCursor); 995 848 else … … 1007 860 * which was unset to default here will not be hidden in capture state. So it is necessary to perform 1008 861 * updateMouseClipping() for the guest resize event if the mouse cursor was captured: */ 1009 if ( m_bIsMouseCaptured)862 if (uisession()->isMouseCaptured()) 1010 863 updateMouseClipping(); 1011 864 … … 1035 888 1036 889 /* Report to the VM thread that we finished resizing */ 1037 m_console.GetDisplay().ResizeCompleted(0);890 session().GetConsole().GetDisplay().ResizeCompleted(0); 1038 891 1039 892 m_bIsMachineWindowResizeIgnored = oldIgnoreMainwndResize; … … 1063 916 viewport()->repaint(pPaintEvent->x() - contentsX(), pPaintEvent->y() - contentsY(), 1064 917 pPaintEvent->width(), pPaintEvent->height()); 1065 /* m_console.GetDisplay().UpdateCompleted(); - the event was acked already */918 /* session().GetConsole().GetDisplay().UpdateCompleted(); - the event was acked already */ 1066 919 return true; 1067 920 } … … 1103 956 { 1104 957 bool pressed = pEvent->type() == QEvent::KeyPress; 1105 CKeyboard keyboard = m_console.GetKeyboard();958 CKeyboard keyboard = session().GetConsole().GetKeyboard(); 1106 959 1107 960 /* Whether the host key is Shift so that it will modify the hot key values? … … 1194 1047 Assert(0); 1195 1048 1196 CKeyboard keyboard = m_console.GetKeyboard();1049 CKeyboard keyboard = session().GetConsole().GetKeyboard(); 1197 1050 keyboard.PutScancodes(combo); 1198 1051 } … … 1203 1056 /* Activate the main menu */ 1204 1057 if (machineWindowWrapper()->isTrueSeamless() || machineWindowWrapper()->isTrueFullscreen()) 1205 machineWindowWrapper()->popupMainMenu ( m_bIsMouseCaptured);1058 machineWindowWrapper()->popupMainMenu (uisession()->isMouseCaptured()); 1206 1059 else 1207 1060 { … … 1224 1077 { 1225 1078 /* Show a possible warning on key release which seems to be more expected by the end user: */ 1226 if ( machineWindowWrapper()->machineLogic()->isPaused())1079 if (uisession()->isPaused()) 1227 1080 { 1228 1081 /* Iif the reminder is disabled we pass the event to Qt to enable normal … … 1324 1177 case QEvent::Resize: 1325 1178 { 1326 if ( m_bIsMouseCaptured)1179 if (uisession()->isMouseCaptured()) 1327 1180 updateMouseClipping(); 1328 1181 #ifdef VBOX_WITH_VIDEOHWACCEL … … 1533 1386 * that's not possible because we cannot predict what other 1534 1387 * keys will be pressed next when one of C, A, D is held. */ 1535 if ( isRunning() && m_bIsKeyboardCaptured)1388 if (uisession()->isRunning() && m_bIsKeyboardCaptured) 1536 1389 { 1537 1390 captureKbd (false); 1538 if (!( m_fIsMouseSupportsAbsolute && m_bIsMouseIntegrated))1391 if (!(uisession()->isMouseSupportsAbsolute() && uisession()->isMouseIntegrated())) 1539 1392 captureMouse (false); 1540 1393 } … … 1589 1442 { 1590 1443 m_bIsHostkeyPressed = m_bIsHostkeyAlone = true; 1591 if ( isRunning())1444 if (uisession()->isRunning()) 1592 1445 saveKeyStates(); 1593 1446 emitSignal = true; … … 1616 1469 if (m_bIsHostkeyAlone) 1617 1470 { 1618 if ( machineWindowWrapper()->machineLogic()->isPaused())1471 if (uisession()->isPaused()) 1619 1472 { 1620 1473 vboxProblem().remindAboutPausedVMInput(); 1621 1474 } 1622 else if ( isRunning())1475 else if (uisession()->isRunning()) 1623 1476 { 1624 1477 bool captured = m_bIsKeyboardCaptured; … … 1644 1497 { 1645 1498 captureKbd (!captured, false); 1646 if (!( m_fIsMouseSupportsAbsolute && m_bIsMouseIntegrated))1499 if (!(uisession()->isMouseSupportsAbsolute() && uisession()->isMouseIntegrated())) 1647 1500 { 1648 1501 #ifdef Q_WS_X11 … … 1658 1511 } 1659 1512 1660 if ( isRunning())1513 if (uisession()->isRunning()) 1661 1514 sendChangedKeyStates(); 1662 1515 … … 1728 1581 1729 1582 /* No more to do, if the host key is in action or the VM is paused: */ 1730 if (m_bIsHostkeyPressed || isHostKey || machineWindowWrapper()->machineLogic()->isPaused())1583 if (m_bIsHostkeyPressed || isHostKey || uisession()->isPaused()) 1731 1584 { 1732 1585 /* Grab the key from Qt and from VM if it's a host key, … … 1735 1588 } 1736 1589 1737 CKeyboard keyboard = m_console.GetKeyboard();1590 CKeyboard keyboard = session().GetConsole().GetKeyboard(); 1738 1591 Assert(!keyboard.isNull()); 1739 1592 … … 1803 1656 wheelHorizontal = aWheelDelta / 120; 1804 1657 1805 if ( m_bIsMouseCaptured)1658 if (uisession()->isMouseCaptured()) 1806 1659 { 1807 1660 #ifdef Q_WS_WIN32 … … 1810 1663 #endif 1811 1664 1812 CMouse mouse = m_console.GetMouse();1665 CMouse mouse = session().GetConsole().GetMouse(); 1813 1666 mouse.PutMouseEvent(aGlobalPos.x() - m_lastMousePos.x(), 1814 1667 aGlobalPos.y() - m_lastMousePos.y(), … … 1903 1756 return true; /* stop further event handling */ 1904 1757 } 1905 else /* ! m_bIsMouseCaptured*/1758 else /* !uisession()->isMouseCaptured() */ 1906 1759 { 1907 1760 #if 0 // TODO: Move that to fullscreen event-hjadler: … … 1928 1781 #endif 1929 1782 1930 if ( m_fIsMouseSupportsAbsolute && m_bIsMouseIntegrated)1783 if (uisession()->isMouseSupportsAbsolute() && uisession()->isMouseIntegrated()) 1931 1784 { 1932 1785 int cw = contentsWidth(), ch = contentsHeight(); … … 1953 1806 else if (cpnt.y() > ch) cpnt.setY (ch); 1954 1807 1955 CMouse mouse = m_console.GetMouse();1808 CMouse mouse = session().GetConsole().GetMouse(); 1956 1809 mouse.PutMouseEventAbsolute (cpnt.x(), cpnt.y(), wheelVertical, 1957 1810 wheelHorizontal, state); … … 1962 1815 if (hasFocus() && (aType == QEvent::MouseButtonRelease && aButtons == Qt::NoButton)) 1963 1816 { 1964 if ( machineWindowWrapper()->machineLogic()->isPaused())1817 if (uisession()->isPaused()) 1965 1818 { 1966 1819 vboxProblem().remindAboutPausedVMInput(); 1967 1820 } 1968 else if ( isRunning())1821 else if (uisession()->isRunning()) 1969 1822 { 1970 1823 /* Temporarily disable auto capture that will take place after this dialog is dismissed because … … 2024 1877 /* Update the dock icon if we are in the running state */ 2025 1878 // TODO_NEW_CORE 2026 // if ( isRunning())1879 // if (uisession()->isRunning()) 2027 1880 // updateDockIcon(); 2028 1881 #endif … … 2316 2169 case XFocusOut: 2317 2170 case XFocusIn: 2318 if ( isRunning())2171 if (uisession()->isRunning()) 2319 2172 focusEvent(pEvent->type == XFocusIn); 2320 2173 return false; … … 2569 2422 #endif 2570 2423 2571 void UIMachineView::fixModifierState( LONG*piCodes, uint *puCount)2424 void UIMachineView::fixModifierState(int *piCodes, uint *puCount) 2572 2425 { 2573 2426 /* Synchronize the views of the host and the guest to the modifier keys. … … 2597 2450 XFreeModifiermap(map); 2598 2451 2599 if ( m_uNumLockAdaptionCnt && (m_fNumLock^ !!(uMask & uKeyMaskNum)))2600 { 2601 -- m_uNumLockAdaptionCnt;2452 if (uisession()->numLockAdaptionCnt() && (uisession()->isNumLock() ^ !!(uMask & uKeyMaskNum))) 2453 { 2454 uisession()->setNumLockAdaptionCnt(uisession()->numLockAdaptionCnt() - 1); 2602 2455 piCodes[(*puCount)++] = 0x45; 2603 2456 piCodes[(*puCount)++] = 0x45 | 0x80; 2604 2457 } 2605 if (m_uCapsLockAdaptionCnt && (m_fCapsLock ^ !!(uMask & uKeyMaskCaps))) 2606 { 2607 m_uCapsLockAdaptionCnt--; 2458 if (uisession()->capsLockAdaptionCnt() && (uisession()->isCapsLock() ^ !!(uMask & uKeyMaskCaps))) 2459 { 2460 uisession()->setCapsLockAdaptionCnt(uisession()->capsLockAdaptionCnt() - 1); 2461 piCodes[(*puCount)++] = 0x3a; 2462 piCodes[(*puCount)++] = 0x3a | 0x80; 2463 /* Some keyboard layouts require shift to be pressed to break 2464 * capslock. For simplicity, only do this if shift is not 2465 * already held down. */ 2466 if (uisession()->isCapsLock() && !(m_pressedKeys[0x2a] & IsKeyPressed)) 2467 { 2468 piCodes[(*puCount)++] = 0x2a; 2469 piCodes[(*puCount)++] = 0x2a | 0x80; 2470 } 2471 } 2472 2473 #elif defined(Q_WS_WIN32) 2474 2475 if (uisession()->numLockAdaptionCnt() && (m_fNumLock ^ !!(GetKeyState(VK_NUMLOCK)))) 2476 { 2477 uisession()->setNumLockAdaptionCnt(uisession()->numLockAdaptionCnt() - 1); 2478 piCodes[(*puCount)++] = 0x45; 2479 piCodes[(*puCount)++] = 0x45 | 0x80; 2480 } 2481 if (uisession()->capsLockAdaptionCnt() && (m_fCapsLock ^ !!(GetKeyState(VK_CAPITAL)))) 2482 { 2483 uisession()->setCapsLockAdaptionCnt(uisession()->capsLockAdaptionCnt() - 1); 2608 2484 piCodes[(*puCount)++] = 0x3a; 2609 2485 piCodes[(*puCount)++] = 0x3a | 0x80; … … 2618 2494 } 2619 2495 2620 #elif defined(Q_WS_WIN32)2621 2622 if (m_uNumLockAdaptionCnt && (m_fNumLock ^ !!(GetKeyState(VK_NUMLOCK))))2623 {2624 m_uNumLockAdaptionCnt--;2625 piCodes[(*puCount)++] = 0x45;2626 piCodes[(*puCount)++] = 0x45 | 0x80;2627 }2628 if (m_uCapsLockAdaptionCnt && (m_fCapsLock ^ !!(GetKeyState(VK_CAPITAL))))2629 {2630 m_uCapsLockAdaptionCnt--;2631 piCodes[(*puCount)++] = 0x3a;2632 piCodes[(*puCount)++] = 0x3a | 0x80;2633 /* Some keyboard layouts require shift to be pressed to break2634 * capslock. For simplicity, only do this if shift is not2635 * already held down. */2636 if (m_fCapsLock && !(m_pressedKeys[0x2a] & IsKeyPressed))2637 {2638 piCodes[(*puCount)++] = 0x2a;2639 piCodes[(*puCount)++] = 0x2a | 0x80;2640 }2641 }2642 2643 2496 #elif defined(Q_WS_MAC) 2644 2497 2645 /* if ( m_uNumLockAdaptionCnt) ... - NumLock isn't implemented by Mac OS X so ignore it. */2646 if ( m_uCapsLockAdaptionCnt&& (m_fCapsLock ^ !!(::GetCurrentEventKeyModifiers() & alphaLock)))2647 { 2648 m_uCapsLockAdaptionCnt--;2498 /* if (uisession()->numLockAdaptionCnt()) ... - NumLock isn't implemented by Mac OS X so ignore it. */ 2499 if (uisession()->capsLockAdaptionCnt() && (m_fCapsLock ^ !!(::GetCurrentEventKeyModifiers() & alphaLock))) 2500 { 2501 uisession()->setCapsLockAdaptionCnt(uisession()->capsLockAdaptionCnt() - 1); 2649 2502 piCodes[(*puCount)++] = 0x3a; 2650 2503 piCodes[(*puCount)++] = 0x3a | 0x80; … … 2758 2611 void UIMachineView::captureMouse(bool fCapture, bool fEmitSignal /* = true */) 2759 2612 { 2760 if ( m_bIsMouseCaptured== fCapture)2613 if (uisession()->isMouseCaptured() == fCapture) 2761 2614 return; 2762 2615 … … 2787 2640 #endif 2788 2641 /* Release mouse buttons: */ 2789 CMouse mouse = m_console.GetMouse();2642 CMouse mouse = session().GetConsole().GetMouse(); 2790 2643 mouse.PutMouseEvent (0, 0, 0, 0 /* Horizontal wheel */, 0); 2791 2644 } 2792 2645 2793 m_bIsMouseCaptured = fCapture;2646 uisession()->setMouseCaptured(fCapture); 2794 2647 2795 2648 updateMouseClipping(); … … 2806 2659 void UIMachineView::releaseAllPressedKeys(bool aReleaseHostKey /* = true */) 2807 2660 { 2808 CKeyboard keyboard = m_console.GetKeyboard();2661 CKeyboard keyboard = session().GetConsole().GetKeyboard(); 2809 2662 bool fSentRESEND = false; 2810 2663 … … 2856 2709 { 2857 2710 QVector <LONG> codes(2); 2858 CKeyboard keyboard = m_console.GetKeyboard();2711 CKeyboard keyboard = session().GetConsole().GetKeyboard(); 2859 2712 for (uint i = 0; i < SIZEOF_ARRAY(m_pressedKeys); ++ i) 2860 2713 { … … 2881 2734 void UIMachineView::updateMouseClipping() 2882 2735 { 2883 if ( m_bIsMouseCaptured)2736 if (uisession()->isMouseCaptured()) 2884 2737 { 2885 2738 viewport()->setCursor(QCursor(Qt::BlankCursor)); … … 2900 2753 viewport()->unsetCursor(); 2901 2754 } 2902 }2903 2904 void UIMachineView::setPointerShape(const uchar *pShapeData, bool fHasAlpha,2905 uint uXHot, uint uYHot, uint uWidth, uint uHeight)2906 {2907 AssertMsg(pShapeData, ("Shape data must not be NULL!\n"));2908 2909 bool ok = false;2910 2911 const uchar *srcAndMaskPtr = pShapeData;2912 uint andMaskSize = (uWidth + 7) / 8 * uHeight;2913 const uchar *srcShapePtr = pShapeData + ((andMaskSize + 3) & ~3);2914 uint srcShapePtrScan = uWidth * 4;2915 2916 #if defined (Q_WS_WIN)2917 2918 BITMAPV5HEADER bi;2919 HBITMAP hBitmap;2920 void *lpBits;2921 2922 ::ZeroMemory(&bi, sizeof (BITMAPV5HEADER));2923 bi.bV5Size = sizeof(BITMAPV5HEADER);2924 bi.bV5Width = uWidth;2925 bi.bV5Height = - (LONG)uHeight;2926 bi.bV5Planes = 1;2927 bi.bV5BitCount = 32;2928 bi.bV5Compression = BI_BITFIELDS;2929 bi.bV5RedMask = 0x00FF0000;2930 bi.bV5GreenMask = 0x0000FF00;2931 bi.bV5BlueMask = 0x000000FF;2932 if (fHasAlpha)2933 bi.bV5AlphaMask = 0xFF000000;2934 else2935 bi.bV5AlphaMask = 0;2936 2937 HDC hdc = GetDC(NULL);2938 2939 /* Create the DIB section with an alpha channel: */2940 hBitmap = CreateDIBSection(hdc, (BITMAPINFO *)&bi, DIB_RGB_COLORS, (void **)&lpBits, NULL, (DWORD) 0);2941 2942 ReleaseDC(NULL, hdc);2943 2944 HBITMAP hMonoBitmap = NULL;2945 if (fHasAlpha)2946 {2947 /* Create an empty mask bitmap: */2948 hMonoBitmap = CreateBitmap(uWidth, uHeight, 1, 1, NULL);2949 }2950 else2951 {2952 /* Word aligned AND mask. Will be allocated and created if necessary. */2953 uint8_t *pu8AndMaskWordAligned = NULL;2954 2955 /* Width in bytes of the original AND mask scan line. */2956 uint32_t cbAndMaskScan = (uWidth + 7) / 8;2957 2958 if (cbAndMaskScan & 1)2959 {2960 /* Original AND mask is not word aligned. */2961 2962 /* Allocate memory for aligned AND mask. */2963 pu8AndMaskWordAligned = (uint8_t *)RTMemTmpAllocZ((cbAndMaskScan + 1) * uHeight);2964 2965 Assert(pu8AndMaskWordAligned);2966 2967 if (pu8AndMaskWordAligned)2968 {2969 /* According to MSDN the padding bits must be 0.2970 * Compute the bit mask to set padding bits to 0 in the last byte of original AND mask. */2971 uint32_t u32PaddingBits = cbAndMaskScan * 8 - uWidth;2972 Assert(u32PaddingBits < 8);2973 uint8_t u8LastBytesPaddingMask = (uint8_t)(0xFF << u32PaddingBits);2974 2975 Log(("u8LastBytesPaddingMask = %02X, aligned w = %d, width = %d, cbAndMaskScan = %d\n",2976 u8LastBytesPaddingMask, (cbAndMaskScan + 1) * 8, uWidth, cbAndMaskScan));2977 2978 uint8_t *src = (uint8_t *)srcAndMaskPtr;2979 uint8_t *dst = pu8AndMaskWordAligned;2980 2981 unsigned i;2982 for (i = 0; i < uHeight; i++)2983 {2984 memcpy(dst, src, cbAndMaskScan);2985 2986 dst[cbAndMaskScan - 1] &= u8LastBytesPaddingMask;2987 2988 src += cbAndMaskScan;2989 dst += cbAndMaskScan + 1;2990 }2991 }2992 }2993 2994 /* Create the AND mask bitmap: */2995 hMonoBitmap = ::CreateBitmap(uWidth, uHeight, 1, 1,2996 pu8AndMaskWordAligned? pu8AndMaskWordAligned: srcAndMaskPtr);2997 2998 if (pu8AndMaskWordAligned)2999 {3000 RTMemTmpFree(pu8AndMaskWordAligned);3001 }3002 }3003 3004 Assert(hBitmap);3005 Assert(hMonoBitmap);3006 if (hBitmap && hMonoBitmap)3007 {3008 DWORD *dstShapePtr = (DWORD *) lpBits;3009 3010 for (uint y = 0; y < uHeight; y ++)3011 {3012 memcpy(dstShapePtr, srcShapePtr, srcShapePtrScan);3013 srcShapePtr += srcShapePtrScan;3014 dstShapePtr += uWidth;3015 }3016 3017 ICONINFO ii;3018 ii.fIcon = FALSE;3019 ii.xHotspot = uXHot;3020 ii.yHotspot = uYHot;3021 ii.hbmMask = hMonoBitmap;3022 ii.hbmColor = hBitmap;3023 3024 HCURSOR hAlphaCursor = CreateIconIndirect(&ii);3025 Assert(hAlphaCursor);3026 if (hAlphaCursor)3027 {3028 viewport()->setCursor(QCursor(hAlphaCursor));3029 ok = true;3030 if (m_alphaCursor)3031 DestroyIcon(m_alphaCursor);3032 m_alphaCursor = hAlphaCursor;3033 }3034 }3035 3036 if (hMonoBitmap)3037 DeleteObject(hMonoBitmap);3038 if (hBitmap)3039 DeleteObject(hBitmap);3040 3041 #elif defined (Q_WS_X11) && !defined (VBOX_WITHOUT_XCURSOR)3042 3043 XcursorImage *img = XcursorImageCreate(uWidth, uHeight);3044 Assert(img);3045 if (img)3046 {3047 img->xhot = uXHot;3048 img->yhot = uYHot;3049 3050 XcursorPixel *dstShapePtr = img->pixels;3051 3052 for (uint y = 0; y < uHeight; y ++)3053 {3054 memcpy (dstShapePtr, srcShapePtr, srcShapePtrScan);3055 3056 if (!fHasAlpha)3057 {3058 /* Convert AND mask to the alpha channel: */3059 uchar byte = 0;3060 for (uint x = 0; x < uWidth; x ++)3061 {3062 if (!(x % 8))3063 byte = *(srcAndMaskPtr ++);3064 else3065 byte <<= 1;3066 3067 if (byte & 0x80)3068 {3069 /* Linux doesn't support inverted pixels (XOR ops,3070 * to be exact) in cursor shapes, so we detect such3071 * pixels and always replace them with black ones to3072 * make them visible at least over light colors */3073 if (dstShapePtr [x] & 0x00FFFFFF)3074 dstShapePtr [x] = 0xFF000000;3075 else3076 dstShapePtr [x] = 0x00000000;3077 }3078 else3079 dstShapePtr [x] |= 0xFF000000;3080 }3081 }3082 3083 srcShapePtr += srcShapePtrScan;3084 dstShapePtr += uWidth;3085 }3086 3087 Cursor cur = XcursorImageLoadCursor(QX11Info::display(), img);3088 Assert (cur);3089 if (cur)3090 {3091 viewport()->setCursor(QCursor(cur));3092 ok = true;3093 }3094 3095 XcursorImageDestroy(img);3096 }3097 3098 #elif defined(Q_WS_MAC)3099 3100 /* Create a ARGB image out of the shape data. */3101 QImage image (uWidth, uHeight, QImage::Format_ARGB32);3102 const uint8_t* pbSrcMask = static_cast<const uint8_t*> (srcAndMaskPtr);3103 unsigned cbSrcMaskLine = RT_ALIGN (uWidth, 8) / 8;3104 for (unsigned int y = 0; y < uHeight; ++y)3105 {3106 for (unsigned int x = 0; x < uWidth; ++x)3107 {3108 unsigned int color = ((unsigned int*)srcShapePtr)[y*uWidth+x];3109 /* If the alpha channel isn't in the shape data, we have to3110 * create them from the and-mask. This is a bit field where 13111 * represent transparency & 0 opaque respectively. */3112 if (!fHasAlpha)3113 {3114 if (!(pbSrcMask[x / 8] & (1 << (7 - (x % 8)))))3115 color |= 0xff000000;3116 else3117 {3118 /* This isn't quite right, but it's the best we can do I think... */3119 if (color & 0x00ffffff)3120 color = 0xff000000;3121 else3122 color = 0x00000000;3123 }3124 }3125 image.setPixel (x, y, color);3126 }3127 /* Move one scanline forward. */3128 pbSrcMask += cbSrcMaskLine;3129 }3130 /* Set the new cursor: */3131 QCursor cursor(QPixmap::fromImage(image), uXHot, uYHot);3132 viewport()->setCursor(cursor);3133 ok = true;3134 NOREF(srcShapePtrScan);3135 3136 #else3137 3138 # warning "port me"3139 3140 #endif3141 3142 if (ok)3143 m_lastCursor = viewport()->cursor();3144 else3145 viewport()->unsetCursor();3146 2755 } 3147 2756 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h
r26798 r26815 24 24 #define ___UIMachineView_h___ 25 25 26 /* Global includes */ 27 #include <QAbstractScrollArea> 28 29 /* Local includes */ 30 #include "VBoxDefs.h" 31 #include "UIMachineDefs.h" 32 33 #ifdef Q_WS_MAC 34 # include <CoreFoundation/CFBase.h> 35 #endif /* Q_WS_MAC */ 36 26 37 /* Local forwards */ 38 class CSession; 39 class UISession; 27 40 class UIFrameBuffer; 28 41 class UIMachineWindow; 29 42 class VBoxGlobalSettings; 30 31 /* Global includes */32 #include <QAbstractScrollArea>33 34 /* Local includes */35 #include "COMDefs.h"36 #include "UIMachineDefs.h"37 38 #ifdef Q_WS_MAC39 # include <CoreFoundation/CFBase.h>40 #endif /* Q_WS_MAC */41 42 /* Local forwards */43 43 #ifdef Q_WS_MAC 44 44 class VBoxChangeDockIconUpdateEvent; … … 61 61 , UIVisualStateType visualStateType); 62 62 63 /* Public virtual members: */64 virtual void normalizeGeometry(bool bAdjustPosition = false) = 0;65 66 63 /* Public getters: */ 67 64 int keyboardState() const; … … 69 66 70 67 /* Public setters: */ 71 void setIgnoreGuestResize(bool bIgnore) { m_bIsGuestResizeIgnored = bIgnore; }72 68 virtual void setGuestAutoresizeEnabled(bool bEnabled) = 0; 73 69 virtual void setMouseIntegrationEnabled(bool bEnabled); 74 70 //void setMachineViewFinalized(bool fTrue = true) { m_bIsMachineWindowResizeIgnored = !fTrue; } 71 72 /* Public members: */ 73 virtual void normalizeGeometry(bool bAdjustPosition = false) = 0; 75 74 76 75 #if defined(Q_WS_MAC) … … 105 104 106 105 /* Protected getters: */ 107 UIMachineWindow* machineWindowWrapper() { return m_pMachineWindow; } 108 CConsole &console() { return m_console; } 109 110 /* Protected getters: */ 111 KMachineState machineState() const { return m_machineState; } 106 UISession* uisession() const; 107 CSession& session(); 108 UIMachineWindow* machineWindowWrapper() const { return m_pMachineWindow; } 112 109 VBoxDefs::RenderMode mode() const { return m_mode; } 113 110 QSize sizeHint() const; … … 119 116 int visibleHeight() const; 120 117 QRect desktopGeometry() const; 121 bool isGuestSupportsGraphics() const { return m_bIsGuestSupportsGraphics; }122 118 const QPixmap& pauseShot() const { return m_pauseShot; } 123 //bool isMouseAbsolute() const { return m_fIsMouseSupportsAbsolute; }124 119 125 120 /* Protected members: */ … … 138 133 139 134 /* Cleanup routines: */ 140 virtual void saveMachineViewSettings();141 virtual void cleanupConsoleConnections() {}142 virtual void cleanupFilters() {}135 //virtual void saveMachineViewSettings() {} 136 //virtual void cleanupConsoleConnections() {} 137 //virtual void cleanupFilters() {} 143 138 virtual void cleanupCommon(); 144 139 virtual void cleanupFrameBuffer(); 145 140 146 /* Update routines: */147 virtual void updateMachineState();148 virtual void updateAdditionsState();149 virtual void updateMousePointerShape();150 virtual void updateMouseCapability();151 152 141 protected slots: 153 142 154 143 /* Console callback handlers: */ 155 virtual void sltMachineStateChanged( KMachineState state);144 virtual void sltMachineStateChanged(); 156 145 virtual void sltAdditionsStateChanged(); 157 virtual void sltKeyboardLedsChanged(bool bNumLock, bool bCapsLock, bool bScrollLock); 158 virtual void sltMousePointerShapeChanged(bool fIsVisible, bool fHasAlpha, 159 uint uXHot, uint uYHot, uint uWidth, uint uHeight, 160 const uchar *pShapeData); 161 virtual void sltMouseCapabilityChanged(bool bIsSupportsAbsolute, bool bIsSupportsRelative, bool bNeedsHostCursor); 146 virtual void sltMousePointerShapeChanged(); 147 virtual void sltMouseCapabilityChanged(); 162 148 163 149 /* Initiate resize request to guest: */ … … 212 198 213 199 /* Private helpers: */ 214 void fixModifierState( LONG*piCodes, uint *puCount);200 void fixModifierState(int *piCodes, uint *puCount); 215 201 QPoint viewportToContents(const QPoint &vp) const; 216 202 void updateSliders(); … … 227 213 void sendChangedKeyStates(); 228 214 void updateMouseClipping(); 229 void setPointerShape(const uchar *pShapeData, bool fHasAlpha,230 uint uXHot, uint uYHot, uint uWidth, uint uHeight);231 232 /* Private getters: */233 bool isRunning() { return m_machineState == KMachineState_Running || m_machineState == KMachineState_Teleporting || m_machineState == KMachineState_LiveSnapshotting; }234 bool shouldHideHostPointer() const { return m_bIsMouseCaptured || (m_fIsMouseSupportsAbsolute && m_fIsHideHostPointer); }235 215 236 216 static void dimImage(QImage &img); … … 238 218 /* Private members: */ 239 219 UIMachineWindow *m_pMachineWindow; 240 CConsole m_console;241 220 VBoxDefs::RenderMode m_mode; 242 221 const VBoxGlobalSettings &m_globalSettings; 243 KMachineState m_machineState;244 222 UIFrameBuffer *m_pFrameBuffer; 245 223 246 QCursor m_lastCursor;247 #if defined(Q_WS_WIN)248 HCURSOR m_alphaCursor;249 #endif250 224 QPoint m_lastMousePos; 251 225 QPoint m_capturedMousePos; … … 255 229 uint8_t m_pressedKeysCopy[128]; 256 230 257 uint m_uNumLockAdaptionCnt;258 uint m_uCapsLockAdaptionCnt;259 260 231 bool m_bIsAutoCaptureDisabled : 1; 261 232 bool m_bIsKeyboardCaptured : 1; 262 bool m_bIsMouseCaptured : 1;263 bool m_fIsMouseSupportsAbsolute : 1;264 bool m_fIsMouseSupportsRelative : 1;265 bool m_bIsMouseIntegrated : 1;266 bool m_fIsHideHostPointer;267 233 bool m_bIsHostkeyPressed : 1; 268 234 bool m_bIsHostkeyAlone : 1; 269 235 bool m_bIsHostkeyInCapture : 1; 270 bool m_bIsGuestSupportsGraphics : 1;271 236 bool m_bIsMachineWindowResizeIgnored : 1; 272 237 bool m_bIsFrameBufferResizeIgnored : 1; 273 bool m_bIsGuestResizeIgnored : 1;274 bool m_fNumLock : 1;275 bool m_fCapsLock : 1;276 bool m_fScrollLock : 1;277 238 bool m_fPassCAD; 278 239 #ifdef VBOX_WITH_VIDEOHWACCEL -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp
r26800 r26815 27 27 28 28 /* Local includes */ 29 #include "COMDefs.h" 29 30 #include "VBoxGlobal.h" 30 31 #include "VBoxProblemReporter.h" … … 98 99 } 99 100 100 CSession UIMachineWindow::session() 101 { 102 return m_pMachineLogic->uisession()->session(); 101 UISession* UIMachineWindow::uisession() 102 { 103 return machineLogic()->uisession(); 104 } 105 106 CSession& UIMachineWindow::session() 107 { 108 return uisession()->session(); 103 109 } 104 110 … … 131 137 } 132 138 133 switch (machineLogic()->machineState()) 139 /* Get machine state: */ 140 KMachineState state = uisession()->machineState(); 141 142 switch (state) 134 143 { 135 144 case KMachineState_PoweredOff: … … 161 170 bool success = true; 162 171 163 bool wasPaused = machineLogic()->machineState() == KMachineState_Paused || 164 machineLogic()->machineState() == KMachineState_Stuck || 165 machineLogic()->machineState() == KMachineState_TeleportingPausedVM; 172 bool wasPaused = uisession()->isPaused() || state == KMachineState_Stuck; 166 173 if (!wasPaused) 167 174 { 168 175 /* Suspend the VM and ignore the close event if failed to do so. 169 176 * pause() will show the error message to the user. */ 170 success = machineLogic()->pause();177 success = uisession()->pause(); 171 178 } 172 179 … … 185 192 dlg.mCbDiscardCurState->setText(dlg.mCbDiscardCurState->text().arg(machine.GetCurrentSnapshot().GetName())); 186 193 187 if ( machineLogic()->machineState()!= KMachineState_Stuck)194 if (state != KMachineState_Stuck) 188 195 { 189 196 /* Read the last user's choice for the given VM */ … … 246 253 { 247 254 /* Unpause the VM to let it grab the ACPI shutdown event */ 248 machineLogic()->unpause();255 uisession()->unpause(); 249 256 /* Prevent the subsequent unpause request */ 250 257 wasPaused = true; … … 330 337 machineLogic()->setPreventAutoClose(false); 331 338 332 if ( machineLogic()->machineState()== KMachineState_PoweredOff ||333 machineLogic()->machineState()== KMachineState_Saved ||334 machineLogic()->machineState()== KMachineState_Teleported ||335 machineLogic()->machineState()== KMachineState_Aborted)339 if (state == KMachineState_PoweredOff || 340 state == KMachineState_Saved || 341 state == KMachineState_Teleported || 342 state == KMachineState_Aborted) 336 343 { 337 344 /* The machine has been stopped while showing the Close or the Pause … … 344 351 { 345 352 /* Restore the running state if needed */ 346 if (!wasPaused && machineLogic()->machineState()== KMachineState_Paused)347 machineLogic()->unpause();353 if (!wasPaused && state == KMachineState_Paused) 354 uisession()->unpause(); 348 355 } 349 356 } … … 393 400 { 394 401 /* Machine state-change updater: */ 395 QObject::connect(machineLogic()->uisession(), SIGNAL(sigStateChange(KMachineState)), 396 machineWindow(), SLOT(sltMachineStateChanged(KMachineState))); 402 QObject::connect(uisession(), SIGNAL(sigMachineStateChange()), machineWindow(), SLOT(sltMachineStateChanged())); 397 403 } 398 404 … … 460 466 #endif /* VBOX_WITH_DEBUGGER_GUI */ 461 467 462 void UIMachineWindow::loadWindowSettings()463 {464 #ifdef Q_WS_MAC465 QString testStr = vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_RealtimeDockIconUpdateEnabled).toLower();466 /* Default to true if it is an empty value */467 bool bIsDockIconEnabled = testStr.isEmpty() || testStr == "true";468 if (machineView())469 {470 machineView()->setDockIconEnabled(bIsDockIconEnabled);471 machineView()->updateDockOverlay();472 }473 #endif474 }475 476 468 void UIMachineWindow::updateAppearanceOf(int iElement) 477 469 { … … 480 472 if (iElement & UIVisualElement_WindowCaption) 481 473 { 474 /* Get machine state: */ 475 KMachineState state = uisession()->machineState(); 476 /* Prepare full name: */ 482 477 QString strSnapshotName; 483 478 if (machine.GetSnapshotCount() > 0) … … 487 482 } 488 483 QString strMachineName = machine.GetName() + strSnapshotName; 489 if ( machineLogic()->machineState()!= KMachineState_Null)490 strMachineName += " [" + vboxGlobal().toString( machineLogic()->machineState()) + "] - ";484 if (state != KMachineState_Null) 485 strMachineName += " [" + vboxGlobal().toString(state) + "] - "; 491 486 strMachineName += m_strWindowTitlePrefix; 492 487 machineWindow()->setWindowTitle(strMachineName); … … 497 492 } 498 493 499 void UIMachineWindow::sltMachineStateChanged( KMachineState /* machineState */)494 void UIMachineWindow::sltMachineStateChanged() 500 495 { 501 496 updateAppearanceOf(UIVisualElement_WindowCaption); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.h
r26800 r26815 25 25 26 26 /* Local includes */ 27 #include "COMDefs.h"28 27 #include "UIMachineDefs.h" 29 28 … … 33 32 34 33 /* Local forwards */ 34 class CSession; 35 class UISession; 35 36 class UIMachineLogic; 36 37 class UIMachineView; … … 58 59 virtual ~UIMachineWindow(); 59 60 61 /* Protected wrappers: */ 62 UISession* uisession(); 63 CSession& session(); 64 60 65 /* Protected getters: */ 61 CSession session();62 66 const QString& defaultWindowTitle() const { return m_strWindowTitlePrefix; } 63 67 … … 76 80 virtual void prepareMenuDebug(); 77 81 #endif 78 virtual void loadWindowSettings();82 //virtual void loadWindowSettings() {} 79 83 80 84 /* Cleanup helpers: */ … … 92 96 93 97 /* Protected slots: */ 94 v oid sltMachineStateChanged(KMachineState machineState);98 virtual void sltMachineStateChanged(); 95 99 96 100 /* Protected variables: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r26795 r26815 28 28 /* Local includes */ 29 29 #include "UISession.h" 30 31 30 #include "UIMachine.h" 31 #include "UIActionsPool.h" 32 32 #include "UIMachineLogic.h" 33 33 #include "UIMachineWindow.h" 34 35 #include "VBoxUtils.h" 34 #include "VBoxProblemReporter.h" 35 36 #ifdef Q_WS_X11 37 # include <QX11Info> 38 # ifndef VBOX_WITHOUT_XCURSOR 39 # include <X11/Xcursor/Xcursor.h> 40 # endif 41 #endif 42 43 #if defined (Q_WS_MAC) 44 # include "VBoxUtils.h" 45 #endif 36 46 37 47 /* Guest mouse pointer shape change event: */ … … 513 523 UISession::UISession(UIMachine *pMachine, const CSession &session) 514 524 : QObject(pMachine) 525 /* Base variables: */ 515 526 , m_pMachine(pMachine) 516 527 , m_session(session) 517 528 , m_pCallback(new UIConsoleCallback(this)) 518 529 , m_callback(CConsoleCallback(m_pCallback)) 530 /* Common varibles: */ 531 , m_machineState(KMachineState_Null) 532 /* Common flags: */ 533 , m_fIsFirstTimeStarted(false) 534 , m_fIsIgnoreRutimeMediumsChanging(false) 535 /* Guest additions flags: */ 536 , m_fIsGuestAdditionsActive(false) 537 , m_fIsGuestSupportsGraphics(false) 538 , m_fIsGuestSupportsSeamless(false) 539 /* Mouse flags: */ 540 , m_fNumLock(false) 541 , m_fCapsLock(false) 542 , m_fScrollLock(false) 543 , m_uNumLockAdaptionCnt(2) 544 , m_uCapsLockAdaptionCnt(2) 545 /* Mouse flags: */ 546 , m_fIsMouseSupportsAbsolute(false) 547 , m_fIsMouseSupportsRelative(false) 548 , m_fIsMouseHostCursorNeeded(false) 549 , m_fIsMouseCaptured(false) 550 , m_fIsMouseIntegrated(true) 551 , m_fIsHideHostPointer(true) 519 552 { 520 553 /* Check CSession object */ 521 AssertMsg(!m_session.isNull(), ("CSession is not set!\n"));554 AssertMsg(!m_session.isNull(), ("CSession should not be NULL!\n")); 522 555 523 556 /* Register console callback: */ 524 557 m_session.GetConsole().RegisterCallback(m_callback); 558 559 /* Load session settings: */ 560 loadSessionSettings(); 525 561 } 526 562 527 563 UISession::~UISession() 528 564 { 565 /* Save session settings: */ 566 saveSessionSettings(); 567 529 568 /* Unregister console callback: */ 530 569 m_session.GetConsole().UnregisterCallback(m_callback); … … 533 572 } 534 573 574 bool UISession::setPause(bool fOn) 575 { 576 if (isPaused() == fOn) 577 return true; 578 579 CConsole console = session().GetConsole(); 580 581 if (fOn) 582 console.Pause(); 583 else 584 console.Resume(); 585 586 bool ok = console.isOk(); 587 if (!ok) 588 { 589 if (fOn) 590 vboxProblem().cannotPauseMachine(console); 591 else 592 vboxProblem().cannotResumeMachine(console); 593 } 594 595 return ok; 596 } 597 535 598 bool UISession::event(QEvent *pEvent) 536 599 { … … 539 602 case UIConsoleEventType_MousePointerShapeChange: 540 603 { 604 /* Convert to mouse shape change event: */ 541 605 UIMousePointerShapeChangeEvent *pConsoleEvent = static_cast<UIMousePointerShapeChangeEvent*>(pEvent); 542 emit sigMousePointerShapeChange(pConsoleEvent->isVisible(), pConsoleEvent->hasAlpha(), 543 pConsoleEvent->xHot(), pConsoleEvent->yHot(), 544 pConsoleEvent->width(), pConsoleEvent->height(), 545 pConsoleEvent->shapeData()); 606 607 /* Remember if we should show cursor: */ 608 m_fIsHideHostPointer = !pConsoleEvent->isVisible(); 609 610 /* Cache shape dataif present: */ 611 if (pConsoleEvent->shapeData()) 612 setPointerShape(pConsoleEvent->shapeData(), pConsoleEvent->hasAlpha(), 613 pConsoleEvent->xHot(), pConsoleEvent->yHot(), 614 pConsoleEvent->width(), pConsoleEvent->height()); 615 616 /* Notify listeners about mouse capability changed: */ 617 emit sigMousePointerShapeChange(); 618 619 /* Accept event: */ 620 pEvent->accept(); 546 621 return true; 547 622 } … … 549 624 case UIConsoleEventType_MouseCapabilityChange: 550 625 { 626 /* Convert to mouse capability event: */ 551 627 UIMouseCapabilityChangeEvent *pConsoleEvent = static_cast<UIMouseCapabilityChangeEvent*>(pEvent); 552 emit sigMouseCapabilityChange(pConsoleEvent->supportsAbsolute(), pConsoleEvent->supportsRelative(), pConsoleEvent->needsHostCursor()); 628 629 /* Check if something had changed: */ 630 if (m_fIsMouseSupportsAbsolute != pConsoleEvent->supportsAbsolute() || 631 m_fIsMouseSupportsRelative != pConsoleEvent->supportsRelative() || 632 m_fIsMouseHostCursorNeeded != pConsoleEvent->needsHostCursor()) 633 { 634 /* Store new data: */ 635 m_fIsMouseSupportsAbsolute = pConsoleEvent->supportsAbsolute(); 636 m_fIsMouseSupportsRelative = pConsoleEvent->supportsRelative(); 637 m_fIsMouseHostCursorNeeded = pConsoleEvent->needsHostCursor(); 638 639 /* Notify listeners about mouse capability changed: */ 640 emit sigMouseCapabilityChange(); 641 } 642 643 /* Accept event: */ 644 pEvent->accept(); 553 645 return true; 554 646 } … … 556 648 case UIConsoleEventType_KeyboardLedsChange: 557 649 { 650 /* Convert to keyboard LEDs change event: */ 558 651 UIKeyboardLedsChangeEvent *pConsoleEvent = static_cast<UIKeyboardLedsChangeEvent*>(pEvent); 559 emit sigKeyboardLedsChange(pConsoleEvent->numLock(), pConsoleEvent->capsLock(), pConsoleEvent->scrollLock()); 652 653 /* Check if something had changed: */ 654 if (m_fNumLock != pConsoleEvent->numLock() || 655 m_fCapsLock != pConsoleEvent->capsLock() || 656 m_fScrollLock != pConsoleEvent->scrollLock()) 657 { 658 /* Store new num lock data: */ 659 if (m_fNumLock != pConsoleEvent->numLock()) 660 { 661 m_fNumLock = pConsoleEvent->numLock(); 662 m_uNumLockAdaptionCnt = 2; 663 } 664 665 /* Store new caps lock data: */ 666 if (m_fCapsLock != pConsoleEvent->capsLock()) 667 { 668 m_fCapsLock = pConsoleEvent->capsLock(); 669 m_uCapsLockAdaptionCnt = 2; 670 } 671 672 /* Store new scroll lock data: */ 673 if (m_fScrollLock != pConsoleEvent->scrollLock()) 674 { 675 m_fScrollLock = pConsoleEvent->scrollLock(); 676 } 677 678 /* Notify listeners about mouse capability changed: */ 679 emit sigKeyboardLedsChange(); 680 } 681 682 /* Accept event: */ 683 pEvent->accept(); 560 684 return true; 561 685 } … … 563 687 case UIConsoleEventType_StateChange: 564 688 { 689 /* Convert to machine state event: */ 565 690 UIStateChangeEvent *pConsoleEvent = static_cast<UIStateChangeEvent*>(pEvent); 566 emit sigStateChange(pConsoleEvent->machineState()); 691 692 /* Check if something had changed: */ 693 if (m_machineState != pConsoleEvent->machineState()) 694 { 695 /* Store new data: */ 696 m_machineState = pConsoleEvent->machineState(); 697 698 /* Notify listeners about machine state changed: */ 699 emit sigMachineStateChange(); 700 } 701 702 /* Accept event: */ 703 pEvent->accept(); 567 704 return true; 568 705 } … … 570 707 case UIConsoleEventType_AdditionsStateChange: 571 708 { 572 emit sigAdditionsStateChange(); 709 /* Get our guest: */ 710 CGuest guest = session().GetConsole().GetGuest(); 711 712 /* Variable flags: */ 713 bool fIsGuestAdditionsActive = guest.GetAdditionsActive(); 714 bool fIsGuestSupportsGraphics = guest.GetSupportsGraphics(); 715 bool fIsGuestSupportsSeamless = guest.GetSupportsSeamless(); 716 717 /* Check if something had changed: */ 718 if (m_fIsGuestAdditionsActive != fIsGuestAdditionsActive || 719 m_fIsGuestSupportsGraphics != fIsGuestSupportsGraphics || 720 m_fIsGuestSupportsSeamless != fIsGuestSupportsSeamless) 721 { 722 /* Store new data: */ 723 m_fIsGuestAdditionsActive = fIsGuestAdditionsActive; 724 m_fIsGuestSupportsGraphics = fIsGuestSupportsGraphics; 725 m_fIsGuestSupportsSeamless = fIsGuestSupportsSeamless; 726 727 /* Notify listeners about guest additions state changed: */ 728 emit sigAdditionsStateChange(); 729 } 730 731 /* Accept event: */ 732 pEvent->accept(); 573 733 return true; 574 734 } … … 679 839 } 680 840 841 void UISession::loadSessionSettings() 842 { 843 /* Get machine: */ 844 CMachine machine = session().GetConsole().GetMachine(); 845 846 /* Availability settings: */ 847 { 848 /* USB Stuff: */ 849 CUSBController usbController = machine.GetUSBController(); 850 if (usbController.isNull()) 851 { 852 /* Hide USB menu if controller is NULL: */ 853 uimachine()->actionsPool()->action(UIActionIndex_Menu_USBDevices)->setVisible(false); 854 } 855 else 856 { 857 /* Enable/Disable USB menu depending on USB controller: */ 858 uimachine()->actionsPool()->action(UIActionIndex_Menu_USBDevices)->setEnabled(usbController.GetEnabled()); 859 } 860 861 /* VRDP Stuff: */ 862 CVRDPServer vrdpServer = machine.GetVRDPServer(); 863 if (vrdpServer.isNull()) 864 { 865 /* Hide VRDP Action: */ 866 uimachine()->actionsPool()->action(UIActionIndex_Toggle_VRDP)->setVisible(false); 867 } 868 } 869 870 /* Prepare some initial settings: */ 871 { 872 /* Initialize CD/FD menus: */ 873 int iDevicesCountCD = 0; 874 int iDevicesCountFD = 0; 875 const CMediumAttachmentVector &attachments = machine.GetMediumAttachments(); 876 foreach (const CMediumAttachment &attachment, attachments) 877 { 878 if (attachment.GetType() == KDeviceType_DVD) 879 ++ iDevicesCountCD; 880 if (attachment.GetType() == KDeviceType_Floppy) 881 ++ iDevicesCountFD; 882 } 883 QAction *pOpticalDevicesMenu = uimachine()->actionsPool()->action(UIActionIndex_Menu_OpticalDevices); 884 QAction *pFloppyDevicesMenu = uimachine()->actionsPool()->action(UIActionIndex_Menu_FloppyDevices); 885 pOpticalDevicesMenu->setData(iDevicesCountCD); 886 pOpticalDevicesMenu->setVisible(iDevicesCountCD); 887 pFloppyDevicesMenu->setData(iDevicesCountFD); 888 pFloppyDevicesMenu->setVisible(iDevicesCountFD); 889 } 890 891 /* Load extra-data settings: */ 892 { 893 /* Temporary: */ 894 QString strSettings; 895 896 /* Is there shoul be First RUN Wizard? */ 897 strSettings = machine.GetExtraData(VBoxDefs::GUI_FirstRun); 898 if (strSettings == "yes") 899 m_fIsFirstTimeStarted = true; 900 901 /* Ignore mediums mounted at runtime? */ 902 strSettings = machine.GetExtraData(VBoxDefs::GUI_SaveMountedAtRuntime); 903 if (strSettings == "no") 904 m_fIsIgnoreRutimeMediumsChanging = true; 905 906 /* Should guest autoresize? */ 907 strSettings = machine.GetExtraData(VBoxDefs::GUI_AutoresizeGuest); 908 QAction *pGuestAutoresizeSwitch = uimachine()->actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize); 909 pGuestAutoresizeSwitch->blockSignals(true); 910 pGuestAutoresizeSwitch->setChecked(strSettings != "off"); 911 pGuestAutoresizeSwitch->blockSignals(false); 912 } 913 } 914 915 void UISession::saveSessionSettings() 916 { 917 /* Get session machine: */ 918 CMachine machine = session().GetConsole().GetMachine(); 919 920 /* Save extra-data settings: */ 921 { 922 /* Disable First RUN Wizard for the since now: */ 923 machine.SetExtraData(VBoxDefs::GUI_FirstRun, QString()); 924 925 /* Remember if guest should autoresize: */ 926 machine.SetExtraData(VBoxDefs::GUI_AutoresizeGuest, 927 uimachine()->actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize)->isChecked() ? 928 QString() : "off"); 929 930 // TODO: Move to fullscreen/seamless logic: 931 //machine.SetExtraData(VBoxDefs::GUI_MiniToolBarAutoHide, mMiniToolBar->isAutoHide() ? "on" : "off"); 932 } 933 } 934 681 935 qulonglong UISession::winId() const 682 936 { 683 return machine()->machineLogic()->machineWindowWrapper()->machineWindow()->winId();937 return uimachine()->machineLogic()->machineWindowWrapper()->machineWindow()->winId(); 684 938 } 685 939 940 void UISession::setPointerShape(const uchar *pShapeData, bool fHasAlpha, 941 uint uXHot, uint uYHot, uint uWidth, uint uHeight) 942 { 943 AssertMsg(pShapeData, ("Shape data must not be NULL!\n")); 944 945 const uchar *srcAndMaskPtr = pShapeData; 946 uint andMaskSize = (uWidth + 7) / 8 * uHeight; 947 const uchar *srcShapePtr = pShapeData + ((andMaskSize + 3) & ~3); 948 uint srcShapePtrScan = uWidth * 4; 949 950 #if defined (Q_WS_WIN) 951 952 BITMAPV5HEADER bi; 953 HBITMAP hBitmap; 954 void *lpBits; 955 956 ::ZeroMemory(&bi, sizeof (BITMAPV5HEADER)); 957 bi.bV5Size = sizeof(BITMAPV5HEADER); 958 bi.bV5Width = uWidth; 959 bi.bV5Height = - (LONG)uHeight; 960 bi.bV5Planes = 1; 961 bi.bV5BitCount = 32; 962 bi.bV5Compression = BI_BITFIELDS; 963 bi.bV5RedMask = 0x00FF0000; 964 bi.bV5GreenMask = 0x0000FF00; 965 bi.bV5BlueMask = 0x000000FF; 966 if (fHasAlpha) 967 bi.bV5AlphaMask = 0xFF000000; 968 else 969 bi.bV5AlphaMask = 0; 970 971 HDC hdc = GetDC(NULL); 972 973 /* Create the DIB section with an alpha channel: */ 974 hBitmap = CreateDIBSection(hdc, (BITMAPINFO *)&bi, DIB_RGB_COLORS, (void **)&lpBits, NULL, (DWORD) 0); 975 976 ReleaseDC(NULL, hdc); 977 978 HBITMAP hMonoBitmap = NULL; 979 if (fHasAlpha) 980 { 981 /* Create an empty mask bitmap: */ 982 hMonoBitmap = CreateBitmap(uWidth, uHeight, 1, 1, NULL); 983 } 984 else 985 { 986 /* Word aligned AND mask. Will be allocated and created if necessary. */ 987 uint8_t *pu8AndMaskWordAligned = NULL; 988 989 /* Width in bytes of the original AND mask scan line. */ 990 uint32_t cbAndMaskScan = (uWidth + 7) / 8; 991 992 if (cbAndMaskScan & 1) 993 { 994 /* Original AND mask is not word aligned. */ 995 996 /* Allocate memory for aligned AND mask. */ 997 pu8AndMaskWordAligned = (uint8_t *)RTMemTmpAllocZ((cbAndMaskScan + 1) * uHeight); 998 999 Assert(pu8AndMaskWordAligned); 1000 1001 if (pu8AndMaskWordAligned) 1002 { 1003 /* According to MSDN the padding bits must be 0. 1004 * Compute the bit mask to set padding bits to 0 in the last byte of original AND mask. */ 1005 uint32_t u32PaddingBits = cbAndMaskScan * 8 - uWidth; 1006 Assert(u32PaddingBits < 8); 1007 uint8_t u8LastBytesPaddingMask = (uint8_t)(0xFF << u32PaddingBits); 1008 1009 Log(("u8LastBytesPaddingMask = %02X, aligned w = %d, width = %d, cbAndMaskScan = %d\n", 1010 u8LastBytesPaddingMask, (cbAndMaskScan + 1) * 8, uWidth, cbAndMaskScan)); 1011 1012 uint8_t *src = (uint8_t *)srcAndMaskPtr; 1013 uint8_t *dst = pu8AndMaskWordAligned; 1014 1015 unsigned i; 1016 for (i = 0; i < uHeight; i++) 1017 { 1018 memcpy(dst, src, cbAndMaskScan); 1019 1020 dst[cbAndMaskScan - 1] &= u8LastBytesPaddingMask; 1021 1022 src += cbAndMaskScan; 1023 dst += cbAndMaskScan + 1; 1024 } 1025 } 1026 } 1027 1028 /* Create the AND mask bitmap: */ 1029 hMonoBitmap = ::CreateBitmap(uWidth, uHeight, 1, 1, 1030 pu8AndMaskWordAligned? pu8AndMaskWordAligned: srcAndMaskPtr); 1031 1032 if (pu8AndMaskWordAligned) 1033 { 1034 RTMemTmpFree(pu8AndMaskWordAligned); 1035 } 1036 } 1037 1038 Assert(hBitmap); 1039 Assert(hMonoBitmap); 1040 if (hBitmap && hMonoBitmap) 1041 { 1042 DWORD *dstShapePtr = (DWORD *) lpBits; 1043 1044 for (uint y = 0; y < uHeight; y ++) 1045 { 1046 memcpy(dstShapePtr, srcShapePtr, srcShapePtrScan); 1047 srcShapePtr += srcShapePtrScan; 1048 dstShapePtr += uWidth; 1049 } 1050 1051 ICONINFO ii; 1052 ii.fIcon = FALSE; 1053 ii.xHotspot = uXHot; 1054 ii.yHotspot = uYHot; 1055 ii.hbmMask = hMonoBitmap; 1056 ii.hbmColor = hBitmap; 1057 1058 HCURSOR hAlphaCursor = CreateIconIndirect(&ii); 1059 Assert(hAlphaCursor); 1060 if (hAlphaCursor) 1061 { 1062 /* Set the new cursor: */ 1063 m_cursor = QCursor(hAlphaCursor); 1064 if (m_alphaCursor) 1065 DestroyIcon(m_alphaCursor); 1066 m_alphaCursor = hAlphaCursor; 1067 } 1068 } 1069 1070 if (hMonoBitmap) 1071 DeleteObject(hMonoBitmap); 1072 if (hBitmap) 1073 DeleteObject(hBitmap); 1074 1075 #elif defined (Q_WS_X11) && !defined (VBOX_WITHOUT_XCURSOR) 1076 1077 XcursorImage *img = XcursorImageCreate(uWidth, uHeight); 1078 Assert(img); 1079 if (img) 1080 { 1081 img->xhot = uXHot; 1082 img->yhot = uYHot; 1083 1084 XcursorPixel *dstShapePtr = img->pixels; 1085 1086 for (uint y = 0; y < uHeight; y ++) 1087 { 1088 memcpy (dstShapePtr, srcShapePtr, srcShapePtrScan); 1089 1090 if (!fHasAlpha) 1091 { 1092 /* Convert AND mask to the alpha channel: */ 1093 uchar byte = 0; 1094 for (uint x = 0; x < uWidth; x ++) 1095 { 1096 if (!(x % 8)) 1097 byte = *(srcAndMaskPtr ++); 1098 else 1099 byte <<= 1; 1100 1101 if (byte & 0x80) 1102 { 1103 /* Linux doesn't support inverted pixels (XOR ops, 1104 * to be exact) in cursor shapes, so we detect such 1105 * pixels and always replace them with black ones to 1106 * make them visible at least over light colors */ 1107 if (dstShapePtr [x] & 0x00FFFFFF) 1108 dstShapePtr [x] = 0xFF000000; 1109 else 1110 dstShapePtr [x] = 0x00000000; 1111 } 1112 else 1113 dstShapePtr [x] |= 0xFF000000; 1114 } 1115 } 1116 1117 srcShapePtr += srcShapePtrScan; 1118 dstShapePtr += uWidth; 1119 } 1120 1121 /* Set the new cursor: */ 1122 m_cursor = QCursor(XcursorImageLoadCursor(QX11Info::display(), img)); 1123 1124 XcursorImageDestroy(img); 1125 } 1126 1127 #elif defined(Q_WS_MAC) 1128 1129 /* Create a ARGB image out of the shape data. */ 1130 QImage image (uWidth, uHeight, QImage::Format_ARGB32); 1131 const uint8_t* pbSrcMask = static_cast<const uint8_t*> (srcAndMaskPtr); 1132 unsigned cbSrcMaskLine = RT_ALIGN (uWidth, 8) / 8; 1133 for (unsigned int y = 0; y < uHeight; ++y) 1134 { 1135 for (unsigned int x = 0; x < uWidth; ++x) 1136 { 1137 unsigned int color = ((unsigned int*)srcShapePtr)[y*uWidth+x]; 1138 /* If the alpha channel isn't in the shape data, we have to 1139 * create them from the and-mask. This is a bit field where 1 1140 * represent transparency & 0 opaque respectively. */ 1141 if (!fHasAlpha) 1142 { 1143 if (!(pbSrcMask[x / 8] & (1 << (7 - (x % 8))))) 1144 color |= 0xff000000; 1145 else 1146 { 1147 /* This isn't quite right, but it's the best we can do I think... */ 1148 if (color & 0x00ffffff) 1149 color = 0xff000000; 1150 else 1151 color = 0x00000000; 1152 } 1153 } 1154 image.setPixel (x, y, color); 1155 } 1156 /* Move one scanline forward. */ 1157 pbSrcMask += cbSrcMaskLine; 1158 } 1159 1160 /* Set the new cursor: */ 1161 m_cursor = cursor(QPixmap::fromImage(image), uXHot, uYHot); 1162 NOREF(srcShapePtrScan); 1163 1164 #else 1165 1166 # warning "port me" 1167 1168 #endif 1169 } 1170 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
r26795 r26815 26 26 /* Global includes */ 27 27 #include <QObject> 28 #include <QCursor> 28 29 29 30 /* Local includes */ … … 69 70 virtual ~UISession(); 70 71 71 /* Publicgetters: */72 /* Common getters: */ 72 73 CSession& session() { return m_session; } 74 KMachineState machineState() const { return m_machineState; } 75 bool isSaved() const { return machineState() == KMachineState_Saved; } 76 bool isTurnedOff() const { return machineState() == KMachineState_PoweredOff || 77 machineState() == KMachineState_Saved || 78 machineState() == KMachineState_Teleported || 79 machineState() == KMachineState_Aborted; } 80 bool isPaused() const { return machineState() == KMachineState_Paused || 81 machineState() == KMachineState_TeleportingPausedVM; } 82 bool isRunning() const { return machineState() == KMachineState_Running || 83 machineState() == KMachineState_Teleporting || 84 machineState() == KMachineState_LiveSnapshotting; } 85 bool isFirstTimeStarted() const { return m_fIsFirstTimeStarted; } 86 bool isIgnoreRuntimeMediumsChanging() const { return m_fIsIgnoreRutimeMediumsChanging; } 87 bool isGuestResizeIgnored() const { return m_fIsGuestResizeIgnored; } 88 QCursor cursor() const { return m_cursor; } 89 90 /* Guest additions state getters: */ 91 bool isGuestAdditionsActive() const { return m_fIsGuestAdditionsActive; } 92 bool isGuestSupportsGraphics() const { return m_fIsGuestSupportsGraphics; } 93 bool isGuestSupportsSeamless() const { return m_fIsGuestSupportsSeamless; } 94 95 /* Keyboard getters: */ 96 bool isNumLock() const { return m_fNumLock; } 97 bool isCapsLock() const { return m_fCapsLock; } 98 bool isScrollLock() const { return m_fScrollLock; } 99 uint numLockAdaptionCnt() const { return m_uNumLockAdaptionCnt; } 100 uint capsLockAdaptionCnt() const { return m_uCapsLockAdaptionCnt; } 101 102 /* Mouse getters: */ 103 bool isMouseSupportsAbsolute() const { return m_fIsMouseSupportsAbsolute; } 104 bool isMouseSupportsRelative() const { return m_fIsMouseSupportsRelative; } 105 bool isMouseHostCursorNeeded() const { return m_fIsMouseHostCursorNeeded; } 106 bool isMouseCaptured() const { return m_fIsMouseCaptured; } 107 bool isMouseIntegrated() const { return m_fIsMouseIntegrated; } 108 bool isHidingHostPointer() const { return m_fIsMouseCaptured || (m_fIsMouseSupportsAbsolute && m_fIsHideHostPointer); } 109 110 /* Common setters: */ 111 bool pause() { return setPause(true); } 112 bool unpause() { return setPause(false); } 113 bool setPause(bool fOn); 114 void setGuestResizeIgnored(bool fIsGuestResizeIgnored) { m_fIsGuestResizeIgnored = fIsGuestResizeIgnored; } 115 116 /* Keyboard setters: */ 117 void setNumLockAdaptionCnt(uint uNumLockAdaptionCnt) { m_uNumLockAdaptionCnt = uNumLockAdaptionCnt; } 118 void setCapsLockAdaptionCnt(uint uCapsLockAdaptionCnt) { m_uCapsLockAdaptionCnt = uCapsLockAdaptionCnt; } 119 120 /* Mouse setters: */ 121 void setMouseCaptured(bool fIsMouseCaptured) { m_fIsMouseCaptured = fIsMouseCaptured; } 122 void setMouseIntegrated(bool fIsMouseIntegrated) { m_fIsMouseIntegrated = fIsMouseIntegrated; } 73 123 74 124 signals: 75 125 76 /* Console signals: */77 void sigMousePointerShapeChange( bool bIsVisible, bool bHasAlpha, uint uXHot, uint uYHot, uint uWidth, uint uHeight, const uchar *pShapeData);78 void sigMouseCapabilityChange( bool bIsSupportsAbsolute, bool bIsSupportsRelative, bool bNeedsHostCursor);79 void sigKeyboardLedsChange( bool bNumLock, bool bCapsLock, bool bScrollLock);80 void sig StateChange(KMachineState machineState);126 /* Console callback signals: */ 127 void sigMousePointerShapeChange(); 128 void sigMouseCapabilityChange(); 129 void sigKeyboardLedsChange(); 130 void sigMachineStateChange(); 81 131 void sigAdditionsStateChange(); 82 132 void sigNetworkAdapterChange(const CNetworkAdapter &networkAdapter); … … 96 146 97 147 /* Private getters: */ 98 UIMachine* machine() const { return m_pMachine; }148 UIMachine* uimachine() const { return m_pMachine; } 99 149 100 150 /* Event handlers: */ 101 151 bool event(QEvent *pEvent); 102 152 103 /* Helper routines: */ 153 /* Prepare helpers: */ 154 void loadSessionSettings(); 155 156 /* Cleanup helpers: */ 157 void saveSessionSettings(); 158 159 /* Common helpers: */ 104 160 qulonglong winId() const; 161 void setPointerShape(const uchar *pShapeData, bool fHasAlpha, uint uXHot, uint uYHot, uint uWidth, uint uHeight); 105 162 106 163 /* Private variables: */ … … 110 167 const CConsoleCallback &m_callback; 111 168 169 /* Common variables: */ 170 KMachineState m_machineState; 171 QCursor m_cursor; 172 #if defined(Q_WS_WIN) 173 HCURSOR m_alphaCursor; 174 #endif 175 176 /* Common flags: */ 177 bool m_fIsFirstTimeStarted : 1; 178 bool m_fIsIgnoreRutimeMediumsChanging : 1; 179 bool m_fIsGuestResizeIgnored : 1; 180 181 /* Guest additions flags: */ 182 bool m_fIsGuestAdditionsActive : 1; 183 bool m_fIsGuestSupportsGraphics : 1; 184 bool m_fIsGuestSupportsSeamless : 1; 185 186 /* Keyboard flags: */ 187 bool m_fNumLock : 1; 188 bool m_fCapsLock : 1; 189 bool m_fScrollLock : 1; 190 uint m_uNumLockAdaptionCnt; 191 uint m_uCapsLockAdaptionCnt; 192 193 /* Mouse flags: */ 194 bool m_fIsMouseSupportsAbsolute : 1; 195 bool m_fIsMouseSupportsRelative : 1; 196 bool m_fIsMouseHostCursorNeeded : 1; 197 bool m_fIsMouseCaptured : 1; 198 bool m_fIsMouseIntegrated : 1; 199 bool m_fIsHideHostPointer : 1; 200 112 201 /* Friend classes: */ 113 202 friend class UIConsoleCallback; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.cpp
r26773 r26815 27 27 28 28 /* Local includes */ 29 #include "COMDefs.h" 29 30 #include "VBoxGlobal.h" 30 31 #include "VBoxProblemReporter.h" … … 55 56 prepareRequiredFeatures(); 56 57 57 /* Load common logic settings: */58 loadLogicSettings();59 60 58 /* Prepare normal machine window: */ 61 59 prepareMachineWindow(); 60 61 /* Initialization: */ 62 sltMachineStateChanged(); 63 sltAdditionsStateChanged(); 64 sltMouseCapabilityChanged(); 62 65 } 63 66 … … 66 69 /* Cleanup normal machine window: */ 67 70 cleanupMachineWindow(); 68 69 /* Save common logic settings: */70 saveLogicSettings();71 71 } 72 72 … … 97 97 void UIMachineLogicNormal::prepareActionConnections() 98 98 { 99 /* Base -class connections: */99 /* Base class connections: */ 100 100 UIMachineLogic::prepareActionConnections(); 101 101 … … 124 124 setMachineWindowWrapper(UIMachineWindow::create(this, visualStateType())); 125 125 126 bool bIsSaved = machineState() == KMachineState_Saved;127 bool bIsRunning = machineState() == KMachineState_Running ||128 machineState() == KMachineState_Teleporting ||129 machineState() == KMachineState_LiveSnapshotting;130 bool bIsRunningOrPaused = bIsRunning ||131 machineState() == KMachineState_Paused;132 133 126 /* If we are not started yet: */ 134 if (! bIsRunningOrPaused)127 if (!uisession()->isRunning() && !uisession()->isPaused()) 135 128 { 136 129 /* Get current machine/console: */ … … 143 136 144 137 /* Shows first run wizard if necessary: */ 145 if ( isFirstTimeStarted())138 if (uisession()->isFirstTimeStarted()) 146 139 { 147 140 UIFirstRunWzd wzd(machineWindowWrapper()->machineWindow(), machine); … … 160 153 } 161 154 162 /* Disable auto 155 /* Disable auto-closure because we want to have a chance to show the error dialog on startup failure: */ 163 156 setPreventAutoClose(true); 164 157 165 158 /* Show "Starting/Restoring" progress dialog: */ 166 if ( bIsSaved)159 if (uisession()->isSaved()) 167 160 vboxProblem().showModalProgressDialog(progress, machine.GetName(), machineWindowWrapper()->machineWindow(), 0); 168 161 else … … 180 173 qApp->processEvents(); 181 174 182 /* Enable auto 175 /* Enable auto-closure again: */ 183 176 setPreventAutoClose(false); 184 177 185 178 /* Check if we missed a really quick termination after successful startup, and process it if we did: */ 186 if (machineState() == KMachineState_PoweredOff || machineState() == KMachineState_Saved || 187 machineState() == KMachineState_Teleported || machineState() == KMachineState_Aborted) 179 if (uisession()->isTurnedOff()) 188 180 { 189 181 machineWindowWrapper()->machineWindow()->close(); … … 216 208 #ifdef VBOX_WITH_UPDATE_REQUEST 217 209 /* Check for updates if necessary: */ 218 vboxGlobal().showUpdateDialog(false /* aForce*/);210 vboxGlobal().showUpdateDialog(false /* force request? */); 219 211 #endif 220 212 } … … 227 219 return; 228 220 229 /* Cleanup machine window: */221 /* Cleanup normal machine window: */ 230 222 UIMachineWindow::destroy(machineWindowWrapper()); 231 223 setMachineWindowWrapper(0); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp
r26773 r26815 30 30 /* Local includes */ 31 31 #include "VBoxGlobal.h" 32 #include "UISession.h" 32 33 #include "UIActionsPool.h" 33 34 #include "UIMachineLogic.h" … … 62 63 /* Load machine view settings: */ 63 64 loadMachineViewSettings(); 65 66 /* Initialization: */ 67 sltMachineStateChanged(); 68 sltAdditionsStateChanged(); 69 sltMousePointerShapeChanged(); 70 sltMouseCapabilityChanged(); 64 71 } 65 72 … … 114 121 115 122 /* Enable/Disable guest auto-resizing depending on advanced graphics availablability: */ 116 setGuestAutoresizeEnabled( isGuestSupportsGraphics() && m_bIsGuestAutoresizeEnabled);123 setGuestAutoresizeEnabled(m_bIsGuestAutoresizeEnabled && uisession()->isGuestSupportsGraphics()); 117 124 } 118 125 … … 134 141 maybeRestrictMinimumSize(); 135 142 136 if ( isGuestSupportsGraphics() && m_bIsGuestAutoresizeEnabled)143 if (uisession()->isGuestSupportsGraphics() && m_bIsGuestAutoresizeEnabled) 137 144 sltPerformGuestResize(); 138 145 } … … 195 202 if (mode() == VBoxDefs::SDLMode) 196 203 { 197 if (! isGuestSupportsGraphics() || !m_bIsGuestAutoresizeEnabled)204 if (!uisession()->isGuestSupportsGraphics() || !m_bIsGuestAutoresizeEnabled) 198 205 setMinimumSize(sizeHint()); 199 206 else -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp
r26800 r26815 31 31 #include "VBoxGlobal.h" 32 32 33 #include "VBoxVMInformationDlg.h"34 35 33 #include "UISession.h" 36 34 #include "UIActionsPool.h" … … 68 66 prepareConnections(); 69 67 68 /* Retranslate normal window finally: */ 69 retranslateUi(); 70 71 /* Prepare normal machine view: */ 72 prepareMachineView(); 73 70 74 /* Load normal window settings: */ 71 75 loadWindowSettings(); 72 76 73 /* Retranslate normal window finally: */74 retranslateUi();75 76 /* Prepare normal machine view: */77 prepareMachineView();78 79 77 /* Update all the elements: */ 80 78 updateAppearanceOf(UIVisualElement_AllStuff); … … 93 91 } 94 92 95 void UIMachineWindowNormal::sltMachineStateChanged( KMachineState machineState)96 { 97 UIMachineWindow::sltMachineStateChanged( machineState);93 void UIMachineWindowNormal::sltMachineStateChanged() 94 { 95 UIMachineWindow::sltMachineStateChanged(); 98 96 } 99 97 … … 477 475 void UIMachineWindowNormal::loadWindowSettings() 478 476 { 479 /* Load parent class settings: */ 480 UIMachineWindow::loadWindowSettings(); 481 482 /* Load this class settings: */ 477 /* Load normal window settings: */ 483 478 CMachine machine = session().GetMachine(); 484 479 485 /* Extra-data settings*/480 /* Load extra-data settings: */ 486 481 { 487 482 QString strPositionSettings = machine.GetExtraData(VBoxDefs::GUI_LastWindowPosition); … … 511 506 machineView()->normalizeGeometry(true /* adjust position? */); 512 507 513 /* Maximize if needed */508 /* Maximize if needed: */ 514 509 if (max) 515 510 setWindowState(windowState() | Qt::WindowMaximized); … … 528 523 } 529 524 530 /* Availability settings*/525 /* Load availability settings: */ 531 526 { 532 527 /* USB Stuff: */ … … 545 540 } 546 541 547 /* Global settings*/542 /* Load global settings: */ 548 543 { 549 544 VBoxGlobalSettings settings = vboxGlobal().settings(); … … 557 552 CMachine machine = session().GetMachine(); 558 553 559 /* Extra-data settings*/554 /* Save extra-data settings: */ 560 555 { 561 556 QString strWindowPosition = QString("%1,%2,%3,%4") -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.h
r26800 r26815 37 37 38 38 /* Local forwards */ 39 class CMediumAttachment; 39 40 class UIIndicatorsPool; 40 41 class QIStateIndicator; … … 53 54 54 55 /* Console callback handlers: */ 55 void sltMachineStateChanged( KMachineState machineState);56 void sltMachineStateChanged(); 56 57 void sltMediumChange(const CMediumAttachment &attachment); 57 58 void sltUSBControllerChange();
Note:
See TracChangeset
for help on using the changeset viewer.