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)




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]