aewl
diff main.c @ 57:f005d46462e8
implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
author | Anselm R. Garbe <garbeam@wmii.de> |
---|---|
date | Fri, 14 Jul 2006 10:07:38 +0200 |
parents | d18f6dd0cf23 |
children | 1269bd127551 |
line diff
1.1 --- a/main.c Fri Jul 14 08:45:30 2006 +0200 1.2 +++ b/main.c Fri Jul 14 10:07:38 2006 +0200 1.3 @@ -6,6 +6,7 @@ 1.4 #include <stdarg.h> 1.5 #include <stdio.h> 1.6 #include <stdlib.h> 1.7 +#include <string.h> 1.8 1.9 #include <X11/cursorfont.h> 1.10 #include <X11/Xatom.h> 1.11 @@ -34,7 +35,8 @@ 1.12 Bool issel; 1.13 1.14 int tsel = Tdev; /* default tag */ 1.15 -int screen, sx, sy, sw, sh, mw, th; 1.16 +int screen, sx, sy, sw, sh, bx, by, bw, bh, mw; 1.17 +char stext[1024]; 1.18 1.19 DC dc = {0}; 1.20 Client *clients = NULL; 1.21 @@ -42,7 +44,7 @@ 1.22 1.23 static Bool other_wm_running; 1.24 static const char version[] = 1.25 - "dwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n"; 1.26 + "dwm-" VERSION ", (C)opyright MMVI Anselm R. Garbe\n"; 1.27 static int (*x_error_handler) (Display *, XErrorEvent *); 1.28 1.29 static void 1.30 @@ -219,12 +221,6 @@ 1.31 if(other_wm_running) 1.32 error("dwm: another window manager is already running\n"); 1.33 1.34 - sx = sy = 0; 1.35 - sw = DisplayWidth(dpy, screen); 1.36 - sh = DisplayHeight(dpy, screen); 1.37 - mw = (sw * MASTERW) / 100; 1.38 - issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask); 1.39 - 1.40 XSetErrorHandler(0); 1.41 x_error_handler = XSetErrorHandler(error_handler); 1.42 1.43 @@ -233,11 +229,9 @@ 1.44 wm_atom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False); 1.45 net_atom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False); 1.46 net_atom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); 1.47 - 1.48 XChangeProperty(dpy, root, net_atom[NetSupported], XA_ATOM, 32, 1.49 PropModeReplace, (unsigned char *) net_atom, NetLast); 1.50 1.51 - 1.52 /* init cursors */ 1.53 cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr); 1.54 cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); 1.55 @@ -251,17 +245,38 @@ 1.56 dc.border = initcolor(BORDERCOLOR); 1.57 initfont(FONT); 1.58 1.59 - th = dc.font.height + 4; 1.60 + sx = sy = 0; 1.61 + sw = DisplayWidth(dpy, screen); 1.62 + sh = DisplayHeight(dpy, screen); 1.63 + mw = (sw * MASTERW) / 100; 1.64 1.65 - dc.drawable = XCreatePixmap(dpy, root, sw, th, DefaultDepth(dpy, screen)); 1.66 - dc.gc = XCreateGC(dpy, root, 0, 0); 1.67 + wa.override_redirect = 1; 1.68 + wa.background_pixmap = ParentRelative; 1.69 + wa.event_mask = ExposureMask; 1.70 + 1.71 + bx = by = 0; 1.72 + bw = sw; 1.73 + dc.h = bh = dc.font.height + 4; 1.74 + barwin = XCreateWindow(dpy, root, bx, by, bw, bh, 0, DefaultDepth(dpy, screen), 1.75 + CopyFromParent, DefaultVisual(dpy, screen), 1.76 + CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); 1.77 + XDefineCursor(dpy, barwin, cursor[CurNormal]); 1.78 + XMapRaised(dpy, barwin); 1.79 + 1.80 + issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask); 1.81 1.82 wa.event_mask = SubstructureRedirectMask | EnterWindowMask \ 1.83 | LeaveWindowMask; 1.84 wa.cursor = cursor[CurNormal]; 1.85 + 1.86 XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa); 1.87 1.88 + dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen)); 1.89 + dc.gc = XCreateGC(dpy, root, 0, 0); 1.90 + 1.91 + strcpy(stext, "dwm-"VERSION); 1.92 scan_wins(); 1.93 + draw_bar(); 1.94 1.95 while(running) { 1.96 XNextEvent(dpy, &ev);