diff options
Diffstat (limited to '')
| -rw-r--r-- | main.c | 30 |
1 files changed, 9 insertions, 21 deletions
| @@ -1,5 +1,4 @@ | |||
| 1 | /* | 1 | /* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> |
| 2 | * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> | ||
| 3 | * See LICENSE file for license details. | 2 | * See LICENSE file for license details. |
| 4 | */ | 3 | */ |
| 5 | 4 | ||
| @@ -93,12 +92,11 @@ setup(void) { | |||
| 93 | netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); | 92 | netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); |
| 94 | XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32, | 93 | XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32, |
| 95 | PropModeReplace, (unsigned char *) netatom, NetLast); | 94 | PropModeReplace, (unsigned char *) netatom, NetLast); |
| 96 | |||
| 97 | /* init cursors */ | 95 | /* init cursors */ |
| 98 | cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr); | 96 | cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr); |
| 99 | cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); | 97 | cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); |
| 100 | cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur); | 98 | cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur); |
| 101 | 99 | /* init modifier map */ | |
| 102 | modmap = XGetModifierMapping(dpy); | 100 | modmap = XGetModifierMapping(dpy); |
| 103 | for (i = 0; i < 8; i++) { | 101 | for (i = 0; i < 8; i++) { |
| 104 | for (j = 0; j < modmap->max_keypermod; j++) { | 102 | for (j = 0; j < modmap->max_keypermod; j++) { |
| @@ -107,19 +105,16 @@ setup(void) { | |||
| 107 | } | 105 | } |
| 108 | } | 106 | } |
| 109 | XFree(modmap); | 107 | XFree(modmap); |
| 110 | 108 | /* select for events */ | |
| 111 | wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask | 109 | wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask |
| 112 | | EnterWindowMask | LeaveWindowMask; | 110 | | EnterWindowMask | LeaveWindowMask; |
| 113 | wa.cursor = cursor[CurNormal]; | 111 | wa.cursor = cursor[CurNormal]; |
| 114 | XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa); | 112 | XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa); |
| 115 | |||
| 116 | grabkeys(); | 113 | grabkeys(); |
| 117 | initrregs(); | 114 | initrregs(); |
| 118 | |||
| 119 | for(ntags = 0; tags[ntags]; ntags++); | 115 | for(ntags = 0; tags[ntags]; ntags++); |
| 120 | seltag = emallocz(sizeof(Bool) * ntags); | 116 | seltag = emallocz(sizeof(Bool) * ntags); |
| 121 | seltag[0] = True; | 117 | seltag[0] = True; |
| 122 | |||
| 123 | /* style */ | 118 | /* style */ |
| 124 | dc.norm[ColBG] = getcolor(NORMBGCOLOR); | 119 | dc.norm[ColBG] = getcolor(NORMBGCOLOR); |
| 125 | dc.norm[ColFG] = getcolor(NORMFGCOLOR); | 120 | dc.norm[ColFG] = getcolor(NORMFGCOLOR); |
| @@ -128,13 +123,13 @@ setup(void) { | |||
| 128 | dc.status[ColBG] = getcolor(STATUSBGCOLOR); | 123 | dc.status[ColBG] = getcolor(STATUSBGCOLOR); |
| 129 | dc.status[ColFG] = getcolor(STATUSFGCOLOR); | 124 | dc.status[ColFG] = getcolor(STATUSFGCOLOR); |
| 130 | setfont(FONT); | 125 | setfont(FONT); |
| 131 | 126 | /* geometry */ | |
| 132 | bmw = textw(TILESYMBOL) > textw(FLOATSYMBOL) ? textw(TILESYMBOL) : textw(FLOATSYMBOL); | 127 | bmw = textw(TILESYMBOL) > textw(FLOATSYMBOL) ? textw(TILESYMBOL) : textw(FLOATSYMBOL); |
| 133 | sx = sy = 0; | 128 | sx = sy = 0; |
| 134 | sw = DisplayWidth(dpy, screen); | 129 | sw = DisplayWidth(dpy, screen); |
| 135 | sh = DisplayHeight(dpy, screen); | 130 | sh = DisplayHeight(dpy, screen); |
| 136 | master = MASTER; | 131 | master = MASTER; |
| 137 | 132 | /* bar */ | |
| 138 | bx = by = 0; | 133 | bx = by = 0; |
| 139 | bw = sw; | 134 | bw = sw; |
| 140 | dc.h = bh = dc.font.height + 2; | 135 | dc.h = bh = dc.font.height + 2; |
| @@ -146,13 +141,13 @@ setup(void) { | |||
| 146 | CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); | 141 | CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); |
| 147 | XDefineCursor(dpy, barwin, cursor[CurNormal]); | 142 | XDefineCursor(dpy, barwin, cursor[CurNormal]); |
| 148 | XMapRaised(dpy, barwin); | 143 | XMapRaised(dpy, barwin); |
| 149 | 144 | strcpy(stext, "dwm-"VERSION); | |
| 145 | /* pixmap for everything */ | ||
| 150 | dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen)); | 146 | dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen)); |
| 151 | dc.gc = XCreateGC(dpy, root, 0, 0); | 147 | dc.gc = XCreateGC(dpy, root, 0, 0); |
| 152 | XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); | 148 | XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); |
| 153 | 149 | /* multihead support */ | |
| 154 | issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask); | 150 | issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask); |
| 155 | strcpy(stext, "dwm-"VERSION); | ||
| 156 | } | 151 | } |
| 157 | 152 | ||
| 158 | /* | 153 | /* |
| @@ -204,8 +199,7 @@ quit(Arg *arg) { | |||
| 204 | readin = running = False; | 199 | readin = running = False; |
| 205 | } | 200 | } |
| 206 | 201 | ||
| 207 | /* | 202 | /* There's no way to check accesses to destroyed windows, thus those cases are |
| 208 | * There's no way to check accesses to destroyed windows, thus those cases are | ||
| 209 | * ignored (especially on UnmapNotify's). Other types of errors call Xlibs | 203 | * ignored (especially on UnmapNotify's). Other types of errors call Xlibs |
| 210 | * default error handler, which may call exit. | 204 | * default error handler, which may call exit. |
| 211 | */ | 205 | */ |
| @@ -236,21 +230,17 @@ main(int argc, char *argv[]) { | |||
| 236 | } | 230 | } |
| 237 | else if(argc != 1) | 231 | else if(argc != 1) |
| 238 | eprint("usage: dwm [-v]\n"); | 232 | eprint("usage: dwm [-v]\n"); |
| 239 | |||
| 240 | dpy = XOpenDisplay(0); | 233 | dpy = XOpenDisplay(0); |
| 241 | if(!dpy) | 234 | if(!dpy) |
| 242 | eprint("dwm: cannot open display\n"); | 235 | eprint("dwm: cannot open display\n"); |
| 243 | |||
| 244 | xfd = ConnectionNumber(dpy); | 236 | xfd = ConnectionNumber(dpy); |
| 245 | screen = DefaultScreen(dpy); | 237 | screen = DefaultScreen(dpy); |
| 246 | root = RootWindow(dpy, screen); | 238 | root = RootWindow(dpy, screen); |
| 247 | |||
| 248 | otherwm = False; | 239 | otherwm = False; |
| 249 | XSetErrorHandler(xerrorstart); | 240 | XSetErrorHandler(xerrorstart); |
| 250 | /* this causes an error if some other window manager is running */ | 241 | /* this causes an error if some other window manager is running */ |
| 251 | XSelectInput(dpy, root, SubstructureRedirectMask); | 242 | XSelectInput(dpy, root, SubstructureRedirectMask); |
| 252 | XSync(dpy, False); | 243 | XSync(dpy, False); |
| 253 | |||
| 254 | if(otherwm) | 244 | if(otherwm) |
| 255 | eprint("dwm: another window manager is already running\n"); | 245 | eprint("dwm: another window manager is already running\n"); |
| 256 | 246 | ||
| @@ -258,7 +248,6 @@ main(int argc, char *argv[]) { | |||
| 258 | XSetErrorHandler(NULL); | 248 | XSetErrorHandler(NULL); |
| 259 | xerrorxlib = XSetErrorHandler(xerror); | 249 | xerrorxlib = XSetErrorHandler(xerror); |
| 260 | XSync(dpy, False); | 250 | XSync(dpy, False); |
| 261 | |||
| 262 | setup(); | 251 | setup(); |
| 263 | drawstatus(); | 252 | drawstatus(); |
| 264 | scan(); | 253 | scan(); |
| @@ -291,6 +280,5 @@ main(int argc, char *argv[]) { | |||
| 291 | } | 280 | } |
| 292 | cleanup(); | 281 | cleanup(); |
| 293 | XCloseDisplay(dpy); | 282 | XCloseDisplay(dpy); |
| 294 | |||
| 295 | return 0; | 283 | return 0; |
| 296 | } | 284 | } |
