devel  

Re: A bug in xset and a fix for it

David Dawes
Thu, 06 Feb 2003 10:44:34 -0800

On Wed, Feb 05, 2003 at 07:52:16PM +0600, Ivan Pascal wrote:
>David Dawes wrote:
>> >That in turn uses _XReply() to fill in a xkbGetKbdByNameReply struct, and
>> >either that call fails, or the "reported" field of the struct is set to
>> >zero. (line 142 in XKBGetByName.c)
>> 
>> Does the xset call actually change the repeat rate when this happens
>> (with your fix)?  Also, do you need to do anything special to reproduce
>> this?  A check for a NULL return value from XkbGetKeyboard() should be
>> added (and I'll do that), but I'm wondering what ignoring it might be
>> covering up.
>
>  It may seem strange but there really is a big difference between
>an XkbGetKeyboard call and a pair XkbAllocKeyboard - XkbGetControls calls.
>  Since the XkbGetKeyboard call actually use an XkbGetKeyboardByName it does
>its task in a long indirect way:
>- converts all server internal structures into an .xkb file format
>- calls an xkbcomp and passes this text to its input
>- the xkbcomp writes the result as an .xkm file
>- the server reads and parses this file
>- and finally sends the result of parsing to the client
>  In the same time the XkbGetControls just delivers contents of needed
>structures to the client.
>
>  Thus you see there can be many reasons why the XkbGetKeyboard fails but
>the XkbGetControls works well.
>  And I think the right way here isn't to check a NULL result but to get rid
>of the XkbGetKeyboard and use the XkbAllocKeyboard (which allocates a 'base'
>structure for all elements of an xkb description) and some call(s) which
>delivers only parts of a complete xkb description that are really needed for
>an application.  (Unless one really needs a complete description).
>  Regardless on does the XkbGetKeyboard fail or not it is 'too expensive' in
>case one wants to change a couple of flags/values in XKB server structures.

Thanks for the explanation.  I'll remove the XkbGetKeyboard() and just
leave XkbAllocKeyboard().  I guess the same should be done in this code
too:

if (XkbQueryExtension(dpy, &xkbopcode, &xkbevent, &xkberror, &xkbmajor, &xkbmino
r)
    && (xkb = XkbGetKeyboard(dpy,XkbControlsMask,XkbUseCoreKbd)) != NULL
    && XkbGetControls(dpy, XkbRepeatKeysMask, xkb) == Success)
  printf ("  auto repeat delay:  %d    repeat rate:  %d\n",
          xkb->ctrls->repeat_delay,  1000/xkb->ctrls->repeat_interval);


>  Of course there still is a question why the XkbGetKeyboard (one of its steps)
>fails.

Yes.  I guess it's something to do with the configuration.  I couldn't get
it to fail when I tried to reproduce the problem that was reported.

David
-- 
David Dawes
Release Engineer/Architect                      The XFree86 Project
www.XFree86.org/~dawes
_______________________________________________
Devel mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/devel