Changeset 30550 in vbox
- Timestamp:
- Jul 1, 2010 1:46:52 AM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 63258
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
r30549 r30550 46 46 #include "UIMachineViewFullscreen.h" 47 47 #include "UIMachineViewSeamless.h" 48 49 #ifdef Q_WS_PM50 # include "QIHotKeyEdit.h"51 #endif /* Q_WS_PM */52 48 53 49 #ifdef Q_WS_WIN … … 448 444 /* Setup focus policy: */ 449 445 setFocusPolicy(Qt::WheelFocus); 450 451 #if defined Q_WS_PM452 bool ok = VBoxHlpInstallKbdHook(0, winId(), UM_PREACCEL_CHAR);453 Assert(ok);454 NOREF(ok);455 #endif /* Q_WS_PM */456 446 } 457 447 … … 510 500 void UIMachineView::cleanupCommon() 511 501 { 512 #ifdef Q_WS_PM513 bool ok = VBoxHlpUninstallKbdHook(0, winId(), UM_PREACCEL_CHAR);514 Assert(ok);515 NOREF(ok);516 #endif /* Q_WS_PM */517 518 502 #ifdef Q_WS_WIN 519 503 if (gKbdHook) … … 1140 1124 { 1141 1125 QKeyEvent *pKeyEvent = static_cast<QKeyEvent*>(pEvent); 1142 1143 #ifdef Q_WS_PM1144 // TODO: that a temporary solution to send Alt+Tab and friends to the guest.1145 // The proper solution is to write a keyboard driver that will steal these combos from the host1146 // (it's impossible to do so using hooks on OS/2):1147 1148 if (m_bIsHostkeyPressed)1149 {1150 bool pressed = pEvent->type() == QEvent::KeyPress;1151 CKeyboard keyboard = session().GetConsole().GetKeyboard();1152 1153 /* Whether the host key is Shift so that it will modify the hot key values?1154 * Note that we don't distinguish between left and right shift here (too much hassle): */1155 const bool kShift = (m_globalSettings.hostKey() == VK_SHIFT ||1156 m_globalSettings.hostKey() == VK_LSHIFT) &&1157 (pKeyEvent->state() & Qt::ShiftModifier);1158 /* define hot keys according to the Shift state */1159 const int kAltTab = kShift ? Qt::Key_Exclam : Qt::Key_1;1160 const int kAltShiftTab = kShift ? Qt::Key_At : Qt::Key_2;1161 const int kCtrlEsc = kShift ? Qt::Key_AsciiTilde : Qt::Key_QuoteLeft;1162 1163 /* Simulate Alt+Tab on Host+1 and Alt+Shift+Tab on Host+2 */1164 if (pKeyEvent->key() == kAltTab || pKeyEvent->key() == kAltShiftTab)1165 {1166 if (pressed)1167 {1168 /* Send the Alt press to the guest */1169 if (!(m_pressedKeysCopy[0x38] & IsKeyPressed))1170 {1171 /* Store the press in *Copy to have it automatically1172 * released when the Host key is released: */1173 m_pressedKeysCopy[0x38] |= IsKeyPressed;1174 keyboard.PutScancode(0x38);1175 }1176 1177 /* Make sure Shift is pressed if it's Key_2 and released if it's Key_1: */1178 if (pKeyEvent->key() == kAltTab &&1179 (m_pressedKeysCopy[0x2A] & IsKeyPressed))1180 {1181 m_pressedKeysCopy[0x2A] &= ~IsKeyPressed;1182 keyboard.PutScancode(0xAA);1183 }1184 else1185 if (pKeyEvent->key() == kAltShiftTab &&1186 !(m_pressedKeysCopy[0x2A] & IsKeyPressed))1187 {1188 m_pressedKeysCopy[0x2A] |= IsKeyPressed;1189 keyboard.PutScancode(0x2A);1190 }1191 }1192 1193 keyboard.PutScancode(pressed ? 0x0F : 0x8F);1194 1195 pKeyEvent->accept();1196 return true;1197 }1198 1199 /* Simulate Ctrl+Esc on Host+Tilde */1200 if (pKeyEvent->key() == kCtrlEsc)1201 {1202 /* Send the Ctrl press to the guest */1203 if (pressed && !(m_pressedKeysCopy[0x1d] & IsKeyPressed))1204 {1205 /* store the press in *Copy to have it automatically1206 * released when the Host key is released */1207 m_pressedKeysCopy[0x1d] |= IsKeyPressed;1208 keyboard.PutScancode(0x1d);1209 }1210 1211 keyboard.PutScancode(pressed ? 0x01 : 0x81);1212 1213 pKeyEvent->accept();1214 return true;1215 }1216 }1217 #endif /* Q_WS_PM */1218 1126 1219 1127 if (m_bIsHostkeyPressed && pEvent->type() == QEvent::KeyPress) … … 1869 1777 } 1870 1778 1871 #elif defined(Q_WS_PM)1872 1873 bool UIMachineView::pmEvent(QMSG *aMsg)1874 {1875 if (aMsg->msg == UM_PREACCEL_CHAR)1876 {1877 /* We are inside the input hook1878 * let the message go through the normal system pipeline. */1879 if (!m_bIsKeyboardCaptured)1880 return false;1881 }1882 1883 if (aMsg->msg != WM_CHAR && aMsg->msg != UM_PREACCEL_CHAR)1884 return false;1885 1886 /* check for the special flag possibly set at the end of this function */1887 if (SHORT2FROMMP(aMsg->mp2) & 0x8000)1888 {1889 aMsg->mp2 = MPFROM2SHORT(SHORT1FROMMP(aMsg->mp2), SHORT2FROMMP(aMsg->mp2) & ~0x8000);1890 return false;1891 }1892 1893 USHORT ch = SHORT1FROMMP(aMsg->mp2);1894 USHORT f = SHORT1FROMMP(aMsg->mp1);1895 1896 int scan = (unsigned int)CHAR4FROMMP(aMsg->mp1);1897 if (!scan || scan > 0x7F)1898 return true;1899 1900 int vkey = QIHotKeyEdit::virtualKey(aMsg);1901 1902 int flags = 0;1903 1904 if ((ch & 0xFF) == 0xE0)1905 {1906 flags |= KeyExtended;1907 scan = ch >> 8;1908 }1909 else if (scan == 0x5C && (ch & 0xFF) == '/')1910 {1911 /* this is the '/' key on the keypad */1912 scan = 0x35;1913 flags |= KeyExtended;1914 }1915 else1916 {1917 /* For some keys, the scan code passed in QMSG is a pseudo scan1918 * code. We replace it with a real hardware scan code, according to1919 * http://www.computer-engineering.org/ps2keyboard/scancodes1.html.1920 * Also detect Pause and PrtScn and set flags. */1921 switch (vkey)1922 {1923 case VK_ENTER: scan = 0x1C; flags |= KeyExtended; break;1924 case VK_CTRL: scan = 0x1D; flags |= KeyExtended; break;1925 case VK_ALTGRAF: scan = 0x38; flags |= KeyExtended; break;1926 case VK_LWIN: scan = 0x5B; flags |= KeyExtended; break;1927 case VK_RWIN: scan = 0x5C; flags |= KeyExtended; break;1928 case VK_WINMENU: scan = 0x5D; flags |= KeyExtended; break;1929 case VK_FORWARD: scan = 0x69; flags |= KeyExtended; break;1930 case VK_BACKWARD: scan = 0x6A; flags |= KeyExtended; break;1931 #if 01932 /// @todo this would send 0xE0 0x46 0xE0 0xC6. It's not fully1933 // clear what is more correct1934 case VK_BREAK: scan = 0x46; flags |= KeyExtended; break;1935 #else1936 case VK_BREAK: scan = 0; flags |= KeyPause; break;1937 #endif1938 case VK_PAUSE: scan = 0; flags |= KeyPause; break;1939 case VK_PRINTSCRN: scan = 0; flags |= KeyPrint; break;1940 default:;1941 }1942 }1943 1944 if (!(f & KC_KEYUP))1945 flags |= KeyPressed;1946 1947 bool result = keyEvent (vkey, scan, flags);1948 if (!result && m_bIsKeyboardCaptured)1949 {1950 /* keyEvent() returned that it didn't process the message, but since the1951 * keyboard is captured, we don't want to pass it to PM. We just want1952 * to let Qt process the message (to handle non-alphanumeric <HOST>+key1953 * shortcuts for example). So send it direcltly to the window with the1954 * special flag in the reserved area of lParam (to avoid recursion). */1955 ::WinSendMsg (aMsg->hwnd, WM_CHAR, aMsg->mp1,1956 MPFROM2SHORT (SHORT1FROMMP (aMsg->mp2), SHORT2FROMMP (aMsg->mp2) | 0x8000));1957 return true;1958 }1959 return result;1960 }1961 1962 1779 #elif defined(Q_WS_X11) 1963 1780 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h
r30549 r30550 177 177 bool winLowKeyboardEvent(UINT msg, const KBDLLHOOKSTRUCT &event); 178 178 bool winEvent(MSG *aMsg, long *aResult); 179 #elif defined(Q_WS_PM)180 bool pmEvent(QMSG *aMsg);181 179 #elif defined(Q_WS_X11) 182 180 bool x11Event(XEvent *event);
Note:
See TracChangeset
for help on using the changeset viewer.