From 73693711df12a8c4684c01aa250b190f5dc69dec Mon Sep 17 00:00:00 2001 From: Kubat <mael.martin31@gmail.com> Date: Tue, 12 May 2020 11:23:54 +0200 Subject: [PATCH] Copy correct values at init time... --- inc/lektor/module/module_sdl2.h | 2 +- inc/lektor/module/module_x11.h | 2 +- inc/lektor/window.h | 1 - src/main/server.c | 4 ++++ src/module/module_sdl2.c | 12 ++++++++++-- src/module/module_x11.c | 7 ++++++- 6 files changed, 22 insertions(+), 6 deletions(-) diff --git a/inc/lektor/module/module_sdl2.h b/inc/lektor/module/module_sdl2.h index d44e74ab..341bf644 100644 --- a/inc/lektor/module/module_sdl2.h +++ b/inc/lektor/module/module_sdl2.h @@ -5,7 +5,7 @@ #include <lektor/window.h> /* The only function with a setted filename */ -int module_set_function(void *mod, struct lkt_state *srv, void *handle); +int load_sdl2(void *mod, struct lkt_state *srv, void *handle); /* Below there are needed functions for a window module. * Names are not fixed but they follow a convention (to get a code easy diff --git a/inc/lektor/module/module_x11.h b/inc/lektor/module/module_x11.h index b173c0fb..b6dc05df 100644 --- a/inc/lektor/module/module_x11.h +++ b/inc/lektor/module/module_x11.h @@ -5,7 +5,7 @@ #include <lektor/window.h> /* The only function with a setted filename */ -int module_set_function(void *mod, struct lkt_state *srv, void *handle); +int load_x11(void *mod, struct lkt_state *srv, void *handle); /* Below there are needed functions for a window module. * Names are not fixed but they follow a convention (to get a code easy diff --git a/inc/lektor/window.h b/inc/lektor/window.h index 5c290745..05acc729 100644 --- a/inc/lektor/window.h +++ b/inc/lektor/window.h @@ -21,7 +21,6 @@ struct lkt_win { bool (*new)(struct lkt_win *win); /* Create a window or only the mpv context */ void (*close)(struct lkt_win *win); /* Close the mpv context, not the window */ void (*free)(struct lkt_win *win); /* Entirelly liberate all the resources */ - void (*attach)(struct lkt_win *win, void *server); /* Get properties from the struct lkt_state */ /* Playback control */ bool (*toggle_pause)(struct lkt_win *win); diff --git a/src/main/server.c b/src/main/server.c index 316d4cca..12cca8a7 100644 --- a/src/main/server.c +++ b/src/main/server.c @@ -20,6 +20,10 @@ REG_BEGIN(server_reg) REG_ADD(load_repo_https) +#ifdef __STATIC_SDL2 +#include <lektor/module/module_sdl2.h> +REG_ADD(module_sdl2_new) +#endif REG_END() static void diff --git a/src/module/module_sdl2.c b/src/module/module_sdl2.c index 1f1001ad..5e0f0a0e 100644 --- a/src/module/module_sdl2.c +++ b/src/module/module_sdl2.c @@ -271,12 +271,17 @@ module_set_function(void *arg__, struct lkt_state *srv, void *handle__) win->get_duration = module_sdl2_get_duration; win->get_elapsed = module_sdl2_get_elapsed; win->handle_events = module_sdl2_handle_events; - win->attach = module_sdl2_attach; win->handle = handle__; return !module_sdl2_new(&srv->win); } +int +load_sdl2(void *arg, struct lkt_state *srv, void *handle) +{ + return module_set_function(arg, srv, handle); +} + bool module_sdl2_new(struct lkt_win *const win) { @@ -289,7 +294,10 @@ module_sdl2_new(struct lkt_win *const win) /* Yeah, this is how it is done. */ mthread_mutex_t mtx = MTHREAD_MUTEX_INITIALIZER; - ((struct module_sdl2_window *) win->window)->mtx = mtx; + struct module_sdl2_window *sdl2 = win->window; + sdl2->mtx = mtx; + sdl2->db = win->srv->db; + sdl2->mpd_idle_events = &win->srv->mpd_idle_events; /* Start the SDL thread */ struct poller_thread_arg *arg = calloc(1, sizeof(struct poller_thread_arg)); diff --git a/src/module/module_x11.c b/src/module/module_x11.c index d0fc16d5..d901ec8d 100644 --- a/src/module/module_x11.c +++ b/src/module/module_x11.c @@ -58,12 +58,17 @@ module_set_function(void *arg__, struct lkt_state *srv, void *handle__) win->get_duration = module_x11_get_duration; win->get_elapsed = module_x11_get_elapsed; win->handle_events = module_x11_handle_events; - win->attach = module_x11_attach; win->handle = handle__; return !module_x11_new(&srv->win); } +int +load_x11(void *arg, struct lkt_state *srv, void *handle) +{ + return module_set_function(arg, srv, handle); +} + /* * * NOW: PRIVATE X11 FUNCTIONS :NOW -- GitLab