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);
y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent;
x = dc.x + (h / 2);
/* shorten text if necessary */
- for(len = MIN(olen, sizeof buf); len && textnw(buf, len) > dc.w - h; len--);
+ for(len = MIN(olen, sizeof buf); len && textnw(text, len) > dc.w - h; len--);
if(!len)
return;
memcpy(buf, text, len);
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++) {
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;
XMappingEvent *ev = &e->xmapping;
XRefreshKeyboardMapping(ev);
- if(ev->request == MappingKeyboard)
+ if(ev->request == MappingKeyboard) {
+ initmodmap();
grabkeys();
+ }
}
void
None, cursor[CurResize], CurrentTime) != GrabSuccess)
return;
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
- for(;;) {
- XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask , &ev);
+ do {
+ XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
switch(ev.type) {
- case ButtonRelease:
- XWarpPointer(dpy, None, c->win, 0, 0, 0, 0,
- c->w + c->bw - 1, c->h + c->bw - 1);
- XUngrabPointer(dpy, CurrentTime);
- while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
- return;
case ConfigureRequest:
case Expose:
case MapRequest:
break;
}
}
+ while(ev.type != ButtonRelease);
+ XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
+ XUngrabPointer(dpy, CurrentTime);
+ while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
}
void
XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa);
XSelectInput(dpy, root, wa.event_mask);
-
- /* grab keys */
+ initmodmap();
grabkeys();
}
void
toggletag(const Arg *arg) {
- unsigned int mask = sel->tags ^ (arg->ui & TAGMASK);
+ unsigned int mask;
+ if (!sel)
+ return;
+
+ mask = sel->tags ^ (arg->ui & TAGMASK);
if(sel && mask) {
sel->tags = mask;
arrange();