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); 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 // Set this true to remember the current state of the keyboard while
// will crab out WireGL. // the window focus is lost, or false to pretend the user is not
bool support_wiregl = config_windisplay.GetBool("support-wiregl", false); // 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 // 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); 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 bool show_fps_meter;
extern float fps_meter_update_interval; extern float fps_meter_update_interval;
extern bool responsive_minimized_fullscreen_window; extern bool responsive_minimized_fullscreen_window;
extern bool hold_keys_across_windows;
extern bool do_vidmemsize_check; extern bool do_vidmemsize_check;
extern bool ime_composition_w; extern bool ime_composition_w;

View File

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