"debounce" (Despair's term:) focus handling in X. Seems multiple focusout

events can arrive when switching workplaces, but only one focusin when
returning. Not good...
This commit is contained in:
Bill Currie 2005-03-06 08:22:15 +00:00
parent 1c21708e8c
commit 1a1d461f0c
2 changed files with 18 additions and 9 deletions

View file

@ -50,20 +50,25 @@ static __attribute__ ((unused)) const char rcsid[] =
cvar_t *in_snd_block; cvar_t *in_snd_block;
static keydest_t old_key_dest = key_none; static keydest_t old_key_dest = key_none;
static int have_focus;
static void static void
event_focusout (void) event_focusout (void)
{ {
if (in_snd_block->int_val) { if (have_focus) {
S_BlockSound (); have_focus = 0;
CDAudio_Pause (); if (in_snd_block->int_val) {
S_BlockSound ();
CDAudio_Pause ();
}
} }
} }
static void static void
event_focusin (void) event_focusin (void)
{ {
have_focus = 1;
if (in_snd_block->int_val) { if (in_snd_block->int_val) {
S_UnblockSound (); S_UnblockSound ();
CDAudio_Resume (); CDAudio_Resume ();

View file

@ -497,18 +497,22 @@ event_button (XEvent *event)
static void static void
event_focusout (XEvent *event) event_focusout (XEvent *event)
{ {
x_have_focus = false; if (x_have_focus) {
XAutoRepeatOn (x_disp); Con_Printf ("focusout\n");
if (in_snd_block->int_val) { x_have_focus = false;
S_BlockSound (); XAutoRepeatOn (x_disp);
CDAudio_Pause (); if (in_snd_block->int_val) {
S_BlockSound ();
CDAudio_Pause ();
}
X11_RestoreGamma ();
} }
X11_RestoreGamma ();
} }
static void static void
event_focusin (XEvent *event) event_focusin (XEvent *event)
{ {
Con_Printf ("focusin\n");
x_have_focus = true; x_have_focus = true;
if (key_dest == key_game) if (key_dest == key_game)
XAutoRepeatOff (x_disp); XAutoRepeatOff (x_disp);