[Xcb] Searching for tutorials

Uli Schlachter psychon at znc.in
Tue Aug 12 10:07:35 PDT 2014


Hi Patrick,

On 06.08.2014 23:09, Patrick wrote:
> Hi Everyone
> 
> This is my first post here.
> 
> I am trying my very best to follow along with this tutorial:
> http://www.x.org/releases/X11R7.6/doc/libxcb/tutorial/index.html
> 
> There is the reference manual and many tiny snippets of code on the 
> internet. I am now understanding about 60-70% of what I need to 
> understand, to use the library but I am still struggling with some topics.

Glad that you found the

> It looks like XCB_EVENT_MAKE_EVENT_HANDLER might have something to do 
> with assigning a callback function but I can't find enough resources to 
> understand it. Could anyone point me to a tutorial or other resource 
> that would help me figure out how to call foo when the foo button(or 
> window really) is pressed ? Right now I can understand button events but 
> not how to distinguish between them.

Google tells me that XCB_EVENT_MAKE_EVENT_HANDLER comes from xcb-util's event
helper library. I am not sure if that thing is really all that useful, so I
would suggest not using it.

Instead you get events from e.g. xcb_wait_for_event(). This gives you a
xcb_generic_event_t* which contains a reponse_type field. Button events have
XCB_BUTTON_PRESS in this field and the event really is a
xcb_button_press_event_t* in this case.

So the code could look something like:

 xcb_generic_event_t *e = xcb_wait_for_event(connection);
 switch (e->response_type) {
 case XCB_BUTTON_PRESS: {
     xcb_button_press_event_t *event = e;
     printf("Button %d pressed\n", (int) event->detail);
     break;
 }
 free(e);

However, I guess that your tutorial already explains this and the "Receiving
events: writing the events loop"-section seems to be doing just that.

So I guess: Sorry, but I didn't get your question?

> The tutorial above also discussed how important pixmaps are but I still 
> can't figure out how to write one to a window to turn that window into 
> an image button and so on. Any resources for this would be great too.

The CopyArea request which xcb maps to xcb_copy_area() copies pixels between
drawables. Drawables are pixmaps or windows ("A pixmap is a drawable" just as
"water is a liquid",).

> Thanks for reading my post

Cheers,
Uli
-- 
Happiness can't be found -- it finds you.
 - Majic


More information about the Xcb mailing list