]> git.decadent.org.uk Git - ion3.git/blobdiff - ioncore/key.c
[svn-upgrade] Integrating new upstream version, ion3 (20070203)
[ion3.git] / ioncore / key.c
index 00848a44e227ec46d25998c947da255d63efc4f7..57ada801f313f85d8f3515f6611e638876e62a2c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * ion/ioncore/key.c
  *
- * Copyright (c) Tuomo Valkonen 1999-2006
+ * Copyright (c) Tuomo Valkonen 1999-2007
  *
  * Ion is free software; you can redistribute it and/or modify it under
  * the terms of the GNU Lesser General Public License as published by
@@ -172,11 +172,20 @@ static bool add_sub(WRegion *reg, uint key, uint state)
 
 
 static XKeyEvent *current_key_event=NULL;
+static uint current_kcb, current_state;
+static bool current_submap;
 
-
-XKeyEvent *ioncore_current_key_event()
+/* Note: state set to AnyModifier for submaps */
+bool ioncore_current_key(uint *kcb, uint *state, bool *sub)
 {
-    return current_key_event;
+    if(current_kcb==0)
+        return FALSE;
+        
+    *kcb=current_kcb;
+    *state=current_state;
+    *sub=current_submap;
+    
+    return TRUE;
 }
 
 
@@ -227,15 +236,16 @@ static bool do_key(WRegion *reg, XKeyEvent *ev)
             if(grabbed)
                 XUngrabKeyboard(ioncore_g.dpy, CurrentTime);
             
-            if(!subs)
-                current_key_event=ev;
-                
+            current_kcb=ev->keycode;
+            current_state=ev->state;
+            current_submap=subs;
+            
             /* TODO: having to pass both mgd and subreg for some handlers
              * to work is ugly and complex.
              */
             extl_call(binding->func, "ooo", NULL, binding_owner, mgd, subreg);
             
-            current_key_event=NULL;
+            current_kcb=0;
             
             if(ev->state!=0 && !subs && binding->wait)
                 waitrelease(oreg);