From 06203da5e3a7ff6fcc7b741607a9ddee6d979d5c Mon Sep 17 00:00:00 2001 From: William Casarin Date: Sun, 8 Jul 2018 12:40:58 -0700 Subject: build stuff --- cmdtree.c | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) (limited to 'cmdtree.c') diff --git a/cmdtree.c b/cmdtree.c index e5f851b..142bbb8 100644 --- a/cmdtree.c +++ b/cmdtree.c @@ -10,6 +10,8 @@ #include +#include "util.h" + static Window root, parentwin, win; static int screen; static Display *display; @@ -20,26 +22,6 @@ static XIC xic; // config static int topbar = 1; -#define MAX(A, B) ((A) > (B) ? (A) : (B)) - -static void -die(const char *fmt, ...) { - va_list ap; - - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); - - if (fmt[0] && fmt[strlen(fmt)-1] == ':') { - fputc(' ', stderr); - perror(NULL); - } else { - fputc('\n', stderr); - } - - exit(1); -} - static void setup() { @@ -97,6 +79,18 @@ setup() /* drawmenu(); */ } +static void +draw_tree() { + static const char *msg = "cmdtree is a tree of commands"; + + XFillRectangle(display, win, DefaultGC(display, screen), + 20, 20, 10, 10); + + XDrawString(display, win, DefaultGC(display, screen), 10, + 50, msg, strlen(msg)); +} + + static void run() { XEvent e; @@ -104,16 +98,11 @@ run() { char buf[32]; KeySym ksym = NoSymbol; Status status; - static const char *msg = "cmdtree is a tree of commands"; while (!done) { XNextEvent(display, &e); if (e.type == Expose) { - XFillRectangle(display, win, DefaultGC(display, screen), - 20, 20, 10, 10); - - XDrawString(display, win, DefaultGC(display, screen), 10, - 50, msg, strlen(msg)); + draw_tree(); } if (e.type == KeyPress) { @@ -127,6 +116,7 @@ run() { } + int main(void) { display = XOpenDisplay(NULL); -- cgit v1.2.3