From e6b69e8c29469dff4ef0ad4a2bccab63efa6af4f Mon Sep 17 00:00:00 2001 From: Ian Osgood Date: Sat, 7 Oct 2006 13:24:15 -0700 Subject: [PATCH] Update demos for removal of XID structs and xcb_poll_for_reply error param. --- app/xte/xte.c | 23 ++++++++++---------- hypnomoire.c | 26 +++++++++++------------ neko/README | 5 +++-- neko/xcbneko.c | 53 ++++++++++++++++++---------------------------- rendertest.c | 54 +++++++++++++++++++++++------------------------ reply_formats.c | 22 +++++++++---------- tests/flames.c | 25 +++++++++++----------- tests/julia.c | 22 +++++++++---------- tests/lissajoux.c | 20 +++++++++--------- xcb-test.c | 15 ++++++------- xcbdpyinfo.c | 2 +- xcbrandr.c | 2 +- xcbxvinfo.c | 8 +++---- 13 files changed, 131 insertions(+), 146 deletions(-) diff --git a/app/xte/xte.c b/app/xte/xte.c index 006b672..b400879 100644 --- a/app/xte/xte.c +++ b/app/xte/xte.c @@ -23,7 +23,6 @@ like a little man in your computer. :) */ #include -#define X_H /* make sure we aren't using symbols from X.h */ #include #include #include @@ -60,7 +59,7 @@ uint8_t thing_to_keycode( xcb_connection_t *c, char *thing ) { } #else /* For now, assume thing[0] == Latin-1 keysym */ - ks.id = (uint8_t)thing[0]; + ks = (uint8_t)thing[0]; #endif kc = xcb_key_symbols_get_keycode( syms, ks ); @@ -68,7 +67,7 @@ uint8_t thing_to_keycode( xcb_connection_t *c, char *thing ) { dmsg( 1, "String '%s' maps to keysym '%d'\n", thing, ks ); dmsg( 1, "String '%s' maps to keycode '%d'\n", thing, kc ); - return( kc.id ); + return( kc ); } /* xcb_test_fake_input(type,detail,time,window,x,y,device) */ @@ -117,9 +116,9 @@ void send_key( xcb_connection_t *c, char *thing ) { const char *cap = "~!@#$%^&*()_+{}|:\"<>?"; if (thing[0] >= 'A' && thing[0] <= 'Z') - wrap_code = xcb_key_symbols_get_keycode( syms, shift ).id; + wrap_code = xcb_key_symbols_get_keycode( syms, shift ); else if (strchr(cap, thing[0]) != NULL) - wrap_code = xcb_key_symbols_get_keycode( syms, shift ).id; + wrap_code = xcb_key_symbols_get_keycode( syms, shift ); #endif code = thing_to_keycode( c, thing ); @@ -201,18 +200,18 @@ void process_command( xcb_connection_t *c, const char *cmd ) { }else if( IS_CMD( cmd, "sym " ) ) { xcb_keysym_t sym; xcb_keycode_t code; - sscanf( str, "sym %x", &sym.id ); + sscanf( str, "sym %x", &sym ); code = xcb_key_symbols_get_keycode( syms, sym ); - fake_input( c, XCB_KEY_PRESS, code.id ); - fake_input( c, XCB_KEY_RELEASE, code.id ); + fake_input( c, XCB_KEY_PRESS, code ); + fake_input( c, XCB_KEY_RELEASE, code ); }else if( IS_CMD( cmd, "symdown " ) ) { xcb_keysym_t sym; - sscanf( str, "symdown %x", &sym.id ); - fake_input( c, XCB_KEY_PRESS, xcb_key_symbols_get_keycode( syms, sym ).id ); + sscanf( str, "symdown %x", &sym ); + fake_input( c, XCB_KEY_PRESS, xcb_key_symbols_get_keycode( syms, sym ) ); }else if( IS_CMD( cmd, "symup " ) ) { xcb_keysym_t sym; - sscanf( str, "symup %x", &sym.id ); - fake_input( c, XCB_KEY_RELEASE, xcb_key_symbols_get_keycode( syms, sym ).id ); + sscanf( str, "symup %x", &sym ); + fake_input( c, XCB_KEY_RELEASE, xcb_key_symbols_get_keycode( syms, sym ) ); }else{ fprintf( stderr, "Unknown command '%s'\n", cmd ); } diff --git a/hypnomoire.c b/hypnomoire.c index b82caf0..cab3c31 100644 --- a/hypnomoire.c +++ b/hypnomoire.c @@ -51,7 +51,7 @@ static void get_depth() depth = geom->depth; fprintf(stderr, "Root 0x%x: %dx%dx%d\n", - root->root.xid, geom->width, geom->height, geom->depth); + root->root, geom->width, geom->height, geom->depth); free(geom); } @@ -69,9 +69,9 @@ int main() root = xcb_aux_get_screen(c, screen_num); get_depth(); - rootwin.window = root->root; - white = xcb_gcontext_new(c); - black = xcb_gcontext_new(c); + rootwin = root->root; + white = xcb_generate_id(c); + black = xcb_generate_id(c); pthread_create(&thr, 0, event_thread, 0); @@ -114,8 +114,8 @@ void *run(void *param) xcb_point_t line[2]; - windows[idx].w.window = xcb_window_new(c); - windows[idx].p.pixmap = xcb_pixmap_new(c); + windows[idx].w = xcb_generate_id(c); + windows[idx].p = xcb_generate_id(c); windows[idx].width = 300; line[0].x = xo = windows[idx].width / 2; windows[idx].height = 300; @@ -136,17 +136,17 @@ void *run(void *param) values[1] = XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_EXPOSURE; values[2] = XCB_EVENT_MASK_BUTTON_PRESS; - xcb_create_window(c, depth, windows[idx].w.window, root->root, + xcb_create_window(c, depth, windows[idx].w, root->root, /* x */ 0, /* y */ 0, windows[idx].width, windows[idx].height, /* border */ 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, /* visual */ root->root_visual, mask, values); - xcb_map_window(c, windows[idx].w.window); + xcb_map_window(c, windows[idx].w); xcb_create_pixmap(c, depth, - windows[idx].p.pixmap, windows[idx].w, + windows[idx].p, windows[idx].w, windows[idx].width, windows[idx].height); xcb_poly_fill_rectangle(c, windows[idx].p, white, 1, &rect); @@ -183,7 +183,7 @@ int lookup_window(xcb_window_t w) { int i; for(i = 0; i < WINS; ++i) - if(windows[i].w.window.xid == w.xid) + if(windows[i].w == w) return i; return -1; } @@ -221,11 +221,11 @@ void *event_thread(void *param) fprintf(stderr, "ButtonRelease on unknown window!\n"); else { - if(bre->detail.id == XCB_BUTTON_INDEX_1) + if(bre->detail == XCB_BUTTON_INDEX_1) windows[idx].angv = -windows[idx].angv; - else if(bre->detail.id == XCB_BUTTON_INDEX_4) + else if(bre->detail == XCB_BUTTON_INDEX_4) windows[idx].angv += 0.001; - else if(bre->detail.id == XCB_BUTTON_INDEX_5) + else if(bre->detail == XCB_BUTTON_INDEX_5) windows[idx].angv -= 0.001; } } diff --git a/neko/README b/neko/README index df81d58..c07a81b 100644 --- a/neko/README +++ b/neko/README @@ -2,7 +2,6 @@ XCB TODO -------- * DEBUG not supported * -geometry not supported -* -iconic not supported (don't like the util interfaces) XCB ENHANCEMENTS ---------------- @@ -11,6 +10,9 @@ XCB ENHANCEMENTS * no X resource cleanup. OK? * convert to use threading * multi-neko! + +-- iano@quirkster.com >^.^< + ======================= This is XNeko. @@ -21,7 +23,6 @@ Don't look at the code. ----------------------- INSTALLATION ----------------------- -% xmkmf -a % make Dat's it. diff --git a/neko/xcbneko.c b/neko/xcbneko.c index bb81f70..32ac535 100644 --- a/neko/xcbneko.c +++ b/neko/xcbneko.c @@ -21,9 +21,8 @@ #include #include #else -#define X_H /* make sure we aren't using symbols from X.h */ #include -/*#include */ +/*#include */ #include /* xcb_aux_get_screen_t */ #include #include /* STRING atom */ @@ -403,19 +402,16 @@ xcb_pixmap_t CreatePixmapFromBitmapData( xcb_connection_t *c, xcb_window_t window, char *data, uint16_t w, uint16_t h, uint32_t fg, uint32_t bg, uint32_t depth) { - xcb_drawable_t drawable; - xcb_pixmap_t bitmap = xcb_pixmap_new( c ); + xcb_pixmap_t bitmap = xcb_generate_id( c ); - drawable.window = window; - xcb_create_pixmap( c, depth, bitmap, drawable, w, h ); + xcb_create_pixmap( c, depth, bitmap, window, w, h ); - xcb_gcontext_t gc = xcb_gcontext_new( c ); + xcb_gcontext_t gc = xcb_generate_id( c ); uint32_t mask = (depth==1 ? 0 : XCB_GC_FOREGROUND | XCB_GC_BACKGROUND); uint32_t values[] = { fg, bg }; - drawable.pixmap = bitmap; - xcb_create_gc( c, gc, drawable, mask, values ); + xcb_create_gc( c, gc, bitmap, mask, values ); /* XImage attributes: bpp=1, xoffset=0, byte_order=bit_order=LSB, unit=8, pad=8, bpl=(w+7/8) */ @@ -453,7 +449,7 @@ xcb_pixmap_t CreatePixmapFromBitmapData( xcb_connection_t *c, screen->bitmap_format_scanline_unit left_pad = (0 + 0) & (32 - 1) = 0 */ - xcb_put_image( c, format, drawable, gc, + xcb_put_image( c, format, bitmap, gc, w, h, 0, 0, 0, 1, /* left_pad, depth */ bufLen, buf); @@ -483,7 +479,6 @@ xcb_pixmap_t CreateBitmapFromData(xcb_connection_t *c, xcb_window_t window, void InitBitmapAndGCs(void) { BitmapGCData *BitmapGCDataTablePtr; uint32_t theGCValues[5]; - xcb_drawable_t drawable; drawable.window = theWindow; theGCValues[0] = XCB_GX_COPY; @@ -505,10 +500,10 @@ void InitBitmapAndGCs(void) { BitmapGCDataTablePtr->PixelHeight, theFgPixel, theBgPixel, theScreen->root_depth); - theGCValues[4] = BitmapGCDataTablePtr->BitmapCreatePtr->xid; /* tile */ + theGCValues[4] = *(BitmapGCDataTablePtr->BitmapCreatePtr); /* tile */ - *(BitmapGCDataTablePtr->GCCreatePtr) = xcb_gcontext_new( xc ); - xcb_create_gc( xc, *(BitmapGCDataTablePtr->GCCreatePtr), drawable, + *(BitmapGCDataTablePtr->GCCreatePtr) = xcb_generate_id( xc ); + xcb_create_gc( xc, *(BitmapGCDataTablePtr->GCCreatePtr), theWindow, XCB_GC_FUNCTION | XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FILL_STYLE | XCB_GC_TILE, theGCValues ); @@ -627,7 +622,7 @@ InitScreen( char *DisplayName, char *theGeometry, char *theTitle, Bool iconicSta exit( 1 ); } - theCursor = xcb_cursor_new( xc ); + theCursor = xcb_generate_id( xc ); xcb_create_cursor ( xc, theCursor, theCursorSource, theCursorMask, blackRep->visual_red, blackRep->visual_green, blackRep->visual_blue, whiteRep->visual_red, whiteRep->visual_green, whiteRep->visual_blue, @@ -639,7 +634,7 @@ InitScreen( char *DisplayName, char *theGeometry, char *theTitle, Bool iconicSta free(whiteRep); if ( useRoot ) { - uint32_t rootAttributes[] = { theBgPixel, EVENT_MASK_ROOT, theCursor.xid }; + uint32_t rootAttributes[] = { theBgPixel, EVENT_MASK_ROOT, theCursor }; theWindow = theScreen->root; xcb_change_window_attributes(xc, theWindow, XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK | XCB_CW_CURSOR, rootAttributes ); @@ -647,9 +642,8 @@ InitScreen( char *DisplayName, char *theGeometry, char *theTitle, Bool iconicSta /* XClearWindow: clear area with all dimensions 0 */ xcb_clear_area( xc, False, theWindow, 0, 0, 0, 0 ); - xcb_drawable_t d = { theWindow }; xcb_get_geometry_reply_t *geometry = xcb_get_geometry_reply( xc, - xcb_get_geometry( xc, d ), NULL); + xcb_get_geometry( xc, theWindow ), NULL); if (geometry) { /* only width & height are used by the program */ WindowWidth = geometry->width; @@ -667,12 +661,12 @@ InitScreen( char *DisplayName, char *theGeometry, char *theTitle, Bool iconicSta theFgPixel, /* border */ False, /* override_redirect */ EVENT_MASK, - theCursor.xid }; + theCursor }; unsigned long theWindowMask = XCB_CW_BACK_PIXEL | XCB_CW_BORDER_PIXEL | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK | XCB_CW_CURSOR; - theWindow = xcb_window_new( xc ); + theWindow = xcb_generate_id( xc ); xcb_create_window( xc, theDepth, theWindow, @@ -784,12 +778,11 @@ SetNekoState( int SetValue ) void DrawNeko( int x, int y, xcb_gcontext_t DrawGC ) { - xcb_drawable_t drawable; drawable.window = theWindow; xcb_rectangle_t rect = { NekoLastX, NekoLastY, BITMAP_WIDTH, BITMAP_HEIGHT }; if ( (x != NekoLastX || y != NekoLastY) && (EventState != DEBUG_LIST) ) { - xcb_poly_fill_rectangle( xc, drawable, SpaceGC, 1, &rect ); + xcb_poly_fill_rectangle( xc, theWindow, SpaceGC, 1, &rect ); rect.x = x; rect.y = y; } @@ -799,7 +792,7 @@ DrawNeko( int x, int y, xcb_gcontext_t DrawGC ) xcb_change_gc( xc, DrawGC, originMask, origin ); /* XSetTSOrigin( theDisplay, DrawGC, x, y ); */ - xcb_poly_fill_rectangle( xc, drawable, DrawGC, 1, &rect ); + xcb_poly_fill_rectangle( xc, theWindow, DrawGC, 1, &rect ); xcb_flush( xc ); @@ -811,10 +804,9 @@ DrawNeko( int x, int y, xcb_gcontext_t DrawGC ) void RedrawNeko(void) { - xcb_drawable_t drawable; drawable.window = theWindow; xcb_rectangle_t rect = { NekoLastX, NekoLastY, BITMAP_WIDTH, BITMAP_HEIGHT }; - xcb_poly_fill_rectangle( xc, drawable, NekoLastGC, 1, &rect ); + xcb_poly_fill_rectangle( xc, theWindow, NekoLastGC, 1, &rect ); xcb_flush( xc ); } @@ -1119,7 +1111,7 @@ ProcessKeyPress( xcb_key_press_event_t *theKeyEvent ) theKeySym = xcb_key_press_lookup_keysym( theKeySyms, theKeyEvent, 1 ); /* KeySym XK_Q == 'Q' */ - if (theKeySym.id == 'Q' && (theKeyEvent->state & XCB_MOD_MASK_1)) + if (theKeySym == 'Q' && (theKeyEvent->state & XCB_MOD_MASK_1)) ReturnState = False; #ifdef DEBUG @@ -1183,7 +1175,7 @@ void NekoAdjust(void) { int IsDeleteMessage(xcb_client_message_event_t *msg) { - return msg->data.data32[0] == deleteWindowAtom.xid; + return msg->data.data32[0] == deleteWindowAtom; } Bool ProcessEvent(void) { @@ -1192,12 +1184,11 @@ Bool ProcessEvent(void) { xcb_expose_event_t *theExposure; xcb_button_press_event_t *theButtonPress; Bool ContinueState = True; - int error = 0; switch ( EventState ) { case NORMAL_STATE: while ( ContinueState && - NULL != (theEvent = xcb_poll_for_event( xc, &error )) ) { /*while ( XCheckMaskEvent( theDisplay, EVENT_MASK, &theEvent ) ) {*/ + NULL != (theEvent = xcb_poll_for_event( xc )) ) { /*while ( XCheckMaskEvent( theDisplay, EVENT_MASK, &theEvent ) ) {*/ switch ( theEvent->response_type & 0x7f ) { case XCB_CONFIGURE_NOTIFY: theConfigureNotification = (xcb_configure_notify_event_t *)theEvent; @@ -1221,7 +1212,7 @@ Bool ProcessEvent(void) { break; case XCB_BUTTON_PRESS: theButtonPress = (xcb_button_press_event_t *)theEvent; - ContinueState = ( theButtonPress->detail.id != 3 ); /* xbutton.button */ + ContinueState = ( theButtonPress->detail != 3 ); /* xbutton.button */ break; /* new: handle ClientMessage */ case XCB_CLIENT_MESSAGE: @@ -1233,8 +1224,6 @@ Bool ProcessEvent(void) { break; } free(theEvent); - if (error != 0) - return False; } /* end while */ break; #ifdef DEBUG diff --git a/rendertest.c b/rendertest.c index 6a22f06..9758574 100644 --- a/rendertest.c +++ b/rendertest.c @@ -53,7 +53,7 @@ int print_formats_info(xcb_render_query_pict_formats_reply_t *reply) xcb_render_pictforminfo_t *forminfo = (xcb_render_pictforminfo_t *)forminfo_iter.data; fprintf(stdout, "PICTFORMINFO #%d\n", 1 + num_formats - forminfo_iter.rem); - fprintf(stdout, " PICTFORMAT ID: %d\n", forminfo->id.xid); + fprintf(stdout, " PICTFORMAT ID: %d\n", forminfo->id); fprintf(stdout, " PICTFORMAT Type: %d\n", forminfo->type); fprintf(stdout, " PICTFORMAT Depth: %d\n", forminfo->depth); fprintf(stdout, " Direct RedShift: %d\n", forminfo->direct.red_shift); @@ -76,7 +76,7 @@ int print_formats_info(xcb_render_query_pict_formats_reply_t *reply) fprintf(stdout, "Screen #%d\n", 1 + num_screens - screen_iter.rem); fprintf(stdout, " Depths for this screen: %d\n", cscreen->num_depths); - fprintf(stdout, " Fallback PICTFORMAT: %d\n", cscreen->fallback.xid); + fprintf(stdout, " Fallback PICTFORMAT: %d\n", cscreen->fallback); depth_iter = xcb_render_pictscreen_depths_iterator(cscreen); num_depths = cscreen->num_depths; @@ -96,8 +96,8 @@ int print_formats_info(xcb_render_query_pict_formats_reply_t *reply) xcb_render_pictvisual_t *cvisual = visual_iter.data; fprintf(stdout, " Visual #%d\n", 1 + num_visuals - visual_iter.rem); - fprintf(stdout, " VISUALID: %d\n", cvisual->visual.id); - fprintf(stdout, " PICTFORMAT: %d\n", cvisual->format.xid); + fprintf(stdout, " VISUALID: %d\n", cvisual->visual); + fprintf(stdout, " PICTFORMAT: %d\n", cvisual->format); xcb_render_pictvisual_next(&visual_iter); } xcb_render_pictdepth_next(&depth_iter); @@ -127,10 +127,10 @@ int draw_window(xcb_connection_t *conn, xcb_render_query_pict_formats_reply_t *r int index; root = xcb_setup_roots_iterator(xcb_get_setup(c)).data; - root_drawable.window = root->root; + root_drawable = root->root; /* Setting query so that it will search for an 8 bit alpha surface. */ - query.id.xid = 0; + query.id = 0; query.type = XCB_RENDER_PICT_TYPE_DIRECT; query.depth = 8; query.direct.red_mask = 0; @@ -143,7 +143,7 @@ int draw_window(xcb_connection_t *conn, xcb_render_query_pict_formats_reply_t *r /* Get the xcb_render_pictformat_t we will use for the alpha mask */ alpha_forminfo_ptr = get_pictforminfo(reply, &query); - alpha_mask_format.xid = alpha_forminfo_ptr->id.xid; + alpha_mask_format = alpha_forminfo_ptr->id; /* resetting certain parts of query to search for the surface format */ query.depth = 32; @@ -151,28 +151,28 @@ int draw_window(xcb_connection_t *conn, xcb_render_query_pict_formats_reply_t *r /* Get the surface forminfo and xcb_render_pictformat_t */ forminfo_ptr = get_pictforminfo(reply, &query); - surface_format.xid = forminfo_ptr->id.xid; + surface_format = forminfo_ptr->id; /* assign XIDs to all of the drawables and pictures */ for(index = 0; index < 4; index++) { - surfaces[index] = xcb_pixmap_new(conn); - pict_surfaces[index] = xcb_render_picture_new(conn); + surfaces[index] = xcb_generate_id(conn); + pict_surfaces[index] = xcb_generate_id(conn); } - alpha_surface = xcb_pixmap_new(conn); - alpha_pict = xcb_render_picture_new(conn); - window = xcb_window_new(conn); - window_pict = xcb_render_picture_new(conn); - window_drawable.window = window; - root_picture = xcb_render_picture_new(conn); + alpha_surface = xcb_generate_id(conn); + alpha_pict = xcb_generate_id(conn); + window = xcb_generate_id(conn); + window_pict = xcb_generate_id(conn); + window_drawable = window; + root_picture = xcb_generate_id(conn); /* Here we will create the pixmaps that we will use */ for(index = 0; index < 4; index++) { - surfaces[index] = xcb_pixmap_new(conn); + surfaces[index] = xcb_generate_id(conn); xcb_create_pixmap(conn, 32, surfaces[index], root_drawable, 600, 600); } - alpha_surface = xcb_pixmap_new(conn); + alpha_surface = xcb_generate_id(conn); xcb_create_pixmap(conn, 8, alpha_surface, root_drawable, 600, 600); /* initialize the value list */ @@ -182,7 +182,7 @@ int draw_window(xcb_connection_t *conn, xcb_render_query_pict_formats_reply_t *r /* Create the window */ xcb_create_window(conn, /* xcb_connection_t */ 0, /* depth, 0 means it will copy it from the parent */ - window, root_drawable.window, /* window and parent */ + window, root_drawable, /* window and parent */ 0, 0, /* x and y */ 600, 600, /* width and height */ 0, /* border width */ @@ -200,12 +200,12 @@ int draw_window(xcb_connection_t *conn, xcb_render_query_pict_formats_reply_t *r value_mask, value_list); xcb_render_create_picture(conn, window_pict, window_drawable, window_format, value_mask, value_list); - tmp.pixmap = alpha_surface; + tmp = alpha_surface; xcb_render_create_picture(conn, alpha_pict, tmp, alpha_mask_format, value_mask, value_list); for(index = 0; index < 4; index++) { - tmp.pixmap = surfaces[index]; + tmp = surfaces[index]; xcb_render_create_picture(conn, pict_surfaces[index], tmp, surface_format, value_mask, value_list); } @@ -437,7 +437,7 @@ xcb_render_pictformat_t get_pictformat_from_visual(xcb_render_query_pict_formats { cvisual = visual_iter.data; - if(cvisual->visual.id == query.id) + if(cvisual->visual == query) { return cvisual->format; } @@ -447,7 +447,7 @@ xcb_render_pictformat_t get_pictformat_from_visual(xcb_render_query_pict_formats } xcb_render_pictscreen_next(&screen_iter); } - return_value.xid = 0; + return_value = 0; return return_value; } @@ -463,7 +463,7 @@ xcb_render_pictforminfo_t *get_pictforminfo(xcb_render_query_pict_formats_reply_ cformat = forminfo_iter.data; xcb_render_pictforminfo_next(&forminfo_iter); - if( (query->id.xid != 0) && (query->id.xid != cformat->id.xid) ) + if( (query->id != 0) && (query->id != cformat->id) ) { continue; } @@ -533,7 +533,7 @@ int main(int argc, char *argv[]) print_formats_info(formats_reply); - forminfo_query.id.xid = 0; + forminfo_query.id = 0; forminfo_query.type = XCB_RENDER_PICT_TYPE_DIRECT; forminfo_query.depth = 8; forminfo_query.direct.red_mask = 0; @@ -543,9 +543,9 @@ int main(int argc, char *argv[]) forminfo_result = get_pictforminfo(formats_reply, &forminfo_query); fprintf(stdout, "\n***** found PICTFORMAT: %d *****\n", - forminfo_result->id.xid); + forminfo_result->id); rootformat = get_pictformat_from_visual(formats_reply, root->root_visual); - fprintf(stdout, "\n***** found root PICTFORMAT: %d *****\n", rootformat.xid); + fprintf(stdout, "\n***** found root PICTFORMAT: %d *****\n", rootformat); #if 0 draw_window(c, formats_reply); diff --git a/reply_formats.c b/reply_formats.c index c7300cd..1644435 100644 --- a/reply_formats.c +++ b/reply_formats.c @@ -14,7 +14,7 @@ int formatGetWindowAttributesReply(xcb_window_t wid, xcb_get_window_attributes_r if(!reply) { fprintf(stderr, "Failed to get attributes for window " WINFMT ".\n", - (unsigned int) wid.xid); + (unsigned int) wid); return 0; } @@ -34,9 +34,9 @@ int formatGetWindowAttributesReply(xcb_window_t wid, xcb_get_window_attributes_r " allEventMasks = 0x%08x\n" " yourEventMask = 0x%08x\n" " doNotPropagateMask = 0x%08x\n", - (unsigned int) wid.xid, + (unsigned int) wid, reply->backing_store, - (unsigned int) reply->visual.id, + (unsigned int) reply->visual, reply->_class, reply->bit_gravity, reply->win_gravity, @@ -46,7 +46,7 @@ int formatGetWindowAttributesReply(xcb_window_t wid, xcb_get_window_attributes_r reply->map_is_installed, reply->map_state, reply->override_redirect, - (unsigned int) reply->colormap.xid, + (unsigned int) reply->colormap, (unsigned int) reply->all_event_masks, (unsigned int) reply->your_event_mask, reply->do_not_propagate_mask); @@ -60,12 +60,12 @@ int formatGetGeometryReply(xcb_window_t wid, xcb_get_geometry_reply_t *reply) if(!reply) { fprintf(stderr, "Failed to get geometry for window " WINFMT ".\n", - (unsigned int) wid.xid); + (unsigned int) wid); return 0; } printf("Geometry for window " WINFMT ": %dx%d%+d%+d\n", - (unsigned int) wid.xid, + (unsigned int) wid, reply->width, reply->height, reply->x, @@ -82,20 +82,20 @@ int formatQueryTreeReply(xcb_window_t wid, xcb_query_tree_reply_t *reply) if(!reply) { fprintf(stderr, "Failed to query tree for window " WINFMT ".\n", - (unsigned int) wid.xid); + (unsigned int) wid); return 0; } printf("Window " WINFMT " has parent " WINFMT ", root " WINFMT ", and %d children%c\n", - (unsigned int) wid.xid, - (unsigned int) reply->parent.xid, - (unsigned int) reply->root.xid, + (unsigned int) wid, + (unsigned int) reply->parent, + (unsigned int) reply->root, (unsigned int) reply->children_len, reply->children_len ? ':' : '.'); for(i = 0; i < reply->children_len; ++i) printf(" window " WINFMT "\n", - (unsigned int) xcb_query_tree_children(reply)[i].xid); + (unsigned int) xcb_query_tree_children(reply)[i]); fflush(stdout); return 1; diff --git a/tests/flames.c b/tests/flames.c index 0557d19..fba49c5 100644 --- a/tests/flames.c +++ b/tests/flames.c @@ -25,7 +25,6 @@ #include #include -#define X_H #include #include #include @@ -104,14 +103,14 @@ flame_init () } screen = xcb_aux_get_screen (f->xcb.c, screen_nbr); - f->xcb.draw.window = screen->root; - f->xcb.gc = xcb_gcontext_new (f->xcb.c); + f->xcb.draw = screen->root; + f->xcb.gc = xcb_generate_id (f->xcb.c); mask = XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES; values[0] = screen->black_pixel; values[1] = 0; /* no graphics exposures */ xcb_create_gc (f->xcb.c, f->xcb.gc, f->xcb.draw, mask, values); - gc = xcb_gcontext_new (f->xcb.c); + gc = xcb_generate_id (f->xcb.c); mask = XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES; values[0] = screen->white_pixel; values[1] = 0; /* no graphics exposures */ @@ -121,9 +120,9 @@ flame_init () mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; values[0] = screen->white_pixel; values[1] = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_BUTTON_PRESS; - f->xcb.draw.window = xcb_window_new (f->xcb.c); + f->xcb.draw = xcb_generate_id (f->xcb.c); xcb_create_window (f->xcb.c, f->xcb.depth, - f->xcb.draw.window, + f->xcb.draw, screen->root, 0, 0, BG_W, BG_H, 0, @@ -132,20 +131,20 @@ flame_init () mask, values); title_set (f, "XCB Flames"); - f->xcb.pixmap.pixmap = xcb_pixmap_new (f->xcb.c); + f->xcb.pixmap = xcb_generate_id (f->xcb.c); xcb_create_pixmap (f->xcb.c, f->xcb.depth, - f->xcb.pixmap.pixmap, f->xcb.draw, + f->xcb.pixmap, f->xcb.draw, BG_W, BG_H); xcb_poly_fill_rectangle(f->xcb.c, f->xcb.pixmap, gc, 1, &rect_coord); - xcb_map_window (f->xcb.c, f->xcb.draw.window); + xcb_map_window (f->xcb.c, f->xcb.draw); xcb_flush (f->xcb.c); - f->xcb.cmap = xcb_colormap_new (f->xcb.c); + f->xcb.cmap = xcb_generate_id (f->xcb.c); xcb_create_colormap (f->xcb.c, XCB_COLORMAP_ALLOC_NONE, f->xcb.cmap, - f->xcb.draw.window, + f->xcb.draw, screen->root_visual); /* Allocation of the flame arrays */ @@ -209,7 +208,7 @@ main () while (1) { - if ((e = xcb_poll_for_event (f->xcb.c, NULL))) + if ((e = xcb_poll_for_event (f->xcb.c))) { switch (e->response_type) { @@ -264,7 +263,7 @@ static void title_set (flame *f, const char *title) atom_name), NULL); xcb_change_property(f->xcb.c, XCB_PROP_MODE_REPLACE, - f->xcb.draw.window, + f->xcb.draw, rep->atom, encoding, 8, strlen (title), title); free (rep); } diff --git a/tests/julia.c b/tests/julia.c index 27d6823..7f184b7 100644 --- a/tests/julia.c +++ b/tests/julia.c @@ -129,50 +129,50 @@ main (int argc, char *argv[]) screen = xcb_aux_get_screen (data.conn, screen_num); data.depth = xcb_aux_get_depth (data.conn, screen); - win.window = screen->root; + win = screen->root; - data.gc = xcb_gcontext_new (data.conn); + data.gc = xcb_generate_id (data.conn); mask = XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES; valgc[0] = screen->black_pixel; valgc[1] = 0; /* no graphics exposures */ xcb_create_gc (data.conn, data.gc, win, mask, valgc); - bgcolor = xcb_gcontext_new (data.conn); + bgcolor = xcb_generate_id (data.conn); mask = XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES; valgc[0] = screen->white_pixel; valgc[1] = 0; /* no graphics exposures */ xcb_create_gc (data.conn, bgcolor, win, mask, valgc); - data.draw.window = xcb_window_new (data.conn); + data.draw = xcb_generate_id (data.conn); mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK | XCB_CW_DONT_PROPAGATE; valwin[0] = screen->white_pixel; valwin[1] = XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_EXPOSURE; valwin[2] = XCB_EVENT_MASK_BUTTON_PRESS; xcb_create_window (data.conn, 0, - data.draw.window, + data.draw, screen->root, 0, 0, W_W, W_H, 10, XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, mask, valwin); - xcb_map_window (data.conn, data.draw.window); + xcb_map_window (data.conn, data.draw); - rect.pixmap = xcb_pixmap_new (data.conn); + rect = xcb_generate_id (data.conn); xcb_create_pixmap (data.conn, data.depth, - rect.pixmap, data.draw, + rect, data.draw, W_W, W_H); xcb_poly_fill_rectangle(data.conn, rect, bgcolor, 1, &rect_coord); - xcb_map_window (data.conn, data.draw.window); + xcb_map_window (data.conn, data.draw); data.format = XCB_IMAGE_FORMAT_Z_PIXMAP; - data.cmap = xcb_colormap_new (data.conn); + data.cmap = xcb_generate_id (data.conn); xcb_create_colormap (data.conn, XCB_COLORMAP_ALLOC_NONE, data.cmap, - data.draw.window, + data.draw, screen->root_visual); palette_julia (&data); diff --git a/tests/lissajoux.c b/tests/lissajoux.c index d512fcd..052d2de 100644 --- a/tests/lissajoux.c +++ b/tests/lissajoux.c @@ -157,7 +157,7 @@ shm_test (Data *datap) assert(shminfo.shmaddr); datap->image->data = shminfo.shmaddr; - shminfo.shmseg = xcb_shm_seg_new (datap->conn); + shminfo.shmseg = xcb_generate_id (datap->conn); xcb_shm_attach (datap->conn, shminfo.shmseg, shminfo.shmid, 0); shmctl_status = shmctl(shminfo.shmid, IPC_RMID, 0); @@ -215,38 +215,38 @@ main (int argc, char *argv[]) screen = xcb_aux_get_screen(data.conn, screen_num); data.depth = xcb_aux_get_depth (data.conn, screen); - win.window = screen->root; + win = screen->root; - data.gc = xcb_gcontext_new (data.conn); + data.gc = xcb_generate_id (data.conn); mask = XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES; valgc[0] = screen->black_pixel; valgc[1] = 0; /* no graphics exposures */ xcb_create_gc (data.conn, data.gc, win, mask, valgc); - bgcolor = xcb_gcontext_new (data.conn); + bgcolor = xcb_generate_id (data.conn); mask = XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES; valgc[0] = screen->white_pixel; valgc[1] = 0; /* no graphics exposures */ xcb_create_gc (data.conn, bgcolor, win, mask, valgc); - data.draw.window = xcb_window_new (data.conn); + data.draw = xcb_generate_id (data.conn); mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK | XCB_CW_DONT_PROPAGATE; valwin[0] = screen->white_pixel; valwin[1] = XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_EXPOSURE; valwin[2] = XCB_EVENT_MASK_BUTTON_PRESS; xcb_create_window (data.conn, 0, - data.draw.window, + data.draw, screen->root, 0, 0, W_W, W_H, 10, XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, mask, valwin); - xcb_map_window (data.conn, data.draw.window); + xcb_map_window (data.conn, data.draw); - rect.pixmap = xcb_pixmap_new (data.conn); + rect = xcb_generate_id (data.conn); xcb_create_pixmap (data.conn, data.depth, - rect.pixmap, data.draw, + rect, data.draw, W_W, W_H); xcb_poly_fill_rectangle(data.conn, rect, bgcolor, 1, &rect_coord); @@ -265,7 +265,7 @@ main (int argc, char *argv[]) t_previous = 0.0; while (1) { - e = xcb_poll_for_event(data.conn, NULL); + e = xcb_poll_for_event(data.conn); if (e) { switch (e->response_type) diff --git a/xcb-test.c b/xcb-test.c index 6d4b604..8de0002 100644 --- a/xcb-test.c +++ b/xcb-test.c @@ -75,7 +75,7 @@ int main(int argc, char **argv) #endif #if 1 - window = xcb_window_new(c); + window = xcb_generate_id(c); #else window = 0; /* should be an invalid ID */ #endif @@ -135,10 +135,8 @@ int main(int argc, char **argv) attr[0] = xcb_get_window_attributes(c, window); #endif #ifdef TEST_GET_GEOMETRY - d.window = root->root; - geom[0] = xcb_get_geometry(c, d); - d.window = window; - geom[1] = xcb_get_geometry(c, d); + geom[0] = xcb_get_geometry(c, root->root); + geom[1] = xcb_get_geometry(c, window); #endif #ifdef TEST_QUERY_TREE # ifdef SUPERVERBOSE /* this produces a lot of output :) */ @@ -175,13 +173,12 @@ int main(int argc, char **argv) treerep[1] = xcb_query_tree_reply(c, tree[1], 0); formatQueryTreeReply(window, treerep[1]); - if(treerep[1] && treerep[1]->parent.xid && treerep[1]->parent.xid != root->root.xid) + if(treerep[1] && treerep[1]->parent && treerep[1]->parent != root->root) { tree[2] = xcb_query_tree(c, treerep[1]->parent); # ifdef TEST_GET_GEOMETRY - d.window = treerep[1]->parent; - geom[2] = xcb_get_geometry(c, d); + geom[2] = xcb_get_geometry(c, treerep[1]->parent); geomrep[2] = xcb_get_geometry_reply(c, geom[2], 0); formatGetGeometryReply(treerep[1]->parent, geomrep[2]); free(geomrep[2]); @@ -231,7 +228,7 @@ int show_event(xcb_generic_event_t *e) void try_events(xcb_connection_t *c) { xcb_generic_event_t *e; - while((e = xcb_poll_for_event(c, 0)) && show_event(e)) + while((e = xcb_poll_for_event(c)) && show_event(e)) /* empty statement */ ; } diff --git a/xcbdpyinfo.c b/xcbdpyinfo.c index fe0145b..ae4b574 100644 --- a/xcbdpyinfo.c +++ b/xcbdpyinfo.c @@ -56,7 +56,7 @@ void print_setup() print_formats(); - printf("\n" "keycode range: minimum %d, maximum %d", xcb_get_setup(c)->min_keycode.id, xcb_get_setup(c)->max_keycode.id); + printf("\n" "keycode range: minimum %d, maximum %d", xcb_get_setup(c)->min_keycode, xcb_get_setup(c)->max_keycode); } void print_formats() diff --git a/xcbrandr.c b/xcbrandr.c index bd22604..65d0bdc 100644 --- a/xcbrandr.c +++ b/xcbrandr.c @@ -416,7 +416,7 @@ main (int argc, char **argv) printf("Got a screen change notify event!\n"); printf(" window = %d\n root = %d\n size_index = %d\n rotation %d\n", - (int) sce->request_window.xid, (int) sce->root.xid, + (int) sce->request_window, (int) sce->root, sce->sizeID, sce->rotation); printf(" timestamp = %d, config_timestamp = %d\n", sce->timestamp, sce->config_timestamp); diff --git a/xcbxvinfo.c b/xcbxvinfo.c index 89691de..95743cf 100644 --- a/xcbxvinfo.c +++ b/xcbxvinfo.c @@ -114,7 +114,7 @@ int main(int argc, char *argv[]) name = ExtractString(xcb_xv_adaptor_info_name(ainfo), xcb_xv_adaptor_info_name_length(ainfo)); fprintf(stdout, " Adaptor #%i: \"%s\"\n", j, name); fprintf(stdout, " number of ports: %i\n", ainfo->num_ports); - fprintf(stdout, " port base: %i\n", ainfo->base_id.xid); + fprintf(stdout, " port base: %i\n", ainfo->base_id); fprintf(stdout, " operations supported: "); free(name); @@ -144,7 +144,7 @@ int main(int argc, char *argv[]) fprintf(stdout, " supported visuals:\n"); for (k=0; k < ainfo->num_formats; k++, format++) fprintf(stdout, " depth %i, visualID 0x%2x\n", - format->depth, format->visual.id); + format->depth, format->visual); attr_rep = xcb_xv_query_port_attributes_reply(c, xcb_xv_query_port_attributes(c, ainfo->base_id), NULL); @@ -179,7 +179,7 @@ int main(int argc, char *argv[]) NULL); the_atom = atom_rep->atom; - if (the_atom.xid != 0) { + if (the_atom != 0) { xcb_xv_get_port_attribute_reply_t *pattr_rep = xcb_xv_get_port_attribute_reply(c, xcb_xv_get_port_attribute(c, ainfo->base_id, the_atom), @@ -226,7 +226,7 @@ int main(int argc, char *argv[]) if(nstrcmp(name, strlen(name), "XV_IMAGE")) { fprintf(stdout, " encoding ID #%i: \"%*s\"\n", - encoding->encoding.xid, + encoding->encoding, strlen(name), name); fprintf(stdout, " size: %i x %i\n", -- 2.34.1