refactor
This commit is contained in:
parent
6c12f44857
commit
dea7ebff5b
|
@ -62,7 +62,7 @@ git clone https://github.com/basaran/awesomewm-machina machina
|
||||||
and call it from your `rc.lua`
|
and call it from your `rc.lua`
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local machina = require('awesomewm-machina')()
|
local machina = require('machina')()
|
||||||
```
|
```
|
||||||
|
|
||||||
### Keybindings
|
### Keybindings
|
||||||
|
|
43
helpers.lua
43
helpers.lua
|
@ -30,6 +30,16 @@ end --|
|
||||||
--|reasons in case we need this again.
|
--|reasons in case we need this again.
|
||||||
|
|
||||||
|
|
||||||
|
local function clear_tabbar(c, position)
|
||||||
|
if not c then return end
|
||||||
|
local position = position or "bottom"
|
||||||
|
local titlebar = awful.titlebar(c, {size=3, position=position})
|
||||||
|
titlebar:setup{
|
||||||
|
layout=wibox.layout.flex.horizontal, nil
|
||||||
|
}
|
||||||
|
end --|clears bottom tabbar
|
||||||
|
|
||||||
|
|
||||||
local function reload(m)
|
local function reload(m)
|
||||||
if package.loaded[m] then
|
if package.loaded[m] then
|
||||||
local attrs = {}
|
local attrs = {}
|
||||||
|
@ -93,36 +103,5 @@ return {
|
||||||
getlowest = getlowest,
|
getlowest = getlowest,
|
||||||
get_client_ix = get_client_ix,
|
get_client_ix = get_client_ix,
|
||||||
reload = reload,
|
reload = reload,
|
||||||
-- clear_tabbar = clear_tabbar
|
clear_tabbar = clear_tabbar
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- d:connect_signal("focus", function(_)
|
|
||||||
-- local poo = awful.titlebar(d, {position="bottom", size="14"})
|
|
||||||
-- -- local dee = poo.get_all_children({"335544341"})
|
|
||||||
-- local dee = poo:get_children_by_id("335544341")
|
|
||||||
|
|
||||||
-- file = io.open("/tmp/lua.txt", "w")
|
|
||||||
-- io.output(file)
|
|
||||||
-- io.write(inspect(poo))
|
|
||||||
-- io.close(file)
|
|
||||||
|
|
||||||
-- naughty.notify({text=inspect(dee)})
|
|
||||||
-- end)
|
|
||||||
|
|
||||||
|
|
||||||
-- -- gears.timer.delayed_call(function (d)
|
|
||||||
-- -- -- local active_region = get_client_region(d)
|
|
||||||
-- -- naughty.notify({text="here"})
|
|
||||||
|
|
||||||
-- -- if active_region then
|
|
||||||
-- -- c.region = active_region
|
|
||||||
-- -- draw_tabbar(active_region)
|
|
||||||
-- -- end
|
|
||||||
-- -- end, c)
|
|
||||||
|
|
26
init.lua
26
init.lua
|
@ -54,37 +54,35 @@ local bindings = {
|
||||||
awful.key({modkey, "Control"}, "i", shift_by_direction("up","swap")),
|
awful.key({modkey, "Control"}, "i", shift_by_direction("up","swap")),
|
||||||
--▨ swap
|
--▨ swap
|
||||||
|
|
||||||
|
awful.key({modkey}, "Insert", move_to("top-left")),
|
||||||
|
awful.key({modkey}, "Delete", move_to("bottom-left")),
|
||||||
|
awful.key({modkey}, "Home", expand_horizontal("center")),
|
||||||
|
awful.key({modkey}, "Page_Up", move_to("top-right")),
|
||||||
|
awful.key({modkey}, "Page_Down", move_to("bottom-right")),
|
||||||
|
--▨ move (positional)
|
||||||
|
|
||||||
awful.key({modkey, "Shift"}, "Insert", expand_horizontal("left")),
|
awful.key({modkey, "Shift"}, "Insert", expand_horizontal("left")),
|
||||||
|
awful.key({modkey, "Shift"}, "End", toggle_always_on),
|
||||||
|
awful.key({modkey, "Shift"}, "Home", move_to("center")),
|
||||||
awful.key({modkey, "Shift"}, "Page_Up", expand_horizontal("right")),
|
awful.key({modkey, "Shift"}, "Page_Up", expand_horizontal("right")),
|
||||||
awful.key({modkey, "Shift"}, "Page_Down", expand_vertical),
|
awful.key({modkey, "Shift"}, "Page_Down", expand_vertical),
|
||||||
--▨ expand (neighbor)
|
--▨ expand (neighbor)
|
||||||
|
|
||||||
awful.key({modkey}, "Insert", move_to("top-left")),
|
|
||||||
awful.key({modkey}, "Page_Up", move_to("top-right")),
|
|
||||||
awful.key({modkey}, "Delete", move_to("bottom-left")),
|
|
||||||
awful.key({modkey}, "Page_Down", move_to("bottom-right")),
|
|
||||||
--▨ move (positional)
|
|
||||||
|
|
||||||
awful.key({modkey}, "Home", expand_horizontal("center")),
|
|
||||||
awful.key({modkey}, "End", function()
|
awful.key({modkey}, "End", function()
|
||||||
client.focus.maximized_vertical = false
|
client.focus.maximized_vertical = false
|
||||||
client.focus.maximized_horizontal = false
|
client.focus.maximized_horizontal = false
|
||||||
awful.client.floating.toggle()
|
awful.client.floating.toggle()
|
||||||
end), --|toggle floating status
|
end), --|toggle floating status
|
||||||
|
|
||||||
awful.key({modkey, "Shift"}, "End", toggle_always_on),
|
|
||||||
awful.key({modkey, "Shift"}, "Home", move_to("center")),
|
|
||||||
|
|
||||||
-- awful.key({mondkey}, "u", )
|
|
||||||
awful.key({modkey,}, "o", function(c)
|
|
||||||
naughty.notify({text=inspect(client.focus.screen)})
|
|
||||||
end), --|client teleport to other screen
|
|
||||||
|
|
||||||
awful.key({modkey}, "Left", focus_by_direction("left")),
|
awful.key({modkey}, "Left", focus_by_direction("left")),
|
||||||
awful.key({modkey}, "Down", focus_by_direction("down")),
|
awful.key({modkey}, "Down", focus_by_direction("down")),
|
||||||
awful.key({modkey}, "Right", focus_by_direction("right")),
|
awful.key({modkey}, "Right", focus_by_direction("right")),
|
||||||
awful.key({modkey}, "Up", focus_by_direction("up")),
|
awful.key({modkey}, "Up", focus_by_direction("up")),
|
||||||
--▨ focus
|
--▨ focus
|
||||||
|
|
||||||
|
awful.key({modkey,}, "o", teleport_client), --|client teleport to other screen
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
--------------------------------------------------------------- signals -- ;
|
--------------------------------------------------------------- signals -- ;
|
||||||
|
|
170
methods.lua
170
methods.lua
|
@ -26,21 +26,6 @@ function update_global_clients(c)
|
||||||
global_client_table[c.window] = c
|
global_client_table[c.window] = c
|
||||||
end
|
end
|
||||||
|
|
||||||
function log(m,context)
|
|
||||||
context = context or ""
|
|
||||||
naughty.notify({text=inspect(m) .. " :" .. context })
|
|
||||||
end
|
|
||||||
|
|
||||||
local function clear_tabbar(c, position)
|
|
||||||
if not c then return end
|
|
||||||
local position = position or "bottom"
|
|
||||||
local titlebar = awful.titlebar(c, {size=3, position=position})
|
|
||||||
titlebar:setup{
|
|
||||||
layout=wibox.layout.flex.horizontal, nil
|
|
||||||
}
|
|
||||||
end --|clears bottom tabbar
|
|
||||||
|
|
||||||
|
|
||||||
------------------------------------------------------------- go_edge() -- ;
|
------------------------------------------------------------- go_edge() -- ;
|
||||||
|
|
||||||
local function go_edge(direction, regions, current_box)
|
local function go_edge(direction, regions, current_box)
|
||||||
|
@ -149,15 +134,12 @@ end
|
||||||
------------------------------------------------------- get_client_info -- ;
|
------------------------------------------------------- get_client_info -- ;
|
||||||
|
|
||||||
local function get_client_info(c)
|
local function get_client_info(c)
|
||||||
|
local c = c or client.focus or nil
|
||||||
|
local s = s or c.screen or nil
|
||||||
|
local source_client = c
|
||||||
local active_region = nil
|
local active_region = nil
|
||||||
local outofboundary = nil
|
local outofboundary = nil
|
||||||
local proximity = {}
|
local proximity = {}
|
||||||
local regions = get_regions()
|
|
||||||
local source_client = c or client.focus or nil
|
|
||||||
|
|
||||||
|
|
||||||
if not regions then return {} end
|
|
||||||
--|flow control
|
|
||||||
|
|
||||||
if not source_client then return {} end
|
if not source_client then return {} end
|
||||||
--|flow control
|
--|flow control
|
||||||
|
@ -166,6 +148,11 @@ local function get_client_info(c)
|
||||||
then outofboundary = true
|
then outofboundary = true
|
||||||
end --| negative coordinates always mean out of boundary
|
end --| negative coordinates always mean out of boundary
|
||||||
|
|
||||||
|
local regions = get_regions(s)
|
||||||
|
--|get regions on the screen
|
||||||
|
|
||||||
|
if not regions then return {} end
|
||||||
|
--|flow control
|
||||||
|
|
||||||
for i, a in ipairs(regions) do
|
for i, a in ipairs(regions) do
|
||||||
local px = a.x - source_client.x
|
local px = a.x - source_client.x
|
||||||
|
@ -238,10 +225,11 @@ end
|
||||||
------------------------------------------------------ region_tablist() -- ;
|
------------------------------------------------------ region_tablist() -- ;
|
||||||
|
|
||||||
local function test_tablist(region_ix, c, s)
|
local function test_tablist(region_ix, c, s)
|
||||||
|
local s = s or c.screen or awful.screen.focused()
|
||||||
local source_client = c or client.focus or nil
|
local source_client = c or client.focus or nil
|
||||||
local source_screen = (source_client and source_client.screen) or s or awful.screen.focused()
|
local source_screen = s or (source_client and source_client.screen)
|
||||||
local active_region = region_ix or nil
|
local active_region = region_ix or nil
|
||||||
local regions = get_regions(source_screen)
|
local regions = get_regions(s)
|
||||||
local all_client = get_global_clients()
|
local all_client = get_global_clients()
|
||||||
local region_clients = {}
|
local region_clients = {}
|
||||||
|
|
||||||
|
@ -256,8 +244,6 @@ local function test_tablist(region_ix, c, s)
|
||||||
end --|if no region index provided, find the region of the
|
end --|if no region index provided, find the region of the
|
||||||
--|focused_client.
|
--|focused_client.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for i, cc in pairs(all_client) do
|
for i, cc in pairs(all_client) do
|
||||||
if cc.region == active_region and regions[active_region].x == cc.x
|
if cc.region == active_region and regions[active_region].x == cc.x
|
||||||
and regions[active_region].y == cc.y
|
and regions[active_region].y == cc.y
|
||||||
|
@ -267,27 +253,15 @@ local function test_tablist(region_ix, c, s)
|
||||||
end
|
end
|
||||||
|
|
||||||
return region_clients
|
return region_clients
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function pest_tablist(region_ix, c, s)
|
||||||
local function region_tablist(region_ix, c)
|
local s = s or c.screen or awful.screen.focused()
|
||||||
local focused_screen = awful.screen.focused()
|
|
||||||
local workarea = awful.screen.focused().workarea
|
|
||||||
local selected_tag = awful.screen.focused().selected_tag
|
|
||||||
local tablist = {}
|
|
||||||
local active_region = region_ix or nil
|
|
||||||
local source_client = c or client.focus or nil
|
local source_client = c or client.focus or nil
|
||||||
|
local source_screen = s or (source_client and source_client.screen)
|
||||||
local regions = get_regions()
|
local active_region = region_ix or nil
|
||||||
|
local regions = get_regions(s)
|
||||||
if not regions then return {} end
|
local tablist = {}
|
||||||
--|flow control
|
|
||||||
|
|
||||||
|
|
||||||
------------------ CHECK FOR SIDE EFFECTS
|
|
||||||
-- if not source_client or source_client.floating then return {} end
|
|
||||||
--|flow control
|
|
||||||
|
|
||||||
if not active_region then
|
if not active_region then
|
||||||
for i, a in ipairs(regions) do
|
for i, a in ipairs(regions) do
|
||||||
|
@ -300,12 +274,24 @@ local function region_tablist(region_ix, c)
|
||||||
end --|if no region index provided, find the region of the
|
end --|if no region index provided, find the region of the
|
||||||
--|focused_client.
|
--|focused_client.
|
||||||
|
|
||||||
for _, tc in ipairs(screen[focused_screen].tiled_clients) do
|
-- for _, tc in ipairs(s.clients) do
|
||||||
if not (tc.floating or tc.immobilized) then
|
-- if not (tc.floating) then
|
||||||
if regions[active_region].x <= tc.x + tc.width + tc.border_width * 2 and
|
-- if regions[active_region].x <= tc.x + tc.width + tc.border_width * 2 and
|
||||||
tc.x <= regions[active_region].x + regions[active_region].width and
|
-- tc.x <= regions[active_region].x + regions[active_region].width and
|
||||||
regions[active_region].y <= tc.y + tc.height + tc.border_width * 2 and
|
-- regions[active_region].y <= tc.y + tc.height + tc.border_width * 2 and
|
||||||
tc.y <= regions[active_region].y + regions[active_region].height
|
-- tc.y <= regions[active_region].y + regions[active_region].height
|
||||||
|
-- then
|
||||||
|
-- tablist[#tablist + 1] = tc
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
-- end --|tablist inside the active region
|
||||||
|
-- --|this will create issues with overflowing clients such as the ones
|
||||||
|
-- --|expanded to center or anything intersecting for that matter.
|
||||||
|
|
||||||
|
for _, tc in ipairs(s.clients) do
|
||||||
|
if not (tc.floating) then
|
||||||
|
if math.abs(regions[active_region].x - tc.x) <= 5 and
|
||||||
|
math.abs(regions[active_region].y - tc.y) <= 5
|
||||||
then
|
then
|
||||||
tablist[#tablist + 1] = tc
|
tablist[#tablist + 1] = tc
|
||||||
end
|
end
|
||||||
|
@ -357,18 +343,6 @@ local function expand_horizontal(direction)
|
||||||
c.maximized_horizontal = true
|
c.maximized_horizontal = true
|
||||||
c.maximixed_vertical = false
|
c.maximixed_vertical = false
|
||||||
|
|
||||||
-- if not c.floating then
|
|
||||||
-- awful.layout.get(focused_screen).machi_zort(c, tobe)
|
|
||||||
-- instance_data = awful.layout.get(
|
|
||||||
-- awful.screen.focused())
|
|
||||||
-- .machi_get_instance_data(awful.screen.focused(), awful.screen.selected_tag)
|
|
||||||
-- naughty.notify({text=inspect(instance_data)})
|
|
||||||
|
|
||||||
-- instance_data[c] = {
|
|
||||||
-- lu=0, rd=0
|
|
||||||
-- }
|
|
||||||
-- end
|
|
||||||
|
|
||||||
gears.timer.delayed_call(function (c)
|
gears.timer.delayed_call(function (c)
|
||||||
c:geometry(tobe)
|
c:geometry(tobe)
|
||||||
draw_tabbar(c.region)
|
draw_tabbar(c.region)
|
||||||
|
@ -438,9 +412,6 @@ end
|
||||||
--|tiled clients require an internal maximized property to
|
--|tiled clients require an internal maximized property to
|
||||||
--|be set, otherwise they won't budge.
|
--|be set, otherwise they won't budge.
|
||||||
|
|
||||||
--|change the logic handling for the center layout to use
|
|
||||||
--|fixedchoices
|
|
||||||
|
|
||||||
----------------------------------------------------- expand_vertical() -- ;
|
----------------------------------------------------- expand_vertical() -- ;
|
||||||
|
|
||||||
local function expand_vertical()
|
local function expand_vertical()
|
||||||
|
@ -719,7 +690,7 @@ end
|
||||||
|
|
||||||
function get_tiled_clients(region_ix, s)
|
function get_tiled_clients(region_ix, s)
|
||||||
local s = s or awful.screen.focused()
|
local s = s or awful.screen.focused()
|
||||||
local tablist = test_tablist(region_ix, c, s)
|
local tablist = pest_tablist(region_ix, c, s)
|
||||||
local all_clients = get_global_clients()
|
local all_clients = get_global_clients()
|
||||||
local tiled_clients = {}
|
local tiled_clients = {}
|
||||||
local myorder = {}
|
local myorder = {}
|
||||||
|
@ -844,36 +815,39 @@ function resize_region(region_ix, geom, reset)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function teleport_client(c)
|
local function teleport_client(c,s)
|
||||||
-- todo: need to recalculate tabs and also update c.region
|
local c = c or client.focus
|
||||||
local cl = c or client.focus
|
local s = s or c.screen or awful.screen.focused()
|
||||||
if not cl then return true end
|
|
||||||
|
|
||||||
|
if not c then return true end
|
||||||
|
--|flow control
|
||||||
|
|
||||||
local is = {
|
local is = {
|
||||||
region=cl.region or get_client_info(c).active_region,
|
region=c.region or get_client_info(c).active_region,
|
||||||
geom=cl:geometry(),
|
geom=c:geometry(),
|
||||||
screen=cl.screen.index
|
screen=c.screen
|
||||||
|
} --|parameters before teleport
|
||||||
|
|
||||||
|
-- log(is)
|
||||||
|
|
||||||
|
if not c.floating then
|
||||||
|
c:geometry({width=300, height=300})
|
||||||
|
end --|to avoid machi's auto expansion (lu,rd) of tiled
|
||||||
|
--|clients, resize them temporarily. they will be auto
|
||||||
|
--|expanded to the region anyway.
|
||||||
|
|
||||||
|
c:move_to_screen()
|
||||||
|
--|teleport
|
||||||
|
|
||||||
|
gears.timer.delayed_call(function (c)
|
||||||
|
local tobe = {
|
||||||
|
region=get_client_info(c).active_region,
|
||||||
}
|
}
|
||||||
|
c.region = tobe.region
|
||||||
if not cl.floating then
|
draw_tabbar(c.region, c.screen )
|
||||||
cl:geometry({width=300, height=300})
|
draw_tabbar(is.region, is.screen )
|
||||||
end --|to avoid machi's auto expansion
|
c:emit_signal("request::activate", "mouse_enter",{raise = true})
|
||||||
|
end,c)
|
||||||
|
|
||||||
cl:move_to_screen()
|
|
||||||
local new_region = get_client_info(c).active_region
|
|
||||||
|
|
||||||
if not new_region then
|
|
||||||
c.region = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
gears.timer.delayed_call(function (cl)
|
|
||||||
|
|
||||||
-- clear_tabbar(cl)
|
|
||||||
cl:emit_signal("request::activate", "mouse_enter",{raise = true})
|
|
||||||
cl:emit_signal("draw_tabbar", new_region)
|
|
||||||
end,cl)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
------------------------------------------------------ signal helpers -- ;
|
------------------------------------------------------ signal helpers -- ;
|
||||||
|
@ -884,9 +858,10 @@ local function manage_signal(c)
|
||||||
--|add window.id to client index
|
--|add window.id to client index
|
||||||
|
|
||||||
local active_region = get_client_info(c).active_region
|
local active_region = get_client_info(c).active_region
|
||||||
|
|
||||||
if active_region then
|
if active_region then
|
||||||
c.region = active_region
|
|
||||||
gears.timer.delayed_call(function(region, screen)
|
gears.timer.delayed_call(function(region, screen)
|
||||||
|
c.region = active_region
|
||||||
draw_tabbar(region, screen)
|
draw_tabbar(region, screen)
|
||||||
end, active_region, c.screen)
|
end, active_region, c.screen)
|
||||||
|
|
||||||
|
@ -912,14 +887,14 @@ local function unmanage_signal(c)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function selected_tag_signal(t)
|
local function selected_tag_signal(t)
|
||||||
-- gears.timer.delayed_call(function(t)
|
gears.timer.delayed_call(function(t)
|
||||||
local regions = get_regions()
|
local regions = get_regions(t.screen)
|
||||||
if regions and #regions then
|
if regions and #regions then
|
||||||
for i, region in ipairs(regions) do
|
for i, region in ipairs(regions) do
|
||||||
draw_tabbar(i, tag.screen)
|
draw_tabbar(i, t.screen)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- end,t)
|
end,t)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function floating_signal(c)
|
local function floating_signal(c)
|
||||||
|
@ -928,6 +903,7 @@ local function floating_signal(c)
|
||||||
gears.timer.delayed_call(function(active_region)
|
gears.timer.delayed_call(function(active_region)
|
||||||
clear_tabbar(c)
|
clear_tabbar(c)
|
||||||
draw_tabbar(c.region)
|
draw_tabbar(c.region)
|
||||||
|
c.region = nil --| check for side effects
|
||||||
end, active_region)
|
end, active_region)
|
||||||
end
|
end
|
||||||
end --|window became floating
|
end --|window became floating
|
||||||
|
@ -966,12 +942,10 @@ client.connect_signal("tabbar_draw", draw_tabbar)
|
||||||
-- client:connect_signal("property::name", function(c)
|
-- client:connect_signal("property::name", function(c)
|
||||||
-- if widget_ix[c.window] then
|
-- if widget_ix[c.window] then
|
||||||
-- local widget = widget_ix[c.window]:get_children_by_id(c.window)
|
-- local widget = widget_ix[c.window]:get_children_by_id(c.window)
|
||||||
|
|
||||||
-- text_temp.markup = "<span foreground='" .. fg_temp .. "'>" .. title_temp.. "</span>"
|
-- text_temp.markup = "<span foreground='" .. fg_temp .. "'>" .. title_temp.. "</span>"
|
||||||
-- end
|
-- end
|
||||||
-- end)
|
-- end)
|
||||||
|
|
||||||
|
|
||||||
client.connect_signal("unmanage", unmanage_signal)
|
client.connect_signal("unmanage", unmanage_signal)
|
||||||
--[[+]
|
--[[+]
|
||||||
when removing a tiled client we must update the tabbars
|
when removing a tiled client we must update the tabbars
|
||||||
|
|
Loading…
Reference in New Issue