83 /* extern */ |
84 /* extern */ |
84 |
85 |
85 char stext[1024]; |
86 char stext[1024]; |
86 Bool *seltag; |
87 Bool *seltag; |
87 int screen, sx, sy, sw, sh, bx, by, bw, bh, mw; |
88 int screen, sx, sy, sw, sh, bx, by, bw, bh, mw; |
88 unsigned int ntags; |
89 unsigned int ntags, numlockmask; |
89 Atom wmatom[WMLast], netatom[NetLast]; |
90 Atom wmatom[WMLast], netatom[NetLast]; |
90 Bool running = True; |
91 Bool running = True; |
91 Bool issel = True; |
92 Bool issel = True; |
92 Client *clients = NULL; |
93 Client *clients = NULL; |
93 Client *sel = NULL; |
94 Client *sel = NULL; |
160 } |
161 } |
161 |
162 |
162 int |
163 int |
163 main(int argc, char *argv[]) |
164 main(int argc, char *argv[]) |
164 { |
165 { |
165 int i, xfd; |
166 int i, j, xfd; |
166 unsigned int mask; |
167 unsigned int mask; |
167 fd_set rd; |
168 fd_set rd; |
168 Bool readin = True; |
169 Bool readin = True; |
169 Window w; |
170 Window w; |
170 XEvent ev; |
171 XEvent ev; |
|
172 XModifierKeymap *modmap; |
171 XSetWindowAttributes wa; |
173 XSetWindowAttributes wa; |
172 |
174 |
173 if(argc == 2 && !strncmp("-v", argv[1], 3)) { |
175 if(argc == 2 && !strncmp("-v", argv[1], 3)) { |
174 fputs("dwm-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout); |
176 fputs("dwm-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout); |
175 exit(EXIT_SUCCESS); |
177 exit(EXIT_SUCCESS); |
209 /* init cursors */ |
211 /* init cursors */ |
210 cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr); |
212 cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr); |
211 cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); |
213 cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); |
212 cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur); |
214 cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur); |
213 |
215 |
214 wa.event_mask = SubstructureRedirectMask | EnterWindowMask | LeaveWindowMask; |
216 modmap = XGetModifierMapping(dpy); |
|
217 for (i = 0; i < 8; i++) { |
|
218 for (j = 0; j < modmap->max_keypermod; j++) { |
|
219 if(modmap->modifiermap[i * modmap->max_keypermod + j] == XKeysymToKeycode(dpy, XK_Num_Lock)) |
|
220 numlockmask = (1 << i); |
|
221 } |
|
222 } |
|
223 XFree(modmap); |
|
224 |
|
225 wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask | EnterWindowMask | LeaveWindowMask; |
215 wa.cursor = cursor[CurNormal]; |
226 wa.cursor = cursor[CurNormal]; |
216 XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa); |
227 XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa); |
217 |
228 |
218 grabkeys(); |
229 grabkeys(); |
219 initrregs(); |
230 initrregs(); |
231 sx = sy = 0; |
242 sx = sy = 0; |
232 sw = DisplayWidth(dpy, screen); |
243 sw = DisplayWidth(dpy, screen); |
233 sh = DisplayHeight(dpy, screen); |
244 sh = DisplayHeight(dpy, screen); |
234 mw = (sw * MASTERW) / 100; |
245 mw = (sw * MASTERW) / 100; |
235 |
246 |
|
247 bx = by = 0; |
|
248 bw = sw; |
|
249 dc.h = bh = dc.font.height + 4; |
236 wa.override_redirect = 1; |
250 wa.override_redirect = 1; |
237 wa.background_pixmap = ParentRelative; |
251 wa.background_pixmap = ParentRelative; |
238 wa.event_mask = ButtonPressMask | ExposureMask; |
252 wa.event_mask = ButtonPressMask | ExposureMask; |
239 |
|
240 bx = by = 0; |
|
241 bw = sw; |
|
242 dc.h = bh = dc.font.height + 4; |
|
243 barwin = XCreateWindow(dpy, root, bx, by, bw, bh, 0, DefaultDepth(dpy, screen), |
253 barwin = XCreateWindow(dpy, root, bx, by, bw, bh, 0, DefaultDepth(dpy, screen), |
244 CopyFromParent, DefaultVisual(dpy, screen), |
254 CopyFromParent, DefaultVisual(dpy, screen), |
245 CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); |
255 CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); |
246 XDefineCursor(dpy, barwin, cursor[CurNormal]); |
256 XDefineCursor(dpy, barwin, cursor[CurNormal]); |
247 XMapRaised(dpy, barwin); |
257 XMapRaised(dpy, barwin); |
276 else |
287 else |
277 strcpy(stext, "broken pipe"); |
288 strcpy(stext, "broken pipe"); |
278 drawstatus(); |
289 drawstatus(); |
279 } |
290 } |
280 if(FD_ISSET(xfd, &rd)) { |
291 if(FD_ISSET(xfd, &rd)) { |
|
292 XLoop: |
281 while(XPending(dpy)) { |
293 while(XPending(dpy)) { |
282 XNextEvent(dpy, &ev); |
294 XNextEvent(dpy, &ev); |
283 if(handler[ev.type]) |
295 if(handler[ev.type]) |
284 (handler[ev.type])(&ev); /* call handler */ |
296 (handler[ev.type])(&ev); /* call handler */ |
285 } |
297 } |