Added support for vertical monitors
This commit is contained in:
35
src/layouts/fair_col.lua
Normal file
35
src/layouts/fair_col.lua
Normal file
@@ -0,0 +1,35 @@
|
||||
local ipairs = ipairs
|
||||
local math = math
|
||||
|
||||
local fair = {}
|
||||
fair.name = "fairc"
|
||||
|
||||
function fair.arrange(s)
|
||||
local wa = s.workarea
|
||||
local cls = s.clients
|
||||
|
||||
if #cls > 0 then
|
||||
local clc = #cls
|
||||
local row_h = math.ceil(wa.height / clc)
|
||||
clc = clc - 1
|
||||
|
||||
for i, c in ipairs(cls) do
|
||||
i = i - 1
|
||||
local g = {
|
||||
width=wa.width,
|
||||
x=wa.x
|
||||
}
|
||||
if i == clc then
|
||||
g.height = wa.height - row_h * i
|
||||
g.y = wa.y + wa.height - g.height
|
||||
else
|
||||
g.height = row_h
|
||||
g.y = wa.y + row_h * i
|
||||
end
|
||||
|
||||
s.geometries[c] = g
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return fair
|
||||
17
src/layouts/init.lua
Normal file
17
src/layouts/init.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
local awful = require('awful')
|
||||
local fair_col = require('src.layouts.fair_col')
|
||||
local tile_col = require('src.layouts.tile_col')
|
||||
|
||||
tag.connect_signal("request::default_layouts", function()
|
||||
awful.layout.append_default_layouts({
|
||||
awful.layout.suit.fair,
|
||||
awful.layout.suit.fair.horizontal,
|
||||
awful.layout.suit.tile,
|
||||
awful.layout.suit.tile.left,
|
||||
awful.layout.suit.tile.bottom,
|
||||
awful.layout.suit.tile.top,
|
||||
awful.layout.suit.floating,
|
||||
fair_col,
|
||||
--tile_col
|
||||
})
|
||||
end)
|
||||
120
src/layouts/tile_col.lua
Normal file
120
src/layouts/tile_col.lua
Normal file
@@ -0,0 +1,120 @@
|
||||
local tag = require("awful.tag")
|
||||
local client = require("awful.client")
|
||||
local ipairs = ipairs
|
||||
local math = math
|
||||
local capi = {
|
||||
mouse = mouse,
|
||||
screen = screen,
|
||||
mousegrabber = mousegrabber
|
||||
}
|
||||
|
||||
local debug = require('gears.debug').dump
|
||||
|
||||
local function apply_size_hints(c, width, height, useless_gap)
|
||||
local bw = c.border_width
|
||||
width, height = width - 2 * bw - useless_gap, height - 2 * bw - useless_gap
|
||||
_, height = c:apply_size_hints(math.max(1, width), math.max(1, height))
|
||||
return height + 2 * bw + useless_gap
|
||||
end
|
||||
|
||||
local tile = {}
|
||||
tile.name = "tilec"
|
||||
|
||||
function tile.arrange(s)
|
||||
local t = s.tag or capi.screen[s.screen].selected_tag
|
||||
local gs = s.geometries
|
||||
local cls = s.clients
|
||||
local useless_gap = s.useless_gap
|
||||
local nmaster = #cls
|
||||
local wa = s.workarea
|
||||
|
||||
local fact = tag.getdata(t).windowfact
|
||||
if not fact then
|
||||
fact = {}
|
||||
tag.getdata(t).windowfact = fact
|
||||
end
|
||||
|
||||
if #cls > 0 then
|
||||
debug(fact)
|
||||
-- find our total values
|
||||
local total_fact = 0
|
||||
local min_fact = 1
|
||||
for i = 1,nmaster do
|
||||
-- calculate the height
|
||||
if not fact[i] then
|
||||
fact[i] = min_fact
|
||||
else
|
||||
min_fact = math.min(fact[i],min_fact)
|
||||
end
|
||||
total_fact = total_fact + fact[i]
|
||||
end
|
||||
|
||||
local coord = wa.y
|
||||
local unused = wa.height
|
||||
for c = 1,nmaster do
|
||||
local geom = {}
|
||||
geom.width = wa.width
|
||||
geom.height = math.max(1, math.floor(unused * fact[c] / total_fact))
|
||||
geom.x = wa.x
|
||||
geom.y = coord
|
||||
gs[cls[c]] = geom
|
||||
local height = apply_size_hints(cls[c], geom.width, geom.height, useless_gap)
|
||||
coord = coord + height
|
||||
unused = unused - height
|
||||
total_fact = total_fact - fact[c]
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function tile.skip_gap(nclients, t) return nclients == 1 and t.master_fill_policy == "expand" end
|
||||
|
||||
function tile.mouse_resize_handler(c, _, _, _)
|
||||
local wa = c.screen.workarea
|
||||
local t = c.screen.selected_tag
|
||||
local useless_gap = t.gap
|
||||
local g = c:geometry()
|
||||
local i = client.idx(c).idx
|
||||
local fact = tag.getdata(t).windowfact
|
||||
if not fact then
|
||||
fact = {}
|
||||
tag.getdata(t).windowfact = fact
|
||||
end
|
||||
local offset = 0
|
||||
if g.height+useless_gap+15 > wa.height then
|
||||
offset = g.height * .5
|
||||
elseif g.y+g.height+useless_gap+15 <= wa.y+wa.height then
|
||||
offset = g.height
|
||||
end
|
||||
|
||||
|
||||
print(g.y + (((capi.mouse.coords().y - g.y) >= (g.height / 2)) and g.height or 0))
|
||||
capi.mouse.coords { x = wa.x + wa.width * 0.5, y = g.y + offset }
|
||||
local prev_coords = {}
|
||||
capi.mousegrabber.run(function(coords)
|
||||
if not c.valid then return false end
|
||||
|
||||
for _, v in ipairs(coords.buttons) do
|
||||
if v then
|
||||
prev_coords = { y = coords.y }
|
||||
|
||||
local geom = c:geometry()
|
||||
|
||||
local wfact
|
||||
if (geom.y + geom.height + useless_gap + 15) > (wa.y + wa.height) then
|
||||
wfact = (geom.y + geom.height - coords.y) / wa.height
|
||||
else
|
||||
wfact = (coords.y - geom.y) / wa.height
|
||||
end
|
||||
|
||||
fact[i] = math.min(math.max(wfact, 0.01), 0.99)
|
||||
t:emit_signal("property::windowfact")
|
||||
print(fact[i])
|
||||
return true
|
||||
end
|
||||
end
|
||||
return (prev_coords.y == coords.y)
|
||||
end, "sb_v_double_arrow")
|
||||
end
|
||||
|
||||
return tile
|
||||
Reference in New Issue
Block a user