diff options
| author | Anselm R. Garbe <garbeam@wmii.de> | 2006-07-14 10:07:38 +0200 |
|---|---|---|
| committer | Anselm R. Garbe <garbeam@wmii.de> | 2006-07-14 10:07:38 +0200 |
| commit | 9cd686c93a80b4095d4ee0960bef320ccd9ea02c (patch) | |
| tree | 5bc29a58baac6bd0d241a3e923380efe1d7b5f8f /main.c | |
| parent | continued with man page (diff) | |
| download | dwm-9cd686c93a80b4095d4ee0960bef320ccd9ea02c.tar.gz dwm-9cd686c93a80b4095d4ee0960bef320ccd9ea02c.zip | |
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.c | 41 |
1 files changed, 28 insertions, 13 deletions
| @@ -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; | |||
| 34 | Bool issel; | 35 | Bool issel; |
| 35 | 36 | ||
| 36 | int tsel = Tdev; /* default tag */ | 37 | int tsel = Tdev; /* default tag */ |
| 37 | int screen, sx, sy, sw, sh, mw, th; | 38 | int screen, sx, sy, sw, sh, bx, by, bw, bh, mw; |
| 39 | char stext[1024]; | ||
| 38 | 40 | ||
| 39 | DC dc = {0}; | 41 | DC dc = {0}; |
| 40 | Client *clients = NULL; | 42 | Client *clients = NULL; |
| @@ -42,7 +44,7 @@ Client *sel = NULL; | |||
| 42 | 44 | ||
| 43 | static Bool other_wm_running; | 45 | static Bool other_wm_running; |
| 44 | static const char version[] = | 46 | static const char version[] = |
| 45 | "dwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n"; | 47 | "dwm-" VERSION ", (C)opyright MMVI Anselm R. Garbe\n"; |
| 46 | static int (*x_error_handler) (Display *, XErrorEvent *); | 48 | static int (*x_error_handler) (Display *, XErrorEvent *); |
| 47 | 49 | ||
| 48 | static void | 50 | static 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); |
