Commit Graph

14 Commits

Author SHA1 Message Date
Uli Schlachter 1dd63b04de check_widget(): Also check .is_widget entry
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-27 14:01:31 +01:00
Uli Schlachter cf1576cdd8 Fix all luacheck warnings in spec/
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-11 21:55:08 +01:00
Uli Schlachter 41a8fabf4c Explicitly track dependencies between widgets
Before this, dependencies between widgets where implicitly discovered by
recursive calls to base.fit_widget() and base.layout_widget(). However, it is
too easy to get this wrong (just call one of these functions from outside of a
widget's :fit() / :layout() function) and the resulting mess would be hard to
debug.

Thus, this commit changes the API so that callers have to identify themselves
and we can explicitly record the dependency between the widgets involved.

This also fixes a bug where no dependencies were tracked for widgets after
:set_visible(false). Whoops...

Sorry for breaking the API for adding this.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-09-17 18:17:05 +02:00
Uli Schlachter c62d323d09 wibox.widget.base: Add caches for :layout and :fit
These caches, well, cache the result of the :layout and :fit callbacks on
widgets.

Clearing caches is done by recording dependencies between a widget. When a call
to base.fit_widget() or base.layout_widget() recursively causes another call to
such a function, this means that the earlier widget depends on the later widget.
This dependency is recorded and when the later widget emits
widget::layout_changed, the caches of all the widgets involved are cleared.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-09-06 18:57:21 +02:00
Uli Schlachter 447492e986 Tests: Have only one place for stubbing widgets
This makes the tests for wibox.hierarchy use test_utils.widget_stub() instead of
having its own implementation of "fake widgets".

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-09-06 18:57:07 +02:00
Uli Schlachter a430f6bc4c Remove now-unused stuff from test_utils
Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-09-05 14:28:53 +02:00
Uli Schlachter 3338718b93 Merge wibox.layout.base and wibox.widget.base
Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-09-05 14:28:53 +02:00
Uli Schlachter e67e2813e9 Convert the align layout to the new widget system
Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-09-05 14:28:52 +02:00
Uli Schlachter bcc1751fca fit_widget(): Sanitize the result of :fit()
After this change, fit_widget() enforces that a widget cannot ask for more space
than was offered to it. This also fixes a rounding issue in the flex layout
where its fit function would return too small numbers.

Thanks to this, lots of "XXX" comments in spec/ disappear.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-08-23 17:08:44 +02:00
Uli Schlachter 1ebc34b5e9 Widgets: Also add a context argument to :fit()
Together with the context argument to :draw(), this even allows widgets to have
DPI-dependant size.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-08-12 11:19:48 +02:00
Daniel Hahler 68b0fa243f Add "visible" property for widgets
Widgets with `visible = false` will not be drawn.

Closes https://github.com/awesomeWM/awesome/pull/326.
2015-08-10 23:09:07 +02:00
Uli Schlachter a239b2cac7 Use gears.cache to replace some other caches
Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-07-25 15:08:00 +02:00
Daniel Hahler c26a96177d spec: fix "require" statements for busted 2.0.rc6
Busted now only provides the magic modules `assert`, `spy` etc for
the busted context.  The helper module `spec/wibox/test_utils.lua`
therefore needs to explicitly require them.

Ref: https://github.com/awesomeWM/awesome/pull/139
2015-02-19 12:13:53 +01:00
Uli Schlachter ba50e65b5b Add unit tests
This uses busted (http://olivinelabs.com/busted/) to implement unit testing.
This is wired up to "make check" and/or "make test".

This commit also adds tests for the more complicated parts of the gears and
wibox.layout libraries.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-08-23 22:09:06 +02:00