From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28786 invoked by alias); 6 Sep 2011 07:45:15 -0000 Received: (qmail 28767 invoked by uid 22791); 6 Sep 2011 07:45:12 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mailout-de.gmx.net (HELO mailout-de.gmx.net) (213.165.64.23) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Tue, 06 Sep 2011 07:44:58 +0000 Received: (qmail invoked by alias); 06 Sep 2011 07:44:55 -0000 Received: from 90-190-59-111-wifi.kjj.estpak.ee (EHLO [90.190.59.111]) [90.190.59.111] by mail.gmx.net (mp039) with SMTP; 06 Sep 2011 09:44:55 +0200 Message-ID: <4E65CF75.8050304@gmx.de> Date: Tue, 06 Sep 2011 07:45:00 -0000 From: Oliver Schmidt User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.1) Gecko/20110830 Thunderbird/6.0.1 MIME-Version: 1.0 To: cygwin-xfree Subject: Re: AltGr key mostly fires an additional CONTROL key References: <4E4916B6.9030602@gmx.de> <4E64D020.7000201@dronecode.org.uk> In-Reply-To: <4E64D020.7000201@dronecode.org.uk> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-xfree-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-xfree-owner@cygwin.com Reply-To: cygwin-xfree@cygwin.com Mail-Followup-To: cygwin-xfree@cygwin.com X-SW-Source: 2011-09/txt/msg00005.txt.bz2 Hi Jon, On 9/5/2011 3:35 PM, Jon TURNEY wrote: > comments, as what this code is trying to do is slightly obscure, and I > assume that the old comments about TweakUI being the cause of this are > just wrong (as you don't mention that you have it installed) Yes I didn't test it with Tweak UI and I ignored the comments on Tweak UI. I also think that the old "sleep(0)" workaround for Tweak UI is now not necessary with the new patch. But I kept the changes as minimal as possible and tried to keep existing code as much as it is. >> diff --git a/hw/xwin/winkeybd.c b/hw/xwin/winkeybd.c >> + static Bool hasLastControlL = FALSE; >> + static UINT lastMessage; >> + static WPARAM lastWparam; >> + static LPARAM lastLparam; >> + static LONG lastTime; > > I was going to suggest using static MSG lastMsg, but then I noticed > that lastWparam, lastLparam are completely unused... yes, they are now unused editing relicts from my testing phase... >> + >> + if ((lastMessage == WM_KEYDOWN || lastMessage == >> WM_SYSKEYDOWN) >> + && lastTime == lTime) > > Why is it necessary to check that the last message was WM_(SYS)KEYDOWN > here? hasLastControlL can't get set unless it was? yes you are right: the if condition here is a little over-determined ;-) >> diff --git a/hw/xwin/winwndproc.c b/hw/xwin/winwndproc.c >> + /* Discard fake Ctrl_L presses that precede AltGR on non-US >> keyboards */ >> + if (winIsFakeCtrl_L (message, wParam, lParam)) >> + return 0; >> + >> - /* Discard fake Ctrl_L presses that precede AltGR on non-US >> keyboards */ >> - if (winIsFakeCtrl_L (message, wParam, lParam)) >> - return 0; >> - > > Can you say why it's necessary to change the order here and why this is > the correct ordering? A comment here might be a good idea :-) in the old coding there is this check for generated Windows auto-repeat key events and this check can cause the function to exit: /* * Discard presses generated from Windows auto-repeat */ if (lParam & (1<<30)) { switch (wParam) { /* ago: Pressing LControl while RControl is pressed is * Indicated as repeat. Fix this! */ case VK_CONTROL: case VK_SHIFT: if (winCheckKeyPressed(wParam, lParam)) return 0; break; default: return 0; } } I didn't change this coding and I'm not sure what the funtion winCheckKeyPressed exactly does. However the check winIsFakeCtrl_L must be done before leaving the function because of auto-repeated key events. Otherwise there will be problems with autorepeated AltGr-Keys. These must also be tracked with winIsFakeCtrl_L otherwise autorepeated AltGr keys could produce a "hanging" Control_L key (I had this effect when I tested the patch). So the order has to be changed, because the function winIsFakeCtrl_L now has an internal state due to it's static variables and this state has to be synchronized with the actuel key events. 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/