summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorAnselm R.Garbe <arg@10ksloc.org>2006-08-14 19:18:02 +0200
committerAnselm R.Garbe <arg@10ksloc.org>2006-08-14 19:18:02 +0200
commitee31e38dc75832a66cb0fc01bcf2f419ac96a20b (patch)
tree0a5103b2dfc4f7cd68038f198ecc3ccd46984385 /main.c
parentadded Sander to LICENSE (since he has contributed/revised big portions) (diff)
downloaddwm-ee31e38dc75832a66cb0fc01bcf2f419ac96a20b.tar.gz
dwm-ee31e38dc75832a66cb0fc01bcf2f419ac96a20b.zip
removed NUMLOCKMASK, added dynamically calculated numlockmask instead
Diffstat (limited to '')
-rw-r--r--main.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/main.c b/main.c
index 2df9683..8699284 100644
--- a/main.c
+++ b/main.c
@@ -11,6 +11,7 @@
11#include <unistd.h> 11#include <unistd.h>
12#include <sys/select.h> 12#include <sys/select.h>
13#include <X11/cursorfont.h> 13#include <X11/cursorfont.h>
14#include <X11/keysym.h>
14#include <X11/Xatom.h> 15#include <X11/Xatom.h>
15#include <X11/Xproto.h> 16#include <X11/Xproto.h>
16 17
@@ -85,7 +86,7 @@ xerrorstart(Display *dsply, XErrorEvent *ee)
85char stext[1024]; 86char stext[1024];
86Bool *seltag; 87Bool *seltag;
87int screen, sx, sy, sw, sh, bx, by, bw, bh, mw; 88int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
88unsigned int ntags; 89unsigned int ntags, numlockmask;
89Atom wmatom[WMLast], netatom[NetLast]; 90Atom wmatom[WMLast], netatom[NetLast];
90Bool running = True; 91Bool running = True;
91Bool issel = True; 92Bool issel = True;
@@ -162,12 +163,13 @@ xerror(Display *dpy, XErrorEvent *ee)
162int 163int
163main(int argc, char *argv[]) 164main(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)) {
@@ -211,7 +213,16 @@ main(int argc, char *argv[])
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
@@ -233,13 +244,12 @@ main(int argc, char *argv[])
233 sh = DisplayHeight(dpy, screen); 244 sh = DisplayHeight(dpy, screen);
234 mw = (sw * MASTERW) / 100; 245 mw = (sw * MASTERW) / 100;
235 246
236 wa.override_redirect = 1;
237 wa.background_pixmap = ParentRelative;
238 wa.event_mask = ButtonPressMask | ExposureMask;
239
240 bx = by = 0; 247 bx = by = 0;
241 bw = sw; 248 bw = sw;
242 dc.h = bh = dc.font.height + 4; 249 dc.h = bh = dc.font.height + 4;
250 wa.override_redirect = 1;
251 wa.background_pixmap = ParentRelative;
252 wa.event_mask = ButtonPressMask | ExposureMask;
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);
@@ -258,6 +268,7 @@ main(int argc, char *argv[])
258 268
259 /* main event loop, also reads status text from stdin */ 269 /* main event loop, also reads status text from stdin */
260 XSync(dpy, False); 270 XSync(dpy, False);
271 goto XLoop;
261 while(running) { 272 while(running) {
262 FD_ZERO(&rd); 273 FD_ZERO(&rd);
263 if(readin) 274 if(readin)
@@ -278,6 +289,7 @@ main(int argc, char *argv[])
278 drawstatus(); 289 drawstatus();
279 } 290 }
280 if(FD_ISSET(xfd, &rd)) { 291 if(FD_ISSET(xfd, &rd)) {
292XLoop:
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])