Fix multiple minor bugs/regressions
This commit is contained in:
parent
e475964238
commit
72e9fea65b
7
base.lua
7
base.lua
|
@ -98,6 +98,13 @@ local function filter(data)
|
|||
end
|
||||
data._total_item_height = visible_counter
|
||||
local w,h = data._internal.layout:fit()
|
||||
-- Make sure to select an item
|
||||
if data._current_item and data._current_item._filter_out then
|
||||
local n = data.next_item
|
||||
if n then
|
||||
n.selected = true
|
||||
end
|
||||
end
|
||||
data.height = h
|
||||
end
|
||||
end
|
||||
|
|
|
@ -89,7 +89,7 @@ local function set_position(self)
|
|||
if (self.direction == "left") or (self.direction == "right") then
|
||||
ret = {x=drawable_geom.x+((self.direction == "right") and - self.width or drawable_geom.width),y=drawable_geom.y+parent.y+((self.arrow_type ~= base.arrow_type.NONE) and parent.height/2-(self.arrow_x or 20)-6 or 0)}
|
||||
else
|
||||
ret = {x=drawable_geom.x+parent.x-((self.arrow_type ~= base.arrow_type.NONE) and (self._arrow_x or 20)+11-parent.width/2 or 0),y=(self.direction == "bottom") and drawable_geom.y-self.height or drawable_geom.y+drawable_geom.height}
|
||||
ret = {x=drawable_geom.x+parent.x-((self.arrow_type ~= base.arrow_type.NONE) and (self.arrow_x or 20)+11-parent.width/2 or 0),y=(self.direction == "bottom") and drawable_geom.y-self.height or drawable_geom.y+drawable_geom.height}
|
||||
end
|
||||
elseif prefx ~= 0 or prefy ~= 0 then
|
||||
ret = capi.mouse.coords()
|
||||
|
@ -121,6 +121,7 @@ local function set_position(self)
|
|||
elseif ret.x < 0 then
|
||||
ret.x = 0
|
||||
end
|
||||
|
||||
change_geometry_idle(self,ret.x,ret.y - 2*(self.wibox.border_width or 0))
|
||||
end
|
||||
|
||||
|
|
|
@ -22,13 +22,15 @@ local fallback_layouts = {
|
|||
suits.magnifier
|
||||
}
|
||||
|
||||
local function createTagList(aScreen)
|
||||
local function createTagList(aScreen,args)
|
||||
if not tag_list then
|
||||
tag_list = require("radical.impl.taglist")
|
||||
end
|
||||
local tagList = radical.context({autodiscard = true})
|
||||
for _, v in ipairs(awful.tag.gettags(aScreen)) do
|
||||
local i = tagList:add_item({text = v.name,icon=awful.tag.geticon(v)})
|
||||
args.text,args.icon = v.name,awful.tag.geticon(v)
|
||||
local i = tagList:add_item(args)
|
||||
i._tag = v
|
||||
i:connect_signal("mouse::enter",function()
|
||||
tag_list.highlight(v)
|
||||
end)
|
||||
|
@ -41,13 +43,13 @@ local function createTagList(aScreen)
|
|||
return tagList
|
||||
end
|
||||
|
||||
function module.listTags()
|
||||
function module.listTags(args)
|
||||
if capi.screen.count() == 1 then
|
||||
return createTagList(1)
|
||||
return createTagList(1,args or {})
|
||||
else
|
||||
local screenSelect = radical.context(({autodiscard = true}))
|
||||
for i=1, capi.screen.count() do
|
||||
screenSelect:add_item({text="Screen "..i , sub_menu = createTagList(i)})
|
||||
screenSelect:add_item({text="Screen "..i , sub_menu = createTagList(i,args or {})})
|
||||
end
|
||||
return screenSelect
|
||||
end
|
||||
|
|
|
@ -18,6 +18,10 @@ Plus, it inherit Radical style and layouts engines for both item and style, so
|
|||
this module could technically be used as a box menu or something like that
|
||||
without modifications.
|
||||
|
||||
### Options
|
||||
|
||||
taglist_watch_name_changes | Make the tag state `changed` if a client title change
|
||||
|
||||
### Beautiful options
|
||||
|
||||
taglist_bg_selected
|
||||
|
|
|
@ -14,6 +14,7 @@ local taglist = nil
|
|||
local module = {}
|
||||
|
||||
local current_client = nil
|
||||
local current_pos = nil
|
||||
|
||||
local classes = {}
|
||||
local global = {}
|
||||
|
@ -40,14 +41,14 @@ local function persistence_menu(ext,position)
|
|||
per_glob = per_m:add_item{text= "All clients" ,checkable = true , button1 = function()
|
||||
local i1 = taglist.item(current_client)
|
||||
if i1 and (not i1._internal.has_widget or not i1._internal.has_widget[ext]) then
|
||||
read_add(i1,ext(current_client),position)
|
||||
read_add(i1,ext(current_client),current_pos)
|
||||
i1._internal.has_widget = i1._internal.has_widget or {}
|
||||
i1._internal.has_widget[ext] = true
|
||||
end
|
||||
for k,v in ipairs(capi.client.get()) do
|
||||
local i2 = taglist.item(v)
|
||||
if i2 and (not i2._internal.has_widget or not i2._internal.has_widget[ext]) then
|
||||
read_add(i2,ext(v),position)
|
||||
read_add(i2,ext(v),current_pos)
|
||||
i2._internal.has_widget = i2._internal.has_widget or {}
|
||||
i2._internal.has_widget[ext] = true
|
||||
end
|
||||
|
@ -57,7 +58,7 @@ local function persistence_menu(ext,position)
|
|||
per_this = per_m:add_item{text= "This client only" ,checkable = true, button1 = function()
|
||||
local i1 = taglist.item(current_client)
|
||||
if i1 and (not i1._internal.has_widget or not i1._internal.has_widget[ext]) then
|
||||
read_add(i1,ext(current_client),position)
|
||||
read_add(i1,ext(current_client),current_pos)
|
||||
i1._internal.has_widget = i1._internal.has_widget or {}
|
||||
i1._internal.has_widget[ext] = true
|
||||
end
|
||||
|
@ -86,10 +87,11 @@ end
|
|||
|
||||
local ext_list_m = nil
|
||||
local function extension_list_menu(position)
|
||||
current_pos = position
|
||||
if not ext_list_m then
|
||||
ext_list_m = radical.context{}
|
||||
for k,v in pairs(extension_list) do
|
||||
ext_list_m:add_item{text=k,sub_menu=function() return persistence_menu(v,position) end}
|
||||
ext_list_m:add_item{text=k,sub_menu=function() return persistence_menu(v,current_pos) end}
|
||||
end
|
||||
end
|
||||
return ext_list_m
|
||||
|
|
|
@ -47,7 +47,7 @@ module.buttons = { [1] = awful.tag.viewonly,
|
|||
|
||||
local function index_draw(self,w, cr, width, height)
|
||||
cr:save()
|
||||
cr:set_source(color(beautiful.bg_normal))
|
||||
cr:set_source(color(beautiful.taglist_fg_prefix or beautiful.fg_normal))
|
||||
local d = wibox.widget.textbox._draw or wibox.widget.textbox.draw
|
||||
d(self,wibox, cr, width, height)
|
||||
cr:restore()
|
||||
|
@ -90,14 +90,15 @@ 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.client,menu,item,button_id,mod)
|
||||
module.buttons[button_id](item.tag[1],menu,item,button_id,mod)
|
||||
end
|
||||
end)
|
||||
|
||||
item._internal.screen = s
|
||||
item.state[radical.base.item_flags.SELECTED] = t.selected or nil
|
||||
cache[t] = item
|
||||
item.tag = t
|
||||
item.tag = setmetatable({}, { __mode = 'v' })
|
||||
item.tag[1] = t
|
||||
return item
|
||||
end
|
||||
|
||||
|
@ -110,6 +111,14 @@ local function track_used(c,t)
|
|||
end
|
||||
end
|
||||
|
||||
local function track_title(c)
|
||||
for _,t in ipairs(c:tags()) do
|
||||
if t.selected ~= true and cache[t] then
|
||||
cache[t].state[radical.base.item_flags.CHANGED] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function tag_activated(t)
|
||||
if not t.activated and cache[t] then
|
||||
instances[cache[t]._internal.screen]:remove(cache[t])
|
||||
|
@ -142,22 +151,12 @@ local function select(t)
|
|||
end
|
||||
end
|
||||
|
||||
capi.tag.add_signal("property::urgent")
|
||||
local function urgent_callback(c)
|
||||
local modif = c.urgent == true and 1 or -1
|
||||
for k,t in ipairs(c:tags()) do
|
||||
local current = (awful.tag.getproperty(t,"urgent") or 0)
|
||||
local item = cache[t] or create_item(t,tag.getscreen(t))
|
||||
if current + modif < 0 then
|
||||
awful.tag.setproperty(t,"urgent",0)
|
||||
item.state[radical.base.item_flags.URGENT] = nil
|
||||
else
|
||||
awful.tag.setproperty(t,"urgent",current + modif)
|
||||
if not t.selected then
|
||||
item.state[radical.base.item_flags.URGENT] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
local function urgent_callback(t)
|
||||
local modif = tag.getproperty(t,"urgent")
|
||||
local item = cache[t] or create_item(t,tag.getscreen(t))
|
||||
if item then
|
||||
item.state[radical.base.item_flags.URGENT] = modif and true or nil
|
||||
end
|
||||
end
|
||||
|
||||
local is_init = false
|
||||
|
@ -165,12 +164,15 @@ local function init()
|
|||
if is_init then return end
|
||||
|
||||
-- Global signals
|
||||
capi.client.connect_signal("tagged", track_used)
|
||||
capi.client.connect_signal("untagged", track_used)
|
||||
capi.client.connect_signal("unmanage", track_used)
|
||||
capi.client.connect_signal("property::urgent" , urgent_callback )
|
||||
capi.tag.connect_signal("property::activated",tag_activated)
|
||||
capi.tag.connect_signal("property::screen", tag_added)
|
||||
capi.client.connect_signal("tagged" , track_used )
|
||||
capi.client.connect_signal("untagged" , track_used )
|
||||
capi.client.connect_signal("unmanage" , track_used )
|
||||
capi.tag.connect_signal("property::activated", tag_activated )
|
||||
capi.tag.connect_signal("property::screen" , tag_added )
|
||||
capi.tag.connect_signal("property::urgent" , urgent_callback )
|
||||
if module.taglist_watch_name_changes then
|
||||
capi.client.connect_signal("property::name", track_title )
|
||||
end
|
||||
|
||||
-- Property bindings
|
||||
capi.tag.connect_signal("property::name", function(t)
|
||||
|
@ -239,7 +241,7 @@ local function new(s)
|
|||
|
||||
instances[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,m,item,button_id,mod)
|
||||
module.buttons[button_id](item.tag[1],m,item,button_id,mod)
|
||||
end
|
||||
end)
|
||||
|
||||
|
|
|
@ -108,12 +108,13 @@ local function persistence_menu(ext,position)
|
|||
return per_m
|
||||
end
|
||||
|
||||
local ext_list_m = nil
|
||||
local ext_list_m,cur_pos = nil
|
||||
local function extension_list_menu(position)
|
||||
cur_pos = position
|
||||
if not ext_list_m then
|
||||
ext_list_m = radical.context{}
|
||||
for k,v in pairs(extension_list) do
|
||||
ext_list_m:add_item{text=k,sub_menu=function() return persistence_menu(v,position) end}
|
||||
ext_list_m:add_item{text=k,sub_menu=function() return persistence_menu(v,cur_pos) end}
|
||||
end
|
||||
end
|
||||
return ext_list_m
|
||||
|
|
|
@ -122,7 +122,7 @@ function module.setup_event(data,item,widget)
|
|||
|
||||
item.state[4] = true
|
||||
data:emit_signal("button::press",item,id,mods_invert)
|
||||
item:emit_signal("button::press",item,id,mods_invert)
|
||||
item:emit_signal("button::press",data,id,mods_invert)
|
||||
end)
|
||||
widget:connect_signal("button::release",function(_,__,___,id,mod)
|
||||
local mods_invert = {}
|
||||
|
@ -131,15 +131,15 @@ function module.setup_event(data,item,widget)
|
|||
end
|
||||
item.state[4] = nil
|
||||
data:emit_signal("button::release",item,id,mods_invert)
|
||||
item:emit_signal("button::release",item,id,mods_invert)
|
||||
item:emit_signal("button::release",data,id,mods_invert)
|
||||
end)
|
||||
widget:connect_signal("mouse::enter",function(b,t)
|
||||
data:emit_signal("mouse::enter",item)
|
||||
item:emit_signal("mouse::enter",item)
|
||||
item:emit_signal("mouse::enter",data)
|
||||
end)
|
||||
widget:connect_signal("mouse::leave",function(b,t)
|
||||
data:emit_signal("mouse::leave",item)
|
||||
item:emit_signal("mouse::leave",item)
|
||||
item:emit_signal("mouse::leave",data)
|
||||
end)
|
||||
|
||||
-- Always tracking mouse::move is expensive, only do it when necessary
|
||||
|
|
|
@ -54,7 +54,7 @@ local function do_gen_menu_top(data, width, height, radius,padding,args)
|
|||
return img
|
||||
end
|
||||
|
||||
local function get_arrow_x(data,direction)
|
||||
local function gen_arrow_x(data,direction)
|
||||
local at = data.arrow_type
|
||||
local par_center_x = data.parent_geometry and (data.parent_geometry.x + data.parent_geometry.width/2) or -1
|
||||
local par_center_y = data.parent_geometry and (data.parent_geometry.y + data.parent_geometry.height/2) or -1
|
||||
|
@ -63,11 +63,11 @@ local function get_arrow_x(data,direction)
|
|||
|
||||
if at == base.arrow_type.PRETTY or not at then
|
||||
if direction == "left" then
|
||||
data._arrow_x = data.height -20 - (data.arrow_x or 20)
|
||||
data._arrow_x = data._internal.w.height -20 - (data.arrow_x_orig or 20)
|
||||
elseif direction == "right" then
|
||||
--TODO
|
||||
elseif direction == "bottom" then
|
||||
data._arrow_x = data.width -20 - (data.arrow_x or 20)
|
||||
data._arrow_x = data.width -20 - (data.arrow_x_orig or 20)
|
||||
if par_center_x >= menu_beg_x then
|
||||
data._arrow_x = data.width - (par_center_x - menu_beg_x) - 13
|
||||
end
|
||||
|
@ -80,10 +80,19 @@ local function get_arrow_x(data,direction)
|
|||
end
|
||||
|
||||
local function _set_direction(data,direction)
|
||||
if not data._arrow_x then
|
||||
get_arrow_x(data,direction)
|
||||
local height,width = data.height,data.width
|
||||
local hash = height*1000+width
|
||||
|
||||
-- Try not to waste time for nothing
|
||||
if data._internal._last_direction == direction..(hash) then return end
|
||||
|
||||
-- Avoid recomputing the arrow_x value
|
||||
if not data._arrow_x or data._internal.last_size ~= hash then
|
||||
gen_arrow_x(data,direction)
|
||||
data._internal.last_size = hash
|
||||
end
|
||||
local geometry = (direction == "left" or direction == "right") and {width = data.height, height = data.width} or {height = data.height, width = data.width}
|
||||
|
||||
local geometry = (direction == "left" or direction == "right") and {width = height, height = width} or {height = height, width = width}
|
||||
local top_clip_surface = do_gen_menu_top(data,geometry.width,geometry.height,10,data.border_width,{bg=beautiful.fg_normal or "#0000ff",fg=data.bg or "#00ffff"})
|
||||
local top_bounding_surface = do_gen_menu_top(data,geometry.width,geometry.height,10,0,{bg="#00000000",fg="#ffffffff"})
|
||||
|
||||
|
@ -102,21 +111,36 @@ local function _set_direction(data,direction)
|
|||
data.wibox.shape_bounding = top_bounding_surface._native
|
||||
data.wibox:set_bg(cairo.Pattern.create_for_surface(top_clip_surface))
|
||||
data._internal._need_direction_reload = false
|
||||
data._internal._last_direction = direction..(hash)
|
||||
end
|
||||
|
||||
-- Try to avoid useless repaint, this function is heavy
|
||||
local function set_direction(data,direction)
|
||||
data._internal._need_direction = direction
|
||||
if not data._internal._need_direction_reload then
|
||||
get_arrow_x(data,direction)
|
||||
if not data._internal._need_direction_reload and data._internal._last_direction ~= direction..(data.height*1000+data.width) then
|
||||
glib.idle_add(glib.PRIORITY_HIGH_IDLE, function() _set_direction(data,data._internal._need_direction) end)
|
||||
data._internal._need_direction_reload = true
|
||||
end
|
||||
end
|
||||
|
||||
local function get_arrow_x(data)
|
||||
local height,width = data.height,data.width
|
||||
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
|
||||
end
|
||||
return data._arrow_x
|
||||
end
|
||||
|
||||
local function draw(data,args)
|
||||
local args = args or {}
|
||||
local direction = data.direction or "top"
|
||||
if not data.get_arrow_x then
|
||||
rawset(data,"arrow_x_orig",data.arrow_x)
|
||||
rawset(data,"arrow_x_orig",nil)
|
||||
data.get_arrow_x = get_arrow_x
|
||||
end
|
||||
|
||||
set_direction(data,direction)
|
||||
-- data._internal.set_position(data) --TODO DEAD CODE?
|
||||
|
|
|
@ -51,7 +51,7 @@ function module.draw_arrow(cr,x,y,width,height,padding,args)
|
|||
cr:restore()
|
||||
end
|
||||
|
||||
function module.draw(text,args)
|
||||
function module.fit(text,args)
|
||||
local args = args or {}
|
||||
local height = args.height or (beautiful.menu_height)
|
||||
local padding = height/4--beautiful.default_height/3
|
||||
|
@ -75,6 +75,14 @@ function module.draw(text,args)
|
|||
ret[k] = pango_l[height]:get_pixel_extents().width + height + padding
|
||||
full_width = full_width + ret[k]
|
||||
end
|
||||
return full_width,ret
|
||||
end
|
||||
|
||||
function module.draw(text,args)
|
||||
local args = args or {}
|
||||
local height = args.height or (beautiful.menu_height)
|
||||
local padding = height/4--beautiful.default_height/3
|
||||
local full_width,ret = module.fit(text,args)
|
||||
|
||||
local img = cairo.ImageSurface.create(cairo.Format.ARGB32, full_width+(args.padding_right or 0), height+padding)
|
||||
cr = cairo.Context(img)
|
||||
|
|
Loading…
Reference in New Issue