commit 5c7e7e7

Michael Forney  ·  2014-07-20 22:06:04 +0000 UTC
parents 78e8dc3, c24ebec
Merge branch 'nice-exit' of git://github.com/Jezze/swc
1 files changed,  +12, -2
+12, -2
 1@@ -51,6 +51,7 @@ static const uint32_t border_color_normal = 0xff888888;
 2 
 3 static struct screen * active_screen;
 4 static struct window * focused_window;
 5+static struct wl_display * display;
 6 static struct wl_event_loop * event_loop;
 7 
 8 /* This is a basic grid arrange function that tries to give each window an
 9@@ -245,10 +246,16 @@ static void spawn(void * data, uint32_t time, uint32_t value, uint32_t state)
10     }
11 }
12 
13-int main(int argc, char * argv[])
14+static void quit(void * data, uint32_t time, uint32_t value, uint32_t state)
15 {
16-    struct wl_display * display;
17+    if (state != WL_KEYBOARD_KEY_STATE_PRESSED)
18+        return;
19 
20+    wl_display_terminate(display);
21+}
22+
23+int main(int argc, char * argv[])
24+{
25     display = wl_display_create();
26 
27     if (!display)
28@@ -264,9 +271,12 @@ int main(int argc, char * argv[])
29                     &spawn, terminal_command);
30     swc_add_binding(SWC_BINDING_KEY, SWC_MOD_LOGO, XKB_KEY_r,
31                     &spawn, dmenu_command);
32+    swc_add_binding(SWC_BINDING_KEY, SWC_MOD_LOGO, XKB_KEY_q,
33+                    &quit, NULL);
34 
35     event_loop = wl_display_get_event_loop(display);
36     wl_display_run(display);
37+    wl_display_destroy(display);
38 
39     return EXIT_SUCCESS;
40 }