Skip to content

Commit 06203da

Browse files
committed
build stuff
1 parent 83dbfd3 commit 06203da

File tree

8 files changed

+600
-29
lines changed

8 files changed

+600
-29
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
/cmdtree
2+
*.d
3+
*.o

LICENSE

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
MIT/X Consortium License
2+
3+
© 2006-2014 Anselm R Garbe <[email protected]>
4+
© 2006-2008 Sander van Dijk <[email protected]>
5+
© 2006-2007 Michał Janeczek <[email protected]>
6+
© 2007 Kris Maglione <[email protected]>
7+
© 2009 Gottox <[email protected]>
8+
© 2009 Markus Schnalke <[email protected]>
9+
© 2009 Evan Gates <[email protected]>
10+
© 2010-2012 Connor Lane Smith <[email protected]>
11+
© 2014-2018 Hiltjo Posthuma <[email protected]>
12+
© 2015-2018 Quentin Rameau <[email protected]>
13+
© 2018-2019 William Casarin <[email protected]>
14+
15+
Permission is hereby granted, free of charge, to any person obtaining a
16+
copy of this software and associated documentation files (the "Software"),
17+
to deal in the Software without restriction, including without limitation
18+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
19+
and/or sell copies of the Software, and to permit persons to whom the
20+
Software is furnished to do so, subject to the following conditions:
21+
22+
The above copyright notice and this permission notice shall be included in
23+
all copies or substantial portions of the Software.
24+
25+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
28+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
30+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
31+
DEALINGS IN THE SOFTWARE.

Makefile

+24-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,28 @@
11

2-
CFLAGS=-O -g -lX11 -Wall -Werror
2+
CFLAGS=-O2 -g -lX11 -Wall -Werror
3+
LDFLAGS=-lXft -lfontconfig
4+
5+
BIN=cmdtree
6+
7+
OBJS += drw.o
8+
OBJS += util.o
9+
OBJS += cmdtree.o
10+
11+
SRCS=$(OBJS:.o=.c)
12+
13+
all: $(SHLIB) $(STATICLIB) $(BIN)
14+
15+
include $(OBJS:.o=.d)
16+
17+
%.d: %.c
18+
$(CC) -MM $(CFLAGS) $< > $@
319

420
all: cmdtree
521

6-
cmdtree: cmdtree.c
7-
$(CC) $(CFLAGS) $< -o $@
22+
$(BIN): $(OBJS)
23+
$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
24+
25+
clean: fake
26+
rm -f $(OBJS) $(BIN)
27+
28+
.PHONY: fake

cmdtree.c

+16-26
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
#include <unistd.h>
1212

13+
#include "util.h"
14+
1315
static Window root, parentwin, win;
1416
static int screen;
1517
static Display *display;
@@ -20,26 +22,6 @@ static XIC xic;
2022
// config
2123
static int topbar = 1;
2224

23-
#define MAX(A, B) ((A) > (B) ? (A) : (B))
24-
25-
static void
26-
die(const char *fmt, ...) {
27-
va_list ap;
28-
29-
va_start(ap, fmt);
30-
vfprintf(stderr, fmt, ap);
31-
va_end(ap);
32-
33-
if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
34-
fputc(' ', stderr);
35-
perror(NULL);
36-
} else {
37-
fputc('\n', stderr);
38-
}
39-
40-
exit(1);
41-
}
42-
4325
static void
4426
setup()
4527
{
@@ -97,23 +79,30 @@ setup()
9779
/* drawmenu(); */
9880
}
9981

82+
static void
83+
draw_tree() {
84+
static const char *msg = "cmdtree is a tree of commands";
85+
86+
XFillRectangle(display, win, DefaultGC(display, screen),
87+
20, 20, 10, 10);
88+
89+
XDrawString(display, win, DefaultGC(display, screen), 10,
90+
50, msg, strlen(msg));
91+
}
92+
93+
10094
static void
10195
run() {
10296
XEvent e;
10397
int done = 0;
10498
char buf[32];
10599
KeySym ksym = NoSymbol;
106100
Status status;
107-
static const char *msg = "cmdtree is a tree of commands";
108101

109102
while (!done) {
110103
XNextEvent(display, &e);
111104
if (e.type == Expose) {
112-
XFillRectangle(display, win, DefaultGC(display, screen),
113-
20, 20, 10, 10);
114-
115-
XDrawString(display, win, DefaultGC(display, screen), 10,
116-
50, msg, strlen(msg));
105+
draw_tree();
117106
}
118107

119108
if (e.type == KeyPress) {
@@ -127,6 +116,7 @@ run() {
127116

128117
}
129118

119+
130120
int main(void) {
131121

132122
display = XOpenDisplay(NULL);

0 commit comments

Comments
 (0)