[Xcb] splitting xcb/util

Julien Danjou julien at danjou.info
Sat Jul 17 00:28:36 PDT 2010


On Sat, Jul 17 2010, Michael Stapelberg wrote:

> Also, it’s about 20 lines of boilerplate code which does
> not actually handle any event. In my opinion, it could well be hidden in a
> library.

As Jamey said, a switch statement would be nicer. And you can probably
be less verbose - if you really want - with a macro.

#define HANDLE_EVENT(type, func) \
  case XCB_#type: func(event); break;

switch((x_event_type(type)))
{
   HANDLE_EVENT(EXPOSE, handle_expose_event)
   HANDLE_EVENT(KEY_PRESS, handle_key_press)
}

(Not tested, I'm just giving the rough idea here).

-- 
Julien Danjou
// ᐰ <julien at danjou.info>   http://julien.danjou.info
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/xcb/attachments/20100717/0607a55a/attachment.pgp>


More information about the Xcb mailing list