diff --git a/awesomerc.lua.in b/awesomerc.lua.in index cbe2ba562..58df8fd5f 100755 --- a/awesomerc.lua.in +++ b/awesomerc.lua.in @@ -65,7 +65,11 @@ awful.layout.layouts = { awful.layout.suit.spiral.dwindle, awful.layout.suit.max, awful.layout.suit.max.fullscreen, - awful.layout.suit.magnifier + awful.layout.suit.magnifier, + awful.layout.suit.corner.nw, + -- awful.layout.suit.corner.ne, + -- awful.layout.suit.corner.sw, + -- awful.layout.suit.corner.se, } -- }}} diff --git a/lib/awful/layout/init.lua.in b/lib/awful/layout/init.lua.in index 875e851b0..89ed3b1c3 100755 --- a/lib/awful/layout/init.lua.in +++ b/lib/awful/layout/init.lua.in @@ -41,7 +41,11 @@ layout.layouts = { layout.suit.spiral.dwindle, layout.suit.max, layout.suit.max.fullscreen, - layout.suit.magnifier + layout.suit.magnifier, + layout.suit.corner.nw, + layout.suit.corner.ne, + layout.suit.corner.sw, + layout.suit.corner.se, } -- This is a special lock used by the arrange function. diff --git a/lib/awful/layout/suit/corner.lua.in b/lib/awful/layout/suit/corner.lua.in new file mode 100644 index 000000000..4b31c3fa1 --- /dev/null +++ b/lib/awful/layout/suit/corner.lua.in @@ -0,0 +1,159 @@ +--------------------------------------------------------------------------- +-- Corner layout. +-- Display master client in a corner of the screen, and slaves in one +-- column and one row around the master. +-- See Pull Request for example : https://github.com/awesomeWM/awesome/pull/251 +-- @module awful.layout.suit.corner +-- @author Alexis Brenon <brenon.alexis+awesomewm@gmail.com> +-- @copyright 2015 Alexis Brenon +-- @release @AWESOME_VERSION@ + +-- Grab environment we need +local ipairs = ipairs +local math = math +local tag = require("awful.tag") + +--- Actually arrange clients of p.clients for corner layout +-- @param p Mandatory table containing required informations for layouts +-- (clients to arrange, workarea geometry, etc.) +-- @param orientation String indicating in which corner is the master window. +-- Available values are : NE, NW, SW, SE +local function do_corner(p, orientation) + local wa = p.workarea + local cls = p.clients + + if #cls == 0 then return end + + local master = {} + local column = {} + local row = {} + -- Use the nmaster field of the tag in a cheaty way + local row_privileged = ((tag.getnmaster(tag.selected(cls[1].screen)) % 2) == 0) + + local master_factor = tag.getmwfact(tag.selected(cls[1].screen)) + master.width = master_factor * wa.width + master.height = master_factor * wa.height + + number_privileged_win = math.ceil((#cls - 1)/2) + number_unprivileged_win = (#cls - 1) - number_privileged_win + + -- Define some obvious parameters + column.width = wa.width - master.width + column.x_increment = 0 + row.height = wa.height - master.height + row.y_increment = 0 + + -- Place master at the right place and move row and column accordingly + column.y = wa.y + row.x = wa.x + if orientation:match('N.') then + master.y = wa.y + row.y = master.y + master.height + elseif orientation:match('S.') then + master.y = wa.y + wa.height - master.height + row.y = wa.y + end + if orientation:match('.W') then + master.x = wa.x + column.x = master.x + master.width + elseif orientation:match('.E') then + master.x = wa.x + wa.width - master.width + column.x = wa.x + end + -- At this point, master is in a corner + -- but row and column are overlayed in the opposite corner... + + -- Reduce the unprivileged slaves to remove overlay + -- and define actual width and height + if row_privileged then + row.width = wa.width + row.number_win = number_privileged_win + column.y = master.y + column.height = master.height + column.number_win = number_unprivileged_win + else + column.height = wa.height + column.number_win = number_privileged_win + row.x = master.x + row.width = master.width + row.number_win = number_unprivileged_win + end + + column.win_height = column.height/column.number_win + column.win_width = column.width + column.y_increment = column.win_height + column.win_idx = 0 + + row.win_width = row.width/row.number_win + row.win_height = row.height + row.x_increment = row.win_width + row.win_idx = 0 + + -- Extend master if there is only a few windows + if #cls < 3 then + if row_privileged then + master.x = wa.x + master.width = wa.width + else + master.y = wa.y + master.height = wa.height + end + if #cls < 2 then + master = wa + end + end + + for i, c in ipairs(cls) do + local g = nil + -- Handle master window + if i == 1 then + g = { + x = master.x, + y = master.y, + width = master.width - (2 * c.border_width), + height = master.height - (2 * c.border_width) + } + -- handle column windows + elseif i % 2 == 0 then + g = { + x = column.x + column.win_idx * column.x_increment, + y = column.y + column.win_idx * column.y_increment, + width = column.win_width - (2 * c.border_width), + height = column.win_height - (2 * c.border_width) + } + column.win_idx = column.win_idx + 1 + else + g = { + x = row.x + row.win_idx * row.x_increment, + y = row.y + row.win_idx * row.y_increment, + width = row.win_width - (2 * c.border_width), + height = row.win_height - (2 * c.border_width) + } + row.win_idx = row.win_idx + 1 + end + c:geometry(g) + end +end + +local corner = {} +corner.row_privileged = false +corner.nw = { + name = "cornernw", + arrange = function (p) return do_corner(p, "NW") end + } +corner.ne = { + name = "cornerne", + arrange = function (p) return do_corner(p, "NE") end + } +corner.sw = { + name = "cornersw", + arrange = function (p) return do_corner(p, "SW") end + } +corner.se = { + name = "cornerse", + arrange = function (p) return do_corner(p, "SE") end + } + +return corner + +-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/lib/awful/layout/suit/init.lua.in b/lib/awful/layout/suit/init.lua.in index 3c3540806..a29b2c01f 100644 --- a/lib/awful/layout/suit/init.lua.in +++ b/lib/awful/layout/suit/init.lua.in @@ -8,6 +8,7 @@ return { + corner = require("awful.layout.suit.corner"); max = require("awful.layout.suit.max"); tile = require("awful.layout.suit.tile"); fair = require("awful.layout.suit.fair"); diff --git a/themes/default/layouts/cornerne.png b/themes/default/layouts/cornerne.png new file mode 100644 index 000000000..e7fb61bb6 Binary files /dev/null and b/themes/default/layouts/cornerne.png differ diff --git a/themes/default/layouts/cornernew.png b/themes/default/layouts/cornernew.png new file mode 100644 index 000000000..aeaf3311a Binary files /dev/null and b/themes/default/layouts/cornernew.png differ diff --git a/themes/default/layouts/cornernw.png b/themes/default/layouts/cornernw.png new file mode 100644 index 000000000..bac56728f Binary files /dev/null and b/themes/default/layouts/cornernw.png differ diff --git a/themes/default/layouts/cornernww.png b/themes/default/layouts/cornernww.png new file mode 100644 index 000000000..93b670675 Binary files /dev/null and b/themes/default/layouts/cornernww.png differ diff --git a/themes/default/layouts/cornerse.png b/themes/default/layouts/cornerse.png new file mode 100644 index 000000000..092a9057a Binary files /dev/null and b/themes/default/layouts/cornerse.png differ diff --git a/themes/default/layouts/cornersew.png b/themes/default/layouts/cornersew.png new file mode 100644 index 000000000..35e900b8d Binary files /dev/null and b/themes/default/layouts/cornersew.png differ diff --git a/themes/default/layouts/cornersw.png b/themes/default/layouts/cornersw.png new file mode 100644 index 000000000..0d519b5c6 Binary files /dev/null and b/themes/default/layouts/cornersw.png differ diff --git a/themes/default/layouts/cornersww.png b/themes/default/layouts/cornersww.png new file mode 100644 index 000000000..2d744fd5f Binary files /dev/null and b/themes/default/layouts/cornersww.png differ diff --git a/themes/default/theme.lua.in b/themes/default/theme.lua.in index 0fc683c6c..a707d1e21 100644 --- a/themes/default/theme.lua.in +++ b/themes/default/theme.lua.in @@ -88,6 +88,10 @@ theme.layout_tile = "@AWESOME_THEMES_PATH@/default/layouts/tilew.png" theme.layout_tiletop = "@AWESOME_THEMES_PATH@/default/layouts/tiletopw.png" theme.layout_spiral = "@AWESOME_THEMES_PATH@/default/layouts/spiralw.png" theme.layout_dwindle = "@AWESOME_THEMES_PATH@/default/layouts/dwindlew.png" +theme.layout_cornernw = "@AWESOME_THEMES_PATH@/default/layouts/cornernww.png" +theme.layout_cornerne = "@AWESOME_THEMES_PATH@/default/layouts/cornernew.png" +theme.layout_cornersw = "@AWESOME_THEMES_PATH@/default/layouts/cornersww.png" +theme.layout_cornerse = "@AWESOME_THEMES_PATH@/default/layouts/cornersew.png" theme.awesome_icon = "@AWESOME_ICON_PATH@/awesome16.png" diff --git a/themes/sky/layouts/cornerne.png b/themes/sky/layouts/cornerne.png new file mode 100644 index 000000000..5da314f51 Binary files /dev/null and b/themes/sky/layouts/cornerne.png differ diff --git a/themes/sky/layouts/cornernw.png b/themes/sky/layouts/cornernw.png new file mode 100644 index 000000000..9eb4c79ec Binary files /dev/null and b/themes/sky/layouts/cornernw.png differ diff --git a/themes/sky/layouts/cornerse.png b/themes/sky/layouts/cornerse.png new file mode 100644 index 000000000..9b59c0ed6 Binary files /dev/null and b/themes/sky/layouts/cornerse.png differ diff --git a/themes/sky/layouts/cornersw.png b/themes/sky/layouts/cornersw.png new file mode 100644 index 000000000..bccd01e76 Binary files /dev/null and b/themes/sky/layouts/cornersw.png differ diff --git a/themes/sky/theme.lua.in b/themes/sky/theme.lua.in index 4fd2cb455..b5252bcb5 100644 --- a/themes/sky/theme.lua.in +++ b/themes/sky/theme.lua.in @@ -37,6 +37,10 @@ theme.layout_tile = "@AWESOME_THEMES_PATH@/sky/layouts/tile.png" theme.layout_tiletop = "@AWESOME_THEMES_PATH@/sky/layouts/tiletop.png" theme.layout_spiral = "@AWESOME_THEMES_PATH@/sky/layouts/spiral.png" theme.layout_dwindle = "@AWESOME_THEMES_PATH@/sky/layouts/dwindle.png" +theme.layout_cornernw = "@AWESOME_THEMES_PATH@/sky/layouts/cornernw.png" +theme.layout_cornerne = "@AWESOME_THEMES_PATH@/sky/layouts/cornerne.png" +theme.layout_cornersw = "@AWESOME_THEMES_PATH@/sky/layouts/cornersw.png" +theme.layout_cornerse = "@AWESOME_THEMES_PATH@/sky/layouts/cornerse.png" theme.awesome_icon = "@AWESOME_THEMES_PATH@/sky/awesome-icon.png" diff --git a/themes/zenburn/layouts/cornerne.png b/themes/zenburn/layouts/cornerne.png new file mode 100644 index 000000000..63960bcb8 Binary files /dev/null and b/themes/zenburn/layouts/cornerne.png differ diff --git a/themes/zenburn/layouts/cornernw.png b/themes/zenburn/layouts/cornernw.png new file mode 100644 index 000000000..cafd5ef77 Binary files /dev/null and b/themes/zenburn/layouts/cornernw.png differ diff --git a/themes/zenburn/layouts/cornerse.png b/themes/zenburn/layouts/cornerse.png new file mode 100644 index 000000000..67b143b36 Binary files /dev/null and b/themes/zenburn/layouts/cornerse.png differ diff --git a/themes/zenburn/layouts/cornersw.png b/themes/zenburn/layouts/cornersw.png new file mode 100644 index 000000000..292b23fec Binary files /dev/null and b/themes/zenburn/layouts/cornersw.png differ diff --git a/themes/zenburn/theme.lua.in b/themes/zenburn/theme.lua.in index 51bd14a4a..5e626e9ef 100644 --- a/themes/zenburn/theme.lua.in +++ b/themes/zenburn/theme.lua.in @@ -95,6 +95,10 @@ theme.layout_max = "@AWESOME_THEMES_PATH@/zenburn/layouts/max.png" theme.layout_fullscreen = "@AWESOME_THEMES_PATH@/zenburn/layouts/fullscreen.png" theme.layout_magnifier = "@AWESOME_THEMES_PATH@/zenburn/layouts/magnifier.png" theme.layout_floating = "@AWESOME_THEMES_PATH@/zenburn/layouts/floating.png" +theme.layout_cornernw = "@AWESOME_THEMES_PATH@/zenburn/layouts/cornernw.png" +theme.layout_cornerne = "@AWESOME_THEMES_PATH@/zenburn/layouts/cornerne.png" +theme.layout_cornersw = "@AWESOME_THEMES_PATH@/zenburn/layouts/cornersw.png" +theme.layout_cornerse = "@AWESOME_THEMES_PATH@/zenburn/layouts/cornerse.png" -- }}} -- {{{ Titlebar