From 21f735600c7adf644d4f54dde81faa7a5a67805b Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 5 Mar 2016 04:52:35 -0500 Subject: [PATCH] dock: Fix a race condition The size wasn't always right --- dock.lua | 31 ++++++++----------------------- item/layout/centerred.lua | 1 - layout/horizontal.lua | 2 -- layout/vertical.lua | 5 +---- 4 files changed, 9 insertions(+), 30 deletions(-) diff --git a/dock.lua b/dock.lua index ec82069..ae061ee 100644 --- a/dock.lua +++ b/dock.lua @@ -44,9 +44,6 @@ end local function adapt_size(data,w,h,screen) local max = get_max_size(data,screen) - -- Get the current size, then compare and ajust - local fit_w,fit_h = data._internal.layout:get_preferred_size({dpi=96,force_values=true},beautiful.default_height) - -- Get the number of items minus the number of widgets -- This can be used to approximate the number of pixel to remove local visible_item = data.visible_row_count - #data._internal.widgets + 1 @@ -56,35 +53,23 @@ local function adapt_size(data,w,h,screen) if orientation == "vertical" and h > max then local wdg_height = data.widget_fit_height_sum --TODO this assume the widget size wont change - -- data.item_height = math.ceil((data.item_height*max)/h) --OLD - data.item_height = math.ceil((max-wdg_height)/visible_item) - w = data.item_height - h = max - data.item_width = w - data.menu_width = w - w = w + data.margins.left+data.margins.right - data.default_width = w - data._internal.private_data.width = w + + data.item_height = math.ceil((max-wdg_height)/visible_item) + data.item_width = data.item_height + data.default_width = data.item_width + elseif orientation == "horizontal" and w > max then --TODO merge this with above - local wdg_width = data.widget_fit_width_sum data.item_width = math.ceil((data.item_height*max)/w) - data._internal.private_data = data.item_width - w = max h = data.item_width data.item_height = h - data.menu_height = h - h = h + data.margins.bottom+data.margins.top - -- data.default_width = h end if data.icon_size and data.icon_size > w then data.icon_size = w end - data._internal.margin:emit_signal("widget::layout_changed") - data._internal.margin:emit_signal("widget::redraw_needed") - - return w == 0 and 1 or w, h == 0 and 1 or h + data._internal.layout:emit_signal("widget::layout_changed") + data._internal.layout:emit_signal("widget::redraw_needed" ) end -- Create the main wibox (lazy-loading) @@ -127,7 +112,7 @@ local function setup_drawable(data) function data:set_visible(value) if internal.w then - internal.w.visible = value or false + internal.w.visible = value or false end end diff --git a/item/layout/centerred.lua b/item/layout/centerred.lua index 5cdd4e6..ee4eeea 100644 --- a/item/layout/centerred.lua +++ b/item/layout/centerred.lua @@ -1,7 +1,6 @@ local setmetatable = setmetatable local wibox = require( "wibox" ) local util = require( "awful.util" ) -local horizontal = require( "radical.item.layout.horizontal" ) local margins2 = require( "radical.margins" ) local common = require( "radical.item.common" ) diff --git a/layout/horizontal.lua b/layout/horizontal.lua index 975fbf2..c59d631 100644 --- a/layout/horizontal.lua +++ b/layout/horizontal.lua @@ -50,8 +50,6 @@ local function new(data) w,h = data.rowcount*(data.item_width or data.default_width),data.item_height end - data:emit_signal("layout_size",w,h) - return w,h end diff --git a/layout/vertical.lua b/layout/vertical.lua index b308fdd..aeec78a 100644 --- a/layout/vertical.lua +++ b/layout/vertical.lua @@ -53,10 +53,7 @@ end local function new(data) local function real_fit(self,context,o_w,o_h,force_values) - if not data.visible then return 1,1 end - local w,h = compute_geo(data,o_w,o_h,force_values) - data:emit_signal("layout_size",w,h) - return w,h + return compute_geo(data,o_w,o_h,force_values) end -- Create the scroll widgets