Ported awful.layout.suit to lua 5.2

Tested with lua 5.1: all good

Signed-off-by: Arvydas Sidorenko <asido4@gmail.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Arvydas Sidorenko 2012-06-14 02:45:17 +02:00 committed by Uli Schlachter
parent 4ca0298564
commit b18b504fdf
8 changed files with 82 additions and 62 deletions

View File

@ -52,7 +52,7 @@ editor_cmd = terminal .. " -e " .. editor
modkey = "Mod4" modkey = "Mod4"
-- Table of layouts to cover with awful.layout.inc, order matters. -- Table of layouts to cover with awful.layout.inc, order matters.
layouts = local layouts =
{ {
awful.layout.suit.floating, awful.layout.suit.floating,
awful.layout.suit.tile, awful.layout.suit.tile,

View File

@ -9,9 +9,10 @@ local ipairs = ipairs
local math = math local math = math
--- Fair layouts module for awful --- Fair layouts module for awful
module("awful.layout.suit.fair") -- awful.layout.suit.fair
local fair = {}
local function fair(p, orientation) local function do_fair(p, orientation)
local wa = p.workarea local wa = p.workarea
local cls = p.clients local cls = p.clients
@ -61,15 +62,17 @@ end
--- Horizontal fair layout. --- Horizontal fair layout.
-- @param screen The screen to arrange. -- @param screen The screen to arrange.
horizontal = {} fair.horizontal = {}
horizontal.name = "fairh" fair.horizontal.name = "fairh"
function horizontal.arrange(p) function fair.horizontal.arrange(p)
return fair(p, "east") return do_fair(p, "east")
end end
-- Vertical fair layout. -- Vertical fair layout.
-- @param screen The screen to arrange. -- @param screen The screen to arrange.
name = "fairv" fair.name = "fairv"
function arrange(p) function fair.arrange(p)
return fair(p, "south") return do_fair(p, "south")
end end
return fair

View File

@ -5,9 +5,12 @@
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
--- Dummy function for floating layout --- Dummy function for floating layout
module("awful.layout.suit.floating") -- awful.layout.suit.floating
local floating = {}
function arrange() function floating.arrange()
end end
name = "floating" floating.name = "floating"
return floating

View File

@ -1,9 +1,11 @@
require("awful.layout.suit.max")
require("awful.layout.suit.tile")
require("awful.layout.suit.fair")
require("awful.layout.suit.floating")
require("awful.layout.suit.magnifier")
require("awful.layout.suit.spiral")
--- Suits for awful --- Suits for awful
module("awful.layout.suit")
return
{
max = require("awful.layout.suit.max");
tile = require("awful.layout.suit.tile");
fair = require("awful.layout.suit.fair");
floating = require("awful.layout.suit.floating");
magnifier = require("awful.layout.suit.magnifier");
spiral = require("awful.layout.suit.spiral");
}

View File

@ -16,9 +16,10 @@ local capi =
local client = require("awful.client") local client = require("awful.client")
--- Magnifier layout module for awful --- Magnifier layout module for awful
module("awful.layout.suit.magnifier") -- awful.layout.suit.magnifier
local magnifier = {}
function arrange(p) function magnifier.arrange(p)
-- Fullscreen? -- Fullscreen?
local area = p.workarea local area = p.workarea
local cls = p.clients local cls = p.clients
@ -102,4 +103,6 @@ function arrange(p)
end end
end end
name = "magnifier" magnifier.name = "magnifier"
return magnifier

View File

@ -9,7 +9,8 @@ local pairs = pairs
local client = require("awful.client") local client = require("awful.client")
--- Maximized and fullscreen layouts module for awful --- Maximized and fullscreen layouts module for awful
module("awful.layout.suit.max") -- awful.layout.suit.max
local max = {}
local function fmax(p, fs) local function fmax(p, fs)
-- Fullscreen? -- Fullscreen?
@ -33,15 +34,17 @@ end
--- Maximized layout. --- Maximized layout.
-- @param screen The screen to arrange. -- @param screen The screen to arrange.
name = "max" max.name = "max"
function arrange(p) function max.arrange(p)
return fmax(p, false) return fmax(p, false)
end end
--- Fullscreen layout. --- Fullscreen layout.
-- @param screen The screen to arrange. -- @param screen The screen to arrange.
fullscreen = {} max.fullscreen = {}
fullscreen.name = "fullscreen" max.fullscreen.name = "fullscreen"
function fullscreen.arrange(p) function max.fullscreen.arrange(p)
return fmax(p, true) return fmax(p, true)
end end
return max

View File

@ -8,9 +8,10 @@
-- Grab environment we need -- Grab environment we need
local ipairs = ipairs local ipairs = ipairs
module("awful.layout.suit.spiral") -- awful.layout.suit.spiral
local spiral = {}
local function spiral(p, spiral) local function do_spiral(p, _spiral)
local wa = p.workarea local wa = p.workarea
local cls = p.clients local cls = p.clients
local n = #cls local n = #cls
@ -24,17 +25,17 @@ local function spiral(p, spiral)
end end
end end
if k % 4 == 0 and spiral then if k % 4 == 0 and _spiral then
wa.x = wa.x - wa.width wa.x = wa.x - wa.width
elseif k % 2 == 0 or elseif k % 2 == 0 or
(k % 4 == 3 and k < n and spiral) then (k % 4 == 3 and k < n and _spiral) then
wa.x = wa.x + wa.width wa.x = wa.x + wa.width
end end
if k % 4 == 1 and k ~= 1 and spiral then if k % 4 == 1 and k ~= 1 and _spiral then
wa.y = wa.y - wa.height wa.y = wa.y - wa.height
elseif k % 2 == 1 and k ~= 1 or elseif k % 2 == 1 and k ~= 1 or
(k % 4 == 0 and k < n and spiral) then (k % 4 == 0 and k < n and _spiral) then
wa.y = wa.y + wa.height wa.y = wa.y + wa.height
end end
@ -49,16 +50,18 @@ local function spiral(p, spiral)
end end
--- Dwindle layout --- Dwindle layout
dwindle = {} spiral.dwindle = {}
dwindle.name = "dwindle" spiral.dwindle.name = "dwindle"
function dwindle.arrange(p) function spiral.dwindle.arrange(p)
return spiral(p, false) return do_spiral(p, false)
end end
--- Spiral layout --- Spiral layout
name = "spiral" spiral.name = "spiral"
function arrange(p) function spiral.arrange(p)
return spiral(p, true) return do_spiral(p, true)
end end
return spiral
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -12,7 +12,8 @@ local math = math
local tag = require("awful.tag") local tag = require("awful.tag")
--- Tiled layouts module for awful --- Tiled layouts module for awful
module("awful.layout.suit.tile") -- awful.layout.suit.tile
local tile = {}
local function tile_group(cls, wa, orientation, fact, group) local function tile_group(cls, wa, orientation, fact, group)
-- get our orientation right -- get our orientation right
@ -72,7 +73,7 @@ local function tile_group(cls, wa, orientation, fact, group)
return used_size return used_size
end end
local function tile(param, orientation) local function do_tile(param, orientation)
local t = tag.selected(param.screen) local t = tag.selected(param.screen)
orientation = orientation or "right" orientation = orientation or "right"
@ -148,33 +149,35 @@ local function tile(param, orientation)
end end
right = {} tile.right = {}
right.name = "tile" tile.right.name = "tile"
right.arrange = tile tile.right.arrange = do_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.
left = {} tile.left = {}
left.name = "tileleft" tile.left.name = "tileleft"
function left.arrange(p) function tile.left.arrange(p)
return tile(p, "left") return do_tile(p, "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.
bottom = {} tile.bottom = {}
bottom.name = "tilebottom" tile.bottom.name = "tilebottom"
function bottom.arrange(p) function tile.bottom.arrange(p)
return tile(p, "bottom") return do_tile(p, "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.
top = {} tile.top = {}
top.name = "tiletop" tile.top.name = "tiletop"
function top.arrange(p) function tile.top.arrange(p)
return tile(p, "top") return do_tile(p, "top")
end end
arrange = right.arrange tile.arrange = tile.right.arrange
name = right.name tile.name = tile.right.name
return tile