[squeak-dev] Unix keyboard events lose track when multiple keys pressed or keys held down

tim Rowledge tim at rowledge.org
Sat Jan 16 04:51:16 UTC 2021



> On 2021-01-15, at 5:13 PM, tim Rowledge <tim at rowledge.org> wrote:
> 
> Oh well, add more debugging clutter to the VM...
> 

Well. That tells us - 

(handleEvent)X KeyRelease    state 0x0 raw keycode 38
symbolic, keyCode, ucs4: 4fd530, -1, 0
Skip KeyRelease at keyCode/ucs4 test line 3764

Where line 3764 is fairly obvious in -
	KeySym symbolic;
	int keyCode, ucs4;
	if (XPending(stDisplay))
	  {
	    XEvent evt2;
	    XPeekEvent(stDisplay, &evt2);
	    if ((evt2.type == KeyPress) && (evt2.xkey.keycode == evt->xkey.keycode) && ((evt2.xkey.time - evt->xkey.time < 2)))
	    	{
	    		DCONV_PRINTERR("Skip KeyRelease at XPeekEvent check line 3757");
	      		break;
	      	}
	  }
	keyCode= x2sqKey(&evt->xkey, &symbolic);
	ucs4= xkeysym2ucs4(symbolic);
	DCONV_PRINTERR("symbolic, keyCode, ucs4: %x, %d, %x\n", symbolic, keyCode, ucs4);
	if ((keyCode >= 0) || (ucs4 > 0)) <<<<<<<-------- line 3764
	  recordKeyboardEvent(keyCode, EventKeyUp, modifierState, ucs4);
	else DCONV_PRINTERR("Skip KeyRelease at keyCode/ucs4 test line 3764");
      }
      break;

Ah; look at static int x2sqKeyInput() {line 1720} - it carefully does some stuff to track the *single* last key pressed and if the event is a release, tells you what the last press key was and then sets the record of last-press to -1. Thus if we press a second key it destroys any evidence of the prior press and we're screwed.

There's the same stuff in static int x2sqKeyCompositionInput() but *not* in static int x2sqKeyPlain(), though it can still return -1. Might it be that you (Dave) had a VM using that? It looks like we can force use of x2sqKeyPlain() by the cmdline flag '-nointl' and that certainly skips the above problem but unfortunately completely misses the point. The log shows 


(handleEvent)X KeyRelease    state 0x0 raw keycode 38
symbolic, keyCode, ucs4: 1785530, -1, 785530
signalInputEvent
EVENT (recordKeyboardEvent): time: 126350 key up    ` ' (0 = 0x0) ucs4 7886128
(ioGetNextEvent) KEYBOARD evt: time: 126350 char: 0 utf32: 7886128 


 - where the keyCode is still -1 but the ucs4 value is the left-over value from the prior read event, totally confusing the system and creating a nonsense event to pass to the image. Oh and the utf32 value is sometimes(?) nonsensical on a release but  I suspect that is just a dumb side-effect. 

This really pretty ridiculous stuff. I really hope somebody around here actually understands X event stuff!

tim
--
tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
Oyster (n.), a person who sprinkles his conversation with Yiddishisms.




More information about the Squeak-dev mailing list