This is the mail archive of the cygwin@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]

Re: cygwin 1.3.2 bug on non-us keyboard layouts


On Fri, Jun 22, 2001 at 12:37:40AM +0200, Corinna Vinschen wrote:
> Oops, a change of 45 lines is not a small patch anymore, unfortunately.

45 is the number wc -l gives; the actual number of code lines touched is
much smaller.

> You would have to fill out the copyright assignment form. Is that ok
> for you?

Yes, but I *hate* snail mail.  Could you look at this patch and tellme
if that is really necessary?

> However, you can send the patch then to the cygwin list if you don't
> want to subscribe to cygwin-patches, of course.

Here it is.  I have tested it on Win98 and on Win2000 with US English
(101), US English (International), Lithuanian (Programers) and German
(Standard) keyboard layouts.

Marius Gedminas
-- 
A bus station is where a bus stops, a train station is where a train stops. On
my desk I have a work station...
Thu Jun 21 22:01:39 2001  Marius Gedminas <mgedmin@delfi.lt>

	* fhandler_console.cc (fhandler_console::read): Detect AltGr more
	robustly on WinNT.
--- fhandler_console.cc.orig	Sun Jun 17 14:15:36 2001
+++ fhandler_console.cc	Thu Jun 21 21:54:51 2001
@@ -289,6 +289,8 @@ fhandler_console::read (void *pv, size_t
 
 #define ich (input_rec.Event.KeyEvent.uChar.AsciiChar)
 #define wch (input_rec.Event.KeyEvent.uChar.UnicodeChar)
+#define ALT_PRESSED (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)
+#define CTRL_PRESSED (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)
 
 	  if (wch == 0 ||
 	      /* arrow/function keys */
@@ -306,8 +308,22 @@ fhandler_console::read (void *pv, size_t
 		 converting a CTRL-U. */
 	      if ((unsigned char)ich > 0x7f)
 		con_to_str (tmp + 1, tmp + 1, 1);
-	      /* Determine if the keystroke is modified by META. */
-	      if (!(input_rec.Event.KeyEvent.dwControlKeyState & meta_mask))
+	      /* Determine if the keystroke is modified by META.  The tricky
+		 part is to distinguish whether the right Alt key should be
+		 recognized as Alt, or as AltGr. */
+	      bool meta;
+	      if (os_being_run == winNT)
+		/* WinNT: AltGr is reported as Ctrl+Alt, and Ctrl+Alt is
+		   treated just like AltGr.  However, if Ctrl+Alt+key generates
+		   an ASCII control character, interpret is as META. */
+		meta = (control_key_state & ALT_PRESSED) != 0
+		       && ((control_key_state & CTRL_PRESSED) == 0
+		           || (ich >= 0 && ich <= 0x1f || ich == 0x7f));
+	      else
+		/* Win9x: there's no way to distinguish Alt from AltGr, so rely
+		   on meta_mask heuristic (see fhandler_console constructor). */
+		meta = (control_key_state & meta_mask) != 0;
+	      if (!meta)
 		toadd = tmp + 1;
 	      else
 		{
@@ -319,6 +335,8 @@ fhandler_console::read (void *pv, size_t
 	    }
 #undef ich
 #undef wch
+#undef ALT_PRESSED
+#undef CTRL_PRESSED
 	  break;
 
 	case MOUSE_EVENT:

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

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