On Sun, Oct 08, 2017 at 08:23:59AM +0200, Anselm Garbe wrote:
> 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
>
Fair points, I'll leave it as is for now until it is changed from deprecated
to removal.
Thanks for the feedback :)
--
Kind regards,
Hiltjo
Received on Mon Oct 09 2017 - 23:18:16 CEST