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:
parent
4ca0298564
commit
b18b504fdf
|
@ -52,7 +52,7 @@ editor_cmd = terminal .. " -e " .. editor
|
|||
modkey = "Mod4"
|
||||
|
||||
-- Table of layouts to cover with awful.layout.inc, order matters.
|
||||
layouts =
|
||||
local layouts =
|
||||
{
|
||||
awful.layout.suit.floating,
|
||||
awful.layout.suit.tile,
|
||||
|
|
|
@ -9,9 +9,10 @@ local ipairs = ipairs
|
|||
local math = math
|
||||
|
||||
--- 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 cls = p.clients
|
||||
|
||||
|
@ -61,15 +62,17 @@ end
|
|||
|
||||
--- Horizontal fair layout.
|
||||
-- @param screen The screen to arrange.
|
||||
horizontal = {}
|
||||
horizontal.name = "fairh"
|
||||
function horizontal.arrange(p)
|
||||
return fair(p, "east")
|
||||
fair.horizontal = {}
|
||||
fair.horizontal.name = "fairh"
|
||||
function fair.horizontal.arrange(p)
|
||||
return do_fair(p, "east")
|
||||
end
|
||||
|
||||
-- Vertical fair layout.
|
||||
-- @param screen The screen to arrange.
|
||||
name = "fairv"
|
||||
function arrange(p)
|
||||
return fair(p, "south")
|
||||
fair.name = "fairv"
|
||||
function fair.arrange(p)
|
||||
return do_fair(p, "south")
|
||||
end
|
||||
|
||||
return fair
|
||||
|
|
|
@ -5,9 +5,12 @@
|
|||
---------------------------------------------------------------------------
|
||||
|
||||
--- Dummy function for floating layout
|
||||
module("awful.layout.suit.floating")
|
||||
-- awful.layout.suit.floating
|
||||
local floating = {}
|
||||
|
||||
function arrange()
|
||||
function floating.arrange()
|
||||
end
|
||||
|
||||
name = "floating"
|
||||
floating.name = "floating"
|
||||
|
||||
return floating
|
||||
|
|
|
@ -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
|
||||
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");
|
||||
}
|
||||
|
|
|
@ -16,9 +16,10 @@ local capi =
|
|||
local client = require("awful.client")
|
||||
|
||||
--- Magnifier layout module for awful
|
||||
module("awful.layout.suit.magnifier")
|
||||
-- awful.layout.suit.magnifier
|
||||
local magnifier = {}
|
||||
|
||||
function arrange(p)
|
||||
function magnifier.arrange(p)
|
||||
-- Fullscreen?
|
||||
local area = p.workarea
|
||||
local cls = p.clients
|
||||
|
@ -102,4 +103,6 @@ function arrange(p)
|
|||
end
|
||||
end
|
||||
|
||||
name = "magnifier"
|
||||
magnifier.name = "magnifier"
|
||||
|
||||
return magnifier
|
||||
|
|
|
@ -9,7 +9,8 @@ local pairs = pairs
|
|||
local client = require("awful.client")
|
||||
|
||||
--- Maximized and fullscreen layouts module for awful
|
||||
module("awful.layout.suit.max")
|
||||
-- awful.layout.suit.max
|
||||
local max = {}
|
||||
|
||||
local function fmax(p, fs)
|
||||
-- Fullscreen?
|
||||
|
@ -33,15 +34,17 @@ end
|
|||
|
||||
--- Maximized layout.
|
||||
-- @param screen The screen to arrange.
|
||||
name = "max"
|
||||
function arrange(p)
|
||||
max.name = "max"
|
||||
function max.arrange(p)
|
||||
return fmax(p, false)
|
||||
end
|
||||
|
||||
--- Fullscreen layout.
|
||||
-- @param screen The screen to arrange.
|
||||
fullscreen = {}
|
||||
fullscreen.name = "fullscreen"
|
||||
function fullscreen.arrange(p)
|
||||
max.fullscreen = {}
|
||||
max.fullscreen.name = "fullscreen"
|
||||
function max.fullscreen.arrange(p)
|
||||
return fmax(p, true)
|
||||
end
|
||||
|
||||
return max
|
||||
|
|
|
@ -8,9 +8,10 @@
|
|||
-- Grab environment we need
|
||||
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 cls = p.clients
|
||||
local n = #cls
|
||||
|
@ -24,17 +25,17 @@ local function spiral(p, spiral)
|
|||
end
|
||||
end
|
||||
|
||||
if k % 4 == 0 and spiral then
|
||||
if k % 4 == 0 and _spiral then
|
||||
wa.x = wa.x - wa.width
|
||||
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
|
||||
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
|
||||
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
|
||||
end
|
||||
|
||||
|
@ -49,16 +50,18 @@ local function spiral(p, spiral)
|
|||
end
|
||||
|
||||
--- Dwindle layout
|
||||
dwindle = {}
|
||||
dwindle.name = "dwindle"
|
||||
function dwindle.arrange(p)
|
||||
return spiral(p, false)
|
||||
spiral.dwindle = {}
|
||||
spiral.dwindle.name = "dwindle"
|
||||
function spiral.dwindle.arrange(p)
|
||||
return do_spiral(p, false)
|
||||
end
|
||||
|
||||
--- Spiral layout
|
||||
name = "spiral"
|
||||
function arrange(p)
|
||||
return spiral(p, true)
|
||||
spiral.name = "spiral"
|
||||
function spiral.arrange(p)
|
||||
return do_spiral(p, true)
|
||||
end
|
||||
|
||||
return spiral
|
||||
|
||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||
|
|
|
@ -12,7 +12,8 @@ local math = math
|
|||
local tag = require("awful.tag")
|
||||
|
||||
--- 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)
|
||||
-- get our orientation right
|
||||
|
@ -72,7 +73,7 @@ local function tile_group(cls, wa, orientation, fact, group)
|
|||
return used_size
|
||||
end
|
||||
|
||||
local function tile(param, orientation)
|
||||
local function do_tile(param, orientation)
|
||||
local t = tag.selected(param.screen)
|
||||
orientation = orientation or "right"
|
||||
|
||||
|
@ -148,33 +149,35 @@ local function tile(param, orientation)
|
|||
|
||||
end
|
||||
|
||||
right = {}
|
||||
right.name = "tile"
|
||||
right.arrange = tile
|
||||
tile.right = {}
|
||||
tile.right.name = "tile"
|
||||
tile.right.arrange = do_tile
|
||||
|
||||
--- The main tile algo, on left.
|
||||
-- @param screen The screen number to tile.
|
||||
left = {}
|
||||
left.name = "tileleft"
|
||||
function left.arrange(p)
|
||||
return tile(p, "left")
|
||||
tile.left = {}
|
||||
tile.left.name = "tileleft"
|
||||
function tile.left.arrange(p)
|
||||
return do_tile(p, "left")
|
||||
end
|
||||
|
||||
--- The main tile algo, on bottom.
|
||||
-- @param screen The screen number to tile.
|
||||
bottom = {}
|
||||
bottom.name = "tilebottom"
|
||||
function bottom.arrange(p)
|
||||
return tile(p, "bottom")
|
||||
tile.bottom = {}
|
||||
tile.bottom.name = "tilebottom"
|
||||
function tile.bottom.arrange(p)
|
||||
return do_tile(p, "bottom")
|
||||
end
|
||||
|
||||
--- The main tile algo, on top.
|
||||
-- @param screen The screen number to tile.
|
||||
top = {}
|
||||
top.name = "tiletop"
|
||||
function top.arrange(p)
|
||||
return tile(p, "top")
|
||||
tile.top = {}
|
||||
tile.top.name = "tiletop"
|
||||
function tile.top.arrange(p)
|
||||
return do_tile(p, "top")
|
||||
end
|
||||
|
||||
arrange = right.arrange
|
||||
name = right.name
|
||||
tile.arrange = tile.right.arrange
|
||||
tile.name = tile.right.name
|
||||
|
||||
return tile
|
||||
|
|
Loading…
Reference in New Issue