libdockapp: Use consistent code formatting.

Used uncrustify to minimize warnings and errors from checkpatch.pl in the
Window Maker source tree.
This commit is contained in:
Doug Torrance 2014-11-28 10:22:51 -06:00 committed by Carlos R. Mafra
parent b002ed2e01
commit 19bf1f277f
13 changed files with 1163 additions and 1146 deletions

View file

@ -19,9 +19,9 @@
/* /*
* Prototypes for local functions * Prototypes for local functions
*/ */
void drawRelief(); void drawRelief(Pixmap pixmap);
void moveBall(); void moveBall(void);
void destroy(); void destroy(void);
/* /*
* Global variables * Global variables
@ -36,7 +36,7 @@ DAShapedPixmap *ballPix;
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
unsigned int x=1, y=1; unsigned int x = 1, y = 1;
Pixmap back; Pixmap back;
DACallbacks eventCallbacks = { DACallbacks eventCallbacks = {
destroy, /* destroy */ destroy, /* destroy */
@ -135,11 +135,11 @@ drawRelief(Pixmap pixmap)
gcv.graphics_exposures = False; gcv.graphics_exposures = False;
lightGrayGC = XCreateGC(DADisplay, DAWindow, lightGrayGC = XCreateGC(DADisplay, DAWindow,
GCForeground|GCGraphicsExposures, &gcv); GCForeground | GCGraphicsExposures, &gcv);
gcv.foreground = DAGetColor("#222222"); gcv.foreground = DAGetColor("#222222");
darkGrayGC = XCreateGC(DADisplay, DAWindow, darkGrayGC = XCreateGC(DADisplay, DAWindow,
GCForeground|GCGraphicsExposures, &gcv); GCForeground | GCGraphicsExposures, &gcv);
/* Drawing */ /* Drawing */
XFillRectangle(DADisplay, pixmap, DAClearGC, 1, 1, 46, 46); XFillRectangle(DADisplay, pixmap, DAClearGC, 1, 1, 46, 46);
@ -157,18 +157,25 @@ drawRelief(Pixmap pixmap)
void void
moveBall() moveBall(void)
{ {
static int x = 1; static int x = 1;
static int y = 1; static int y = 1;
static int dx = 0; static int dx;
static int dy = 0; static int dy;
signed int var = random()%3 -1; signed int var = random() % 3 - 1;
if (dx == 0) dx = var; if (dx == 0)
if (dy == 0) dy = var; dx = var;
if (dx > MAX_MOVE) dx = MAX_MOVE;
if (dy > MAX_MOVE) dy = MAX_MOVE; if (dy == 0)
dy = var;
if (dx > MAX_MOVE)
dx = MAX_MOVE;
if (dy > MAX_MOVE)
dy = MAX_MOVE;
/* calculate new position */ /* calculate new position */
x += dx; x += dx;
@ -204,6 +211,6 @@ destroy(void)
XFreePixmap(DADisplay, ballPix->pixmap); XFreePixmap(DADisplay, ballPix->pixmap);
XFreePixmap(DADisplay, ballPix->shape); XFreePixmap(DADisplay, ballPix->shape);
fprintf(stderr, "Destroyed!\n"); fprintf(stderr, "Destroyed!\n");
/* exit is done by libdockapp */ /* exit is done by libdockapp */
} }

View file

