X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=OSX%2Fjwxyz.m;h=de78750a2080ab87ba1abbde4fe1eb9ca3f6ad67;hp=f9dc5b007b163376c6fd8303b50064cd2164d3bd;hb=b81f521c5ad7022ac12db18ca8fcdd9fb063831e;hpb=c141c2b05e374757b6499d12bb8a6d4d943b1529 diff --git a/OSX/jwxyz.m b/OSX/jwxyz.m index f9dc5b00..de78750a 100644 --- a/OSX/jwxyz.m +++ b/OSX/jwxyz.m @@ -3218,11 +3218,25 @@ XLookupString (XKeyEvent *e, char *buf, int size, KeySym *k_ret, XComposeStatus *xc) { KeySym ks = XKeycodeToKeysym (0, e->keycode, 0); - char c = (char) ks; // could be smarter about modifiers here... + char c = 0; + // Do not put non-ASCII KeySyms like XK_Shift_L and XK_Page_Up in the string. + if ((unsigned int) ks <= 255) + c = (char) ks; + + // Put control characters in the string. Not meta. + if (e->state & ControlMask) { + if (c >= 'a' && c <= 'z') // Upcase control. + c -= 'a'-'A'; + if (c >= '@' && c <= '_') // Shift to control page. + c -= '@'; + if (c == ' ') // C-SPC is NULL. + c = 0; + } + if (k_ret) *k_ret = ks; if (size > 0) buf[0] = c; if (size > 1) buf[1] = 0; - return 0; + return (size > 0 ? 1 : 0); }