mirror of
https://cagebreak.project-repo.co/cagebreak.git
synced 2026-08-22 21:44:19 +02:00
Add custom event command
This commit is contained in:
parent
8f1ef0383b
commit
443abb53b2
3 changed files with 25 additions and 0 deletions
15
keybinding.c
15
keybinding.c
|
|
@ -96,6 +96,12 @@ keybinding_free(struct keybinding *keybinding, bool recursive) {
|
|||
if(keybinding->data.c != NULL) {
|
||||
free(keybinding->data.c);
|
||||
}
|
||||
break;
|
||||
case KEYBINDING_SEND_CUSTOM_EVENT:
|
||||
if(keybinding->data.c != NULL) {
|
||||
free(keybinding->data.c);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
@ -1245,6 +1251,12 @@ keybinding_display_message(struct cg_server *server, char *msg) {
|
|||
message_printf(server->curr_output, "%s", msg);
|
||||
}
|
||||
|
||||
void
|
||||
keybinding_send_custom_event(struct cg_server *server, char *msg) {
|
||||
ipc_send_event( server,
|
||||
"{\"event_name\":\"custom_event\",\"message\":\"%s\"}", msg);
|
||||
}
|
||||
|
||||
void
|
||||
keybinding_move_view_to_cycle_output(struct cg_server *server, bool reverse) {
|
||||
if(wl_list_length(&server->outputs) <= 1) {
|
||||
|
|
@ -1706,6 +1718,9 @@ run_action(enum keybinding_action action, struct cg_server *server,
|
|||
case KEYBINDING_DISPLAY_MESSAGE:
|
||||
keybinding_display_message(server, data.c);
|
||||
break;
|
||||
case KEYBINDING_SEND_CUSTOM_EVENT:
|
||||
keybinding_send_custom_event(server, data.c);
|
||||
break;
|
||||
case KEYBINDING_RESIZE_TILE_HORIZONTAL:
|
||||
resize_tile(server, data.i, 0);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ struct cg_server;
|
|||
KEYBINDING(KEYBINDING_SHOW_TIME, time) \
|
||||
KEYBINDING(KEYBINDING_SHOW_INFO, show_info) \
|
||||
KEYBINDING(KEYBINDING_DISPLAY_MESSAGE, message) \
|
||||
KEYBINDING(KEYBINDING_SEND_CUSTOM_EVENT, custom_event) \
|
||||
KEYBINDING(KEYBINDING_CURSOR, cursor) \
|
||||
\
|
||||
KEYBINDING(KEYBINDING_SWAP_LEFT, exchangeleft) \
|
||||
|
|
|
|||
9
parse.c
9
parse.c
|
|
@ -811,6 +811,15 @@ parse_command(struct cg_server *server, struct keybinding *keybinding,
|
|||
return -1;
|
||||
}
|
||||
keybinding->data.c = strdup(saveptr);
|
||||
} else if(strcmp(action, "custom_event") == 0) {
|
||||
keybinding->action = KEYBINDING_SEND_CUSTOM_EVENT;
|
||||
if(saveptr == NULL) {
|
||||
*errstr =
|
||||
log_error("Not enough paramaters to \"custom_event\". Expected "
|
||||
"string to send.");
|
||||
return -1;
|
||||
}
|
||||
keybinding->data.c = strdup(saveptr);
|
||||
} else if(strcmp(action, "time") == 0) {
|
||||
keybinding->action = KEYBINDING_SHOW_TIME;
|
||||
} else if(strcmp(action, "nextscreen") == 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue