summaryrefslogtreecommitdiff
path: root/xcl
diff options
context:
space:
mode:
authorJamey Sharp <jamey@minilop.net>2002-03-31 08:47:02 +0000
committerJamey Sharp <jamey@minilop.net>2002-03-31 08:47:02 +0000
commit63a22536047143a8673d0d5894e33f20b5d9182c (patch)
treef9c7d0c8c7cf2b5743970eb30d347c92b5274e8c /xcl
parent9401009c4d573f95e377f7b4f4e2b7fe715861cf (diff)
Fixed QueryColors: rxvt runs without visible error now. Turned on -Wall and
fixed all warnings. Fixed a couple of memory leaks. Re-wrote some functions.
Diffstat (limited to 'xcl')
-rw-r--r--xcl/src/ChkTypWEv.c1
-rw-r--r--xcl/src/CrGC.c61
-rw-r--r--xcl/src/DisName.c3
-rw-r--r--xcl/src/ErrDes.c2
-rw-r--r--xcl/src/EvToWire.c4
-rw-r--r--xcl/src/Font.c2
-rw-r--r--xcl/src/GetPntMap.c13
-rw-r--r--xcl/src/GetProp.c9
-rw-r--r--xcl/src/ImText.c62
-rw-r--r--xcl/src/IntAtom.c19
-rw-r--r--xcl/src/ModMap.c15
-rw-r--r--xcl/src/OpenDis.c3
-rw-r--r--xcl/src/ParseCol.c13
13 files changed, 113 insertions, 94 deletions
diff --git a/xcl/src/ChkTypWEv.c b/xcl/src/ChkTypWEv.c
index 3b31a23..31de391 100644
--- a/xcl/src/ChkTypWEv.c
+++ b/xcl/src/ChkTypWEv.c
@@ -28,7 +28,6 @@ Bool XCheckTypedWindowEvent(Display *dpy, Window w, int type, XEvent *event)
{
_XQEvent *prev = NULL;
unsigned long qe_serial = 0;
- int n; /* time through count */
LockDisplay(dpy);
diff --git a/xcl/src/CrGC.c b/xcl/src/CrGC.c
index dcb4cc7..29ee7af 100644
--- a/xcl/src/CrGC.c
+++ b/xcl/src/CrGC.c
@@ -73,71 +73,82 @@ int _XUpdateGCCache(register GC gc, register unsigned long mask, register XGCVal
{
register XGCValues *gv = &gc->values;
- if (mask & GCFunction)
+ if (mask & GCFunction) {
if (gv->function != attr->function)
gv->function = attr->function;
else
mask &= ~GCFunction;
+ }
- if (mask & GCPlaneMask)
+ if (mask & GCPlaneMask) {
if (gv->plane_mask != attr->plane_mask)
gv->plane_mask = attr->plane_mask;
else
mask &= ~GCPlaneMask;
+ }
- if (mask & GCForeground)
+ if (mask & GCForeground) {
if (gv->foreground != attr->foreground)
gv->foreground = attr->foreground;
else
mask &= ~GCForeground;
+ }
- if (mask & GCBackground)
+ if (mask & GCBackground) {
if (gv->background != attr->background)
gv->background = attr->background;
else
mask &= ~GCBackground;
+ }
- if (mask & GCLineWidth)
+ if (mask & GCLineWidth) {
if (gv->line_width != attr->line_width)
gv->line_width = attr->line_width;
else
mask &= ~GCLineWidth;
+ }
- if (mask & GCLineStyle)
+ if (mask & GCLineStyle) {
if (gv->line_style != attr->line_style)
gv->line_style = attr->line_style;
else
mask &= ~GCLineStyle;
+ }
- if (mask & GCCapStyle)
+ if (mask & GCCapStyle) {
if (gv->cap_style != attr->cap_style)
gv->cap_style = attr->cap_style;
else
mask &= ~GCCapStyle;
+ }
- if (mask & GCJoinStyle)
+ if (mask & GCJoinStyle) {
if (gv->join_style != attr->join_style)
gv->join_style = attr->join_style;
else
mask &= ~GCJoinStyle;
+ }
- if (mask & GCFillStyle)
+ if (mask & GCFillStyle) {
if (gv->fill_style != attr->fill_style)
gv->fill_style = attr->fill_style;
else
mask &= ~GCFillStyle;
+ }
- if (mask & GCFillRule)
+ if (mask & GCFillRule) {
if (gv->fill_rule != attr->fill_rule)
gv->fill_rule = attr->fill_rule;
else
mask &= ~GCFillRule;
+ }
- if (mask & GCArcMode)
+ if (mask & GCArcMode) {
if (gv->arc_mode != attr->arc_mode)
gv->arc_mode = attr->arc_mode;
else
mask &= ~GCArcMode;
+ }
/* always write through tile change, since client may have changed pixmap contents */
if (mask & GCTile)
@@ -147,66 +158,76 @@ int _XUpdateGCCache(register GC gc, register unsigned long mask, register XGCVal
if (mask & GCStipple)
gv->stipple = attr->stipple;
- if (mask & GCTileStipXOrigin)
+ if (mask & GCTileStipXOrigin) {
if (gv->ts_x_origin != attr->ts_x_origin)
gv->ts_x_origin = attr->ts_x_origin;
else
mask &= ~GCTileStipXOrigin;
+ }
- if (mask & GCTileStipYOrigin)
+ if (mask & GCTileStipYOrigin) {
if (gv->ts_y_origin != attr->ts_y_origin)
gv->ts_y_origin = attr->ts_y_origin;
else
mask &= ~GCTileStipYOrigin;
+ }
- if (mask & GCFont)
+ if (mask & GCFont) {
if (gv->font != attr->font)
gv->font = attr->font;
else
mask &= ~GCFont;
+ }
- if (mask & GCSubwindowMode)
+ if (mask & GCSubwindowMode) {
if (gv->subwindow_mode != attr->subwindow_mode)
gv->subwindow_mode = attr->subwindow_mode;
else
mask &= ~GCSubwindowMode;
+ }
- if (mask & GCGraphicsExposures)
+ if (mask & GCGraphicsExposures) {
if (gv->graphics_exposures != attr->graphics_exposures)
gv->graphics_exposures = attr->graphics_exposures;
else
mask &= ~GCGraphicsExposures;
+ }
- if (mask & GCClipXOrigin)
+ if (mask & GCClipXOrigin) {
if (gv->clip_x_origin != attr->clip_x_origin)
gv->clip_x_origin = attr->clip_x_origin;
else
mask &= ~GCClipXOrigin;
+ }
- if (mask & GCClipYOrigin)
+ if (mask & GCClipYOrigin) {
if (gv->clip_y_origin != attr->clip_y_origin)
gv->clip_y_origin = attr->clip_y_origin;
else
mask &= ~GCClipYOrigin;
+ }
+
/* always write through mask change, since client may have changed pixmap contents */
if (mask & GCClipMask) {
gv->clip_mask = attr->clip_mask;
gc->rects = 0;
}
- if (mask & GCDashOffset)
+ if (mask & GCDashOffset) {
if (gv->dash_offset != attr->dash_offset)
gv->dash_offset = attr->dash_offset;
else
mask &= ~GCDashOffset;
+ }
- if (mask & GCDashList)
+ if (mask & GCDashList) {
if ((gv->dashes != attr->dashes) || (gc->dashes == True)) {
gv->dashes = attr->dashes;
gc->dashes = 0;
} else
mask &= ~GCDashList;
+ }
gc->dirty |= mask;
diff --git a/xcl/src/DisName.c b/xcl/src/DisName.c
index c89d66c..7929e31 100644
--- a/xcl/src/DisName.c
+++ b/xcl/src/DisName.c
@@ -22,7 +22,8 @@ char *XDisplayName(char *display)
char *d;
if(display && *display != '\0')
return display;
- if(d = getenv("DISPLAY"))
+ d = getenv("DISPLAY");
+ if(d)
return d;
return "";
}
diff --git a/xcl/src/ErrDes.c b/xcl/src/ErrDes.c
index bb59753..7356a54 100644
--- a/xcl/src/ErrDes.c
+++ b/xcl/src/ErrDes.c
@@ -91,7 +91,9 @@ XGetErrorDatabaseText(dpy, name, type, defaultp, buffer, nbytes)
{
static XrmDatabase db = NULL;
+#if 0 /* not implemented yet */
XrmString type_str;
+#endif
XrmValue result;
char temp[BUFSIZ];
char* tptr;
diff --git a/xcl/src/EvToWire.c b/xcl/src/EvToWire.c
index 7e780c9..7a30966 100644
--- a/xcl/src/EvToWire.c
+++ b/xcl/src/EvToWire.c
@@ -6,7 +6,7 @@
/* event: wire protocol event */
Status _XUnknownNativeEvent(register Display *dpy, register XEvent *re, register xEvent *event)
{
- fprintf(stderr, "XCL: unhandled native event! event number = %d, display = %x\n.", re->type, dpy);
+ fprintf(stderr, "XCL: unhandled native event! event number = %d, display = %p\n.", re->type, (void *) dpy);
return(0);
}
@@ -378,7 +378,7 @@ Status _XEventToWire(register Display *dpy, register XEvent *re, register xEvent
/* event: wire protocol event */
Bool _XUnknownWireEvent(register Display *dpy, register XEvent *re, register xEvent *event)
{
- fprintf(stderr, "Xlib: unhandled wire event! event number = %d, display = %x\n.", event->u.u.type, dpy);
+ fprintf(stderr, "Xlib: unhandled wire event! event number = %d, display = %p\n.", event->u.u.type, (void *) dpy);
return(False);
}
diff --git a/xcl/src/Font.c b/xcl/src/Font.c
index af2df3f..146f8e4 100644
--- a/xcl/src/Font.c
+++ b/xcl/src/Font.c
@@ -66,7 +66,9 @@ XFontStruct *XLoadQueryFont(dpy, name)
char *name;
#endif
{
+#ifdef USE_LOCALE
XFontStruct *font_result;
+#endif
FONT f;
#ifdef USE_LOCALE
diff --git a/xcl/src/GetPntMap.c b/xcl/src/GetPntMap.c
index 186f663..e10e8a0 100644
--- a/xcl/src/GetPntMap.c
+++ b/xcl/src/GetPntMap.c
@@ -63,14 +63,15 @@ KeySym *XGetKeyboardMapping (Display *dpy,
c = XCBGetKeyboardMapping(XCBConnectionOfDisplay(dpy), XCLKEYCODE(first_keycode), count);
r = XCBGetKeyboardMappingReply(XCBConnectionOfDisplay(dpy), c, 0);
if (!r)
- return 0;
+ return 0;
mapping = (KeySym *) Xmalloc(r->length * 4 * sizeof(KEYSYM));
- if (!mapping)
- return 0;
- memcpy(mapping, XCBGetKeyboardMappingkeysyms(r), r->length * 4 * sizeof(KEYSYM));
-
- *keysyms_per_keycode = r->keysyms_per_keycode;
+ if (mapping)
+ {
+ memcpy(mapping, XCBGetKeyboardMappingkeysyms(r), r->length * 4 * sizeof(KEYSYM));
+ *keysyms_per_keycode = r->keysyms_per_keycode;
+ }
+ free(r);
return mapping;
}
diff --git a/xcl/src/GetProp.c b/xcl/src/GetProp.c
index f032cf1..4c43841 100644
--- a/xcl/src/GetProp.c
+++ b/xcl/src/GetProp.c
@@ -31,8 +31,7 @@ XGetWindowProperty(register Display *dpy, Window window, Atom property, long off
error.minorCode = 0;
error.errorCode = BadImplementation;
_XError(dpy, &error);
- /* XXX: Xlib returns BadAlloc here, but that's weird. */
- return BadAlloc; /* not Success */
+ goto error;
}
/* One more byte is malloced than is needed to contain the property
* data, but this last byte is null terminated and convenient for
@@ -41,7 +40,7 @@ XGetWindowProperty(register Display *dpy, Window window, Atom property, long off
* it's a really stupid idea. */
*prop = Xmalloc (r->bytes_after + 1);
if (!*prop)
- return BadAlloc; /* not Success */
+ goto error;
/* FIXME: Xlib has a different behavior than this for systems where a
* short isn't 16 bits or where a long isn't 32 bits. */
memcpy (*prop, XCBGetPropertyvalue(r), r->bytes_after);
@@ -54,4 +53,8 @@ XGetWindowProperty(register Display *dpy, Window window, Atom property, long off
*bytesafter = r->bytes_after;
free(r);
return Success;
+
+error:
+ free(r);
+ return BadAlloc; /* not Success */
}
diff --git a/xcl/src/ImText.c b/xcl/src/ImText.c
index 3696373..2ef49f9 100644
--- a/xcl/src/ImText.c
+++ b/xcl/src/ImText.c
@@ -1,54 +1,48 @@
#include "xclint.h"
-int XDrawImageString(register Display *dpy, Drawable d, GC gc, int x, int y, const char *string, int length)
+#define MAXIMTEXTREQ 255
+
+int XDrawImageString(Display *dpy, const Drawable d, GC gc, int x, const int y, const char *string, int length)
{
- char *CharacterOffset = (char *)string;
- int FirstTimeThrough = True;
- int lastX = 0;
+ register XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ CHAR2B buf[MAXIMTEXTREQ];
+ register CHAR2B *ptr;
+ register int i;
+
+ if(length <= 0)
+ return 0;
LockDisplay(dpy);
FlushGC(dpy, gc);
- while (length > 0)
+ /* if it'll be used later, zero the high bytes of the buffer. */
+ if(length > MAXIMTEXTREQ)
+ for(i = MAXIMTEXTREQ, ptr = buf; i; --i)
+ (ptr++)->byte1 = 0;
+
+ while(1)
{
- int Unit;
+ i = (length > MAXIMTEXTREQ) ? MAXIMTEXTREQ : length;
- if (length > 255) Unit = 255;
- else Unit = length;
+ XCBImageText8(c, i, XCLDRAWABLE(d), XCLGCONTEXT(gc->gid), x, y, string);
- if (FirstTimeThrough)
- {
- FirstTimeThrough = False;
- }
- else
- {
- char buf[512];
- char *ptr, *str;
- XCBQueryTextExtentsCookie c;
- XCBQueryTextExtentsRep *r;
- int i;
+ length -= MAXIMTEXTREQ;
+ if(length <= 0)
+ break;
- str = CharacterOffset - 255;
- for(ptr = buf, i = 255; --i >= 0; )
- {
- *ptr++ = 0;
- *ptr++ = *str++;
- }
+ /* invariant: i == MAXIMTEXTREQ */
+ for(ptr = buf; i; --i)
+ (ptr++)->byte2 = *string++;
- c = XCBQueryTextExtents(XCBConnectionOfDisplay(dpy), XCLFONTABLE(gc->gid), 255, (CHAR2B *) buf);
- r = XCBQueryTextExtentsReply(XCBConnectionOfDisplay(dpy), c, 0);
+ {
+ XCBQueryTextExtentsRep *r;
+ r = XCBQueryTextExtentsReply(c, XCBQueryTextExtents(c, XCLFONTABLE(gc->gid), MAXIMTEXTREQ, buf), 0);
if(!r)
break;
- x = lastX + cvtINT32toInt(r->overall_width);
+ x += cvtINT32toInt(r->overall_width);
free(r);
}
-
- XCBImageText8(XCBConnectionOfDisplay(dpy), Unit, XCLDRAWABLE(d), XCLGCONTEXT(gc->gid), x, y, CharacterOffset);
-
- lastX = x;
- CharacterOffset += Unit;
- length -= Unit;
}
UnlockDisplay(dpy);
return 0;
diff --git a/xcl/src/IntAtom.c b/xcl/src/IntAtom.c
index d885cf6..dc525dd 100644
--- a/xcl/src/IntAtom.c
+++ b/xcl/src/IntAtom.c
@@ -3,17 +3,16 @@
/* XXX: this implementation does no caching. */
-Atom XInternAtom(Display *dpy, const char *name, Bool onlyIfExists)
+Atom XInternAtom(Display *dpy, const char *name, const Bool onlyIfExists)
{
+ register XCBConnection *c = XCBConnectionOfDisplay(dpy);
Atom atom;
- XCBInternAtomCookie c;
XCBInternAtomRep *r;
if (!name)
name = "";
- c = XCBInternAtom(XCBConnectionOfDisplay(dpy), onlyIfExists, strlen(name), name);
- r = XCBInternAtomReply(XCBConnectionOfDisplay(dpy), c, 0);
+ r = XCBInternAtomReply(c, XCBInternAtom(c, onlyIfExists, strlen(name), name), 0);
if (!r)
return None;
atom = r->atom.xid;
@@ -21,11 +20,12 @@ Atom XInternAtom(Display *dpy, const char *name, Bool onlyIfExists)
return (atom);
}
-Status XInternAtoms(Display *dpy, char **names, int count, Bool onlyIfExists, Atom *atoms_return)
+Status XInternAtoms(Display *dpy, char **const names, const int count, const Bool onlyIfExists, Atom *const atoms_return)
{
+ register XCBConnection *c = XCBConnectionOfDisplay(dpy);
XCBInternAtomCookie *cs;
- XCBInternAtomRep *r;
- int i, ret = 1;
+ register int i;
+ int ret = 1;
cs = (XCBInternAtomCookie *) malloc(count * sizeof(XCBInternAtomCookie));
/* even if this memory allocation fails, ensure that every entry in
@@ -40,10 +40,11 @@ Status XInternAtoms(Display *dpy, char **names, int count, Bool onlyIfExists, At
}
for (i = 0; i < count; ++i)
- cs[i] = XCBInternAtom(XCBConnectionOfDisplay(dpy), onlyIfExists, strlen(names[i]), names[i]);
+ cs[i] = XCBInternAtom(c, onlyIfExists, strlen(names[i]), names[i]);
for (i = 0; i < count; ++i) {
- r = XCBInternAtomReply(XCBConnectionOfDisplay(dpy), cs[i], 0);
+ XCBInternAtomRep *r;
+ r = XCBInternAtomReply(c, cs[i], 0);
if (!r) {
ret = 0; /* something failed... */
continue; /* ...but finish working anyway. */
diff --git a/xcl/src/ModMap.c b/xcl/src/ModMap.c
index 2542135..a1bdbc3 100644
--- a/xcl/src/ModMap.c
+++ b/xcl/src/ModMap.c
@@ -1,8 +1,8 @@
#include "xclint.h"
-XModifierKeymap *XGetModifierMapping(register Display *dpy)
-{
- XCBGetModifierMappingCookie c;
+XModifierKeymap *XGetModifierMapping(Display *dpy)
+{
+ register XCBConnection *c = XCBConnectionOfDisplay(dpy);
XCBGetModifierMappingRep *r;
XModifierKeymap *res;
unsigned int nbytes;
@@ -11,9 +11,7 @@ XModifierKeymap *XGetModifierMapping(register Display *dpy)
if (!res)
return 0;
- c = XCBGetModifierMapping(XCBConnectionOfDisplay(dpy));
- r = XCBGetModifierMappingReply(XCBConnectionOfDisplay(dpy), c, 0);
-
+ r = XCBGetModifierMappingReply(c, XCBGetModifierMapping(c), 0);
if (!r)
goto error;
@@ -24,12 +22,15 @@ XModifierKeymap *XGetModifierMapping(register Display *dpy)
memcpy(res->modifiermap, XCBGetModifierMappingkeycodes(r), nbytes);
res->max_keypermod = r->keycodes_per_modifier;
+
+done:
return (res);
error:
if (res)
Xfree((char *) res);
- return 0;
+ res = 0;
+ goto done;
}
/*
diff --git a/xcl/src/OpenDis.c b/xcl/src/OpenDis.c
index a468bc4..398a95d 100644
--- a/xcl/src/OpenDis.c
+++ b/xcl/src/OpenDis.c
@@ -1,6 +1,7 @@
#include "xclint.h"
#include <X11/Xatom.h>
#include <stdio.h>
+#include <unistd.h>
#ifdef XKB
#include "XKBlib.h"
@@ -37,8 +38,6 @@ void (*_XFreeDisplayLock_fn)(Display *dpy) = NULL;
#define FreeDisplayLock(dis)
#endif /* XTHREADS */
-static xReq _dummy_request;
-
static Display _default_display;
static void _XInitDefaultDisplay()
{
diff --git a/xcl/src/ParseCol.c b/xcl/src/ParseCol.c
index 403662e..7d44e6a 100644
--- a/xcl/src/ParseCol.c
+++ b/xcl/src/ParseCol.c
@@ -45,22 +45,17 @@ Status XParseColor(register Display *dpy, Colormap cmap, const char *spec, XColo
}
{
- COLORMAP cm = { cmap };
- XCBLookupColorCookie c;
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
XCBLookupColorRep *r;
- c = XCBLookupColor(XCBConnectionOfDisplay(dpy), cm, strlen(spec), spec);
- r = XCBLookupColorReply(XCBConnectionOfDisplay(dpy), c, 0);
-
- if (!r)
- {
+ r = XCBLookupColorReply(c, XCBLookupColor(c, XCLCOLORMAP(cmap), strlen(spec), spec), 0);
+ if(!r)
return 0;
- }
def->red = r->exact_red;
def->green = r->exact_green;
def->blue = r->exact_blue;
def->flags = DoRed | DoGreen | DoBlue;
- return (1);
+ return 1;
}
}