aboutsummaryrefslogtreecommitdiff
path: root/sway/tree/view.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r--sway/tree/view.c86
1 files changed, 71 insertions, 15 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 648c1655..07157818 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -139,10 +139,20 @@ void view_autoconfigure(struct sway_view *view) {
return;
}
- int other_views = 1;
+ struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
+
+ int other_views = 0;
if (config->hide_edge_borders == E_SMART) {
- struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
- 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;
@@ -151,47 +161,67 @@ void view_autoconfigure(struct sway_view *view) {
if (config->hide_edge_borders == E_BOTH
|| config->hide_edge_borders == E_VERTICAL
|| (config->hide_edge_borders == E_SMART && !other_views)) {
- view->border_left = view->swayc->x != 0;
+ view->border_left = view->swayc->x != ws->x;
int right_x = view->swayc->x + view->swayc->width;
- view->border_right = right_x != output->width;
+ view->border_right = right_x != ws->x + ws->width;
}
if (config->hide_edge_borders == E_BOTH
|| config->hide_edge_borders == E_HORIZONTAL
|| (config->hide_edge_borders == E_SMART && !other_views)) {
- view->border_top = view->swayc->y != 0;
+ view->border_top = view->swayc->y != ws->y;
int bottom_y = view->swayc->y + view->swayc->height;
- view->border_bottom = bottom_y != output->height;
+ view->border_bottom = bottom_y != ws->y + ws->height;
}
}
double x, y, width, height;
x = y = width = height = 0;
+ double y_offset = 0;
+
+ // In a tabbed or stacked container, the swayc's y is the top of the title
+ // 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 = container_titlebar_height();
+ view->border_top = 0;
+ } else if (view->swayc->parent->layout == L_STACKED) {
+ y_offset = container_titlebar_height()
+ * view->swayc->parent->children->length;
+ view->border_top = 0;
+ }
+
switch (view->border) {
case B_NONE:
x = view->swayc->x;
- y = view->swayc->y;
+ y = view->swayc->y + y_offset;
width = view->swayc->width;
- height = view->swayc->height;
+ height = view->swayc->height - y_offset;
break;
case B_PIXEL:
x = view->swayc->x + view->border_thickness * view->border_left;
- y = view->swayc->y + view->border_thickness * view->border_top;
+ y = view->swayc->y + view->border_thickness * view->border_top + y_offset;
width = view->swayc->width
- view->border_thickness * view->border_left
- view->border_thickness * view->border_right;
- height = view->swayc->height
+ height = view->swayc->height - y_offset
- view->border_thickness * view->border_top
- 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;
- y = view->swayc->y + config->font_height + view->border_thickness * 2;
width = view->swayc->width
- view->border_thickness * view->border_left
- view->border_thickness * view->border_right;
- height = view->swayc->height - config->font_height
- - view->border_thickness * (2 + view->border_bottom);
+ if (y_offset) {
+ y = view->swayc->y + y_offset;
+ height = view->swayc->height - y_offset
+ - view->border_thickness * view->border_bottom;
+ } else {
+ y = view->swayc->y + container_titlebar_height();
+ height = view->swayc->height - container_titlebar_height()
+ - view->border_thickness * view->border_bottom;
+ }
break;
}
@@ -440,6 +470,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) {
input_manager_set_focus(input_manager, cont);
view_update_title(view, false);
+ container_notify_child_title_changed(view->swayc->parent);
view_execute_criteria(view);
container_damage_whole(cont);
@@ -863,3 +894,28 @@ void view_update_marks_textures(struct sway_view *view) {
&config->border_colors.urgent);
container_damage_whole(view->swayc);
}
+
+bool view_is_visible(struct sway_view *view) {
+ if (!view->swayc) {
+ return false;
+ }
+ // Check view isn't in a tabbed or stacked container on an inactive tab
+ struct sway_seat *seat = input_manager_current_seat(input_manager);
+ struct sway_container *container = view->swayc;
+ while (container->type != C_WORKSPACE) {
+ if (container->parent->layout == L_TABBED ||
+ container->parent->layout == L_STACKED) {
+ if (seat_get_active_child(seat, container->parent) != container) {
+ return false;
+ }
+ }
+ container = container->parent;
+ }
+ // Check view isn't hidden by another fullscreen view
+ struct sway_container *workspace = container;
+ if (workspace->sway_workspace->fullscreen && !view->is_fullscreen) {
+ return false;
+ }
+ // Check the workspace is visible
+ return workspace_is_visible(workspace);
+}