Rename to outline

pull/6/head
Martin Tournoij 6 years ago
parent dc35cfe7ca
commit 274e07fbaa
No known key found for this signature in database
GPG Key ID: A6258419189EE585

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

Loading…
Cancel
Save