Changeset 649 in vbox for trunk/src/VBox
- Timestamp:
- Feb 5, 2007 7:23:22 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
r648 r649 1026 1026 bool VBoxConsoleView::winLowKeyboardEvent (UINT msg, const KBDLLHOOKSTRUCT &event) 1027 1027 { 1028 // Log (("### vkCode=%08X, scanCode=%08X, flags=%08X, dwExtraInfo=%08X (kbd_captured=%d)\n", 1029 // event.vkCode, event.scanCode, event.flags, event.dwExtraInfo, kbd_captured)); 1030 // char buf[256]; 1031 // sprintf (buf, 1032 // "### vkCode=%08X, scanCode=%08X, flags=%08X, dwExtraInfo=%08X", 1033 // event.vkCode, event.scanCode, event.flags, event.dwExtraInfo); 1034 // ((QMainWindow*)mainwnd)->statusBar()->message (buf); 1035 1036 // Sometimes it happens that Win inserts additional events on some key 1037 // press/release. For example, it prepends ALT_GR in German layout with 1038 // the VK_LCONTROL vkey with curious 0x21D scan code (seems to be necessary 1039 // to specially treat ALT_GR to enter additional chars to regular apps). 1040 // These events are definitely unwanted in VM, so filter them out. 1028 #if 0 1029 LogFlow (("### vkCode=%08X, scanCode=%08X, flags=%08X, dwExtraInfo=%08X (kbd_captured=%d)\n", 1030 event.vkCode, event.scanCode, event.flags, event.dwExtraInfo, kbd_captured)); 1031 char buf [256]; 1032 sprintf (buf, "### vkCode=%08X, scanCode=%08X, flags=%08X, dwExtraInfo=%08X", 1033 event.vkCode, event.scanCode, event.flags, event.dwExtraInfo); 1034 mainwnd->statusBar()->message (buf); 1035 #endif 1036 1037 /* Sometimes it happens that Win inserts additional events on some key 1038 * press/release. For example, it prepends ALT_GR in German layout with 1039 * the VK_LCONTROL vkey with curious 0x21D scan code (seems to be necessary 1040 * to specially treat ALT_GR to enter additional chars to regular apps). 1041 * These events are definitely unwanted in VM, so filter them out. */ 1041 1042 if (hasFocus() && (event.scanCode & ~0xFF)) 1042 1043 return true; … … 1045 1046 return false; 1046 1047 1047 / /it's possible that a key has been pressed while the keyboard was not1048 //captured, but is being released under the capture. Detect this situation1049 //and return false to let Windows process the message normally and update1050 // its key state table (to avoid the stuck key effect).1048 /* it's possible that a key has been pressed while the keyboard was not 1049 * captured, but is being released under the capture. Detect this situation 1050 * and return false to let Windows process the message normally and update 1051 * its key state table (to avoid the stuck key effect). */ 1051 1052 uint8_t what_pressed = (event.flags & 0x01) && (event.vkCode != VK_RSHIFT) 1052 1053 ? IsExtKeyPressed … … 1066 1067 (event.flags & 0xFF) << 24; 1067 1068 1068 / /Windows sets here the extended bit when the Right Shift key is pressed,1069 // which is totally wrong. Undo it.1069 /* Windows sets here the extended bit when the Right Shift key is pressed, 1070 * which is totally wrong. Undo it. */ 1070 1071 if (event.vkCode == VK_RSHIFT) 1071 1072 message.lParam &= ~0x1000000; 1072 1073 1073 / / we suppose here that this hook is always called on the main GUI thread1074 /* we suppose here that this hook is always called on the main GUI thread */ 1074 1075 return winEvent (&message); 1075 1076 } … … 1088 1089 return false; 1089 1090 1090 / / check for the special flag possibly set at the end of this function1091 /* check for the special flag possibly set at the end of this function */ 1091 1092 if ((msg->lParam >> 25) & 0x1) 1092 1093 return false; 1093 1094 1094 // V_DEBUG(( 1095 // "*** WM_%04X: vk=%04X rep=%05d scan=%02X ext=%01d rzv=%01X ctx=%01d prev=%01d tran=%01d", 1096 // msg->message, msg->wParam, 1097 // (msg->lParam & 0xFFFF), 1098 // ((msg->lParam >> 16) & 0xFF), 1099 // ((msg->lParam >> 24) & 0x1), 1100 // ((msg->lParam >> 25) & 0xF), 1101 // ((msg->lParam >> 29) & 0x1), 1102 // ((msg->lParam >> 30) & 0x1), 1103 // ((msg->lParam >> 31) & 0x1) 1104 // )); 1105 // char buf[256]; 1106 // sprintf (buf, 1107 // "WM_%04X: vk=%04X rep=%05d scan=%02X ext=%01d rzv=%01X ctx=%01d prev=%01d tran=%01d", 1108 // msg->message, msg->wParam, 1109 // (msg->lParam & 0xFFFF), 1110 // ((msg->lParam >> 16) & 0xFF), 1111 // ((msg->lParam >> 24) & 0x1), 1112 // ((msg->lParam >> 25) & 0xF), 1113 // ((msg->lParam >> 29) & 0x1), 1114 // ((msg->lParam >> 30) & 0x1), 1115 // ((msg->lParam >> 31) & 0x1)); 1116 // ((QMainWindow*)mainwnd)->statusBar()->message (buf); 1095 #if 0 1096 LogFlow (("*** WM_%04X: vk=%04X rep=%05d scan=%02X ext=%01d rzv=%01X ctx=%01d prev=%01d tran=%01d", 1097 msg->message, msg->wParam, 1098 (msg->lParam & 0xFFFF), 1099 ((msg->lParam >> 16) & 0xFF), 1100 ((msg->lParam >> 24) & 0x1), 1101 ((msg->lParam >> 25) & 0xF), 1102 ((msg->lParam >> 29) & 0x1), 1103 ((msg->lParam >> 30) & 0x1), 1104 ((msg->lParam >> 31) & 0x1))); 1105 char buf [256]; 1106 sprintf (buf, "WM_%04X: vk=%04X rep=%05d scan=%02X ext=%01d rzv=%01X ctx=%01d prev=%01d tran=%01d", 1107 msg->message, msg->wParam, 1108 (msg->lParam & 0xFFFF), 1109 ((msg->lParam >> 16) & 0xFF), 1110 ((msg->lParam >> 24) & 0x1), 1111 ((msg->lParam >> 25) & 0xF), 1112 ((msg->lParam >> 29) & 0x1), 1113 ((msg->lParam >> 30) & 0x1), 1114 ((msg->lParam >> 31) & 0x1)); 1115 mainwnd->statusBar()->message (buf); 1116 #endif 1117 1117 1118 1118 int scan = (msg->lParam >> 16) & 0x7F; 1119 / / scancodes 0x80 and 0x00 are ignored1119 /* scancodes 0x80 and 0x00 are ignored */ 1120 1120 if (!scan) 1121 1121 return true; … … 1123 1123 int vkey = msg->wParam; 1124 1124 1125 // When one of the SHIFT keys is held and one of the cursor movement 1126 // keys is pressed, Windows duplicates SHIFT press/release messages, 1127 // but with the virtual key code set to 0xFF. These virtual keys are also 1128 // sent in some other situations (Pause, PrtScn, etc.). Ignore such messages. 1125 /* When one of the SHIFT keys is held and one of the cursor movement 1126 * keys is pressed, Windows duplicates SHIFT press/release messages, 1127 * but with the virtual key code set to 0xFF. These virtual keys are also 1128 * sent in some other situations (Pause, PrtScn, etc.). Ignore such 1129 * messages. */ 1129 1130 if (vkey == 0xFF) 1130 1131 return true; … … 1142 1143 case VK_MENU: 1143 1144 { 1144 / / overcome stupid Win32 modifier key generalization1145 /* overcome stupid Win32 modifier key generalization */ 1145 1146 int keyscan = scan; 1146 1147 if (flags & KeyExtended) … … 1158 1159 } 1159 1160 case VK_NUMLOCK: 1160 / / Win32 sets the extended bit for the NumLock key. Reset it.1161 /* Win32 sets the extended bit for the NumLock key. Reset it. */ 1161 1162 flags &= ~KeyExtended; 1162 1163 break; … … 1172 1173 if (!result && kbd_captured) 1173 1174 { 1174 / /keyEvent() returned that it didn't process the message, but since the1175 //keyboard is captured, we don't want to pass it to Windows. We just want1176 //to let Qt process the message (to handle non-alphanumeric <HOST>+key1177 //shortcuts for example). So send it direcltly to the window with the1178 // special flag in the reserved area of lParam (to avoid recursion).1175 /* keyEvent() returned that it didn't process the message, but since the 1176 * keyboard is captured, we don't want to pass it to Windows. We just want 1177 * to let Qt process the message (to handle non-alphanumeric <HOST>+key 1178 * shortcuts for example). So send it direcltly to the window with the 1179 * special flag in the reserved area of lParam (to avoid recursion). */ 1179 1180 ::SendMessage (msg->hwnd, msg->message, 1180 1181 msg->wParam, msg->lParam | (0x1 << 25)); … … 1187 1188 1188 1189 /** 1189 * This routine gets X11 events before they are processed by Qt. This is1190 * used for our platform specific keyboard implementation. A return value1191 * of TRUE indicates that the event has been processed by us.1190 * This routine gets X11 events before they are processed by Qt. This is 1191 * used for our platform specific keyboard implementation. A return value 1192 * of TRUE indicates that the event has been processed by us. 1192 1193 */ 1193 bool VBoxConsoleView::x11Event (XEvent *event)1194 bool VBoxConsoleView::x11Event (XEvent *event) 1194 1195 { 1195 1196 static WINEKEYBOARDINFO wineKeyboardInfo; … … 1201 1202 if (attached) 1202 1203 break; 1203 / / else fall through1204 /* else fall through */ 1204 1205 /// @todo (AH) later, we might want to handle these as well 1205 1206 case KeymapNotify: 1206 1207 case MappingNotify: 1207 1208 default: 1208 return false; // pass the event to Qt1209 } 1210 1211 / / perform the mega-complex translation using the wine algorithms1209 return false; /* pass the event to Qt */ 1210 } 1211 1212 /* perform the mega-complex translation using the wine algorithms */ 1212 1213 handleXKeyEvent (this->x11Display(), event, &wineKeyboardInfo); 1213 1214 1214 // char buf[256]; 1215 // sprintf (buf, 1216 // "pressed=%d keycode=%08X state=%08X flags=%08X scan=%04X", 1217 // event->type == XKeyPress ? 1 : 0, event->xkey.keycode, 1218 // event->xkey.state, wineKeyboardInfo.dwFlags, wineKeyboardInfo.wScan); 1219 // ((QMainWindow*)mainwnd)->statusBar()->message (buf); 1215 #if 0 1216 char buf [256]; 1217 sprintf (buf, "pr=%d kc=%08X st=%08X fl=%08lX scan=%04X", 1218 event->type == XKeyPress ? 1 : 0, event->xkey.keycode, 1219 event->xkey.state, wineKeyboardInfo.dwFlags, wineKeyboardInfo.wScan); 1220 mainwnd->statusBar()->message (buf); 1221 LogFlow (("### %s\n", buf)); 1222 #endif 1220 1223 1221 1224 int scan = wineKeyboardInfo.wScan & 0x7F; … … 1922 1925 return; 1923 1926 1924 // on Win32, keyboard grabbing is ineffective, 1925 // low-level keyboard hook is used instead 1926 #ifndef Q_WS_WIN32 1927 /* On Win32, keyboard grabbing is ineffective, a low-level keyboard hook is 1928 * used instead. On X11, we use XGrabKey instead of XGrabKeyboard (called 1929 * by QWidget::grabKeyboard()) because the latter causes problems under 1930 * metacity 2.16 (in particular, due to a bug, a window cannot be moved 1931 * using the mouse if it is currently grabing the keyboard). */ 1932 #if defined (Q_WS_WIN32) 1933 /**/ 1934 #elif defined (Q_WS_X11) 1935 if (capture) 1936 XGrabKey (x11Display(), AnyKey, AnyModifier, 1937 topLevelWidget()->winId(), False, 1938 GrabModeAsync, GrabModeAsync); 1939 else 1940 XUngrabKey (x11Display(), AnyKey, AnyModifier, 1941 topLevelWidget()->winId()); 1942 #else 1927 1943 if (capture) 1928 1944 grabKeyboard();
Note:
See TracChangeset
for help on using the changeset viewer.