More bug fixes

This is a step forward to stabilize Radical again. Most of impl/ and widgets/
code is still a mess, but the other modules slowly start to be maintainable
again. The road is still long before the Radical code is good enough to go
into Awesome. It will get there, eventually.
This commit is contained in:
Emmanuel Lepage Vallee 2016-06-25 02:13:56 -04:00
parent f3124b761d
commit 825ff024ef
7 changed files with 35 additions and 44 deletions

View File

@ -81,7 +81,8 @@ local function filter(data)
-- * Is the item matching the filter
--
for k,v in ipairs(data.items) do
-- Do not count widgets as item
if not v._private_data.is_widget then
v.widget.visible = (not fs or v.text and v.text:lower():find(fs) ~= nil)
and k >= start_at and visible_counter < max_items
@ -94,6 +95,9 @@ local function filter(data)
if visible_counter >= max_items then break end
end
end
local changed = data._internal.visible_item_count ~= visible_counter
data._internal.visible_item_count = visible_counter
@ -104,6 +108,10 @@ local function filter(data)
n.selected = true
end
end
if changed then
data:emit_signal("visible_item_count::changed", visible_counter)
end
end
-- Get the number of visible rows
@ -237,6 +245,7 @@ local function add_widget(data,widget,args)
local item,private_data = object({
private_data = {
widget = widget,
is_widget = true,
selected = false,
},
force_private = {

View File

@ -44,7 +44,7 @@ local function adapt_size(data,w,h,screen)
-- 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
local visible_item = data.visible_row_count
local orientation = "vertical"
@ -97,7 +97,8 @@ local function get_wibox(data, screen)
aplace.left(w, {
attach = true,
update_workarea = beautiful.dock_always_show
update_workarea = beautiful.dock_always_show,
honor_workarea = false,
})
return w

View File

@ -18,13 +18,11 @@ local surface = require( "gears.surface" )
local tracker = require( "radical.impl.taglist.tracker" )
local tag_menu = require( "radical.impl.taglist.tag_menu" )
local CLONED = 100
local HIGHLIGHTED = -2
local EMPTY = 412345
local last_idx = EMPTY
theme.register_color(CLONED , "cloned" , "cloned" , true )
theme.register_color(HIGHLIGHTED , "highlight" , "highlight" , true )
theme.register_color(EMPTY , "empty" , "empty" , true )
@ -112,22 +110,6 @@ local function create_item(t,s)
item.tw = tw
if tag.getproperty(t,"clone_of") then
item.state[CLONED] = true
end
-- menu:move(item,index)
menu:connect_signal("button::press",function(_,_,button_id,mod,geo)
if module.buttons and module.buttons[button_id] then
if item.tag[1] then
assert(type(item.tag[1]) == "tag")
module.buttons[button_id](item.tag[1],menu,item,button_id,mod,geo)
else
print("Invalid tag")
end
end
end)
item._internal.screen = capi.screen[s]
item.state[radical.base.item_flags.SELECTED] = t.selected or nil
cache[t] = item
@ -277,7 +259,7 @@ local function new(s)
item_border_width = beautiful.taglist_item_border_width ,
-- fkeys_prefix = true,
}
for k,v in ipairs {"hover","used","urgent","cloned","changed","highlight"} do
for k,v in ipairs {"hover","used","urgent","changed","highlight"} do
args["bg_"..v] = beautiful["taglist_bg_"..v]
args["bgimage_"..v] = beautiful["taglist_bgimage_"..v]
args["fg_"..v] = beautiful["taglist_fg_"..v]
@ -295,9 +277,6 @@ local function new(s)
create_item(t,capi.screen[s])
end
-- Per screen signals
-- tag.attached_connect_signal(screen, "property::hide", ut)!
instances[capi.screen[s]]:connect_signal("button::press",function(m,item,button_id,mod)
if module.buttons and module.buttons[button_id] then
module.buttons[button_id](item.tag[1],m,item,button_id,mod)

View File

@ -153,9 +153,12 @@ local function new_item(data,args)
item["button"..i] = args["button"..i]
end
-- Use _internal to avoid the radical.object trigger
data._internal.visible_item_count = (data._internal.visible_item_count or 0) + 1
item._internal.f_key = data._internal.visible_item_count
-- Invalidate the filter when there is still room for new items
-- this is slow, but more reliable than it was before
if data._internal.visible_item_count
and data._internal.visible_item_count < (data.max_items or 9999999) then
data._internal.visible_item_count = nil
end
-- Need to be done before painting
data._internal.items[#data._internal.items+1] = {}

View File

@ -14,10 +14,10 @@ local module = {
local function widget_draw(self, context, cr, width, height)
if not self.background then
if not self._private.background then
cr:set_source_rgba(0,0,0,0)
else
cr:set_source(color(self.background))
cr:set_source(color(self._private.background))
end
shape.rounded_rect(cr ,width, height, 3)
@ -34,7 +34,7 @@ local function widget_draw(self, context, cr, width, height)
end
local function draw_width_shadow(self, context, cr, width, height)
if not self.background then return end
if not self._private.background then return end
cr:save()
cr:reset_clip()
@ -62,7 +62,7 @@ local function shadow(item)
theme.update_colors(item)
end
module.shadow = {}
module.shadow = {need_full_repaint = true}
setmetatable(module.shadow, { __call = function(_, ...) return shadow(...) end })
return setmetatable(module, { __call = function(_, ...) return draw(...) end })

View File

@ -41,11 +41,12 @@ local function compute_geo(data,width,height,force_values)
local _,sh = data._internal.suf_l:get_preferred_size()
local _,ph = data._internal.pref_l:get_preferred_size()
if not data._internal.has_widget then
return w, visblerow*data.item_height + ph + sh
else
local sumh = data.widget_fit_height_sum
local h = (visblerow-#data._internal.widgets)*data.item_height + sumh
local h = visblerow*data.item_height + sumh
return w,h
end
end

View File

@ -29,7 +29,6 @@ local main_widget = {}
-- This (try to) avoid going offscreen
local function set_position(self)
local pf = rawget(self, "_placement")
if pf == false then return end
if pf then
@ -228,7 +227,6 @@ end
-- @tparam[opt=next_to] function|string|boolean The placement function or name
-- (or false to disable placement)
function wb_func:set_placement(f)
if type(f) == "string" then
f = placement[f]
end
@ -280,7 +278,7 @@ local function create_auto_resize_widget(self, wdg, args)
end
for k,v in ipairs{"shape_border_color", "shape_border_width", "placement"} do
if args[v] then
if args[v] ~= nil then
w["set_"..v](w, args[v])
end
end