about summary refs log tree commit diff stats
path: root/main.c
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@wmii.de>2006-07-14 10:07:38 +0200
committerAnselm R. Garbe <garbeam@wmii.de>2006-07-14 10:07:38 +0200
commit9cd686c93a80b4095d4ee0960bef320ccd9ea02c (patch)
tree5bc29a58baac6bd0d241a3e923380efe1d7b5f8f /main.c
parent1549faf3b93f77aee08e7aad12c75f6b6ca4c058 (diff)
downloaddwm-9cd686c93a80b4095d4ee0960bef320ccd9ea02c.tar.gz
implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Diffstat (limited to 'main.c')
-rw-r--r--main.c41
1 files changed, 28 insertions, 13 deletions
diff --git a/main.c b/main.c
index 7b150f6..99e9f49 100644
--- a/main.c
+++ b/main.c
@@ -6,6 +6,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include <X11/cursorfont.h>
 #include <X11/Xatom.h>
@@ -34,7 +35,8 @@ Bool running = True;
 Bool issel;
 
 int tsel = Tdev; /* default tag */
-int screen, sx, sy, sw, sh, mw, th;
+int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
+char stext[1024];
 
 DC dc = {0};
 Client *clients = NULL;
@@ -42,7 +44,7 @@ Client *sel = NULL;
 
 static Bool other_wm_running;
 static const char version[] =
-	"dwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
+	"dwm-" VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
 static int (*x_error_handler) (Display *, XErrorEvent *);
 
 static void
@@ -219,12 +221,6 @@ main(int argc, char *argv[])
 	if(other_wm_running)
 		error("dwm: another window manager is already running\n");
 
-	sx = sy = 0;
-	sw = DisplayWidth(dpy, screen);
-	sh = DisplayHeight(dpy, screen);
-	mw = (sw * MASTERW) / 100;
-	issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
-
 	XSetErrorHandler(0);
 	x_error_handler = XSetErrorHandler(error_handler);
 
@@ -233,11 +229,9 @@ main(int argc, char *argv[])
 	wm_atom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
 	net_atom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
 	net_atom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
-
 	XChangeProperty(dpy, root, net_atom[NetSupported], XA_ATOM, 32,
 			PropModeReplace, (unsigned char *) net_atom, NetLast);
 
-
 	/* init cursors */
 	cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
 	cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
@@ -251,17 +245,38 @@ main(int argc, char *argv[])
 	dc.border = initcolor(BORDERCOLOR);
 	initfont(FONT);
 
-	th = dc.font.height + 4;
+	sx = sy = 0;
+	sw = DisplayWidth(dpy, screen);
+	sh = DisplayHeight(dpy, screen);
+	mw = (sw * MASTERW) / 100;
 
-	dc.drawable = XCreatePixmap(dpy, root, sw, th, DefaultDepth(dpy, screen));
-	dc.gc = XCreateGC(dpy, root, 0, 0);
+	wa.override_redirect = 1;
+	wa.background_pixmap = ParentRelative;
+	wa.event_mask = ExposureMask;
+
+	bx = by = 0;
+	bw = sw;
+	dc.h = bh = dc.font.height + 4;
+	barwin = XCreateWindow(dpy, root, bx, by, bw, bh, 0, DefaultDepth(dpy, screen),
+			CopyFromParent, DefaultVisual(dpy, screen),
+			CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
+	XDefineCursor(dpy, barwin, cursor[CurNormal]);
+	XMapRaised(dpy, barwin);
+
+	issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
 
 	wa.event_mask = SubstructureRedirectMask | EnterWindowMask \
 					| LeaveWindowMask;
 	wa.cursor = cursor[CurNormal];
+
 	XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
 
+	dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
+	dc.gc = XCreateGC(dpy, root, 0, 0);
+
+	strcpy(stext, "dwm-"VERSION);
 	scan_wins();
+	draw_bar();
 
 	while(running) {
 		XNextEvent(dpy, &ev);
+0100 committer Silvino Silva <silvino@bk.ru> 2016-09-20 20:41:53 +0100 initial r-0.2.1' href='/punk/doc/commit/tools/tar.html?id=e4b9fd6157b8b5eedf67006719a0ef5f1ac0027e'>e4b9fd6 ^
94e429f ^






e4b9fd6 ^

94e429f ^
e2fd026 ^
94e429f ^
183caad ^
94e429f ^


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130