[Xcb] xlib - xcb question

Jamey Sharp jamey at minilop.net
Mon Dec 4 20:53:03 PST 2006


On Tue, Dec 05, 2006 at 02:19:46PM +1030, Peter Hutterer wrote:
> Hey guys,

Hi Peter!

> So my thoughts were that I could use libX11-xcb, get the  
> xcb_connection_t using XGetXCBConnection()

Right! But...

> and then just port the event loop over.

Only one of Xlib or XCB can handle events on a single connection to the
X server, and you have to tell Xlib which it is.

You should find that your program works if you call
XSetEventQueueOwner(dpy, XCBOwnsEventQueue) after opening the Display
but before making any other Xlib calls.

It occurs to me that we haven't really, uh, tested that particular claim
though. So if you have further difficulties please do let us know. :-)

> 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;
> }
> ========

Don't forget to 'free(ev)' somewhere too. :-)

> 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.

It's probably basically coincidence that you got your extension events
but not other kinds. Any time you call into Xlib and it waits for an X
server response, if it owns the event queue, it's going to pull all the
events it can find out of XCB's queue. I bet you got your extension's
events because they came just after you made requests to your extension,
and you didn't make any intervening Xlib calls.

--Jamey
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.freedesktop.org/archives/xcb/attachments/20061204/121b30cb/attachment.pgp


More information about the Xcb mailing list