[Xcb] splitting xcb/util

Jamey Sharp jamey at minilop.net
Fri Jul 16 17:45:50 PDT 2010

Hi Michael!

On Fri, Jul 16, 2010 at 1:34 PM, Michael Stapelberg
<michael+xcb at stapelberg.de> wrote:
> What makes you think that? In the example posted above (i3lock), the
> handling is relatively straight-forward as I only need to handle a
> very small number of events, but still the code is quite ugly and
> using xcb-event would have been easier. I can’t imagine the situation
> being better in i3 itself. But maybe you have a good idea of how
> your proposed clearer code could actually look like? :-)

Well... I'd use a switch statement rather than a series of if
statements in the event loop, and I'd throw away the separate
x_event_type function. Then switching to the xcb-event library would
involve almost as much code as writing an event loop directly, and
you'd be pulling in an extra library besides.

If you really want the xcb-event style of event loop, just keep your
own array of function pointers. You don't need a library to do that
for you. But I'd just use a switch statement, since that's idiomatic
for C, often easier to understand at a glance, and generates better

If you can explain what's you're actually finding hard about the code
you're writing, perhaps then we can discuss what to do about it? I'm
always happy to explore better APIs.


More information about the Xcb mailing list