This is the mail archive of the cygwin-xfree@cygwin.com mailing list for the Cygwin XFree86 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: New devel to-do item (release all pressed keyboard keys on focus loss)




After some experimentation, I am somewhat confident that the doubling affects
only certain clients, specifically xterm and not emacs or kedit.  I doubt
whether I can figure it out completely without a major time investment.

It is still the case that whatever key I use to dismiss the non-X application
and return focus to X gets passed on to an X client (including emacs and kedit).
I suppose for this the solution would be to make winSendKeyEvent do nothing if
its fDown already matches the array element (since in this case both would be
false), but I fear that such a change might adversely affect other code that I
don't know about.  Perhaps we want a g_fLostFocus flag that winSendKeyEvent
resets the first time it's called after X regains focus.

By the way, the same thing happens for mouse buttons as for keys.  If I have a
mouse button down when a popup appears, X wrongly considers the button to be
down when it gets focus back.  In practice, I find this more amusing than
annoying, but I suppose in some situations it could cause problems.

Thanks for your help.

-John





"Harold Hunt" <huntharo@msu.edu> on 04-12-2001 09:19:48 PM

To:   John Tobey/Intdata@INTDATA
cc:   "cygx" <cygwin-xfree@cygwin.com>

Subject:  RE: New devel to-do item (release all pressed keyboard keys on focus
      loss)




Looks good to me.  I agree that testing this for a bit would be a good idea.
I wouldn't want to commit it until we figure out what is causing the extra
key stroke that you talk about.

Good work,

Harold

> -----Original Message-----
> From: John_Tobey@notes.intdata.com [mailto:John_Tobey@notes.intdata.com]
> Sent: Tuesday, December 04, 2001 5:10 PM
> To: Harold Hunt
> Cc: cygx
> Subject: RE: New devel to-do item (release all pressed keyboard keys on
> focus loss)
>
>
>
>
> Thanks for the help.  It sort of works now.  I see no autorepeat,
> but there
> seems to be one extra keystroke received.  I have not tested
> enough to be sure
> what the new behavior is.  Perhaps the fake winSendKeyEvent(i, FALSE) is
> interpreted as a key event, which in addition to the original
> keydown results in
> a double keystroke seen by the application.
>
> This happens only in conjunction with an asynchronous focus loss,
> and it beats
> the earlier behavior, but perhaps it could be improved upon.  I
> don't have any
> more time to work on it today.  I would like to try using the new
> server for a
> while before I suggest applying this patch.
>
> Fiddling with InitInput.c and winwndproc.c as you suggested did not have a
> noticeable effect.
>
> -John
>
> --- winkeybd.c.dist Tue Dec  4 16:58:07 2001
> +++ winkeybd.c Tue Dec  4 16:42:28 2001
> @@ -391,6 +391,11 @@
>    return FALSE;
>  }
>
> +/*
> + * Remember which keys are down for when we lose focus.
> + */
> +
> +Bool g_fKeyStates[MAP_LENGTH];
>
>  /*
>   * Lift any modifier keys that are pressed
> @@ -399,16 +404,28 @@
>  void
>  winKeybdReleaseModifierKeys ()
>  {
> +  int i;
> +
>    /* Verify that the mi input system has been initialized */
>    if (g_fdMessageQueue == WIN_FD_INVALID)
>      return;
>
> -  winSendKeyEvent (KEY_Alt, FALSE);
> -  winSendKeyEvent (KEY_AltLang, FALSE);
> -  winSendKeyEvent (KEY_LCtrl, FALSE);
> -  winSendKeyEvent (KEY_RCtrl, FALSE);
> -  winSendKeyEvent (KEY_ShiftL, FALSE);
> -  winSendKeyEvent (KEY_ShiftR, FALSE);
> +  for (i = 0; i < MAP_LENGTH; i++)
> +    switch (i)
> +      {
> +      default:
> +    if (g_fKeyStates[i])
> +      {
> +        ErrorF ("Simulating release of key #%d!\n", i);
> +        winSendKeyEvent (i, FALSE);
> +      }
> +    break;
> +      case KEY_CapsLock:
> +      case KEY_ScrollLock:
> +      case KEY_NumLock:
> +      case KEY_HKTG:
> +    break;
> +      }
>  }
>
>
> @@ -430,4 +447,5 @@
>      g_c32LastInputEventTime = GetTickCount ();
>    xCurrentEvent.u.u.detail = dwKey + MIN_KEYCODE;
>    mieqEnqueue (&xCurrentEvent);
> +  g_fKeyStates[dwKey] = fDown;
>  }
>
>






Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]