smart_wibox: Do not call set_position when the area reamin the same.

This is a band-aid on top of deeper issues when layout_changed is
wrongly called. This should prevent menus moving in random places
when the mouse is moved. Note that this commit wont stop them from
moving when their size really change.

This is harder to fix as all the "outside of the workarea" checks
still need to be performed and in many cases, such as async loaded
menus, the move itself is really necessary while in others it is
unwanted.
This commit is contained in:
Emmanuel Lepage Vallee 2016-08-09 16:20:35 -04:00
parent 3488622ac3
commit a58ac33afb
1 changed files with 5 additions and 1 deletions

View File

@ -71,9 +71,13 @@ function main_widget:layout(context, width, height)
if self.widget then
local w, h = wibox.widget.base.fit_widget(self, context, self.widget, 9999, 9999)
glib.idle_add(glib.PRIORITY_HIGH_IDLE, function()
local prev_geo = self._wb:geometry()
self._wb.width = math.ceil(w or 1)
self._wb.height = math.ceil(h or 1)
if self._wb.width ~= prev_geo.width and self._wb.height ~= prev_geo.height then
set_position(self._wb)
end
end)
return { wibox.widget.base.place_widget_at(self.widget, 0, 0, width, height) }
end