From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4410 invoked by alias); 16 Aug 2011 15:31:59 -0000 Received: (qmail 4134 invoked by uid 22791); 16 Aug 2011 15:31:57 -0000 X-SWARE-Spam-Status: No, hits=-0.4 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; Tue, 16 Aug 2011 15:31:43 +0000 Received: (qmail invoked by alias); 16 Aug 2011 15:31:40 -0000 Received: from p5B08E01D.dip0.t-ipconnect.de (EHLO [192.168.178.47]) [91.8.224.29] by mail.gmx.net (mp023) with SMTP; 16 Aug 2011 17:31:40 +0200 Message-ID: <4E4A8D56.6010704@gmx.de> Date: Tue, 16 Aug 2011 15:31: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: considering modifier keys after gaining focus Content-Type: multipart/mixed; boundary="------------020906090702030907070509" 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/msg00041.txt.bz2 --------------020906090702030907070509 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1076 Hi, I had the problem, that the state of the modifier keys was lost when a window is created (or raised). Example: in window A Ctrl + some key opens a window B, then in window B Ctrl + some other key triggers the next action. However after the opening of window B the Ctrl key has to be released and pressed again. If the user keeps the Ctrl key holding when the window B is opened, the next key press X will be interpreted as X and not as Ctrl+X. I send a patch to fix this problem with this email: I just extended the function winRestoreModeKeyStates in winkeybd.c to consider not only the mode switch key but also the modifiers Ctrl, Shift, Alt/AltGr by using the Windows function GetAsyncKeyState. This patch works fine for me. However one problem is unsolved: if the key combination for opening window B (in the above example) is an AltGr key combination, the GetAsyncKeyState will also report, that the Ctrl key is pressed, which is not true, since this is the well known Windows fake Ctrl_L :-( Any suggestions how to solve this? Best regards, Oliver --------------020906090702030907070509 Content-Type: text/plain; name="diff03.txt" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="diff03.txt" Content-length: 1675 diff --git a/cygwin/hw/xwin/winkeybd.c b/cygwin/hw/xwin/winkeybd.c index 9e5a9b0..e807fc5 100644 --- a/cygwin/hw/xwin/winkeybd.c +++ b/cygwin/hw/xwin/winkeybd.c @@ -255,6 +255,7 @@ void winRestoreModeKeyStates (void) { DWORD dwKeyState; + BOOL modifierPressed; BOOL processEvents = TRUE; unsigned short internalKeyStates; @@ -282,6 +283,34 @@ winRestoreModeKeyStates (void) * have a logical XOR operator, so we use a macro instead. */ + modifierPressed = (GetAsyncKeyState (VK_CONTROL) < 0); + if (WIN_XOR (internalKeyStates & ControlMask, modifierPressed)) + { + if (modifierPressed) winSendKeyEvent (KEY_LCtrl, TRUE); + else winSendKeyEvent (KEY_LCtrl, FALSE); + } + + modifierPressed = (GetAsyncKeyState (VK_SHIFT) < 0); + if (WIN_XOR (internalKeyStates & ShiftMask, modifierPressed)) + { + if (modifierPressed) winSendKeyEvent (KEY_ShiftL, TRUE); + else winSendKeyEvent (KEY_ShiftL, FALSE); + } + + modifierPressed = (GetAsyncKeyState (VK_LMENU) < 0); + if (WIN_XOR (internalKeyStates & Mod1Mask, modifierPressed)) + { + if (modifierPressed) winSendKeyEvent (KEY_Alt, TRUE); + else winSendKeyEvent (KEY_Alt, FALSE); + } + + modifierPressed = (GetAsyncKeyState (VK_RMENU) < 0); + if (WIN_XOR (internalKeyStates & Mod5Mask, modifierPressed)) + { + if (modifierPressed) winSendKeyEvent (KEY_AltLang, TRUE); + else winSendKeyEvent (KEY_AltLang, FALSE); + } + /* Has the key state changed? */ dwKeyState = GetKeyState (VK_NUMLOCK) & 0x0001; if (WIN_XOR (internalKeyStates & NumLockMask, dwKeyState)) --------------020906090702030907070509 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/ --------------020906090702030907070509--