Changeset 37322 in vbox
- Timestamp:
- Jun 3, 2011 3:47:45 PM (14 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp
r37239 r37322 1115 1115 * @returns true if handling should stop here, false otherwise 1116 1116 */ 1117 bool UIKeyboardHandler::keyEvent HandleCAD(uint8_t uScan)1117 bool UIKeyboardHandler::keyEventCADHandled(uint8_t uScan) 1118 1118 { 1119 1119 /* Check if it's C-A-D and GUI/PassCAD is not true: */ … … 1192 1192 } 1193 1193 1194 /** 1195 * Check whether the key pressed results in a host key combination being 1196 * handled. 1197 * @returns true if a combination was handled, false otherwise 1198 * @param pfResult where to store the result of the handling 1199 */ 1200 bool UIKeyboardHandler::keyEventHostComboHandled(int iKey, wchar_t *pUniKey, bool isHostComboStateChanged, bool *pfResult) 1201 { 1202 if (isHostComboStateChanged) 1203 { 1204 if (!m_bIsHostComboPressed) 1205 { 1206 m_bIsHostComboPressed = true; 1207 m_bIsHostComboAlone = true; 1208 m_bIsHostComboProcessed = false; 1209 if (uisession()->isRunning()) 1210 saveKeyStates(); 1211 } 1212 } 1213 else 1214 { 1215 if (m_bIsHostComboPressed) 1216 { 1217 if (m_bIsHostComboAlone) 1218 { 1219 m_bIsHostComboAlone = false; 1220 m_bIsHostComboProcessed = true; 1221 /* Process Host+<key> shortcuts. 1222 * Currently, <key> is limited to alphanumeric chars. 1223 * Other Host+<key> combinations are handled in Qt event(): */ 1224 *pfResult = processHotKey(iKey, pUniKey); 1225 return true; 1226 } 1227 } 1228 } 1229 return false; 1230 } 1231 1232 /** 1233 * Handle a key event that releases the host key combination 1234 */ 1235 void UIKeyboardHandler::keyEventHandleHostComboRelease(ulong uScreenId) 1236 { 1237 if (m_bIsHostComboPressed) 1238 { 1239 m_bIsHostComboPressed = false; 1240 /* Capturing/releasing keyboard/mouse if necessary: */ 1241 if (m_bIsHostComboAlone && !m_bIsHostComboProcessed) 1242 { 1243 if (uisession()->isRunning()) 1244 { 1245 bool ok = true; 1246 if (!m_fIsKeyboardCaptured) 1247 { 1248 /* Temporarily disable auto-capture that will take place after 1249 * this dialog is dismissed because the capture state is to be 1250 * defined by the dialog result itself: */ 1251 uisession()->setAutoCaptureDisabled(true); 1252 bool fIsAutoConfirmed = false; 1253 ok = vboxProblem().confirmInputCapture(&fIsAutoConfirmed); 1254 if (fIsAutoConfirmed) 1255 uisession()->setAutoCaptureDisabled(false); 1256 /* Otherwise, the disable flag will be reset in the next 1257 * machine-view's focus-in event (since may happen asynchronously 1258 * on some platforms, after we return from this code): */ 1259 } 1260 if (ok) 1261 { 1262 if (m_fIsKeyboardCaptured) 1263 releaseKeyboard(); 1264 else 1265 captureKeyboard(uScreenId); 1266 if (!uisession()->isMouseSupportsAbsolute() || !uisession()->isMouseIntegrated()) 1267 { 1268 #ifdef Q_WS_X11 1269 /* Make sure that pending FocusOut events from the 1270 * previous message box are handled, otherwise the 1271 * mouse is immediately ungrabbed: */ 1272 qApp->processEvents(); 1273 #endif /* Q_WS_X11 */ 1274 if (m_fIsKeyboardCaptured) 1275 machineLogic()->mouseHandler()->captureMouse(uScreenId); 1276 else 1277 machineLogic()->mouseHandler()->releaseMouse(); 1278 } 1279 } 1280 } 1281 } 1282 if (uisession()->isRunning()) 1283 sendChangedKeyStates(); 1284 } 1285 } 1286 1287 void UIKeyboardHandler::keyEventReleaseHostComboKeys(CKeyboard keyboard) 1288 { 1289 /* We have to make guest to release pressed keys from the host-combination: */ 1290 QList<uint8_t> hostComboScans = m_pressedHostComboKeys.values(); 1291 for (int i = 0 ; i < hostComboScans.size(); ++i) 1292 { 1293 uint8_t uScan = hostComboScans[i]; 1294 if (m_pressedKeys[uScan] & IsKeyPressed) 1295 { 1296 keyboard.PutScancode(uScan | 0x80); 1297 } 1298 else if (m_pressedKeys[uScan] & IsExtKeyPressed) 1299 { 1300 QVector<LONG> scancodes(2); 1301 scancodes[0] = 0xE0; 1302 scancodes[1] = uScan | 0x80; 1303 keyboard.PutScancodes(scancodes); 1304 } 1305 m_pressedKeys[uScan] = 0; 1306 } 1307 } 1308 1194 1309 bool UIKeyboardHandler::keyEvent(int iKey, uint8_t uScan, int fFlags, ulong uScreenId, wchar_t *pUniKey /* = 0 */) 1195 1310 { … … 1227 1342 #endif /* Q_WS_WIN */ 1228 1343 1229 if (keyEvent HandleCAD(uScan))1344 if (keyEventCADHandled(uScan)) 1230 1345 return true; 1231 1346 … … 1282 1397 if (fFlags & KeyPressed) 1283 1398 { 1399 bool fResult; 1400 if (keyEventHostComboHandled(iKey, pUniKey, isHostComboStateChanged, &fResult)) 1401 return fResult; 1402 } 1403 else 1404 { 1284 1405 if (isHostComboStateChanged) 1285 { 1286 if (!m_bIsHostComboPressed) 1287 { 1288 m_bIsHostComboPressed = true; 1289 m_bIsHostComboAlone = true; 1290 m_bIsHostComboProcessed = false; 1291 if (uisession()->isRunning()) 1292 saveKeyStates(); 1293 } 1294 } 1295 else 1296 { 1297 if (m_bIsHostComboPressed) 1298 { 1299 if (m_bIsHostComboAlone) 1300 { 1301 m_bIsHostComboAlone = false; 1302 m_bIsHostComboProcessed = true; 1303 /* Process Host+<key> shortcuts. 1304 * Currently, <key> is limited to alphanumeric chars. 1305 * Other Host+<key> combinations are handled in Qt event(): */ 1306 return processHotKey(iKey, pUniKey); 1307 } 1308 } 1309 } 1310 } 1311 else 1312 { 1313 if (isHostComboStateChanged) 1314 { 1315 if (m_bIsHostComboPressed) 1316 { 1317 m_bIsHostComboPressed = false; 1318 /* Capturing/releasing keyboard/mouse if necessary: */ 1319 if (m_bIsHostComboAlone && !m_bIsHostComboProcessed) 1320 { 1321 if (uisession()->isRunning()) 1322 { 1323 bool ok = true; 1324 if (!m_fIsKeyboardCaptured) 1325 { 1326 /* Temporarily disable auto-capture that will take place after 1327 * this dialog is dismissed because the capture state is to be 1328 * defined by the dialog result itself: */ 1329 uisession()->setAutoCaptureDisabled(true); 1330 bool fIsAutoConfirmed = false; 1331 ok = vboxProblem().confirmInputCapture(&fIsAutoConfirmed); 1332 if (fIsAutoConfirmed) 1333 uisession()->setAutoCaptureDisabled(false); 1334 /* Otherwise, the disable flag will be reset in the next 1335 * machine-view's focus-in event (since may happen asynchronously 1336 * on some platforms, after we return from this code): */ 1337 } 1338 if (ok) 1339 { 1340 if (m_fIsKeyboardCaptured) 1341 releaseKeyboard(); 1342 else 1343 captureKeyboard(uScreenId); 1344 if (!uisession()->isMouseSupportsAbsolute() || !uisession()->isMouseIntegrated()) 1345 { 1346 #ifdef Q_WS_X11 1347 /* Make sure that pending FocusOut events from the 1348 * previous message box are handled, otherwise the 1349 * mouse is immediately ungrabbed: */ 1350 qApp->processEvents(); 1351 #endif /* Q_WS_X11 */ 1352 if (m_fIsKeyboardCaptured) 1353 machineLogic()->mouseHandler()->captureMouse(uScreenId); 1354 else 1355 machineLogic()->mouseHandler()->releaseMouse(); 1356 } 1357 } 1358 } 1359 } 1360 if (uisession()->isRunning()) 1361 sendChangedKeyStates(); 1362 } 1363 } 1406 keyEventHandleHostComboRelease(uScreenId); 1364 1407 else 1365 1408 { … … 1390 1433 if (isHostComboStateChanged && m_bIsHostComboPressed) 1391 1434 { 1392 /* We have to make guest to release pressed keys from the host-combination: */ 1393 QList<uint8_t> hostComboScans = m_pressedHostComboKeys.values(); 1394 for (int i = 0 ; i < hostComboScans.size(); ++i) 1395 { 1396 uint8_t uScan = hostComboScans[i]; 1397 if (m_pressedKeys[uScan] & IsKeyPressed) 1398 { 1399 keyboard.PutScancode(uScan | 0x80); 1400 } 1401 else if (m_pressedKeys[uScan] & IsExtKeyPressed) 1402 { 1403 QVector<LONG> scancodes(2); 1404 scancodes[0] = 0xE0; 1405 scancodes[1] = uScan | 0x80; 1406 keyboard.PutScancodes(scancodes); 1407 } 1408 m_pressedKeys[uScan] = 0; 1409 } 1435 keyEventReleaseHostComboKeys(keyboard); 1410 1436 } 1411 1437 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.h
r37239 r37322 124 124 #endif 125 125 126 bool keyEvent HandleCAD(uint8_t uScan);126 bool keyEventCADHandled(uint8_t uScan); 127 127 bool keyEventHandleNormal(int iKey, uint8_t uScan, int fFlags, LONG *pCodes, uint *puCodesCount); 128 bool keyEventHostComboHandled(int iKey, wchar_t *pUniKey, bool isHostComboStateChanged, bool *pfResult); 129 void keyEventHandleHostComboRelease(ulong uScreenId); 130 void keyEventReleaseHostComboKeys(CKeyboard keyboard); 128 131 /* Separate function to handle most of existing keyboard-events: */ 129 132 bool keyEvent(int iKey, uint8_t uScan, int fFlags, ulong uScreenId, wchar_t *pUniKey = 0);
Note:
See TracChangeset
for help on using the changeset viewer.