Skip to content

Commit

Permalink
Fix segfault when X keyboard map does not include Num_Lock.
Browse files Browse the repository at this point in the history
Fixes #21
  • Loading branch information
LordReg committed Nov 8, 2013
1 parent 157c555 commit b2c1286
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions spectrwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -6818,9 +6818,11 @@ updatenumlockmask(void)
+ j];
keycode = xcb_key_symbols_get_keycode(syms,
XK_Num_Lock);
if (kc == *keycode)
numlockmask = (1 << i);
free(keycode);
if (keycode) {
if (kc == *keycode)
numlockmask = (1 << i);
free(keycode);
}
}
}
free(modmap_r);
Expand Down Expand Up @@ -8771,10 +8773,22 @@ mapnotify(xcb_map_notify_event_t *e)
void
mappingnotify(xcb_mapping_notify_event_t *e)
{
struct ws_win *w;
int i, j, num_screens;

xcb_refresh_keyboard_mapping(syms, e);

if (e->request == XCB_MAPPING_KEYBOARD)
if (e->request == XCB_MAPPING_KEYBOARD) {
grabkeys();

/* Regrab buttons on all managed windows. */
num_screens = get_screen_count();
for (i = 0; i < num_screens; i++)
for (j = 0; j < workspace_limit; j++)
TAILQ_FOREACH(w, &screens[i].ws[j].winlist,
entry)
grabbuttons(w);
}
}

void
Expand Down

0 comments on commit b2c1286

Please sign in to comment.