From f12bb57c663c8a208cf87daa97ba70035d07c2b2 Mon Sep 17 00:00:00 2001 From: Aire-One Date: Thu, 11 Nov 2021 19:24:24 +0100 Subject: [PATCH] fix(w.w.template) fit and layout methods The previous implementation for these methods was a naive attempt at making the base widget working. We need to make sure computing the widget's sizes is more robust for complex widget_template definition. --- lib/wibox/widget/template.lua | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/wibox/widget/template.lua b/lib/wibox/widget/template.lua index 02cc5eea3..a64f4940d 100644 --- a/lib/wibox/widget/template.lua +++ b/lib/wibox/widget/template.lua @@ -21,8 +21,22 @@ local template = { queued_updates = {}, } -function template:fit(...) - return self._private.widget:fit(...) +-- Layout this layout +function template:layout(_, width, height) + if not self._private.widget then + return + end + + return { wbase.place_widget_at(self._private.widget, 0, 0, width, height) } +end + +-- Fit this layout into the given area. +function template:fit(context, width, height) + if not self._private.widget then + return 0, 0 + end + + return wbase.fit_widget(self, context, self._private.widget, width, height) end function template:draw(...)