commit eab1c18
Michael Forney
·
2013-06-14 10:36:34 +0000 UTC
parent cdc1730
Handle VT switching and quitting
1 files changed,
+29,
-6
+29,
-6
1@@ -169,6 +169,22 @@ static void destroy_surface(struct wl_resource * resource)
2 free(surface);
3 }
4
5+static void handle_terminate(uint32_t time, uint32_t value, void * data)
6+{
7+ struct wl_display * display = data;
8+ printf("handling terminate\n");
9+ wl_display_terminate(display);
10+}
11+
12+static void handle_switch_vt(uint32_t time, uint32_t value, void * data)
13+{
14+ struct swc_tty * tty = data;
15+ uint8_t vt = value - XKB_KEY_XF86Switch_VT_1 + 1;
16+ printf("handle switch vt%u\n", vt);
17+ if (vt != tty->vt)
18+ swc_tty_switch_vt(tty, vt);
19+}
20+
21 static void create_surface(struct wl_client * client,
22 struct wl_resource * resource, uint32_t id)
23 {
24@@ -244,12 +260,7 @@ bool swc_compositor_initialize(struct swc_compositor * compositor,
25 struct wl_event_loop * event_loop;
26 struct udev_device * drm_device;
27 struct wl_list * outputs;
28-
29- if (compositor == NULL)
30- {
31- printf("could not allocate compositor\n");
32- return NULL;
33- }
34+ xkb_keysym_t keysym;
35
36 compositor->display = display;
37 compositor->tty_listener.notify = &handle_tty_event;
38@@ -338,6 +349,18 @@ bool swc_compositor_initialize(struct swc_compositor * compositor,
39 wl_array_init(&compositor->key_bindings);
40 wl_signal_init(&compositor->destroy_signal);
41
42+ swc_compositor_add_key_binding(compositor,
43+ SWC_MOD_CTRL | SWC_MOD_ALT, XKB_KEY_BackSpace, &handle_terminate, display);
44+
45+ for (keysym = XKB_KEY_XF86Switch_VT_1;
46+ keysym <= XKB_KEY_XF86Switch_VT_12;
47+ ++keysym)
48+ {
49+ swc_compositor_add_key_binding(compositor, SWC_MOD_ANY, keysym,
50+ &handle_switch_vt, &compositor->tty);
51+ }
52+
53+
54 return true;
55
56 error_renderer: