summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile12
-rw-r--r--overdraw.c44
2 files changed, 32 insertions, 24 deletions
diff --git a/Makefile b/Makefile
index fb93f3d..b474cf4 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,16 @@
-LDLIBS = -lX11 -lcairo
-
PREFIX ?= /usr/local
BINDIR ?= /bin
+CFLAGS = -Wunused-variable -Wunused-function -Wconversion
+LDLIBS = -lX11 -lcairo
+
+ifeq ($(DEBUG),1)
+CFLAGS += -Og -g
+else
+CFLAGS += -O2
+endif
+
+
all: overdraw
clean:
diff --git a/overdraw.c b/overdraw.c
index 549a910..0df1cbf 100644
--- a/overdraw.c
+++ b/overdraw.c
@@ -27,7 +27,7 @@ struct line {
};
static struct rgb colors[3];
-static int color_index;
+static size_t color_index;
XWindowAttributes scr;
static Display *display;
@@ -41,11 +41,11 @@ static cairo_surface_t *cs;
static cairo_t *cr;
static struct line *lines;
-static int lines_cnt, lines_cap;
+static size_t lines_cnt, lines_cap;
static bool transparent;
-void
+static void
add_line(cairo_path_t *path, struct rgb *color)
{
if (lines_cnt == lines_cap) {
@@ -60,7 +60,7 @@ add_line(cairo_path_t *path, struct rgb *color)
lines_cnt++;
}
-void
+static void
draw_color_mark(void)
{
struct rgb *c;
@@ -74,21 +74,21 @@ draw_color_mark(void)
cairo_restore(cr);
}
-void
+static void
update_pixmap(void)
{
Pixmap pix;
GC gc;
- pix = XCreatePixmap(display, win,
- scr.width, scr.height, scr.depth);
+ pix = XCreatePixmap(display, win, (unsigned int) scr.width,
+ (unsigned int) scr.height, (unsigned int) scr.depth);
gc = XCreateGC(display, win, 0, 0);
XCopyArea(display, win, pix, gc, 0, 0,
- scr.width, scr.height, 0, 0);
+ (unsigned int) scr.width, (unsigned int) scr.height, 0, 0);
XSetWindowBackgroundPixmap(display, win, pix);
}
-void
+static void
draw_lines(void)
{
int i;
@@ -104,7 +104,7 @@ draw_lines(void)
cairo_restore(cr);
}
-void
+static void
grab(void)
{
Cursor cursor;
@@ -118,7 +118,7 @@ grab(void)
grabbed = true;
}
-void
+static void
ungrab(void)
{
XUngrabKeyboard(display, CurrentTime);
@@ -128,12 +128,13 @@ ungrab(void)
grabbed = false;
}
-void
+static void
redraw(void)
{
if (transparent) {
cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
- cairo_rectangle(cr, 0, 0, scr.width, scr.height);
+ cairo_rectangle(cr, 0, 0,
+ (double) scr.width, (double) scr.height);
cairo_fill(cr);
cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
} else {
@@ -145,12 +146,12 @@ redraw(void)
XFlush(display);
}
-void
+static void
keypress(XEvent ev)
{
- int keysym;
+ KeySym keysym;
- keysym = XkbKeycodeToKeysym(display, ev.xkey.keycode, 0,
+ keysym = XkbKeycodeToKeysym(display, (KeyCode) ev.xkey.keycode, 0,
ev.xkey.state & ShiftMask ? 1 : 0);
switch (keysym) {
case XK_Escape:
@@ -179,11 +180,10 @@ keypress(XEvent ev)
}
}
-void
+static void
init(void)
{
XSetWindowAttributes swa;
- XGCValues gcvals;
XVisualInfo vinfo;
Visual *visual;
int depth;
@@ -208,7 +208,8 @@ init(void)
swa.override_redirect = 1;
swa.event_mask = ExposureMask;
swa.colormap = XCreateColormap(display, root, visual, AllocNone);
- win = XCreateWindow(display, root, scr.x, scr.y, scr.width, scr.height,
+ win = XCreateWindow(display, root, scr.x, scr.y,
+ (unsigned int) scr.width, (unsigned int) scr.height,
0, depth, InputOutput, visual, CWOverrideRedirect
| CWBorderPixel | CWColormap | CWEventMask, &swa);
if (!win) err(1, "XCreateWindow");
@@ -239,10 +240,9 @@ init(void)
grab();
}
-void
+static void
update(void)
{
- int px, py, x, y;
struct rgb color;
cairo_path_t *path;
XEvent ev;
@@ -291,7 +291,7 @@ update(void)
}
}
-void
+static void
deinit(void)
{
cairo_surface_destroy(cs);