From: Andy Spencer Date: Wed, 5 Oct 2011 03:28:51 +0000 (+0000) Subject: Support graceful shutdown X-Git-Url: http://pileus.org/git/?p=wmpus;a=commitdiff_plain;h=43cb9b7de22dac5864d73321ec974bb937a217ff Support graceful shutdown --- diff --git a/sys-x11.c b/sys-x11.c index 072216b..7222b46 100644 --- a/sys-x11.c +++ b/sys-x11.c @@ -55,6 +55,7 @@ typedef enum { } color_t; /* Global data */ +static int running; static void *cache; static Atom atoms[natoms]; static int (*xerrorxlib)(Display *, XErrorEvent *); @@ -569,10 +570,16 @@ void sys_run(win_t *root) wm_update(); // For struts /* Main loop */ - for(;;) + running = 1; + while (running) { XEvent ev; XNextEvent(root->sys->dpy, &ev); process_event(ev.type, &ev, root); } } + +void sys_exit(void) +{ + running = 0; +} diff --git a/sys.h b/sys.h index d200122..c08b595 100644 --- a/sys.h +++ b/sys.h @@ -119,3 +119,6 @@ win_t *sys_init(void); /* Starts the main loop */ void sys_run(win_t *root); + +/* Exit main loop */ +void sys_exit(void); diff --git a/wm-wmii.c b/wm-wmii.c index 06b71f6..ea63124 100644 --- a/wm-wmii.c +++ b/wm-wmii.c @@ -739,6 +739,7 @@ int wm_handle_key(win_t *win, Key_t key, mod_t mod, ptr_t ptr) #endif if (key == key_f5) return wm_update(), 1; if (key == key_f6) return print_txt(), 1; + if (key == 'q') return sys_exit(), 1; } /* Floating layer */ @@ -902,7 +903,7 @@ void wm_init(win_t *root) wm->tags = list_insert(NULL, wm->tag); Key_t keys_e[] = {key_enter, key_focus}; - Key_t keys_s[] = {'h', 'j', 'k', 'l', ' ', + Key_t keys_s[] = {'h', 'j', 'k', 'l', 'q', ' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; Key_t keys_m[] = {'h', 'j', 'k', 'l', 'd', 's', 'm', 't', ' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',