Bug fixes
This commit is contained in:
parent
72e9fea65b
commit
1662a013dc
5
bar.lua
5
bar.lua
|
@ -10,7 +10,7 @@ local fkey = require( "radical.widgets.fkey" )
|
|||
local button = require( "awful.button" )
|
||||
local checkbox = require( "radical.widgets.checkbox" )
|
||||
local item_style = require( "radical.item.style.arrow_single" )
|
||||
local vertical = require( "radical.layout.vertical" )
|
||||
-- local vertical = require( "radical.layout.vertical" )
|
||||
local item_layout= require( "radical.item.layout.horizontal" )
|
||||
|
||||
local capi,module = { mouse = mouse , screen = screen, keygrabber = keygrabber },{}
|
||||
|
@ -122,7 +122,7 @@ end
|
|||
|
||||
local function setup_item(data,item,args)
|
||||
-- Add widgets
|
||||
data._internal.layout:add(item_layout(item,data,args))
|
||||
data._internal.layout:add(data.item_layout(item,data,args))
|
||||
if data.select_on == base.event.HOVER then
|
||||
item.widget:connect_signal("mouse::enter", function() item.selected = true end)
|
||||
item.widget:connect_signal("mouse::leave", function() item.selected = false end)
|
||||
|
@ -143,6 +143,7 @@ local function new(args)
|
|||
args.internal.setup_drawable = args.internal.setup_drawable or setup_drawable
|
||||
args.internal.setup_item = args.internal.setup_item or setup_item
|
||||
args.item_style = args.item_style or item_style
|
||||
args.item_layout = args.item_layout or item_layout
|
||||
args.sub_menu_on = args.sub_menu_on or base.event.BUTTON1
|
||||
local ret = base(args)
|
||||
ret:connect_signal("clear::menu",function(_,vis)
|
||||
|
|
4
base.lua
4
base.lua
|
@ -266,8 +266,8 @@ local function new(args)
|
|||
separator_color = args.separator_color or beautiful.menu_separator_color or args.border_color or beautiful.menu_border_color or beautiful.border_color or "#333333",
|
||||
item_height = args.item_height or beautiful.menu_height or 30,
|
||||
item_width = args.item_width or nil,
|
||||
width = args.width or beautiful.menu_width or 130,
|
||||
default_width = args.width or beautiful.menu_width or 130,
|
||||
width = args.width or args.menu_width or beautiful.menu_width or 130,
|
||||
default_width = args.width or args.menu_width or beautiful.menu_width or 130,
|
||||
icon_size = args.icon_size or nil,
|
||||
auto_resize = args.auto_resize or true,
|
||||
parent_geometry = args.parent or nil,
|
||||
|
|
|
@ -55,7 +55,7 @@ end
|
|||
|
||||
local function create_item(t,s)
|
||||
local menu = instances[s]
|
||||
if not menu then return end
|
||||
if not menu or not t then return end
|
||||
local w = wibox.layout.fixed.horizontal()
|
||||
local icon = tag.geticon(t)
|
||||
local ib = wibox.widget.imagebox()
|
||||
|
@ -90,7 +90,11 @@ local function create_item(t,s)
|
|||
|
||||
menu:connect_signal("button::press",function(menu,item,button_id,mod)
|
||||
if module.buttons and module.buttons[button_id] then
|
||||
module.buttons[button_id](item.tag[1],menu,item,button_id,mod)
|
||||
if item.tag[1] then
|
||||
module.buttons[button_id](item.tag[1],menu,item,button_id,mod)
|
||||
else
|
||||
print("Invalid tag")
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
@ -127,15 +131,24 @@ local function tag_activated(t)
|
|||
end
|
||||
|
||||
local function tag_added(t,b)
|
||||
if t then
|
||||
local s = tag.getscreen(t)
|
||||
if not cache[t] then
|
||||
create_item(t,s)
|
||||
elseif cache[t]._internal.screen ~= s then
|
||||
instances[cache[t]._internal.screen]:remove(cache[t])
|
||||
instances[s]:append(cache[t])
|
||||
cache[t]._internal.screen = s
|
||||
if not t then return end
|
||||
|
||||
local s = tag.getscreen(t)
|
||||
local item = cache[t]
|
||||
|
||||
-- Creating items when there is no screen cause random behaviors
|
||||
if not item and s then
|
||||
create_item(t,s)
|
||||
elseif item._internal.screen ~= s then
|
||||
if item._internal.screen then
|
||||
instances[item._internal.screen]:remove(item)
|
||||
end
|
||||
if s then
|
||||
instances[s]:append(item)
|
||||
end
|
||||
|
||||
--Allow nil
|
||||
item._internal.screen = s
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -215,10 +228,10 @@ local function new(s)
|
|||
local track = tracker(s)
|
||||
|
||||
local args = {
|
||||
item_style = radical.item.style.arrow_prefix,
|
||||
item_style = beautiful.taglist_theme or radical.item.style.arrow_prefix,
|
||||
select_on = radical.base.event.NEVER,
|
||||
fg = beautiful.tasglist_fg or beautiful.fg_normal,
|
||||
bg = beautiful.tasglist_bg or beautiful.bg_normal,
|
||||
fg = beautiful.taglist_fg or beautiful.fg_normal,
|
||||
bg = beautiful.taglist_bg or beautiful.bg_normal,
|
||||
bg_focus = beautiful.taglist_bg_selected,
|
||||
fg_focus = beautiful.taglist_fg_selected,
|
||||
-- fkeys_prefix = true,
|
||||
|
|
1
init.lua
1
init.lua
|
@ -80,6 +80,7 @@ return {
|
|||
style = require( "radical.style" ),
|
||||
widgets = require( "radical.widgets" ),
|
||||
item = require( "radical.item" ),
|
||||
-- dock = require( "radical.dock" ),
|
||||
bar = bar,
|
||||
flexbar = bar.flex,
|
||||
tooltip = tooltip
|
||||
|
|
|
@ -100,7 +100,7 @@ local function new_item(data,args)
|
|||
local item,private_data = object({
|
||||
private_data = {
|
||||
text = args.text or "" ,
|
||||
height = args.height or data.item_height or beautiful.menu_height or 30 ,
|
||||
-- height = args.height or data.item_height or beautiful.menu_height or 30 ,
|
||||
width = args.width or nil ,
|
||||
icon = args.icon or nil ,
|
||||
prefix = args.prefix or "" ,
|
||||
|
@ -131,7 +131,12 @@ local function new_item(data,args)
|
|||
item._private_data = private_data
|
||||
item._internal = {}
|
||||
theme.setup_item_colors(data,item,args)
|
||||
item.get_y = function() return (args.y and args.y >= 0) and args.y or data.height - (data.margins.top or data.border_width) - data.item_height end --Hack around missing :fit call for last item
|
||||
item.get_y = function()
|
||||
return (args.y and args.y >= 0) and args.y or data.height - (data.margins.top or data.border_width) - data.item_height --Hack around missing :fit call for last item
|
||||
end
|
||||
item.get_height = function()
|
||||
return args.height or data.item_height or beautiful.menu_height or 30
|
||||
end
|
||||
item.get_bg = function()
|
||||
return data.bg
|
||||
end
|
||||
|
|
|
@ -11,7 +11,21 @@ local module = {}
|
|||
|
||||
local function icon_fit(data,...)
|
||||
local w,h = wibox.widget.imagebox.fit(...)
|
||||
return w,data.icon_size or h
|
||||
--Try to retermine the limiting factor
|
||||
if data._internal.layout.dir == "y" then
|
||||
return data.icon_size or w,data.icon_size or h
|
||||
else
|
||||
return w,data.icon_size or h
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local function icon_draw(self,w, cr, width, height)
|
||||
local w,h = wibox.widget.imagebox.fit(self,width,height)
|
||||
cr:save()
|
||||
cr:translate((width-w)/2,0)
|
||||
wibox.widget.imagebox.draw(self,w, cr, width, height)
|
||||
cr:restore()
|
||||
end
|
||||
|
||||
local function create_item(item,data,args)
|
||||
|
@ -30,12 +44,14 @@ local function create_item(item,data,args)
|
|||
local text_w = wibox.widget.textbox()
|
||||
text_w:set_align("center")
|
||||
item._private_data._fit = wibox.widget.background.fit
|
||||
m.fit = function(...)
|
||||
if item.visible == false or item._filter_out == true then
|
||||
return 0,0
|
||||
end
|
||||
return data._internal.layout.item_fit(data,item,...)
|
||||
end
|
||||
-- m.fit = function(...)
|
||||
-- if item.visible == false or item._filter_out == true then
|
||||
-- return 0,0
|
||||
-- end
|
||||
-- local w,h = data._internal.layout.item_fit(data,item,...)
|
||||
-- print("item_fit",w,h)
|
||||
-- return data._internal.layout.item_fit(data,item,...)
|
||||
-- end
|
||||
|
||||
if data.fkeys_prefix == true then
|
||||
local pref = wibox.widget.textbox()
|
||||
|
@ -52,26 +68,26 @@ local function create_item(item,data,args)
|
|||
l:add(args.prefix_widget)
|
||||
end
|
||||
|
||||
local icon_flex = wibox.layout.align.horizontal()
|
||||
local icon = wibox.widget.imagebox()
|
||||
icon.fit = function(...) return icon_fit(data,...) end
|
||||
icon.draw = icon_draw
|
||||
icon._data = data
|
||||
icon.set_image = horizontal.set_icon
|
||||
if args.icon then
|
||||
icon:set_image(args.icon)
|
||||
end
|
||||
icon_flex:set_middle(icon)
|
||||
l:add(icon_flex)
|
||||
|
||||
l:add(icon)
|
||||
l:add(text_w)
|
||||
if item._private_data.sub_menu_f or item._private_data.sub_menu_m then
|
||||
local subArrow = wibox.widget.imagebox() --TODO, make global
|
||||
subArrow.fit = function(box, w, h) return subArrow._image:get_width(),item.height end
|
||||
subArrow:set_image( beautiful.menu_submenu_icon )
|
||||
lr:add(subArrow)
|
||||
bg.fit = function(box,w,h,...)
|
||||
args.y = data.height-h-data.margins.top
|
||||
return wibox.widget.background.fit(box,w,h,...)
|
||||
end
|
||||
end
|
||||
bg.fit = function(box,w,h,...)
|
||||
-- args.y = data.height-h-data.margins.top --TODO dead code?
|
||||
return data._internal.layout.item_fit(data,item,box,w,h)
|
||||
end
|
||||
if item.checkable then
|
||||
item.get_checked = function()
|
||||
|
|
|
@ -50,11 +50,16 @@ local function draw(item,args)
|
|||
end
|
||||
|
||||
local ih = item.height
|
||||
local iw = item.width
|
||||
if iw and iw > ih then
|
||||
ih = iw
|
||||
end
|
||||
if not focussed or not focussed[ih] then
|
||||
if not focussed then
|
||||
focussed,default={},{}
|
||||
end
|
||||
local bc = item.border_color
|
||||
|
||||
focussed[ih] = gen(ih,item.bg_focus,bc)
|
||||
default [ih] = gen(ih,item.bg,bc)
|
||||
end
|
||||
|
|
|
@ -81,7 +81,9 @@ local function setup_event(data,item,args)
|
|||
data:connect_signal("parent_geometry::changed",function(_,vis)
|
||||
local fit_w,fit_h = data._internal.layout:fit()
|
||||
data.height = fit_h
|
||||
data.style(data)
|
||||
if data.style then
|
||||
data.style(data)
|
||||
end
|
||||
end)
|
||||
item.widget:buttons( util.table.join(unpack(buttons)))
|
||||
end
|
||||
|
@ -93,7 +95,9 @@ function module:setup_item(data,item,args)
|
|||
local fit_w,fit_h = data._internal.layout:fit()
|
||||
data.width = fit_w
|
||||
data.height = fit_h
|
||||
data.style(data)
|
||||
if data.style then
|
||||
data.style(data)
|
||||
end
|
||||
local text_w = item._internal.text_w
|
||||
local icon_w = item._internal.icon_w
|
||||
|
||||
|
@ -143,11 +147,14 @@ local function new(data)
|
|||
l.fit = function(a1,a2,a3)
|
||||
local result,r2 = wibox.layout.fixed.fit(a1,99999,99999)
|
||||
-- return data.rowcount*(data.item_width or data.default_width),data.item_height
|
||||
local w,h
|
||||
if data.auto_resize and data._internal.largest_item_h then
|
||||
return data.rowcount*(data.item_width or data.default_width),data._internal.largest_item_h_v > data.item_height and data._internal.largest_item_h_v or data.item_height
|
||||
w,h = data.rowcount*(data.item_width or data.default_width),data._internal.largest_item_h_v > data.item_height and data._internal.largest_item_h_v or data.item_height
|
||||
else
|
||||
return data.rowcount*(data.item_width or data.default_width),data.item_height
|
||||
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
|
||||
l.add = function(l,item)
|
||||
return wibox.layout.fixed.add(l,item.widget)
|
||||
|
|
|
@ -52,13 +52,14 @@ function module:setup_key_hooks(data)
|
|||
end
|
||||
|
||||
--Get preferred item geometry
|
||||
local function item_fit(data,item,...)
|
||||
local w, h = item._internal.cache_w or 1,item._internal.cache_h or 1
|
||||
local function item_fit(data,item,self,width,height)
|
||||
local w, h = 0,0--item._internal.cache_w or 1,item._internal.cache_h or 1
|
||||
if data.visible then
|
||||
w, h = item._private_data._fit(...)
|
||||
w, h = item._private_data._fit(self,width,height)
|
||||
item._internal.pix_cache = {} --Clear the pimap cache
|
||||
end
|
||||
return w, item._private_data.height or h
|
||||
|
||||
return w, item.height or h
|
||||
end
|
||||
|
||||
-- As of July 2013, LGI is too slow to redraw big menus at ok speed
|
||||
|
@ -253,8 +254,10 @@ local function new(data)
|
|||
real_l.fit = function(a1,a2,a3)
|
||||
if not data.visible then return 1,1 end
|
||||
local result,r2 = wibox.layout.fixed.fit(a1,99999,99999)
|
||||
local total = data._total_item_height
|
||||
return compute_geo(data)
|
||||
local w,h = compute_geo(data)
|
||||
print("MIT",w,h)
|
||||
data:emit_signal("layout_size",w,h)
|
||||
return w,h
|
||||
end
|
||||
real_l.add = function(real_l,item)
|
||||
return wibox.layout.fixed.add(l,item.widget)
|
||||
|
|
|
@ -82,6 +82,7 @@ end
|
|||
local function _set_direction(data,direction)
|
||||
local height,width = data.height,data.width
|
||||
local hash = height*1000+width
|
||||
print("DIR",direction,hash,data._arrow_x,data._internal.last_size)
|
||||
|
||||
-- Try not to waste time for nothing
|
||||
if data._internal._last_direction == direction..(hash) then return end
|
||||
|
@ -128,7 +129,7 @@ local function get_arrow_x(data)
|
|||
local hash = height*1000+width
|
||||
if not data._arrow_x or data._internal.last_size ~= hash then
|
||||
gen_arrow_x(data,direction)
|
||||
data._internal.last_size = hash
|
||||
-- data._internal.last_size = hash
|
||||
end
|
||||
return data._arrow_x
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue