code: drawterm

Download patch

ref: b9347940d8f079bbf9f5301dc85a2223bdbaea6e
parent: 40db9d5361e9283b53c368eca2f66f0db32cbdd9
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Apr 10 22:19:22 EDT 2016

reverting this megashit

comment is useless, it talks about alt keys without giving any context
the state machine is all spaghetti and hard to understand
    1.39+	if(k==Kalt && e->xany.type == KeyPress)
     1.40+	if(focusarm == 0)
     1.41+	focusarm=2;
     1.42+	else
     1.43+	focusarm=0;
     1.44+	else if(focusarm && e->xany.type == KeyPress)
     1.45+	focusarm--;
     1.46
and then nested if without {}, this sucks
all you need to know is if alt was down, not trying to replicate
kbdfs's compose state (you do not know when compose ends... its not
limited to like two key presses and depends on the characters typed after
its engadged).

what you want is when you loose focus, and alt is only key down, you send
alt [up, down, up] canceling the compose. thats all.

please take your time and make a proper patch.

--
cinap

--- a/gui-x11/x11.c
+++ b/gui-x11/x11.c
@@ -129,7 +129,6 @@
 static uchar			map7to8[128][2];
 static Colormap			xcmap;		/* Default shared colormap  */
 
-static int	focusarm; /* on focusin undo alt when pressed during focus out by sending second alt */
 extern int mousequeue;
 
 /* for copy/paste, lifted from plan9ports */
@@ -303,9 +302,6 @@
 		Button4MotionMask|
 		Button5MotionMask|
 		ExposureMask|
-		EnterWindowMask|
-		LeaveWindowMask|
-		FocusChangeMask|
 		StructureNotifyMask;
 
 	XSelectInput(xkmcon, xdrawable, mask);
@@ -733,13 +729,6 @@
 {
 	KeySym k;
 
-	if(e->xany.type == FocusIn && focusarm){
-		focusarm=0;
-		kbdkey(Kalt, 0);
-		kbdkey(Kalt, 1);
-		return;
-	}
-		
 	/*
 	 * I tried using XtGetActionKeysym, but it didn't seem to
 	 * do case conversion properly
@@ -880,14 +869,6 @@
 	if(k == NoSymbol) {
 		return;
 	}
-
-	if(k==Kalt && e->xany.type == KeyPress)
-		if(focusarm == 0)
-			focusarm=2;
-		else
-			focusarm=0;
-	else if(focusarm && e->xany.type == KeyPress)
-		focusarm--;	
 
 	kbdkey(k, e->xany.type == KeyPress);
 }