Used uncrustify to minimize warnings and errors from checkpatch.pl in the Window Maker source tree. --- libdockapp/examples/basic/basic.c | 289 +++++------ libdockapp/examples/rectangles/rectangles.c | 732 ++++++++++++++-------------- libdockapp/src/daargs.c | 353 +++++++------- libdockapp/src/daargs.h | 22 +- libdockapp/src/dacallback.c | 40 +- libdockapp/src/dacolor.c | 20 +- libdockapp/src/daevent.c | 162 +++--- libdockapp/src/damain.c | 345 +++++++------ libdockapp/src/dapixmap.c | 88 ++-- libdockapp/src/darect.c | 42 +- libdockapp/src/dashaped.c | 142 +++--- libdockapp/src/dautil.c | 116 ++--- libdockapp/src/dockapp.h | 144 +++--- 13 files changed, 1256 insertions(+), 1239 deletions(-)
diff --git a/libdockapp/examples/basic/basic.c b/libdockapp/examples/basic/basic.c index 0c1f4cc..17d5264 100644 --- a/libdockapp/examples/basic/basic.c +++ b/libdockapp/examples/basic/basic.c @@ -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,174 +36,181 @@ DAShapedPixmap *ballPix; int main(int argc, char **argv) { - unsigned int x=1, y=1; - Pixmap back; - DACallbacks eventCallbacks = { - destroy, /* destroy */ - NULL, /* buttonPress */ - NULL, /* buttonRelease */ - NULL, /* motion (mouse) */ - NULL, /* mouse enters window */ - NULL, /* mouse leaves window */ - moveBall /* timeout */ - }; - - /* provide standard command-line options */ - DAParseArguments( - argc, argv, /* Where the options come from */ - NULL, 0, /* Our list with options - none as you can see */ - "This is the help text for the basic example of how to " - "use libDockapp.\n", - "Basic example version 1.1"); - - /* Tell libdockapp what version we expect it to be (a date from the - * ChangeLog should do). - */ - DASetExpectedVersion(20020126); - - DAOpenDisplay( - NULL /* default display */, - argc, argv /* needed by libdockapp */ - ); - DACreateIcon( - "daBasicExample" /* WM_CLASS hint; don't use chars in [.?*: ] */, - 48, 48 /* geometry of dockapp internals */, - argc, argv /* needed by libdockapp */ - ); - - /* The pixmap that makes up the background of the dockapp */ - back = DAMakePixmap(); - drawRelief(back); - DASetPixmap(back); - XFreePixmap(DADisplay, back); - - /* A window(!) for the ball pixmap. - * Moving a window is a lot easier then erasing/copying the pixmap all - * the time. - * - * I use a DAShapedPixmap here, which contains all the information - * related to the pixmap: pixmap, mask and geometry. - */ - ballPix = DAMakeShapedPixmapFromData(ball_red_xpm); - ballWin = XCreateSimpleWindow(DADisplay, DAWindow, - x, y, - /* Use the geometry of the shaped pixmap */ - ballPix->geometry.width, ballPix->geometry.height, - 0, 0, 0); - DASPSetPixmapForWindow(ballWin, ballPix); - - /* Respond to destroy and timeout events (the ones not NULL in the - * eventCallbacks variable. - */ - DASetCallbacks(&eventCallbacks); - - /* Set the time for timeout events (in msec) */ - DASetTimeout(SPEED); - - /* Randomize movement variation. - * Run multiple versions of the dockapp simultaneously to see the effect - * best. - * (which function to use is set from the Imakefile) - */ + unsigned int x = 1, y = 1; + Pixmap back; + DACallbacks eventCallbacks = { + destroy, /* destroy */ + NULL, /* buttonPress */ + NULL, /* buttonRelease */ + NULL, /* motion (mouse) */ + NULL, /* mouse enters window */ + NULL, /* mouse leaves window */ + moveBall /* timeout */ + }; + + /* provide standard command-line options */ + DAParseArguments( + argc, argv, /* Where the options come from */ + NULL, 0, /* Our list with options - none as you can see */ + "This is the help text for the basic example of how to " + "use libDockapp.\n", + "Basic example version 1.1"); + + /* Tell libdockapp what version we expect it to be (a date from the + * ChangeLog should do). + */ + DASetExpectedVersion(20020126); + + DAOpenDisplay( + NULL /* default display */, + argc, argv /* needed by libdockapp */ + ); + DACreateIcon( + "daBasicExample" /* WM_CLASS hint; don't use chars in [.?*: ] */, + 48, 48 /* geometry of dockapp internals */, + argc, argv /* needed by libdockapp */ + ); + + /* The pixmap that makes up the background of the dockapp */ + back = DAMakePixmap(); + drawRelief(back); + DASetPixmap(back); + XFreePixmap(DADisplay, back); + + /* A window(!) for the ball pixmap. + * Moving a window is a lot easier then erasing/copying the pixmap all + * the time. + * + * I use a DAShapedPixmap here, which contains all the information + * related to the pixmap: pixmap, mask and geometry. + */ + ballPix = DAMakeShapedPixmapFromData(ball_red_xpm); + ballWin = XCreateSimpleWindow(DADisplay, DAWindow, + x, y, + /* Use the geometry of the shaped pixmap */ + ballPix->geometry.width, ballPix->geometry.height, + 0, 0, 0); + DASPSetPixmapForWindow(ballWin, ballPix); + + /* Respond to destroy and timeout events (the ones not NULL in the + * eventCallbacks variable. + */ + DASetCallbacks(&eventCallbacks); + + /* Set the time for timeout events (in msec) */ + DASetTimeout(SPEED); + + /* Randomize movement variation. + * Run multiple versions of the dockapp simultaneously to see the effect + * best. + * (which function to use is set from the Imakefile) + */ #ifdef HAS_RANDOMDEV - srandomdev(); + srandomdev(); #else - srandom(time(NULL)); + srandom(time(NULL)); #endif - DAShow(); /* Show the dockapp window. */ + DAShow(); /* Show the dockapp window. */ - /* Process events and keep the dockapp running */ - DAEventLoop(); + /* Process events and keep the dockapp running */ + DAEventLoop(); - /* not reached */ - exit(EXIT_SUCCESS); + /* not reached */ + exit(EXIT_SUCCESS); } void drawRelief(Pixmap pixmap) { - XGCValues gcv; - GC lightGrayGC, darkGrayGC; + XGCValues gcv; + GC lightGrayGC, darkGrayGC; - /* GC's */ - gcv.foreground = DAGetColor("Navy"); - XChangeGC(DADisplay, DAClearGC, GCForeground, &gcv); + /* GC's */ + gcv.foreground = DAGetColor("Navy"); + XChangeGC(DADisplay, DAClearGC, GCForeground, &gcv); - gcv.foreground = DAGetColor("lightGray"); - gcv.graphics_exposures = False; + gcv.foreground = DAGetColor("lightGray"); + gcv.graphics_exposures = False; - lightGrayGC = XCreateGC(DADisplay, DAWindow, - GCForeground|GCGraphicsExposures, &gcv); + lightGrayGC = XCreateGC(DADisplay, DAWindow, + GCForeground | GCGraphicsExposures, &gcv); - gcv.foreground = DAGetColor("#222222"); - darkGrayGC = XCreateGC(DADisplay, DAWindow, - GCForeground|GCGraphicsExposures, &gcv); + gcv.foreground = DAGetColor("#222222"); + darkGrayGC = XCreateGC(DADisplay, DAWindow, + GCForeground | GCGraphicsExposures, &gcv); - /* Drawing */ - XFillRectangle(DADisplay, pixmap, DAClearGC, 1, 1, 46, 46); + /* Drawing */ + XFillRectangle(DADisplay, pixmap, DAClearGC, 1, 1, 46, 46); - XDrawLine(DADisplay, pixmap, darkGrayGC, 0, 0, 0, 46); - XDrawLine(DADisplay, pixmap, darkGrayGC, 1, 0, 47, 0); + XDrawLine(DADisplay, pixmap, darkGrayGC, 0, 0, 0, 46); + XDrawLine(DADisplay, pixmap, darkGrayGC, 1, 0, 47, 0); - XDrawLine(DADisplay, pixmap, lightGrayGC, 0, 47, 47, 47); - XDrawLine(DADisplay, pixmap, lightGrayGC, 47, 1, 47, 46); + XDrawLine(DADisplay, pixmap, lightGrayGC, 0, 47, 47, 47); + XDrawLine(DADisplay, pixmap, lightGrayGC, 47, 1, 47, 46); - /* Free the GC's, we don't use them anymore */ - XFreeGC(DADisplay, lightGrayGC); - XFreeGC(DADisplay, darkGrayGC); + /* Free the GC's, we don't use them anymore */ + XFreeGC(DADisplay, lightGrayGC); + XFreeGC(DADisplay, darkGrayGC); } 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; - - 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; - y += dy; - - if (x < 1) { - x = 1; - dx = -dx + var; - } - - if (y < 1) { - y = 1; - dy = -dy + var; - } - - if (x + ballPix->geometry.width > 46) { - x = 46 - ballPix->geometry.width; - dx = -dx + var; - } - - if (y + ballPix->geometry.height > 46) { - y = 46 - ballPix->geometry.height; - dy = -dy + var; - } - - XMoveWindow(DADisplay, ballWin, x, y); + static int x = 1; + static int y = 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; + + /* calculate new position */ + x += dx; + y += dy; + + if (x < 1) { + x = 1; + dx = -dx + var; + } + + if (y < 1) { + y = 1; + dy = -dy + var; + } + + if (x + ballPix->geometry.width > 46) { + x = 46 - ballPix->geometry.width; + dx = -dx + var; + } + + if (y + ballPix->geometry.height > 46) { + y = 46 - ballPix->geometry.height; + dy = -dy + var; + } + + XMoveWindow(DADisplay, ballWin, x, y); } void destroy(void) { - XFreePixmap(DADisplay, ballPix->pixmap); - XFreePixmap(DADisplay, ballPix->shape); + XFreePixmap(DADisplay, ballPix->pixmap); + XFreePixmap(DADisplay, ballPix->shape); -fprintf(stderr, "Destroyed!\n"); - /* exit is done by libdockapp */ + fprintf(stderr, "Destroyed!\n"); + /* exit is done by libdockapp */ } diff --git a/libdockapp/examples/rectangles/rectangles.c b/libdockapp/examples/rectangles/rectangles.c index c030c5f..7097004 100644 --- a/libdockapp/examples/rectangles/rectangles.c +++ b/libdockapp/examples/rectangles/rectangles.c @@ -28,24 +28,24 @@ /* I like to keep my graphic contexts (GCs) together */ struct Colors { - GC white; /* foreground color from X-resource, or default */ - GC black; /* background color, idem */ - GC lightGray; /* Some GC's we'll have to define for colors */ - GC darkGray; - GC slider; /* draw-color when not highlighted, + GC white; /* foreground color from X-resource, or default */ + GC black; /* background color, idem */ + GC lightGray; /* Some GC's we'll have to define for colors */ + GC darkGray; + GC slider; /* draw-color when not highlighted, * dark-color when highlighted */ - GC sliderLight; /* draw-color when highlighted */ - GC sliderDark; /* dark-color when not highlighted */ + GC sliderLight; /* draw-color when highlighted */ + GC sliderDark; /* dark-color when not highlighted */ }; /* * Global variables */ -Pixmap pixmap; /* pixmap pixmap */ +Pixmap pixmap; /* pixmap pixmap */ DARect *buttonDown = NULL; -struct Colors *colors; /* our colors */ +struct Colors *colors; /* our colors */ DAActionRect **actionRects; float sliderPos = 0.7; int mouseIn = 0; @@ -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 */ @@ -103,215 +103,215 @@ void sliderLeave(int x, int y, DARect rect, void *data); int main(int argc, char **argv) { - /* define the event handlers for the events */ - DACallbacks eventCallbacks = { - destroy, /* destroy */ - buttonPress, /* buttonPress */ - buttonRelease, /* buttonRelease */ - mouseMove, /* motion (mouse) */ - mouseEnter, /* mouse enters window */ - mouseLeave, /* mouse leaves window */ - NULL /* timeout */ - }; - - /* define regions (x, y, width, height) that need event-handling */ - Region clipRegion = XCreateRegion(); - - DARect btn = {0, 0, 16, 16}, - square = {0, 25, 22, 22}, - slider = {24, 0, 23, 48}; - - /* define what to do if an event occurs in a rectangle */ - DAActionRect *buttonPressRects, *buttonReleaseRects, - *mouseMoveRects, *mouseEnterRects, *mouseLeaveRects; - - buttonPressRects = malloc(3 * sizeof(DAActionRect)); - buttonPressRects[0] = setRectAction(btn, btnDown); - buttonPressRects[1] = setRectAction(square, squareDown); - buttonPressRects[2] = setRectAction(slider, sliderDown); - - buttonReleaseRects = malloc(2 * sizeof(DAActionRect)); - buttonReleaseRects[0] = setRectAction(btn, btnUp); - buttonReleaseRects[1] = setRectAction(slider, sliderUp); - - mouseMoveRects = malloc(sizeof(DAActionRect)); - mouseMoveRects[0] = setRectAction(slider, sliderMove); - - mouseEnterRects = malloc(sizeof(DAActionRect)); - mouseEnterRects[0] = setRectAction(slider, sliderEnter); - - mouseLeaveRects = malloc(2 * sizeof(DAActionRect)); - mouseLeaveRects[0] = setRectAction(btn, btnLeave); - mouseLeaveRects[1] = setRectAction(slider, sliderLeave); - - - /* XXX: make action rectangles available outside main() - * ...libDockapp should be able to do this... (reminder) - */ - actionRects = malloc(6 * sizeof(DAActionRect*)); - actionRects[0] = buttonPressRects; - actionRects[1] = buttonReleaseRects; - actionRects[2] = mouseMoveRects; - actionRects[3] = mouseEnterRects; - actionRects[4] = mouseLeaveRects; - actionRects[5] = NULL; - - /* provide standard command-line options */ - DAParseArguments( - argc, argv, /* Where the options come from */ - NULL, 0, /* Our list with options - none as you can see */ - "This is the help text for the rectangle example of how to " - "use libDockapp.\n", - "Rectangle example version 1.0"); - - /* Tell libdockapp what version we expect it to be, so that you can use - * older programs with newer versions of libdockapp with less risc for - * compatibility problems. - */ - DASetExpectedVersion(20030126); - - /* Initialize a dockapp */ - DAInitialize( - "", /* Use default display */ - "daRectangleExample", /* WM_CLASS hint; don't use chars in [.?*: ] */ - 48, 48, /* geometry of dockapp internals */ - argc, argv /* (needed internally) */ - ); - - /* Create a pixmap to draw on, and to display */ - pixmap = DAMakePixmap(); /* size == dockapp geometry (48,48) */ - - colors = setGCs(pixmap); - - XFillRectangle(DADisplay, pixmap, DAClearGC, 0, 0, 48, 48); - XClearWindow(DADisplay, DAWindow); - - /* Make a "Region" from the shapes we have */ - XUnionRectWithRegion(&btn, clipRegion, clipRegion); - XUnionRectWithRegion(&square, clipRegion, clipRegion); - XUnionRectWithRegion(&slider, clipRegion, clipRegion); - - /* Make this region a window shape mask */ - XShapeCombineRegion(DADisplay, DAWindow, ShapeBounding, - 0, 0, clipRegion, ShapeSet); - - /* We don't need the region anymore (it is copied by XShapeCombineRegion). - * XXX: That's not certain, it is not documented. XSetRegion does so, - * though, so it is a likely assumption that it does copy. - */ - XDestroyRegion(clipRegion); - - /* The cursor we want to use. - * Specify 'None' for the default, - * or one from X11/cursorfont.h - */ - pointer = XCreateFontCursor(DADisplay, XC_based_arrow_up); - XDefineCursor(DADisplay, DAWindow, pointer); - - /* a square with an image that changes when clicked (A button). */ - createBtn(btn); - - /* a square that shows the number of the mouse-button pressed on click. */ - createSquare(square); - - /* a slider a using two dashed line GC's. */ - createSlider(slider); - - /* Tell libdockapp this is the pixmap that we want to show */ - DASetPixmap(pixmap); - - /* Process events every 100ms */ - DASetTimeout(100); - - /* set event callbacks */ - DASetCallbacks(&eventCallbacks); - - /* Display the pixmap we said it to show */ - DAShow(); - - /* Process events and keep the dockapp running */ - DAEventLoop(); - - return 0; + /* define the event handlers for the events */ + DACallbacks eventCallbacks = { + destroy, /* destroy */ + buttonPress, /* buttonPress */ + buttonRelease, /* buttonRelease */ + mouseMove, /* motion (mouse) */ + mouseEnter, /* mouse enters window */ + mouseLeave, /* mouse leaves window */ + NULL /* timeout */ + }; + + /* define regions (x, y, width, height) that need event-handling */ + Region clipRegion = XCreateRegion(); + + DARect btn = {0, 0, 16, 16}, + square = {0, 25, 22, 22}, + slider = {24, 0, 23, 48}; + + /* define what to do if an event occurs in a rectangle */ + DAActionRect *buttonPressRects, *buttonReleaseRects, + *mouseMoveRects, *mouseEnterRects, *mouseLeaveRects; + + buttonPressRects = malloc(3 * sizeof(DAActionRect)); + buttonPressRects[0] = setRectAction(btn, btnDown); + buttonPressRects[1] = setRectAction(square, squareDown); + buttonPressRects[2] = setRectAction(slider, sliderDown); + + buttonReleaseRects = malloc(2 * sizeof(DAActionRect)); + buttonReleaseRects[0] = setRectAction(btn, btnUp); + buttonReleaseRects[1] = setRectAction(slider, sliderUp); + + mouseMoveRects = malloc(sizeof(DAActionRect)); + mouseMoveRects[0] = setRectAction(slider, sliderMove); + + mouseEnterRects = malloc(sizeof(DAActionRect)); + mouseEnterRects[0] = setRectAction(slider, sliderEnter); + + mouseLeaveRects = malloc(2 * sizeof(DAActionRect)); + mouseLeaveRects[0] = setRectAction(btn, btnLeave); + mouseLeaveRects[1] = setRectAction(slider, sliderLeave); + + + /* XXX: make action rectangles available outside main() + * ...libDockapp should be able to do this... (reminder) + */ + actionRects = malloc(6 * sizeof(DAActionRect *)); + actionRects[0] = buttonPressRects; + actionRects[1] = buttonReleaseRects; + actionRects[2] = mouseMoveRects; + actionRects[3] = mouseEnterRects; + actionRects[4] = mouseLeaveRects; + actionRects[5] = NULL; + + /* provide standard command-line options */ + DAParseArguments( + argc, argv, /* Where the options come from */ + NULL, 0, /* Our list with options - none as you can see */ + "This is the help text for the rectangle example of how to " + "use libDockapp.\n", + "Rectangle example version 1.0"); + + /* Tell libdockapp what version we expect it to be, so that you can use + * older programs with newer versions of libdockapp with less risc for + * compatibility problems. + */ + DASetExpectedVersion(20030126); + + /* Initialize a dockapp */ + DAInitialize( + "", /* Use default display */ + "daRectangleExample", /* WM_CLASS hint; don't use chars in [.?*: ] */ + 48, 48, /* geometry of dockapp internals */ + argc, argv /* (needed internally) */ + ); + + /* Create a pixmap to draw on, and to display */ + pixmap = DAMakePixmap(); /* size == dockapp geometry (48,48) */ + + colors = setGCs(pixmap); + + XFillRectangle(DADisplay, pixmap, DAClearGC, 0, 0, 48, 48); + XClearWindow(DADisplay, DAWindow); + + /* Make a "Region" from the shapes we have */ + XUnionRectWithRegion(&btn, clipRegion, clipRegion); + XUnionRectWithRegion(&square, clipRegion, clipRegion); + XUnionRectWithRegion(&slider, clipRegion, clipRegion); + + /* Make this region a window shape mask */ + XShapeCombineRegion(DADisplay, DAWindow, ShapeBounding, + 0, 0, clipRegion, ShapeSet); + + /* We don't need the region anymore (it is copied by XShapeCombineRegion). + * XXX: That's not certain, it is not documented. XSetRegion does so, + * though, so it is a likely assumption that it does copy. + */ + XDestroyRegion(clipRegion); + + /* The cursor we want to use. + * Specify 'None' for the default, + * or one from X11/cursorfont.h + */ + pointer = XCreateFontCursor(DADisplay, XC_based_arrow_up); + XDefineCursor(DADisplay, DAWindow, pointer); + + /* a square with an image that changes when clicked (A button). */ + createBtn(btn); + + /* a square that shows the number of the mouse-button pressed on click. */ + createSquare(square); + + /* a slider a using two dashed line GC's. */ + createSlider(slider); + + /* Tell libdockapp this is the pixmap that we want to show */ + DASetPixmap(pixmap); + + /* Process events every 100ms */ + DASetTimeout(100); + + /* set event callbacks */ + DASetCallbacks(&eventCallbacks); + + /* Display the pixmap we said it to show */ + DAShow(); + + /* Process events and keep the dockapp running */ + DAEventLoop(); + + return 0; } /* Create our GC's to draw colored lines and such */ -struct Colors* +struct Colors * setGCs(Drawable d) { - struct Colors *colors; - XGCValues gcv; - unsigned long origColor; - char dashList[2] = {3, 1}; + struct Colors *colors; + XGCValues gcv; + unsigned long origColor; + char dashList[2] = {3, 1}; - colors = malloc(sizeof(struct Colors)); - if (colors == NULL) - return NULL; + colors = malloc(sizeof(struct Colors)); + if (colors == NULL) + return NULL; - /* Get the GC-values of the default GC */ - XGetGCValues(DADisplay, DAGC, - GCForeground|GCBackground|GCGraphicsExposures, &gcv); + /* Get the GC-values of the default GC */ + XGetGCValues(DADisplay, DAGC, + GCForeground | GCBackground | GCGraphicsExposures, &gcv); - origColor = gcv.foreground; + origColor = gcv.foreground; - /* don't send expose events */ - gcv.graphics_exposures = False; + /* don't send expose events */ + gcv.graphics_exposures = False; - /* GC for white color */ - gcv.foreground = WhitePixel(DADisplay, DefaultScreen(DADisplay)); - colors->white = XCreateGC(DADisplay, d, - GCForeground|GCGraphicsExposures, &gcv); + /* GC for white color */ + gcv.foreground = WhitePixel(DADisplay, DefaultScreen(DADisplay)); + colors->white = XCreateGC(DADisplay, d, + GCForeground | GCGraphicsExposures, &gcv); - /* GC for dark blue color */ + /* GC for dark blue color */ #if 1 - gcv.foreground = DAGetColor("navy"); + gcv.foreground = DAGetColor("navy"); #else - gcv.foreground = 0; + gcv.foreground = 0; #endif - colors->black = XCreateGC(DADisplay, d, - GCForeground|GCGraphicsExposures, &gcv); + colors->black = XCreateGC(DADisplay, d, + GCForeground | GCGraphicsExposures, &gcv); - /* GC for light borders */ - gcv.foreground = DAGetColor("lightGray"); - colors->lightGray = XCreateGC(DADisplay, d, - GCForeground|GCGraphicsExposures, &gcv); + /* GC for light borders */ + gcv.foreground = DAGetColor("lightGray"); + colors->lightGray = XCreateGC(DADisplay, d, + 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); + /* GC for dark borders (note re-use of gcv-values) */ + gcv.foreground = DAGetColor("#222222"); + colors->darkGray = XCreateGC(DADisplay, d, + GCForeground | GCGraphicsExposures, &gcv); - /* GC for the un-/highlighted colors and dashed line of the slider */ - gcv.foreground = origColor; - gcv.line_width = 9; - gcv.line_style = LineOnOffDash; + /* GC for the un-/highlighted colors and dashed line of the slider */ + gcv.foreground = origColor; + gcv.line_width = 9; + gcv.line_style = LineOnOffDash; - colors->slider = XCreateGC(DADisplay, d, - GCForeground|GCBackground|GCGraphicsExposures| - GCLineWidth|GCLineStyle, &gcv); + colors->slider = XCreateGC(DADisplay, d, + GCForeground | GCBackground | GCGraphicsExposures | + GCLineWidth | GCLineStyle, &gcv); - XSetDashes(DADisplay, colors->slider, 1, dashList, 2); + XSetDashes(DADisplay, colors->slider, 1, dashList, 2); - /* light slider GC */ - gcv.foreground = adjustColor(origColor, +0x40); + /* light slider GC */ + gcv.foreground = adjustColor(origColor, +0x40); - colors->sliderLight = XCreateGC(DADisplay, d, - GCForeground|GCBackground|GCGraphicsExposures| - GCLineWidth|GCLineStyle, &gcv); + colors->sliderLight = XCreateGC(DADisplay, d, + GCForeground | GCBackground | GCGraphicsExposures | + GCLineWidth | GCLineStyle, &gcv); - XSetDashes(DADisplay, colors->sliderLight, 1, dashList, 2); + XSetDashes(DADisplay, colors->sliderLight, 1, dashList, 2); - /* dark slider GC */ - gcv.foreground = adjustColor(origColor, -0x40); + /* dark slider GC */ + gcv.foreground = adjustColor(origColor, -0x40); - colors->sliderDark = XCreateGC(DADisplay, d, - GCForeground|GCBackground|GCGraphicsExposures| - GCLineWidth|GCLineStyle, &gcv); + colors->sliderDark = XCreateGC(DADisplay, d, + GCForeground | GCBackground | GCGraphicsExposures | + GCLineWidth | GCLineStyle, &gcv); - XSetDashes(DADisplay, colors->sliderDark, 1, dashList, 2); + XSetDashes(DADisplay, colors->sliderDark, 1, dashList, 2); - return colors; + return colors; } @@ -319,99 +319,110 @@ setGCs(Drawable d) unsigned long adjustColor(unsigned long color, signed int adjustment) { - signed long r, g, b; + signed long r, g, b; - r = color >> 16; - g = (color - (r << 16)) >> 8; - b = (color - (g << 8) - (r << 16)); + r = color >> 16; + g = (color - (r << 16)) >> 8; + b = (color - (g << 8) - (r << 16)); - r += adjustment; - g += adjustment; - b += adjustment; + r += 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; - return ((unsigned short)r << 16) + - ((unsigned short)g << 8) + - (unsigned short)b; + 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) + + (unsigned short)b; } void setPointerColor(GC color) { - XGCValues gcv; - XColor fcolor, bcolor; + XGCValues gcv; + XColor fcolor, bcolor; - XGetGCValues(DADisplay, color, GCForeground, &gcv); + XGetGCValues(DADisplay, color, GCForeground, &gcv); - fcolor.pixel = gcv.foreground; - fcolor.flags = DoRed|DoGreen|DoBlue; + fcolor.pixel = gcv.foreground; + fcolor.flags = DoRed | DoGreen | DoBlue; - bcolor.red = 0; - bcolor.green = 0; - bcolor.blue = 0; + bcolor.red = 0; + bcolor.green = 0; + bcolor.blue = 0; - XRecolorCursor(DADisplay, pointer, &fcolor, &bcolor); + XRecolorCursor(DADisplay, pointer, &fcolor, &bcolor); } /* 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; + *data = button; - DAProcessActionRects(x, y, actionRects[0], 3, (void*)data); + DAProcessActionRects(x, y, actionRects[0], 3, (void *)data); - free(data); + free(data); } void buttonRelease(int button, int state, int x, int y) { - DAProcessActionRects(x, y, actionRects[1], 2, NULL); + DAProcessActionRects(x, y, actionRects[1], 2, NULL); } void mouseMove(int x, int y) { - DAProcessActionRects(x, y, actionRects[2], 1, NULL); + DAProcessActionRects(x, y, actionRects[2], 1, NULL); } void mouseEnter(void) { - mouseIn = 1; + mouseIn = 1; - drawSlider(actionRects[3][0].rect); + drawSlider(actionRects[3][0].rect); } void mouseLeave(void) { - mouseIn = 0; + mouseIn = 0; - /* mouse pointer left the dockapp window */ - DAProcessActionRects(0, 0, actionRects[4], 2, NULL); + /* mouse pointer left the dockapp window */ + DAProcessActionRects(0, 0, actionRects[4], 2, NULL); - /* 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 */ - if (buttonDown != NULL) { - btnUp(0, 0, *buttonDown, NULL); - } + if (buttonDown != NULL) + btnUp(0, 0, *buttonDown, NULL); - drawSlider(actionRects[4][1].rect); + drawSlider(actionRects[4][1].rect); } /* what to do for a specific event for every 'item' in the dockapp */ @@ -419,24 +430,26 @@ mouseLeave(void) void btnDown(int x, int y, DARect rect, void *data) { - buttonDown = ▭ - drawSunkenFrame(rect); + buttonDown = ▭ + drawSunkenFrame(rect); } void btnUp(int x, int y, DARect rect, void *data) { - buttonDown = NULL; - drawRaisedFrame(rect); + buttonDown = NULL; + drawRaisedFrame(rect); } void btnLeave(int x, int y, DARect rect, void *data) { - if (buttonDown == NULL) return; - drawRaisedFrame(rect); + if (buttonDown == NULL) + return; + + drawRaisedFrame(rect); } @@ -444,16 +457,16 @@ btnLeave(int x, int y, DARect rect, void *data) void squareDown(int x, int y, DARect rect, void *data) { - int button; + int button; - if (data) { - int *tmp = (int*)data; + if (data) { + int *tmp = (int *)data; - button = *tmp; - } else - button = 0; + button = *tmp; + } else + button = 0; - drawSquare(rect, button); + drawSquare(rect, button); } @@ -461,40 +474,45 @@ squareDown(int x, int y, DARect rect, void *data) void sliderDown(int x, int y, DARect rect, void *data) { - buttonDown = ▭ - setPointerColor(colors->sliderDark); + buttonDown = ▭ + setPointerColor(colors->sliderDark); } void sliderUp(int x, int y, DARect rect, void *data) { - buttonDown = NULL; - setPointerColor(colors->black); + buttonDown = NULL; + setPointerColor(colors->black); } void sliderMove(int x, int y, DARect rect, void *data) { - if (buttonDown == NULL /* || - rect.x != buttonDown->x || - 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; - - drawSlider(rect); + if (buttonDown == NULL /* || + rect.x != buttonDown->x || + 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; + + 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) +{ +} @@ -504,147 +522,147 @@ void sliderLeave(int x, int y, DARect rect, void *data) {} void createBtn(DARect rect) { - /* fill square excluding borders */ - XFillRectangle(DADisplay, pixmap, colors->lightGray, - rect.x +1, rect.y +1, rect.width -2, rect.height -2); + /* fill square excluding borders */ + XFillRectangle(DADisplay, pixmap, colors->lightGray, + rect.x + 1, rect.y + 1, rect.width - 2, rect.height - 2); - drawRaisedFrame(rect); + drawRaisedFrame(rect); } void drawRaisedFrame(DARect rect) { - /* left border */ - XDrawLine(DADisplay, pixmap, colors->white, - 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); - /* bottom border */ - XDrawLine(DADisplay, pixmap, colors->darkGray, - 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); - - DASetPixmap(pixmap); + /* left border */ + XDrawLine(DADisplay, pixmap, colors->white, + 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); + /* bottom border */ + XDrawLine(DADisplay, pixmap, colors->darkGray, + 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); + + DASetPixmap(pixmap); } void drawSunkenFrame(DARect rect) { - /* left border */ - XDrawLine(DADisplay, pixmap, colors->darkGray, - 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); - /* bottom border */ - XDrawLine(DADisplay, pixmap, colors->white, - 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); - - DASetPixmap(pixmap); + /* left border */ + XDrawLine(DADisplay, pixmap, colors->darkGray, + 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); + /* bottom border */ + XDrawLine(DADisplay, pixmap, colors->white, + 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); + + DASetPixmap(pixmap); } void createSquare(DARect rect) { - /* fill square excluding borders */ - XFillRectangle(DADisplay, pixmap, colors->black, - rect.x +1, rect.y +1, rect.width -2, rect.height -2); + /* fill square excluding borders */ + XFillRectangle(DADisplay, pixmap, colors->black, + 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); + XDrawRectangle(DADisplay, pixmap, colors->lightGray, + rect.x, rect.y, rect.width - 1, rect.height - 1); - drawSquare(rect, 0); + drawSquare(rect, 0); } void drawSquare(DARect rect, int button) { - char label[3]; + char label[3]; - XFillRectangle(DADisplay, pixmap, colors->black, - rect.x +1, rect.y +1, rect.width -2, rect.height -2); + XFillRectangle(DADisplay, pixmap, colors->black, + 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); + snprintf(label, 3, "%2d", button); + XDrawString(DADisplay, pixmap, colors->white, + rect.x + 3, rect.y + rect.height - 5, label, 2); - DASetPixmap(pixmap); + DASetPixmap(pixmap); } void createSlider(DARect rect) { - /* fill square excluding borders */ - XFillRectangle(DADisplay, pixmap, colors->black, - rect.x +1, rect.y +1, rect.width -2, rect.height -2); + /* fill square excluding borders */ + XFillRectangle(DADisplay, pixmap, colors->black, + rect.x + 1, rect.y + 1, rect.width - 2, rect.height - 2); - drawSunkenFrame(rect); + drawSunkenFrame(rect); - drawSlider(rect); + drawSlider(rect); } void drawSlider(DARect rect) { - GC highColor, lowColor; /* determine colors to use */ - - if (mouseIn) { - highColor = colors->sliderLight; - lowColor = colors->slider; - } else { - highColor = colors->slider; - lowColor = colors->sliderDark; - } - - /* 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)); - - XDrawLine(DADisplay, pixmap, highColor, - 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)); - - XDrawLine(DADisplay, pixmap, lowColor, - rect.x + 17, rect.y +1, - rect.x + 17, rect.y + (1.0 - sliderPos) * (rect.height -2)); - } - - DASetPixmap(pixmap); + GC highColor, lowColor; /* determine colors to use */ + + if (mouseIn) { + highColor = colors->sliderLight; + lowColor = colors->slider; + } else { + highColor = colors->slider; + lowColor = colors->sliderDark; + } + + /* 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)); + + XDrawLine(DADisplay, pixmap, highColor, + 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)); + + XDrawLine(DADisplay, pixmap, lowColor, + rect.x + 17, rect.y + 1, + rect.x + 17, rect.y + (1.0 - sliderPos) * (rect.height - 2)); + } + + DASetPixmap(pixmap); } DAActionRect setRectAction(DARect rect, DARectCallback action) { - DAActionRect ar; + DAActionRect ar; - ar.rect = rect; - ar.action = action; + ar.rect = rect; + ar.action = action; - return ar; + return ar; } diff --git a/libdockapp/src/daargs.c b/libdockapp/src/daargs.c index 807ea71..365fac6 100644 --- a/libdockapp/src/daargs.c +++ b/libdockapp/src/daargs.c @@ -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); /* @@ -55,151 +55,150 @@ DAParseArguments( char *programDescription, char *versionDescription) { - int i, j, size; - int found = 0; + int i, j, size; + int found = 0; - _daContext = DAContextInit(); + _daContext = DAContextInit(); - _daContext->argc = argc; - _daContext->argv = argv; - _daContext->programName = argv[0]; + _daContext->argc = argc; + _daContext->argv = argv; + _daContext->programName = argv[0]; - size = (count + DEFAULT_OPTION_COUNT) * sizeof(DAProgramOption*); - _daContext->options = malloc(size); - memset(_daContext->options, 0, size); + size = (count + DEFAULT_OPTION_COUNT) * sizeof(DAProgramOption *); + _daContext->options = malloc(size); + memset(_daContext->options, 0, size); - _daContextAddDefaultOptions(); - _daContextAddOptions(options, count); + _daContextAddDefaultOptions(); + _daContextAddOptions(options, count); - for (i = 1; i < argc; i++) { - char *optStr = argv[i]; + for (i = 1; i < argc; i++) { + char *optStr = argv[i]; - /* Handle default options */ - if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) - printHelp(programDescription), exit(0); + /* Handle default options */ + if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) + printHelp(programDescription), exit(0); - if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) - puts(versionDescription), exit(0); + if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) + puts(versionDescription), exit(0); - if (strcmp(argv[i], "-w") == 0 || strcmp(argv[i], "--windowed") == 0) { - _daContext->windowed = 1; - continue; - } - - found = 0; - /* options with a one-to-one mapping */ - for (j = 0; j < count; j++) { - DAProgramOption *option = &options[j]; - - if ((option->longForm && strcmp(option->longForm, optStr) == 0) - || (option->shortForm && strcmp(option->shortForm, optStr) == 0)) { + if (strcmp(argv[i], "-w") == 0 || strcmp(argv[i], "--windowed") == 0) { + _daContext->windowed = 1; + continue; + } - found = 1; - i = parseOption(option, i, argc, argv); - } - } + found = 0; + /* options with a one-to-one mapping */ + for (j = 0; j < count; j++) { + DAProgramOption *option = &options[j]; - /* mixed options */ - if (!found) { - /* XXX: Parsing all options again... */ - for (j = 0; j < count; j++) { - DAProgramOption *option = &options[j]; + if ((option->longForm && strcmp(option->longForm, optStr) == 0) + || (option->shortForm && strcmp(option->shortForm, optStr) == 0)) { - if (option->shortForm && contains(option->shortForm, optStr)) { - found = 1; - i = parseOption(option, i, argc, argv); + found = 1; + i = parseOption(option, i, argc, argv); + } } - } - } - if (!found) { - printf("%s: unrecognized option '%s'\n", argv[0], argv[i]); - printHelp(programDescription), exit(1); + /* mixed options */ + if (!found) + /* XXX: Parsing all options again... */ + for (j = 0; j < count; j++) { + DAProgramOption *option = &options[j]; + + if (option->shortForm && contains(option->shortForm, optStr)) { + found = 1; + i = parseOption(option, i, argc, argv); + } + } + + if (!found) { + printf("%s: unrecognized option '%s'\n", argv[0], argv[i]); + printHelp(programDescription), exit(1); + } } - } } int contains(char *needle, char *haystack) { - char c, *pos; + char c, *pos; - assert(strlen(needle) == 2); + assert(strlen(needle) == 2); - c = needle[1]; + c = needle[1]; - pos = strchr(haystack, c); + pos = strchr(haystack, c); - return (pos != NULL); + return (pos != NULL); } 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; - if (option->type == DONone) - return i; + if (option->type == DONone) + return i; - i++; - if (i >= argc) - printf("%s: missing argument for option '%s'\n", - argv[0], - argv[i-1]), - exit(1); + i++; + if (i >= argc) + printf("%s: missing argument for option '%s'\n", + argv[0], + argv[i-1]), + exit(1); - switch (option->type) { + switch (option->type) { case DOInteger: - *option->value.integer = readIntOption(i, argv); + *option->value.integer = readIntOption(i, argv); - break; + break; case DONatural: - *option->value.integer = readIntOption(i, argv); + *option->value.integer = readIntOption(i, argv); - if (*option->value.integer < 0) - printf("%s: argument %s must be >= 0\n", - argv[0], - argv[i-1]), - exit(1); - break; + if (*option->value.integer < 0) + printf("%s: argument %s must be >= 0\n", + argv[0], + argv[i-1]), + exit(1); + break; case DOString: - *option->value.string = argv[i]; - break; - } + *option->value.string = argv[i]; + break; + } - return i; + return i; } int readIntOption(int index, char **argv) { - int integer; + int integer; - if (sscanf(argv[index], "%i", &integer) != 1) - DAError("error parsing argument for option %s\n", argv[index-1]), - exit(1); + if (sscanf(argv[index], "%i", &integer) != 1) + DAError("error parsing argument for option %s\n", argv[index-1]), + exit(1); - return integer; + return integer; } int DAGetArgC() { - return _daContext->argc; + return _daContext->argc; } -char** +char ** DAGetArgV() { - return _daContext->argv; + return _daContext->argv; } -char* +char * DAGetProgramName() { - return _daContext->programName; + return _daContext->programName; } @@ -207,137 +206,133 @@ DAGetProgramName() * Local functions */ -struct DAContext* -DAContextInit() +struct DAContext * +DAContextInit(void) { - struct DAContext *context = malloc(sizeof(struct DAContext)); + struct DAContext *context = malloc(sizeof(struct DAContext)); - memset(context, 0, sizeof(struct DAContext)); + memset(context, 0, sizeof(struct DAContext)); - return context; + return context; } void -DAFreeContext() +DAFreeContext(void) { - if (_daContext->optionCount > 0) { - int i; + if (_daContext->optionCount > 0) { + int i; - for (i = 0; i < _daContext->optionCount; i++) { - free(_daContext->options[i]); - } + for (i = 0; i < _daContext->optionCount; i++) + free(_daContext->options[i]); - free(_daContext->options); - } + free(_daContext->options); + } - free(_daContext); + free(_daContext); } static void _daContextAddOption(DAProgramOption *option) { - /* If the buffer is full, double its size */ - if (sizeof(_daContext->options) == _daContext->optionCount * sizeof(DAProgramOption)) - { - DAProgramOption **options; + /* If the buffer is full, double its size */ + if (sizeof(_daContext->options) == _daContext->optionCount * sizeof(DAProgramOption)) { + DAProgramOption **options; - options = (DAProgramOption**)realloc( - (DAProgramOption**)_daContext->options, - 2 * sizeof(_daContext->options)); + options = (DAProgramOption **)realloc( + (DAProgramOption **)_daContext->options, + 2 * sizeof(_daContext->options)); - if (options == NULL) - DAError("Out of memory"); + if (options == NULL) + DAError("Out of memory"); - _daContext->options = options; - } + _daContext->options = options; + } - _daContext->options[_daContext->optionCount] = option; - _daContext->optionCount++; + _daContext->options[_daContext->optionCount] = option; + _daContext->optionCount++; } static void _daContextAddOptionData(char *shortForm, char *longForm, - char *description, short type) + char *description, short type) { - DAProgramOption *option = malloc(sizeof(DAProgramOption)); + DAProgramOption *option = malloc(sizeof(DAProgramOption)); - option->shortForm = shortForm; - option->longForm = longForm; - option->description = description; - option->type = type; - option->used = False; - option->value.ptr = NULL; + option->shortForm = shortForm; + option->longForm = longForm; + option->description = description; + option->type = type; + option->used = False; + option->value.ptr = NULL; - _daContextAddOption(option); + _daContextAddOption(option); } static void -_daContextAddDefaultOptions() +_daContextAddDefaultOptions(void) { - _daContextAddOptionData("-h", "--help", "show this help text and exit", DONone); - _daContextAddOptionData("-v", "--version", "show program version and exit", DONone); - _daContextAddOptionData("-w", "--windowed", "run the application in windowed mode", DONone); + _daContextAddOptionData("-h", "--help", "show this help text and exit", DONone); + _daContextAddOptionData("-v", "--version", "show program version and exit", DONone); + _daContextAddOptionData("-w", "--windowed", "run the application in windowed mode", DONone); } static void _daContextAddOptions(DAProgramOption *options, int count) { - int i; - - for (i = 0; i < count; i++) { - _daContextAddOptionData( - options[i].shortForm, - options[i].longForm, - options[i].description, - options[i].type); - } + int 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) { - int i; - DAProgramOption **options = _daContext->options; - int count = _daContext->optionCount; - - printf("Usage: %s [OPTIONS]\n", _daContext->programName); - if (description) - puts(description); - - for (i = 0; i < count; i++) - { - char blank[30]; - int c; - - if (options[i]->shortForm && options[i]->longForm) - c = printf(" %s, %s", options[i]->shortForm, options[i]->longForm); - else if (options[i]->shortForm) - c = printf(" %s", options[i]->shortForm); - else if (options[i]->longForm) - c = printf(" %s", options[i]->longForm); - else - continue; - - if (options[i]->type != DONone) { - switch (options[i]->type) { - case DOInteger: - c += printf(" <integer>"); - break; - case DOString: - c += printf(" <string>"); - break; - case DONatural: - c += printf(" <number>"); - break; - } - } + int i; + DAProgramOption **options = _daContext->options; + int count = _daContext->optionCount; + + printf("Usage: %s [OPTIONS]\n", _daContext->programName); + if (description) + puts(description); + + for (i = 0; i < count; i++) { + char blank[30]; + int c; + + if (options[i]->shortForm && options[i]->longForm) + c = printf(" %s, %s", options[i]->shortForm, options[i]->longForm); + else if (options[i]->shortForm) + c = printf(" %s", options[i]->shortForm); + else if (options[i]->longForm) + c = printf(" %s", options[i]->longForm); + else + continue; + + if (options[i]->type != DONone) { + switch (options[i]->type) { + case DOInteger: + c += printf(" <integer>"); + break; + case DOString: + c += printf(" <string>"); + break; + case DONatural: + c += printf(" <number>"); + break; + } + } - memset(blank, ' ', 30); - if (c > 29) - c = 1; - blank[30-c] = 0; - printf("%s %s\n", blank, options[i]->description); - } + memset(blank, ' ', 30); + if (c > 29) + c = 1; + blank[30-c] = 0; + printf("%s %s\n", blank, options[i]->description); + } } diff --git a/libdockapp/src/daargs.h b/libdockapp/src/daargs.h index 7f10a8a..0373ffb 100644 --- a/libdockapp/src/daargs.h +++ b/libdockapp/src/daargs.h @@ -26,22 +26,22 @@ * Context structure to keep track of globals */ struct DAContext { - int argc; /* Raw input data */ - char **argv; + int argc; /* Raw input data */ + char **argv; - int windowed; - int width, height; - int timeOut; + int windowed; + int width, height; + int timeOut; - DACallbacks callbacks; + DACallbacks callbacks; - char *programName; /* shortcut to argv[0] */ + char *programName; /* shortcut to argv[0] */ - DAProgramOption **options; /* Array of option pointers */ - short optionCount; + DAProgramOption **options; /* Array of option pointers */ + short optionCount; }; -struct DAContext* DAContextInit(); -void DAFreeContext(); +struct DAContext *DAContextInit(void); +void DAFreeContext(void); diff --git a/libdockapp/src/dacallback.c b/libdockapp/src/dacallback.c index 5f4522e..c4ef178 100644 --- a/libdockapp/src/dacallback.c +++ b/libdockapp/src/dacallback.c @@ -28,30 +28,30 @@ extern struct DAContext *_daContext; void DASetCallbacks(DACallbacks *callbacks) { - long mask = 0; - - _daContext->callbacks = *callbacks; - - if (callbacks->destroy) - mask |= StructureNotifyMask; - if (callbacks->buttonPress) - mask |= ButtonPressMask; - if (callbacks->buttonRelease) - mask |= ButtonReleaseMask; - if (callbacks->motion) - mask |= PointerMotionMask; - if (callbacks->enter) - mask |= EnterWindowMask; - if (callbacks->leave) - mask |= LeaveWindowMask; - - XSelectInput(DADisplay, DAWindow, mask); - XFlush(DADisplay); + long mask = 0; + + _daContext->callbacks = *callbacks; + + if (callbacks->destroy) + mask |= StructureNotifyMask; + if (callbacks->buttonPress) + mask |= ButtonPressMask; + if (callbacks->buttonRelease) + mask |= ButtonReleaseMask; + if (callbacks->motion) + mask |= PointerMotionMask; + if (callbacks->enter) + mask |= EnterWindowMask; + if (callbacks->leave) + mask |= LeaveWindowMask; + + XSelectInput(DADisplay, DAWindow, mask); + XFlush(DADisplay); } void DASetTimeout(int milliseconds) { - _daContext->timeOut = milliseconds; + _daContext->timeOut = milliseconds; } diff --git a/libdockapp/src/dacolor.c b/libdockapp/src/dacolor.c index f648768..b1ce2c1 100644 --- a/libdockapp/src/dacolor.c +++ b/libdockapp/src/dacolor.c @@ -29,18 +29,18 @@ extern struct DAContext *_daContext; unsigned long DAGetColor(char *colorName) { - XColor color; + XColor color; - if (!XParseColor(DADisplay, - DefaultColormap(DADisplay, DefaultScreen(DADisplay)), - colorName, &color)) - DAError("could not parse color %s", colorName); + if (!XParseColor(DADisplay, + DefaultColormap(DADisplay, DefaultScreen(DADisplay)), + colorName, &color)) + DAError("could not parse color %s", colorName); - if (!XAllocColor(DADisplay, DefaultColormap(DADisplay, DefaultScreen(DADisplay)), &color)) { - DAWarning("could not allocate color %s. Using black instead", colorName); - return BlackPixel(DADisplay, DefaultScreen(DADisplay)); - } + if (!XAllocColor(DADisplay, DefaultColormap(DADisplay, DefaultScreen(DADisplay)), &color)) { + DAWarning("could not allocate color %s. Using black instead", colorName); + return BlackPixel(DADisplay, DefaultScreen(DADisplay)); + } - return color.pixel; + return color.pixel; } diff --git a/libdockapp/src/daevent.c b/libdockapp/src/daevent.c index 0972cb8..21fad98 100644 --- a/libdockapp/src/daevent.c +++ b/libdockapp/src/daevent.c @@ -29,131 +29,129 @@ #include "daargs.h" #include "dautil.h" -extern struct DAContext *_daContext; -extern Atom WM_DELETE_WINDOW; +extern struct DAContext *_daContext; +extern Atom WM_DELETE_WINDOW; Bool DAProcessEvent(XEvent *event) { - if (event->xany.window == DAWindow) - return DAProcessEventForWindow(DAWindow, event); - else if (event->xany.window == DALeader) - /* XXX: Is this superfluous now that DAWindow always references the - * dockapp window? - */ - return DAProcessEventForWindow(DALeader, event); - else - /* XXX: What about handling events for child windows? */ - return False; + if (event->xany.window == DAWindow) + return DAProcessEventForWindow(DAWindow, event); + else if (event->xany.window == DALeader) + /* XXX: Is this superfluous now that DAWindow always references the + * dockapp window? + */ + return DAProcessEventForWindow(DALeader, event); + else + /* XXX: What about handling events for child windows? */ + return False; } Bool DAProcessEventForWindow(Window window, XEvent *event) { - if (event->xany.window != window) - return False; + if (event->xany.window != window) + return False; - switch (event->type) { + switch (event->type) { case ClientMessage: - if (event->xclient.data.l[0] != WM_DELETE_WINDOW) { - break; - } - /* fallthrough */ + if (event->xclient.data.l[0] != WM_DELETE_WINDOW) + break; + /* fallthrough */ case DestroyNotify: - if (_daContext->callbacks.destroy) - (*_daContext->callbacks.destroy)(); + if (_daContext->callbacks.destroy) + (*_daContext->callbacks.destroy)(); - DAFreeContext(); - XCloseDisplay(DADisplay); + DAFreeContext(); + XCloseDisplay(DADisplay); #ifdef DEBUG - debug("%s: DestroyNotify\n", _daContext->programName); + debug("%s: DestroyNotify\n", _daContext->programName); #endif - exit(0); - break; + exit(0); + break; case ButtonPress: - if (_daContext->callbacks.buttonPress) - (*_daContext->callbacks.buttonPress)(event->xbutton.button, - event->xbutton.state, - event->xbutton.x, - event->xbutton.y); - break; + if (_daContext->callbacks.buttonPress) + (*_daContext->callbacks.buttonPress)(event->xbutton.button, + event->xbutton.state, + event->xbutton.x, + event->xbutton.y); + break; case ButtonRelease: - if (_daContext->callbacks.buttonRelease) - (*_daContext->callbacks.buttonRelease)(event->xbutton.button, - event->xbutton.state, - event->xbutton.x, - event->xbutton.y); - break; + if (_daContext->callbacks.buttonRelease) + (*_daContext->callbacks.buttonRelease)(event->xbutton.button, + event->xbutton.state, + event->xbutton.x, + event->xbutton.y); + break; case MotionNotify: - if (_daContext->callbacks.motion) - (*_daContext->callbacks.motion)(event->xmotion.x, - event->xmotion.y); - break; + if (_daContext->callbacks.motion) + (*_daContext->callbacks.motion)(event->xmotion.x, + event->xmotion.y); + break; case EnterNotify: - if (_daContext->callbacks.enter) - (*_daContext->callbacks.enter)(); - break; + if (_daContext->callbacks.enter) + (*_daContext->callbacks.enter)(); + break; case LeaveNotify: - if (_daContext->callbacks.leave) - (*_daContext->callbacks.leave)(); - break; + if (_daContext->callbacks.leave) + (*_daContext->callbacks.leave)(); + break; default: - return False; - } + return False; + } - return True; + return True; } void DAEventLoop(void) { - DAEventLoopForWindow(DAWindow); + DAEventLoopForWindow(DAWindow); } void DAEventLoopForWindow(Window window) { - XEvent event; - - for (;;) { - if (_daContext->timeOut >= 0) { - if (!DANextEventOrTimeout(&event, _daContext->timeOut)) { - if (_daContext->callbacks.timeout) - (*_daContext->callbacks.timeout)(); - continue; - } + XEvent event; + + for (;; ) { + if (_daContext->timeOut >= 0) { + if (!DANextEventOrTimeout(&event, _daContext->timeOut)) { + if (_daContext->callbacks.timeout) + (*_daContext->callbacks.timeout)(); + continue; + } + } else + XNextEvent(DADisplay, &event); + + DAProcessEventForWindow(window, &event); } - else - XNextEvent(DADisplay, &event); - - DAProcessEventForWindow(window, &event); - } } Bool DANextEventOrTimeout(XEvent *event, unsigned long milliseconds) { - struct timeval timeout; - fd_set rset; + struct timeval timeout; + fd_set rset; - XSync(DADisplay, False); - if (XPending(DADisplay)) { - XNextEvent(DADisplay, event); - return True; - } + XSync(DADisplay, False); + if (XPending(DADisplay)) { + XNextEvent(DADisplay, event); + return True; + } - timeout.tv_sec = milliseconds / 1000; - timeout.tv_usec = (milliseconds % 1000) * 1000; + timeout.tv_sec = milliseconds / 1000; + timeout.tv_usec = (milliseconds % 1000) * 1000; - FD_ZERO(&rset); - FD_SET(ConnectionNumber(DADisplay), &rset); + FD_ZERO(&rset); + FD_SET(ConnectionNumber(DADisplay), &rset); - if (select(ConnectionNumber(DADisplay)+1, &rset, NULL, NULL, &timeout) > 0) { - XNextEvent(DADisplay, event); - return True; - } + if (select(ConnectionNumber(DADisplay)+1, &rset, NULL, NULL, &timeout) > 0) { + XNextEvent(DADisplay, event); + return True; + } - return False; + return False; } diff --git a/libdockapp/src/damain.c b/libdockapp/src/damain.c index 7951c51..6e583a6 100644 --- a/libdockapp/src/damain.c +++ b/libdockapp/src/damain.c @@ -24,195 +24,195 @@ #include "daargs.h" #include "dautil.h" -#define MIN(a, b) (a < b ? a : b) +#define MIN(a, b) (a < b ? a : b) struct DAContext *_daContext; -DARect DANoRect = {0, 0, 0, 0}; -Display *DADisplay = NULL; -Window DALeader = None; -Window DAIcon = None; -Window DAWindow = None; -int DADepth = 0; -Visual *DAVisual = NULL; -unsigned long DAExpectedVersion = 0; -GC DAGC = NULL, DAClearGC = NULL; -DARect DAPreferredIconSizes = {-1, -1, 0, 0}; -Atom WM_DELETE_WINDOW; +DARect DANoRect = {0, 0, 0, 0}; +Display *DADisplay = NULL; +Window DALeader = None; +Window DAIcon = None; +Window DAWindow = None; +int DADepth = 0; +Visual *DAVisual = NULL; +unsigned long DAExpectedVersion = 0; +GC DAGC = NULL, DAClearGC = NULL; +DARect DAPreferredIconSizes = {-1, -1, 0, 0}; +Atom WM_DELETE_WINDOW; void DAOpenDisplay(char *display, int argc, char **argv) { - /* Open Connection to X Server */ - DADisplay = XOpenDisplay(display); - if (!DADisplay) { - printf("%s: could not open display %s!\n", _daContext->programName, - XDisplayName(display)); - exit(EXIT_FAILURE); - } - - DADepth = DefaultDepth(DADisplay, DefaultScreen(DADisplay)); - DAVisual = DefaultVisual(DADisplay, DefaultScreen(DADisplay)); - DAGC = DefaultGC(DADisplay, DefaultScreen(DADisplay)); + /* Open Connection to X Server */ + DADisplay = XOpenDisplay(display); + if (!DADisplay) { + printf("%s: could not open display %s!\n", _daContext->programName, + XDisplayName(display)); + exit(EXIT_FAILURE); + } + + DADepth = DefaultDepth(DADisplay, DefaultScreen(DADisplay)); + DAVisual = DefaultVisual(DADisplay, DefaultScreen(DADisplay)); + DAGC = DefaultGC(DADisplay, DefaultScreen(DADisplay)); } void DAProposeIconSize(unsigned width, unsigned height) { - XIconSize *iconSizes; - int nrSizes = 0; - - _daContext->width = width; - _daContext->height = height; - - /* Get the nearest allowed icon size if the WM specifies such */ - iconSizes = XAllocIconSize(); - if (XGetIconSizes(DADisplay, DefaultRootWindow(DADisplay), - &iconSizes, &nrSizes)) { - int i; - int da = -1; - int min_w = -1, min_h = -1; - int max_w = 0, max_h = 0; - - for (i = 0; i < nrSizes; i++) { - int w1, h1, w, h; - - if ((max_w < iconSizes[i].max_width) || - (max_h < iconSizes[i].max_height)) { - max_w = iconSizes[i].max_width; - max_h = iconSizes[i].max_height; - } - - if ((min_w > iconSizes[i].min_width) || - (min_h > iconSizes[i].min_height) || - (min_w == -1)) { - min_w = iconSizes[i].min_width; - min_h = iconSizes[i].min_height; - } - - if ((width > iconSizes[i].max_width) || - (width < iconSizes[i].min_width) || - (height > iconSizes[i].max_height) || - (height < iconSizes[i].min_height)) - continue; - - 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); - - if ((w * h < da) || (da == -1)) { - _daContext->width = width + w; - _daContext->height = height + h; - da = w * h; - } - } - - DAPreferredIconSizes.x = min_w; - DAPreferredIconSizes.y = min_h; - DAPreferredIconSizes.width = max_w; - DAPreferredIconSizes.height = max_h; - - 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); + XIconSize *iconSizes; + int nrSizes = 0; + + _daContext->width = width; + _daContext->height = height; + + /* Get the nearest allowed icon size if the WM specifies such */ + iconSizes = XAllocIconSize(); + if (XGetIconSizes(DADisplay, DefaultRootWindow(DADisplay), + &iconSizes, &nrSizes)) { + int i; + int da = -1; + int min_w = -1, min_h = -1; + int max_w = 0, max_h = 0; + + for (i = 0; i < nrSizes; i++) { + int w1, h1, w, h; + + if ((max_w < iconSizes[i].max_width) || + (max_h < iconSizes[i].max_height)) { + max_w = iconSizes[i].max_width; + max_h = iconSizes[i].max_height; + } + + if ((min_w > iconSizes[i].min_width) || + (min_h > iconSizes[i].min_height) || + (min_w == -1)) { + min_w = iconSizes[i].min_width; + min_h = iconSizes[i].min_height; + } + + if ((width > iconSizes[i].max_width) || + (width < iconSizes[i].min_width) || + (height > iconSizes[i].max_height) || + (height < iconSizes[i].min_height)) + continue; + + 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); + + if ((w * h < da) || (da == -1)) { + _daContext->width = width + w; + _daContext->height = height + h; + da = w * h; + } + } + + DAPreferredIconSizes.x = min_w; + DAPreferredIconSizes.y = min_h; + DAPreferredIconSizes.width = max_w; + DAPreferredIconSizes.height = max_h; + + 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); + XFree(iconSizes); } void DACreateIcon(char *name, unsigned width, unsigned height, int argc, char **argv) { - XClassHint *classHint; - XWMHints *wmHints; - XGCValues gcv; - unsigned long valueMask; - char *resourceValue; - - _daContext->width = width; - _daContext->height = height; - - /* Create Windows */ - DALeader = XCreateSimpleWindow(DADisplay, DefaultRootWindow(DADisplay), - 0, 0, width, height, 0, 0, 0); - - if (! _daContext->windowed) { - DAIcon = XCreateSimpleWindow(DADisplay, DefaultRootWindow(DADisplay), - 0, 0, width, height, 0, 0, 0); - DAWindow = DAIcon; - } else { - DAIcon = None; - DAWindow = DALeader; - } - - /* Set ClassHint */ - if (!(classHint = XAllocClassHint())) - printf("%s: can't allocate memory for class hints!\n", - _daContext->programName), exit(1); - classHint->res_class = RES_CLASSNAME; - classHint->res_name = name; - - XSetClassHint(DADisplay, DALeader, classHint); - XFree(classHint); - - /* Set WMHints */ - if (!(wmHints = XAllocWMHints())) - printf("%s: can't allocate memory for wm hints!\n", - _daContext->programName), exit(1); - - wmHints->flags = WindowGroupHint; - wmHints->window_group = DALeader; - - if (!_daContext->windowed) { - wmHints->flags |= IconWindowHint|StateHint; - wmHints->icon_window = DAIcon; - wmHints->initial_state = WithdrawnState; - } - - XSetWMHints(DADisplay, DALeader, wmHints); - XFree(wmHints); - - /* Set WMProtocols */ - WM_DELETE_WINDOW = XInternAtom(DADisplay, "WM_DELETE_WINDOW", True); - XSetWMProtocols(DADisplay, DALeader, &WM_DELETE_WINDOW, 1); - - /* Set Command to start the app so it can be docked properly */ - XSetCommand(DADisplay, DALeader, argv, argc); - - gcv.graphics_exposures = False; - valueMask = GCGraphicsExposures; - - /* continue setting the foreground GC */ - resourceValue = XGetDefault(DADisplay, RES_CLASSNAME, "foreground"); - if (resourceValue) { - gcv.foreground = DAGetColor(resourceValue); - valueMask |= GCForeground; - } - - XChangeGC(DADisplay, DAGC, valueMask, &gcv); - - /* set background GC values before setting value for foreground */ - resourceValue = XGetDefault(DADisplay, RES_CLASSNAME, "background"); - if (resourceValue) { - gcv.foreground = DAGetColor(resourceValue); - } - - DAClearGC = XCreateGC(DADisplay, DAWindow, - GCGraphicsExposures|GCForeground, &gcv); - - XFlush(DADisplay); + XClassHint *classHint; + XWMHints *wmHints; + XGCValues gcv; + unsigned long valueMask; + char *resourceValue; + + _daContext->width = width; + _daContext->height = height; + + /* Create Windows */ + DALeader = XCreateSimpleWindow(DADisplay, DefaultRootWindow(DADisplay), + 0, 0, width, height, 0, 0, 0); + + if (!_daContext->windowed) { + DAIcon = XCreateSimpleWindow(DADisplay, DefaultRootWindow(DADisplay), + 0, 0, width, height, 0, 0, 0); + DAWindow = DAIcon; + } else { + DAIcon = None; + DAWindow = DALeader; + } + + /* Set ClassHint */ + classHint = XAllocClassHint(); + if (!classHint) + printf("%s: can't allocate memory for class hints!\n", + _daContext->programName), exit(1); + classHint->res_class = RES_CLASSNAME; + classHint->res_name = name; + + XSetClassHint(DADisplay, DALeader, classHint); + XFree(classHint); + + /* Set WMHints */ + wmHints = XAllocWMHints(); + if (!wmHints) + printf("%s: can't allocate memory for wm hints!\n", + _daContext->programName), exit(1); + + wmHints->flags = WindowGroupHint; + wmHints->window_group = DALeader; + + if (!_daContext->windowed) { + wmHints->flags |= IconWindowHint|StateHint; + wmHints->icon_window = DAIcon; + wmHints->initial_state = WithdrawnState; + } + + XSetWMHints(DADisplay, DALeader, wmHints); + XFree(wmHints); + + /* Set WMProtocols */ + WM_DELETE_WINDOW = XInternAtom(DADisplay, "WM_DELETE_WINDOW", True); + XSetWMProtocols(DADisplay, DALeader, &WM_DELETE_WINDOW, 1); + + /* Set Command to start the app so it can be docked properly */ + XSetCommand(DADisplay, DALeader, argv, argc); + + gcv.graphics_exposures = False; + valueMask = GCGraphicsExposures; + + /* continue setting the foreground GC */ + resourceValue = XGetDefault(DADisplay, RES_CLASSNAME, "foreground"); + if (resourceValue) { + gcv.foreground = DAGetColor(resourceValue); + valueMask |= GCForeground; + } + + XChangeGC(DADisplay, DAGC, valueMask, &gcv); + + /* set background GC values before setting value for foreground */ + resourceValue = XGetDefault(DADisplay, RES_CLASSNAME, "background"); + if (resourceValue) + gcv.foreground = DAGetColor(resourceValue); + + DAClearGC = XCreateGC(DADisplay, DAWindow, + GCGraphicsExposures|GCForeground, &gcv); + + XFlush(DADisplay); } void DAShow(void) { - DAShowWindow(DALeader); + DAShowWindow(DALeader); } @@ -220,22 +220,21 @@ void DAShowWindow(Window window) { - XMapRaised(DADisplay, window); - if ((window == DALeader) && !_daContext->windowed) { - XMapSubwindows(DADisplay, DAIcon); - } else { - XMapSubwindows(DADisplay, window); - } - - XFlush(DADisplay); + XMapRaised(DADisplay, window); + if ((window == DALeader) && !_daContext->windowed) + XMapSubwindows(DADisplay, DAIcon); + else + XMapSubwindows(DADisplay, window); + + XFlush(DADisplay); } /* Deprecated */ void DAInitialize(char *display, char *name, unsigned width, unsigned height, - int argc, char **argv) + int argc, char **argv) { - DAOpenDisplay(display, argc, argv); - DACreateIcon(name, width, height, argc, argv); + DAOpenDisplay(display, argc, argv); + DACreateIcon(name, width, height, argc, argv); } diff --git a/libdockapp/src/dapixmap.c b/libdockapp/src/dapixmap.c index 39b9e47..58733b2 100644 --- a/libdockapp/src/dapixmap.c +++ b/libdockapp/src/dapixmap.c @@ -32,109 +32,109 @@ extern struct DAContext *_daContext; /* Local typedef */ typedef enum { - daXpmSourceData, - daXpmSourceFile + daXpmSourceData, + daXpmSourceFile } daXpmSource; /* Function prototype */ Bool _daMakePixmap(daXpmSource source, - char **data, Pixmap *pixmap, Pixmap *mask, - unsigned short *width, unsigned short *height); + char **data, Pixmap *pixmap, Pixmap *mask, + unsigned short *width, unsigned short *height); void DASetShapeWithOffset(Pixmap shapeMask, int x_ofs, int y_ofs) { - DASetShapeWithOffsetForWindow(DAWindow, shapeMask, x_ofs, y_ofs); + DASetShapeWithOffsetForWindow(DAWindow, shapeMask, x_ofs, y_ofs); } void DASetShapeWithOffsetForWindow(Window window, Pixmap shapeMask, - int x_ofs, int y_ofs) + int x_ofs, int y_ofs) { - XShapeCombineMask(DADisplay, window, ShapeBounding, -x_ofs, -y_ofs, - shapeMask, ShapeSet); - XFlush(DADisplay); + XShapeCombineMask(DADisplay, window, ShapeBounding, -x_ofs, -y_ofs, + shapeMask, ShapeSet); + XFlush(DADisplay); } void DASetPixmap(Pixmap pixmap) { - DASetPixmapForWindow(DAWindow, pixmap); + DASetPixmapForWindow(DAWindow, pixmap); } void DASetPixmapForWindow(Window window, Pixmap pixmap) { - XSetWindowBackgroundPixmap(DADisplay, window, pixmap); - XClearWindow(DADisplay, window); - XFlush(DADisplay); + XSetWindowBackgroundPixmap(DADisplay, window, pixmap); + XClearWindow(DADisplay, window); + XFlush(DADisplay); } Pixmap DAMakePixmap(void) { - return (XCreatePixmap(DADisplay, DAWindow, - _daContext->width, _daContext->height, - DADepth)); + return (XCreatePixmap(DADisplay, DAWindow, + _daContext->width, _daContext->height, + DADepth)); } Pixmap DAMakeShape(void) { - return (XCreatePixmap(DADisplay, DAWindow, - _daContext->width, _daContext->height, - 1)); + return (XCreatePixmap(DADisplay, DAWindow, + _daContext->width, _daContext->height, + 1)); } Bool DAMakePixmapFromData(char **data, Pixmap *pixmap, Pixmap *mask, - unsigned short *width, unsigned short *height) + unsigned short *width, unsigned short *height) { - return _daMakePixmap(daXpmSourceData, data, - pixmap, mask, - width, height); + return _daMakePixmap(daXpmSourceData, data, + pixmap, mask, + width, height); } Bool DAMakePixmapFromFile(char *filename, Pixmap *pixmap, Pixmap *mask, - unsigned short *width, unsigned short *height) + unsigned short *width, unsigned short *height) { - if (access(filename, R_OK) < 0) - return False; + if (access(filename, R_OK) < 0) + return False; - return _daMakePixmap(daXpmSourceFile, (char**)filename, - pixmap, mask, - width, height); + return _daMakePixmap(daXpmSourceFile, (char **)filename, + pixmap, mask, + width, height); } Bool _daMakePixmap(daXpmSource source, - char **data, Pixmap *pixmap, Pixmap *mask, - unsigned short *width, unsigned short *height) + char **data, Pixmap *pixmap, Pixmap *mask, + unsigned short *width, unsigned short *height) { - XpmAttributes xpmAttr; + XpmAttributes xpmAttr; - xpmAttr.valuemask = XpmCloseness; - xpmAttr.closeness = 40000; + xpmAttr.valuemask = XpmCloseness; + xpmAttr.closeness = 40000; - if (source == daXpmSourceData + if (source == daXpmSourceData && (XpmCreatePixmapFromData( - DADisplay, DAWindow, data, pixmap, mask, &xpmAttr) != 0)) - return False; + DADisplay, DAWindow, data, pixmap, mask, &xpmAttr) != 0)) + return False; - else if (source == daXpmSourceFile - && (XpmReadFileToPixmap( - DADisplay, DAWindow, (char*)data, pixmap, mask, &xpmAttr) != 0)) - return False; + else if (source == daXpmSourceFile + && (XpmReadFileToPixmap( + DADisplay, DAWindow, (char *)data, pixmap, mask, &xpmAttr) != 0)) + return False; - *width = xpmAttr.width; - *height = xpmAttr.height; + *width = xpmAttr.width; + *height = xpmAttr.height; - return True; + return True; } diff --git a/libdockapp/src/darect.c b/libdockapp/src/darect.c index c216a74..626c037 100644 --- a/libdockapp/src/darect.c +++ b/libdockapp/src/darect.c @@ -26,27 +26,27 @@ void DAProcessActionRects(int x, int y, DAActionRect *actionrects, int count, - void *data) + void *data) { - int index = 0; - - if (!actionrects) - return; - - while ( (index < count) && - ((x < actionrects[index].rect.x) || - (x > actionrects[index].rect.x + actionrects[index].rect.width) || - (y < actionrects[index].rect.y) || - (y > actionrects[index].rect.y + actionrects[index].rect.height))) - index++; - - if (index == count) - return; - - if (actionrects[index].action) - (*actionrects[index].action)(x - actionrects[index].rect.x, - y - actionrects[index].rect.y, - actionrects[index].rect, - data); + int index = 0; + + if (!actionrects) + return; + + while ((index < count) && + ((x < actionrects[index].rect.x) || + (x > actionrects[index].rect.x + actionrects[index].rect.width) || + (y < actionrects[index].rect.y) || + (y > actionrects[index].rect.y + actionrects[index].rect.height))) + index++; + + if (index == count) + return; + + if (actionrects[index].action) + (*actionrects[index].action)(x - actionrects[index].rect.x, + y - actionrects[index].rect.y, + actionrects[index].rect, + data); } diff --git a/libdockapp/src/dashaped.c b/libdockapp/src/dashaped.c index a2b7a5c..94ccefc 100644 --- a/libdockapp/src/dashaped.c +++ b/libdockapp/src/dashaped.c @@ -32,51 +32,51 @@ /* Local typedef */ typedef enum { - daShapeSourceData, - daShapeSourceFile + daShapeSourceData, + daShapeSourceFile } daShapeSource; /* 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)); + DAShapedPixmap *dasp = malloc(sizeof(DAShapedPixmap)); - if (dasp == NULL) - return NULL; + if (dasp == NULL) + return NULL; - memset(dasp, 0, sizeof(DAShapedPixmap)); - dasp->pixmap = DAMakePixmap(); - dasp->shape = DAMakeShape(); - dasp->geometry.width = _daContext->width; - dasp->geometry.height = _daContext->height; + memset(dasp, 0, sizeof(DAShapedPixmap)); + dasp->pixmap = DAMakePixmap(); + dasp->shape = DAMakeShape(); + dasp->geometry.width = _daContext->width; + dasp->geometry.height = _daContext->height; - setGCs(dasp); - DASPClear(dasp); + setGCs(dasp); + DASPClear(dasp); - return dasp; + return dasp; } /* Create a new shaped pixmap from XPM-data */ -DAShapedPixmap* +DAShapedPixmap * DAMakeShapedPixmapFromData(char **data) { - return _daMakeShapedPixmap(daShapeSourceData, data); + return _daMakeShapedPixmap(daShapeSourceData, data); } /* Create a new shaped pixmap from XPM-data */ -DAShapedPixmap* +DAShapedPixmap * DAMakeShapedPixmapFromFile(char *filename) { - return _daMakeShapedPixmap(daShapeSourceFile, (char**)filename); + return _daMakeShapedPixmap(daShapeSourceFile, (char **)filename); } @@ -84,13 +84,13 @@ DAMakeShapedPixmapFromFile(char *filename) void DAFreeShapedPixmap(DAShapedPixmap *dasp) { - assert(dasp); + assert(dasp); - XFreePixmap(DADisplay, dasp->pixmap); - XFreePixmap(DADisplay, dasp->shape); - XFreeGC(DADisplay, dasp->shapeGC); + XFreePixmap(DADisplay, dasp->pixmap); + XFreePixmap(DADisplay, dasp->shape); + XFreeGC(DADisplay, dasp->shapeGC); - free(dasp); + free(dasp); } /* Copy shape-mask and pixmap-data from an area in one shaped pixmap @@ -98,10 +98,10 @@ DAFreeShapedPixmap(DAShapedPixmap *dasp) void DASPCopyArea(DAShapedPixmap *src, DAShapedPixmap *dst, int x1, int y1, int w, int h, int x2, int y2) { - assert(src != NULL && dst != NULL); + assert(src != NULL && dst != NULL); - XCopyPlane(DADisplay, src->shape, dst->shape, src->shapeGC, x1, y1, w, h, x2, y2, 1); - XCopyArea(DADisplay, src->pixmap, dst->pixmap, src->drawGC, x1, y1, w, h, x2, y2); + XCopyPlane(DADisplay, src->shape, dst->shape, src->shapeGC, x1, y1, w, h, x2, y2, 1); + XCopyArea(DADisplay, src->pixmap, dst->pixmap, src->drawGC, x1, y1, w, h, x2, y2); } @@ -109,21 +109,21 @@ DASPCopyArea(DAShapedPixmap *src, DAShapedPixmap *dst, int x1, int y1, int w, in void DASPClear(DAShapedPixmap *dasp) { - XGCValues gcv; + XGCValues gcv; - assert(dasp != NULL); + assert(dasp != NULL); - gcv.foreground = 0; - XChangeGC(DADisplay, dasp->shapeGC, GCForeground, &gcv); + gcv.foreground = 0; + XChangeGC(DADisplay, dasp->shapeGC, GCForeground, &gcv); - /* Clear pixmaps */ - XFillRectangle(DADisplay, dasp->pixmap, - DAClearGC, 0, 0, dasp->geometry.width, dasp->geometry.height); - XFillRectangle(DADisplay, dasp->shape, - dasp->shapeGC, 0, 0, dasp->geometry.width, dasp->geometry.height); + /* Clear pixmaps */ + XFillRectangle(DADisplay, dasp->pixmap, + DAClearGC, 0, 0, dasp->geometry.width, dasp->geometry.height); + XFillRectangle(DADisplay, dasp->shape, + dasp->shapeGC, 0, 0, dasp->geometry.width, dasp->geometry.height); - gcv.foreground = 1; - XChangeGC(DADisplay, dasp->shapeGC, GCForeground, &gcv); + gcv.foreground = 1; + XChangeGC(DADisplay, dasp->shapeGC, GCForeground, &gcv); } @@ -131,66 +131,66 @@ DASPClear(DAShapedPixmap *dasp) void DASPSetPixmap(DAShapedPixmap *dasp) { - DASPSetPixmapForWindow(DAWindow, dasp); + DASPSetPixmapForWindow(DAWindow, dasp); } void DASPSetPixmapForWindow(Window window, DAShapedPixmap *dasp) { - assert(dasp != NULL); + assert(dasp != NULL); - DASetShapeForWindow(window, dasp->shape); - DASetPixmapForWindow(window, dasp->pixmap); + DASetShapeForWindow(window, dasp->shape); + DASetPixmapForWindow(window, dasp->pixmap); } void setGCs(DAShapedPixmap *dasp) { - XGCValues gcv; + XGCValues gcv; - dasp->drawGC = DAGC; - dasp->clearGC = DAClearGC; + dasp->drawGC = DAGC; + dasp->clearGC = DAClearGC; - /* create GC for bit-plane operations in shapes */ - gcv.graphics_exposures = False; - gcv.foreground = 1; - gcv.background = 0; - gcv.plane_mask = 1; + /* create GC for bit-plane operations in shapes */ + gcv.graphics_exposures = False; + gcv.foreground = 1; + gcv.background = 0; + gcv.plane_mask = 1; - dasp->shapeGC = XCreateGC( - DADisplay, - dasp->shape, - GCGraphicsExposures|GCForeground|GCBackground|GCPlaneMask, - &gcv); + dasp->shapeGC = XCreateGC( + DADisplay, + dasp->shape, + GCGraphicsExposures|GCForeground|GCBackground|GCPlaneMask, + &gcv); } /* Create a new shaped pixmap using specified method */ -DAShapedPixmap* +DAShapedPixmap * _daMakeShapedPixmap(daShapeSource source, char **data) { - Bool success; - DAShapedPixmap *dasp = malloc(sizeof(DAShapedPixmap)); + Bool success; + DAShapedPixmap *dasp = malloc(sizeof(DAShapedPixmap)); - if (dasp == NULL) - return NULL; + if (dasp == NULL) + return NULL; - memset(dasp, 0, sizeof(DAShapedPixmap)); + memset(dasp, 0, sizeof(DAShapedPixmap)); - if (source == daShapeSourceData) - success = DAMakePixmapFromData(data, &dasp->pixmap, &dasp->shape, - &dasp->geometry.width, &dasp->geometry.height); - else - success = DAMakePixmapFromFile((char*)data, &dasp->pixmap, &dasp->shape, - &dasp->geometry.width, &dasp->geometry.height); + if (source == daShapeSourceData) + success = DAMakePixmapFromData(data, &dasp->pixmap, &dasp->shape, + &dasp->geometry.width, &dasp->geometry.height); + else + success = DAMakePixmapFromFile((char *)data, &dasp->pixmap, &dasp->shape, + &dasp->geometry.width, &dasp->geometry.height); - if (!success) - return NULL; + if (!success) + return NULL; - setGCs(dasp); + setGCs(dasp); - return dasp; + return dasp; } diff --git a/libdockapp/src/dautil.c b/libdockapp/src/dautil.c index f1a7894..2fae039 100644 --- a/libdockapp/src/dautil.c +++ b/libdockapp/src/dautil.c @@ -39,137 +39,137 @@ void _message(const char *label, const char *fmt, va_list args); void DASetExpectedVersion(unsigned long expectedVersion) { - DAExpectedVersion = expectedVersion; + DAExpectedVersion = expectedVersion; - if (expectedVersion > DA_VERSION) - DAWarning("Version of libdockapp (%u) is older than " - "version expected (%u)", - DA_VERSION, - DAExpectedVersion); + if (expectedVersion > DA_VERSION) + DAWarning("Version of libdockapp (%u) is older than " + "version expected (%u)", + DA_VERSION, + DAExpectedVersion); } -Display* +Display * DAGetDisplay(char *d, ...) { - /* Be backward compatible */ - if (DAExpectedVersion < 20030126) { - va_list ap; - int argc; - char **argv; + /* Be backward compatible */ + if (DAExpectedVersion < 20030126) { + va_list ap; + int argc; + char **argv; - va_start(ap, d); - argc = va_arg(ap, int); - argv = va_arg(ap, char**); - va_end(ap); + va_start(ap, d); + argc = va_arg(ap, int); + argv = va_arg(ap, char **); + va_end(ap); - DAOpenDisplay(d, argc, argv); + DAOpenDisplay(d, argc, argv); - DAWarning("Expected version of libdockapp is not set."); - DAWarning("Obsolete call to DAGetDisplay()."); + DAWarning("Expected version of libdockapp is not set."); + DAWarning("Obsolete call to DAGetDisplay()."); - return NULL; - } + return NULL; + } - return DADisplay; + return DADisplay; } void DASetDisplay(Display *display) { - DADisplay = display; + DADisplay = display; } Window DAGetWindow(void) { - return DAWindow; + return DAWindow; } void DASetWindow(Window window) { - DAWindow = window; + DAWindow = window; } Window DAGetLeader(void) { - return DALeader; + return DALeader; } void DASetLeader(Window leader) { - DALeader = leader; + DALeader = leader; } Window DAGetIconWindow(void) { - return DAIcon; + return DAIcon; } void DASetIconWindow(Window icon_win) { - DAIcon = icon_win; + DAIcon = icon_win; } int DAGetDepth(void) { - return DADepth; + return DADepth; } void DASetDepth(int depth) { - DADepth = depth; + DADepth = depth; } -Visual* +Visual * DAGetVisual(void) { - return DAVisual; + return DAVisual; } void DASetVisual(Visual *visual) { - DAVisual = visual; + DAVisual = visual; } void DAWarning(const char *fmt, ...) { - va_list args; + va_list args; - va_start(args, fmt); - _message("Warning", fmt, args); - va_end(args); + va_start(args, fmt); + _message("Warning", fmt, args); + va_end(args); } void DAError(const char *fmt, ...) { - va_list args; + va_list args; - va_start(args, fmt); - _message("Error", fmt, args); - exit(1); - va_end(args); + va_start(args, fmt); + _message("Error", fmt, args); + exit(1); + va_end(args); } @@ -180,19 +180,19 @@ DAError(const char *fmt, ...) void _message(const char *label, const char *fmt, va_list args) { - char *w_fmt; + char *w_fmt; - if (_daContext->programName != NULL) { - /* put default string in front of message, add newline */ - 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)); - sprintf(w_fmt, "%s\n", fmt); - } + if (_daContext->programName != NULL) { + /* put default string in front of message, add newline */ + 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)); + sprintf(w_fmt, "%s\n", fmt); + } - /* print the message */ - vfprintf(stderr, w_fmt, args); + /* print the message */ + vfprintf(stderr, w_fmt, args); } @@ -200,10 +200,10 @@ void debug(const char *fmt, ...) { #ifdef DEBUG - va_list args; + va_list args; - va_start(args, fmt); - _message("debug", fmt, args); - va_end(args); + va_start(args, fmt); + _message("debug", fmt, args); + va_end(args); #endif } diff --git a/libdockapp/src/dockapp.h b/libdockapp/src/dockapp.h index d50c544..edcc5f8 100644 --- a/libdockapp/src/dockapp.h +++ b/libdockapp/src/dockapp.h @@ -22,7 +22,7 @@ #ifndef _DOCKAPP_H_ #define _DOCKAPP_H_ -#define DA_VERSION 20050716 +#define DA_VERSION 20050716 /* * This is a simple (trivial) library for writing Window Maker dock @@ -53,37 +53,37 @@ * to handle */ typedef struct { - /* the dockapp window was destroyed */ - void (*destroy)(void); - /* button pressed */ - void (*buttonPress)(int button, int state, int x, int y); - /* button released */ - void (*buttonRelease)(int button, int state, int x, int y); - /* pointer motion */ - void (*motion)(int x, int y); - /* pointer entered dockapp window */ - void (*enter)(void); - /* pointer left dockapp window */ - void (*leave)(void); - /* timer expired */ - void (*timeout)(void); + /* the dockapp window was destroyed */ + void (*destroy)(void); + /* button pressed */ + void (*buttonPress)(int button, int state, int x, int y); + /* button released */ + void (*buttonRelease)(int button, int state, int x, int y); + /* pointer motion */ + void (*motion)(int x, int y); + /* pointer entered dockapp window */ + void (*enter)(void); + /* pointer left dockapp window */ + void (*leave)(void); + /* timer expired */ + void (*timeout)(void); } DACallbacks; typedef struct { - char *shortForm; /* short form for option, like -w */ - char *longForm; /* long form for option, like --withdrawn */ - char *description; /* description for the option */ - - short type; /* type of argument */ - Bool used; /* if the argument was passed on the cmd-line */ - - /* the following are only set if the "used" field is True */ - union { - void *ptr; /* a ptr for the value that was passed */ - int *integer; /* on the command line */ - char **string; - } value; + char *shortForm; /* short form for option, like -w */ + char *longForm; /* long form for option, like --withdrawn */ + char *description; /* description for the option */ + + short type; /* type of argument */ + Bool used; /* if the argument was passed on the cmd-line */ + + /* the following are only set if the "used" field is True */ + union { + void *ptr; /* a ptr for the value that was passed */ + int *integer; /* on the command line */ + char **string; + } value; } DAProgramOption; @@ -98,37 +98,37 @@ typedef void DARectCallback(int x, int y, DARect rect, void *data); * The action rectangle structure */ typedef struct { - DARect rect; - DARectCallback *action; + DARect rect; + DARectCallback *action; } DAActionRect; /* option argument types */ enum { - DONone, /* simple on/off flag */ - DOInteger, /* an integer number */ - DOString, /* a string */ - DONatural /* positive integer number */ + DONone, /* simple on/off flag */ + DOInteger, /* an integer number */ + DOString, /* a string */ + DONatural /* positive integer number */ }; /* Shaped pixmaps: Shapes in combination with pixmaps */ typedef struct { - Pixmap pixmap; - Pixmap shape; /* needs a 1-bit plane GC (shapeGC). */ - GC drawGC, clearGC, shapeGC; - DARect geometry; /* position and size */ - DAActionRect *triggers; + Pixmap pixmap; + Pixmap shape; /* needs a 1-bit plane GC (shapeGC). */ + GC drawGC, clearGC, shapeGC; + DARect geometry; /* position and size */ + DAActionRect *triggers; } DAShapedPixmap; -extern Display *DADisplay; -extern Window DAWindow, DALeader, DAIcon; /* see [NOTE] */ -extern int DADepth; -extern Visual *DAVisual; -extern GC DAGC, DAClearGC; -extern DARect DANoRect; +extern Display *DADisplay; +extern Window DAWindow, DALeader, DAIcon; /* see [NOTE] */ +extern int DADepth; +extern Visual *DAVisual; +extern GC DAGC, DAClearGC; +extern DARect DANoRect; extern unsigned long DAExpectedVersion; /* [NOTE] @@ -159,7 +159,7 @@ void DASetExpectedVersion(unsigned long expectedVersion); * in windowed mode. */ void DAParseArguments(int argc, char **argv, DAProgramOption *options, - int count, char *programDescription, char *versionDescription); + int count, char *programDescription, char *versionDescription); /* * DAInitialize- @@ -184,12 +184,12 @@ void DAParseArguments(int argc, char **argv, DAProgramOption *options, */ void DAInitialize(char *display, char *name, unsigned width, unsigned height, - int argc, char **argv); + int argc, char **argv); void DAOpenDisplay(char *display, int argc, char **argv); void DACreateIcon(char *name, unsigned width, unsigned height, - int argc, char **argv); + int argc, char **argv); void DAProposeIconSize(unsigned width, unsigned height); @@ -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); @@ -237,13 +237,13 @@ void DASetVisual(Visual *visual); * This is only needed if you want the dockapp to be shaped. */ #define DASetShape(shapeMask) \ - (DASetShapeWithOffset((shapeMask), 0, 0)) + (DASetShapeWithOffset((shapeMask), 0, 0)) #define DASetShapeForWindow(window, shapeMask) \ - (DASetShapeWithOffsetForWindow((window), (shapeMask), 0, 0)) + (DASetShapeWithOffsetForWindow((window), (shapeMask), 0, 0)) void DASetShapeWithOffset(Pixmap shapeMask, int x_ofs, int y_ofs); void DASetShapeWithOffsetForWindow(Window window, Pixmap shapeMask, - int x_ofs, int y_ofs); + int x_ofs, int y_ofs); /* * DASetPixmap- * Sets the image pixmap for the dockapp. Once you set the image with it, @@ -271,7 +271,7 @@ Pixmap DAMakeShape(void); * Returns true on success, false on failure. */ Bool DAMakePixmapFromData(char **data, Pixmap *pixmap, Pixmap *mask, - unsigned short *width, unsigned short *height); + unsigned short *width, unsigned short *height); /* * DAMakePixmapFromFile- @@ -279,50 +279,50 @@ Bool DAMakePixmapFromData(char **data, Pixmap *pixmap, Pixmap *mask, * Returns true on success, false on failure. */ Bool DAMakePixmapFromFile(char *filename, Pixmap *pixmap, Pixmap *mask, - unsigned short *width, unsigned short *height); + unsigned short *width, unsigned short *height); /* * 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. + * 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. + * 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- - * Free memory reserved for a ShapedPixmap + * Free memory reserved for a ShapedPixmap */ void DAFreeShapedPixmap(DAShapedPixmap *dasp); /* * DASPCopyArea- - * Copies shape-mask and pixmap-data from an area in one shaped pixmap + * Copies shape-mask and pixmap-data from an area in one shaped pixmap * into another shaped pixmap. */ void DASPCopyArea(DAShapedPixmap *src, DAShapedPixmap *dst, - int x1, int y1, int w, int h, int x2, int y2); + int x1, int y1, int w, int h, int x2, int y2); /* * DASPClear- - * Clears a shaped pixmaps contents. + * Clears a shaped pixmaps contents. */ void DASPClear(DAShapedPixmap *dasp); /* DASPShow- - * Displays the pixmap in the dockapp-window. + * Displays the pixmap in the dockapp-window. */ void DASPSetPixmap(DAShapedPixmap *dasp); void DASPSetPixmapForWindow(Window window, DAShapedPixmap *dasp); @@ -343,8 +343,8 @@ void DAShow(void); /* * DAShowWindow- - * Display a window. Also displays subwindows if it is the dockapp leader - * window (DALeader). + * Display a window. Also displays subwindows if it is the dockapp leader + * window (DALeader). */ void DAShowWindow(Window window); @@ -391,13 +391,13 @@ void DAEventLoopForWindow(Window window); /* * DAProcessActionRects- - * Processes the current coordinates with one of the functions in + * Processes the current coordinates with one of the functions in * the array of action rectangles. Coordinates are converted to relative * coordinates in one of the rectangles. The last item in the array of * action rectangles must be NULL. */ void DAProcessActionRects(int x, int y, DAActionRect *actionrects, - int count, void *data); + int count, void *data); /* -- 2.1.0 -- To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.