comparison event.c @ 279:2cedfbefd025

added mappingnotify event for kb refreshes
author Anselm R.Garbe <arg@10ksloc.org>
date Mon, 14 Aug 2006 16:08:52 +0200
parents c1187ddcd7f7
children 74d00f634ee2
comparison
equal deleted inserted replaced
278:c1187ddcd7f7 279:2cedfbefd025
275 drawall(); 275 drawall();
276 } 276 }
277 } 277 }
278 278
279 static void 279 static void
280 mappingnotify(XEvent *e)
281 {
282 XMappingEvent *ev = &e->xmapping;
283
284 XRefreshKeyboardMapping(ev);
285 if(ev->request == MappingKeyboard)
286 grabkeys();
287 }
288
289 static void
280 maprequest(XEvent *e) 290 maprequest(XEvent *e)
281 { 291 {
282 static XWindowAttributes wa; 292 static XWindowAttributes wa;
283 XMapRequestEvent *ev = &e->xmaprequest; 293 XMapRequestEvent *ev = &e->xmaprequest;
284 294
346 [DestroyNotify] = destroynotify, 356 [DestroyNotify] = destroynotify,
347 [EnterNotify] = enternotify, 357 [EnterNotify] = enternotify,
348 [LeaveNotify] = leavenotify, 358 [LeaveNotify] = leavenotify,
349 [Expose] = expose, 359 [Expose] = expose,
350 [KeyPress] = keypress, 360 [KeyPress] = keypress,
361 [MappingNotify] = mappingnotify,
351 [MapRequest] = maprequest, 362 [MapRequest] = maprequest,
352 [PropertyNotify] = propertynotify, 363 [PropertyNotify] = propertynotify,
353 [UnmapNotify] = unmapnotify 364 [UnmapNotify] = unmapnotify
354 }; 365 };
355 366
358 { 369 {
359 static unsigned int len = sizeof(key) / sizeof(key[0]); 370 static unsigned int len = sizeof(key) / sizeof(key[0]);
360 unsigned int i; 371 unsigned int i;
361 KeyCode code; 372 KeyCode code;
362 373
374 XUngrabKey(dpy, AnyKey, AnyModifier, root);
363 for(i = 0; i < len; i++) { 375 for(i = 0; i < len; i++) {
364 code = XKeysymToKeycode(dpy, key[i].keysym); 376 code = XKeysymToKeycode(dpy, key[i].keysym);
365 XGrabKey(dpy, code, key[i].mod, root, True, 377 XGrabKey(dpy, code, key[i].mod, root, True,
366 GrabModeAsync, GrabModeAsync); 378 GrabModeAsync, GrabModeAsync);
367 XGrabKey(dpy, code, key[i].mod | LockMask, root, True, 379 XGrabKey(dpy, code, key[i].mod | LockMask, root, True,