diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/utils.c | 16 | ||||
-rw-r--r-- | src/utils.h | 2 | ||||
-rw-r--r-- | src/yawa.c | 40 | ||||
-rw-r--r-- | src/yawa.h | 8 |
4 files changed, 33 insertions, 33 deletions
diff --git a/src/utils.c b/src/utils.c index 19d249d..8247a2d 100644 --- a/src/utils.c +++ b/src/utils.c @@ -28,7 +28,7 @@ parse_int(char *string, char *arg) fprintf(stderr, "Valid %s not found\n", arg); exit(-2); } - return (int)val; + return (signed)val; } unsigned @@ -50,7 +50,7 @@ parse_uint(char *string, char *arg) fprintf(stderr, "Valid %s not found\n", arg); exit(-2); } - return (unsigned int)val; + return (unsigned)val; } double @@ -76,13 +76,13 @@ parse_double(char *string, char *arg) } bool -parse_color(char *hex, Color *c, int a) +parse_color(char *hex, Color *c, signed alpha) { if ((strlen(hex) != 7) && (strlen(hex) != 9)) { return false; } - int len; + signed len; if (strlen(hex) == 9) { len = 4; } else { @@ -90,8 +90,8 @@ parse_color(char *hex, Color *c, int a) } hex++; - int colors[4]; - for (int i = 0; i < len; hex += 2, i++) { + signed colors[4]; + for (signed i = 0; i < len; hex += 2, i++) { char color[3]; strlcpy(color, hex, 3); @@ -107,7 +107,7 @@ parse_color(char *hex, Color *c, int a) exit(-2); } - colors[i] = (int)val; + colors[i] = (signed)val; } c->r = colors[0]; @@ -116,7 +116,7 @@ parse_color(char *hex, Color *c, int a) if (len == 4) { c->a = colors[3]; } else { - c->a = a; + c->a = alpha; } return true; diff --git a/src/utils.h b/src/utils.h index b21c6d5..86d77ea 100644 --- a/src/utils.h +++ b/src/utils.h @@ -14,6 +14,6 @@ double parse_double(char *string, char *arg); bool -parse_color(char *arg, Color *c, int a); +parse_color(char *hex, Color *color, signed alpha); #endif @@ -34,7 +34,7 @@ // Order of parameters: KEY, ARG, STATE. static error_t -parse_opt(int key, char *arg, struct argp_state *state) +parse_opt(signed key, char *arg, struct argp_state *state) { struct arguments *arguments = state->input; @@ -151,14 +151,14 @@ static struct argp argp = {options, parse_opt, "", doc, NULL, NULL, 0}; // Globals: static Display *display; -static int screen; +static signed screen; signed set_root_atoms(Pixmap pixmap) { Atom atom_root, atom_eroot, type; unsigned char *data_root, *data_eroot; - int format; + signed format; unsigned long length, after; atom_root = XInternAtom(display, "_XROOTMAP_ID", True); @@ -199,10 +199,10 @@ set_root_atoms(Pixmap pixmap) } signed -load_image(ImageMode mode, const char *arg, int rootW, int rootH, - int alpha, Imlib_Image rootimg) +load_image(ImageMode mode, const char *arg, signed rootW, signed rootH, + signed alpha, Imlib_Image rootimg) { - int imgW, imgH, o; + signed imgW, imgH, o; Imlib_Image buffer = imlib_load_image(arg); if (!buffer) { @@ -234,19 +234,19 @@ load_image(ImageMode mode, const char *arg, int rootW, int rootH, 0, 0, rootW, rootH); } else if (mode == Full) { double aspect = ((double) rootW) / imgW; - int top, left; - if ((int) (imgH * aspect) > rootH) + signed top, left; + if ((signed) (imgH * aspect) > rootH) aspect = (double) rootH / (double) imgH; - top = (rootH - (int) (imgH * aspect)) / 2; - left = (rootW - (int) (imgW * aspect)) / 2; + top = (rootH - (signed) (imgH * aspect)) / 2; + left = (rootW - (signed) (imgW * aspect)) / 2; imlib_blend_image_onto_image(buffer, 0, 0, 0, imgW, imgH, - left, top, (int) (imgW * aspect), - (int) (imgH * aspect)); + left, top, (signed) (imgW * aspect), + (signed) (imgH * aspect)); } else { - int left = (rootW - imgW) / 2, top = (rootH - imgH) / 2; + signed left = (rootW - imgW) / 2, top = (rootH - imgH) / 2; if (mode == Tile) { - int x, y; + signed x, y; for (; left > 0; left -= imgW); for (; top > 0; top -= imgH); @@ -271,7 +271,7 @@ load_image(ImageMode mode, const char *arg, int rootW, int rootH, } signed -main(int argc, char **argv) +main(signed argc, char **argv) { struct arguments arguments = { "", "", {{0}}, "", "", 0, 0, 0, 0, 0, 0, 0, @@ -289,8 +289,8 @@ main(int argc, char **argv) Display *_display; Imlib_Context *context; Imlib_Image image; - int width, height, depth, alpha; - int i = 0; + signed width, height, depth, alpha; + signed i = 0; Pixmap pixmap; Imlib_Color_Modifier modifier = NULL; _display = XOpenDisplay(NULL); @@ -310,8 +310,8 @@ main(int argc, char **argv) pixmap = XCreatePixmap(display, RootWindow(display, screen), - (unsigned int) width, (unsigned int) height, - (unsigned int) depth); + (unsigned) width, (unsigned) height, + (unsigned) depth); imlib_context_set_visual(vis); imlib_context_set_colormap(cm); @@ -396,7 +396,7 @@ main(int argc, char **argv) if (arguments.tint) { Color c; DATA8 r[256], g[256], b[256], a[256]; - int j; + signed j; if (parse_color(arguments.tint_color, &c, 255) == 0) { fprintf(stderr, "Bad color\n"); @@ -7,7 +7,7 @@ typedef struct { - int r, g, b, a; + signed r, g, b, a; } Color; typedef enum @@ -21,13 +21,13 @@ signed set_root_atoms(Pixmap pixmap); signed -load_image(ImageMode mode, const char *arg, int rootW, int rootH, - int alpha, Imlib_Image rootimg); +load_image(ImageMode mode, const char *arg, signed rootW, signed rootH, + signed alpha, Imlib_Image rootimg); /// Argument parsing -static int num_add_colors; +static signed num_add_colors; struct arguments { char *image; char *write_file; |