aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/view.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-09-23 08:38:15 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-09-23 08:39:11 +1000
commitcb66bbea42adeabd7bd87132a66589e14a46940f (patch)
tree43f409e1619b2deded320f0af7064e73e3969d30 /sway/tree/view.c
parentMerge pull request #2677 from ggreer/pretty-fonts (diff)
downloadsway-cb66bbea42adeabd7bd87132a66589e14a46940f.tar.gz
sway-cb66bbea42adeabd7bd87132a66589e14a46940f.tar.zst
sway-cb66bbea42adeabd7bd87132a66589e14a46940f.zip
Allow running commands on containers without focusing them
This adds a `con` argument to `execute_command` which allows you to specify the container to execute the command on. In most cases it leaves it as `NULL` which makes it use the focused node. We only set it when executing `for_window` criteria such as when a view maps. This means we don't send unnecessary IPC focus events, and fixes a crash when the criteria command is `move scratchpad` (because we can't give focus to a hidden scratchpad container). Each of the shell map handlers now check to see if the view has a workspace. It won't have a workspace if criteria has moved it to the scratchpad.
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r--sway/tree/view.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c
index f61f5c84..e370443c 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -391,8 +391,6 @@ static bool view_has_executed_criteria(struct sway_view *view,
391} 391}
392 392
393void view_execute_criteria(struct sway_view *view) { 393void view_execute_criteria(struct sway_view *view) {
394 struct sway_seat *seat = input_manager_current_seat(input_manager);
395 struct sway_node *prior_focus = seat_get_focus(seat);
396 list_t *criterias = criteria_for_view(view, CT_COMMAND); 394 list_t *criterias = criteria_for_view(view, CT_COMMAND);
397 for (int i = 0; i < criterias->length; i++) { 395 for (int i = 0; i < criterias->length; i++) {
398 struct criteria *criteria = criterias->items[i]; 396 struct criteria *criteria = criterias->items[i];
@@ -403,16 +401,12 @@ void view_execute_criteria(struct sway_view *view) {
403 } 401 }
404 wlr_log(WLR_DEBUG, "for_window '%s' matches view %p, cmd: '%s'", 402 wlr_log(WLR_DEBUG, "for_window '%s' matches view %p, cmd: '%s'",
405 criteria->raw, view, criteria->cmdlist); 403 criteria->raw, view, criteria->cmdlist);
406 seat_set_focus_container(seat, view->container);
407 list_add(view->executed_criteria, criteria); 404 list_add(view->executed_criteria, criteria);
408 struct cmd_results *res = execute_command(criteria->cmdlist, NULL); 405 struct cmd_results *res = execute_command(
409 if (res->status != CMD_SUCCESS) { 406 criteria->cmdlist, NULL, view->container);
410 wlr_log(WLR_ERROR, "Command '%s' failed: %s", res->input, res->error);
411 }
412 free_cmd_results(res); 407 free_cmd_results(res);
413 } 408 }
414 list_free(criterias); 409 list_free(criterias);
415 seat_set_focus(seat, prior_focus);
416} 410}
417 411
418static struct sway_workspace *select_workspace(struct sway_view *view) { 412static struct sway_workspace *select_workspace(struct sway_view *view) {