by default, don't think keys are held down when window focus is lost.

This commit is contained in:
David Rose 2003-07-07 21:09:48 +00:00
parent b4edf464e1
commit 3ea371a282
3 changed files with 39 additions and 22 deletions

View File

@ -33,9 +33,12 @@ float fps_meter_update_interval = max(0.5,config_windisplay.GetFloat("fps-meter-
bool responsive_minimized_fullscreen_window = config_windisplay.GetBool("responsive-minimized-fullscreen-window",false);
// Set this true to not attempt to use any of the function calls that
// will crab out WireGL.
bool support_wiregl = config_windisplay.GetBool("support-wiregl", false);
// Set this true to remember the current state of the keyboard while
// the window focus is lost, or false to pretend the user is not
// holding down any keys while the window focus is lost. In either
// case it should accurately restore the correct keyboard state when
// the window focus is regained.
bool hold_keys_across_windows = config_windisplay.GetBool("hold-keys-across-windows", false);
// if true, use ddraw's GetAvailVidMem to fail if driver says it has too little video mem
bool do_vidmemsize_check = config_windisplay.GetBool("do-vidmemsize-check", true);

View File

@ -32,6 +32,7 @@ extern Filename get_mono_cursor_filename();
extern bool show_fps_meter;
extern float fps_meter_update_interval;
extern bool responsive_minimized_fullscreen_window;
extern bool hold_keys_across_windows;
extern bool do_vidmemsize_check;
extern bool ime_composition_w;

View File

@ -994,29 +994,42 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
windisplay_cat.debug()
<< "killfocus\n";
}
if (_lost_keypresses) {
resend_lost_keypresses();
}
// Record the current state of the keyboard when the focus is
// lost, so we can check it for changes when we regain focus.
GetKeyboardState(_keyboard_state);
if (windisplay_cat.is_debug()) {
// Report the set of keys that are held down at the time of
// the killfocus event.
for (int i = 0; i < num_virtual_keys; i++) {
if (i != VK_SHIFT && i != VK_CONTROL && i != VK_MENU) {
if ((_keyboard_state[i] & 0x80) != 0) {
windisplay_cat.debug()
<< "on killfocus, key is down: " << i << " (" << lookup_key(i) << ")\n";
if (!_lost_keypresses) {
// Record the current state of the keyboard when the focus is
// lost, so we can check it for changes when we regain focus.
GetKeyboardState(_keyboard_state);
if (windisplay_cat.is_debug()) {
// Report the set of keys that are held down at the time of
// the killfocus event.
for (int i = 0; i < num_virtual_keys; i++) {
if (i != VK_SHIFT && i != VK_CONTROL && i != VK_MENU) {
if ((_keyboard_state[i] & 0x80) != 0) {
windisplay_cat.debug()
<< "on killfocus, key is down: " << i
<< " (" << lookup_key(i) << ")\n";
}
}
}
}
}
// Now set the flag indicating that some keypresses from now
// on may be lost.
_lost_keypresses = true;
if (!hold_keys_across_windows) {
// If we don't want to remember the keystate while the
// window focus is lost, then generate a keyup event
// right now for each key currently held.
for (int i = 0; i < num_virtual_keys; i++) {
if (i != VK_SHIFT && i != VK_CONTROL && i != VK_MENU) {
if ((_keyboard_state[i] & 0x80) != 0) {
handle_keyrelease(lookup_key(i));
_keyboard_state[i] &= ~0x80;
}
}
}
}
// Now set the flag indicating that some keypresses from now
// on may be lost.
_lost_keypresses = true;
}
break;
case WM_SETFOCUS: