From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21564 invoked by alias); 21 Aug 2011 08:44:31 -0000 Received: (qmail 21498 invoked by uid 22791); 21 Aug 2011 08:44:08 -0000 X-Spam-Check-By: sourceware.org Received: from aquarius.hirmke.de (HELO calimero.vinschen.de) (217.91.18.234) by sourceware.org (qpsmtpd/0.83/v0.83-20-g38e4449) with ESMTP; Sun, 21 Aug 2011 08:43:39 +0000 Received: by calimero.vinschen.de (Postfix, from userid 500) id 89A722C00F3; Sun, 21 Aug 2011 10:43:35 +0200 (CEST) Date: Sun, 21 Aug 2011 08:44:00 -0000 From: Corinna Vinschen To: cygwin-xfree@cygwin.com Subject: Re: considering modifier keys after gaining focus Message-ID: <20110821084335.GA18237@calimero.vinschen.de> Reply-To: cygwin-xfree@cygwin.com Mail-Followup-To: cygwin-xfree@cygwin.com References: <4E4A8D56.6010704@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <4E4A8D56.6010704@gmx.de> User-Agent: Mutt/1.5.21 (2010-09-15) 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/msg00050.txt.bz2 On Aug 16 17:31, Oliver Schmidt wrote: > 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? At that time, doesn't GetAsyncKeyState (VK_RMENU) also return < 0? So, shouldn't something along these lines do the trick: BOOL ctrl = (GetAsyncKeyState (VK_CONTROL) < 0); BOOL shift = (GetAsyncKeyState (VK_CONTROL) < 0); BOOL alt = (GetAsyncKeyState (VK_CONTROL) < 0); BOOL altlang = (GetAsyncKeyState (VK_CONTROL) < 0); if (ctrl & altlang) ctrl = FALSE; if (WIN_XOR (internalKeyStates & ControlMask, ctrl) winSendKeyEvent (KEY_LCtrl, ctrl); if (WIN_XOR (internalKeyStates & ShiftMask, shift)) winSendKeyEvent (KEY_ShiftL, shift); if (WIN_XOR (internalKeyStates & Mod1Mask, alt)) winSendKeyEvent (KEY_Alt, alt); if (WIN_XOR (internalKeyStates & Mod5Mask, altlang)) winSendKeyEvent (KEY_AltLang, altlang); Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Project Co-Leader cygwin AT cygwin DOT com Red Hat -- 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/