diff options
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r-- | sway/tree/view.c | 68 |
1 files changed, 33 insertions, 35 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c index 64597c02..812d7740 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -17,6 +17,7 @@ #include "sway/tree/workspace.h" #include "sway/config.h" #include "pango.h" +#include "stringop.h" void view_init(struct sway_view *view, enum sway_view_type type, const struct sway_view_impl *impl) { @@ -141,9 +142,18 @@ void view_autoconfigure(struct sway_view *view) { struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE); - int other_views = 1; + int other_views = 0; if (config->hide_edge_borders == E_SMART) { - other_views = container_count_descendants_of_type(ws, C_VIEW) - 1; + struct sway_container *con = view->swayc; + while (con != output) { + if (con->layout != L_TABBED && con->layout != L_STACKED) { + other_views += con->children ? con->children->length - 1 : 0; + if (other_views > 0) { + break; + } + } + con = con->parent; + } } view->border_top = view->border_bottom = true; @@ -173,11 +183,11 @@ void view_autoconfigure(struct sway_view *view) { // area. We have to offset the surface y by the height of the title bar, and // disable any top border because we'll always have the title bar. if (view->swayc->parent->layout == L_TABBED) { - y_offset = config->border_thickness * 2 + config->font_height; + y_offset = container_titlebar_height(); view->border_top = 0; } else if (view->swayc->parent->layout == L_STACKED) { - y_offset = config->border_thickness * 2 + config->font_height; - y_offset *= view->swayc->parent->children->length; + y_offset = container_titlebar_height() + * view->swayc->parent->children->length; view->border_top = 0; } @@ -199,7 +209,7 @@ void view_autoconfigure(struct sway_view *view) { - view->border_thickness * view->border_bottom; break; case B_NORMAL: - // Height is: border + title height + border + view height + border + // Height is: 1px border + 3px pad + title height + 3px pad + 1px border x = view->swayc->x + view->border_thickness * view->border_left; width = view->swayc->width - view->border_thickness * view->border_left @@ -209,10 +219,9 @@ void view_autoconfigure(struct sway_view *view) { height = view->swayc->height - y_offset - view->border_thickness * view->border_bottom; } else { - y = view->swayc->y + config->font_height + view->border_thickness * 2 - + y_offset; - height = view->swayc->height - config->font_height - - view->border_thickness * (2 + view->border_bottom); + y = view->swayc->y + container_titlebar_height(); + height = view->swayc->height - container_titlebar_height() + - view->border_thickness * view->border_bottom; } break; } @@ -430,10 +439,11 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { // Check if there's any `assign` criteria for the view list_t *criterias = criteria_for_view(view, CT_ASSIGN_WORKSPACE | CT_ASSIGN_OUTPUT); + struct sway_container *workspace = NULL; if (criterias->length) { struct criteria *criteria = criterias->items[0]; if (criteria->type == CT_ASSIGN_WORKSPACE) { - struct sway_container *workspace = workspace_by_name(criteria->target); + workspace = workspace_by_name(criteria->target); if (!workspace) { workspace = workspace_create(NULL, criteria->target); } @@ -460,9 +470,12 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { arrange_children_of(cont->parent); input_manager_set_focus(input_manager, cont); + if (workspace) { + workspace_switch(workspace); + } view_update_title(view, false); - container_notify_child_title_changed(view->swayc->parent); + container_notify_subtree_changed(view->swayc->parent); view_execute_criteria(view); container_damage_whole(cont); @@ -653,49 +666,35 @@ static size_t parse_title_format(struct sway_view *view, char *buffer) { char *format = view->title_format; char *next = strchr(format, '%'); while (next) { - if (buffer) { - // Copy everything up to the % - strncat(buffer, format, next - format); - } + // Copy everything up to the % + lenient_strncat(buffer, format, next - format); len += next - format; format = next; if (strncmp(next, "%title", 6) == 0) { - if (buffer && title) { - strcat(buffer, title); - } + lenient_strcat(buffer, title); len += title_len; format += 6; } else if (strncmp(next, "%class", 6) == 0) { - if (buffer && class) { - strcat(buffer, class); - } + lenient_strcat(buffer, class); len += class_len; format += 6; } else if (strncmp(next, "%instance", 9) == 0) { - if (buffer && instance) { - strcat(buffer, instance); - } + lenient_strcat(buffer, instance); len += instance_len; format += 9; } else if (strncmp(next, "%shell", 6) == 0) { - if (buffer) { - strcat(buffer, shell); - } + lenient_strcat(buffer, shell); len += shell_len; format += 6; } else { - if (buffer) { - strcat(buffer, "%"); - } + lenient_strcat(buffer, "%"); ++format; ++len; } next = strchr(format, '%'); } - if (buffer) { - strcat(buffer, format); - } + lenient_strcat(buffer, format); len += strlen(format); return len; @@ -751,7 +750,6 @@ void view_update_title(struct sway_view *view, bool force) { } container_calculate_title_height(view->swayc); container_update_title_textures(view->swayc); - container_notify_child_title_changed(view->swayc->parent); config_update_font_height(false); } |