Do not emit two events on single command

This commit is contained in:
project-repo 2023-01-03 08:39:23 +01:00
commit 1813245e21
3 changed files with 12 additions and 10 deletions

View file

@ -630,7 +630,7 @@ set_output(struct cg_server *server, struct cg_output *output) {
}
void
keybinding_cycle_outputs(struct cg_server *server, bool reverse) {
keybinding_cycle_outputs(struct cg_server *server, bool reverse, bool trigger_event) {
struct cg_output *output = NULL;
struct cg_output *old_output = server->curr_output;
if(reverse) {
@ -648,11 +648,13 @@ keybinding_cycle_outputs(struct cg_server *server, bool reverse) {
}
}
set_output(server, output);
ipc_send_event(output->server,
"{\"event_name\":\"cycle_outputs\",\"old_output\":\"%s\","
"\"new_output\":\"%s\",\"reverse\":%d}",
old_output->wlr_output->name, output->wlr_output->name,
reverse);
if(trigger_event) {
ipc_send_event(output->server,
"{\"event_name\":\"cycle_outputs\",\"old_output\":\"%s\","
"\"new_output\":\"%s\",\"reverse\":%d}",
old_output->wlr_output->name, output->wlr_output->name,
reverse);
}
}
/* Cycle through views, whereby the workspace does not change */
@ -1211,7 +1213,7 @@ keybinding_move_view_to_cycle_output(struct cg_server *server, bool reverse) {
seat_set_focus(server->seat, NULL);
}
}
keybinding_cycle_outputs(server, reverse);
keybinding_cycle_outputs(server, reverse,false);
if(view != NULL) {
struct cg_workspace *ws =
server->curr_output
@ -1597,7 +1599,7 @@ run_action(enum keybinding_action action, struct cg_server *server,
keybinding_cycle_tiles(server, data.b);
break;
case KEYBINDING_CYCLE_OUTPUT:
keybinding_cycle_outputs(server, data.b);
keybinding_cycle_outputs(server, data.b, true);
break;
case KEYBINDING_SWITCH_WORKSPACE:
keybinding_switch_ws(server, data.u);

View file

@ -106,7 +106,7 @@ keybinding_list_push(struct keybinding_list *list,
void
keybinding_list_free(struct keybinding_list *list);
void
keybinding_cycle_outputs(struct cg_server *server, bool reverse);
keybinding_cycle_outputs(struct cg_server *server, bool reverse, bool trigger_event);
struct keybinding **
find_keybinding(const struct keybinding_list *list,
const struct keybinding *keybinding);

View file

@ -53,7 +53,7 @@ output_clear(struct cg_output *output) {
if(server->running && server->curr_output == output &&
wl_list_length(&server->outputs) > 1) {
keybinding_cycle_outputs(server, false);
keybinding_cycle_outputs(server, false, true);
}
wl_list_remove(&output->link);