From 78b8756068532d96ce22b223cffd732805498432 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Mon, 19 Apr 2021 01:13:00 -0700 Subject: [PATCH] place: Split internal logic to be reusable. This will become the base class of a new "tile" container. I also fixed a bug which could cause the output to be blurry for some widget sizes. --- lib/wibox/container/place.lua | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/wibox/container/place.lua b/lib/wibox/container/place.lua index 364afed5..6956d12d 100644 --- a/lib/wibox/container/place.lua +++ b/lib/wibox/container/place.lua @@ -23,13 +23,8 @@ local align_fct = { } align_fct.top, align_fct.bottom = align_fct.left, align_fct.right --- Layout this layout -function place:layout(context, width, height) - - if not self._private.widget then - return - end - +-- Shared with some subclasses like the `tiled` and `scaled` modules. +function place:_layout(context, width, height) local w, h = base.fit_widget(self, context, self._private.widget, width, height) if self._private.content_fill_horizontal then @@ -45,6 +40,21 @@ function place:layout(context, width, height) local x, y = align_fct[halign](w, width), align_fct[valign](h, height) + -- Sub pixels makes everything blurry. This is now what people expect. + x, y = math.floor(x), math.floor(y) + + return x, y, w, h +end + +-- Layout this layout +function place:layout(context, width, height) + + if not self._private.widget then + return + end + + local x, y, w, h = self:_layout(context, width, height) + return { base.place_widget_at(self._private.widget, x, y, w, h) } end