commit e549412
Michael Forney
·
2014-01-18 13:21:03 +0000 UTC
parent 9b3ddc4
seat: Pass name through initialize function
3 files changed,
+19,
-13
+17,
-11
1@@ -35,8 +35,6 @@
2 #include <string.h>
3 #include <libudev.h>
4
5-#define SEAT_NAME "seat0"
6-
7 static struct
8 {
9 char * name;
10@@ -235,9 +233,14 @@ static void add_devices()
11 udev_enumerate_unref(enumerate);
12 }
13
14-bool swc_seat_initialize()
15+bool swc_seat_initialize(const char * seat_name)
16 {
17- seat.name = SEAT_NAME;
18+ if (!(seat.name = strdup(seat_name)))
19+ {
20+ ERROR("Could not allocate seat name string\n");
21+ goto error0;
22+ }
23+
24 seat.capabilities = 0;
25 wl_list_init(&seat.resources);
26 wl_list_init(&seat.devices);
27@@ -246,12 +249,12 @@ bool swc_seat_initialize()
28 NULL, &bind_seat);
29
30 if (!seat.global)
31- goto error0;
32+ goto error1;
33
34 if (!swc_data_device_initialize(&seat.data_device))
35 {
36 ERROR("Could not initialize data device\n");
37- goto error1;
38+ goto error2;
39 }
40
41 wl_signal_add(&seat.data_device.event_signal, &data_device_listener);
42@@ -259,7 +262,7 @@ bool swc_seat_initialize()
43 if (!swc_keyboard_initialize(&seat.keyboard))
44 {
45 ERROR("Could not initialize keyboard\n");
46- goto error2;
47+ goto error3;
48 }
49
50 wl_signal_add(&seat.keyboard.focus.event_signal, &keyboard_focus_listener);
51@@ -267,19 +270,21 @@ bool swc_seat_initialize()
52 if (!swc_pointer_initialize(&seat.pointer))
53 {
54 ERROR("Could not initialize pointer\n");
55- goto error3;
56+ goto error4;
57 }
58
59 add_devices();
60
61 return true;
62
63- error3:
64+ error4:
65 swc_keyboard_finish(&seat.keyboard);
66- error2:
67+ error3:
68 swc_data_device_finish(&seat.data_device);
69- error1:
70+ error2:
71 wl_global_destroy(seat.global);
72+ error1:
73+ free(seat.name);
74 error0:
75 return false;
76 }
77@@ -295,6 +300,7 @@ void swc_seat_finalize()
78 swc_evdev_device_destroy(device);
79
80 wl_global_destroy(seat.global);
81+ free(seat.name);
82 }
83
84 void swc_seat_reopen_devices()
+1,
-1
1@@ -33,7 +33,7 @@ struct swc_seat_global
2 struct swc_data_device * data_device;
3 };
4
5-bool swc_seat_initialize();
6+bool swc_seat_initialize(const char * seat_name);
7 void swc_seat_finalize();
8 void swc_seat_reopen_devices();
9
+1,
-1
1@@ -130,7 +130,7 @@ bool swc_initialize(struct wl_display * display,
2 goto error5;
3 }
4
5- if (!swc_seat_initialize())
6+ if (!swc_seat_initialize(default_seat))
7 {
8 ERROR("Could not initialize seat\n");
9 goto error6;