Pass in rows and columns
This commit is contained in:
parent
2dbb212f75
commit
ed065bf9db
|
@ -7,21 +7,16 @@ function workspace_grid:new(args)
|
||||||
end
|
end
|
||||||
|
|
||||||
function workspace_grid:init(args)
|
function workspace_grid:init(args)
|
||||||
self.test = 0
|
self.rows = args.rows
|
||||||
|
self.columns = args.columns
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
local rows = 2
|
|
||||||
local columns = 3
|
|
||||||
|
|
||||||
function workspace_grid:navigate(direction)
|
function workspace_grid:navigate(direction)
|
||||||
log(tostring(direction))
|
|
||||||
local t = awful.screen.focused().selected_tag
|
local t = awful.screen.focused().selected_tag
|
||||||
local i = t.index - 1
|
local i = t.index - 1
|
||||||
local c = columns
|
local c = self.columns
|
||||||
local r = rows
|
local r = self.rows
|
||||||
log("Rows " .. tostring(rows))
|
|
||||||
log("Cols" .. tostring(columns))
|
|
||||||
|
|
||||||
-- Don't cycle.
|
-- Don't cycle.
|
||||||
-- Top row
|
-- Top row
|
||||||
|
@ -34,17 +29,15 @@ function workspace_grid:navigate(direction)
|
||||||
if (i >= (r - 1) * c) and (direction == "down") then return true end
|
if (i >= (r - 1) * c) and (direction == "down") then return true end
|
||||||
|
|
||||||
action = {
|
action = {
|
||||||
["down"] = (i + columns) % (rows * columns) + 1,
|
["down"] = (i + c) % (r * c) + 1,
|
||||||
["up"] = (i - columns) % (rows * columns) + 1,
|
["up"] = (i - c) % (r * c) + 1,
|
||||||
["left"] = (math.ceil((i + 1) / columns) - 1) * columns + ((i - 1) % columns) + 1,
|
["left"] = (math.ceil((i + 1) / c) - 1) * c + ((i - 1) % c) + 1,
|
||||||
["right"] = (math.ceil((i + 1) / columns) - 1) * columns + ((i + 1) % columns) + 1,
|
["right"] = (math.ceil((i + 1) / c) - 1) * c + ((i + 1) % c) + 1,
|
||||||
}
|
}
|
||||||
local j = action[direction]
|
local j = action[direction]
|
||||||
log(tostring(j))
|
|
||||||
|
|
||||||
-- Switch tags on all screens at the same time.
|
-- Switch tags on all screens at the same time.
|
||||||
for s in screen do
|
for s in screen do
|
||||||
log(tostring(s))
|
|
||||||
t = s.tags[j]
|
t = s.tags[j]
|
||||||
if t then t:view_only() end
|
if t then t:view_only() end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue