aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-09-06 09:13:36 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-09-06 09:13:36 +1000
commitc6368febc8045ce884cc0047e89b980d6a81ce2f (patch)
treee2db4a2927bb81e3baf579d01a2bed4f1be62e62
parentMerge pull request #2572 from RedSoxFan/wlr-output-disabling (diff)
downloadsway-c6368febc8045ce884cc0047e89b980d6a81ce2f.tar.gz
sway-c6368febc8045ce884cc0047e89b980d6a81ce2f.tar.zst
sway-c6368febc8045ce884cc0047e89b980d6a81ce2f.zip
Adjust container box
Prior to f5b9815128b6c000bb5d47c339480fa481a5e99d, children of tabbed and stacked containers would have their container size and position set to the same as the tabbed/stacked container. Normally this would be a problem for a layout such as T[V[view]], but there was some code in the arrange functions which would check if the grandparent of the view was a tabbed or stacked container and would offset the view's Y accordingly. Commit f5b9815128b6c000bb5d47c339480fa481a5e99d changed the box to exclude the titlebar for all tabbed/stacked children so that the grandparent check could be removed. But this meant the title was not covered in the container and wasn't damaged when the child changed its title. This patch changes it so that a child of a tabbed/stacked container will have its box include the title bar if the child is a view, but not if it's a layout container. This fixes the title damage issue while avoiding the grandparent check in the arrange functions, and matches what we see visually.
-rw-r--r--sway/tree/arrange.c11
-rw-r--r--sway/tree/view.c35
2 files changed, 27 insertions, 19 deletions
diff --git a/sway/tree/arrange.c b/sway/tree/arrange.c
index edb05f86..d50be25d 100644
--- a/sway/tree/arrange.c
+++ b/sway/tree/arrange.c
@@ -97,15 +97,14 @@ static void apply_tabbed_layout(list_t *children, struct wlr_box *parent) {
97 if (!children->length) { 97 if (!children->length) {
98 return; 98 return;
99 } 99 }
100 size_t parent_offset = container_titlebar_height();
101 size_t parent_height = parent->height - parent_offset;
102 for (int i = 0; i < children->length; ++i) { 100 for (int i = 0; i < children->length; ++i) {
103 struct sway_container *child = children->items[i]; 101 struct sway_container *child = children->items[i];
102 size_t parent_offset = child->view ? 0 : container_titlebar_height();
104 container_remove_gaps(child); 103 container_remove_gaps(child);
105 child->x = parent->x; 104 child->x = parent->x;
106 child->y = parent->y + parent_offset; 105 child->y = parent->y + parent_offset;
107 child->width = parent->width; 106 child->width = parent->width;
108 child->height = parent_height; 107 child->height = parent->height - parent_offset;
109 container_add_gaps(child); 108 container_add_gaps(child);
110 } 109 }
111} 110}
@@ -114,15 +113,15 @@ static void apply_stacked_layout(list_t *children, struct wlr_box *parent) {
114 if (!children->length) { 113 if (!children->length) {
115 return; 114 return;
116 } 115 }
117 size_t parent_offset = container_titlebar_height() * children->length;
118 size_t parent_height = parent->height - parent_offset;
119 for (int i = 0; i < children->length; ++i) { 116 for (int i = 0; i < children->length; ++i) {
120 struct sway_container *child = children->items[i]; 117 struct sway_container *child = children->items[i];
118 size_t parent_offset = child->view ? 0 :
119 container_titlebar_height() * children->length;
121 container_remove_gaps(child); 120 container_remove_gaps(child);
122 child->x = parent->x; 121 child->x = parent->x;
123 child->y = parent->y + parent_offset; 122 child->y = parent->y + parent_offset;
124 child->width = parent->width; 123 child->width = parent->width;
125 child->height = parent_height; 124 child->height = parent->height - parent_offset;
126 container_add_gaps(child); 125 container_add_gaps(child);
127 } 126 }
128} 127}
diff --git a/sway/tree/view.c b/sway/tree/view.c
index f63a35b5..f9dcb11a 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -219,14 +219,17 @@ void view_autoconfigure(struct sway_view *view) {
219 x = y = width = height = 0; 219 x = y = width = height = 0;
220 double y_offset = 0; 220 double y_offset = 0;
221 221
222 // In a tabbed or stacked container, the swayc's y is the bottom of the 222 // In a tabbed or stacked container, the container's y is the top of the
223 // title area. We have to disable any top border because the title bar is 223 // title area. We have to offset the surface y by the height of the title,
224 // rendered by the parent. 224 // bar, and disable any top border because we'll always have the title bar.
225 enum sway_container_layout layout = container_parent_layout(con); 225 enum sway_container_layout layout = container_parent_layout(con);
226 if (layout == L_TABBED || layout == L_STACKED) { 226 if (layout == L_TABBED) {
227 view->border_top = false;
228 } else {
229 y_offset = container_titlebar_height(); 227 y_offset = container_titlebar_height();
228 view->border_top = false;
229 } else if (layout == L_STACKED) {
230 list_t *siblings = container_get_siblings(con);
231 y_offset = container_titlebar_height() * siblings->length;
232 view->border_top = false;
230 } 233 }
231 234
232 enum sway_container_border border = view->border; 235 enum sway_container_border border = view->border;
@@ -237,17 +240,17 @@ void view_autoconfigure(struct sway_view *view) {
237 switch (border) { 240 switch (border) {
238 case B_NONE: 241 case B_NONE:
239 x = con->x; 242 x = con->x;
240 y = con->y; 243 y = con->y + y_offset;
241 width = con->width; 244 width = con->width;
242 height = con->height; 245 height = con->height - y_offset;
243 break; 246 break;
244 case B_PIXEL: 247 case B_PIXEL:
245 x = con->x + view->border_thickness * view->border_left; 248 x = con->x + view->border_thickness * view->border_left;
246 y = con->y + view->border_thickness * view->border_top; 249 y = con->y + view->border_thickness * view->border_top + y_offset;
247 width = con->width 250 width = con->width
248 - view->border_thickness * view->border_left 251 - view->border_thickness * view->border_left
249 - view->border_thickness * view->border_right; 252 - view->border_thickness * view->border_right;
250 height = con->height 253 height = con->height - y_offset
251 - view->border_thickness * view->border_top 254 - view->border_thickness * view->border_top
252 - view->border_thickness * view->border_bottom; 255 - view->border_thickness * view->border_bottom;
253 break; 256 break;
@@ -257,9 +260,15 @@ void view_autoconfigure(struct sway_view *view) {
257 width = con->width 260 width = con->width
258 - view->border_thickness * view->border_left 261 - view->border_thickness * view->border_left
259 - view->border_thickness * view->border_right; 262 - view->border_thickness * view->border_right;
260 y = con->y + y_offset; 263 if (y_offset) {
261 height = con->height - y_offset 264 y = con->y + y_offset;
262 - view->border_thickness * view->border_bottom; 265 height = con->height - y_offset
266 - view->border_thickness * view->border_bottom;
267 } else {
268 y = con->y + container_titlebar_height();
269 height = con->height - container_titlebar_height()
270 - view->border_thickness * view->border_bottom;
271 }
263 break; 272 break;
264 } 273 }
265 274