This is the mail archive of the cygwin-xfree 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: considering modifier keys after gaining focus


On 1/12/2012 1:19 PM, Oliver Schmidt wrote:
> On 1/11/2012 6:16 PM, Jon TURNEY wrote:
>> Hm... on looking at this again, isn't that code you are adding checking the
>> internal state of non-latching modifiers bogus?  If we release all keys on
>> WM_KILLFOCUS, then the non-latching modifiers will always be clear when the
>> WM_SETFOCUS occurs, so we will always generate the keypress for the modifier.
> 
> Yes, my patch also generates key release events for modifiers despite
> the fact, that all modifier have been released after the xserver looses
> the window focus. When writing the patch, I wasn't sure if this is
> always the case, so I made the code a little bit more "robust" in the
> sense that it tries to correct the modifier keys in any case (so it will
> always work, even if something goes wrong in other code locations).

My answer is perhaps a little bit unexact. To be more precise:

+    BOOL ctrl   = (GetAsyncKeyState (VK_CONTROL) < 0);
+    if (WIN_XOR (internalKeyStates & ControlMask, ctrl))
+      winSendKeyEvent (KEY_LCtrl, ctrl);

The above code fragment will send a key press event for the ctrl key, if
the current "real" ctrl modifier state is pressed and differs from the
xserver's internal key state for ControlMask.

It will send a key release event for the ctrl key, if the current "real"
ctrl modifier state is "not pressed" and differs from the xserver's
internal key state for ControlMask.

Best regards,
Oliver

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://x.cygwin.com/docs/
FAQ:                   http://x.cygwin.com/docs/faq/


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