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.
|
-- Register an arrange hook.
|
||||||
local function on_arrange (screen)
|
local function on_arrange (screen)
|
||||||
get(screen)(screen)
|
get(screen).arrange(screen)
|
||||||
end
|
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.
|
--- Get the current layout name.
|
||||||
-- @param layout the layout name.
|
-- @param layout the layout name.
|
||||||
-- @return The layout name.
|
-- @return The layout name.
|
||||||
function getname(layout)
|
function getname(layout)
|
||||||
return layouts_name[layout]
|
return layout.name
|
||||||
end
|
end
|
||||||
|
|
||||||
hooks.arrange.register(on_arrange)
|
hooks.arrange.register(on_arrange)
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
-- Grab environment we need
|
-- Grab environment we need
|
||||||
local setmetatable = setmetatable
|
|
||||||
local ipairs = ipairs
|
local ipairs = ipairs
|
||||||
local math = math
|
local math = math
|
||||||
local client = require("awful.client")
|
local client = require("awful.client")
|
||||||
|
@ -63,16 +62,18 @@ local function fair(screen, orientation)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Horizontal fair layout.
|
--- Horizontal fair layout.
|
||||||
-- @param screen The screen to arrange.
|
-- @param screen The screen to arrange.
|
||||||
function horizontal(screen)
|
horizontal = {}
|
||||||
return fair(screen, "east")
|
horizontal.name = "fairh"
|
||||||
|
function horizontal.arrange(p)
|
||||||
|
return fair(p, "east")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Vertical fair layout.
|
-- Vertical fair layout.
|
||||||
-- @param screen The screen to arrange.
|
-- @param screen The screen to arrange.
|
||||||
local function fairv(_, screen)
|
name = "fairv"
|
||||||
return fair(screen, "south")
|
function arrange(p)
|
||||||
|
return fair(p, "south")
|
||||||
end
|
end
|
||||||
|
|
||||||
setmetatable(_M, { __call = fairv })
|
|
||||||
|
|
|
@ -4,14 +4,11 @@
|
||||||
-- @release @AWESOME_VERSION@
|
-- @release @AWESOME_VERSION@
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
-- Grab environment we need
|
|
||||||
local setmetatable = setmetatable
|
|
||||||
|
|
||||||
--- Dummy function for floating layout
|
--- Dummy function for floating layout
|
||||||
module("awful.layout.suit.floating")
|
module("awful.layout.suit.floating")
|
||||||
|
|
||||||
local function floating(_, screen)
|
function arrange(screen)
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
setmetatable(_M, { __call = floating })
|
name = "floating"
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
-- Grab environment we need
|
-- Grab environment we need
|
||||||
local setmetatable = setmetatable
|
|
||||||
local ipairs = ipairs
|
local ipairs = ipairs
|
||||||
local math = math
|
local math = math
|
||||||
local tag = require("awful.tag")
|
local tag = require("awful.tag")
|
||||||
|
@ -19,7 +18,7 @@ local client = require("awful.client")
|
||||||
--- Magnifier layout module for awful
|
--- Magnifier layout module for awful
|
||||||
module("awful.layout.suit.magnifier")
|
module("awful.layout.suit.magnifier")
|
||||||
|
|
||||||
local function magnifier(_, screen)
|
function arrange(screen)
|
||||||
-- Fullscreen?
|
-- Fullscreen?
|
||||||
local area = capi.screen[screen].workarea
|
local area = capi.screen[screen].workarea
|
||||||
local cls = client.tiled(screen)
|
local cls = client.tiled(screen)
|
||||||
|
@ -91,4 +90,4 @@ local function magnifier(_, screen)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
setmetatable(_M, { __call = magnifier })
|
name = "magnifier"
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
-- Grab environment we need
|
-- Grab environment we need
|
||||||
local setmetatable = setmetatable
|
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
local client = require("awful.client")
|
local client = require("awful.client")
|
||||||
local capi =
|
local capi =
|
||||||
|
@ -34,14 +33,15 @@ end
|
||||||
|
|
||||||
--- Maximized layout.
|
--- Maximized layout.
|
||||||
-- @param screen The screen to arrange.
|
-- @param screen The screen to arrange.
|
||||||
local function max(_, screen)
|
name = "max"
|
||||||
|
function arrange(screen)
|
||||||
return fmax(screen, false)
|
return fmax(screen, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Fullscreen layout.
|
--- Fullscreen layout.
|
||||||
-- @param screen The screen to arrange.
|
-- @param screen The screen to arrange.
|
||||||
function fullscreen(screen)
|
fullscreen = {}
|
||||||
|
fullscreen.name = "fullscreen"
|
||||||
|
function fullscreen.arrange(screen)
|
||||||
return fmax(screen, true)
|
return fmax(screen, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
setmetatable(_M, { __call = max })
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
-- Grab environment we need
|
-- Grab environment we need
|
||||||
local setmetatable = setmetatable
|
|
||||||
local ipairs = ipairs
|
local ipairs = ipairs
|
||||||
local math = math
|
local math = math
|
||||||
local client = require("awful.client")
|
local client = require("awful.client")
|
||||||
|
@ -79,7 +78,7 @@ local function tile_group(cls, wa, orientation, fact, group)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function tile(_, screen, orientation)
|
local function tile(screen, orientation)
|
||||||
orientation = orientation or "right"
|
orientation = orientation or "right"
|
||||||
|
|
||||||
-- this handles are different orientations
|
-- this handles are different orientations
|
||||||
|
@ -156,22 +155,33 @@ local function tile(_, screen, orientation)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
right = {}
|
||||||
|
right.name = "tile"
|
||||||
|
right.arrange = tile
|
||||||
|
|
||||||
--- The main tile algo, on left.
|
--- The main tile algo, on left.
|
||||||
-- @param screen The screen number to tile.
|
-- @param screen The screen number to tile.
|
||||||
function left(screen)
|
left = {}
|
||||||
return tile(nil, screen, "left")
|
left.name = "tileleft"
|
||||||
|
function left.arrange(screen)
|
||||||
|
return tile(screen, "left")
|
||||||
end
|
end
|
||||||
|
|
||||||
--- The main tile algo, on bottom.
|
--- The main tile algo, on bottom.
|
||||||
-- @param screen The screen number to tile.
|
-- @param screen The screen number to tile.
|
||||||
function bottom(screen)
|
bottom = {}
|
||||||
return tile(nil, screen, "bottom")
|
bottom.name = "tilebottom"
|
||||||
|
function bottom.arrange(screen)
|
||||||
|
return tile(screen, "bottom")
|
||||||
end
|
end
|
||||||
|
|
||||||
--- The main tile algo, on top.
|
--- The main tile algo, on top.
|
||||||
-- @param screen The screen number to tile.
|
-- @param screen The screen number to tile.
|
||||||
function top(screen)
|
top = {}
|
||||||
return tile(nil, screen, "top")
|
top.name = "tiletop"
|
||||||
|
function top.arrange(screen)
|
||||||
|
return tile(screen, "top")
|
||||||
end
|
end
|
||||||
|
|
||||||
setmetatable(_M, { __call = tile })
|
arrange = right.arrange
|
||||||
|
name = right.name
|
||||||
|
|
Loading…
Reference in New Issue