From c2842fe8f3513a0243c920db1f0d9f2f54727872 Mon Sep 17 00:00:00 2001 From: Alexis BRENON Date: Mon, 25 May 2015 17:09:43 +0200 Subject: [PATCH] Add a new tag layout: corner Closes https://github.com/awesomeWM/awesome/pull/251 --- awesomerc.lua.in | 6 +- lib/awful/layout/init.lua.in | 6 +- lib/awful/layout/suit/corner.lua.in | 159 +++++++++++++++++++++++++++ lib/awful/layout/suit/init.lua.in | 1 + themes/default/layouts/cornerne.png | Bin 0 -> 451 bytes themes/default/layouts/cornernew.png | Bin 0 -> 409 bytes themes/default/layouts/cornernw.png | Bin 0 -> 439 bytes themes/default/layouts/cornernww.png | Bin 0 -> 381 bytes themes/default/layouts/cornerse.png | Bin 0 -> 424 bytes themes/default/layouts/cornersew.png | Bin 0 -> 411 bytes themes/default/layouts/cornersw.png | Bin 0 -> 424 bytes themes/default/layouts/cornersww.png | Bin 0 -> 423 bytes themes/default/theme.lua.in | 4 + themes/sky/layouts/cornerne.png | Bin 0 -> 238 bytes themes/sky/layouts/cornernw.png | Bin 0 -> 236 bytes themes/sky/layouts/cornerse.png | Bin 0 -> 228 bytes themes/sky/layouts/cornersw.png | Bin 0 -> 235 bytes themes/sky/theme.lua.in | 4 + themes/zenburn/layouts/cornerne.png | Bin 0 -> 273 bytes themes/zenburn/layouts/cornernw.png | Bin 0 -> 272 bytes themes/zenburn/layouts/cornerse.png | Bin 0 -> 271 bytes themes/zenburn/layouts/cornersw.png | Bin 0 -> 267 bytes themes/zenburn/theme.lua.in | 4 + 23 files changed, 182 insertions(+), 2 deletions(-) create mode 100644 lib/awful/layout/suit/corner.lua.in create mode 100644 themes/default/layouts/cornerne.png create mode 100644 themes/default/layouts/cornernew.png create mode 100644 themes/default/layouts/cornernw.png create mode 100644 themes/default/layouts/cornernww.png create mode 100644 themes/default/layouts/cornerse.png create mode 100644 themes/default/layouts/cornersew.png create mode 100644 themes/default/layouts/cornersw.png create mode 100644 themes/default/layouts/cornersww.png create mode 100644 themes/sky/layouts/cornerne.png create mode 100644 themes/sky/layouts/cornernw.png create mode 100644 themes/sky/layouts/cornerse.png create mode 100644 themes/sky/layouts/cornersw.png create mode 100644 themes/zenburn/layouts/cornerne.png create mode 100644 themes/zenburn/layouts/cornernw.png create mode 100644 themes/zenburn/layouts/cornerse.png create mode 100644 themes/zenburn/layouts/cornersw.png 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 0000000000000000000000000000000000000000..e7fb61bb6250e5ca65494dfad9979a8957aabe3e GIT binary patch literal 451 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=Y)RhkE)35=aM#78c%TSpfk$L9 zP{(x;W^~e+T>%tiFY)wsWxvlV%g-Cb)ck=doD5#NZ(MEs2NEK_?dUYj_7bChDsv^5KU zDtJyRo|f94-|Ez{d&;Lt%U*t*UUmJ|?DD&X-&Sqq+i!X$s=YM!{i;<~e}mpf)qdW_ z7V4GTX7<*~dfC0LyVAI)zheYC4*?F`UYmJ__w{=Q4^92#b<^vov(M1#T6BDleL>_j zMmeCmJy*Oue2g96?`N!>_r6_3YpI#@`6|`}Cc;OU5vG7x_KXuaCvnc|^eK3$W|1EM zV%Ax!hMm8h=BG#A7yfdO<@l_K%OMqlObzjy=DnKrj>~^*^PTJ0cd;KStTFCA-74^X zk;XQ?Us3-#Z~R!Fuu3+itkuvFV!?rQhGjDs^x7Oqjek9JL8jb;UHVQLH>;Rjl6HK^ S*?UwFq{`FP&t;ucLK6UD-mh!` literal 0 HcmV?d00001 diff --git a/themes/default/layouts/cornernew.png b/themes/default/layouts/cornernew.png new file mode 100644 index 0000000000000000000000000000000000000000..aeaf3311ad8f87080e8ae5a2474356be9094dd06 GIT binary patch literal 409 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=Y)RhkE(}T_xaPG;Ay9;~z$3C4 zsN*^aGdgL^t^f+Mmw5WRvfpQw<>y!V`eL^?0|TR)r;B4q#jUrq4)Qh|2(a{bi2b<0 z=<9H5fy*h5&>hV68cIK11v@#P^&G7D)@gCN=Lna+c9X!V$fJJ_8SwOP%iUeyeA%Sa zFzwCnfBRDHw#EF`eQs{%yE*G~XlQ3gN%ZsN(_8P)e(W~i)%?6XOQNJh9uv?V2w>;u zYp1^EG^4?>9=qeGPd{ahip-v$UiV-Gl>=U#E^o#(nI>~oK$);A|ltA>M7L3ipx@hfGm-(M-L zf5(-*^exx>tB!GZMXzZc+26F+>O@Jap(DiL14azFY7$EP9Xs XrzPv}#V=@I3{vFj>gTe~DWM4fkFb*Q literal 0 HcmV?d00001 diff --git a/themes/default/layouts/cornernw.png b/themes/default/layouts/cornernw.png new file mode 100644 index 0000000000000000000000000000000000000000..bac56728fe5ece81d7a57f0e971ee89ae63ccdc7 GIT binary patch literal 439 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=Y)RhkE)35=aM#78c%TSpfk$L9 zP{(x;W^~e+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w&sE`lM-zpd4n5=7xmpv$pGDU|`hnba4!+xb=3{LBVDP5!U^FQ6G}n z%@%4N7SdI|#Ufj=u;Yne5>wrYhBww$A12+D3zopr0ACoI#{d8T literal 0 HcmV?d00001 diff --git a/themes/default/layouts/cornersw.png b/themes/default/layouts/cornersw.png new file mode 100644 index 0000000000000000000000000000000000000000..0d519b5c6ce9a4b1c8c1ffea2358b6762ece30e8 GIT binary patch literal 424 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=Y)RhkE)35=aM#78c%TSpfk$L9 zP{(x;W^~e+T>%tiFY)wsWxvlV%P+vem37mMfq~J~)5S5Q;?~<)2YFi*1Y9rXaE3iN znVZlxBTDD^s%4E|Q&_(}xHr)^g;Dv}zl#qz^nWSOFXU7Fl4AO=wNS=B&1}ubrc^Kf~#`BmC|?kmgoz283L>^Irn$516=_I5B}&J zITfxPe)kDOk74zj<{rb}!KIVmvt~`+`i)1@-Z!|No#BBigUgd`+dEGD^N^cRyzyO~ z-A>MBH?}{Yly5)(kFZAR$DPlv?cuD;ig(CSi}))okaQ#J^~cir3^NtfIAHbw=>{{# z7MHjCHeO}su+0B3S3Bm>(hGC`X71c+CkK>u>Gau9#*osK(lkQ>NfW~)h7%Y2XM1h5 sJ+a;Bpos0>og%lJ=PbT1p%}7#-`CW&j}zxU5C*CDboFyt=akR{0DS|Yd;kCd literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..5da314f514d4b874ed28a5bd2f1068b28ffbf21c GIT binary patch literal 238 zcmeAS@N?(olHy`uVBq!ia0vp^#z3sV!3HGvKX#A@Qfx`y?k)`fL2$v|<&%LToCO|{ z#Xvd-gc)O`|LOr5>?NMQuI%?&WrfT{PI{Zw0fnkPT^vIq4!@mY$aO%0$94bG>jG9^ z|2=;h^1`u1ThB}5WkOB8@Fts2lh=E3{9SiNZryXe&5Uz?R!DC1n9Iq!Ir`T1;B0U2 zz0<26H=J!?JeJ9LW`^YrotkqOBoo5sORoPdWZ8UHCf6+L>9ysDrdt)Y&17Vg@cc77 d(Rj-itq?bTaa%5ilR#%Mc)I$ztaD0e0sxNnROSEx literal 0 HcmV?d00001 diff --git a/themes/sky/layouts/cornernw.png b/themes/sky/layouts/cornernw.png new file mode 100644 index 0000000000000000000000000000000000000000..9eb4c79ec3389e608ee40f79b58d5a0ff5c8cdd5 GIT binary patch literal 236 zcmeAS@N?(olHy`uVBq!ia0vp^#z3sV!3HGvKX#A@Qfx`y?k)`fL2$v|<&%LToCO|{ z#Xvd-gc)O`|LOr5>?NMQuI%?&WrfUmZmF-+018!lx;TbJ98OM5qxx#_@*9XB(Kq*;|E Z7#RM&(HFNd(gyj0!PC{xWt~$(69BpxP_+O6 literal 0 HcmV?d00001 diff --git a/themes/sky/layouts/cornerse.png b/themes/sky/layouts/cornerse.png new file mode 100644 index 0000000000000000000000000000000000000000..9b59c0ed698c6883f8d7a38da9d295b6b29f7893 GIT binary patch literal 228 zcmeAS@N?(olHy`uVBq!ia0vp^#z3sV!3HGvKX#A@Qfx`y?k)`fL2$v|<&%LToCO|{ z#Xvd-gc)O`|LOr5>?NMQuI%?&Wra-59T-K<1BD7bT^vIq4ksr_ur>=DC>7_~)_tg7 zQR(0t#`unX*+UWI!>5dOj=0F{HO$fZxN`Z@U5V1hi|0vxJ>ww8;Jopi?NMQuI%?&Wra*--t2wb4-~5Kba4!cIGmgy!P+crpj4b^Tlb-U zMWusp7~?zkWe-J+51%sDIpQL3<>1%%CB$9Bx<_qu;Q5}aHZRr#4vb!}c3t!;Hkmn5 z@X``BS1~UhS)QLMTQcOnp2@IvuKOqHo3{954nZwigdT#42w_Zi1ai~M%hm?5iX=6Oy-Zb`lT0gEwjMap6Ekhz&X(NBC~hPT b3PLvK70i;~#quw00||S&`njxgN@xNAjAK%! literal 0 HcmV?d00001 diff --git a/themes/zenburn/layouts/cornernw.png b/themes/zenburn/layouts/cornernw.png new file mode 100644 index 0000000000000000000000000000000000000000..cafd5ef77bc2a33b250c8d6392ca85b8dd0fab58 GIT binary patch literal 272 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=Y)RhkE)4%caKYZ?lYt_f1s;*b zKpodXn9)gNb_Gz7y~NYkmHj@etbj5Xd#PnQP-w2Fi(^Q|t+%%h@-`^&um%|P9pZRr z->AHyJ8tK!M+;y6Hs@3MaVhE2g;^dizmyt2|C?g*MIyX^PUYSDko7?QC}2Utxi|6~ z_{>8X8k%$y)K;*f$TBcAtTzH0)^&yx;TbZ+L4{Lxy-yx27 z_KnILy5&sOAz4Pzd8|-)HHr&%UDQ9R%;I3fLV1%iJ(g`g$II|da3y$~&aHB~v bD1G|<=Gt%B@>(zLW{{kxtDnm{r-UW|73fq( literal 0 HcmV?d00001 diff --git a/themes/zenburn/layouts/cornersw.png b/themes/zenburn/layouts/cornersw.png new file mode 100644 index 0000000000000000000000000000000000000000..292b23fec4b3c0bb46db454b49414072996cf95d GIT binary patch literal 267 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=Y)RhkE)4%caKYZ?lYt_f1s;*b zKpodXn9)gNb_Gz7y~NYkmHj@etbnqZa7n5LP-upyi(^Q|t+zKe@-`?4um%|P9pZRr z->AHSd)xI{%}pQb(iM-Mu2l~2I&pF3$A#a^&)DqQx_q65b#-3Nf2&$1pb0QgAbHDJ z&sl52>Agkr8?*{rd=H%AykU4V^Mhar<9|jim@*hGBWCR=8ql~mS$zevDIn>Fjz6c^ XudR_S*H|{Y2_)d@>gTe~DWM4f`1?;x literal 0 HcmV?d00001 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