[Xcb] xlib - xcb question

Josh Triplett josh at freedesktop.org
Mon Dec 4 20:40:02 PST 2006


Peter Hutterer wrote:
> A quick question:
> I have an Xlib program that I would like to intermix with xcb.
> Reason being I need to use a new X extension for which no Xlib  
> implementation exists. There is a XCB extension though.

A phrase we've waited a long time to hear; thanks again. :)

> So my thoughts were that I could use libX11-xcb, get the  
> xcb_connection_t using XGetXCBConnection() and then just port the  
> event loop over.

This should definitely work.

> The old code looks like this
> ========
> XEvent ev;
> XNextEvent(dpy, &ev);
> switch(ev.type)
> {
>     case foo:
> 	handleFooEvent(ev);
> 	break;
> }
> ========
> 
> XCB code should be something like this
> ========
> xcb_generic_event_t* ev;
> ev = xcb_wait_for_event(c);
> switch(ev->response_type)
> {
> 	case foo:
> 	handleXCBFooEvent(ev);
> 	break;
> }
> ========
> 
> The rest of the code should stay the same.
> The problem is that except for some extension events (of the  
> extension without Xlib) I am not actually getting any events, neither  
> expose, nor anything else.
>
> So the question is: am I forgetting something here?

Only one of Xlib or XCB can handle events.  Because Xlib/XCB must maintain
compatibility with standard Xlib, by default Xlib owns the event queue, and
thus you have to use Xlib functions for event handling.  If you want to handle
events with XCB instead, you need to call:
XSetEventQueueOwner(dpy, XCBOwnsEventQueue);
immediately after XOpenDisplay.

- Josh Triplett

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
Url : http://lists.freedesktop.org/archives/xcb/attachments/20061204/38f070ae/signature.pgp


More information about the Xcb mailing list