Changeset 88680 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Apr 23, 2021 2:53:29 PM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r88678 r88680 256 256 257 257 /* Warn listeners about we are initialized: */ 258 m_fInitialized = true; 258 259 emit sigInitialized(); 259 260 … … 594 595 { 595 596 /* Cleanup everything COM related: */ 597 cleanupFramebuffers(); 596 598 cleanupConsoleEventHandlers(); 597 cleanupFramebuffers();598 599 cleanupSession(); 599 600 } … … 960 961 , m_machineState(KMachineState_Null) 961 962 , m_pMachineWindowIcon(0) 962 #ifdef VBOX_WS_WIN963 , m_alphaCursor(0)964 #endif /* VBOX_WS_WIN */965 963 #ifdef VBOX_WS_MAC 966 964 , m_pWatchdogDisplayChange(0) … … 1009 1007 bool UISession::prepare() 1010 1008 { 1011 /* Prepare session: */1009 /* Prepare COM stuff: */ 1012 1010 if (!prepareSession()) 1013 1011 return false; 1014 1015 /* Prepare actions: */ 1012 prepareConsoleEventHandlers(); 1013 prepareFramebuffers(); 1014 1015 /* Prepare GUI stuff: */ 1016 1016 prepareActions(); 1017 1018 /* Prepare connections: */1019 1017 prepareConnections(); 1020 1021 /* Prepare console event-handlers: */ 1022 prepareConsoleEventHandlers(); 1023 1024 /* Prepare screens: */ 1018 prepareMachineWindowIcon(); 1025 1019 prepareScreens(); 1026 1027 /* Prepare framebuffers: */ 1028 prepareFramebuffers(); 1020 prepareSignalHandling(); 1029 1021 1030 1022 /* Load settings: */ 1031 1023 loadSessionSettings(); 1032 1033 #ifdef VBOX_GUI_WITH_KEYS_RESET_HANDLER1034 struct sigaction sa;1035 sa.sa_sigaction = &signalHandlerSIGUSR1;1036 sigemptyset(&sa.sa_mask);1037 sa.sa_flags = SA_RESTART | SA_SIGINFO;1038 sigaction(SIGUSR1, &sa, NULL);1039 #endif /* VBOX_GUI_WITH_KEYS_RESET_HANDLER */1040 1024 1041 1025 /* True by default: */ … … 1048 1032 m_session = uiCommon().openSession(uiCommon().managedVMUuid(), 1049 1033 uiCommon().isSeparateProcess() 1050 ? KLockType_Shared : KLockType_VM); 1034 ? KLockType_Shared 1035 : KLockType_VM); 1051 1036 if (m_session.isNull()) 1052 1037 return false; … … 1097 1082 } 1098 1083 1084 void UISession::prepareConsoleEventHandlers() 1085 { 1086 /* Create console event-handler: */ 1087 UIConsoleEventHandler::create(this); 1088 1089 /* Add console event connections: */ 1090 connect(gConsoleEvents, &UIConsoleEventHandler::sigMousePointerShapeChange, 1091 this, &UISession::sltMousePointerShapeChange); 1092 connect(gConsoleEvents, &UIConsoleEventHandler::sigMouseCapabilityChange, 1093 this, &UISession::sltMouseCapabilityChange); 1094 connect(gConsoleEvents, &UIConsoleEventHandler::sigCursorPositionChange, 1095 this, &UISession::sltCursorPositionChange); 1096 connect(gConsoleEvents, &UIConsoleEventHandler::sigKeyboardLedsChangeEvent, 1097 this, &UISession::sltKeyboardLedsChangeEvent); 1098 connect(gConsoleEvents, &UIConsoleEventHandler::sigStateChange, 1099 this, &UISession::sltStateChange); 1100 connect(gConsoleEvents, &UIConsoleEventHandler::sigAdditionsChange, 1101 this, &UISession::sltAdditionsChange); 1102 connect(gConsoleEvents, &UIConsoleEventHandler::sigVRDEChange, 1103 this, &UISession::sltVRDEChange); 1104 connect(gConsoleEvents, &UIConsoleEventHandler::sigRecordingChange, 1105 this, &UISession::sltRecordingChange); 1106 connect(gConsoleEvents, &UIConsoleEventHandler::sigNetworkAdapterChange, 1107 this, &UISession::sigNetworkAdapterChange); 1108 connect(gConsoleEvents, &UIConsoleEventHandler::sigStorageDeviceChange, 1109 this, &UISession::sltHandleStorageDeviceChange); 1110 connect(gConsoleEvents, &UIConsoleEventHandler::sigMediumChange, 1111 this, &UISession::sigMediumChange); 1112 connect(gConsoleEvents, &UIConsoleEventHandler::sigUSBControllerChange, 1113 this, &UISession::sigUSBControllerChange); 1114 connect(gConsoleEvents, &UIConsoleEventHandler::sigUSBDeviceStateChange, 1115 this, &UISession::sigUSBDeviceStateChange); 1116 connect(gConsoleEvents, &UIConsoleEventHandler::sigSharedFolderChange, 1117 this, &UISession::sigSharedFolderChange); 1118 connect(gConsoleEvents, &UIConsoleEventHandler::sigRuntimeError, 1119 this, &UISession::sigRuntimeError); 1120 #ifdef VBOX_WS_MAC 1121 connect(gConsoleEvents, &UIConsoleEventHandler::sigShowWindow, 1122 this, &UISession::sigShowWindows, Qt::QueuedConnection); 1123 #endif /* VBOX_WS_MAC */ 1124 connect(gConsoleEvents, &UIConsoleEventHandler::sigCPUExecutionCapChange, 1125 this, &UISession::sigCPUExecutionCapChange); 1126 connect(gConsoleEvents, &UIConsoleEventHandler::sigGuestMonitorChange, 1127 this, &UISession::sltGuestMonitorChange); 1128 connect(gConsoleEvents, &UIConsoleEventHandler::sigAudioAdapterChange, 1129 this, &UISession::sltAudioAdapterChange); 1130 connect(gConsoleEvents, &UIConsoleEventHandler::sigClipboardModeChange, 1131 this, &UISession::sltClipboardModeChange); 1132 connect(gConsoleEvents, &UIConsoleEventHandler::sigDnDModeChange, 1133 this, &UISession::sltDnDModeChange); 1134 } 1135 1136 void UISession::prepareFramebuffers() 1137 { 1138 /* Each framebuffer will be really prepared on first UIMachineView creation: */ 1139 m_frameBufferVector.resize(machine().GetGraphicsAdapter().GetMonitorCount()); 1140 } 1141 1099 1142 void UISession::prepareActions() 1100 1143 { 1101 1144 /* Create action-pool: */ 1102 1145 m_pActionPool = UIActionPool::create(UIActionPoolType_Runtime); 1103 AssertPtrReturnVoid(actionPool()); 1104 { 1146 if (actionPool()) 1147 { 1148 /* Make sure action-pool knows guest-screen count: */ 1149 actionPool()->toRuntime()->setGuestScreenCount(m_frameBufferVector.size()); 1105 1150 /* Update action restrictions: */ 1106 1151 updateActionRestrictions(); … … 1109 1154 /* Create Mac OS X menu-bar: */ 1110 1155 m_pMenuBar = new QMenuBar; 1111 AssertPtrReturnVoid(m_pMenuBar);1156 if (m_pMenuBar) 1112 1157 { 1113 1158 /* Configure Mac OS X menu-bar: */ … … 1123 1168 void UISession::prepareConnections() 1124 1169 { 1125 connect(this, &UISession::sigInitialized, this, &UISession::sltMarkInitialized);1170 /* UICommon connections: */ 1126 1171 connect(&uiCommon(), &UICommon::sigAskToDetachCOM, this, &UISession::sltDetachCOM); 1127 1172 … … 1145 1190 } 1146 1191 1147 void UISession::prepareConsoleEventHandlers() 1148 { 1149 /* Create console event-handler: */ 1150 UIConsoleEventHandler::create(this); 1151 1152 /* Add console event connections: */ 1153 connect(gConsoleEvents, &UIConsoleEventHandler::sigMousePointerShapeChange, 1154 this, &UISession::sltMousePointerShapeChange); 1155 1156 connect(gConsoleEvents, &UIConsoleEventHandler::sigMouseCapabilityChange, 1157 this, &UISession::sltMouseCapabilityChange); 1158 1159 connect(gConsoleEvents, &UIConsoleEventHandler::sigCursorPositionChange, 1160 this, &UISession::sltCursorPositionChange); 1161 1162 connect(gConsoleEvents, &UIConsoleEventHandler::sigKeyboardLedsChangeEvent, 1163 this, &UISession::sltKeyboardLedsChangeEvent); 1164 1165 connect(gConsoleEvents, &UIConsoleEventHandler::sigStateChange, 1166 this, &UISession::sltStateChange); 1167 1168 connect(gConsoleEvents, &UIConsoleEventHandler::sigAdditionsChange, 1169 this, &UISession::sltAdditionsChange); 1170 1171 connect(gConsoleEvents, &UIConsoleEventHandler::sigVRDEChange, 1172 this, &UISession::sltVRDEChange); 1173 1174 connect(gConsoleEvents, &UIConsoleEventHandler::sigRecordingChange, 1175 this, &UISession::sltRecordingChange); 1176 1177 connect(gConsoleEvents, &UIConsoleEventHandler::sigNetworkAdapterChange, 1178 this, &UISession::sigNetworkAdapterChange); 1179 1180 connect(gConsoleEvents, &UIConsoleEventHandler::sigStorageDeviceChange, 1181 this, &UISession::sltHandleStorageDeviceChange); 1182 1183 connect(gConsoleEvents, &UIConsoleEventHandler::sigMediumChange, 1184 this, &UISession::sigMediumChange); 1185 1186 connect(gConsoleEvents, &UIConsoleEventHandler::sigUSBControllerChange, 1187 this, &UISession::sigUSBControllerChange); 1188 1189 connect(gConsoleEvents, &UIConsoleEventHandler::sigUSBDeviceStateChange, 1190 this, &UISession::sigUSBDeviceStateChange); 1191 1192 connect(gConsoleEvents, &UIConsoleEventHandler::sigSharedFolderChange, 1193 this, &UISession::sigSharedFolderChange); 1194 1195 connect(gConsoleEvents, &UIConsoleEventHandler::sigRuntimeError, 1196 this, &UISession::sigRuntimeError); 1197 1198 #ifdef VBOX_WS_MAC 1199 connect(gConsoleEvents, &UIConsoleEventHandler::sigShowWindow, 1200 this, &UISession::sigShowWindows, Qt::QueuedConnection); 1201 #endif /* VBOX_WS_MAC */ 1202 1203 connect(gConsoleEvents, &UIConsoleEventHandler::sigCPUExecutionCapChange, 1204 this, &UISession::sigCPUExecutionCapChange); 1205 1206 connect(gConsoleEvents, &UIConsoleEventHandler::sigGuestMonitorChange, 1207 this, &UISession::sltGuestMonitorChange); 1208 1209 connect(gConsoleEvents, &UIConsoleEventHandler::sigAudioAdapterChange, 1210 this, &UISession::sltAudioAdapterChange); 1211 1212 connect(gConsoleEvents, &UIConsoleEventHandler::sigClipboardModeChange, 1213 this, &UISession::sltClipboardModeChange); 1214 1215 connect(gConsoleEvents, &UIConsoleEventHandler::sigDnDModeChange, 1216 this, &UISession::sltDnDModeChange); 1192 void UISession::prepareMachineWindowIcon() 1193 { 1194 /* Acquire user machine-window icon: */ 1195 QIcon icon = uiCommon().vmUserIcon(machine()); 1196 /* Use the OS type icon if user one was not set: */ 1197 if (icon.isNull()) 1198 icon = uiCommon().vmGuestOSTypeIcon(machine().GetOSTypeId()); 1199 /* Use the default icon if nothing else works: */ 1200 if (icon.isNull()) 1201 icon = QIcon(":/VirtualBox_48px.png"); 1202 /* Store the icon dynamically: */ 1203 m_pMachineWindowIcon = new QIcon(icon); 1217 1204 } 1218 1205 … … 1288 1275 } 1289 1276 1290 void UISession::prepareFramebuffers() 1291 { 1292 /* Each framebuffer will be really prepared on first UIMachineView creation: */ 1293 m_frameBufferVector.resize(machine().GetGraphicsAdapter().GetMonitorCount()); 1294 1295 /* Make sure action-pool knows guest-screen count: */ 1296 actionPool()->toRuntime()->setGuestScreenCount(m_frameBufferVector.size()); 1277 void UISession::prepareSignalHandling() 1278 { 1279 #ifdef VBOX_GUI_WITH_KEYS_RESET_HANDLER 1280 struct sigaction sa; 1281 sa.sa_sigaction = &signalHandlerSIGUSR1; 1282 sigemptyset(&sa.sa_mask); 1283 sa.sa_flags = SA_RESTART | SA_SIGINFO; 1284 sigaction(SIGUSR1, &sa, NULL); 1285 #endif /* VBOX_GUI_WITH_KEYS_RESET_HANDLER */ 1297 1286 } 1298 1287 … … 1303 1292 /* Get machine ID: */ 1304 1293 const QUuid uMachineID = uiCommon().managedVMUuid(); 1305 1306 /* Prepare machine-window icon: */1307 {1308 /* Acquire user machine-window icon: */1309 QIcon icon = uiCommon().vmUserIcon(machine());1310 /* Use the OS type icon if user one was not set: */1311 if (icon.isNull())1312 icon = uiCommon().vmGuestOSTypeIcon(machine().GetOSTypeId());1313 /* Use the default icon if nothing else works: */1314 if (icon.isNull())1315 icon = QIcon(":/VirtualBox_48px.png");1316 /* Store the icon dynamically: */1317 m_pMachineWindowIcon = new QIcon(icon);1318 }1319 1294 1320 1295 #ifndef VBOX_WS_MAC … … 1394 1369 } 1395 1370 1396 void UISession::saveSessionSettings() 1397 { 1398 /* Save extra-data settings: */ 1399 { 1400 /* Cleanup machine-window icon: */ 1401 delete m_pMachineWindowIcon; 1402 m_pMachineWindowIcon = 0; 1403 } 1371 void UISession::cleanupMachineWindowIcon() 1372 { 1373 /* Cleanup machine-window icon: */ 1374 delete m_pMachineWindowIcon; 1375 m_pMachineWindowIcon = 0; 1376 } 1377 1378 void UISession::cleanupConnections() 1379 { 1380 #ifdef VBOX_WS_MAC 1381 /* Remove display reconfiguration callback: */ 1382 CGDisplayRemoveReconfigurationCallback(cgDisplayReconfigurationCallback, this); 1383 #endif /* VBOX_WS_MAC */ 1384 } 1385 1386 void UISession::cleanupActions() 1387 { 1388 #ifdef VBOX_WS_MAC 1389 /* Destroy Mac OS X menu-bar: */ 1390 delete m_pMenuBar; 1391 m_pMenuBar = 0; 1392 #endif /* VBOX_WS_MAC */ 1393 1394 /* Destroy action-pool if necessary: */ 1395 if (actionPool()) 1396 UIActionPool::destroy(actionPool()); 1404 1397 } 1405 1398 … … 1434 1427 } 1435 1428 1436 void UISession::cleanupConnections()1437 {1438 #ifdef VBOX_WS_MAC1439 /* Remove display reconfiguration callback: */1440 CGDisplayRemoveReconfigurationCallback(cgDisplayReconfigurationCallback, this);1441 #endif /* VBOX_WS_MAC */1442 }1443 1444 void UISession::cleanupActions()1445 {1446 #ifdef VBOX_WS_MAC1447 /* Destroy Mac OS X menu-bar: */1448 delete m_pMenuBar;1449 m_pMenuBar = 0;1450 #endif /* VBOX_WS_MAC */1451 1452 /* Destroy action-pool if necessary: */1453 if (actionPool())1454 UIActionPool::destroy(actionPool());1455 }1456 1457 1429 void UISession::cleanupSession() 1458 1430 { … … 1495 1467 void UISession::cleanup() 1496 1468 { 1497 #ifdef VBOX_WS_WIN 1498 /* Destroy alpha cursor: */ 1499 if (m_alphaCursor) 1500 DestroyIcon(m_alphaCursor); 1501 #endif /* VBOX_WS_WIN */ 1502 1503 /* Save settings: */ 1504 saveSessionSettings(); 1505 1506 /* Cleanup connections: */ 1469 /* Cleanup GUI stuff: */ 1470 //cleanupSignalHandling(); 1471 //cleanupScreens(); 1472 cleanupMachineWindowIcon(); 1507 1473 cleanupConnections(); 1508 1509 /* Cleanup actions: */1510 1474 cleanupActions(); 1511 1475 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
r88678 r88680 362 362 private slots: 363 363 364 /** Marks machine started. */365 void sltMarkInitialized() { m_fInitialized = true; }366 367 364 /** Detaches COM. */ 368 365 void sltDetachCOM(); … … 424 421 bool prepare(); 425 422 bool prepareSession(); 423 void prepareConsoleEventHandlers(); 424 void prepareFramebuffers(); 426 425 void prepareActions(); 427 426 void prepareConnections(); 428 void prepare ConsoleEventHandlers();427 void prepareMachineWindowIcon(); 429 428 void prepareScreens(); 430 void prepareFramebuffers(); 429 void prepareSignalHandling(); 430 431 /* Settings stuff: */ 431 432 void loadSessionSettings(); 432 433 433 434 /* Cleanup helpers: */ 434 void saveSessionSettings(); 435 void cleanupFramebuffers(); 435 //void cleanupSignalHandling(); 436 436 //void cleanupScreens() {} 437 void cleanup ConsoleEventHandlers();437 void cleanupMachineWindowIcon(); 438 438 void cleanupConnections(); 439 439 void cleanupActions(); 440 void cleanupFramebuffers(); 441 void cleanupConsoleEventHandlers(); 440 442 void cleanupSession(); 441 443 void cleanup(); … … 531 533 /** @} */ 532 534 533 #if defined(VBOX_WS_WIN)534 HCURSOR m_alphaCursor;535 #endif536 537 535 /** @name Host-screen configuration variables. 538 536 * @{ */
Note:
See TracChangeset
for help on using the changeset viewer.