diff options
author | Bart Massey <bart@cs.pdx.edu> | 2005-12-19 21:06:08 +0000 |
---|---|---|
committer | Bart Massey <bart@cs.pdx.edu> | 2005-12-19 21:06:08 +0000 |
commit | 4e6cd1b290ba236d4751bb159e051d2372980d32 (patch) | |
tree | 7021a015cd2ce4a820ffdf9b04f832329f27c384 | |
parent | 8a72ffb69b6228cb71f15a9e52a61db4f8209ba4 (diff) |
Fixed widgy error handling in rendertest . Made all demos compile cleanly
-ansi -Wall .
-rw-r--r-- | xcb-demo/rendertest.c | 6 | ||||
-rw-r--r-- | xcb-demo/xcbrandr.c | 58 | ||||
-rw-r--r-- | xcb-demo/xdpyinfo.c | 8 |
3 files changed, 44 insertions, 28 deletions
diff --git a/xcb-demo/rendertest.c b/xcb-demo/rendertest.c index 2b88889..9a2840d 100644 --- a/xcb-demo/rendertest.c +++ b/xcb-demo/rendertest.c @@ -18,7 +18,7 @@ XCBRenderPICTFORMINFO *get_pictforminfo(XCBRenderQueryPictFormatsRep *reply, XCB XCBConnection *c; XCBRenderPICTFORMAT pf; -inline XCBRenderFIXED make_fixed(INT16 i, INT16 f) +XCBRenderFIXED make_fixed(INT16 i, INT16 f) { return (i << 16) | (f & 0xffff); } @@ -547,7 +547,9 @@ int main(int argc, char *argv[]) rootformat = get_pictformat_from_visual(formats_reply, root->root_visual); fprintf(stdout, "\n***** found root PICTFORMAT: %ld *****\n", rootformat.xid); - //draw_window(c, formats_reply); +#if 0 + draw_window(c, formats_reply); +#endif /* It's very important to free the replys. We don't want memory leaks. */ free(version_reply); diff --git a/xcb-demo/xcbrandr.c b/xcb-demo/xcbrandr.c index 85a5cca..44b3f3e 100644 --- a/xcb-demo/xcbrandr.c +++ b/xcb-demo/xcbrandr.c @@ -79,9 +79,11 @@ usage(void) /*NOTREACHED*/ } -// Same idea as xc/lib/Xrandr.c (XRRConfigRates). -// Returns the rates for a given screen. -// Would be nice to put in another library or something. +/* + * Same idea as xc/lib/Xrandr.c (XRRConfigRates). + * Returns the rates for a given screen. + * Would be nice to put in another library or something. + */ short* ConfigRates(XCBRandRGetScreenInfoRep *config, int sizeID, int *nrates) { @@ -135,6 +137,11 @@ main (int argc, char **argv) int width = 0, height = 0; int have_pixel_size = 0; XCBGenericError *err; + CARD16 mask = (CARD16) StructureNotifyMask; + CARD32 values[1]; + XCBRandRGetScreenInfoCookie scookie; + int major_version, minor_version; + XCBRandRQueryVersionRep *rr_version; program_name = argv[0]; if (argc == 1) query = 1; @@ -230,19 +237,18 @@ main (int argc, char **argv) exit (1); } root = XCBAuxGetScreen(c, screen); - XCBRandRGetScreenInfoCookie scookie; - - int major_version, minor_version; - XCBRandRQueryVersionRep *rr_version; - rr_version = XCBRandRQueryVersionReply(c, XCBRandRQueryVersion(c, 1, 1), &err); + rr_version = XCBRandRQueryVersionReply(c, XCBRandRQueryVersion(c, 1, 1), 0); + if (!rr_version) { + fprintf(stderr, "Can't get VersionReply.\n"); + exit (1); + } major_version = rr_version->major_version; minor_version = rr_version->minor_version; scookie = XCBRandRGetScreenInfo(c, root->root); - sc = XCBRandRGetScreenInfoReply(c, scookie, &err); - - if (sc == NULL || err) { - fprintf(stderr, "Can't get screen info.\n"); + sc = XCBRandRGetScreenInfoReply(c, scookie, 0); + if (!sc) { + fprintf(stderr, "Can't get ScreenInfo.\n"); exit (1); } @@ -304,8 +310,11 @@ main (int argc, char **argv) } } - //rotations = XRRConfigRotations(sc, ¤t_rotation); +#if 0 + rotations = XRRConfigRotations(sc, ¤t_rotation); +#else rotations = sc->rotation; +#endif rotation = 1 << rot ; if (query) { @@ -361,8 +370,6 @@ main (int argc, char **argv) } /* we should test configureNotify on the root window */ - CARD16 mask = (CARD16) StructureNotifyMask; - CARD32 values[1]; values[0] = 1; XCBConfigureWindow(c, root->root, mask, values); @@ -370,15 +377,16 @@ main (int argc, char **argv) if (setit) { XCBRandRSetScreenConfigCookie sscc; + XCBRandRSetScreenConfigRep *config; sscc = XCBRandRSetScreenConfig(c, root->root, CurrentTime, sc->config_timestamp, size, (short) (rotation | reflection), rate); - status = XCBRandRSetScreenConfigReply(c, sscc, &err)->status; - - if (err && status) { + config = XCBRandRSetScreenConfigReply(c, sscc, &err); + if (!config) { fprintf(stderr, "Can't set the screen. Error Code: %i Status:%i\n", err->error_code, status); exit(1); } + status = config->status; } const XCBQueryExtensionRep *qrre_rep = XCBRandRInit(c); @@ -393,9 +401,13 @@ main (int argc, char **argv) event = XCBWaitForEvent(c); printf ("Event received, type = %d\n", event->response_type); - //update Xlib's knowledge of the event - ////Not sure what the equiv of this is or if we need it. - //XRRUpdateConfiguration (&event); +#if 0 + /* + * update Xlib's knowledge of the event + * Not sure what the equiv of this is or if we need it. + */ + XRRUpdateConfiguration (&event); +#endif if (event->response_type == ConfigureNotify) printf("Received ConfigureNotify Event!\n"); @@ -431,7 +443,9 @@ main (int argc, char **argv) } } } - //XRRFreeScreenConfigInfo(sc); +#if 0 + XRRFreeScreenConfigInfo(sc); +#endif free(sc); free(c); return(0); diff --git a/xcb-demo/xdpyinfo.c b/xcb-demo/xdpyinfo.c index 4de3ad1..3b2adbb 100644 --- a/xcb-demo/xdpyinfo.c +++ b/xcb-demo/xdpyinfo.c @@ -28,11 +28,11 @@ int main(int argc, char **argv) if(!strcmp(argv[argc], "-queryExtensions")) ext_printer = query_extension; - // "name of display: %s" "\n" + /* "name of display: %s" "\n" */ print_setup(c); - // "\n" "focus: window 0x%x, revert to %s" (e.g. PointerRoot) + /* "\n" "focus: window 0x%x, revert to %s" (e.g. PointerRoot) */ list_extensions(ext_printer); - // "\n" "default screen number: %d" + /* "\n" "default screen number: %d" */ list_screens(); fputs("\n", stdout); @@ -47,7 +47,7 @@ void print_setup() fputs("\n" "vendor string: ", stdout); fwrite(XCBConnSetupSuccessRepVendor(XCBGetSetup(c)), 1, XCBConnSetupSuccessRepVendorLength(XCBGetSetup(c)), stdout); printf("\n" "vendor release number: %d", (int) XCBGetSetup(c)->release_number); - // "\n" "XFree86 version: %d.%d.%d.%d" + /* "\n" "XFree86 version: %d.%d.%d.%d" */ printf("\n" "maximum request size: %d bytes", XCBGetSetup(c)->maximum_request_length * 4); printf("\n" "motion buffer size: %d", (int)XCBGetSetup(c)->motion_buffer_size); printf("\n" "bitmap unit, bit order, padding: %d, %s, %d", XCBGetSetup(c)->bitmap_format_scanline_unit, (XCBGetSetup(c)->bitmap_format_bit_order == LSBFirst) ? "LSBFirst" : "MSBFirst", XCBGetSetup(c)->bitmap_format_scanline_pad); |