Merge pull request #279 from actionless/useless_gapv3

Useless gap v3
This commit is contained in:
Emmanuel Lepage Vallée 2015-07-03 15:51:15 -04:00
commit d51a647003
6 changed files with 57 additions and 30 deletions

View File

@ -10,14 +10,15 @@
-- Grab environment we need
local ipairs = ipairs
local type = type
local tag = require("awful.tag")
local util = require("awful.util")
local ascreen = require("awful.screen")
local capi = {
screen = screen,
awesome = awesome,
client = client
client = client,
tag = tag
}
local tag = require("awful.tag")
local client = require("awful.client")
local timer = require("gears.timer")
@ -120,22 +121,26 @@ function layout.arrange(screen)
local p = {}
p.workarea = capi.screen[screen].workarea
local useless_gap = tag.getgap(tag.selected(screen))
-- Handle padding
local padding = ascreen.padding(capi.screen[screen])
if padding then
p.workarea.x = p.workarea.x + (padding.left or 0)
p.workarea.y = p.workarea.y + (padding.top or 0)
p.workarea.width = p.workarea.width - ((padding.left or 0 ) + (padding.right or 0))
p.workarea.height = p.workarea.height - ((padding.top or 0) + (padding.bottom or 0))
end
local padding = ascreen.padding(capi.screen[screen]) or {}
p.workarea.x = p.workarea.x + (padding.left or 0) + useless_gap
p.workarea.y = p.workarea.y + (padding.top or 0) + useless_gap
p.workarea.width = p.workarea.width - ((padding.left or 0 ) +
(padding.right or 0) + useless_gap * 2)
p.workarea.height = p.workarea.height - ((padding.top or 0) +
(padding.bottom or 0) + useless_gap * 2)
p.geometry = capi.screen[screen].geometry
p.clients = client.tiled(screen)
p.screen = screen
p.geometries = setmetatable({}, {__mode = "k"})
layout.get(screen).arrange(p)
for c, g in pairs(p.geometries) do
g.width = g.width - c.border_width * 2
g.height = g.height - c.border_width * 2
g.width = g.width - c.border_width * 2 - useless_gap * 2
g.height = g.height - c.border_width * 2 - useless_gap * 2
g.x = g.x + useless_gap
g.y = g.y + useless_gap
c:geometry(g)
end
capi.screen[screen]:emit_signal("arrange")
@ -173,31 +178,23 @@ capi.client.connect_signal("property::screen", function(c, old_screen)
layout.arrange(c.screen)
end)
local function arrange_on_tagged(c, tag)
if not tag.screen then return end
layout.arrange(tag.screen)
if not capi.client.focus or not capi.client.focus:isvisible() then
local c = client.focus.history.get(tag.screen, 0)
if c then
c:emit_signal("request::activate", "layout.arrange_on_tagged",
{raise=false})
end
end
end
local function arrange_tag(t)
layout.arrange(tag.getscreen(t))
end
capi.screen.add_signal("arrange")
capi.tag.connect_signal("property::mwfact", arrange_tag)
capi.tag.connect_signal("property::nmaster", arrange_tag)
capi.tag.connect_signal("property::ncol", arrange_tag)
capi.tag.connect_signal("property::layout", arrange_tag)
capi.tag.connect_signal("property::windowfact", arrange_tag)
capi.tag.connect_signal("property::selected", arrange_tag)
capi.tag.connect_signal("property::activated", arrange_tag)
capi.tag.connect_signal("property::useless_gap", arrange_tag)
capi.tag.connect_signal("tagged", arrange_tag)
for s = 1, capi.screen.count() do
tag.attached_connect_signal(s, "property::mwfact", arrange_tag)
tag.attached_connect_signal(s, "property::nmaster", arrange_tag)
tag.attached_connect_signal(s, "property::ncol", arrange_tag)
tag.attached_connect_signal(s, "property::layout", arrange_tag)
tag.attached_connect_signal(s, "property::windowfact", arrange_tag)
tag.attached_connect_signal(s, "property::selected", arrange_tag)
tag.attached_connect_signal(s, "property::activated", arrange_tag)
tag.attached_connect_signal(s, "tagged", arrange_tag)
capi.screen[s]:connect_signal("property::workarea", function(screen)
layout.arrange(screen.index)
end)

View File

@ -10,6 +10,7 @@
-- Grab environment we need
local util = require("awful.util")
local timer = require("gears.timer")
local beautiful = require("beautiful")
local tostring = tostring
local pairs = pairs
local ipairs = ipairs
@ -383,6 +384,30 @@ function tag.getmwfact(t)
return tag.getproperty(t, "mwfact") or 0.5
end
--- Set the spacing between clients
-- @param useless_gap The spacing between clients
-- @param t The tag to modify, if null tag.selected() is used.
function tag.setgap(useless_gap, t)
local t = t or tag.selected()
if useless_gap >= 0 then
tag.setproperty(t, "useless_gap", useless_gap)
end
end
--- Increase the spacing between clients
-- @param add Value to add to the spacing between clients
-- @param t The tag to modify, if null tag.selected() is used.
function tag.incgap(add, t)
tag.setgap(tag.getgap(t) + add, t)
end
--- Get the spacing between clients
-- @param t Optional tag.
function tag.getgap(t)
local t = t or tag.selected()
return tag.getproperty(t, "useless_gap") or beautiful.useless_gap or 0
end
--- Set the number of master windows.
-- @param nmaster The number of master windows.
-- @param[opt] t The tag.
@ -673,6 +698,7 @@ capi.tag.add_signal("property::icon")
capi.tag.add_signal("property::icon_only")
capi.tag.add_signal("property::layout")
capi.tag.add_signal("property::mwfact")
capi.tag.add_signal("property::useless_gap")
capi.tag.add_signal("property::ncol")
capi.tag.add_signal("property::nmaster")
capi.tag.add_signal("property::windowfact")

View File

@ -17,6 +17,7 @@ theme.fg_focus = "#ffffff"
theme.fg_urgent = "#ffffff"
theme.fg_minimize = "#ffffff"
theme.useless_gap = 0
theme.border_width = 1
theme.border_normal = "#000000"
theme.border_focus = "#535d6c"

View File

@ -19,6 +19,7 @@ theme.fg_focus = "#2e3436"
theme.fg_urgent = "#2e3436"
theme.fg_minimize = "#2e3436"
theme.useless_gap = 0
theme.border_width = 2
theme.border_normal = "#dae3e0"
theme.border_focus = "#729fcf"

View File

@ -22,6 +22,7 @@ theme.fg_focus = theme.bg_normal
theme.fg_urgent = theme.bg_normal
theme.fg_minimize = theme.bg_normal
theme.useless_gap = dpi(5)
theme.border_width = dpi(1)
theme.border_normal = xrdb.color0
theme.border_focus = theme.bg_focus

View File

@ -25,6 +25,7 @@ theme.bg_systray = theme.bg_normal
-- }}}
-- {{{ Borders
theme.useless_gap = 0
theme.border_width = 2
theme.border_normal = "#3F3F3F"
theme.border_focus = "#6F6F6F"