Add ability to toggle a client (in the current tag) directly from the alt+tab menu
This commit is contained in:
parent
5c140a93ac
commit
8f1c8d8323
76
base.lua
76
base.lua
|
@ -44,47 +44,47 @@ local function activateKeyboard(data)
|
|||
if not data or grabKeyboard == true then return end
|
||||
if (not (data._internal.private_data.enable_keyboard == false)) and data.visible == true then
|
||||
capi.keygrabber.run(function(mod, key, event)
|
||||
for k,v in pairs(data._internal.filter_hooks or {}) do --TODO modkeys
|
||||
if k.key == "Mod4" and (key == "End" or key == "Super_L") then
|
||||
local found = false
|
||||
for k3,v3 in ipairs(mod) do
|
||||
if v3 == "Mod4" and event == k.event then
|
||||
local retval,self = v(data,mod)
|
||||
if self and type(self) == "table" then
|
||||
data = self
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if k.key == key and k.event == event then
|
||||
local retval, self = v(data,mod)
|
||||
if self and type(self) == "table" then
|
||||
data = self
|
||||
end
|
||||
return retval
|
||||
for k,v in pairs(data._internal.filter_hooks or {}) do --TODO modkeys
|
||||
if k.key == "Mod4" and (key == "End" or key == "Super_L") then
|
||||
local found = false
|
||||
for k3,v3 in ipairs(mod) do
|
||||
if v3 == "Mod4" and event == k.event then
|
||||
local retval,self = v(data,mod)
|
||||
if self and type(self) == "table" then
|
||||
data = self
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if event == "release" then
|
||||
return true
|
||||
if k.key == key and k.event == event then
|
||||
local retval, self = v(data,mod)
|
||||
if self and type(self) == "table" then
|
||||
data = self
|
||||
end
|
||||
return retval
|
||||
end
|
||||
end
|
||||
if event == "release" then
|
||||
return true
|
||||
end
|
||||
|
||||
if (key == 'Return') and data._current_item and data._current_item.button1 then
|
||||
data._current_item.button1()
|
||||
data.visible = false
|
||||
elseif key == 'Escape' or (key == 'Tab' and data.filter_string == "") then
|
||||
data.visible = false
|
||||
capi.keygrabber.stop()
|
||||
elseif (key == 'BackSpace') and data.filter_string ~= "" and data.filter == true then
|
||||
data.filter_string = data.filter_string:sub(1,-2)
|
||||
filter(data)
|
||||
elseif data.filter == true and key:len() == 1 then
|
||||
data.filter_string = data.filter_string .. key:lower()
|
||||
filter(data)
|
||||
else
|
||||
data.visible = false
|
||||
capi.keygrabber.stop()
|
||||
end
|
||||
return true
|
||||
if (key == 'Return') and data._current_item and data._current_item.button1 then
|
||||
data._current_item.button1()
|
||||
data.visible = false
|
||||
elseif key == 'Escape' or (key == 'Tab' and data.filter_string == "") then
|
||||
data.visible = false
|
||||
capi.keygrabber.stop()
|
||||
elseif (key == 'BackSpace') and data.filter_string ~= "" and data.filter == true then
|
||||
data.filter_string = data.filter_string:sub(1,-2)
|
||||
filter(data)
|
||||
elseif data.filter == true and key:len() == 1 then
|
||||
data.filter_string = data.filter_string .. key:lower()
|
||||
filter(data)
|
||||
else
|
||||
data.visible = false
|
||||
capi.keygrabber.stop()
|
||||
end
|
||||
return true
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
@ -400,7 +400,7 @@ local function new(args)
|
|||
filter(data)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function data:scroll_down()
|
||||
if data.max_items ~= nil and data.rowcount >= data.max_items and (data._start_at or 1)+data.max_items <= data.rowcount then
|
||||
data._start_at = (data._start_at or 1) + 1
|
||||
|
|
|
@ -3,12 +3,11 @@ local ipairs, pairs = ipairs, pairs
|
|||
local button = require( "awful.button" )
|
||||
local beautiful = require( "beautiful" )
|
||||
local tag = require( "awful.tag" )
|
||||
local client2 = require( "awful.client" )
|
||||
local menu = require( "radical.box" )
|
||||
local util = require( "awful.util" )
|
||||
local wibox = require( "wibox" )
|
||||
local color = require( "gears.color" )
|
||||
local capi = { client = client, mouse = mouse, screen = screen,}
|
||||
local print = print
|
||||
local capi = { client = client, mouse = mouse, screen = screen}
|
||||
|
||||
local module,pause_monitoring = {},false
|
||||
|
||||
|
@ -54,18 +53,9 @@ end
|
|||
|
||||
-- Simulate a titlebar
|
||||
local function button_group(args)
|
||||
local c = args.client
|
||||
local field = args.field
|
||||
local focus = args.focus or false
|
||||
local checked = args.checked or false
|
||||
local widget = wibox.widget.imagebox()
|
||||
|
||||
|
||||
local curfocus = ((((type(focus) == "function") and focus() or focus) == true) and "focus" or "normal")
|
||||
local curactive = ((((type(checked) == "function") and checked() or checked) == true) and "active" or "inactive")
|
||||
widget:set_image( module.titlebar_path.. field .."_"..curfocus .."_"..curactive..".png" )
|
||||
widget:set_image( module.titlebar_path.. args.field .."_normal_"..(args.checked() and "active" or "inactive")..".png" )
|
||||
widget:buttons( util.table.join(button({ }, 1 , args.onclick)))
|
||||
|
||||
return widget
|
||||
end
|
||||
|
||||
|
@ -76,49 +66,62 @@ local function select_next(menu)
|
|||
return true
|
||||
end
|
||||
|
||||
local function new(screen, args)
|
||||
local function is_in_tag(t,c)
|
||||
for k,v in ipairs(c:tags()) do if t == v then return true end end
|
||||
return false
|
||||
end
|
||||
|
||||
local function new(args)
|
||||
local currentMenu = menu({filter = true, show_filter=true, autodiscard = true,
|
||||
disable_markup=true,fkeys_prefix=true,width=(((screen or capi.screen[capi.mouse.screen]).geometry.width)/2)})
|
||||
disable_markup=true,fkeys_prefix=true,width=(((capi.screen[capi.mouse.screen]).geometry.width)/2)})
|
||||
|
||||
local t = tag.selected(capi.mouse.screen)
|
||||
|
||||
currentMenu:add_key_hook({}, "Tab", "press", select_next)
|
||||
currentMenu:add_key_hook({}, "Shift_L", "press", function()
|
||||
currentMenu._current_item.checked = not currentMenu._current_item.checked
|
||||
client2.toggletag (t, currentMenu._current_item.client)
|
||||
return true
|
||||
end)
|
||||
|
||||
|
||||
if module.titlebar_path then
|
||||
for k,v2 in ipairs(get_history(--[[screen]])) do
|
||||
local l,v = wibox.layout.fixed.horizontal(),v2[2]
|
||||
l:add( button_group({client = v, field = "floating" , focus = false, checked = function() return v.floating end, onclick = function() v.floating = not v.floating end }))
|
||||
l:add( button_group({client = v, field = "maximized", focus = false, checked = function() return v.maximized end, onclick = function() v.maximized = not v.maximized end }))
|
||||
l:add( button_group({client = v, field = "sticky" , focus = false, checked = function() return v.sticky end, onclick = function() v.sticky = not v.sticky end }))
|
||||
l:add( button_group({client = v, field = "ontop" , focus = false, checked = function() return v.ontop end, onclick = function() v.ontop = not v.ontop end }))
|
||||
l:add( button_group({client = v, field = "close" , focus = false, checked = function() return false end, onclick = function() v:kill() end }))
|
||||
|
||||
l.fit = function (s,w,h) return 5*h,h end
|
||||
currentMenu:add_item({
|
||||
text = v.name,
|
||||
icon = module.icon_transform and module.icon_transform(v.icon or module.default_icon) or v.icon or module.default_icon,
|
||||
suffix_widget = l,
|
||||
selected = capi.client.focus == v,
|
||||
underlay = v:tags()[1] and draw_underlay(v:tags()[1].name),
|
||||
checkable = not args.auto_release,
|
||||
checked = is_in_tag(t,v),
|
||||
button1 = function()
|
||||
if v:tags()[1] and v:tags()[1].selected == false then
|
||||
tag.viewonly(v:tags()[1])
|
||||
end
|
||||
capi.client.focus = v
|
||||
end,
|
||||
}).client = v
|
||||
end
|
||||
end
|
||||
|
||||
if args and args.auto_release then
|
||||
currentMenu:add_key_hook({}, "Alt_L", "release", function(_)
|
||||
currentMenu.visible = false
|
||||
return false
|
||||
end)
|
||||
end
|
||||
|
||||
if module.titlebar_path then
|
||||
for k,v2 in ipairs(get_history(screen)) do
|
||||
local l,v = wibox.layout.fixed.horizontal(),v2[2]
|
||||
l:add( button_group({client = v, width=5, field = "close", focus = false, checked = false , onclick = function() v:kill() end }))
|
||||
l:add( button_group({client = v, width=5, field = "ontop", focus = false, checked = function() return v.ontop end , onclick = function() v.ontop = not v.ontop end }))
|
||||
l:add( button_group({client = v, width=5, field = "maximized", focus = false, checked = function() return v.maximized end, onclick = function() v.maximized = not v.maximized end }))
|
||||
l:add( button_group({client = v, width=5, field = "sticky", focus = false, checked = function() return v.sticky end , onclick = function() v.sticky = not v.sticky end }))
|
||||
l:add( button_group({client = v, width=5, field = "floating", focus = false, checked = function() return v.floating end , onclick = function() v.floating = not v.floating end }))
|
||||
|
||||
l.fit = function (s,w,h) return 5*h,h end
|
||||
currentMenu:add_item({
|
||||
text = v.name,
|
||||
button1 = function()
|
||||
if v:tags()[1] and v:tags()[1].selected == false then
|
||||
tag.viewonly(v:tags()[1])
|
||||
end
|
||||
capi.client.focus = v
|
||||
end,
|
||||
icon = module.icon_transform and module.icon_transform(v.icon or module.default_icon) or v.icon or module.default_icon,
|
||||
suffix_widget = l,
|
||||
selected = capi.client.focus == v,
|
||||
underlay = v:tags()[1] and draw_underlay(v:tags()[1].name)
|
||||
})
|
||||
end
|
||||
select_next(currentMenu)
|
||||
end
|
||||
|
||||
pause_monitoring,currentMenu.visible = true, true
|
||||
if args.auto_release then
|
||||
select_next(currentMenu)
|
||||
end
|
||||
currentMenu:connect_signal("visible::changed",function(m)
|
||||
if not m.visible then pause_monitoring = false;push_focus(capi.client.focus) end
|
||||
end)
|
||||
|
@ -126,11 +129,11 @@ local function new(screen, args)
|
|||
end
|
||||
|
||||
function module.altTab(args)
|
||||
new(nil,{leap = 1,auto_release = (args or {}).auto_release})
|
||||
new({leap = 1,auto_release = (args or {}).auto_release})
|
||||
end
|
||||
|
||||
function module.altTabBack(args)
|
||||
new(nil,{leap = -1,auto_release = (args or {}).auto_release})
|
||||
new({leap = -1,auto_release = (args or {}).auto_release})
|
||||
end
|
||||
|
||||
return setmetatable(module, { __call = function(_, ...) return new(...) end })
|
||||
|
|
Loading…
Reference in New Issue