"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;
static keydest_t old_key_dest = key_none;
static int have_focus;
static void
event_focusout (void)
{
if (in_snd_block->int_val) {
S_BlockSound ();
CDAudio_Pause ();
if (have_focus) {
have_focus = 0;
if (in_snd_block->int_val) {
S_BlockSound ();
CDAudio_Pause ();
}
}
}
static void
event_focusin (void)
{
have_focus = 1;
if (in_snd_block->int_val) {
S_UnblockSound ();
CDAudio_Resume ();

View file

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