1
0
Fork 0

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
libdockapp

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
@ -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;

View file

@ -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) +
@ -363,7 +373,9 @@ 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)
{ {
@ -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);
} }
@ -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)
{
}

View file

@ -34,7 +34,7 @@ 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);
@ -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]);
@ -208,7 +207,7 @@ DAGetProgramName()
*/ */
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,8 +235,7 @@ 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(
@ -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,14 +281,13 @@ _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
printHelp(char *description) printHelp(char *description)
@ -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)
@ -123,8 +122,7 @@ DAEventLoopForWindow(Window window)
(*_daContext->callbacks.timeout)(); (*_daContext->callbacks.timeout)();
continue; continue;
} }
} } else
else
XNextEvent(DADisplay, &event); XNextEvent(DADisplay, &event);
DAProcessEventForWindow(window, &event); DAProcessEventForWindow(window, &event);

View file

@ -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);
} }
@ -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);
} }