From 1a633c55ad0432be80a19d4dd071e97d893185d6 Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 8 May 2024 10:28:38 +0200 Subject: [PATCH] set term signal to close client, add todos for later Signed-off-by: falkTX --- src/ui-client.c | 13 +++++++++++++ src/ui-server.c | 6 +++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/ui-client.c b/src/ui-client.c index 9933994..3819618 100644 --- a/src/ui-client.c +++ b/src/ui-client.c @@ -4,6 +4,7 @@ #include "ui-base.h" #include +// TODO use C11 threads #include #include @@ -210,6 +211,7 @@ static int lv2ui_idle(void* const ptr) if (ipc_client_read(bridge->ipc, &msg_type, sizeof(uint32_t))) { uint32_t port_index, buffer_size, format; + // TODO use switch case if (msg_type == lv2ui_message_port_event && ipc_client_read(bridge->ipc, &port_index, sizeof(uint32_t)) && ipc_client_read(bridge->ipc, &buffer_size, sizeof(uint32_t)) && @@ -316,6 +318,11 @@ static void* lv2ui_thread_run(void* const ptr) return NULL; } +static void signal_handler(int) +{ + gtk_main_quit(); +} + int main(int argc, char* argv[]) { if (! gtk_init_check(&argc, &argv)) @@ -330,6 +337,12 @@ int main(int argc, char* argv[]) return 1; } + struct sigaction sig = { 0 }; + sig.sa_handler = signal_handler; + sig.sa_flags = SA_RESTART; + sigemptyset(&sig.sa_mask); + sigaction(SIGTERM, &sig, NULL); + const char* const uri = argv[1]; const char* const shm = argc == 4 ? argv[2] : NULL; const char* const wid = argc == 4 ? argv[3] : NULL; diff --git a/src/ui-server.c b/src/ui-server.c index 9882f43..8cdf6e1 100644 --- a/src/ui-server.c +++ b/src/ui-server.c @@ -24,7 +24,6 @@ static LV2UI_Handle lv2ui_instantiate(const LV2UI_Descriptor* const descriptor, LV2UI_Widget* const widget, const LV2_Feature* const* const features) { - // TODO idle feature // TODO log feature // ---------------------------------------------------------------------------------------------------------------- @@ -107,6 +106,7 @@ static LV2UI_Handle lv2ui_instantiate(const LV2UI_Descriptor* const descriptor, // convert parent window id into a string char wid[24] = { 0 }; + // FIXME hexa snprintf(wid, sizeof(wid) - 1, "%llu", (unsigned long long)parent); // ---------------------------------------------------------------------------------------------------------------- @@ -215,10 +215,10 @@ static int lv2ui_idle(const LV2UI_Handle ui) while (ipc_server_read_size(bridge->ipc) != 0) { uint32_t msg_type = lv2ui_message_null; - uint32_t port_index, buffer_size, port_protocol; - if (ipc_server_read(bridge->ipc, &msg_type, sizeof(uint32_t))) { + uint32_t port_index, buffer_size, port_protocol; + // TODO use switch case if (msg_type == lv2ui_message_port_event && ipc_server_read(bridge->ipc, &port_index, sizeof(uint32_t)) && ipc_server_read(bridge->ipc, &buffer_size, sizeof(uint32_t)) &&