|
|
|
@ -25,7 +25,7 @@ int parse_num(int ch, char *opt, char *name);
|
|
|
|
|
void draw(
|
|
|
|
|
char *name,
|
|
|
|
|
int size, int distance, int wait, int line_width, char *color_name,
|
|
|
|
|
int follow, int transparent, int grow);
|
|
|
|
|
int follow, int transparent, int grow, int outline);
|
|
|
|
|
|
|
|
|
|
static struct option longopts[] = {
|
|
|
|
|
{"help", no_argument, NULL, 'h'},
|
|
|
|
@ -37,6 +37,7 @@ static struct option longopts[] = {
|
|
|
|
|
{"follow", no_argument, NULL, 'f'},
|
|
|
|
|
{"transparent", no_argument, NULL, 't'},
|
|
|
|
|
{"grow", no_argument, NULL, 'g'},
|
|
|
|
|
{"outline", no_argument, NULL, 'o'},
|
|
|
|
|
{NULL, 0, NULL, 0}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -59,6 +60,8 @@ void usage(char *name) {
|
|
|
|
|
printf(" some display issues when following the cursor position,\n");
|
|
|
|
|
printf(" but it doesn't work well with all WMs, which is why\n");
|
|
|
|
|
printf(" it's disabled by default.\n");
|
|
|
|
|
printf(" -o, --outline Draw an outline in the opposite color as well. Helps\n");
|
|
|
|
|
printf(" visibility on all backgrounds.\n");
|
|
|
|
|
printf("\n");
|
|
|
|
|
printf("Examples:\n");
|
|
|
|
|
printf(" The defaults:\n");
|
|
|
|
@ -91,9 +94,10 @@ int main(int argc, char* argv[]) {
|
|
|
|
|
int follow = 0;
|
|
|
|
|
int transparent = 0;
|
|
|
|
|
int grow = 0;
|
|
|
|
|
int outline = 0;
|
|
|
|
|
|
|
|
|
|
int ch;
|
|
|
|
|
while ((ch = getopt_long(argc, argv, "hs:d:w:l:c:r:ftg", longopts, NULL)) != -1)
|
|
|
|
|
while ((ch = getopt_long(argc, argv, "hs:d:w:l:c:r:ftgo", longopts, NULL)) != -1)
|
|
|
|
|
switch (ch) {
|
|
|
|
|
case 's':
|
|
|
|
|
size = parse_num(ch, optarg, argv[0]);
|
|
|
|
@ -122,6 +126,9 @@ int main(int argc, char* argv[]) {
|
|
|
|
|
case 'g':
|
|
|
|
|
grow = 1;
|
|
|
|
|
break;
|
|
|
|
|
case 'o':
|
|
|
|
|
outline = 1;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
usage(argv[0]);
|
|
|
|
|
exit(1);
|
|
|
|
@ -131,13 +138,13 @@ int main(int argc, char* argv[]) {
|
|
|
|
|
|
|
|
|
|
draw(argv[0],
|
|
|
|
|
size, distance, wait, line_width, color_name,
|
|
|
|
|
follow, transparent, grow);
|
|
|
|
|
follow, transparent, grow, outline);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void draw(
|
|
|
|
|
char *name,
|
|
|
|
|
int size, int distance, int wait, int line_width, char *color_name,
|
|
|
|
|
int follow, int transparent, int grow
|
|
|
|
|
int follow, int transparent, int grow, int outline
|
|
|
|
|
) {
|
|
|
|
|
// Setup display and such
|
|
|
|
|
char *display_name = getenv("DISPLAY");
|
|
|
|
@ -260,8 +267,21 @@ void draw(
|
|
|
|
|
Colormap colormap = DefaultColormap(display, screen);
|
|
|
|
|
XColor color;
|
|
|
|
|
XAllocNamedColor(display, colormap, color_name, &color, &color);
|
|
|
|
|
XSetForeground(display, gc, color.pixel);
|
|
|
|
|
XSetLineAttributes(display, gc, line_width, LineSolid, CapButt, JoinBevel);
|
|
|
|
|
|
|
|
|
|
XColor color2;
|
|
|
|
|
char color2_name[14]; // hash + 3x4-digit hex
|
|
|
|
|
if (outline) {
|
|
|
|
|
// Insert and convert to XColor.
|
|
|
|
|
color2.red = 65535 - color.red;
|
|
|
|
|
color2.green = 65535 - color.green;
|
|
|
|
|
color2.blue = 65535 - color.blue;
|
|
|
|
|
sprintf(color2_name,"#%04X%04X%04X", color2.red,color2.green, color2.blue);
|
|
|
|
|
XAllocNamedColor(display, colormap, color2_name, &color2, &color2);
|
|
|
|
|
} else {
|
|
|
|
|
// Set colour only once if not outline.
|
|
|
|
|
XSetLineAttributes(display, gc, line_width, LineSolid, CapButt, JoinBevel);
|
|
|
|
|
XSetForeground(display, gc, color.pixel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Draw the circles
|
|
|
|
|
int i = 1;
|
|
|
|
@ -276,6 +296,19 @@ void draw(
|
|
|
|
|
else
|
|
|
|
|
cs = size - i;
|
|
|
|
|
|
|
|
|
|
if (outline) {
|
|
|
|
|
XSetLineAttributes(display, gc, line_width+2, LineSolid, CapButt, JoinBevel);
|
|
|
|
|
XSetForeground(display, gc, color2.pixel);
|
|
|
|
|
XDrawArc(display, window, gc,
|
|
|
|
|
size/2 - cs/2, size/2 - cs/2, // x, y position
|
|
|
|
|
cs, cs, // Size
|
|
|
|
|
0, 360 * 64); // Make it a full circle
|
|
|
|
|
|
|
|
|
|
// Set color back for the normal circle.
|
|
|
|
|
XSetLineAttributes(display, gc, line_width, LineSolid, CapButt, JoinBevel);
|
|
|
|
|
XSetForeground(display, gc, color.pixel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XDrawArc(display, window, gc,
|
|
|
|
|
size/2 - cs/2, size/2 - cs/2, // x, y position
|
|
|
|
|
cs, cs, // Size
|
|
|
|
|