Add more bits for the overlay feature

This commit is contained in:
Emmanuel Lepage Vallee 2014-02-14 23:35:53 -05:00
parent 9205d9f27a
commit b65f47e86b
7 changed files with 89 additions and 1 deletions

View File

@ -45,6 +45,7 @@ end
local function track_used(c,t)
if t then
local item = cache[t] or create_item(t,tag.getscreen(t))
if not item then return end -- Yes, it happen if the screen is still nil
item.used = #t:clients()
else
for _,t2 in ipairs(c:tags()) do

View File

@ -7,10 +7,12 @@
---------------------------------------------------------------------------
local capi = {client = client}
local rawset = rawset
local radical = require( "radical" )
local tag = require( "awful.tag" )
local beautiful = require( "beautiful" )
local client = require( "awful.client" )
local wibox = require( "wibox" )
local sticky,urgent,instances,module = {},{},{},{}
@ -164,7 +166,29 @@ local function new(screen)
load_clients(tag.selected(screen))
return menu
-- Try to make awesome think radical.bar is a real widget
-- Use "menu._internal.layout" directly in :add to avoid
-- the proxy overhead, for now it doesn't event work on 3.5.2
-- rawset(menu,"fit",function(self,...)
-- return menu._internal.layout.fit(menu._internal.layout,...)
-- end)
-- rawset(menu,"draw",function(self,...)
-- return menu._internal.layout.draw(menu._internal.layout,...)
-- end)
-- rawset(menu,"add_signal",function(self,...)
-- return menu._internal.layout.add_signal(menu._internal.layout,...)
-- end)
-- rawset(menu,"disconnect_signal",function(a,...)
-- return menu._internal.layout.disconnect_signal(menu._internal.layout,...)
-- end)
-- rawset(menu,"connect_signal",function(a,...)
-- return menu._internal.layout.disconnect_signal(menu._internal.layout,...)
-- end)
-- rawset(menu,"emit_signal",function(a,...)
-- return menu._internal.layout.emit_signal(menu._internal.layout,...)
-- end)
return menu,menu._internal.layout
end
-- Global callbacks

View File

@ -81,6 +81,10 @@ local function draw_real(self, w, cr, width, height)
cr:paint()
cr:restore()
self.widget:draw(w, cr, width, height)
local overlay = self._item and self._item.overlay
if overlay then
overlay(self._item._menu,self._item,cr,width,height)
end
end
local function get_prev(data,item)

View File

@ -45,10 +45,24 @@ local function suffix_fit(box,w,h)
return width + h/2 + h/6,height
end
local function widget_draw(self, w, cr, width, height)
self:_draw(w, cr, width, height)
local overlay = self._item and self._item.overlay
if overlay then
overlay(self._item._menu,self._item,cr,width,height)
end
end
local function draw(data,item,args)
local args,flags = args or {},{}
for _,v in pairs(args) do flags[v] = true end
if not item.widget._overlay_init then
item.widget._draw = item.widget.draw
item.widget.draw = widget_draw
item.widget._overlay_init = true
end
if not item._internal.align._setup then
item._internal.align._setup = true

View File

@ -12,10 +12,25 @@ local module = {
}
}
local function widget_draw(self, w, cr, width, height)
self:_draw(w, cr, width, height)
local overlay = self._item and self._item.overlay
if overlay then
overlay(self._item._menu,self._item,cr,width,height)
end
end
local function draw(data,item,args)
local args,flags = args or {},{}
for _,v in pairs(args) do flags[v] = true end
if not item.widget._overlay_init then
item.widget._draw = item.widget.draw
item.widget.draw = widget_draw
item.widget._overlay_init = true
end
if flags[base.item_flags.SELECTED] or (item._tmp_menu) then
item.widget:set_bg(args.color or data.bg_focus)
else

View File

@ -27,10 +27,25 @@ local function gen(item_height,bg_color,border_color)
return cairo.Pattern.create_for_surface(img)
end
local function widget_draw(self, w, cr, width, height)
self:_draw2(w, cr, width, height)
local overlay = self._item and self._item.overlay
if overlay then
overlay(self._item._menu,self._item,cr,width,height)
end
end
local function draw(data,item,args)
local args,flags = args or {},{}
local col = args.color
for _,v in pairs(args) do flags[v] = true end
if not item.widget._overlay_init then
item.widget._draw2 = item.widget.draw
item.widget.draw = widget_draw
item.widget._overlay_init = true
end
local ih = data.item_height
if not focussed or not focussed[ih] then
if not focussed then

View File

@ -32,9 +32,24 @@ local function gen(item_height,bg_color,border_color)
return cairo.Pattern.create_for_surface(img)
end
local function widget_draw(self, w, cr, width, height)
self:_draw(w, cr, width, height)
local overlay = self._item and self._item.overlay
if overlay then
overlay(self._item._menu,self._item,cr,width,height)
end
end
local function draw(data,item,args)
local args,flags = args or {},{}
for _,v in pairs(args) do flags[v] = true end
if not item.widget._overlay_init then
item.widget._draw = item.widget.draw
item.widget.draw = widget_draw
item.widget._overlay_init = true
end
local ih = data.item_height
if not focussed or not focussed[ih] then
if not focussed then