Skip to content

Commit

Permalink
fixed get client geometry
Browse files Browse the repository at this point in the history
  • Loading branch information
wxg4dev committed Apr 29, 2015
1 parent cf5f4ee commit 02deef5
Showing 1 changed file with 55 additions and 12 deletions.
67 changes: 55 additions & 12 deletions init.lua
Expand Up @@ -130,7 +130,6 @@ function revelation.expose(args)
local t={}
local zt={}


for scr=1,capi.screen.count() do

all_tags = awful.tag.gettags(scr)
Expand All @@ -155,19 +154,63 @@ function revelation.expose(args)

local hintindex = {} -- Table of visible clients with the hint letter as the keys
local clientlist = awful.client.visible()
for i,thisclient in pairs(clientlist) do
-- Move wiboxes to center of visible windows and populate hintindex
local char = charorder:sub(i,i)
if char and char ~= '' then
hintindex[char] = thisclient
local geom = thisclient.geometry(thisclient)
hintbox[char].visible = true
hintbox[char].x = geom.x + geom.width/2 - hintsize/2
hintbox[char].y = geom.y + geom.height/2 - hintsize/2
hintbox[char].screen = thisclient.screen

if #clientlist > 0 then
local rows, cols = 0, 0
if #clientlist == 2 then
rows, cols = 1, 2
else
rows = math.ceil(math.sqrt(#clientlist))
cols = math.ceil(#clientlist / rows)
end
end

for k, c in ipairs(clientlist) do
local char = charorder:sub(k,k)
k = k - 1
local g = {}
local wa = capi.screen[c.screen].workarea
local row, col = 0, 0
row = k % rows
col = math.floor(k / rows)

local lrows, lcols = 0, 0
if k >= rows * cols - rows then
lrows = #clientlist - (rows * cols - rows)
lcols = cols
else
lrows = rows
lcols = cols
end

if row == lrows - 1 then
g.height = wa.height - math.ceil(wa.height / lrows) * row
g.y = wa.height - g.height
else
g.height = math.ceil(wa.height / lrows)
g.y = g.height * row
end

if col == lcols - 1 then
g.width = wa.width - math.ceil(wa.width / lcols) * col
g.x = wa.width - g.width
else
g.width = math.ceil(wa.width / lcols)
g.x = g.width * col
end

g.y = g.y + wa.y
g.x = g.x + wa.x

if char and char ~= '' then
hintindex[char] = c
hintbox[char].visible = true
hintbox[char].x = g.x + g.width/2 - hintsize/2
hintbox[char].y = g.y + g.height/2 - hintsize/2
hintbox[char].screen = c.screen
end
end
end

local function restore()
local k,v
for scr=1, capi.screen.count() do
Expand Down

0 comments on commit 02deef5

Please sign in to comment.