From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22625 invoked by alias); 15 Aug 2011 12:53:33 -0000 Received: (qmail 22617 invoked by uid 22791); 15 Aug 2011 12:53:32 -0000 X-SWARE-Spam-Status: No, hits=0.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,T_TO_NO_BRKTS_FREEMAIL 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; Mon, 15 Aug 2011 12:53:16 +0000 Received: (qmail invoked by alias); 15 Aug 2011 12:53:14 -0000 Received: from p5B08D404.dip0.t-ipconnect.de (EHLO [192.168.178.47]) [91.8.212.4] by mail.gmx.net (mp049) with SMTP; 15 Aug 2011 14:53:14 +0200 Message-ID: <4E4916B6.9030602@gmx.de> Date: Mon, 15 Aug 2011 12:53:00 -0000 From: Oliver Schmidt User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20110624 Thunderbird/5.0 MIME-Version: 1.0 To: cygwin-xfree@cygwin.com Subject: Re: AltGr key mostly fires an additional CONTROL key Content-Type: multipart/mixed; boundary="------------090105070406010804030907" 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-08/txt/msg00035.txt.bz2 --------------090105070406010804030907 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Content-length: 839 Hi, I also had problems with the AltGr key. These could reliably be reproduced by holding the AltGr for some seconds (causing Windows generating auto repeat events). Unfortunately the test version at ftp://cygwin.com/pub/cygwinx/XWin.20110801-git-2d9f9305cb559907.exe.bz2 doesn't fix this problem for me. I discovered that the mechanism in winkeybd.c function winIsFakeCtrl_L had a problem if PeekMessage cannot obtain the next Alt_R message because it is not there. I prepared a patch that remembers the last Ctrl_L event and reacts on a later following Alt_R. It was also necessary to alter the order in winWindowProc in winwndproc.c: the invocation of winIsFakeCtrl_L had to be done before discarding auto-repeated key presses. The attached patch is against the sources of xserver-cygwin-1.10.3-1. Best regards, Oliver --------------090105070406010804030907 Content-Type: text/plain; name="diff2.txt" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="diff2.txt" Content-length: 3879 diff --git a/hw/xwin/winkeybd.c b/hw/xwin/winkeybd.c index e807fc5..460c9d6 100644 --- a/hw/xwin/winkeybd.c +++ b/hw/xwin/winkeybd.c @@ -356,6 +356,12 @@ winIsFakeCtrl_L (UINT message, WPARAM wParam, LPARAM lParam) MSG msgNext; LONG lTime; Bool fReturn; + + static Bool hasLastControlL = FALSE; + static UINT lastMessage; + static WPARAM lastWparam; + static LPARAM lastLparam; + static LONG lastTime; /* * Fake Ctrl_L presses will be followed by an Alt_R keypress @@ -389,9 +395,22 @@ winIsFakeCtrl_L (UINT message, WPARAM wParam, LPARAM lParam) WM_KEYDOWN, WM_SYSKEYDOWN, PM_NOREMOVE); } - if (msgNext.message != WM_KEYDOWN && msgNext.message != WM_SYSKEYDOWN) + if (fReturn && msgNext.message != WM_KEYDOWN && msgNext.message != WM_SYSKEYDOWN) fReturn = 0; + if (!fReturn) + { + hasLastControlL = TRUE; + lastMessage = message; + lastWparam = wParam; + lastLparam = lParam; + lastTime = lTime; + } + else + { + hasLastControlL = FALSE; + } + /* Is next press an Alt_R with the same timestamp? */ if (fReturn && msgNext.wParam == VK_MENU && msgNext.time == lTime @@ -406,11 +425,33 @@ winIsFakeCtrl_L (UINT message, WPARAM wParam, LPARAM lParam) } } + /* + * Check for Alt_R keypress, that was not ready when the + * last Ctrl_L appeared. + */ + else if ((message == WM_KEYDOWN || message == WM_SYSKEYDOWN) + && wParam == VK_MENU + && (HIWORD (lParam) & KF_EXTENDED)) + { + if (hasLastControlL) + { + lTime = GetMessageTime (); + + if ((lastMessage == WM_KEYDOWN || lastMessage == WM_SYSKEYDOWN) + && lastTime == lTime) + { + /* take back the fake ctrl_L key */ + winSendKeyEvent (KEY_LCtrl, FALSE); + } + hasLastControlL = FALSE; + } + } + /* * Fake Ctrl_L releases will be followed by an Alt_R release * with the same timestamp as the Ctrl_L release. */ - if ((message == WM_KEYUP || message == WM_SYSKEYUP) + else if ((message == WM_KEYUP || message == WM_SYSKEYUP) && wParam == VK_CONTROL && (HIWORD (lParam) & KF_EXTENDED) == 0) { @@ -439,9 +480,11 @@ winIsFakeCtrl_L (UINT message, WPARAM wParam, LPARAM lParam) PM_NOREMOVE); } - if (msgNext.message != WM_KEYUP && msgNext.message != WM_SYSKEYUP) + if (fReturn && msgNext.message != WM_KEYUP && msgNext.message != WM_SYSKEYUP) fReturn = 0; + hasLastControlL = FALSE; + /* Is next press an Alt_R with the same timestamp? */ if (fReturn && (msgNext.message == WM_KEYUP @@ -458,6 +501,10 @@ winIsFakeCtrl_L (UINT message, WPARAM wParam, LPARAM lParam) return TRUE; } } + else + { + hasLastControlL = FALSE; + } /* Not a fake control left press/release */ return FALSE; diff --git a/hw/xwin/winwndproc.c b/hw/xwin/winwndproc.c index 316cf08..7de5a5d 100644 --- a/hw/xwin/winwndproc.c +++ b/hw/xwin/winwndproc.c @@ -1060,6 +1060,10 @@ winWindowProc (HWND hwnd, UINT message, if ((wParam == VK_LWIN || wParam == VK_RWIN) && !g_fKeyboardHookLL) break; + /* Discard fake Ctrl_L presses that precede AltGR on non-US keyboards */ + if (winIsFakeCtrl_L (message, wParam, lParam)) + return 0; + /* * Discard presses generated from Windows auto-repeat */ @@ -1080,10 +1084,6 @@ winWindowProc (HWND hwnd, UINT message, } } - /* Discard fake Ctrl_L presses that precede AltGR on non-US keyboards */ - if (winIsFakeCtrl_L (message, wParam, lParam)) - return 0; - /* Translate Windows key code to X scan code */ winTranslateKey (wParam, lParam, &iScanCode); --------------090105070406010804030907 Content-Type: text/plain; charset=us-ascii Content-length: 223 -- 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/ --------------090105070406010804030907--