diff options
| author | Federico Angelilli <code@fedang.net> | 2024-11-24 16:13:20 +0100 |
|---|---|---|
| committer | Federico Angelilli <code@fedang.net> | 2024-11-24 16:13:20 +0100 |
| commit | 441c0b974d00c01fccbce4ebed61711b7b0eeec7 (patch) | |
| tree | 487af9329c0b1c1d9fa01091f460058c3dbc5198 /src/event.c | |
| parent | ab8a774df0ebc88c4b16377547366b01134b041c (diff) | |
Start performing actions
Diffstat (limited to 'src/event.c')
| -rw-r--r-- | src/event.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/event.c b/src/event.c index c2c98ab..c226bea 100644 --- a/src/event.c +++ b/src/event.c @@ -5,10 +5,11 @@ #include "layout.h" #include "event.h" #include "block.h" +#include "action.h" const char *event_type_to_string(event_type_t type) { - const char *types[] = { + const char *types[EVENT_LENGTH] = { "trigger", "left_click", "middle_click", @@ -20,7 +21,7 @@ const char *event_type_to_string(event_type_t type) "hover_stop", }; - assert(type >= EVENT_TRIGGER && type <= EVENT_HOVER_STOP); + assert(type >= EVENT_TRIGGER && type < EVENT_LENGTH); return types[type]; } @@ -62,7 +63,7 @@ static layout_t *event_dispatch_find(block_t *block, layout_t *layout) return NULL; } -static void event_dispatch_callback(layout_t *layout, event_t event) +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 @@ -77,8 +78,13 @@ static void event_dispatch_callback(layout_t *layout, event_t event) "i:y", layout->y, "i:width", layout->width, "i:height", layout->height, + "b:action", layout->block->actions != NULL, "b:callback", event_fn != NULL); + if (layout->block->actions != NULL) { + action_perform(layout->block->actions, layout->block, state->config); + } + if (event_fn != NULL) { event_fn(layout, event); log_trace("Completed event callback"); @@ -98,7 +104,7 @@ static void event_dispatch_callback_block(event_state_t *state, block_t *block, ? &tmp : event_dispatch_find(block, state->layout); - event_dispatch_callback(l, event); + event_dispatch_callback(state, l, event); } static bool event_dispatch_mouse(event_state_t *state, layout_t *layout, event_t event) @@ -140,7 +146,7 @@ static bool event_dispatch_mouse(event_state_t *state, layout_t *layout, event_t } } - event_dispatch_callback(layout, event); + event_dispatch_callback(state, layout, event); return true; } |
