summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-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 @@
6#include <stdarg.h> 6#include <stdarg.h>
7#include <stdio.h> 7#include <stdio.h>
8#include <stdlib.h> 8#include <stdlib.h>
9#include <string.h>
9 10
10#include <X11/cursorfont.h> 11#include <X11/cursorfont.h>
11#include <X11/Xatom.h> 12#include <X11/Xatom.h>
@@ -34,7 +35,8 @@ Bool running = True;
34Bool issel; 35Bool issel;
35 36
36int tsel = Tdev; /* default tag */ 37int tsel = Tdev; /* default tag */
37int screen, sx, sy, sw, sh, mw, th; 38int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
39char stext[1024];
38 40
39DC dc = {0}; 41DC dc = {0};
40Client *clients = NULL; 42Client *clients = NULL;
@@ -42,7 +44,7 @@ Client *sel = NULL;
42 44
43static Bool other_wm_running; 45static Bool other_wm_running;
44static const char version[] = 46static const char version[] =
45 "dwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n"; 47 "dwm-" VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
46static int (*x_error_handler) (Display *, XErrorEvent *); 48static int (*x_error_handler) (Display *, XErrorEvent *);
47 49
48static void 50static void
@@ -219,12 +221,6 @@ main(int argc, char *argv[])
219 if(other_wm_running) 221 if(other_wm_running)
220 error("dwm: another window manager is already running\n"); 222 error("dwm: another window manager is already running\n");
221 223
222 sx = sy = 0;
223 sw = DisplayWidth(dpy, screen);
224 sh = DisplayHeight(dpy, screen);
225 mw = (sw * MASTERW) / 100;
226 issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
227
228 XSetErrorHandler(0); 224 XSetErrorHandler(0);
229 x_error_handler = XSetErrorHandler(error_handler); 225 x_error_handler = XSetErrorHandler(error_handler);
230 226
@@ -233,11 +229,9 @@ main(int argc, char *argv[])
233 wm_atom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False); 229 wm_atom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
234 net_atom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False); 230 net_atom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
235 net_atom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); 231 net_atom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
236
237 XChangeProperty(dpy, root, net_atom[NetSupported], XA_ATOM, 32, 232 XChangeProperty(dpy, root, net_atom[NetSupported], XA_ATOM, 32,
238 PropModeReplace, (unsigned char *) net_atom, NetLast); 233 PropModeReplace, (unsigned char *) net_atom, NetLast);
239 234
240
241 /* init cursors */ 235 /* init cursors */
242 cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr); 236 cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
243 cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); 237 cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
@@ -251,17 +245,38 @@ main(int argc, char *argv[])
251 dc.border = initcolor(BORDERCOLOR); 245 dc.border = initcolor(BORDERCOLOR);
252 initfont(FONT); 246 initfont(FONT);
253 247
254 th = dc.font.height + 4; 248 sx = sy = 0;
249 sw = DisplayWidth(dpy, screen);
250 sh = DisplayHeight(dpy, screen);
251 mw = (sw * MASTERW) / 100;
255 252
256 dc.drawable = XCreatePixmap(dpy, root, sw, th, DefaultDepth(dpy, screen)); 253 wa.override_redirect = 1;
257 dc.gc = XCreateGC(dpy, root, 0, 0); 254 wa.background_pixmap = ParentRelative;
255 wa.event_mask = ExposureMask;
256
257 bx = by = 0;
258 bw = sw;
259 dc.h = bh = dc.font.height + 4;
260 barwin = XCreateWindow(dpy, root, bx, by, bw, bh, 0, DefaultDepth(dpy, screen),
261 CopyFromParent, DefaultVisual(dpy, screen),
262 CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
263 XDefineCursor(dpy, barwin, cursor[CurNormal]);
264 XMapRaised(dpy, barwin);
265
266 issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
258 267
259 wa.event_mask = SubstructureRedirectMask | EnterWindowMask \ 268 wa.event_mask = SubstructureRedirectMask | EnterWindowMask \
260 | LeaveWindowMask; 269 | LeaveWindowMask;
261 wa.cursor = cursor[CurNormal]; 270 wa.cursor = cursor[CurNormal];
271
262 XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa); 272 XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
263 273
274 dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
275 dc.gc = XCreateGC(dpy, root, 0, 0);
276
277 strcpy(stext, "dwm-"VERSION);
264 scan_wins(); 278 scan_wins();
279 draw_bar();
265 280
266 while(running) { 281 while(running) {
267 XNextEvent(dpy, &ev); 282 XNextEvent(dpy, &ev);