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:
parent
b002ed2e01
commit
19bf1f277f
|
@ -19,9 +19,9 @@
|
|||
/*
|
||||
* Prototypes for local functions
|
||||
*/
|
||||
void drawRelief();
|
||||
void moveBall();
|
||||
void destroy();
|
||||
void drawRelief(Pixmap pixmap);
|
||||
void moveBall(void);
|
||||
void destroy(void);
|
||||
|
||||
/*
|
||||
* Global variables
|
||||
|
@ -36,7 +36,7 @@ DAShapedPixmap *ballPix;
|
|||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
unsigned int x=1, y=1;
|
||||
unsigned int x = 1, y = 1;
|
||||
Pixmap back;
|
||||
DACallbacks eventCallbacks = {
|
||||
destroy, /* destroy */
|
||||
|
@ -135,11 +135,11 @@ drawRelief(Pixmap pixmap)
|
|||
gcv.graphics_exposures = False;
|
||||
|
||||
lightGrayGC = XCreateGC(DADisplay, DAWindow,
|
||||
GCForeground|GCGraphicsExposures, &gcv);
|
||||
GCForeground | GCGraphicsExposures, &gcv);
|
||||
|
||||
gcv.foreground = DAGetColor("#222222");
|
||||
darkGrayGC = XCreateGC(DADisplay, DAWindow,
|
||||
GCForeground|GCGraphicsExposures, &gcv);
|
||||
GCForeground | GCGraphicsExposures, &gcv);
|
||||
|
||||
/* Drawing */
|
||||
XFillRectangle(DADisplay, pixmap, DAClearGC, 1, 1, 46, 46);
|
||||
|
@ -157,18 +157,25 @@ drawRelief(Pixmap pixmap)
|
|||
|
||||
|
||||
void
|
||||
moveBall()
|
||||
moveBall(void)
|
||||
{
|
||||
static int x = 1;
|
||||
static int y = 1;
|
||||
static int dx = 0;
|
||||
static int dy = 0;
|
||||
signed int var = random()%3 -1;
|
||||
static int dx;
|
||||
static int dy;
|
||||
signed int var = random() % 3 - 1;
|
||||
|
||||
if (dx == 0) dx = var;
|
||||
if (dy == 0) dy = var;
|
||||
if (dx > MAX_MOVE) dx = MAX_MOVE;
|
||||
if (dy > MAX_MOVE) dy = MAX_MOVE;
|
||||
if (dx == 0)
|
||||
dx = var;
|
||||
|
||||
if (dy == 0)
|
||||
dy = var;
|
||||
|
||||
if (dx > MAX_MOVE)
|
||||
dx = MAX_MOVE;
|
||||
|
||||
if (dy > MAX_MOVE)
|
||||
dy = MAX_MOVE;
|
||||
|
||||
/* calculate new position */
|
||||
x += dx;
|
||||
|
@ -204,6 +211,6 @@ destroy(void)
|
|||
XFreePixmap(DADisplay, ballPix->pixmap);
|
||||
XFreePixmap(DADisplay, ballPix->shape);
|
||||
|
||||
fprintf(stderr, "Destroyed!\n");
|
||||
fprintf(stderr, "Destroyed!\n");
|
||||
/* exit is done by libdockapp */
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ Cursor pointer;
|
|||
/*
|
||||
* Prototypes for local functions
|
||||
*/
|
||||
struct Colors* setGCs(Drawable d);
|
||||
struct Colors *setGCs(Drawable d);
|
||||
unsigned long adjustColor(unsigned long color, signed int adjustment);
|
||||
|
||||
/* drawing routines */
|
||||
|
@ -148,7 +148,7 @@ main(int argc, char **argv)
|
|||
/* XXX: make action rectangles available outside main()
|
||||
* ...libDockapp should be able to do this... (reminder)
|
||||
*/
|
||||
actionRects = malloc(6 * sizeof(DAActionRect*));
|
||||
actionRects = malloc(6 * sizeof(DAActionRect *));
|
||||
actionRects[0] = buttonPressRects;
|
||||
actionRects[1] = buttonReleaseRects;
|
||||
actionRects[2] = mouseMoveRects;
|
||||
|
@ -237,7 +237,7 @@ main(int argc, char **argv)
|
|||
|
||||
|
||||
/* Create our GC's to draw colored lines and such */
|
||||
struct Colors*
|
||||
struct Colors *
|
||||
setGCs(Drawable d)
|
||||
{
|
||||
struct Colors *colors;
|
||||
|
@ -251,7 +251,7 @@ setGCs(Drawable d)
|
|||
|
||||
/* Get the GC-values of the default GC */
|
||||
XGetGCValues(DADisplay, DAGC,
|
||||
GCForeground|GCBackground|GCGraphicsExposures, &gcv);
|
||||
GCForeground | GCBackground | GCGraphicsExposures, &gcv);
|
||||
|
||||
origColor = gcv.foreground;
|
||||
|
||||
|
@ -261,7 +261,7 @@ setGCs(Drawable d)
|
|||
/* GC for white color */
|
||||
gcv.foreground = WhitePixel(DADisplay, DefaultScreen(DADisplay));
|
||||
colors->white = XCreateGC(DADisplay, d,
|
||||
GCForeground|GCGraphicsExposures, &gcv);
|
||||
GCForeground | GCGraphicsExposures, &gcv);
|
||||
|
||||
/* GC for dark blue color */
|
||||
#if 1
|
||||
|
@ -270,17 +270,17 @@ setGCs(Drawable d)
|
|||
gcv.foreground = 0;
|
||||
#endif
|
||||
colors->black = XCreateGC(DADisplay, d,
|
||||
GCForeground|GCGraphicsExposures, &gcv);
|
||||
GCForeground | GCGraphicsExposures, &gcv);
|
||||
|
||||
/* GC for light borders */
|
||||
gcv.foreground = DAGetColor("lightGray");
|
||||
colors->lightGray = XCreateGC(DADisplay, d,
|
||||
GCForeground|GCGraphicsExposures, &gcv);
|
||||
GCForeground | GCGraphicsExposures, &gcv);
|
||||
|
||||
/* GC for dark borders (note re-use of gcv-values) */
|
||||
gcv.foreground = DAGetColor("#222222");
|
||||
colors->darkGray = XCreateGC(DADisplay, d,
|
||||
GCForeground|GCGraphicsExposures, &gcv);
|
||||
GCForeground | GCGraphicsExposures, &gcv);
|
||||
|
||||
/* GC for the un-/highlighted colors and dashed line of the slider */
|
||||
gcv.foreground = origColor;
|
||||
|
@ -288,8 +288,8 @@ setGCs(Drawable d)
|
|||
gcv.line_style = LineOnOffDash;
|
||||
|
||||
colors->slider = XCreateGC(DADisplay, d,
|
||||
GCForeground|GCBackground|GCGraphicsExposures|
|
||||
GCLineWidth|GCLineStyle, &gcv);
|
||||
GCForeground | GCBackground | GCGraphicsExposures |
|
||||
GCLineWidth | GCLineStyle, &gcv);
|
||||
|
||||
XSetDashes(DADisplay, colors->slider, 1, dashList, 2);
|
||||
|
||||
|
@ -297,8 +297,8 @@ setGCs(Drawable d)
|
|||
gcv.foreground = adjustColor(origColor, +0x40);
|
||||
|
||||
colors->sliderLight = XCreateGC(DADisplay, d,
|
||||
GCForeground|GCBackground|GCGraphicsExposures|
|
||||
GCLineWidth|GCLineStyle, &gcv);
|
||||
GCForeground | GCBackground | GCGraphicsExposures |
|
||||
GCLineWidth | GCLineStyle, &gcv);
|
||||
|
||||
XSetDashes(DADisplay, colors->sliderLight, 1, dashList, 2);
|
||||
|
||||
|
@ -306,8 +306,8 @@ setGCs(Drawable d)
|
|||
gcv.foreground = adjustColor(origColor, -0x40);
|
||||
|
||||
colors->sliderDark = XCreateGC(DADisplay, d,
|
||||
GCForeground|GCBackground|GCGraphicsExposures|
|
||||
GCLineWidth|GCLineStyle, &gcv);
|
||||
GCForeground | GCBackground | GCGraphicsExposures |
|
||||
GCLineWidth | GCLineStyle, &gcv);
|
||||
|
||||
XSetDashes(DADisplay, colors->sliderDark, 1, dashList, 2);
|
||||
|
||||
|
@ -329,13 +329,23 @@ adjustColor(unsigned long color, signed int adjustment)
|
|||
g += adjustment;
|
||||
b += adjustment;
|
||||
|
||||
if (r > 0xff) r = 0xff;
|
||||
if (g > 0xff) g = 0xff;
|
||||
if (b > 0xff) b = 0xff;
|
||||
if (r > 0xff)
|
||||
r = 0xff;
|
||||
|
||||
if (r < 0) r = 0;
|
||||
if (g < 0) g = 0;
|
||||
if (b < 0) b = 0;
|
||||
if (g > 0xff)
|
||||
g = 0xff;
|
||||
|
||||
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) +
|
||||
((unsigned short)g << 8) +
|
||||
|
@ -352,7 +362,7 @@ setPointerColor(GC color)
|
|||
XGetGCValues(DADisplay, color, GCForeground, &gcv);
|
||||
|
||||
fcolor.pixel = gcv.foreground;
|
||||
fcolor.flags = DoRed|DoGreen|DoBlue;
|
||||
fcolor.flags = DoRed | DoGreen | DoBlue;
|
||||
|
||||
bcolor.red = 0;
|
||||
bcolor.green = 0;
|
||||
|
@ -363,15 +373,17 @@ setPointerColor(GC color)
|
|||
|
||||
|
||||
/* event handlers functions */
|
||||
void destroy(void){}
|
||||
void destroy(void)
|
||||
{
|
||||
}
|
||||
|
||||
void buttonPress(int button, int state, int x, int y)
|
||||
{
|
||||
int *data = malloc(sizeof(int*));
|
||||
int *data = malloc(sizeof(int *));
|
||||
|
||||
*data = button;
|
||||
|
||||
DAProcessActionRects(x, y, actionRects[0], 3, (void*)data);
|
||||
DAProcessActionRects(x, y, actionRects[0], 3, (void *)data);
|
||||
|
||||
free(data);
|
||||
}
|
||||
|
@ -407,9 +419,8 @@ mouseLeave(void)
|
|||
|
||||
/* if the button is still depressed, make it go up again. */
|
||||
/* TODO: Use data in actionRects[4] here instead of below check */
|
||||
if (buttonDown != NULL) {
|
||||
if (buttonDown != NULL)
|
||||
btnUp(0, 0, *buttonDown, NULL);
|
||||
}
|
||||
|
||||
drawSlider(actionRects[4][1].rect);
|
||||
}
|
||||
|
@ -435,7 +446,9 @@ btnUp(int x, int y, DARect rect, void *data)
|
|||
void
|
||||
btnLeave(int x, int y, DARect rect, void *data)
|
||||
{
|
||||
if (buttonDown == NULL) return;
|
||||
if (buttonDown == NULL)
|
||||
return;
|
||||
|
||||
drawRaisedFrame(rect);
|
||||
}
|
||||
|
||||
|
@ -447,7 +460,7 @@ squareDown(int x, int y, DARect rect, void *data)
|
|||
int button;
|
||||
|
||||
if (data) {
|
||||
int *tmp = (int*)data;
|
||||
int *tmp = (int *)data;
|
||||
|
||||
button = *tmp;
|
||||
} else
|
||||
|
@ -482,19 +495,24 @@ sliderMove(int x, int y, DARect rect, void *data)
|
|||
rect.y != buttonDown->y ||
|
||||
rect.width != buttonDown->width ||
|
||||
rect.height != buttonDown->height */)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
sliderPos = (float)(rect.height - y)/(float)rect.height;
|
||||
if (sliderPos > 1.0) sliderPos = 1.0;
|
||||
if (sliderPos < 0.0) sliderPos = 0.0;
|
||||
sliderPos = (float)(rect.height - y) / (float)rect.height;
|
||||
if (sliderPos > 1.0)
|
||||
sliderPos = 1.0;
|
||||
|
||||
if (sliderPos < 0.0)
|
||||
sliderPos = 0.0;
|
||||
|
||||
drawSlider(rect);
|
||||
}
|
||||
|
||||
void sliderEnter(int x, int y, DARect rect, void *data) {}
|
||||
void sliderLeave(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)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -506,7 +524,7 @@ createBtn(DARect rect)
|
|||
{
|
||||
/* fill square excluding borders */
|
||||
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);
|
||||
}
|
||||
|
@ -517,18 +535,18 @@ drawRaisedFrame(DARect rect)
|
|||
{
|
||||
/* left border */
|
||||
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 */
|
||||
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 */
|
||||
XDrawLine(DADisplay, pixmap, colors->darkGray,
|
||||
rect.x, rect.y + rect.height -1,
|
||||
rect.x + rect.width -1, rect.y + rect.height -1);
|
||||
rect.x, rect.y + rect.height - 1,
|
||||
rect.x + rect.width - 1, rect.y + rect.height - 1);
|
||||
/* right border */
|
||||
XDrawLine(DADisplay, pixmap, colors->darkGray,
|
||||
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 + 1,
|
||||
rect.x + rect.width - 1, rect.y + rect.height - 2);
|
||||
|
||||
DASetPixmap(pixmap);
|
||||
}
|
||||
|
@ -539,18 +557,18 @@ drawSunkenFrame(DARect rect)
|
|||
{
|
||||
/* left border */
|
||||
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 */
|
||||
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 */
|
||||
XDrawLine(DADisplay, pixmap, colors->white,
|
||||
rect.x, rect.y + rect.height -1,
|
||||
rect.x + rect.width -1, rect.y + rect.height -1);
|
||||
rect.x, rect.y + rect.height - 1,
|
||||
rect.x + rect.width - 1, rect.y + rect.height - 1);
|
||||
/* right border */
|
||||
XDrawLine(DADisplay, pixmap, colors->white,
|
||||
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 + 1,
|
||||
rect.x + rect.width - 1, rect.y + rect.height - 2);
|
||||
|
||||
DASetPixmap(pixmap);
|
||||
}
|
||||
|
@ -561,10 +579,10 @@ createSquare(DARect rect)
|
|||
{
|
||||
/* fill square excluding borders */
|
||||
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,
|
||||
rect.x, rect.y, rect.width -1, rect.height -1);
|
||||
rect.x, rect.y, rect.width - 1, rect.height - 1);
|
||||
|
||||
drawSquare(rect, 0);
|
||||
}
|
||||
|
@ -576,11 +594,11 @@ drawSquare(DARect rect, int button)
|
|||
char label[3];
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
@ -591,7 +609,7 @@ createSlider(DARect rect)
|
|||
{
|
||||
/* fill square excluding borders */
|
||||
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);
|
||||
|
||||
|
@ -615,22 +633,22 @@ drawSlider(DARect rect)
|
|||
/* Draw two lines from bottom to sliderPos fraction of height */
|
||||
if (sliderPos < 1.0) {
|
||||
XDrawLine(DADisplay, pixmap, highColor,
|
||||
rect.x + 6, rect.y + rect.height -2,
|
||||
rect.x + 6, rect.y + (1.0 - sliderPos) * (rect.height -2));
|
||||
rect.x + 6, rect.y + rect.height - 2,
|
||||
rect.x + 6, rect.y + (1.0 - sliderPos) * (rect.height - 2));
|
||||
|
||||
XDrawLine(DADisplay, pixmap, highColor,
|
||||
rect.x + 17, rect.y + rect.height -2,
|
||||
rect.x + 17, rect.y + (1.0 - sliderPos) * (rect.height -2));
|
||||
rect.x + 17, rect.y + rect.height - 2,
|
||||
rect.x + 17, rect.y + (1.0 - sliderPos) * (rect.height - 2));
|
||||
}
|
||||
|
||||
if (sliderPos > 0.0) {
|
||||
XDrawLine(DADisplay, pixmap, lowColor,
|
||||
rect.x + 6, rect.y +1,
|
||||
rect.x + 6, rect.y + (1.0 - sliderPos) * (rect.height -2));
|
||||
rect.x + 6, rect.y + 1,
|
||||
rect.x + 6, rect.y + (1.0 - sliderPos) * (rect.height - 2));
|
||||
|
||||
XDrawLine(DADisplay, pixmap, lowColor,
|
||||
rect.x + 17, rect.y +1,
|
||||
rect.x + 17, rect.y + (1.0 - sliderPos) * (rect.height -2));
|
||||
rect.x + 17, rect.y + 1,
|
||||
rect.x + 17, rect.y + (1.0 - sliderPos) * (rect.height - 2));
|
||||
}
|
||||
|
||||
DASetPixmap(pixmap);
|
||||
|
|
|
@ -34,12 +34,12 @@ extern struct DAContext *_daContext;
|
|||
* Prototypes
|
||||
*/
|
||||
|
||||
static void _daContextAddDefaultOptions();
|
||||
static void _daContextAddDefaultOptions(void);
|
||||
static void _daContextAddOptions(DAProgramOption *options, int count);
|
||||
static void printHelp(char *description);
|
||||
|
||||
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);
|
||||
|
||||
/*
|
||||
|
@ -64,7 +64,7 @@ DAParseArguments(
|
|||
_daContext->argv = argv;
|
||||
_daContext->programName = argv[0];
|
||||
|
||||
size = (count + DEFAULT_OPTION_COUNT) * sizeof(DAProgramOption*);
|
||||
size = (count + DEFAULT_OPTION_COUNT) * sizeof(DAProgramOption *);
|
||||
_daContext->options = malloc(size);
|
||||
memset(_daContext->options, 0, size);
|
||||
|
||||
|
@ -100,7 +100,7 @@ DAParseArguments(
|
|||
}
|
||||
|
||||
/* mixed options */
|
||||
if (!found) {
|
||||
if (!found)
|
||||
/* XXX: Parsing all options again... */
|
||||
for (j = 0; j < count; j++) {
|
||||
DAProgramOption *option = &options[j];
|
||||
|
@ -110,7 +110,6 @@ DAParseArguments(
|
|||
i = parseOption(option, i, argc, argv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
printf("%s: unrecognized option '%s'\n", argv[0], argv[i]);
|
||||
|
@ -134,7 +133,7 @@ contains(char *needle, char *haystack)
|
|||
}
|
||||
|
||||
int
|
||||
parseOption(DAProgramOption *option, int i, int argc, char** argv)
|
||||
parseOption(DAProgramOption *option, int i, int argc, char **argv)
|
||||
{
|
||||
option->used = True;
|
||||
|
||||
|
@ -190,13 +189,13 @@ DAGetArgC()
|
|||
return _daContext->argc;
|
||||
}
|
||||
|
||||
char**
|
||||
char **
|
||||
DAGetArgV()
|
||||
{
|
||||
return _daContext->argv;
|
||||
}
|
||||
|
||||
char*
|
||||
char *
|
||||
DAGetProgramName()
|
||||
{
|
||||
return _daContext->programName;
|
||||
|
@ -207,8 +206,8 @@ DAGetProgramName()
|
|||
* Local functions
|
||||
*/
|
||||
|
||||
struct DAContext*
|
||||
DAContextInit()
|
||||
struct DAContext *
|
||||
DAContextInit(void)
|
||||
{
|
||||
struct DAContext *context = malloc(sizeof(struct DAContext));
|
||||
|
||||
|
@ -218,14 +217,13 @@ DAContextInit()
|
|||
}
|
||||
|
||||
void
|
||||
DAFreeContext()
|
||||
DAFreeContext(void)
|
||||
{
|
||||
if (_daContext->optionCount > 0) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < _daContext->optionCount; i++) {
|
||||
for (i = 0; i < _daContext->optionCount; i++)
|
||||
free(_daContext->options[i]);
|
||||
}
|
||||
|
||||
free(_daContext->options);
|
||||
}
|
||||
|
@ -237,12 +235,11 @@ static void
|
|||
_daContextAddOption(DAProgramOption *option)
|
||||
{
|
||||
/* 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;
|
||||
|
||||
options = (DAProgramOption**)realloc(
|
||||
(DAProgramOption**)_daContext->options,
|
||||
options = (DAProgramOption **)realloc(
|
||||
(DAProgramOption **)_daContext->options,
|
||||
2 * sizeof(_daContext->options));
|
||||
|
||||
if (options == NULL)
|
||||
|
@ -272,7 +269,7 @@ _daContextAddOptionData(char *shortForm, char *longForm,
|
|||
}
|
||||
|
||||
static void
|
||||
_daContextAddDefaultOptions()
|
||||
_daContextAddDefaultOptions(void)
|
||||
{
|
||||
_daContextAddOptionData("-h", "--help", "show this help text and exit", DONone);
|
||||
_daContextAddOptionData("-v", "--version", "show program version and exit", DONone);
|
||||
|
@ -284,13 +281,12 @@ _daContextAddOptions(DAProgramOption *options, int count)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
for (i = 0; i < count; i++)
|
||||
_daContextAddOptionData(
|
||||
options[i].shortForm,
|
||||
options[i].longForm,
|
||||
options[i].description,
|
||||
options[i].type);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -304,8 +300,7 @@ printHelp(char *description)
|
|||
if (description)
|
||||
puts(description);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
for (i = 0; i < count; i++) {
|
||||
char blank[30];
|
||||
int c;
|
||||
|
||||
|
|
|
@ -42,6 +42,6 @@ struct DAContext {
|
|||
};
|
||||
|
||||
|
||||
struct DAContext* DAContextInit();
|
||||
void DAFreeContext();
|
||||
struct DAContext *DAContextInit(void);
|
||||
void DAFreeContext(void);
|
||||
|
||||
|
|
|
@ -55,9 +55,8 @@ DAProcessEventForWindow(Window window, XEvent *event)
|
|||
|
||||
switch (event->type) {
|
||||
case ClientMessage:
|
||||
if (event->xclient.data.l[0] != WM_DELETE_WINDOW) {
|
||||
if (event->xclient.data.l[0] != WM_DELETE_WINDOW)
|
||||
break;
|
||||
}
|
||||
/* fallthrough */
|
||||
case DestroyNotify:
|
||||
if (_daContext->callbacks.destroy)
|
||||
|
@ -116,15 +115,14 @@ DAEventLoopForWindow(Window window)
|
|||
{
|
||||
XEvent event;
|
||||
|
||||
for (;;) {
|
||||
for (;; ) {
|
||||
if (_daContext->timeOut >= 0) {
|
||||
if (!DANextEventOrTimeout(&event, _daContext->timeOut)) {
|
||||
if (_daContext->callbacks.timeout)
|
||||
(*_daContext->callbacks.timeout)();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
XNextEvent(DADisplay, &event);
|
||||
|
||||
DAProcessEventForWindow(window, &event);
|
||||
|
|
|
@ -98,7 +98,7 @@ DAProposeIconSize(unsigned width, unsigned height)
|
|||
(height < iconSizes[i].min_height))
|
||||
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;
|
||||
w = MIN(w1, iconSizes[i].width_inc - w1);
|
||||
h = MIN(h1, iconSizes[i].height_inc - h1);
|
||||
|
@ -115,12 +115,11 @@ DAProposeIconSize(unsigned width, unsigned height)
|
|||
DAPreferredIconSizes.width = max_w;
|
||||
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 "
|
||||
"allowed by the window manager\n",
|
||||
_daContext->width, _daContext->height);
|
||||
}
|
||||
}
|
||||
XFree(iconSizes);
|
||||
}
|
||||
|
||||
|
@ -141,7 +140,7 @@ DACreateIcon(char *name, unsigned width, unsigned height, int argc, char **argv)
|
|||
DALeader = XCreateSimpleWindow(DADisplay, DefaultRootWindow(DADisplay),
|
||||
0, 0, width, height, 0, 0, 0);
|
||||
|
||||
if (! _daContext->windowed) {
|
||||
if (!_daContext->windowed) {
|
||||
DAIcon = XCreateSimpleWindow(DADisplay, DefaultRootWindow(DADisplay),
|
||||
0, 0, width, height, 0, 0, 0);
|
||||
DAWindow = DAIcon;
|
||||
|
@ -151,7 +150,8 @@ DACreateIcon(char *name, unsigned width, unsigned height, int argc, char **argv)
|
|||
}
|
||||
|
||||
/* Set ClassHint */
|
||||
if (!(classHint = XAllocClassHint()))
|
||||
classHint = XAllocClassHint();
|
||||
if (!classHint)
|
||||
printf("%s: can't allocate memory for class hints!\n",
|
||||
_daContext->programName), exit(1);
|
||||
classHint->res_class = RES_CLASSNAME;
|
||||
|
@ -161,7 +161,8 @@ DACreateIcon(char *name, unsigned width, unsigned height, int argc, char **argv)
|
|||
XFree(classHint);
|
||||
|
||||
/* Set WMHints */
|
||||
if (!(wmHints = XAllocWMHints()))
|
||||
wmHints = XAllocWMHints();
|
||||
if (!wmHints)
|
||||
printf("%s: can't allocate memory for wm hints!\n",
|
||||
_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 */
|
||||
resourceValue = XGetDefault(DADisplay, RES_CLASSNAME, "background");
|
||||
if (resourceValue) {
|
||||
if (resourceValue)
|
||||
gcv.foreground = DAGetColor(resourceValue);
|
||||
}
|
||||
|
||||
DAClearGC = XCreateGC(DADisplay, DAWindow,
|
||||
GCGraphicsExposures|GCForeground, &gcv);
|
||||
|
@ -221,11 +221,10 @@ DAShowWindow(Window window)
|
|||
|
||||
{
|
||||
XMapRaised(DADisplay, window);
|
||||
if ((window == DALeader) && !_daContext->windowed) {
|
||||
if ((window == DALeader) && !_daContext->windowed)
|
||||
XMapSubwindows(DADisplay, DAIcon);
|
||||
} else {
|
||||
else
|
||||
XMapSubwindows(DADisplay, window);
|
||||
}
|
||||
|
||||
XFlush(DADisplay);
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ DAMakePixmapFromFile(char *filename, Pixmap *pixmap, Pixmap *mask,
|
|||
if (access(filename, R_OK) < 0)
|
||||
return False;
|
||||
|
||||
return _daMakePixmap(daXpmSourceFile, (char**)filename,
|
||||
return _daMakePixmap(daXpmSourceFile, (char **)filename,
|
||||
pixmap, mask,
|
||||
width, height);
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ _daMakePixmap(daXpmSource source,
|
|||
|
||||
else if (source == daXpmSourceFile
|
||||
&& (XpmReadFileToPixmap(
|
||||
DADisplay, DAWindow, (char*)data, pixmap, mask, &xpmAttr) != 0))
|
||||
DADisplay, DAWindow, (char *)data, pixmap, mask, &xpmAttr) != 0))
|
||||
return False;
|
||||
|
||||
*width = xpmAttr.width;
|
||||
|
|
|
@ -33,7 +33,7 @@ DAProcessActionRects(int x, int y, DAActionRect *actionrects, int count,
|
|||
if (!actionrects)
|
||||
return;
|
||||
|
||||
while ( (index < count) &&
|
||||
while ((index < count) &&
|
||||
((x < actionrects[index].rect.x) ||
|
||||
(x > actionrects[index].rect.x + actionrects[index].rect.width) ||
|
||||
(y < actionrects[index].rect.y) ||
|
||||
|
|
|
@ -38,12 +38,12 @@ typedef enum {
|
|||
|
||||
/* local functions */
|
||||
void setGCs(DAShapedPixmap *dasp);
|
||||
DAShapedPixmap* _daMakeShapedPixmap(daShapeSource source, char **data);
|
||||
DAShapedPixmap *_daMakeShapedPixmap(daShapeSource source, char **data);
|
||||
|
||||
extern struct DAContext *_daContext;
|
||||
|
||||
/* Create a new shaped pixmap with width & height of dockapp window */
|
||||
DAShapedPixmap*
|
||||
DAShapedPixmap *
|
||||
DAMakeShapedPixmap()
|
||||
{
|
||||
DAShapedPixmap *dasp = malloc(sizeof(DAShapedPixmap));
|
||||
|
@ -65,7 +65,7 @@ DAMakeShapedPixmap()
|
|||
|
||||
|
||||
/* Create a new shaped pixmap from XPM-data */
|
||||
DAShapedPixmap*
|
||||
DAShapedPixmap *
|
||||
DAMakeShapedPixmapFromData(char **data)
|
||||
{
|
||||
return _daMakeShapedPixmap(daShapeSourceData, data);
|
||||
|
@ -73,10 +73,10 @@ DAMakeShapedPixmapFromData(char **data)
|
|||
|
||||
|
||||
/* Create a new shaped pixmap from XPM-data */
|
||||
DAShapedPixmap*
|
||||
DAShapedPixmap *
|
||||
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 */
|
||||
DAShapedPixmap*
|
||||
DAShapedPixmap *
|
||||
_daMakeShapedPixmap(daShapeSource source, char **data)
|
||||
{
|
||||
Bool success;
|
||||
|
@ -183,7 +183,7 @@ _daMakeShapedPixmap(daShapeSource source, char **data)
|
|||
success = DAMakePixmapFromData(data, &dasp->pixmap, &dasp->shape,
|
||||
&dasp->geometry.width, &dasp->geometry.height);
|
||||
else
|
||||
success = DAMakePixmapFromFile((char*)data, &dasp->pixmap, &dasp->shape,
|
||||
success = DAMakePixmapFromFile((char *)data, &dasp->pixmap, &dasp->shape,
|
||||
&dasp->geometry.width, &dasp->geometry.height);
|
||||
|
||||
if (!success)
|
||||
|
|
|
@ -49,7 +49,7 @@ DASetExpectedVersion(unsigned long expectedVersion)
|
|||
}
|
||||
|
||||
|
||||
Display*
|
||||
Display *
|
||||
DAGetDisplay(char *d, ...)
|
||||
{
|
||||
/* Be backward compatible */
|
||||
|
@ -60,7 +60,7 @@ DAGetDisplay(char *d, ...)
|
|||
|
||||
va_start(ap, d);
|
||||
argc = va_arg(ap, int);
|
||||
argv = va_arg(ap, char**);
|
||||
argv = va_arg(ap, char **);
|
||||
va_end(ap);
|
||||
|
||||
DAOpenDisplay(d, argc, argv);
|
||||
|
@ -138,7 +138,7 @@ DASetDepth(int depth)
|
|||
}
|
||||
|
||||
|
||||
Visual*
|
||||
Visual *
|
||||
DAGetVisual(void)
|
||||
{
|
||||
return DAVisual;
|
||||
|
@ -184,10 +184,10 @@ _message(const char *label, const char *fmt, va_list args)
|
|||
|
||||
if (_daContext->programName != NULL) {
|
||||
/* 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);
|
||||
} else {
|
||||
w_fmt = malloc((strlen(fmt) +1) * sizeof(char));
|
||||
w_fmt = malloc((strlen(fmt) + 1) * sizeof(char));
|
||||
sprintf(w_fmt, "%s\n", fmt);
|
||||
}
|
||||
|
||||
|
|
|
@ -203,11 +203,11 @@ void DAProposeIconSize(unsigned width, unsigned height);
|
|||
* only.
|
||||
* XXX: Argument list is a kludge.
|
||||
*/
|
||||
Display* DAGetDisplay(char *d, ...);
|
||||
Display *DAGetDisplay(char *d, ...);
|
||||
void DASetDisplay(Display *display);
|
||||
|
||||
/* 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. */
|
||||
Window DAGetWindow(void);
|
||||
|
@ -224,7 +224,7 @@ int DAGetDepth(void);
|
|||
void DASetDepth(int depth);
|
||||
|
||||
/* Get/Set DAVisual; the visual type for the screen. For use with external code. */
|
||||
Visual* DAGetVisual(void);
|
||||
Visual *DAGetVisual(void);
|
||||
void DASetVisual(Visual *visual);
|
||||
|
||||
|
||||
|
@ -285,21 +285,21 @@ Bool DAMakePixmapFromFile(char *filename, Pixmap *pixmap, Pixmap *mask,
|
|||
* DAMakeShapedPixmap-
|
||||
* Creates a shaped pixmap with width & height of dockapp window.
|
||||
*/
|
||||
DAShapedPixmap* DAMakeShapedPixmap();
|
||||
DAShapedPixmap *DAMakeShapedPixmap();
|
||||
|
||||
/*
|
||||
* DAMakeShapedPixmapFromData-
|
||||
* Creates a shaped pixmap from XPM-data.
|
||||
* Returns shaped pixmap on success, NULL on failure.
|
||||
*/
|
||||
DAShapedPixmap* DAMakeShapedPixmapFromData(char **data);
|
||||
DAShapedPixmap *DAMakeShapedPixmapFromData(char **data);
|
||||
|
||||
/*
|
||||
* DAMakeShapedPixmapFromFile-
|
||||
* Creates a shaped pixmap from an XPM file.
|
||||
* Returns shaped pixmap on success, NULL on failure.
|
||||
*/
|
||||
DAShapedPixmap* DAMakeShapedPixmapFromFile(char *filename);
|
||||
DAShapedPixmap *DAMakeShapedPixmapFromFile(char *filename);
|
||||
|
||||
/*
|
||||
* DAFreeShapedPixmap-
|
||||
|
|
Loading…
Reference in a new issue