diff options
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands/swap.c | 4 | ||||
-rw-r--r-- | sway/input/seat.c | 2 | ||||
-rw-r--r-- | sway/tree/container.c | 6 | ||||
-rw-r--r-- | sway/tree/layout.c | 8 | ||||
-rw-r--r-- | sway/tree/view.c | 33 |
5 files changed, 23 insertions, 30 deletions
diff --git a/sway/commands/swap.c b/sway/commands/swap.c index e925ad33..e8dfc57f 100644 --- a/sway/commands/swap.c +++ b/sway/commands/swap.c @@ -60,8 +60,8 @@ struct cmd_results *cmd_swap(int argc, char **argv) { } else if (current->type < C_CONTAINER || other->type < C_CONTAINER) { error = cmd_results_new(CMD_FAILURE, "swap", "Can only swap with containers and views"); - } else if (container_has_anscestor(current, other) - || container_has_anscestor(other, current)) { + } else if (container_has_ancestor(current, other) + || container_has_ancestor(other, current)) { error = cmd_results_new(CMD_FAILURE, "swap", "Cannot swap ancestor and descendant"); } else if (current->layout == L_FLOATING || other->layout == L_FLOATING) { diff --git a/sway/input/seat.c b/sway/input/seat.c index 6cfbe8d4..0295212c 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -542,7 +542,7 @@ void seat_set_focus_warp(struct sway_seat *seat, return; } - // put all the anscestors of this container on top of the focus stack + // put all the ancestors of this container on top of the focus stack struct sway_seat_container *parent = seat_container_from_container(seat, container->parent); while (parent) { diff --git a/sway/tree/container.c b/sway/tree/container.c index a4798c7e..59137d88 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -656,11 +656,11 @@ void container_for_each_descendant_bfs(struct sway_container *con, } } -bool container_has_anscestor(struct sway_container *descendant, - struct sway_container *anscestor) { +bool container_has_ancestor(struct sway_container *descendant, + struct sway_container *ancestor) { while (descendant->type != C_ROOT) { descendant = descendant->parent; - if (descendant == anscestor) { + if (descendant == ancestor) { return true; } } diff --git a/sway/tree/layout.c b/sway/tree/layout.c index 6d76ae0f..1507eba9 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c @@ -157,7 +157,7 @@ struct sway_container *container_remove_child(struct sway_container *child) { void container_move_to(struct sway_container *container, struct sway_container *destination) { if (container == destination - || container_has_anscestor(container, destination)) { + || container_has_ancestor(container, destination)) { return; } struct sway_container *old_parent = container_remove_child(container); @@ -953,9 +953,9 @@ void container_swap(struct sway_container *con1, struct sway_container *con2) { "Can only swap containers and views")) { return; } - if (!sway_assert(!container_has_anscestor(con1, con2) - && !container_has_anscestor(con2, con1), - "Cannot swap anscestor and descendant")) { + if (!sway_assert(!container_has_ancestor(con1, con2) + && !container_has_ancestor(con2, con1), + "Cannot swap ancestor and descendant")) { return; } if (!sway_assert(con1->layout != L_FLOATING && con2->layout != L_FLOATING, diff --git a/sway/tree/view.c b/sway/tree/view.c index d91182ed..26ff1e8d 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -641,6 +641,14 @@ void view_child_destroy(struct sway_view_child *child) { } } +static size_t append_prop(char *buffer, const char *value) { + if (!value) { + return 0; + } + lenient_strcat(buffer, value); + return strlen(value); +} + /** * Calculate and return the length of the formatted title. * If buffer is not NULL, also populate the buffer with the formatted title. @@ -653,16 +661,6 @@ static size_t parse_title_format(struct sway_view *view, char *buffer) { } return title ? strlen(title) : 0; } - const char *title = view_get_title(view); - const char *app_id = view_get_app_id(view); - const char *class = view_get_class(view); - const char *instance = view_get_instance(view); - const char *shell = view_get_shell(view); - size_t title_len = title ? strlen(title) : 0; - size_t app_id_len = app_id ? strlen(app_id) : 0; - size_t class_len = class ? strlen(class) : 0; - size_t instance_len = instance ? strlen(instance) : 0; - size_t shell_len = shell ? strlen(shell) : 0; size_t len = 0; char *format = view->title_format; @@ -674,24 +672,19 @@ static size_t parse_title_format(struct sway_view *view, char *buffer) { format = next; if (strncmp(next, "%title", 6) == 0) { - lenient_strcat(buffer, title); - len += title_len; + len += append_prop(buffer, view_get_title(view)); format += 6; } else if (strncmp(next, "%app_id", 7) == 0) { - lenient_strcat(buffer, app_id); - len += app_id_len; + len += append_prop(buffer, view_get_app_id(view)); format += 7; } else if (strncmp(next, "%class", 6) == 0) { - lenient_strcat(buffer, class); - len += class_len; + len += append_prop(buffer, view_get_class(view)); format += 6; } else if (strncmp(next, "%instance", 9) == 0) { - lenient_strcat(buffer, instance); - len += instance_len; + len += append_prop(buffer, view_get_instance(view)); format += 9; } else if (strncmp(next, "%shell", 6) == 0) { - lenient_strcat(buffer, shell); - len += shell_len; + len += append_prop(buffer, view_get_shell(view)); format += 6; } else { lenient_strcat(buffer, "%"); |