about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--LICENSE1
-rw-r--r--dwm.c31
2 files changed, 19 insertions, 13 deletions
diff --git a/LICENSE b/LICENSE
index 66c0f87..9138fe2 100644
--- a/LICENSE
+++ b/LICENSE
@@ -7,6 +7,7 @@ MIT/X Consortium License
 © 2007 Szabolcs Nagy <nszabolcs at gmail dot com>
 © 2007 Christof Musik <christof at sendfax dot de>
 © 2007-2008 Enno Gottox Boland <gottox at s01 dot de>
+© 2007-2008 Peter Hartlich <sgkkr at hartlich dot com>
 © 2008 Martin Hurton <martin dot hurton at gmail dot com>
 
 Permission is hereby granted, free of charge, to any person obtaining a
diff --git a/dwm.c b/dwm.c
index ec87228..fa8344a 100644
--- a/dwm.c
+++ b/dwm.c
@@ -158,6 +158,7 @@ static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
 static void grabbuttons(Client *c, Bool focused);
 static void grabkeys(void);
 static void initfont(const char *fontstr);
+static void initmodmap(void);
 static Bool isprotodel(Client *c);
 static void keypress(XEvent *e);
 static void killclient(const Arg *arg);
@@ -753,16 +754,6 @@ grabkeys(void) {
 	unsigned int i, j;
 	unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
 	KeyCode code;
-	XModifierKeymap *modmap;
-
-	/* init modifier map */
-	modmap = XGetModifierMapping(dpy);
-	for(i = 0; i < 8; i++)
-		for(j = 0; j < modmap->max_keypermod; j++) {
-			if(modmap->modifiermap[i * modmap->max_keypermod + j] == XKeysymToKeycode(dpy, XK_Num_Lock))
-				numlockmask = (1 << i);
-		}
-	XFreeModifiermap(modmap);
 
 	XUngrabKey(dpy, AnyKey, AnyModifier, root);
 	for(i = 0; i < LENGTH(keys); i++) {
@@ -813,6 +804,19 @@ initfont(const char *fontstr) {
 	dc.font.height = dc.font.ascent + dc.font.descent;
 }
 
+void
+initmodmap(void) {
+	unsigned int i, j;
+	XModifierKeymap *modmap;
+
+	modmap = XGetModifierMapping(dpy);
+	for(i = 0; i < 8; i++)
+		for(j = 0; j < modmap->max_keypermod; j++)
+			if(modmap->modifiermap[i * modmap->max_keypermod + j] == XKeysymToKeycode(dpy, XK_Num_Lock))
+				numlockmask = (1 << i);
+	XFreeModifiermap(modmap);
+}
+
 Bool
 isprotodel(Client *c) {
 	int i, n;
@@ -925,8 +929,10 @@ mappingnotify(XEvent *e) {
 	XMappingEvent *ev = &e->xmapping;
 
 	XRefreshKeyboardMapping(ev);
-	if(ev->request == MappingKeyboard)
+	if(ev->request == MappingKeyboard) {
+		initmodmap();
 		grabkeys();
+	}
 }
 
 void
@@ -1373,8 +1379,7 @@ setup(void) {
 	XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa);
 	XSelectInput(dpy, root, wa.event_mask);
 
-
-	/* grab keys */
+	initmodmap();
 	grabkeys();
 }
 
#n216'>216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386