@ -54,7 +54,7 @@ Cursor pointer;
/* /*
* Prototypes for local functions * Prototypes for local functions
*/ */
struct Colors* setGCs(Drawable d); struct Colors *setGCs(Drawable d);
unsigned long adjustColor(unsigned long color, signed int adjustment); unsigned long adjustColor(unsigned long color, signed int adjustment);
/* drawing routines */ /* drawing routines */
@ -148,7 +148,7 @@ main(int argc, char **argv)
/* XXX: make action rectangles available outside main() /* XXX: make action rectangles available outside main()
* ...libDockapp should be able to do this... (reminder) * ...libDockapp should be able to do this... (reminder)
*/ */
actionRects = malloc(6 * sizeof(DAActionRect*)); actionRects = malloc(6 * sizeof(DAActionRect *));
actionRects[0] = buttonPressRects; actionRects[0] = buttonPressRects;
actionRects[1] = buttonReleaseRects; actionRects[1] = buttonReleaseRects;
actionRects[2] = mouseMoveRects; actionRects[2] = mouseMoveRects;
@ -237,7 +237,7 @@ main(int argc, char **argv)
/* Create our GC's to draw colored lines and such */ /* Create our GC's to draw colored lines and such */
struct Colors* struct Colors *
setGCs(Drawable d) setGCs(Drawable d)
{ {
struct Colors *colors; struct Colors *colors;
@ -251,7 +251,7 @@ setGCs(Drawable d)
/* Get the GC-values of the default GC */ /* Get the GC-values of the default GC */
XGetGCValues(DADisplay, DAGC, XGetGCValues(DADisplay, DAGC,
GCForeground|GCBackground|GCGraphicsExposures, &gcv); GCForeground | GCBackground | GCGraphicsExposures, &gcv);
origColor = gcv.foreground; origColor = gcv.foreground;
@ -261,7 +261,7 @@ setGCs(Drawable d)
/* GC for white color */ /* GC for white color */
gcv.foreground = WhitePixel(DADisplay, DefaultScreen(DADisplay)); gcv.foreground = WhitePixel(DADisplay, DefaultScreen(DADisplay));
colors->white = XCreateGC(DADisplay, d, colors->white = XCreateGC(DADisplay, d,
GCForeground|GCGraphicsExposures, &gcv); GCForeground | GCGraphicsExposures, &gcv);
/* GC for dark blue color */ /* GC for dark blue color */
#if 1 #if 1
@ -270,17 +270,17 @@ setGCs(Drawable d)
gcv.foreground = 0; gcv.foreground = 0;
#endif #endif
colors->black = XCreateGC(DADisplay, d, colors->black = XCreateGC(DADisplay, d,
GCForeground|GCGraphicsExposures, &gcv); GCForeground | GCGraphicsExposures, &gcv);
/* GC for light borders */ /* GC for light borders */
gcv.foreground = DAGetColor("lightGray"); gcv.foreground = DAGetColor("lightGray");
colors->lightGray = XCreateGC(DADisplay, d, colors->lightGray = XCreateGC(DADisplay, d,
GCForeground|GCGraphicsExposures, &gcv); GCForeground | GCGraphicsExposures, &gcv);
/* GC for dark borders (note re-use of gcv-values) */ /* GC for dark borders (note re-use of gcv-values) */
gcv.foreground = DAGetColor("#222222"); gcv.foreground = DAGetColor("#222222");
colors->darkGray = XCreateGC(DADisplay, d, colors->darkGray = XCreateGC(DADisplay, d,
GCForeground|GCGraphicsExposures, &gcv); GCForeground | GCGraphicsExposures, &gcv);
/* GC for the un-/highlighted colors and dashed line of the slider */ /* GC for the un-/highlighted colors and dashed line of the slider */
gcv.foreground = origColor; gcv.foreground = origColor;
@ -288,8 +288,8 @@ setGCs(Drawable d)
gcv.line_style = LineOnOffDash; gcv.line_style = LineOnOffDash;
colors->slider = XCreateGC(DADisplay, d, colors->slider = XCreateGC(DADisplay, d,
GCForeground|GCBackground|GCGraphicsExposures| GCForeground | GCBackground | GCGraphicsExposures |
GCLineWidth|GCLineStyle, &gcv); GCLineWidth | GCLineStyle, &gcv);
XSetDashes(DADisplay, colors->slider, 1, dashList, 2); XSetDashes(DADisplay, colors->slider, 1, dashList, 2);
@ -297,8 +297,8 @@ setGCs(Drawable d)
gcv.foreground = adjustColor(origColor, +0x40); gcv.foreground = adjustColor(origColor, +0x40);
colors->sliderLight = XCreateGC(DADisplay, d, colors->sliderLight = XCreateGC(DADisplay, d,
GCForeground|GCBackground|GCGraphicsExposures| GCForeground | GCBackground | GCGraphicsExposures |
GCLineWidth|GCLineStyle, &gcv); GCLineWidth | GCLineStyle, &gcv);
XSetDashes(DADisplay, colors->sliderLight, 1, dashList, 2); XSetDashes(DADisplay, colors->sliderLight, 1, dashList, 2);
@ -306,8 +306,8 @@ setGCs(Drawable d)
gcv.foreground = adjustColor(origColor, -0x40); gcv.foreground = adjustColor(origColor, -0x40);
colors->sliderDark = XCreateGC(DADisplay, d, colors->sliderDark = XCreateGC(DADisplay, d,
GCForeground|GCBackground|GCGraphicsExposures| GCForeground | GCBackground | GCGraphicsExposures |
GCLineWidth|GCLineStyle, &gcv); GCLineWidth | GCLineStyle, &gcv);
XSetDashes(DADisplay, colors->sliderDark, 1, dashList, 2); XSetDashes(DADisplay, colors->sliderDark, 1, dashList, 2);
@ -329,13 +329,23 @@ adjustColor(unsigned long color, signed int adjustment)
g += adjustment; g += adjustment;
b += adjustment; b += adjustment;
if (r > 0xff) r = 0xff; if (r > 0xff)
if (g > 0xff) g = 0xff; r = 0xff;
if (b > 0xff) b = 0xff;
if (r < 0) r = 0; if (g > 0xff)
if (g < 0) g = 0; g = 0xff;
if (b < 0) b = 0;
if (b > 0xff)
b = 0xff;
if (r < 0)
r = 0;
if (g < 0)
g = 0;
if (b < 0)
b = 0;
return ((unsigned short)r << 16) + return ((unsigned short)r << 16) +
((unsigned short)g << 8) + ((unsigned short)g << 8) +
@ -352,7 +362,7 @@ setPointerColor(GC color)
XGetGCValues(DADisplay, color, GCForeground, &gcv); XGetGCValues(DADisplay, color, GCForeground, &gcv);
fcolor.pixel = gcv.foreground; fcolor.pixel = gcv.foreground;
fcolor.flags = DoRed|DoGreen|DoBlue; fcolor.flags = DoRed | DoGreen | DoBlue;
bcolor.red = 0; bcolor.red = 0;
bcolor.green = 0; bcolor.green = 0;
@ -363,15 +373,17 @@ setPointerColor(GC color)
/* event handlers functions */ /* event handlers functions */
void destroy(void){} void destroy(void)
{
}
void buttonPress(int button, int state, int x, int y) void buttonPress(int button, int state, int x, int y)
{ {
int *data = malloc(sizeof(int*)); int *data = malloc(sizeof(int *));
*data = button; *data = button;
DAProcessActionRects(x, y, actionRects[0], 3, (void*)data); DAProcessActionRects(x, y, actionRects[0], 3, (void *)data);
free(data); free(data);
} }
@ -407,9 +419,8 @@ mouseLeave(void)
/* if the button is still depressed, make it go up again. */ /* if the button is still depressed, make it go up again. */
/* TODO: Use data in actionRects[4] here instead of below check */ /* TODO: Use data in actionRects[4] here instead of below check */
if (buttonDown != NULL) { if (buttonDown != NULL)
btnUp(0, 0, *buttonDown, NULL); btnUp(0, 0, *buttonDown, NULL);
}
drawSlider(actionRects[4][1].rect); drawSlider(actionRects[4][1].rect);
} }
@ -435,7 +446,9 @@ btnUp(int x, int y, DARect rect, void *data)
void void
btnLeave(int x, int y, DARect rect, void *data) btnLeave(int x, int y, DARect rect, void *data)
{ {
if (buttonDown == NULL) return; if (buttonDown == NULL)
return;
drawRaisedFrame(rect); drawRaisedFrame(rect);
} }
@ -447,7 +460,7 @@ squareDown(int x, int y, DARect rect, void *data)
int button; int button;
if (data) { if (data) {
int *tmp = (int*)data; int *tmp = (int *)data;
button = *tmp; button = *tmp;
} else } else
@ -482,19 +495,24 @@ sliderMove(int x, int y, DARect rect, void *data)
rect.y != buttonDown->y || rect.y != buttonDown->y ||
rect.width != buttonDown->width || rect.width != buttonDown->width ||
rect.height != buttonDown->height */) rect.height != buttonDown->height */)
{
return; return;
}
sliderPos = (float)(rect.height - y)/(float)rect.height; sliderPos = (float)(rect.height - y) / (float)rect.height;
if (sliderPos > 1.0) sliderPos = 1.0; if (sliderPos > 1.0)
if (sliderPos < 0.0) sliderPos = 0.0; sliderPos = 1.0;
if (sliderPos < 0.0)
sliderPos = 0.0;
drawSlider(rect); drawSlider(rect);
} }
void sliderEnter(int x, int y, DARect rect, void *data) {} void sliderEnter(int x, int y, DARect rect, void *data)
void sliderLeave(int x, int y, DARect rect, void *data) {} {
}
void sliderLeave(int x, int y, DARect rect, void *data)
{
}
@ -506,7 +524,7 @@ createBtn(DARect rect)
{ {
/* fill square excluding borders */ /* fill square excluding borders */
XFillRectangle(DADisplay, pixmap, colors->lightGray, XFillRectangle(DADisplay, pixmap, colors->lightGray,
rect.x +1, rect.y +1, rect.width -2, rect.height -2); rect.x + 1, rect.y + 1, rect.width - 2, rect.height - 2);
drawRaisedFrame(rect); drawRaisedFrame(rect);
} }
@ -517,18 +535,18 @@ drawRaisedFrame(DARect rect)
{ {
/* left border */ /* left border */
XDrawLine(DADisplay, pixmap, colors->white, XDrawLine(DADisplay, pixmap, colors->white,
rect.x, rect.y, rect.x, rect.y + rect.height -2); rect.x, rect.y, rect.x, rect.y + rect.height - 2);
/* top border */ /* top border */
XDrawLine(DADisplay, pixmap, colors->white, XDrawLine(DADisplay, pixmap, colors->white,
rect.x +1, rect.y, rect.width -1, rect.y); rect.x + 1, rect.y, rect.width - 1, rect.y);
/* bottom border */ /* bottom border */
XDrawLine(DADisplay, pixmap, colors->darkGray, XDrawLine(DADisplay, pixmap, colors->darkGray,
rect.x, rect.y + rect.height -1, rect.x, rect.y + rect.height - 1,
rect.x + rect.width -1, rect.y + rect.height -1); rect.x + rect.width - 1, rect.y + rect.height - 1);
/* right border */ /* right border */
XDrawLine(DADisplay, pixmap, colors->darkGray, XDrawLine(DADisplay, pixmap, colors->darkGray,
rect.x + rect.width -1, rect.y +1, rect.x + rect.width - 1, rect.y + 1,
rect.x + rect.width -1, rect.y + rect.height -2); rect.x + rect.width - 1, rect.y + rect.height - 2);
DASetPixmap(pixmap); DASetPixmap(pixmap);
} }
@ -539,18 +557,18 @@ drawSunkenFrame(DARect rect)
{ {
/* left border */ /* left border */
XDrawLine(DADisplay, pixmap, colors->darkGray, XDrawLine(DADisplay, pixmap, colors->darkGray,
rect.x, rect.y, rect.x, rect.y + rect.height -2); rect.x, rect.y, rect.x, rect.y + rect.height - 2);
/* top border */ /* top border */
XDrawLine(DADisplay, pixmap, colors->darkGray, XDrawLine(DADisplay, pixmap, colors->darkGray,
rect.x +1, rect.y, rect.width -1, rect.y); rect.x + 1, rect.y, rect.width - 1, rect.y);
/* bottom border */ /* bottom border */
XDrawLine(DADisplay, pixmap, colors->white, XDrawLine(DADisplay, pixmap, colors->white,
rect.x, rect.y + rect.height -1, rect.x, rect.y + rect.height - 1,
rect.x + rect.width -1, rect.y + rect.height -1); rect.x + rect.width - 1, rect.y + rect.height - 1);
/* right border */ /* right border */
XDrawLine(DADisplay, pixmap, colors->white, XDrawLine(DADisplay, pixmap, colors->white,
rect.x + rect.width -1, rect.y +1, rect.x + rect.width - 1, rect.y + 1,
rect.x + rect.width -1, rect.y + rect.height -2); rect.x + rect.width - 1, rect.y + rect.height - 2);
DASetPixmap(pixmap); DASetPixmap(pixmap);
} }
@ -561,10 +579,10 @@ createSquare(DARect rect)
{ {
/* fill square excluding borders */ /* fill square excluding borders */
XFillRectangle(DADisplay, pixmap, colors->black, XFillRectangle(DADisplay, pixmap, colors->black,
rect.x +1, rect.y +1, rect.width -2, rect.height -2); rect.x + 1, rect.y + 1, rect.width - 2, rect.height - 2);
XDrawRectangle(DADisplay, pixmap, colors->lightGray, XDrawRectangle(DADisplay, pixmap, colors->lightGray,
rect.x, rect.y, rect.width -1, rect.height -1); rect.x, rect.y, rect.width - 1, rect.height - 1);
drawSquare(rect, 0); drawSquare(rect, 0);
} }
@ -576,11 +594,11 @@ drawSquare(DARect rect, int button)
char label[3]; char label[3];
XFillRectangle(DADisplay, pixmap, colors->black, XFillRectangle(DADisplay, pixmap, colors->black,
rect.x +1, rect.y +1, rect.width -2, rect.height -2); rect.x + 1, rect.y + 1, rect.width - 2, rect.height - 2);
snprintf(label, 3, "%2d", button); snprintf(label, 3, "%2d", button);
XDrawString(DADisplay, pixmap, colors->white, XDrawString(DADisplay, pixmap, colors->white,
rect.x +3, rect.y + rect.height -5, label, 2); rect.x + 3, rect.y + rect.height - 5, label, 2);
DASetPixmap(pixmap); DASetPixmap(pixmap);
} }
@ -591,7 +609,7 @@ createSlider(DARect rect)
{ {
/* fill square excluding borders */ /* fill square excluding borders */
XFillRectangle(DADisplay, pixmap, colors->black, XFillRectangle(DADisplay, pixmap, colors->black,
rect.x +1, rect.y +1, rect.width -2, rect.height -2); rect.x + 1, rect.y + 1, rect.width - 2, rect.height - 2);
drawSunkenFrame(rect); drawSunkenFrame(rect);
@ -615,22 +633,22 @@ drawSlider(DARect rect)
/* Draw two lines from bottom to sliderPos fraction of height */ /* Draw two lines from bottom to sliderPos fraction of height */
if (sliderPos < 1.0) { if (sliderPos < 1.0) {
XDrawLine(DADisplay, pixmap, highColor, XDrawLine(DADisplay, pixmap, highColor,
rect.x + 6, rect.y + rect.height -2, rect.x + 6, rect.y + rect.height - 2,
rect.x + 6, rect.y + (1.0 - sliderPos) * (rect.height -2)); rect.x + 6, rect.y + (1.0 - sliderPos) * (rect.height - 2));
XDrawLine(DADisplay, pixmap, highColor, XDrawLine(DADisplay, pixmap, highColor,
rect.x + 17, rect.y + rect.height -2, rect.x + 17, rect.y + rect.height - 2,
rect.x + 17, rect.y + (1.0 - sliderPos) * (rect.height -2)); rect.x + 17, rect.y + (1.0 - sliderPos) * (rect.height - 2));
} }
if (sliderPos > 0.0) { if (sliderPos > 0.0) {
XDrawLine(DADisplay, pixmap, lowColor, XDrawLine(DADisplay, pixmap, lowColor,
rect.x + 6, rect.y +1, rect.x + 6, rect.y + 1,
rect.x + 6, rect.y + (1.0 - sliderPos) * (rect.height -2)); rect.x + 6, rect.y + (1.0 - sliderPos) * (rect.height - 2));
XDrawLine(DADisplay, pixmap, lowColor, XDrawLine(DADisplay, pixmap, lowColor,
rect.x + 17, rect.y +1, rect.x + 17, rect.y + 1,
rect.x + 17, rect.y + (1.0 - sliderPos) * (rect.height -2)); rect.x + 17, rect.y + (1.0 - sliderPos) * (rect.height - 2));
} }
DASetPixmap(pixmap); DASetPixmap(pixmap);

View file

@ -34,12 +34,12 @@ extern struct DAContext *_daContext;
* Prototypes * Prototypes
*/ */
static void _daContextAddDefaultOptions(); static void _daContextAddDefaultOptions(void);
static void _daContextAddOptions(DAProgramOption *options, int count); static void _daContextAddOptions(DAProgramOption *options, int count);
static void printHelp(char *description); static void printHelp(char *description);
int contains(char *needle, char *haystack); int contains(char *needle, char *haystack);
int parseOption(DAProgramOption *option, int i, int argc, char** argv); int parseOption(DAProgramOption *option, int i, int argc, char **argv);
int readIntOption(int index, char **argv); int readIntOption(int index, char **argv);
/* /*
@ -64,7 +64,7 @@ DAParseArguments(
_daContext->argv = argv; _daContext->argv = argv;
_daContext->programName = argv[0]; _daContext->programName = argv[0];
size = (count + DEFAULT_OPTION_COUNT) * sizeof(DAProgramOption*); size = (count + DEFAULT_OPTION_COUNT) * sizeof(DAProgramOption *);
_daContext->options = malloc(size); _daContext->options = malloc(size);
memset(_daContext->options, 0, size); memset(_daContext->options, 0, size);
@ -100,7 +100,7 @@ DAParseArguments(
} }
/* mixed options */ /* mixed options */
if (!found) { if (!found)
/* XXX: Parsing all options again... */ /* XXX: Parsing all options again... */
for (j = 0; j < count; j++) { for (j = 0; j < count; j++) {
DAProgramOption *option = &options[j]; DAProgramOption *option = &options[j];
@ -110,7 +110,6 @@ DAParseArguments(
i = parseOption(option, i, argc, argv); i = parseOption(option, i, argc, argv);
} }
} }
}
if (!found) { if (!found) {
printf("%s: unrecognized option '%s'\n", argv[0], argv[i]); printf("%s: unrecognized option '%s'\n", argv[0], argv[i]);
@ -134,7 +133,7 @@ contains(char *needle, char *haystack)
} }
int int
parseOption(DAProgramOption *option, int i, int argc, char** argv) parseOption(DAProgramOption *option, int i, int argc, char **argv)
{ {
option->used = True; option->used = True;
@ -190,13 +189,13 @@ DAGetArgC()
return _daContext->argc; return _daContext->argc;
} }
char** char **
DAGetArgV() DAGetArgV()
{ {
return _daContext->argv; return _daContext->argv;
} }
char* char *
DAGetProgramName() DAGetProgramName()
{ {
return _daContext->programName; return _daContext->programName;
@ -207,8 +206,8 @@ DAGetProgramName()
* Local functions * Local functions
*/ */
struct DAContext* struct DAContext *
DAContextInit() DAContextInit(void)
{ {
struct DAContext *context = malloc(sizeof(struct DAContext)); struct DAContext *context = malloc(sizeof(struct DAContext));
@ -218,14 +217,13 @@ DAContextInit()
} }
void void
DAFreeContext() DAFreeContext(void)
{ {
if (_daContext->optionCount > 0) { if (_daContext->optionCount > 0) {
int i; int i;
for (i = 0; i < _daContext->optionCount; i++) { for (i = 0; i < _daContext->optionCount; i++)
free(_daContext->options[i]); free(_daContext->options[i]);
}
free(_daContext->options); free(_daContext->options);
} }
@ -237,12 +235,11 @@ static void
_daContextAddOption(DAProgramOption *option) _daContextAddOption(DAProgramOption *option)
{ {
/* If the buffer is full, double its size */ /* If the buffer is full, double its size */
if (sizeof(_daContext->options) == _daContext->optionCount * sizeof(DAProgramOption)) if (sizeof(_daContext->options) == _daContext->optionCount * sizeof(DAProgramOption)) {
{
DAProgramOption **options; DAProgramOption **options;
options = (DAProgramOption**)realloc( options = (DAProgramOption **)realloc(
(DAProgramOption**)_daContext->options, (DAProgramOption **)_daContext->options,
2 * sizeof(_daContext->options)); 2 * sizeof(_daContext->options));
if (options == NULL) if (options == NULL)
@ -272,7 +269,7 @@ _daContextAddOptionData(char *shortForm, char *longForm,
} }
static void static void
_daContextAddDefaultOptions() _daContextAddDefaultOptions(void)
{ {
_daContextAddOptionData("-h", "--help", "show this help text and exit", DONone); _daContextAddOptionData("-h", "--help", "show this help text and exit", DONone);
_daContextAddOptionData("-v", "--version", "show program version and exit", DONone); _daContextAddOptionData("-v", "--version", "show program version and exit", DONone);
@ -284,13 +281,12 @@ _daContextAddOptions(DAProgramOption *options, int count)
{ {
int i; int i;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++)
_daContextAddOptionData( _daContextAddOptionData(
options[i].shortForm, options[i].shortForm,
options[i].longForm, options[i].longForm,
options[i].description, options[i].description,
options[i].type); options[i].type);
}
} }
static void static void
@ -304,8 +300,7 @@ printHelp(char *description)
if (description) if (description)
puts(description); puts(description);
for (i = 0; i < count; i++) for (i = 0; i < count; i++) {
{
char blank[30]; char blank[30];
int c; int c;

View file

@ -42,6 +42,6 @@ struct DAContext {
}; };
struct DAContext* DAContextInit(); struct DAContext *DAContextInit(void);
void DAFreeContext(); void DAFreeContext(void);

View file

@ -55,9 +55,8 @@ DAProcessEventForWindow(Window window, XEvent *event)
switch (event->type) { switch (event->type) {
case ClientMessage: case ClientMessage:
if (event->xclient.data.l[0] != WM_DELETE_WINDOW) { if (event->xclient.data.l[0] != WM_DELETE_WINDOW)
break; break;
}
/* fallthrough */ /* fallthrough */
case DestroyNotify: case DestroyNotify:
if (_daContext->callbacks.destroy) if (_daContext->callbacks.destroy)
@ -116,15 +115,14 @@ DAEventLoopForWindow(Window window)
{ {
XEvent event; XEvent event;
for (;;) { for (;; ) {
if (_daContext->timeOut >= 0) { if (_daContext->timeOut >= 0) {
if (!DANextEventOrTimeout(&event, _daContext->timeOut)) { if (!DANextEventOrTimeout(&event, _daContext->timeOut)) {
if (_daContext->callbacks.timeout) if (_daContext->callbacks.timeout)
(*_daContext->callbacks.timeout)(); (*_daContext->callbacks.timeout)();
continue; continue;
} }
} } else
else
XNextEvent(DADisplay, &event); XNextEvent(DADisplay, &event);
DAProcessEventForWindow(window, &event); DAProcessEventForWindow(window, &event);

View file

@ -98,7 +98,7 @@ DAProposeIconSize(unsigned width, unsigned height)
(height < iconSizes[i].min_height)) (height < iconSizes[i].min_height))
continue; continue;
w1 = (iconSizes[i].max_width - width ) % iconSizes[i].width_inc; w1 = (iconSizes[i].max_width - width) % iconSizes[i].width_inc;
h1 = (iconSizes[i].max_height - height) % iconSizes[i].height_inc; h1 = (iconSizes[i].max_height - height) % iconSizes[i].height_inc;
w = MIN(w1, iconSizes[i].width_inc - w1); w = MIN(w1, iconSizes[i].width_inc - w1);
h = MIN(h1, iconSizes[i].height_inc - h1); h = MIN(h1, iconSizes[i].height_inc - h1);
@ -115,12 +115,11 @@ DAProposeIconSize(unsigned width, unsigned height)
DAPreferredIconSizes.width = max_w; DAPreferredIconSizes.width = max_w;
DAPreferredIconSizes.height = max_h; DAPreferredIconSizes.height = max_h;
if (da == -1) { /* requested size is out of bounds */ if (da == -1) /* requested size is out of bounds */
DAWarning("Requested icon-size (%d x %d) is out of the range " DAWarning("Requested icon-size (%d x %d) is out of the range "
"allowed by the window manager\n", "allowed by the window manager\n",
_daContext->width, _daContext->height); _daContext->width, _daContext->height);
} }
}
XFree(iconSizes); XFree(iconSizes);
} }
@ -141,7 +140,7 @@ DACreateIcon(char *name, unsigned width, unsigned height, int argc, char **argv)
DALeader = XCreateSimpleWindow(DADisplay, DefaultRootWindow(DADisplay), DALeader = XCreateSimpleWindow(DADisplay, DefaultRootWindow(DADisplay),
0, 0, width, height, 0, 0, 0); 0, 0, width, height, 0, 0, 0);
if (! _daContext->windowed) { if (!_daContext->windowed) {
DAIcon = XCreateSimpleWindow(DADisplay, DefaultRootWindow(DADisplay), DAIcon = XCreateSimpleWindow(DADisplay, DefaultRootWindow(DADisplay),
0, 0, width, height, 0, 0, 0); 0, 0, width, height, 0, 0, 0);
DAWindow = DAIcon; DAWindow = DAIcon;
@ -151,7 +150,8 @@ DACreateIcon(char *name, unsigned width, unsigned height, int argc, char **argv)
} }
/* Set ClassHint */ /* Set ClassHint */
if (!(classHint = XAllocClassHint())) classHint = XAllocClassHint();
if (!classHint)
printf("%s: can't allocate memory for class hints!\n", printf("%s: can't allocate memory for class hints!\n",
_daContext->programName), exit(1); _daContext->programName), exit(1);
classHint->res_class = RES_CLASSNAME; classHint->res_class = RES_CLASSNAME;
@ -161,7 +161,8 @@ DACreateIcon(char *name, unsigned width, unsigned height, int argc, char **argv)
XFree(classHint); XFree(classHint);
/* Set WMHints */ /* Set WMHints */
if (!(wmHints = XAllocWMHints())) wmHints = XAllocWMHints();
if (!wmHints)
printf("%s: can't allocate memory for wm hints!\n", printf("%s: can't allocate memory for wm hints!\n",
_daContext->programName), exit(1); _daContext->programName), exit(1);
@ -198,9 +199,8 @@ DACreateIcon(char *name, unsigned width, unsigned height, int argc, char **argv)
/* set background GC values before setting value for foreground */ /* set background GC values before setting value for foreground */
resourceValue = XGetDefault(DADisplay, RES_CLASSNAME, "background"); resourceValue = XGetDefault(DADisplay, RES_CLASSNAME, "background");
if (resourceValue) { if (resourceValue)
gcv.foreground = DAGetColor(resourceValue); gcv.foreground = DAGetColor(resourceValue);
}
DAClearGC = XCreateGC(DADisplay, DAWindow, DAClearGC = XCreateGC(DADisplay, DAWindow,
GCGraphicsExposures|GCForeground, &gcv); GCGraphicsExposures|GCForeground, &gcv);
@ -221,11 +221,10 @@ DAShowWindow(Window window)
{ {
XMapRaised(DADisplay, window); XMapRaised(DADisplay, window);
if ((window == DALeader) && !_daContext->windowed) { if ((window == DALeader) && !_daContext->windowed)
XMapSubwindows(DADisplay, DAIcon); XMapSubwindows(DADisplay, DAIcon);
} else { else
XMapSubwindows(DADisplay, window); XMapSubwindows(DADisplay, window);
}
XFlush(DADisplay); XFlush(DADisplay);
} }

View file

@ -104,7 +104,7 @@ DAMakePixmapFromFile(char *filename, Pixmap *pixmap, Pixmap *mask,
if (access(filename, R_OK) < 0) if (access(filename, R_OK) < 0)
return False; return False;
return _daMakePixmap(daXpmSourceFile, (char**)filename, return _daMakePixmap(daXpmSourceFile, (char **)filename,
pixmap, mask, pixmap, mask,
width, height); width, height);
} }
@ -129,7 +129,7 @@ _daMakePixmap(daXpmSource source,
else if (source == daXpmSourceFile else if (source == daXpmSourceFile
&& (XpmReadFileToPixmap( && (XpmReadFileToPixmap(
DADisplay, DAWindow, (char*)data, pixmap, mask, &xpmAttr) != 0)) DADisplay, DAWindow, (char *)data, pixmap, mask, &xpmAttr) != 0))
return False; return False;
*width = xpmAttr.width; *width = xpmAttr.width;

View file

@ -33,7 +33,7 @@ DAProcessActionRects(int x, int y, DAActionRect *actionrects, int count,
if (!actionrects) if (!actionrects)
return; return;
while ( (index < count) && while ((index < count) &&
((x < actionrects[index].rect.x) || ((x < actionrects[index].rect.x) ||
(x > actionrects[index].rect.x + actionrects[index].rect.width) || (x > actionrects[index].rect.x + actionrects[index].rect.width) ||
(y < actionrects[index].rect.y) || (y < actionrects[index].rect.y) ||

View file

@ -38,12 +38,12 @@ typedef enum {
/* local functions */ /* local functions */
void setGCs(DAShapedPixmap *dasp); void setGCs(DAShapedPixmap *dasp);
DAShapedPixmap* _daMakeShapedPixmap(daShapeSource source, char **data); DAShapedPixmap *_daMakeShapedPixmap(daShapeSource source, char **data);
extern struct DAContext *_daContext; extern struct DAContext *_daContext;
/* Create a new shaped pixmap with width & height of dockapp window */ /* Create a new shaped pixmap with width & height of dockapp window */
DAShapedPixmap* DAShapedPixmap *
DAMakeShapedPixmap() DAMakeShapedPixmap()
{ {
DAShapedPixmap *dasp = malloc(sizeof(DAShapedPixmap)); DAShapedPixmap *dasp = malloc(sizeof(DAShapedPixmap));
@ -65,7 +65,7 @@ DAMakeShapedPixmap()
/* Create a new shaped pixmap from XPM-data */ /* Create a new shaped pixmap from XPM-data */
DAShapedPixmap* DAShapedPixmap *
DAMakeShapedPixmapFromData(char **data) DAMakeShapedPixmapFromData(char **data)
{ {
return _daMakeShapedPixmap(daShapeSourceData, data); return _daMakeShapedPixmap(daShapeSourceData, data);
@ -73,10 +73,10 @@ DAMakeShapedPixmapFromData(char **data)
/* Create a new shaped pixmap from XPM-data */ /* Create a new shaped pixmap from XPM-data */
DAShapedPixmap* DAShapedPixmap *
DAMakeShapedPixmapFromFile(char *filename) DAMakeShapedPixmapFromFile(char *filename)
{ {
return _daMakeShapedPixmap(daShapeSourceFile, (char**)filename); return _daMakeShapedPixmap(daShapeSourceFile, (char **)filename);
} }
@ -168,7 +168,7 @@ setGCs(DAShapedPixmap *dasp)
/* Create a new shaped pixmap using specified method */ /* Create a new shaped pixmap using specified method */
DAShapedPixmap* DAShapedPixmap *
_daMakeShapedPixmap(daShapeSource source, char **data) _daMakeShapedPixmap(daShapeSource source, char **data)
{ {
Bool success; Bool success;
@ -183,7 +183,7 @@ _daMakeShapedPixmap(daShapeSource source, char **data)
success = DAMakePixmapFromData(data, &dasp->pixmap, &dasp->shape, success = DAMakePixmapFromData(data, &dasp->pixmap, &dasp->shape,
&dasp->geometry.width, &dasp->geometry.height); &dasp->geometry.width, &dasp->geometry.height);
else else
success = DAMakePixmapFromFile((char*)data, &dasp->pixmap, &dasp->shape, success = DAMakePixmapFromFile((char *)data, &dasp->pixmap, &dasp->shape,
&dasp->geometry.width, &dasp->geometry.height); &dasp->geometry.width, &dasp->geometry.height);
if (!success) if (!success)

View file

@ -49,7 +49,7 @@ DASetExpectedVersion(unsigned long expectedVersion)
} }
Display* Display *
DAGetDisplay(char *d, ...) DAGetDisplay(char *d, ...)
{ {
/* Be backward compatible */ /* Be backward compatible */
@ -60,7 +60,7 @@ DAGetDisplay(char *d, ...)
va_start(ap, d); va_start(ap, d);
argc = va_arg(ap, int); argc = va_arg(ap, int);
argv = va_arg(ap, char**); argv = va_arg(ap, char **);
va_end(ap); va_end(ap);
DAOpenDisplay(d, argc, argv); DAOpenDisplay(d, argc, argv);
@ -138,7 +138,7 @@ DASetDepth(int depth)
} }
Visual* Visual *
DAGetVisual(void) DAGetVisual(void)
{ {
return DAVisual; return DAVisual;
@ -184,10 +184,10 @@ _message(const char *label, const char *fmt, va_list args)
if (_daContext->programName != NULL) { if (_daContext->programName != NULL) {
/* put default string in front of message, add newline */ /* put default string in front of message, add newline */
w_fmt = malloc((strlen(_daContext->programName) + strlen(fmt) +13) * sizeof(char)); w_fmt = malloc((strlen(_daContext->programName) + strlen(fmt) + 13) * sizeof(char));
sprintf(w_fmt, "%s: %s: %s\n", _daContext->programName, label, fmt); sprintf(w_fmt, "%s: %s: %s\n", _daContext->programName, label, fmt);
} else { } else {
w_fmt = malloc((strlen(fmt) +1) * sizeof(char)); w_fmt = malloc((strlen(fmt) + 1) * sizeof(char));
sprintf(w_fmt, "%s\n", fmt); sprintf(w_fmt, "%s\n", fmt);
} }

View file

@ -203,11 +203,11 @@ void DAProposeIconSize(unsigned width, unsigned height);
* only. * only.
* XXX: Argument list is a kludge. * XXX: Argument list is a kludge.
*/ */
Display* DAGetDisplay(char *d, ...); Display *DAGetDisplay(char *d, ...);
void DASetDisplay(Display *display); void DASetDisplay(Display *display);
/* Get program name (from argv[0]). Returns a reference. */ /* Get program name (from argv[0]). Returns a reference. */
char* DAGetProgramName(); char *DAGetProgramName();
/* Get/Set DAWindow and DALeader values respectively. For use with external code. */ /* Get/Set DAWindow and DALeader values respectively. For use with external code. */
Window DAGetWindow(void); Window DAGetWindow(void);
@ -224,7 +224,7 @@ int DAGetDepth(void);
void DASetDepth(int depth); void DASetDepth(int depth);
/* Get/Set DAVisual; the visual type for the screen. For use with external code. */ /* Get/Set DAVisual; the visual type for the screen. For use with external code. */
Visual* DAGetVisual(void); Visual *DAGetVisual(void);
void DASetVisual(Visual *visual); void DASetVisual(Visual *visual);
@ -285,21 +285,21 @@ Bool DAMakePixmapFromFile(char *filename, Pixmap *pixmap, Pixmap *mask,
* DAMakeShapedPixmap- * DAMakeShapedPixmap-
* Creates a shaped pixmap with width & height of dockapp window. * Creates a shaped pixmap with width & height of dockapp window.
*/ */
DAShapedPixmap* DAMakeShapedPixmap(); DAShapedPixmap *DAMakeShapedPixmap();
/* /*
* DAMakeShapedPixmapFromData- * DAMakeShapedPixmapFromData-
* Creates a shaped pixmap from XPM-data. * Creates a shaped pixmap from XPM-data.
* Returns shaped pixmap on success, NULL on failure. * Returns shaped pixmap on success, NULL on failure.
*/ */
DAShapedPixmap* DAMakeShapedPixmapFromData(char **data); DAShapedPixmap *DAMakeShapedPixmapFromData(char **data);
/* /*
* DAMakeShapedPixmapFromFile- * DAMakeShapedPixmapFromFile-
* Creates a shaped pixmap from an XPM file. * Creates a shaped pixmap from an XPM file.
* Returns shaped pixmap on success, NULL on failure. * Returns shaped pixmap on success, NULL on failure.
*/ */
DAShapedPixmap* DAMakeShapedPixmapFromFile(char *filename); DAShapedPixmap *DAMakeShapedPixmapFromFile(char *filename);
/* /*
* DAFreeShapedPixmap- * DAFreeShapedPixmap-