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
|
```lua
|
||||||
local menu = radical.context{}
|
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="Screen 9",icon=beautiful.path.."Icon/layouts/tileleft.png"}
|
||||||
menu:add_item {text="Sub Menu",sub_menu = function()
|
menu:add_item {text="Sub Menu",sub_menu = function()
|
||||||
local smenu = radical.context{}
|
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)
|
item:connect_signal("button::press",function(_m,_i,button_id,mods)
|
||||||
if #mods == 0 and buttons[button_id] then
|
if #mods == 0 and buttons[button_id] then
|
||||||
buttons[button_id]()
|
buttons[button_id](_m,_i,mods)
|
||||||
end
|
end
|
||||||
end)
|
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)
|
item:connect_signal("button::press",function(_m,_i,button_id,mods)
|
||||||
if #mods == 0 and buttons[button_id] then
|
if #mods == 0 and buttons[button_id] then
|
||||||
buttons[button_id]()
|
buttons[button_id](_m,_i,mods)
|
||||||
end
|
end
|
||||||
end)
|
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)
|
item:connect_signal("button::press",function(_m,_i,button_id,mods)
|
||||||
if #mods == 0 and buttons[button_id] then
|
if #mods == 0 and buttons[button_id] then
|
||||||
buttons[button_id]()
|
buttons[button_id](_m,_i,mods)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,6 +16,39 @@ local wibox = require( "wibox" )
|
||||||
|
|
||||||
local sticky,urgent,instances,module = {},{},{},{}
|
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 function sticky_callback(c)
|
||||||
local val = c.sticky
|
local val = c.sticky
|
||||||
sticky[c] = val and true or nil
|
sticky[c] = val and true or nil
|
||||||
|
@ -80,11 +113,10 @@ local function create_client_item(c,screen)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Too bad, let's create a new one
|
-- Too bad, let's create a new one
|
||||||
cache[c] = menu:add_item{text=c.name,icon=c.icon,button1=function()
|
local item = menu:add_item{text=c.name,icon=c.icon}
|
||||||
capi.client.focus = c
|
item.client = c
|
||||||
c:raise()
|
cache[c] = item
|
||||||
end}
|
return item
|
||||||
return cache[c]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function add_client(c,screen)
|
local function add_client(c,screen)
|
||||||
|
@ -188,6 +220,12 @@ local function new(screen)
|
||||||
-- return menu._internal.layout.emit_signal(menu._internal.layout,...)
|
-- return menu._internal.layout.emit_signal(menu._internal.layout,...)
|
||||||
-- end)
|
-- 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
|
return menu,menu._internal.layout
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue