儲存庫 vbox 的更動 37239
- 時間撮記:
- 2011-5-27 下午03:20:05 (13 年 以前)
- 位置:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- 檔案:
-
- 修改 2 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp
r36853 r37239 1110 1110 #endif 1111 1111 1112 bool UIKeyboardHandler::keyEvent(int iKey, uint8_t uScan, int fFlags, ulong uScreenId, wchar_t *pUniKey /* = 0 */) 1113 { 1114 /* Get host-combo key list: */ 1115 QSet<int> allHostComboKeys = UIHotKeyCombination::toKeyCodeList(m_globalSettings.hostCombo()).toSet(); 1116 1117 /* Update the map of pressed host-combo keys: */ 1118 if (allHostComboKeys.contains(iKey)) 1119 { 1120 if (fFlags & KeyPressed) 1121 { 1122 if (!m_pressedHostComboKeys.contains(iKey)) 1123 m_pressedHostComboKeys.insert(iKey, uScan); 1124 else if (m_bIsHostComboPressed) 1125 return true; 1126 } 1127 else 1128 { 1129 if (m_pressedHostComboKeys.contains(iKey)) 1130 m_pressedHostComboKeys.remove(iKey); 1131 } 1132 } 1133 /* Check if we are currently holding FULL host-combo: */ 1134 bool fIsFullHostComboPresent = !allHostComboKeys.isEmpty() && allHostComboKeys == m_pressedHostComboKeys.keys().toSet(); 1135 /* Check if currently pressed/released key had changed host-combo state: */ 1136 const bool isHostComboStateChanged = (!m_bIsHostComboPressed && fIsFullHostComboPresent) || 1137 ( m_bIsHostComboPressed && !fIsFullHostComboPresent); 1138 1139 #ifdef Q_WS_WIN 1140 if (m_bIsHostComboPressed || isHostComboStateChanged) 1141 { 1142 /* Currently this is used in winLowKeyboardEvent() only: */ 1143 m_bIsHostkeyInCapture = m_fIsKeyboardCaptured; 1144 } 1145 #endif /* Q_WS_WIN */ 1146 1112 /** 1113 * If the user has just completed a control-alt-del combination then handle 1114 * that. 1115 * @returns true if handling should stop here, false otherwise 1116 */ 1117 bool UIKeyboardHandler::keyEventHandleCAD(uint8_t uScan) 1118 { 1147 1119 /* Check if it's C-A-D and GUI/PassCAD is not true: */ 1148 1120 if (!m_fPassCAD && … … 1164 1136 return true; 1165 1137 } 1138 return false; 1139 } 1140 1141 /** 1142 * Handle a non-special (C-A-D, pause, print) key press or release 1143 * @returns true if handling should stop here, false otherwise 1144 */ 1145 bool UIKeyboardHandler::keyEventHandleNormal(int iKey, uint8_t uScan, int fFlags, LONG *pCodes, uint *puCodesCount) 1146 { 1147 /* Get host-combo key list: */ 1148 QSet<int> allHostComboKeys = UIHotKeyCombination::toKeyCodeList(m_globalSettings.hostCombo()).toSet(); 1149 /* Get the type of key - simple or extended: */ 1150 uint8_t uWhatPressed = fFlags & KeyExtended ? IsExtKeyPressed : IsKeyPressed; 1151 1152 /* If some key was pressed or some previously pressed key was released => 1153 * we are updating the list of pressed keys and preparing scancodes: */ 1154 if ((fFlags & KeyPressed) || (m_pressedKeys[uScan] & uWhatPressed)) 1155 { 1156 /* Check if the guest has the same view on the modifier keys 1157 * (NumLock, CapsLock, ScrollLock) as the X server. 1158 * If not, send KeyPress events to synchronize the state: */ 1159 if (fFlags & KeyPressed) 1160 fixModifierState(pCodes, puCodesCount); 1161 1162 /* Prepend 'extended' scancode if needed: */ 1163 if (fFlags & KeyExtended) 1164 pCodes[(*puCodesCount)++] = 0xE0; 1165 1166 /* Process key-press: */ 1167 if (fFlags & KeyPressed) 1168 { 1169 /* Append scancode: */ 1170 pCodes[(*puCodesCount)++] = uScan; 1171 m_pressedKeys[uScan] |= uWhatPressed; 1172 } 1173 /* Process key-release if that key was pressed before: */ 1174 else if (m_pressedKeys[uScan] & uWhatPressed) 1175 { 1176 /* Append scancode: */ 1177 pCodes[(*puCodesCount)++] = uScan | 0x80; 1178 m_pressedKeys[uScan] &= ~uWhatPressed; 1179 } 1180 1181 /* Update keyboard-captured flag: */ 1182 if (m_fIsKeyboardCaptured) 1183 m_pressedKeys[uScan] |= IsKbdCaptured; 1184 else 1185 m_pressedKeys[uScan] &= ~IsKbdCaptured; 1186 } 1187 /* Ignore key-release if that key was NOT pressed before, 1188 * but only if thats not one of the host-combination keys: */ 1189 else if (!allHostComboKeys.contains(iKey)) 1190 return true; 1191 return false; 1192 } 1193 1194 bool UIKeyboardHandler::keyEvent(int iKey, uint8_t uScan, int fFlags, ulong uScreenId, wchar_t *pUniKey /* = 0 */) 1195 { 1196 /* Get host-combo key list: */ 1197 QSet<int> allHostComboKeys = UIHotKeyCombination::toKeyCodeList(m_globalSettings.hostCombo()).toSet(); 1198 1199 /* Update the map of pressed host-combo keys: */ 1200 if (allHostComboKeys.contains(iKey)) 1201 { 1202 if (fFlags & KeyPressed) 1203 { 1204 if (!m_pressedHostComboKeys.contains(iKey)) 1205 m_pressedHostComboKeys.insert(iKey, uScan); 1206 else if (m_bIsHostComboPressed) 1207 return true; 1208 } 1209 else 1210 { 1211 if (m_pressedHostComboKeys.contains(iKey)) 1212 m_pressedHostComboKeys.remove(iKey); 1213 } 1214 } 1215 /* Check if we are currently holding FULL host-combo: */ 1216 bool fIsFullHostComboPresent = !allHostComboKeys.isEmpty() && allHostComboKeys == m_pressedHostComboKeys.keys().toSet(); 1217 /* Check if currently pressed/released key had changed host-combo state: */ 1218 const bool isHostComboStateChanged = (!m_bIsHostComboPressed && fIsFullHostComboPresent) || 1219 ( m_bIsHostComboPressed && !fIsFullHostComboPresent); 1220 1221 #ifdef Q_WS_WIN 1222 if (m_bIsHostComboPressed || isHostComboStateChanged) 1223 { 1224 /* Currently this is used in winLowKeyboardEvent() only: */ 1225 m_bIsHostkeyInCapture = m_fIsKeyboardCaptured; 1226 } 1227 #endif /* Q_WS_WIN */ 1228 1229 if (keyEventHandleCAD(uScan)) 1230 return true; 1166 1231 1167 1232 /* Preparing the press/release scan-codes array for sending to the guest: … … 1210 1275 /* Common flags handling: */ 1211 1276 else 1212 { 1213 /* Get the type of key - simple or extended: */ 1214 uint8_t uWhatPressed = fFlags & KeyExtended ? IsExtKeyPressed : IsKeyPressed; 1215 1216 /* If some key was pressed or some previously pressed key was released => 1217 * we are updating the list of pressed keys and preparing scancodes: */ 1218 if ((fFlags & KeyPressed) || (m_pressedKeys[uScan] & uWhatPressed)) 1219 { 1220 /* Check if the guest has the same view on the modifier keys 1221 * (NumLock, CapsLock, ScrollLock) as the X server. 1222 * If not, send KeyPress events to synchronize the state: */ 1223 if (fFlags & KeyPressed) 1224 fixModifierState(pCodes, &uCodesCount); 1225 1226 /* Prepend 'extended' scancode if needed: */ 1227 if (fFlags & KeyExtended) 1228 pCodes[uCodesCount++] = 0xE0; 1229 1230 /* Process key-press: */ 1231 if (fFlags & KeyPressed) 1232 { 1233 /* Append scancode: */ 1234 pCodes[uCodesCount++] = uScan; 1235 m_pressedKeys[uScan] |= uWhatPressed; 1236 } 1237 /* Process key-release if that key was pressed before: */ 1238 else if (m_pressedKeys[uScan] & uWhatPressed) 1239 { 1240 /* Append scancode: */ 1241 pCodes[uCodesCount++] = uScan | 0x80; 1242 m_pressedKeys[uScan] &= ~uWhatPressed; 1243 } 1244 1245 /* Update keyboard-captured flag: */ 1246 if (m_fIsKeyboardCaptured) 1247 m_pressedKeys[uScan] |= IsKbdCaptured; 1248 else 1249 m_pressedKeys[uScan] &= ~IsKbdCaptured; 1250 } 1251 /* Ignore key-release if that key was NOT pressed before, 1252 * but only if thats not one of the host-combination keys: */ 1253 else if (!allHostComboKeys.contains(iKey)) 1277 if (keyEventHandleNormal(iKey, uScan, fFlags, pCodes, &uCodesCount)) 1254 1278 return true; 1255 }1256 1279 } 1257 1280 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.h
r36049 r37239 124 124 #endif 125 125 126 bool keyEventHandleCAD(uint8_t uScan); 127 bool keyEventHandleNormal(int iKey, uint8_t uScan, int fFlags, LONG *pCodes, uint *puCodesCount); 126 128 /* Separate function to handle most of existing keyboard-events: */ 127 129 bool keyEvent(int iKey, uint8_t uScan, int fFlags, ulong uScreenId, wchar_t *pUniKey = 0);
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器