aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/action.c4
-rw-r--r--src/block.h4
-rw-r--r--src/blocks/slider.c4
-rw-r--r--src/comet.c6
-rw-r--r--src/event.c4
-rw-r--r--src/layout.c8
-rw-r--r--src/lua/api.c14
-rw-r--r--src/lua/api.h17
8 files changed, 49 insertions, 12 deletions
diff --git a/src/action.c b/src/action.c
index df6ad3a..a09d7e5 100644
--- a/src/action.c
+++ b/src/action.c
@@ -103,8 +103,8 @@ bool action_perform(action_t *action, block_t *block, config_t *config)
event_init_trigger(&event, action->label, value);
action_t *action = target->actions[EVENT_TRIGGER];
- block_event_t event_fn = target->type == BLOCK_SPEC
- ? ((block_spec_t *)target)->event_fn
+ block_event_t event_fn = target->type == BLOCK_DYNAMIC
+ ? ((block_dynamic_t *)target)->event_fn
: NULL;
log_value_debug("Block received a trigger",
diff --git a/src/block.h b/src/block.h
index 983c6b9..cda6444 100644
--- a/src/block.h
+++ b/src/block.h
@@ -23,7 +23,7 @@ typedef enum {
typedef enum {
BLOCK_TEXT,
BLOCK_GROUP,
- BLOCK_SPEC,
+ BLOCK_DYNAMIC,
} block_type_t;
typedef struct block block_t;
@@ -90,7 +90,7 @@ typedef struct {
block_layout_t layout_fn;
block_render_t render_fn;
block_event_t event_fn;
-} block_spec_t;
+} block_dynamic_t;
// Called to allocate a block with its default state
//
diff --git a/src/blocks/slider.c b/src/blocks/slider.c
index f4a9ad0..93b51d2 100644
--- a/src/blocks/slider.c
+++ b/src/blocks/slider.c
@@ -17,7 +17,7 @@ typedef enum {
} block_slider_knob_t;
typedef struct {
- block_spec_t block;
+ block_dynamic_t block;
int value;
unsigned int height;
unsigned int width;
@@ -240,7 +240,7 @@ static void block_slider_event(layout_t *layout, config_t *config, event_t event
static void block_slider_init(block_t *block)
{
- block->type = BLOCK_SPEC;
+ block->type = BLOCK_DYNAMIC;
block_slider_t *slider = (block_slider_t *)block;
slider->block.layout_fn = block_slider_layout;
slider->block.render_fn = block_slider_render;
diff --git a/src/comet.c b/src/comet.c
index dbb7139..fec831e 100644
--- a/src/comet.c
+++ b/src/comet.c
@@ -9,6 +9,7 @@
#include "event.h"
#include "config.h"
#include "block.h"
+#include "lua/api.h"
#ifdef RELEASE
#define ANY_LOG_VALUE_BEFORE(level, module, func, message) \
@@ -70,6 +71,9 @@ int main(int argc, char **argv)
any_log_init(stdout, log_level);
+ lua_api_t lua;
+ lua_api_init(&lua);
+
config_t config;
config_init(&config);
log_debug("Copied default config");
@@ -162,7 +166,9 @@ int main(int argc, char **argv)
window_close(&window);
display_close(&display);
+
config_free(&config);
+ lua_api_close(&lua);
return 0;
}
diff --git a/src/event.c b/src/event.c
index 24975bf..db00e30 100644
--- a/src/event.c
+++ b/src/event.c
@@ -86,8 +86,8 @@ static layout_t *event_dispatch_find(block_t *block, layout_t *layout)
static void event_dispatch_callback(event_state_t *state, layout_t *layout, event_t event)
{
- block_event_t event_fn = layout->block->type == BLOCK_SPEC
- ? ((block_spec_t *)layout->block)->event_fn
+ block_event_t event_fn = layout->block->type == BLOCK_DYNAMIC
+ ? ((block_dynamic_t *)layout->block)->event_fn
: NULL;
log_value_debug("Block received an event",
diff --git a/src/layout.c b/src/layout.c
index ee82f83..e45526a 100644
--- a/src/layout.c
+++ b/src/layout.c
@@ -72,9 +72,9 @@ void layout_init(layout_t *layout, block_t *block, layout_info_t info)
break;
}
- case BLOCK_SPEC: {
+ case BLOCK_DYNAMIC: {
// You are on your own
- block_spec_t *spec = (block_spec_t *)block;
+ block_dynamic_t *spec = (block_dynamic_t *)block;
spec->layout_fn(block, layout, info);
// TODO: Add more checks
@@ -155,12 +155,12 @@ void layout_render(layout_t *layout, cairo_t *cr)
break;
}
- case BLOCK_SPEC: {
+ case BLOCK_DYNAMIC: {
// NOTE: What if a special block adds children to the layout?
// For now do nothing and let them handle it, however
// this is a strange behavior in my opinion...
//
- block_spec_t *spec = (block_spec_t *)layout->block;
+ block_dynamic_t *spec = (block_dynamic_t *)layout->block;
spec->render_fn(layout, cr);
break;
}
diff --git a/src/lua/api.c b/src/lua/api.c
new file mode 100644
index 0000000..5a29cca
--- /dev/null
+++ b/src/lua/api.c
@@ -0,0 +1,14 @@
+#include "api.h"
+
+
+bool lua_api_init(lua_api_t *api)
+{
+ api->state = luaL_newstate();
+ luaL_openlibs(api->state);
+ return true;
+}
+
+void lua_api_close(lua_api_t *api)
+{
+ lua_close(api->state);
+}
diff --git a/src/lua/api.h b/src/lua/api.h
new file mode 100644
index 0000000..a134aa0
--- /dev/null
+++ b/src/lua/api.h
@@ -0,0 +1,17 @@
+#ifndef COMET_LUA_API_H
+#define COMET_LUA_API_H
+
+#include <lauxlib.h>
+#include <lua.h>
+#include <lualib.h>
+#include <stdbool.h>
+
+typedef struct {
+ lua_State *state;
+} lua_api_t;
+
+bool lua_api_init(lua_api_t *api);
+
+void lua_api_close(lua_api_t *api);
+
+#endif