Re: [hackers] [dwm] fix keysyms processing by kfx_

From: Anselm Garbe <garbeam_AT_gmail.com>
Date: Sun, 8 Oct 2017 08:23:59 +0200

Hi Hiltjo,

I don't really like this change, see below for the reasons.

On 30 September 2017 at 12:39, Hiltjo Posthuma <hiltjo_AT_codemadness.org> wrote:
> --- a/dwm.c
> +++ b/dwm.c
> _AT_@ -988,16 +988,18 @@ void
> keypress(XEvent *e)
> {
> unsigned int i;
> - KeySym keysym;
> + KeySym *keysym;
> XKeyEvent *ev;
> + int keysyms;
>
> ev = &e->xkey;
> - keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
> + keysym = XGetKeyboardMapping(dpy, (KeyCode)ev->keycode, 1, &keysyms);

if (keysym == NULL)
    return;

> for (i = 0; i < LENGTH(keys); i++)
> - if (keysym == keys[i].keysym
> + if (keysym[0] == keys[i].keysym

Previously keysym was safe to be checked in this comparison. Now
keysym could point to NULL I presume and is never checked. Also I
dislike the array syntax here. KeySym is CARD32 afair. So this should
become

if (*keysym == keys[i].keysym

instead.

> + XFree(keysym);

Now we start malloc/free'ing memory on every keypress? This sucks imho.

X has always been retarded.

Tbh I would stick to the deprecated function to avoid this retarded
malloc/free on every(!) keypress that was recognized. What moron came
up with such retarded API design?

BR,
Anselm
Received on Sun Oct 08 2017 - 08:23:59 CEST

This archive was generated by hypermail 2.3.0 : Sun Oct 08 2017 - 08:36:17 CEST