summaryrefslogtreecommitdiff
path: root/xcl
diff options
context:
space:
mode:
authorJamey Sharp <jamey@minilop.net>2002-06-06 12:43:11 +0000
committerJamey Sharp <jamey@minilop.net>2002-06-06 12:43:11 +0000
commit46bbd39726398aa58d9fd566c4eece5b5a75724a (patch)
tree10b58c843a27b4786e1241fed6bf20421aa6cda8 /xcl
parent907784cdd1bbbea8abb6d8c5096a6a3562da7f06 (diff)
XCL now uses XCB iterators for connection setup data. Also, fixed xclint.h
to compile again since XCB uses Xmd.h.
Diffstat (limited to 'xcl')
-rw-r--r--xcl/src/OpenDis.c118
-rw-r--r--xcl/src/xclint.h20
2 files changed, 50 insertions, 88 deletions
diff --git a/xcl/src/OpenDis.c b/xcl/src/OpenDis.c
index d58606d..2f9e049 100644
--- a/xcl/src/OpenDis.c
+++ b/xcl/src/OpenDis.c
@@ -75,18 +75,20 @@ static void _XInitDefaultDisplay()
_default_display.vnumber = X_PROTOCOL;
}
-static int _XInitPixmapFormats(register Display *dpy)
+static int _XInitPixmapFormats(Display *dpy)
{
int i;
register ScreenFormat *fmtdst;
register FORMAT *fmtsrc;
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ dpy->nformats = XCBConnSetupSuccessReppixmap_formatsLength(c->setup);
/* Now iterate down setup information... */
fmtdst = (ScreenFormat *) Xmalloc(dpy->nformats * sizeof(ScreenFormat));
if(!fmtdst)
return 0;
dpy->pixmap_format = fmtdst;
- fmtsrc = XCBConnectionOfDisplay(dpy)->pixmapFormats;
+ fmtsrc = XCBConnSetupSuccessReppixmap_formats(c->setup);
/* First decode the Z axis Screen format information. */
for(i = dpy->nformats; i; --i, ++fmtsrc, ++fmtdst)
@@ -99,23 +101,16 @@ static int _XInitPixmapFormats(register Display *dpy)
return 1;
}
-static int _XInitVisuals(Depth *dpdst, register VISUALTYPE *vpsrc)
+static Visual *_XInitVisuals(int len, register VISUALTYPE *vpsrc)
{
- int i;
Visual *vpdst;
+ Visual *dst;
- if(dpdst->nvisuals <= 0)
- {
- dpdst->visuals = (Visual *) NULL;
- return 1;
- }
-
- vpdst = (Visual *) Xmalloc(dpdst->nvisuals * sizeof(Visual));
+ dst = vpdst = (Visual *) Xmalloc(len * sizeof(Visual));
if(!vpdst)
return 0;
- dpdst->visuals = vpdst;
- for(i = dpdst->nvisuals; i; --i, ++vpsrc, ++vpdst)
+ for(; len; --len, ++vpsrc, ++vpdst)
{
vpdst->visualid = vpsrc->visual_id.id;
vpdst->class = vpsrc->class;
@@ -126,73 +121,71 @@ static int _XInitVisuals(Depth *dpdst, register VISUALTYPE *vpsrc)
vpdst->blue_mask = vpsrc->blue_mask;
vpdst->ext_data = NULL;
}
- return 1;
+ return dst;
}
-static int _XInitDepths(Screen *spdst, register XCBDepth *dpsrc)
+static Depth *_XInitDepths(DEPTHIter dpsrc)
{
- int i;
register Depth *dpdst;
+ Depth *dst;
- /* lets set up the depth structures. */
- dpdst = (Depth *) Xmalloc(spdst->ndepths * sizeof(Depth));
+ dst = dpdst = (Depth *) Xmalloc(dpsrc.rem * sizeof(Depth));
if(!dpdst)
return 0;
- spdst->depths = dpdst;
/* for all depths on this screen. */
- for(i = spdst->ndepths; i; --i, ++dpsrc, ++dpdst)
+ for(; dpsrc.rem; DEPTHNext(&dpsrc), ++dpdst)
{
- dpdst->depth = dpsrc->data->depth;
- dpdst->nvisuals = dpsrc->data->visuals_len;
+ dpdst->depth = dpsrc.data->depth;
+ dpdst->nvisuals = DEPTHvisualsLength(dpsrc.data);
- if(!_XInitVisuals(dpdst, dpsrc->visuals))
+ dpdst->visuals = _XInitVisuals(dpdst->nvisuals, DEPTHvisuals(dpsrc.data));
+ if(!dpdst->visuals)
return 0;
}
- return 1;
+ return dst;
}
-static int _XInitScreens(register Display *dpy)
+static int _XInitScreens(Display *dpy, SCREENIter spsrc)
{
- int i;
register Screen *spdst;
- register XCBScreen *spsrc;
XGCValues values;
- /* next the Screen structures. */
- spdst = (Screen *) Xmalloc(dpy->nscreens * sizeof(Screen));
+ dpy->nscreens = spsrc.rem;
+
+ spdst = (Screen *) Xmalloc(spsrc.rem * sizeof(Screen));
if(!spdst)
return 0;
dpy->screens = spdst;
- spsrc = XCBConnectionOfDisplay(dpy)->roots;
/* Now go deal with each screen structure. */
- for(i = dpy->nscreens; i; --i, ++spsrc, ++spdst)
+ for(; spsrc.rem; SCREENNext(&spsrc), ++spdst)
{
spdst->display = dpy;
- spdst->root = spsrc->data->root.xid;
- spdst->cmap = spsrc->data->default_colormap.xid;
- spdst->white_pixel = spsrc->data->white_pixel;
+ spdst->root = spsrc.data->root.xid;
+ spdst->cmap = spsrc.data->default_colormap.xid;
+ spdst->white_pixel = spsrc.data->white_pixel;
values.background = spdst->white_pixel;
- spdst->black_pixel = spsrc->data->black_pixel;
+ spdst->black_pixel = spsrc.data->black_pixel;
values.foreground = spdst->black_pixel;
- spdst->root_input_mask = spsrc->data->current_input_masks;
- spdst->width = spsrc->data->width_in_pixels;
- spdst->height = spsrc->data->height_in_pixels;
- spdst->mwidth = spsrc->data->width_in_millimeters;
- spdst->mheight = spsrc->data->height_in_millimeters;
- spdst->min_maps = spsrc->data->min_installed_maps;
- spdst->max_maps = spsrc->data->max_installed_maps;
- spdst->backing_store = spsrc->data->backing_stores;
- spdst->save_unders = spsrc->data->save_unders;
- spdst->root_depth = spsrc->data->root_depth;
- spdst->ndepths = spsrc->data->allowed_depths_len;
+ spdst->root_input_mask = spsrc.data->current_input_masks;
+ spdst->width = spsrc.data->width_in_pixels;
+ spdst->height = spsrc.data->height_in_pixels;
+ spdst->mwidth = spsrc.data->width_in_millimeters;
+ spdst->mheight = spsrc.data->height_in_millimeters;
+ spdst->min_maps = spsrc.data->min_installed_maps;
+ spdst->max_maps = spsrc.data->max_installed_maps;
+ spdst->backing_store = spsrc.data->backing_stores;
+ spdst->save_unders = spsrc.data->save_unders;
+ spdst->root_depth = spsrc.data->root_depth;
+ spdst->ndepths = spsrc.data->allowed_depths_len;
spdst->ext_data = NULL;
- if(!_XInitDepths(spdst, spsrc->depths))
+ spdst->depths = _XInitDepths(SCREENallowed_depths(spsrc.data));
+ if(!spdst->depths)
return 0;
- spdst->root_visual = _XVIDtoVisual(dpy, spsrc->data->root_visual.id);
+ spdst->root_visual = _XVIDtoVisual(dpy, spsrc.data->root_visual.id);
/* Set up other stuff clients are always going to use. */
spdst->default_gc = XCreateGC(dpy, spdst->root, GCForeground|GCBackground, &values);
@@ -212,20 +205,9 @@ Display *XOpenDisplay (register const char *display)
_XInitDefaultDisplay();
- /*
- * If the display specifier string supplied as an argument to this
- * routine is NULL or a pointer to NULL, read the DISPLAY variable.
- */
- if (display == NULL || *display == '\0') {
- if ((display_name = getenv("DISPLAY")) == NULL) {
- /* Oops! No DISPLAY environment variable - error. */
- return(NULL);
- }
- }
- else {
- /* Display is non-NULL, copy the pointer */
- display_name = (char *)display;
- }
+ display_name = XDisplayName(display);
+ if(display_name[0] == '\0')
+ return NULL;
/* Attempt to allocate a display structure. Return NULL if allocation
* fails. */
@@ -268,8 +250,6 @@ Display *XOpenDisplay (register const char *display)
dpy->resource_mask = c->setup->resource_id_mask;
dpy->motion_buffer = c->setup->motion_buffer_size;
dpy->max_request_size = c->setup->maximum_request_length;
- dpy->nscreens = c->setup->roots_len;
- dpy->nformats = c->setup->pixmap_formats_len;
dpy->byte_order = c->setup->image_byte_order;
dpy->bitmap_bit_order = c->setup->bitmap_format_bit_order;
dpy->bitmap_unit = c->setup->bitmap_format_scanline_unit;
@@ -284,11 +264,13 @@ Display *XOpenDisplay (register const char *display)
}
dpy->resource_max = (dpy->resource_mask >> dpy->resource_shift) - 5;
- dpy->vendor = Xmalloc(c->setup->vendor_len + 1);
- memcpy(dpy->vendor, c->vendor, c->setup->vendor_len);
- dpy->vendor[c->setup->vendor_len] = '\0';
+ dpy->vendor = Xmalloc(XCBConnSetupSuccessRepvendorLength(c->setup) + 1);
+ memcpy(dpy->vendor, XCBConnSetupSuccessRepvendor(c->setup), XCBConnSetupSuccessRepvendorLength(c->setup));
+ dpy->vendor[XCBConnSetupSuccessRepvendorLength(c->setup)] = '\0';
- if(!_XInitPixmapFormats(dpy) || !_XInitScreens(dpy))
+ if(!_XInitPixmapFormats(dpy))
+ goto error;
+ if(!_XInitScreens(dpy, XCBConnSetupSuccessReproots(c->setup)))
goto error;
/* get the resource manager database off the root window. */
diff --git a/xcl/src/xclint.h b/xcl/src/xclint.h
index cdc8d30..f1063bc 100644
--- a/xcl/src/xclint.h
+++ b/xcl/src/xclint.h
@@ -7,30 +7,10 @@
#include "xcl.h"
-#define INT32 XlibINT32
-#define INT16 XlibINT16
-#define INT8 XlibINT8
-#define CARD32 XlibCARD32
-#define CARD16 XlibCARD16
-#define CARD8 XlibCARD8
-#define BITS32 XlibBITS32
-#define BITS16 XlibBITS16
-#define BYTE XlibBYTE
-#define BOOL XlibBOOL
#define KEYCODE XlibKEYCODE
#include <X11/Xlibint.h>
-#undef INT32
-#undef INT16
-#undef INT8
-#undef CARD32
-#undef CARD16
-#undef CARD8
-#undef BITS32
-#undef BITS16
-#undef BYTE
-#undef BOOL
#undef KEYCODE
#endif /* XCLINT_H */