| 31 #include <unistd.h> |
31 #include <unistd.h> |
| 32 #include <pthread.h> |
32 #include <pthread.h> |
| 33 |
33 |
| 34 #include "toolkit.h" |
34 #include "toolkit.h" |
| 35 |
35 |
| |
36 #include "../common/message.h" |
| |
37 #include "../common/threadpool.h" |
| 36 |
38 |
| |
39 static const char *ui_app_name; |
| |
40 |
| |
41 static UiMessageHandler *message_handler; |
| |
42 |
| |
43 static ui_callback onstartup; |
| |
44 static void *onstartupdata; |
| |
45 |
| |
46 static UiQueue *event_queue; |
| |
47 |
| |
48 void ui_init(const char *appname, int argc, char **argv) { |
| |
49 ui_app_name = appname; |
| |
50 |
| |
51 message_handler = uic_simple_msg_handler(STDIN_FILENO, STDOUT_FILENO, ui_server_message_received); |
| |
52 } |
| |
53 |
| |
54 const char* ui_appname() { |
| |
55 return ui_app_name; |
| |
56 } |
| |
57 |
| |
58 void ui_onstartup(ui_callback f, void *userdata) { |
| |
59 onstartup = f; |
| |
60 onstartupdata = userdata; |
| |
61 } |
| |
62 |
| |
63 void ui_add_styledata(const char *styledata, int len) { |
| |
64 // NOOP |
| |
65 } |
| |
66 |
| |
67 |
| |
68 void ui_server_message_received(cxstring msg) { |
| |
69 |
| |
70 } |
| |
71 |
| |
72 void ui_main(void) { |
| |
73 event_queue = ui_queue_create(); |
| |
74 UiServerEvent *event = NULL; |
| |
75 while((event = ui_queue_get_wait(event_queue)) != NULL) { |
| |
76 if(event->callback) { |
| |
77 event->callback(&event->event, event->userdata); |
| |
78 } |
| |
79 } |
| |
80 ui_queue_free(event_queue); |
| |
81 } |