Skip to content

Commit

Permalink
set term signal to close client, add todos for later
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <[email protected]>
  • Loading branch information
falkTX committed May 8, 2024
1 parent a308604 commit 1a633c5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
13 changes: 13 additions & 0 deletions src/ui-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "ui-base.h"

#include <dlfcn.h>
// TODO use C11 threads
#include <pthread.h>

#include <gtk/gtk.h>
Expand Down Expand Up @@ -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)) &&
Expand Down Expand Up @@ -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))
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/ui-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

// ----------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -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);

// ----------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -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)) &&
Expand Down

0 comments on commit 1a633c5

Please sign in to comment.