Skip to content

Instantly share code, notes, and snippets.

@wxg4net
Created April 24, 2015 00:31
Show Gist options
  • Save wxg4net/fba47cacbd1e9066c90e to your computer and use it in GitHub Desktop.
Save wxg4net/fba47cacbd1e9066c90e to your computer and use it in GitHub Desktop.
awesome窗口程序固定布局
---------------------------------------------------------------------------
--- Fair layouts module for awful
--
-- @author wxg
-- @copyright 2015 Josh wxg
-- @release @AWESOME_VERSION@
-- @module awful.layout.suit.firefox
---------------------------------------------------------------------------
-- Grab environment we need
local ipairs = ipairs
local math = math
local firefox = {}
local function do_firefox(p)
local wa = p.workarea
local cls = p.clients
if #cls > 0 then
local rows, cols = #cls, 1
local ff = false
if #cls > 1 then
for k, c in ipairs(cls) do
if c.class = 'Firefox' then
local g = {}
g.height = wa.height
g.width = wa.width/2
g.y = wa.y
g.x = wa.width/2 + wa.x
p.geometries[c] = g
table.remove(cls,k)
ff = true
break
end
end
end
local width = wa.width
if ff then
rows, cols = #cls-1, 2
width = wa.width/2
end
local height = math.ceil(wa.height / rows)
for k, c in ipairs(cls) do
k = k - 1
local g = {}
g.height = height
g.width = width
g.y = g.height * k + wa.y
g.x = 0 + wa.x
p.geometries[c] = g
end
end
end
--- Vertical firefox layout.
-- @param screen The screen to arrange.
firefox.name = "firefoxv"
function firefox.arrange(p)
return do_firefox(p)
end
return firefox
@wxg4net
Copy link
Author

wxg4net commented Apr 24, 2015

多个firefox窗口时,只对第一个发现的firefox做特定处理 其余按照一般窗口处理。如果没有firefox时,布局会采用等高排列。适合多终端。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment