This is the mail archive of the cygwin-cvs@cygwin.com mailing list for the Cygwin 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]

[newlib-cygwin] cygwin: generate Alt-Numpad characters independent of NumLock state


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=60546ae5299cf8d53d83ba0031e61235413fe535

commit 60546ae5299cf8d53d83ba0031e61235413fe535
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Tue Aug 1 14:10:50 2017 +0200

    cygwin: generate Alt-Numpad characters independent of NumLock state
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/miscfuncs.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/miscfuncs.h b/winsup/cygwin/miscfuncs.h
index eb898e6..3960b54 100644
--- a/winsup/cygwin/miscfuncs.h
+++ b/winsup/cygwin/miscfuncs.h
@@ -20,8 +20,14 @@ details. */
 static inline bool
 is_alt_numpad_key (PINPUT_RECORD pirec)
 {
+  /* Remove lock key state from ControlKeyState.  Do not remove enhanced key
+     state since it helps to distinguish between cursor (EK) and numpad keys
+     (non-EK). */
+  DWORD ctrl_state = pirec->Event.KeyEvent.dwControlKeyState
+		     & ~(CAPSLOCK_ON | NUMLOCK_ON | SCROLLLOCK_ON);
+
   return pirec->Event.KeyEvent.uChar.UnicodeChar == 0
-	 && pirec->Event.KeyEvent.dwControlKeyState == LEFT_ALT_PRESSED
+	 && ctrl_state == LEFT_ALT_PRESSED
 	 && pirec->Event.KeyEvent.wVirtualScanCode >= DIK_NUMPAD7
 	 && pirec->Event.KeyEvent.wVirtualScanCode <= DIK_NUMPAD0
 	 && pirec->Event.KeyEvent.wVirtualScanCode != DIK_SUBTRACT;


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