[RFC] libxkbcommon: the xkbcomp killer

Dan Nicholson dbn.lists at gmail.com
Thu Apr 23 06:31:02 PDT 2009


Right now there are a couple difficult XKB tasks that the server forks
xkbcomp to accomplish. The main reason for this is that xkbcomp contains a
parser for XKB files and code to do intelligent things with the definitions
in them. However, these interactions are awful and are an endless source of
headaches for users and developers.

Since a discussion with Daniel a few months back, I've been working on
moving the guts of xkbcomp into a library, libxkbcommon, which exposes
appropriate interfaces to the server (blame Daniel if you hate the name
:). A secondary goal of libxkbcommon is to move XKB code duplicated in
the server and client libraries into a reusable location. A few repos
encompass the work I've done.

http://cgit.freedesktop.org/~dbn/libxkbcommon/

The library itself. New interfaces are in <X11/extensions/XKBcommon.h>.
Right now all that's really exposed are compiling keymaps and listing
components (i.e., satisfy the server's requirements).

http://cgit.freedesktop.org/~dbn/kbproto/

Refactored XKB headers. I needed to split the generic datatypes away from
the client side datatypes to avoid pulling in Xlib.h and friends. Should
remain API compatible as the headers just go from XKBstr.h to XKBstr.h +
XKBstrcommon.h (generic types). It's not pretty, but the XKB headers never
were, and I didn't want to have to make a full internal copy of them like
in the server.

http://cgit.freedesktop.org/~dbn/xserver/

Reworked keymap compiling and component listing to use xkbcommon. Current
diffstat:
 configure.ac            |   19 +-
 include/inputstr.h      |    2 +-
 include/xkb-config.h.in |    3 -
 include/xkbfile.h       |   20 -
 include/xkbsrv.h        |   10 +-
 include/xkbstr.h        |   96 +----
 xkb/Makefile.am         |    4 -
 xkb/ddxList.c           |  247 +++-------
 xkb/ddxLoad.c           |  331 +++++---------
 xkb/xkb.c               |   31 +-
 xkb/xkbInit.c           |    5 +-
 xkb/xkbUtils.c          |    2 +-
 xkb/xkbfmisc.c          |    7 +
 xkb/xkmread.c           | 1227 -----------------------------------------------
 xorg-server.pc.in       |    2 +-
 15 files changed, 221 insertions(+), 1785 deletions(-)
 delete mode 100644 xkb/xkmread.c

This is just scratching the surface, though. There is currently a full XKB
stack in the server and a lot of it could just be reused from xkbcommon. A
ton of code is there to support writing a XKB keymap file. Sadly, I can't
kill this yet as it's what makes XkbGetKeyboardByName possible.

On the positive side, the server is now fork-free and xkbcomp is a thing of
the past.

http://cgit.freedesktop.org/~dbn/libxkbfile/

Not really needed, but I moved a couple generic headers to kbproto. This
version just requires a newer kbproto so there aren't header conflicts.

Things still to do:
 - There's a bug somewhere in the keymap compiling that exposed a floating
   point exception in the server xkb code, but my keyboard seems to be
   working correctly
 - Figure out how to do all the "merge new components into current keymap"
   thing required by X_kbGetKbdByName without resorting to generating a
   whole custom keymap file.
 - Refactor more XKB code into xkbcommon and actually start using it in
   xserver, xlib and xkbfile. This work increases the number of full XKB
   stacks to 3. :)

Let me know what you think. I'm open to changing names or interfaces or
whatever, but I think the major direction of the code is a good thing.

--
Dan


More information about the xorg-devel mailing list