awful.layout: store name into module
Layouts now store their name as a string and their arrange function in a table rather than being stored as the entire module. Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
8745d691fe
commit
a2fe3919f2
|
@ -59,28 +59,14 @@ end
|
|||
|
||||
-- Register an arrange hook.
|
||||
local function on_arrange (screen)
|
||||
get(screen)(screen)
|
||||
get(screen).arrange(screen)
|
||||
end
|
||||
|
||||
local layouts_name =
|
||||
{
|
||||
[suit.tile] = "tile",
|
||||
[suit.tile.left] = "tileleft",
|
||||
[suit.tile.bottom] = "tilebottom",
|
||||
[suit.tile.top] = "tiletop",
|
||||
[suit.fair] = "fairv",
|
||||
[suit.fair.horizontal] = "fairh",
|
||||
[suit.max] = "max",
|
||||
[suit.max.fullscreen] = "fullscreen",
|
||||
[suit.magnifier] = "magnifier",
|
||||
[suit.floating] = "floating"
|
||||
}
|
||||
|
||||
--- Get the current layout name.
|
||||
-- @param layout the layout name.
|
||||
-- @return The layout name.
|
||||
function getname(layout)
|
||||
return layouts_name[layout]
|
||||
return layout.name
|
||||
end
|
||||
|
||||
hooks.arrange.register(on_arrange)
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
---------------------------------------------------------------------------
|
||||
|
||||
-- Grab environment we need
|
||||
local setmetatable = setmetatable
|
||||
local ipairs = ipairs
|
||||
local math = math
|
||||
local client = require("awful.client")
|
||||
|
@ -63,16 +62,18 @@ local function fair(screen, orientation)
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Horizontal fair layout.
|
||||
-- @param screen The screen to arrange.
|
||||
function horizontal(screen)
|
||||
return fair(screen, "east")
|
||||
horizontal = {}
|
||||
horizontal.name = "fairh"
|
||||
function horizontal.arrange(p)
|
||||
return fair(p, "east")
|
||||
end
|
||||
|
||||
-- Vertical fair layout.
|
||||
-- @param screen The screen to arrange.
|
||||
local function fairv(_, screen)
|
||||
return fair(screen, "south")
|
||||
name = "fairv"
|
||||
function arrange(p)
|
||||
return fair(p, "south")
|
||||
end
|
||||
|
||||
setmetatable(_M, { __call = fairv })
|
||||
|
|
|
@ -4,14 +4,11 @@
|
|||
-- @release @AWESOME_VERSION@
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
-- Grab environment we need
|
||||
local setmetatable = setmetatable
|
||||
|
||||
--- Dummy function for floating layout
|
||||
module("awful.layout.suit.floating")
|
||||
|
||||
local function floating(_, screen)
|
||||
function arrange(screen)
|
||||
return nil
|
||||
end
|
||||
|
||||
setmetatable(_M, { __call = floating })
|
||||
name = "floating"
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
---------------------------------------------------------------------------
|
||||
|
||||
-- Grab environment we need
|
||||
local setmetatable = setmetatable
|
||||
local ipairs = ipairs
|
||||
local math = math
|
||||
local tag = require("awful.tag")
|
||||
|
@ -19,7 +18,7 @@ local client = require("awful.client")
|
|||
--- Magnifier layout module for awful
|
||||
module("awful.layout.suit.magnifier")
|
||||
|
||||
local function magnifier(_, screen)
|
||||
function arrange(screen)
|
||||
-- Fullscreen?
|
||||
local area = capi.screen[screen].workarea
|
||||
local cls = client.tiled(screen)
|
||||
|
@ -91,4 +90,4 @@ local function magnifier(_, screen)
|
|||
end
|
||||
end
|
||||
|
||||
setmetatable(_M, { __call = magnifier })
|
||||
name = "magnifier"
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
---------------------------------------------------------------------------
|
||||
|
||||
-- Grab environment we need
|
||||
local setmetatable = setmetatable
|
||||
local pairs = pairs
|
||||
local client = require("awful.client")
|
||||
local capi =
|
||||
|
@ -34,14 +33,15 @@ end
|
|||
|
||||
--- Maximized layout.
|
||||
-- @param screen The screen to arrange.
|
||||
local function max(_, screen)
|
||||
name = "max"
|
||||
function arrange(screen)
|
||||
return fmax(screen, false)
|
||||
end
|
||||
|
||||
--- Fullscreen layout.
|
||||
-- @param screen The screen to arrange.
|
||||
function fullscreen(screen)
|
||||
fullscreen = {}
|
||||
fullscreen.name = "fullscreen"
|
||||
function fullscreen.arrange(screen)
|
||||
return fmax(screen, true)
|
||||
end
|
||||
|
||||
setmetatable(_M, { __call = max })
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
---------------------------------------------------------------------------
|
||||
|
||||
-- Grab environment we need
|
||||
local setmetatable = setmetatable
|
||||
local ipairs = ipairs
|
||||
local math = math
|
||||
local client = require("awful.client")
|
||||
|
@ -79,7 +78,7 @@ local function tile_group(cls, wa, orientation, fact, group)
|
|||
|
||||
end
|
||||
|
||||
local function tile(_, screen, orientation)
|
||||
local function tile(screen, orientation)
|
||||
orientation = orientation or "right"
|
||||
|
||||
-- this handles are different orientations
|
||||
|
@ -156,22 +155,33 @@ local function tile(_, screen, orientation)
|
|||
|
||||
end
|
||||
|
||||
right = {}
|
||||
right.name = "tile"
|
||||
right.arrange = tile
|
||||
|
||||
--- The main tile algo, on left.
|
||||
-- @param screen The screen number to tile.
|
||||
function left(screen)
|
||||
return tile(nil, screen, "left")
|
||||
left = {}
|
||||
left.name = "tileleft"
|
||||
function left.arrange(screen)
|
||||
return tile(screen, "left")
|
||||
end
|
||||
|
||||
--- The main tile algo, on bottom.
|
||||
-- @param screen The screen number to tile.
|
||||
function bottom(screen)
|
||||
return tile(nil, screen, "bottom")
|
||||
bottom = {}
|
||||
bottom.name = "tilebottom"
|
||||
function bottom.arrange(screen)
|
||||
return tile(screen, "bottom")
|
||||
end
|
||||
|
||||
--- The main tile algo, on top.
|
||||
-- @param screen The screen number to tile.
|
||||
function top(screen)
|
||||
return tile(nil, screen, "top")
|
||||
top = {}
|
||||
top.name = "tiletop"
|
||||
function top.arrange(screen)
|
||||
return tile(screen, "top")
|
||||
end
|
||||
|
||||
setmetatable(_M, { __call = tile })
|
||||
arrange = right.arrange
|
||||
name = right.name
|
||||
|
|
Loading…
Reference in New Issue