summaryrefslogtreecommitdiff
path: root/sway/tree/container.c
diff options
context:
space:
mode:
authorPedro CĂ´rte-Real <[email protected]>2019-07-06 11:57:32 +0100
committerBrian Ashworth <[email protected]>2019-07-15 23:46:27 -0400
commitd0233af3b39475b47be4248846536811ddca2624 (patch)
treeacc61150bd9e6bc1a69c8e7f38a700e8a9e8b2ed /sway/tree/container.c
parent2dc4978d8af326c310057ca8fd22a4c7f5d09335 (diff)
Rework gaps code to be simpler and correct
Instead of tracking gaps per child apply gaps in two logical places: 1. In tiled containers use the layout code to add the gaps between windows. This is much simpler and guarantees that the sizing of children is correct. 2. In the workspace itself apply all the gaps around the edge. Here we're in the correct position to size inner and outer gaps correctly and decide on smart gaps in a single location. Fixes #4296
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r--sway/tree/container.c67
1 files changed, 0 insertions, 67 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 068dbb88..10aed599 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -1173,72 +1173,6 @@ void container_discover_outputs(struct sway_container *con) {
}
}
-void container_remove_gaps(struct sway_container *c) {
- if (c->current_gaps.top == 0 && c->current_gaps.right == 0 &&
- c->current_gaps.bottom == 0 && c->current_gaps.left == 0) {
- return;
- }
-
- c->width += c->current_gaps.left + c->current_gaps.right;
- c->height += c->current_gaps.top + c->current_gaps.bottom;
- c->x -= c->current_gaps.left;
- c->y -= c->current_gaps.top;
-
- c->current_gaps.top = 0;
- c->current_gaps.right = 0;
- c->current_gaps.bottom = 0;
- c->current_gaps.left = 0;
-}
-
-void container_add_gaps(struct sway_container *c) {
- if (c->current_gaps.top > 0 || c->current_gaps.right > 0 ||
- c->current_gaps.bottom > 0 || c->current_gaps.left > 0) {
- return;
- }
- // Fullscreen global scratchpad containers cannot have gaps
- struct sway_workspace *ws = c->workspace;
- if (!ws) {
- return;
- }
- // Linear containers don't have gaps because it'd create double gaps
- if (!c->view && c->layout != L_TABBED && c->layout != L_STACKED) {
- return;
- }
- // Descendants of tabbed/stacked containers re-use the gaps of the container
- struct sway_container *temp = c;
- while (temp) {
- enum sway_container_layout layout = container_parent_layout(temp);
- if (layout == L_TABBED || layout == L_STACKED) {
- return;
- }
- temp = temp->parent;
- }
- // If smart gaps is on, don't add gaps if there is only one view visible
- if (config->smart_gaps) {
- struct sway_view *view = c->view;
- if (!view) {
- struct sway_seat *seat =
- input_manager_get_default_seat();
- struct sway_container *focus =
- seat_get_focus_inactive_view(seat, &c->node);
- view = focus ? focus->view : NULL;
- }
- if (view && view_is_only_visible(view)) {
- return;
- }
- }
-
- c->current_gaps.top = c->y == ws->y ? ws->gaps_inner : 0;
- c->current_gaps.right = ws->gaps_inner;
- c->current_gaps.bottom = ws->gaps_inner;
- c->current_gaps.left = c->x == ws->x ? ws->gaps_inner : 0;
-
- c->x += c->current_gaps.left;
- c->y += c->current_gaps.top;
- c->width -= c->current_gaps.left + c->current_gaps.right;
- c->height -= c->current_gaps.top + c->current_gaps.bottom;
-}
-
enum sway_container_layout container_parent_layout(struct sway_container *con) {
if (con->parent) {
return con->parent->layout;
@@ -1421,7 +1355,6 @@ struct sway_container *container_split(struct sway_container *child,
cont->height_fraction = child->height_fraction;
cont->x = child->x;
cont->y = child->y;
- cont->current_gaps = child->current_gaps;
cont->layout = layout;
container_replace(child, cont);