Check grab_key return on start and disable it if it fails

This commit is contained in:
Michael Rosenberg 2012-09-02 16:47:37 -04:00
parent 8a3970f223
commit 8794107a63

10
dunst.c
View File

@ -133,6 +133,8 @@ static int tear_down_error_handler(void)
int grab_key(keyboard_shortcut * ks) int grab_key(keyboard_shortcut * ks)
{ {
if (!ks->is_valid)
return 1;
Window root; Window root;
root = RootWindow(dc->dpy, DefaultScreen(dc->dpy)); root = RootWindow(dc->dpy, DefaultScreen(dc->dpy));
@ -144,6 +146,7 @@ int grab_key(keyboard_shortcut * ks)
if (tear_down_error_handler()) { if (tear_down_error_handler()) {
fprintf(stderr, "Unable to grab key \"%s\"\n", ks->str); fprintf(stderr, "Unable to grab key \"%s\"\n", ks->str);
ks->is_valid = False;
return 1; return 1;
} }
return 0; return 0;
@ -1726,6 +1729,13 @@ int main(int argc, char *argv[])
init_shortcut(&close_all_ks); init_shortcut(&close_all_ks);
init_shortcut(&history_ks); init_shortcut(&history_ks);
grab_key(&close_ks);
ungrab_key(&close_ks);
grab_key(&close_all_ks);
ungrab_key(&close_all_ks);
grab_key(&history_ks);
ungrab_key(&history_ks);
geometry.mask = XParseGeometry(geom, geometry.mask = XParseGeometry(geom,
&geometry.x, &geometry.y, &geometry.x, &geometry.y,
&geometry.w, &geometry.h); &geometry.w, &geometry.h);