awful.layout: do not use global env
Layouts are passed a data structure that holds all the information they need to render the clients. Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
a2fe3919f2
commit
2a2166d856
|
@ -9,6 +9,7 @@ local ipairs = ipairs
|
|||
local tag = require("awful.tag")
|
||||
local util = require("awful.util")
|
||||
local suit = require("awful.layout.suit")
|
||||
local client = require("awful.client")
|
||||
local capi =
|
||||
{
|
||||
hooks = hooks,
|
||||
|
@ -59,7 +60,16 @@ end
|
|||
|
||||
-- Register an arrange hook.
|
||||
local function on_arrange (screen)
|
||||
get(screen).arrange(screen)
|
||||
local t = tag.selected(screen)
|
||||
local p = {}
|
||||
p.workarea = capi.screen[screen].workarea
|
||||
p.geometry = capi.screen[screen].geometry
|
||||
p.clients = client.tiled(screen)
|
||||
p.ncol = tag.getncol(t)
|
||||
p.nmaster = tag.getnmaster(t)
|
||||
p.mwfact = tag.getmwfact(t)
|
||||
p.tagdata = tag.getdata(t)
|
||||
get(screen).arrange(p)
|
||||
end
|
||||
|
||||
--- Get the current layout name.
|
||||
|
|
|
@ -7,18 +7,13 @@
|
|||
-- Grab environment we need
|
||||
local ipairs = ipairs
|
||||
local math = math
|
||||
local client = require("awful.client")
|
||||
local capi =
|
||||
{
|
||||
screen = screen
|
||||
}
|
||||
|
||||
--- Fair layouts module for awful
|
||||
module("awful.layout.suit.fair")
|
||||
|
||||
local function fair(screen, orientation)
|
||||
local wa = capi.screen[screen].workarea
|
||||
local cls = client.tiled(screen)
|
||||
local function fair(p, orientation)
|
||||
local wa = p.workarea
|
||||
local cls = p.clients
|
||||
|
||||
if #cls > 0 then
|
||||
local cells = math.ceil(math.sqrt(#cls))
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
--- Dummy function for floating layout
|
||||
module("awful.layout.suit.floating")
|
||||
|
||||
function arrange(screen)
|
||||
function arrange(p)
|
||||
return nil
|
||||
end
|
||||
|
||||
|
|
|
@ -18,14 +18,12 @@ local client = require("awful.client")
|
|||
--- Magnifier layout module for awful
|
||||
module("awful.layout.suit.magnifier")
|
||||
|
||||
function arrange(screen)
|
||||
function arrange(p)
|
||||
-- Fullscreen?
|
||||
local area = capi.screen[screen].workarea
|
||||
local cls = client.tiled(screen)
|
||||
local area = p.workarea
|
||||
local cls = p.clients
|
||||
local focus = capi.client.focus
|
||||
local t = tag.selected(screen)
|
||||
local mwfact = tag.getmwfact(t)
|
||||
local fidx -- Focus client index in cls table
|
||||
local mwfact = p.mwfact
|
||||
|
||||
-- Check that the focused window is on the right screen
|
||||
if focus and focus.screen ~= screen then focus = nil end
|
||||
|
|
|
@ -7,41 +7,35 @@
|
|||
-- Grab environment we need
|
||||
local pairs = pairs
|
||||
local client = require("awful.client")
|
||||
local capi =
|
||||
{
|
||||
screen = screen
|
||||
}
|
||||
|
||||
--- Maximized and fullscreen layouts module for awful
|
||||
module("awful.layout.suit.max")
|
||||
|
||||
local function fmax(screen, fs)
|
||||
local function fmax(p, fs)
|
||||
-- Fullscreen?
|
||||
local area
|
||||
if fs then
|
||||
area = capi.screen[screen].geometry
|
||||
area = p.geometry
|
||||
else
|
||||
area = capi.screen[screen].workarea
|
||||
area = p.workarea
|
||||
end
|
||||
|
||||
for k, c in pairs(client.visible(screen)) do
|
||||
if not client.floating.get(c) then
|
||||
for k, c in pairs(p.clients) do
|
||||
c:geometry(area)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Maximized layout.
|
||||
-- @param screen The screen to arrange.
|
||||
name = "max"
|
||||
function arrange(screen)
|
||||
return fmax(screen, false)
|
||||
function arrange(p)
|
||||
return fmax(p, false)
|
||||
end
|
||||
|
||||
--- Fullscreen layout.
|
||||
-- @param screen The screen to arrange.
|
||||
fullscreen = {}
|
||||
fullscreen.name = "fullscreen"
|
||||
function fullscreen.arrange(screen)
|
||||
return fmax(screen, true)
|
||||
function fullscreen.arrange(p)
|
||||
return fmax(p, true)
|
||||
end
|
||||
|
|
|
@ -9,12 +9,6 @@
|
|||
-- Grab environment we need
|
||||
local ipairs = ipairs
|
||||
local math = math
|
||||
local client = require("awful.client")
|
||||
local tag = require("awful.tag")
|
||||
local capi =
|
||||
{
|
||||
screen = screen
|
||||
}
|
||||
|
||||
--- Tiled layouts module for awful
|
||||
module("awful.layout.suit.tile")
|
||||
|
@ -75,10 +69,9 @@ local function tile_group(cls, wa, orientation, fact, group)
|
|||
end
|
||||
|
||||
return used_size
|
||||
|
||||
end
|
||||
|
||||
local function tile(screen, orientation)
|
||||
local function tile(param, orientation)
|
||||
orientation = orientation or "right"
|
||||
|
||||
-- this handles are different orientations
|
||||
|
@ -93,23 +86,21 @@ local function tile(screen, orientation)
|
|||
y = "x"
|
||||
end
|
||||
|
||||
local t = tag.selected(screen)
|
||||
local cls = client.tiled(screen)
|
||||
local nmaster = math.min(tag.getnmaster(t), #cls)
|
||||
local cls = param.clients
|
||||
local nmaster = math.min(param.nmaster, #cls)
|
||||
local nother = math.max(#cls - nmaster,0)
|
||||
|
||||
local mwfact = tag.getmwfact(t)
|
||||
local wa = capi.screen[screen].workarea
|
||||
local ncol = tag.getncol(t)
|
||||
local mwfact = param.mwfact
|
||||
local wa = param.workarea
|
||||
local ncol = param.ncol
|
||||
|
||||
local data = tag.getproperty(t,"windowfact")
|
||||
local data = param.tagdata.windowfact
|
||||
|
||||
if not data then
|
||||
data = {}
|
||||
tag.setproperty(t,"windowfact", data)
|
||||
param.tagdata.windowfact = data
|
||||
end
|
||||
|
||||
--
|
||||
local coord = wa[x]
|
||||
local place_master = true
|
||||
if orientation == "left" or orientation == "top" then
|
||||
|
@ -163,24 +154,24 @@ right.arrange = tile
|
|||
-- @param screen The screen number to tile.
|
||||
left = {}
|
||||
left.name = "tileleft"
|
||||
function left.arrange(screen)
|
||||
return tile(screen, "left")
|
||||
function left.arrange(p)
|
||||
return tile(p, "left")
|
||||
end
|
||||
|
||||
--- The main tile algo, on bottom.
|
||||
-- @param screen The screen number to tile.
|
||||
bottom = {}
|
||||
bottom.name = "tilebottom"
|
||||
function bottom.arrange(screen)
|
||||
return tile(screen, "bottom")
|
||||
function bottom.arrange(p)
|
||||
return tile(p, "bottom")
|
||||
end
|
||||
|
||||
--- The main tile algo, on top.
|
||||
-- @param screen The screen number to tile.
|
||||
top = {}
|
||||
top.name = "tiletop"
|
||||
function top.arrange(screen)
|
||||
return tile(screen, "top")
|
||||
function top.arrange(p)
|
||||
return tile(p, "top")
|
||||
end
|
||||
|
||||
arrange = right.arrange
|
||||
|
|
|
@ -244,6 +244,13 @@ local function hook_tags(screen, tag, action)
|
|||
end
|
||||
end
|
||||
|
||||
--- Get tag data table.
|
||||
-- @param tag The Tag.
|
||||
-- @return The data table.
|
||||
function getdata(tag)
|
||||
return data.tags[tag]
|
||||
end
|
||||
|
||||
--- Get a tag property.
|
||||
-- @param tag The tag.
|
||||
-- @param prop The property name.
|
||||
|
|
Loading…
Reference in New Issue