2014-05-13 05:35:45 +02:00
|
|
|
local capi = { root = root, client = client ,
|
2014-05-08 05:51:28 +02:00
|
|
|
screen = screen, keygrabber = keygrabber}
|
2014-05-11 05:46:27 +02:00
|
|
|
local util = require( "awful.util" )
|
|
|
|
local awful = require( "awful" )
|
2014-05-08 05:51:28 +02:00
|
|
|
local module = {
|
2014-05-10 05:09:17 +02:00
|
|
|
_focus = require( "customIndicator.focus" ),
|
2014-05-13 05:35:45 +02:00
|
|
|
_resize = require( "customIndicator.resize"),
|
|
|
|
_max = require( "customIndicator.max" ),
|
2014-05-08 05:51:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
local current_mode = "focus"
|
|
|
|
|
2014-05-08 07:53:57 +02:00
|
|
|
local event_callback = {
|
2014-05-10 05:09:17 +02:00
|
|
|
focus = module._focus._global_bydirection_key,
|
|
|
|
move = module._focus._global_bydirection_key,
|
|
|
|
resize = module._resize.resize
|
2014-05-08 05:51:28 +02:00
|
|
|
}
|
|
|
|
|
2014-05-10 06:42:59 +02:00
|
|
|
local start_callback = {
|
|
|
|
focus = module._focus.display,
|
|
|
|
move = module._focus.display,
|
|
|
|
resize = module._resize.display
|
|
|
|
}
|
|
|
|
|
2014-05-08 07:53:57 +02:00
|
|
|
local exit_callback = {
|
2014-05-10 05:09:17 +02:00
|
|
|
focus = module._focus._quit,
|
|
|
|
move = module._focus._quit,
|
|
|
|
resize = module._resize.hide
|
2014-05-08 07:53:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
local keys = {--Normal Xephyr G510 alt G510
|
2014-05-11 05:46:27 +02:00
|
|
|
up = {"Up" --[[, "&" , "XF86AudioPause" , "F15"]] },
|
|
|
|
down = {"Down" --[[, "KP_Enter" , "XF86WebCam" , "F14"]] },
|
|
|
|
left = {"Left" --[[, "#" , "Cancel" , "F13"]] },
|
|
|
|
right = {"Right" --[[, "\"" , "XF86Paste" , "F17"]] }
|
2014-05-08 07:53:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
local function exit_loop()
|
2014-05-10 05:09:17 +02:00
|
|
|
exit_callback[current_mode]()
|
|
|
|
capi.keygrabber.stop()
|
|
|
|
return false
|
2014-05-08 07:53:57 +02:00
|
|
|
end
|
|
|
|
|
2014-05-08 05:51:28 +02:00
|
|
|
-- Event loop
|
2014-05-08 07:53:57 +02:00
|
|
|
local function start_loop(is_swap,is_max)
|
2014-05-10 05:09:17 +02:00
|
|
|
capi.keygrabber.run(function(mod, key, event)
|
|
|
|
-- Detect the direction
|
|
|
|
for k,v in pairs(keys) do
|
|
|
|
if util.table.hasitem(v,key) then
|
|
|
|
if event == "press" then
|
|
|
|
if not event_callback[current_mode](mod,key,event,k,is_swap,is_max) then
|
|
|
|
return exit_loop()
|
|
|
|
end
|
|
|
|
return
|
2014-05-08 07:53:57 +02:00
|
|
|
end
|
2014-05-10 05:09:17 +02:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
2014-05-08 07:53:57 +02:00
|
|
|
|
2014-05-10 05:09:17 +02:00
|
|
|
if key == "Shift_L" or key == "Shift_R" then
|
|
|
|
is_swap = event == "press"
|
|
|
|
return true
|
|
|
|
elseif key == "Control_L" or key == "Control_R" then
|
|
|
|
is_max = event == "press"
|
|
|
|
return true
|
2014-05-10 06:42:59 +02:00
|
|
|
elseif key == "Alt_L" or key == "Alt_R" then
|
|
|
|
exit_callback[current_mode]()
|
|
|
|
current_mode = event == "press" and "resize" or "focus"
|
|
|
|
start_callback[current_mode](mod,key,event,k,is_swap,is_max)
|
|
|
|
return true
|
2014-05-10 05:09:17 +02:00
|
|
|
end
|
2014-05-08 07:53:57 +02:00
|
|
|
|
2014-05-10 05:09:17 +02:00
|
|
|
return exit_loop()
|
|
|
|
end)
|
2014-05-08 05:51:28 +02:00
|
|
|
end
|
|
|
|
|
2014-05-08 07:53:57 +02:00
|
|
|
function module.focus(direction,c,max)
|
2014-05-10 05:09:17 +02:00
|
|
|
current_mode = "focus"
|
2014-05-13 05:35:45 +02:00
|
|
|
local screen = (c or capi.client.focus).screen
|
|
|
|
if awful.layout.get((c or capi.client.focus).screen) == awful.layout.suit.max then
|
|
|
|
module._max.display_clients(screen)
|
|
|
|
else
|
|
|
|
module._focus.global_bydirection(direction,c,false,true)
|
|
|
|
end
|
2014-05-08 07:53:57 +02:00
|
|
|
start_loop(false,max)
|
2014-05-08 05:51:28 +02:00
|
|
|
end
|
|
|
|
|
2014-05-08 07:53:57 +02:00
|
|
|
function module.move(direction,c,max)
|
2014-05-10 05:09:17 +02:00
|
|
|
current_mode = "move"
|
2014-05-08 07:53:57 +02:00
|
|
|
module._focus.global_bydirection(direction,c,true)
|
|
|
|
start_loop(true,max)
|
2014-05-08 05:51:28 +02:00
|
|
|
end
|
|
|
|
|
2014-05-10 05:09:17 +02:00
|
|
|
function module.resize(direction,c,max)
|
|
|
|
current_mode = "resize"
|
|
|
|
start_loop(false,max)
|
|
|
|
module._resize.display(c)
|
|
|
|
end
|
|
|
|
|
|
|
|
function module.mouse_resize(c)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2014-05-11 05:46:27 +02:00
|
|
|
local function new(k)
|
|
|
|
local k = k or keys
|
|
|
|
local aw = {}
|
|
|
|
|
|
|
|
for k,v in pairs(keys) do
|
|
|
|
for _,key_nane in ipairs(v) do
|
|
|
|
aw[#aw+1] = awful.key({ modkey, }, key_nane, function () module.focus (k ) end)
|
|
|
|
aw[#aw+1] = awful.key({ modkey, "Mod1" }, key_nane, function () module.resize(k ) end)
|
|
|
|
aw[#aw+1] = awful.key({ modkey, "Shift" }, key_nane, function () module.move (k ) end)
|
|
|
|
aw[#aw+1] = awful.key({ modkey, "Shift", "Control" }, key_nane, function () module.move (k,nil,true) end)
|
|
|
|
aw[#aw+1] = awful.key({ modkey, "Control" }, key_nane, function () module.focus (k,nil,true) end)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
capi.root.keys(awful.util.table.join(capi.root.keys(),unpack(aw)))
|
|
|
|
end
|
|
|
|
|
|
|
|
return setmetatable(module, { __call = function(_, ...) return new(...) end })
|
2014-05-10 05:09:17 +02:00
|
|
|
-- kate: space-indent on; indent-width 2; replace-tabs on;
|