summaryrefslogtreecommitdiffstats
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) {
139 return; 139 return;
140 } 140 }
141 141
142 int other_views = 1; 142 struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
143
144 int other_views = 0;
143 if (config->hide_edge_borders == E_SMART) { 145 if (config->hide_edge_borders == E_SMART) {
144 struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE); 146 struct sway_container *con = view->swayc;
145 other_views = container_count_descendants_of_type(ws, C_VIEW) - 1; 147 while (con != output) {
148 if (con->layout != L_TABBED && con->layout != L_STACKED) {
149 other_views += con->children ? con->children->length - 1 : 0;
150 if (other_views > 0) {
151 break;
152 }
153 }
154 con = con->parent;
155 }
146 } 156 }
147 157
148 view->border_top = view->border_bottom = true; 158 view->border_top = view->border_bottom = true;
@@ -151,47 +161,67 @@ void view_autoconfigure(struct sway_view *view) {
151 if (config->hide_edge_borders == E_BOTH 161 if (config->hide_edge_borders == E_BOTH
152 || config->hide_edge_borders == E_VERTICAL 162 || config->hide_edge_borders == E_VERTICAL
153 || (config->hide_edge_borders == E_SMART && !other_views)) { 163 || (config->hide_edge_borders == E_SMART && !other_views)) {
154 view->border_left = view->swayc->x != 0; 164 view->border_left = view->swayc->x != ws->x;
155 int right_x = view->swayc->x + view->swayc->width; 165 int right_x = view->swayc->x + view->swayc->width;
156 view->border_right = right_x != output->width; 166 view->border_right = right_x != ws->x + ws->width;
157 } 167 }
158 if (config->hide_edge_borders == E_BOTH 168 if (config->hide_edge_borders == E_BOTH
159 || config->hide_edge_borders == E_HORIZONTAL 169 || config->hide_edge_borders == E_HORIZONTAL
160 || (config->hide_edge_borders == E_SMART && !other_views)) { 170 || (config->hide_edge_borders == E_SMART && !other_views)) {
161 view->border_top = view->swayc->y != 0; 171 view->border_top = view->swayc->y != ws->y;
162 int bottom_y = view->swayc->y + view->swayc->height; 172 int bottom_y = view->swayc->y + view->swayc->height;
163 view->border_bottom = bottom_y != output->height; 173 view->border_bottom = bottom_y != ws->y + ws->height;
164 } 174 }
165 } 175 }
166 176
167 double x, y, width, height; 177 double x, y, width, height;
168 x = y = width = height = 0; 178 x = y = width = height = 0;
179 double y_offset = 0;
180
181 // In a tabbed or stacked container, the swayc's y is the top of the title
182 // area. We have to offset the surface y by the height of the title bar, and
183 // disable any top border because we'll always have the title bar.
184 if (view->swayc->parent->layout == L_TABBED) {
185 y_offset = container_titlebar_height();
186 view->border_top = 0;
187 } else if (view->swayc->parent->layout == L_STACKED) {
188 y_offset = container_titlebar_height()
189 * view->swayc->parent->children->length;
190 view->border_top = 0;
191 }
192
169 switch (view->border) { 193 switch (view->border) {
170 case B_NONE: 194 case B_NONE:
171 x = view->swayc->x; 195 x = view->swayc->x;
172 y = view->swayc->y; 196 y = view->swayc->y + y_offset;
173 width = view->swayc->width; 197 width = view->swayc->width;
174 height = view->swayc->height; 198 height = view->swayc->height - y_offset;
175 break; 199 break;
176 case B_PIXEL: 200 case B_PIXEL:
177 x = view->swayc->x + view->border_thickness * view->border_left; 201 x = view->swayc->x + view->border_thickness * view->border_left;
178 y = view->swayc->y + view->border_thickness * view->border_top; 202 y = view->swayc->y + view->border_thickness * view->border_top + y_offset;
179 width = view->swayc->width 203 width = view->swayc->width
180 - view->border_thickness * view->border_left 204 - view->border_thickness * view->border_left
181 - view->border_thickness * view->border_right; 205 - view->border_thickness * view->border_right;
182 height = view->swayc->height 206 height = view->swayc->height - y_offset
183 - view->border_thickness * view->border_top 207 - view->border_thickness * view->border_top
184 - view->border_thickness * view->border_bottom; 208 - view->border_thickness * view->border_bottom;
185 break; 209 break;
186 case B_NORMAL: 210 case B_NORMAL:
187 // Height is: border + title height + border + view height + border 211 // Height is: 1px border + 3px pad + title height + 3px pad + 1px border
188 x = view->swayc->x + view->border_thickness * view->border_left; 212 x = view->swayc->x + view->border_thickness * view->border_left;
189 y = view->swayc->y + config->font_height + view->border_thickness * 2;
190 width = view->swayc->width 213 width = view->swayc->width
191 - view->border_thickness * view->border_left 214 - view->border_thickness * view->border_left
192 - view->border_thickness * view->border_right; 215 - view->border_thickness * view->border_right;
193 height = view->swayc->height - config->font_height 216 if (y_offset) {
194 - view->border_thickness * (2 + view->border_bottom); 217 y = view->swayc->y + y_offset;
218 height = view->swayc->height - y_offset
219 - view->border_thickness * view->border_bottom;
220 } else {
221 y = view->swayc->y + container_titlebar_height();
222 height = view->swayc->height - container_titlebar_height()
223 - view->border_thickness * view->border_bottom;
224 }
195 break; 225 break;
196 } 226 }
197 227
@@ -440,6 +470,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) {
440 input_manager_set_focus(input_manager, cont); 470 input_manager_set_focus(input_manager, cont);
441 471
442 view_update_title(view, false); 472 view_update_title(view, false);
473 container_notify_child_title_changed(view->swayc->parent);
443 view_execute_criteria(view); 474 view_execute_criteria(view);
444 475
445 container_damage_whole(cont); 476 container_damage_whole(cont);
@@ -863,3 +894,28 @@ void view_update_marks_textures(struct sway_view *view) {
863 &config->border_colors.urgent); 894 &config->border_colors.urgent);
864 container_damage_whole(view->swayc); 895 container_damage_whole(view->swayc);
865} 896}
897
898bool view_is_visible(struct sway_view *view) {
899 if (!view->swayc) {
900 return false;
901 }
902 // Check view isn't in a tabbed or stacked container on an inactive tab
903 struct sway_seat *seat = input_manager_current_seat(input_manager);
904 struct sway_container *container = view->swayc;
905 while (container->type != C_WORKSPACE) {
906 if (container->parent->layout == L_TABBED ||
907 container->parent->layout == L_STACKED) {
908 if (seat_get_active_child(seat, container->parent) != container) {
909 return false;
910 }
911 }
912 container = container->parent;
913 }
914 // Check view isn't hidden by another fullscreen view
915 struct sway_container *workspace = container;
916 if (workspace->sway_workspace->fullscreen && !view->is_fullscreen) {
917 return false;
918 }
919 // Check the workspace is visible
920 return workspace_is_visible(workspace);
921}