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.c61
1 files changed, 54 insertions, 7 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 192a73c5..64597c02 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -167,32 +167,53 @@ void view_autoconfigure(struct sway_view *view) {
167 167
168 double x, y, width, height; 168 double x, y, width, height;
169 x = y = width = height = 0; 169 x = y = width = height = 0;
170 double y_offset = 0;
171
172 // In a tabbed or stacked container, the swayc's y is the top of the title
173 // area. We have to offset the surface y by the height of the title bar, and
174 // disable any top border because we'll always have the title bar.
175 if (view->swayc->parent->layout == L_TABBED) {
176 y_offset = config->border_thickness * 2 + config->font_height;
177 view->border_top = 0;
178 } else if (view->swayc->parent->layout == L_STACKED) {
179 y_offset = config->border_thickness * 2 + config->font_height;
180 y_offset *= view->swayc->parent->children->length;
181 view->border_top = 0;
182 }
183
170 switch (view->border) { 184 switch (view->border) {
171 case B_NONE: 185 case B_NONE:
172 x = view->swayc->x; 186 x = view->swayc->x;
173 y = view->swayc->y; 187 y = view->swayc->y + y_offset;
174 width = view->swayc->width; 188 width = view->swayc->width;
175 height = view->swayc->height; 189 height = view->swayc->height - y_offset;
176 break; 190 break;
177 case B_PIXEL: 191 case B_PIXEL:
178 x = view->swayc->x + view->border_thickness * view->border_left; 192 x = view->swayc->x + view->border_thickness * view->border_left;
179 y = view->swayc->y + view->border_thickness * view->border_top; 193 y = view->swayc->y + view->border_thickness * view->border_top + y_offset;
180 width = view->swayc->width 194 width = view->swayc->width
181 - view->border_thickness * view->border_left 195 - view->border_thickness * view->border_left
182 - view->border_thickness * view->border_right; 196 - view->border_thickness * view->border_right;
183 height = view->swayc->height 197 height = view->swayc->height - y_offset
184 - view->border_thickness * view->border_top 198 - view->border_thickness * view->border_top
185 - view->border_thickness * view->border_bottom; 199 - view->border_thickness * view->border_bottom;
186 break; 200 break;
187 case B_NORMAL: 201 case B_NORMAL:
188 // Height is: border + title height + border + view height + border 202 // Height is: border + title height + border + view height + border
189 x = view->swayc->x + view->border_thickness * view->border_left; 203 x = view->swayc->x + view->border_thickness * view->border_left;
190 y = view->swayc->y + config->font_height + view->border_thickness * 2;
191 width = view->swayc->width 204 width = view->swayc->width
192 - view->border_thickness * view->border_left 205 - view->border_thickness * view->border_left
193 - view->border_thickness * view->border_right; 206 - view->border_thickness * view->border_right;
194 height = view->swayc->height - config->font_height 207 if (y_offset) {
195 - view->border_thickness * (2 + view->border_bottom); 208 y = view->swayc->y + y_offset;
209 height = view->swayc->height - y_offset
210 - view->border_thickness * view->border_bottom;
211 } else {
212 y = view->swayc->y + config->font_height + view->border_thickness * 2
213 + y_offset;
214 height = view->swayc->height - config->font_height
215 - view->border_thickness * (2 + view->border_bottom);
216 }
196 break; 217 break;
197 } 218 }
198 219
@@ -441,6 +462,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) {
441 input_manager_set_focus(input_manager, cont); 462 input_manager_set_focus(input_manager, cont);
442 463
443 view_update_title(view, false); 464 view_update_title(view, false);
465 container_notify_child_title_changed(view->swayc->parent);
444 view_execute_criteria(view); 466 view_execute_criteria(view);
445 467
446 container_damage_whole(cont); 468 container_damage_whole(cont);
@@ -864,3 +886,28 @@ void view_update_marks_textures(struct sway_view *view) {
864 &config->border_colors.urgent); 886 &config->border_colors.urgent);
865 container_damage_whole(view->swayc); 887 container_damage_whole(view->swayc);
866} 888}
889
890bool view_is_visible(struct sway_view *view) {
891 if (!view->swayc) {
892 return false;
893 }
894 // Check view isn't in a tabbed or stacked container on an inactive tab
895 struct sway_seat *seat = input_manager_current_seat(input_manager);
896 struct sway_container *container = view->swayc;
897 while (container->type != C_WORKSPACE) {
898 if (container->parent->layout == L_TABBED ||
899 container->parent->layout == L_STACKED) {
900 if (seat_get_active_child(seat, container->parent) != container) {
901 return false;
902 }
903 }
904 container = container->parent;
905 }
906 // Check view isn't hidden by another fullscreen view
907 struct sway_container *workspace = container;
908 if (workspace->sway_workspace->fullscreen && !view->is_fullscreen) {
909 return false;
910 }
911 // Check the workspace is visible
912 return workspace_is_visible(workspace);
913}