Port rc.lua default tasklist buttons to the tasklist module
This commit is contained in:
parent
5cebb6a961
commit
cd88700613
|
@ -32,7 +32,7 @@ The most simple kind of menus, contexts one, can be created like this:
|
|||
|
||||
```lua
|
||||
local menu = radical.context{}
|
||||
menu:add_item {text="Screen 1",button1=function() print("Hello World! ") end}
|
||||
menu:add_item {text="Screen 1",button1=function(_menu,item,mods) print("Hello World! ") end}
|
||||
menu:add_item {text="Screen 9",icon=beautiful.path.."Icon/layouts/tileleft.png"}
|
||||
menu:add_item {text="Sub Menu",sub_menu = function()
|
||||
local smenu = radical.context{}
|
||||
|
|
2
bar.lua
2
bar.lua
|
@ -107,7 +107,7 @@ local function setup_buttons(data,item,args)
|
|||
|
||||
item:connect_signal("button::press",function(_m,_i,button_id,mods)
|
||||
if #mods == 0 and buttons[button_id] then
|
||||
buttons[button_id]()
|
||||
buttons[button_id](_m,_i,mods)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
|
|
@ -212,7 +212,7 @@ local function setup_buttons(data,item,args)
|
|||
|
||||
item:connect_signal("button::press",function(_m,_i,button_id,mods)
|
||||
if #mods == 0 and buttons[button_id] then
|
||||
buttons[button_id]()
|
||||
buttons[button_id](_m,_i,mods)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
|
|
@ -67,7 +67,7 @@ local function setup_item(data,item,args)
|
|||
|
||||
item:connect_signal("button::press",function(_m,_i,button_id,mods)
|
||||
if #mods == 0 and buttons[button_id] then
|
||||
buttons[button_id]()
|
||||
buttons[button_id](_m,_i,mods)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
|
|
@ -16,6 +16,39 @@ local wibox = require( "wibox" )
|
|||
|
||||
local sticky,urgent,instances,module = {},{},{},{}
|
||||
|
||||
-- Default button implementation
|
||||
module.buttons = {
|
||||
[1] = function (c)
|
||||
if c == client.focus then
|
||||
c.minimized = true
|
||||
else
|
||||
-- Without this, the following
|
||||
-- :isvisible() makes no sense
|
||||
c.minimized = false
|
||||
if not c:isvisible() then
|
||||
tag.viewonly(c:tags()[1])
|
||||
end
|
||||
-- This will also un-minimize
|
||||
-- the client, if needed
|
||||
client.focus = c
|
||||
c:raise()
|
||||
end
|
||||
end,
|
||||
[3] = function(c)
|
||||
customMenu.clientMenu.client = c
|
||||
local menu = customMenu.clientMenu.menu()
|
||||
menu.visible = true
|
||||
end,
|
||||
[4] = function ()
|
||||
client.focus.byidx(1)
|
||||
if client.focus then client.focus:raise() end
|
||||
end,
|
||||
[5] = function ()
|
||||
client.focus.byidx(-1)
|
||||
if client.focus then client.focus:raise() end
|
||||
end
|
||||
}
|
||||
|
||||
local function sticky_callback(c)
|
||||
local val = c.sticky
|
||||
sticky[c] = val and true or nil
|
||||
|
@ -80,11 +113,10 @@ local function create_client_item(c,screen)
|
|||
end
|
||||
|
||||
-- Too bad, let's create a new one
|
||||
cache[c] = menu:add_item{text=c.name,icon=c.icon,button1=function()
|
||||
capi.client.focus = c
|
||||
c:raise()
|
||||
end}
|
||||
return cache[c]
|
||||
local item = menu:add_item{text=c.name,icon=c.icon}
|
||||
item.client = c
|
||||
cache[c] = item
|
||||
return item
|
||||
end
|
||||
|
||||
local function add_client(c,screen)
|
||||
|
@ -187,6 +219,12 @@ local function new(screen)
|
|||
-- rawset(menu,"emit_signal",function(a,...)
|
||||
-- return menu._internal.layout.emit_signal(menu._internal.layout,...)
|
||||
-- end)
|
||||
|
||||
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)
|
||||
end
|
||||
end)
|
||||
|
||||
return menu,menu._internal.layout
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue