URI: 
       tdevdraw: fix handling of compose key on OS X - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit 73b0f029e107c2d015ebb48d59d32f264973de49
   DIR parent a995f469b3e412ae39a57efa4472592a55248aac
  HTML Author: David Jeannot <djeannot24@gmail.com>
       Date:   Mon, 16 Jan 2012 17:08:31 -0500
       
       devdraw: fix handling of compose key on OS X
       
       This implementation is simpler to understand.  It
       removes conflicts with other modifiers and with
       tthe virtual buttons.  Pressing alt during a
       sequence now cancels it correctly.
       
       R=rsc
       CC=plan9port.codebot
       http://codereview.appspot.com/5507049
       
       Diffstat:
         M src/cmd/devdraw/cocoa-screen.m      |      15 ++++-----------
         M src/cmd/devdraw/cocoa-srv.c         |      12 +++++++++++-
       
       2 files changed, 15 insertions(+), 12 deletions(-)
       ---
   DIR diff --git a/src/cmd/devdraw/cocoa-screen.m b/src/cmd/devdraw/cocoa-screen.m
       t@@ -98,7 +98,6 @@ struct
        struct
        {
                NSCursor        *bigarrow;
       -        int                kalting;
                int                kbuttons;
                int                mbuttons;
                NSPoint        mpos;
       t@@ -593,6 +592,7 @@ interpretdeadkey(NSEvent *e)
        static void
        getkeyboard(NSEvent *e)
        {
       +        static int omod;
                NSString *s;
                char c;
                int k, m;
       t@@ -602,8 +602,6 @@ getkeyboard(NSEvent *e)
        
                switch([e type]){
                case NSKeyDown:
       -                in.kalting = 0;
       -
                        s = [e characters];
                        c = [s UTF8String][0];
        
       t@@ -635,15 +633,14 @@ getkeyboard(NSEvent *e)
                                        in.kbuttons |= 4;
                                sendmouse();
                        }else
       -                if(m & NSAlternateKeyMask){
       -                        in.kalting = 1;
       +                if(m&NSAlternateKeyMask && (omod&NSAlternateKeyMask)==0)
                                keystroke(Kalt);
       -                }
                        break;
        
                default:
                        panic("getkey: unexpected event type");
                }
       +        omod = m;
        }
        
        /*
       t@@ -715,12 +712,8 @@ getmouse(NSEvent *e)
                        if(b == 1){
                                m = [e modifierFlags];
                                if(m & NSAlternateKeyMask){
       +                                abortcompose();
                                        b = 2;
       -                                // Take the ALT away from the keyboard handler.
       -                                if(in.kalting){
       -                                        in.kalting = 0;
       -                                        keystroke(Kalt);
       -                                }
                                }else
                                if(m & NSCommandKeyMask)
                                        b = 4;
   DIR diff --git a/src/cmd/devdraw/cocoa-srv.c b/src/cmd/devdraw/cocoa-srv.c
       t@@ -358,15 +358,25 @@ kputc(int c)
                zunlock();
        }
        
       +static int alting;
       +
       +void
       +abortcompose(void)
       +{
       +        if(alting)
       +                keystroke(Kalt);
       +}
       +
        void
        keystroke(int c)
        {
                static Rune k[10];
       -        static int alting, nk;
       +        static int nk;
                int i;
        
                if(c == Kalt){
                        alting = !alting;
       +                nk = 0;
                        return;
                }
                if(!alting){