awesome/spec/wibox/layout
Shay Agroskin 62850476d2 layout/fixed: Prevent overloading widgets with negative spacing
For each widget, the layout function checks whether placing it would
make the function exceed the allowed geometry.
If not, the function places both the widget and a spacing widget.
This check ignores the size of the spacing widget itself, this can cause
overloading of widgets on top of each other.

For example, the following scenario with these widgets:
    widgets: widget1 { width = 10, height = 10  }
	     widget2 { width = 10, height = 10  }
	     widget3 { width = 10, height = 10  }
and a call to horizontal layout with the
{ width = 10, height = 10, spacing = -5 } parameters.

The function would layout the widgets the following way:
{
    widget1: { x = 0, y = 0, width = 10, height = 10 }
    spacing: { x = 5, y = 0, width = 5, height = 10  }
    widget2: { x = 5, y = 0, width = 5, height = 10  }
    spacing: { x = 5, y = 0, width = 5, height = 10 }
    widget3: { x = 5, y = 0, width = 5, height = 10  }
}

This behaviour would be the same for any number of widgets for negative
layout.

This patch changes the layout function to check whether the current
widget uses up the whole space.
It also removes 'pos' variable. Its purpose isn't intuitive in the
presence of x and y. This helps to understand where each widget is
placed now that x, y don't hold the end location of the widget in the
previous loop iteration.

The result of the previous example becomes:
{
    widget1: { x = 0, y = 0, width = 10, height = 10 }
}

While this might not be the wanted behaviour exactly, distinguishing
between the scenario where 2 widgets are drawn and a scenario where 3
are drawn might complicate the layout function too much.

This patch also adds unit testing that catches the described behaviour.

Signed-off-by: Shay Agroskin <agrosshay@gmail.com>
2021-03-26 16:11:01 +03:00
..
align_spec.lua Add tests for get_children of layouts 2017-06-08 17:00:44 +02:00
fixed_spec.lua layout/fixed: Prevent overloading widgets with negative spacing 2021-03-26 16:11:01 +03:00
flex_spec.lua wibox.layout.flex: Do not leave empty space behind 2018-11-05 10:13:18 +01:00
grid_spec.lua Add tests for get_children of layouts 2017-06-08 17:00:44 +02:00
stack_spec.lua Add tests for widget constructors 2021-03-08 20:09:58 +01:00