[Xcb] No XIfEvent like function in XCB?

Barton C Massey bart at cs.pdx.edu
Mon Sep 15 10:25:55 PDT 2008


In message <20080915121739.3f312322 at before> you wrote:
> for Expose-events it works that way. But after scrolling
> with XCopyArea I used to query corresponding
> GraphicsExpose-events synchronously with XIfEvent to
> archieve a behaviour similar to Windows' ScrollDC function
> (sorry for that ;) ) which returns the uncovered region.

Still not getting the problem.  You have to have some sort
of event loop processing that will repair damage anyway.
Why not just let that take care of your damage from
XCopyArea?

In any case, as far as I know existing servers will generate
the GraphicsExpose events immediately after XCopyArea
completes.  So it should work (although I haven't tried it)
to just call xcb_copy_area_checked() and
xcb_request_check(), then call xcb_wait_for_event() until
you get the GraphicsExpose event with count 0.

> I know that it is almost always better to follow the pure
> async approach, but in real-world software it is likely
> that you run into situations where you have to query the
> events synchronously or filter it by type or other
> criteria. I think there should be some functions to
> examine the queue in XCB like in XLib.

It's not likely to happen.  See the email list archives for
a detailed discussion.  The thread-transparency of XCB
resulted in some design decisions that make it hard to do
this: there really isn't a "queue like in Xlib" in XCB.
Further, the thread-transparency makes it less necessary;
threads are a better mechanism than callbacks for
concurrency anyhow.  XCB is just a protocol binding, not a
giant bag of tricks.  An event queue would be a possible
thing to layer on top of XCB, but it doesn't belong inside
it.

There's code in util/events that layers an event callback
mechanism on top of XCB.  If you just have to have
callbacks, build on top of that---there's a callback there
for GraphicsExpose events.  It's undocumented and provides
kind of an ugly abstraction; please feel free to improve on
it.  In particular, if you feel that you need to enqueue
events rather than handling them for some reason, this would
be the place to put queueing code.

    Bart


More information about the Xcb mailing list