Changeset 6674 in vbox
- Timestamp:
- Jan 31, 2008 7:23:08 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 27747
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleView.h
r6467 r6674 34 34 #if defined (Q_WS_PM) 35 35 #include "src/os2/VBoxHlp.h" 36 #define UM_PREACCEL_CHAR WM_USER 36 37 #endif 37 38 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
r6649 r6674 96 96 #if defined (Q_WS_WIN32) 97 97 98 static HHOOK g _kbdhook = NULL;99 static VBoxConsoleView *g _view = 0;98 static HHOOK gKbdHook = NULL; 99 static VBoxConsoleView *gView = 0; 100 100 101 101 LRESULT CALLBACK VBoxConsoleView::lowLevelKeyboardProc (int nCode, 102 102 WPARAM wParam, LPARAM lParam) 103 103 { 104 Assert (g _view);105 if (g _view && nCode == HC_ACTION &&106 g _view->winLowKeyboardEvent (wParam, *(KBDLLHOOKSTRUCT *) lParam))104 Assert (gView); 105 if (gView && nCode == HC_ACTION && 106 gView->winLowKeyboardEvent (wParam, *(KBDLLHOOKSTRUCT *) lParam)) 107 107 return 1; 108 108 … … 753 753 754 754 #if defined (Q_WS_WIN) 755 g _view = this;755 gView = this; 756 756 #endif 757 757 758 758 #if defined (Q_WS_PM) 759 bool ok = VBoxHlpInstallKbdHook (0, winId(), WM_CHAR);759 bool ok = VBoxHlpInstallKbdHook (0, winId(), UM_PREACCEL_CHAR); 760 760 Assert (ok); 761 761 NOREF (ok); … … 770 770 { 771 771 #if defined (Q_WS_PM) 772 bool ok = VBoxHlpUninstallKbdHook (0, winId(), WM_CHAR);772 bool ok = VBoxHlpUninstallKbdHook (0, winId(), UM_PREACCEL_CHAR); 773 773 Assert (ok); 774 774 NOREF (ok); … … 776 776 777 777 #if defined (Q_WS_WIN) 778 if (g _kbdhook)779 UnhookWindowsHookEx (g _kbdhook);780 g _view = 0;778 if (gKbdHook) 779 UnhookWindowsHookEx (gKbdHook); 780 gView = 0; 781 781 if (mAlphaCursor) 782 782 DestroyIcon (mAlphaCursor); … … 1269 1269 1270 1270 case QEvent::KeyPress: 1271 { 1271 #ifdef Q_WS_PM 1272 case QEvent::KeyRelease: 1273 { 1274 /// @todo temporary solution to send Alt+Tab and friends to 1275 // the guest. The proper solution is to write a keyboard 1276 // driver that will steal these combos from the host (it's 1277 // impossible to do so using hooks on OS/2). 1278 1272 1279 QKeyEvent *ke = (QKeyEvent *) e; 1280 if (mIsHostkeyPressed) 1281 { 1282 bool pressed = e->type() == QEvent::KeyPress; 1283 CKeyboard keyboard = mConsole.GetKeyboard(); 1284 1285 /* whether the host key is Shift so that it will modify 1286 * the hot key values? Note that we don't distinguish 1287 * between left and right shift here (too much hassle) */ 1288 const bool kShift = (gs.hostKey() == VK_SHIFT || 1289 gs.hostKey() == VK_LSHIFT) && 1290 (ke->state() & ShiftButton); 1291 /* define hot keys according to the Shift state */ 1292 const int kAltTab = kShift ? Key_Exclam : Key_1; 1293 const int kAltShiftTab = kShift ? Key_At : Key_2; 1294 const int kCtrlEsc = kShift ? Key_AsciiTilde : Key_QuoteLeft; 1295 1296 /* Simulate Alt+Tab on Host+1 and Alt+Shift+Tab on Host+2 */ 1297 if (ke->key() == kAltTab || ke->key() == kAltShiftTab) 1298 { 1299 if (pressed) 1300 { 1301 /* Send the Alt press to the guest */ 1302 if (!(mPressedKeysCopy [0x38] & IsKeyPressed)) 1303 { 1304 /* store the press in *Copy to have it automatically 1305 * released when the Host key is released */ 1306 mPressedKeysCopy [0x38] |= IsKeyPressed; 1307 keyboard.PutScancode (0x38); 1308 } 1309 1310 /* Make sure Shift is pressed if it's Key_2 and released 1311 * if it's Key_1 */ 1312 if (ke->key() == kAltTab && 1313 (mPressedKeysCopy [0x2A] & IsKeyPressed)) 1314 { 1315 mPressedKeysCopy [0x2A] &= ~IsKeyPressed; 1316 keyboard.PutScancode (0xAA); 1317 } 1318 else 1319 if (ke->key() == kAltShiftTab && 1320 !(mPressedKeysCopy [0x2A] & IsKeyPressed)) 1321 { 1322 mPressedKeysCopy [0x2A] |= IsKeyPressed; 1323 keyboard.PutScancode (0x2A); 1324 } 1325 } 1326 1327 keyboard.PutScancode (pressed ? 0x0F : 0x8F); 1328 1329 ke->accept(); 1330 return true; 1331 } 1332 1333 /* Simulate Ctrl+Esc on Host+Tilde */ 1334 if (ke->key() == kCtrlEsc) 1335 { 1336 /* Send the Ctrl press to the guest */ 1337 if (pressed && !(mPressedKeysCopy [0x1d] & IsKeyPressed)) 1338 { 1339 /* store the press in *Copy to have it automatically 1340 * released when the Host key is released */ 1341 mPressedKeysCopy [0x1d] |= IsKeyPressed; 1342 keyboard.PutScancode (0x1d); 1343 } 1344 1345 keyboard.PutScancode (pressed ? 0x01 : 0x81); 1346 1347 ke->accept(); 1348 return true; 1349 } 1350 } 1351 if (e->type() == QEvent::KeyRelease) 1352 break; 1353 1354 /* fall through for normal processing of KeyPress */ 1355 #else 1356 { 1357 QKeyEvent *ke = (QKeyEvent *) e; 1358 #endif 1273 1359 if (mIsHostkeyPressed) 1274 1360 { … … 1295 1381 1296 1382 CKeyboard keyboard = mConsole.GetKeyboard(); 1297 Assert (!keyboard.isNull());1298 1383 keyboard.PutScancodes (combo, 6); 1299 1384 } … … 1416 1501 case QEvent::WindowActivate: 1417 1502 { 1418 g _kbdhook = SetWindowsHookEx (WH_KEYBOARD_LL, lowLevelKeyboardProc,1503 gKbdHook = SetWindowsHookEx (WH_KEYBOARD_LL, lowLevelKeyboardProc, 1419 1504 GetModuleHandle (NULL), 0); 1420 AssertMsg (g _kbdhook, ("SetWindowsHookEx(): err=%d", GetLastError()));1505 AssertMsg (gKbdHook, ("SetWindowsHookEx(): err=%d", GetLastError())); 1421 1506 break; 1422 1507 } 1423 1508 case QEvent::WindowDeactivate: 1424 1509 { 1425 if (g _kbdhook)1510 if (gKbdHook) 1426 1511 { 1427 UnhookWindowsHookEx (g _kbdhook);1428 g _kbdhook = NULL;1512 UnhookWindowsHookEx (gKbdHook); 1513 gKbdHook = NULL; 1429 1514 } 1430 1515 break; … … 1559 1644 1560 1645 /* check for the special flag possibly set at the end of this function */ 1561 if ((msg->lParam >> 25) & 0x1) 1646 if (msg->lParam & (0x1 << 25)) 1647 { 1648 msg->lParam &= ~(0x1 << 25); 1562 1649 return false; 1650 } 1563 1651 1564 1652 #if 0 … … 1661 1749 bool VBoxConsoleView::pmEvent (QMSG *aMsg) 1662 1750 { 1663 if (!mAttached || aMsg->msg != WM_CHAR) 1751 if (!mAttached) 1752 return false; 1753 1754 if (aMsg->msg == UM_PREACCEL_CHAR) 1755 { 1756 /* we are inside the input hook */ 1757 1758 /* let the message go through the normal system pipeline */ 1759 if (!mKbdCaptured) 1760 return false; 1761 } 1762 1763 if (aMsg->msg != WM_CHAR && 1764 aMsg->msg != UM_PREACCEL_CHAR) 1664 1765 return false; 1665 1766 1666 1767 /* check for the special flag possibly set at the end of this function */ 1667 1768 if (SHORT2FROMMP (aMsg->mp2) & 0x8000) 1769 { 1770 aMsg->mp2 = MPFROM2SHORT (SHORT1FROMMP (aMsg->mp2), 1771 SHORT2FROMMP (aMsg->mp2) & ~0x8000); 1668 1772 return false; 1773 } 1669 1774 1670 1775 #if 0 1671 1776 { 1672 1777 char buf [256]; 1673 sprintf (buf, "*** WM_CHAR: f=%04X rep=%03d scan=%02X ch=%04X vk=%04X", 1778 sprintf (buf, "*** %s: f=%04X rep=%03d scan=%02X ch=%04X vk=%04X", 1779 (aMsg->msg == WM_CHAR ? "WM_CHAR" : "UM_PREACCEL_CHAR"), 1674 1780 SHORT1FROMMP (aMsg->mp1), CHAR3FROMMP (aMsg->mp1), 1675 1781 CHAR4FROMMP (aMsg->mp1), SHORT1FROMMP (aMsg->mp2), … … 1742 1848 * shortcuts for example). So send it direcltly to the window with the 1743 1849 * special flag in the reserved area of lParam (to avoid recursion). */ 1744 ::WinSendMsg (aMsg->hwnd, aMsg->msg,1850 ::WinSendMsg (aMsg->hwnd, WM_CHAR, 1745 1851 aMsg->mp1, 1746 1852 MPFROM2SHORT (SHORT1FROMMP (aMsg->mp2), … … 2349 2455 emitKeyboardStateChanged(); 2350 2456 2351 /* process HOST+<key> shortcuts. currently, <key> is limited to 2352 * alphanumeric chars. */ 2457 /* Process Host+<key> shortcuts. currently, <key> is limited to 2458 * alphanumeric chars. Other Host+<key> combinations are handled in 2459 * event(). */ 2353 2460 if (hotkey) 2354 2461 {
Note:
See TracChangeset
for help on using the changeset viewer.