diff options
Diffstat (limited to 'sway/commands')
-rw-r--r-- | sway/commands/border.c | 60 | ||||
-rw-r--r-- | sway/commands/client.c | 4 | ||||
-rw-r--r-- | sway/commands/focus.c | 109 | ||||
-rw-r--r-- | sway/commands/mark.c | 19 | ||||
-rw-r--r-- | sway/commands/move.c | 76 | ||||
-rw-r--r-- | sway/commands/reload.c | 4 | ||||
-rw-r--r-- | sway/commands/show_marks.c | 4 | ||||
-rw-r--r-- | sway/commands/swap.c | 4 | ||||
-rw-r--r-- | sway/commands/unmark.c | 41 |
9 files changed, 160 insertions, 161 deletions
diff --git a/sway/commands/border.c b/sway/commands/border.c index 37047812..b6eab550 100644 --- a/sway/commands/border.c +++ b/sway/commands/border.c @@ -12,37 +12,41 @@ // in use (we set using_csd instead and render a sway border). // - view->saved_border should be the last applied border when switching to CSD. // - view->using_csd should always reflect whether CSD is applied or not. -static void set_border(struct sway_view *view, +static void set_border(struct sway_container *con, enum sway_container_border new_border) { - if (view->using_csd && new_border != B_CSD) { - view_set_csd_from_server(view, false); - } else if (!view->using_csd && new_border == B_CSD) { - view_set_csd_from_server(view, true); - view->saved_border = view->border; + if (con->view) { + if (con->view->using_csd && new_border != B_CSD) { + view_set_csd_from_server(con->view, false); + } else if (!con->view->using_csd && new_border == B_CSD) { + view_set_csd_from_server(con->view, true); + con->saved_border = con->border; + } + } + if (new_border != B_CSD || container_is_floating(con)) { + con->border = new_border; } - if (new_border != B_CSD || container_is_floating(view->container)) { - view->border = new_border; + if (con->view) { + con->view->using_csd = new_border == B_CSD; } - view->using_csd = new_border == B_CSD; } -static void border_toggle(struct sway_view *view) { - if (view->using_csd) { - set_border(view, B_NONE); +static void border_toggle(struct sway_container *con) { + if (con->view && con->view->using_csd) { + set_border(con, B_NONE); return; } - switch (view->border) { + switch (con->border) { case B_NONE: - set_border(view, B_PIXEL); + set_border(con, B_PIXEL); break; case B_PIXEL: - set_border(view, B_NORMAL); + set_border(con, B_NORMAL); break; case B_NORMAL: - if (view->xdg_decoration) { - set_border(view, B_CSD); + if (con->view && con->view->xdg_decoration) { + set_border(con, B_CSD); } else { - set_border(view, B_NONE); + set_border(con, B_NONE); } break; case B_CSD: @@ -66,33 +70,33 @@ struct cmd_results *cmd_border(int argc, char **argv) { struct sway_view *view = container->view; if (strcmp(argv[0], "none") == 0) { - set_border(view, B_NONE); + set_border(container, B_NONE); } else if (strcmp(argv[0], "normal") == 0) { - set_border(view, B_NORMAL); + set_border(container, B_NORMAL); } else if (strcmp(argv[0], "pixel") == 0) { - set_border(view, B_PIXEL); + set_border(container, B_PIXEL); } else if (strcmp(argv[0], "csd") == 0) { - if (!view->xdg_decoration) { + if (!view || !view->xdg_decoration) { return cmd_results_new(CMD_INVALID, "border", "This window doesn't support client side decorations"); } - set_border(view, B_CSD); + set_border(container, B_CSD); } else if (strcmp(argv[0], "toggle") == 0) { - border_toggle(view); + border_toggle(container); } else { return cmd_results_new(CMD_INVALID, "border", "Expected 'border <none|normal|pixel|csd|toggle>' " "or 'border pixel <px>'"); } if (argc == 2) { - view->border_thickness = atoi(argv[1]); + container->border_thickness = atoi(argv[1]); } - if (container_is_floating(view->container)) { - container_set_geometry_from_floating_view(view->container); + if (container_is_floating(container)) { + container_set_geometry_from_floating_view(container); } - arrange_container(view->container); + arrange_container(container); return cmd_results_new(CMD_SUCCESS, NULL, NULL); } diff --git a/sway/commands/client.c b/sway/commands/client.c index 9f54fa94..746e8713 100644 --- a/sway/commands/client.c +++ b/sway/commands/client.c @@ -5,9 +5,7 @@ #include "sway/tree/container.h" static void rebuild_textures_iterator(struct sway_container *con, void *data) { - if (con->view) { - view_update_marks_textures(con->view); - } + container_update_marks_textures(con); container_update_title_textures(con); } diff --git a/sway/commands/focus.c b/sway/commands/focus.c index 2204f722..cef92144 100644 --- a/sway/commands/focus.c +++ b/sway/commands/focus.c @@ -1,4 +1,5 @@ #include <strings.h> +#include <wlr/types/wlr_output_layout.h> #include <wlr/util/log.h> #include "log.h" #include "sway/commands.h" @@ -13,20 +14,16 @@ #include "stringop.h" #include "util.h" -static bool parse_movement_direction(const char *name, - enum movement_direction *out) { +static bool parse_direction(const char *name, + enum wlr_direction *out) { if (strcasecmp(name, "left") == 0) { - *out = MOVE_LEFT; + *out = WLR_DIRECTION_LEFT; } else if (strcasecmp(name, "right") == 0) { - *out = MOVE_RIGHT; + *out = WLR_DIRECTION_RIGHT; } else if (strcasecmp(name, "up") == 0) { - *out = MOVE_UP; + *out = WLR_DIRECTION_UP; } else if (strcasecmp(name, "down") == 0) { - *out = MOVE_DOWN; - } else if (strcasecmp(name, "parent") == 0) { - *out = MOVE_PARENT; - } else if (strcasecmp(name, "child") == 0) { - *out = MOVE_CHILD; + *out = WLR_DIRECTION_DOWN; } else { return false; } @@ -38,7 +35,7 @@ static bool parse_movement_direction(const char *name, * Get node in the direction of newly entered output. */ static struct sway_node *get_node_in_output_direction( - struct sway_output *output, enum movement_direction dir) { + struct sway_output *output, enum wlr_direction dir) { struct sway_seat *seat = config->handler_context.seat; struct sway_workspace *ws = output_get_active_workspace(output); if (ws->fullscreen) { @@ -48,7 +45,7 @@ static struct sway_node *get_node_in_output_direction( if (ws->tiling->length > 0) { switch (dir) { - case MOVE_LEFT: + case WLR_DIRECTION_LEFT: if (ws->layout == L_HORIZ || ws->layout == L_TABBED) { // get most right child of new output container = ws->tiling->items[ws->tiling->length-1]; @@ -56,7 +53,7 @@ static struct sway_node *get_node_in_output_direction( container = seat_get_focus_inactive_tiling(seat, ws); } break; - case MOVE_RIGHT: + case WLR_DIRECTION_RIGHT: if (ws->layout == L_HORIZ || ws->layout == L_TABBED) { // get most left child of new output container = ws->tiling->items[0]; @@ -64,7 +61,7 @@ static struct sway_node *get_node_in_output_direction( container = seat_get_focus_inactive_tiling(seat, ws); } break; - case MOVE_UP: + case WLR_DIRECTION_UP: if (ws->layout == L_VERT || ws->layout == L_STACKED) { // get most bottom child of new output container = ws->tiling->items[ws->tiling->length-1]; @@ -72,7 +69,7 @@ static struct sway_node *get_node_in_output_direction( container = seat_get_focus_inactive_tiling(seat, ws); } break; - case MOVE_DOWN: { + case WLR_DIRECTION_DOWN: if (ws->layout == L_VERT || ws->layout == L_STACKED) { // get most top child of new output container = ws->tiling->items[0]; @@ -81,9 +78,6 @@ static struct sway_node *get_node_in_output_direction( } break; } - default: - break; - } } if (container) { @@ -95,11 +89,8 @@ static struct sway_node *get_node_in_output_direction( } static struct sway_node *node_get_in_direction(struct sway_container *container, - struct sway_seat *seat, enum movement_direction dir) { + struct sway_seat *seat, enum wlr_direction dir) { if (container->is_fullscreen) { - if (dir == MOVE_PARENT) { - return NULL; - } // Fullscreen container with a direction - go straight to outputs struct sway_output *output = container->workspace->output; struct sway_output *new_output = output_get_in_direction(output, dir); @@ -108,9 +99,6 @@ static struct sway_node *node_get_in_direction(struct sway_container *container, } return get_node_in_output_direction(new_output, dir); } - if (dir == MOVE_PARENT) { - return node_get_parent(&container->node); - } struct sway_container *wrap_candidate = NULL; struct sway_container *current = container; @@ -122,15 +110,15 @@ static struct sway_node *node_get_in_direction(struct sway_container *container, container_parent_layout(current); list_t *siblings = container_get_siblings(current); - if (dir == MOVE_LEFT || dir == MOVE_RIGHT) { + if (dir == WLR_DIRECTION_LEFT || dir == WLR_DIRECTION_RIGHT) { if (parent_layout == L_HORIZ || parent_layout == L_TABBED) { can_move = true; - desired = idx + (dir == MOVE_LEFT ? -1 : 1); + desired = idx + (dir == WLR_DIRECTION_LEFT ? -1 : 1); } } else { if (parent_layout == L_VERT || parent_layout == L_STACKED) { can_move = true; - desired = idx + (dir == MOVE_UP ? -1 : 1); + desired = idx + (dir == WLR_DIRECTION_UP ? -1 : 1); } } @@ -200,15 +188,25 @@ static struct cmd_results *focus_output(struct sway_seat *seat, struct sway_output *output = output_by_name(identifier); if (!output) { - enum movement_direction direction; - if (!parse_movement_direction(identifier, &direction) || - direction == MOVE_PARENT || direction == MOVE_CHILD) { + enum wlr_direction direction; + if (!parse_direction(identifier, &direction)) { free(identifier); return cmd_results_new(CMD_INVALID, "focus", "There is no output with that name"); } struct sway_workspace *ws = seat_get_focused_workspace(seat); output = output_get_in_direction(ws->output, direction); + + if (!output) { + int center_lx = ws->output->lx + ws->output->width / 2; + int center_ly = ws->output->ly + ws->output->height / 2; + struct wlr_output *target = wlr_output_layout_farthest_output( + root->output_layout, opposite_direction(direction), + ws->output->wlr_output, center_lx, center_ly); + if (target) { + output = output_from_wlr_output(target); + } + } } free(identifier); @@ -220,6 +218,31 @@ static struct cmd_results *focus_output(struct sway_seat *seat, return cmd_results_new(CMD_SUCCESS, NULL, NULL); } +static struct cmd_results *focus_parent(void) { + struct sway_seat *seat = config->handler_context.seat; + struct sway_container *con = config->handler_context.container; + if (!con || con->is_fullscreen) { + return cmd_results_new(CMD_SUCCESS, NULL, NULL); + } + struct sway_node *parent = node_get_parent(&con->node); + if (parent) { + seat_set_focus(seat, parent); + seat_consider_warp_to_focus(seat); + } + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} + +static struct cmd_results *focus_child(void) { + struct sway_seat *seat = config->handler_context.seat; + struct sway_node *node = config->handler_context.node; + struct sway_node *focus = seat_get_active_tiling_child(seat, node); + if (focus) { + seat_set_focus(seat, focus); + seat_consider_warp_to_focus(seat); + } + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} + struct cmd_results *cmd_focus(int argc, char **argv) { if (config->reading || !config->active) { return cmd_results_new(CMD_DEFER, NULL, NULL); @@ -257,27 +280,21 @@ struct cmd_results *cmd_focus(int argc, char **argv) { return focus_output(seat, argc, argv); } - enum movement_direction direction = 0; - if (!parse_movement_direction(argv[0], &direction)) { + if (strcasecmp(argv[0], "parent") == 0) { + return focus_parent(); + } + if (strcasecmp(argv[0], "child") == 0) { + return focus_child(); + } + + enum wlr_direction direction = 0; + if (!parse_direction(argv[0], &direction)) { return cmd_results_new(CMD_INVALID, "focus", "Expected 'focus <direction|parent|child|mode_toggle|floating|tiling>' " "or 'focus output <direction|name>'"); } - if (direction == MOVE_CHILD) { - struct sway_node *focus = seat_get_active_tiling_child(seat, node); - if (focus) { - seat_set_focus(seat, focus); - seat_consider_warp_to_focus(seat); - } - return cmd_results_new(CMD_SUCCESS, NULL, NULL); - } - if (node->type == N_WORKSPACE) { - if (direction == MOVE_PARENT) { - return cmd_results_new(CMD_SUCCESS, NULL, NULL); - } - // Jump to the next output struct sway_output *new_output = output_get_in_direction(workspace->output, direction); diff --git a/sway/commands/mark.c b/sway/commands/mark.c index b1f47be1..c76e1d63 100644 --- a/sway/commands/mark.c +++ b/sway/commands/mark.c @@ -19,11 +19,10 @@ struct cmd_results *cmd_mark(int argc, char **argv) { return error; } struct sway_container *container = config->handler_context.container; - if (!container || !container->view) { + if (!container) { return cmd_results_new(CMD_INVALID, "mark", - "Only views can have marks"); + "Only containers can have marks"); } - struct sway_view *view = container->view; bool add = false, toggle = false; while (argc > 0 && strncmp(*argv, "--", 2) == 0) { @@ -47,22 +46,24 @@ struct cmd_results *cmd_mark(int argc, char **argv) { } char *mark = join_args(argv, argc); - bool had_mark = view_has_mark(view, mark); + bool had_mark = container_has_mark(container, mark); if (!add) { // Replacing - view_clear_marks(view); + container_clear_marks(container); } - view_find_and_unmark(mark); + container_find_and_unmark(mark); if (!toggle || !had_mark) { - view_add_mark(view, mark); + container_add_mark(container, mark); } free(mark); - view_update_marks_textures(view); - view_execute_criteria(view); + container_update_marks_textures(container); + if (container->view) { + view_execute_criteria(container->view); + } return cmd_results_new(CMD_SUCCESS, NULL, NULL); } diff --git a/sway/commands/move.c b/sway/commands/move.c index ffe12d41..7d8c1f1a 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c @@ -27,19 +27,6 @@ static const char *expected_syntax = "'move <container|window|workspace> [to] output <name|direction>' or " "'move <container|window> [to] mark <mark>'"; -enum wlr_direction opposite_direction(enum wlr_direction d) { - switch (d) { - case WLR_DIRECTION_UP: - return WLR_DIRECTION_DOWN; - case WLR_DIRECTION_DOWN: - return WLR_DIRECTION_UP; - case WLR_DIRECTION_RIGHT: - return WLR_DIRECTION_LEFT; - default: - return WLR_DIRECTION_RIGHT; - } -} - static struct sway_output *output_in_direction(const char *direction_string, struct sway_output *reference, int ref_lx, int ref_ly) { struct { @@ -81,14 +68,14 @@ static struct sway_output *output_in_direction(const char *direction_string, } static bool is_parallel(enum sway_container_layout layout, - enum movement_direction dir) { + enum wlr_direction dir) { switch (layout) { case L_TABBED: case L_HORIZ: - return dir == MOVE_LEFT || dir == MOVE_RIGHT; + return dir == WLR_DIRECTION_LEFT || dir == WLR_DIRECTION_RIGHT; case L_STACKED: case L_VERT: - return dir == MOVE_UP || dir == MOVE_DOWN; + return dir == WLR_DIRECTION_UP || dir == WLR_DIRECTION_DOWN; default: return false; } @@ -115,7 +102,7 @@ static void workspace_focus_fullscreen(struct sway_workspace *workspace) { static void container_move_to_container_from_direction( struct sway_container *container, struct sway_container *destination, - enum movement_direction move_dir) { + enum wlr_direction move_dir) { if (destination->view) { if (destination->parent == container->parent && destination->workspace == container->workspace) { @@ -126,7 +113,8 @@ static void container_move_to_container_from_direction( list_swap(siblings, container_index, destination_index); } else { wlr_log(WLR_DEBUG, "Promoting to sibling of cousin"); - int offset = move_dir == MOVE_LEFT || move_dir == MOVE_UP; + int offset = + move_dir == WLR_DIRECTION_LEFT || move_dir == WLR_DIRECTION_UP; int index = container_sibling_index(destination) + offset; if (destination->parent) { container_insert_child(destination->parent, container, index); @@ -141,7 +129,8 @@ static void container_move_to_container_from_direction( if (is_parallel(destination->layout, move_dir)) { wlr_log(WLR_DEBUG, "Reparenting container (parallel)"); - int index = move_dir == MOVE_RIGHT || move_dir == MOVE_DOWN ? + int index = + move_dir == WLR_DIRECTION_RIGHT || move_dir == WLR_DIRECTION_DOWN ? 0 : destination->children->length; container_insert_child(destination, container, index); container->width = container->height = 0; @@ -164,10 +153,11 @@ static void container_move_to_container_from_direction( static void container_move_to_workspace_from_direction( struct sway_container *container, struct sway_workspace *workspace, - enum movement_direction move_dir) { + enum wlr_direction move_dir) { if (is_parallel(workspace->layout, move_dir)) { wlr_log(WLR_DEBUG, "Reparenting container (parallel)"); - int index = move_dir == MOVE_RIGHT || move_dir == MOVE_DOWN ? + int index = + move_dir == WLR_DIRECTION_RIGHT || move_dir == WLR_DIRECTION_DOWN ? 0 : workspace->tiling->length; workspace_insert_tiling(workspace, container, index); return; @@ -258,28 +248,31 @@ static void container_move_to_container(struct sway_container *container, * container, switches the layout of the workspace, and drops the child back in. * In other words, rejigger it. */ static void workspace_rejigger(struct sway_workspace *ws, - struct sway_container *child, enum movement_direction move_dir) { + struct sway_container *child, enum wlr_direction move_dir) { if (!child->parent && ws->tiling->length == 1) { ws->layout = - move_dir == MOVE_LEFT || move_dir == MOVE_RIGHT ? L_HORIZ : L_VERT; + move_dir == WLR_DIRECTION_LEFT || move_dir == WLR_DIRECTION_RIGHT ? + L_HORIZ : L_VERT; workspace_update_representation(ws); return; } container_detach(child); struct sway_container *new_parent = workspace_wrap_children(ws); - int index = move_dir == MOVE_LEFT || move_dir == MOVE_UP ? 0 : 1; + int index = + move_dir == WLR_DIRECTION_LEFT || move_dir == WLR_DIRECTION_UP ? 0 : 1; workspace_insert_tiling(ws, child, index); container_flatten(new_parent); ws->layout = - move_dir == MOVE_LEFT || move_dir == MOVE_RIGHT ? L_HORIZ : L_VERT; + move_dir == WLR_DIRECTION_LEFT || move_dir == WLR_DIRECTION_RIGHT ? + L_HORIZ : L_VERT; workspace_update_representation(ws); child->width = child->height = 0; } // Returns true if moved static bool container_move_in_direction(struct sway_container *container, - enum movement_direction move_dir) { + enum wlr_direction move_dir) { // If moving a fullscreen view, only consider outputs if (container->is_fullscreen) { struct sway_output *new_output = @@ -305,7 +298,8 @@ static bool container_move_in_direction(struct sway_container *container, // The below loop stops once we hit the workspace because current->parent // is NULL for the topmost containers in a workspace. struct sway_container *current = container; - int offs = move_dir == MOVE_LEFT || move_dir == MOVE_UP ? -1 : 1; + int offs = + move_dir == WLR_DIRECTION_LEFT || move_dir == WLR_DIRECTION_UP ? -1 : 1; while (current) { list_t *siblings = container_get_siblings(current); @@ -494,12 +488,12 @@ static struct cmd_results *cmd_move_container(int argc, char **argv) { } destination = seat_get_focus_inactive(seat, &new_output->node); } else if (strcasecmp(argv[1], "mark") == 0) { - struct sway_view *dest_view = view_find_mark(argv[2]); - if (dest_view == NULL) { + struct sway_container *dest_con = container_find_mark(argv[2]); + if (dest_con == NULL) { return cmd_results_new(CMD_FAILURE, "move", "Mark '%s' not found", argv[2]); } - destination = &dest_view->container->node; + destination = &dest_con->node; } else { return cmd_results_new(CMD_INVALID, "move", expected_syntax); } @@ -642,7 +636,7 @@ static struct cmd_results *cmd_move_workspace(int argc, char **argv) { } static struct cmd_results *cmd_move_in_direction( - enum movement_direction direction, int argc, char **argv) { + enum wlr_direction direction, int argc, char **argv) { int move_amt = 10; if (argc > 1) { char *inv; @@ -666,22 +660,18 @@ static struct cmd_results *cmd_move_in_direction( double lx = container->x; double ly = container->y; switch (direction) { - case MOVE_LEFT: + case WLR_DIRECTION_LEFT: lx -= move_amt; break; - case MOVE_RIGHT: + case WLR_DIRECTION_RIGHT: lx += move_amt; break; - case MOVE_UP: + case WLR_DIRECTION_UP: ly -= move_amt; break; - case MOVE_DOWN: + case WLR_DIRECTION_DOWN: ly += move_amt; break; - case MOVE_PARENT: - case MOVE_CHILD: - return cmd_results_new(CMD_FAILURE, "move", - "Cannot move floating container to parent or child"); } container_floating_move_to(container, lx, ly); return cmd_results_new(CMD_SUCCESS, NULL, NULL); @@ -850,13 +840,13 @@ struct cmd_results *cmd_move(int argc, char **argv) { } if (strcasecmp(argv[0], "left") == 0) { - return cmd_move_in_direction(MOVE_LEFT, argc, argv); + return cmd_move_in_direction(WLR_DIRECTION_LEFT, argc, argv); } else if (strcasecmp(argv[0], "right") == 0) { - return cmd_move_in_direction(MOVE_RIGHT, argc, argv); + return cmd_move_in_direction(WLR_DIRECTION_RIGHT, argc, argv); } else if (strcasecmp(argv[0], "up") == 0) { - return cmd_move_in_direction(MOVE_UP, argc, argv); + return cmd_move_in_direction(WLR_DIRECTION_UP, argc, argv); } else if (strcasecmp(argv[0], "down") == 0) { - return cmd_move_in_direction(MOVE_DOWN, argc, argv); + return cmd_move_in_direction(WLR_DIRECTION_DOWN, argc, argv); } else if ((strcasecmp(argv[0], "container") == 0 || strcasecmp(argv[0], "window") == 0) || (strcasecmp(argv[0], "--no-auto-back-and-forth") && argc >= 2 diff --git a/sway/commands/reload.c b/sway/commands/reload.c index 791081a8..62105cdc 100644 --- a/sway/commands/reload.c +++ b/sway/commands/reload.c @@ -10,9 +10,7 @@ #include "log.h" static void rebuild_textures_iterator(struct sway_container *con, void *data) { - if (con->view) { - view_update_marks_textures(con->view); - } + container_update_marks_textures(con); container_update_title_textures(con); } diff --git a/sway/commands/show_marks.c b/sway/commands/show_marks.c index d501584a..0baf6852 100644 --- a/sway/commands/show_marks.c +++ b/sway/commands/show_marks.c @@ -11,9 +11,7 @@ #include "util.h" static void rebuild_marks_iterator(struct sway_container *con, void *data) { - if (con->view) { - view_update_marks_textures(con->view); - } + container_update_marks_textures(con); } struct cmd_results *cmd_show_marks(int argc, char **argv) { diff --git a/sway/commands/swap.c b/sway/commands/swap.c index a70a6cdd..23e8d583 100644 --- a/sway/commands/swap.c +++ b/sway/commands/swap.c @@ -159,8 +159,8 @@ static bool test_id(struct sway_container *container, void *id) { } static bool test_mark(struct sway_container *container, void *mark) { - if (container->view && container->view->marks->length) { - return !list_seq_find(container->view->marks, + if (container->marks->length) { + return !list_seq_find(container->marks, (int (*)(const void *, const void *))strcmp, mark); } return false; diff --git a/sway/commands/unmark.c b/sway/commands/unmark.c index c671ed4e..98ac6ff2 100644 --- a/sway/commands/unmark.c +++ b/sway/commands/unmark.c @@ -9,10 +9,8 @@ #include "stringop.h" static void remove_all_marks_iterator(struct sway_container *con, void *data) { - if (con->view) { - view_clear_marks(con->view); - view_update_marks_textures(con->view); - } + container_clear_marks(con); + container_update_marks_textures(con); } // unmark Remove all marks from all views @@ -21,15 +19,10 @@ static void remove_all_marks_iterator(struct sway_container *con, void *data) { // [criteria] unmark foo Remove single mark from matched view struct cmd_results *cmd_unmark(int argc, char **argv) { - // Determine the view - struct sway_view *view = NULL; + // Determine the container + struct sway_container *con = NULL; if (config->handler_context.using_criteria) { - struct sway_container *container = config->handler_context.container; - if (!container || !container->view) { - return cmd_results_new(CMD_INVALID, "unmark", - "Only views can have marks"); - } - view = container->view; + con = config->handler_context.container; } // Determine the mark @@ -38,20 +31,20 @@ struct cmd_results *cmd_unmark(int argc, char **argv) { mark = join_args(argv, argc); } - if (view && mark) { - // Remove the mark from the given view - if (view_has_mark(view, mark)) { - view_find_and_unmark(mark); + if (con && mark) { + // Remove the mark from the given container + if (container_has_mark(con, mark)) { + container_find_and_unmark(mark); } - } else if (view && !mark) { - // Clear all marks from the given view - view_clear_marks(view); - view_update_marks_textures(view); - } else if (!view && mark) { - // Remove mark from whichever view has it - view_find_and_unmark(mark); + } else if (con && !mark) { + // Clear all marks from the given container + container_clear_marks(con); + container_update_marks_textures(con); + } else if (!con && mark) { + // Remove mark from whichever container has it + container_find_and_unmark(mark); } else { - // Remove all marks from all views + // Remove all marks from all containers root_for_each_container(remove_all_marks_iterator, NULL); } free(mark); |