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