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
13 changed files with 1163 additions and 1146 deletions
|
@ -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
|
||||
|
@ -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;
|
||||
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;
|
||||
|
|
|
@ -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) +
|
||||
|
@ -363,7 +373,9 @@ setPointerColor(GC color)
|
|||
|
||||
|
||||
/* event handlers functions */
|
||||
void destroy(void){}
|
||||
void destroy(void)
|
||||
{
|
||||
}
|
||||
|
||||
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. */
|
||||
/* 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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ extern struct DAContext *_daContext;
|
|||
* Prototypes
|
||||
*/
|
||||
|
||||
static void _daContextAddDefaultOptions();
|
||||
static void _daContextAddDefaultOptions(void);
|
||||
static void _daContextAddOptions(DAProgramOption *options, int count);
|
||||
static void printHelp(char *description);
|
||||
|
||||
|
@ -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]);
|
||||
|
@ -208,7 +207,7 @@ DAGetProgramName()
|
|||
*/
|
||||
|
||||
struct DAContext *
|
||||
DAContextInit()
|
||||
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,8 +235,7 @@ 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(
|
||||
|
@ -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,14 +281,13 @@ _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
|
||||
printHelp(char *description)
|
||||
|
@ -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)
|
||||
|
@ -123,8 +122,7 @@ DAEventLoopForWindow(Window window)
|
|||
(*_daContext->callbacks.timeout)();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
XNextEvent(DADisplay, &event);
|
||||
|
||||
DAProcessEventForWindow(window, &event);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue