summaryrefslogtreecommitdiff
path: root/utils.lua
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2020-04-08 17:44:01 +0200
committerAnton Khirnov <anton@khirnov.net>2020-04-08 17:44:57 +0200
commit15372f7dcfc027cd5bf767584de0e826cc876612 (patch)
treeea13500381c47e3ce770a1785af032504baaf541 /utils.lua
parent97d9056f352865dcd04ffae09b62ec4e36ed4959 (diff)
utils: work with screen objects rather than indices
Diffstat (limited to 'utils.lua')
-rw-r--r--utils.lua12
1 files changed, 6 insertions, 6 deletions
diff --git a/utils.lua b/utils.lua
index 51d159a..ebb1995 100644
--- a/utils.lua
+++ b/utils.lua
@@ -4,26 +4,26 @@ local awful = require("awful")
-- mapping from logical screen indices to indices corresponding to their
-- physical layout
-local function map_screen_physical(n)
+local function screen_physical(n)
local function screen_cmp(s1, s2)
- return s1[2].geometry.x < s2[2].geometry.x
+ return s1.geometry.x < s2.geometry.x
end
local screens = {}
- for s = 1, screen.count() do
- screens[s] = {s, screen[s]}
+ for s in screen do
+ screens[s.index] = s
end
table.sort(screens, screen_cmp)
if screens[n] ~= nil then
- return screens[n][2]
+ return screens[n]
end
return nil
end
function M.screen_focus_physical(n)
- local s = map_screen_physical(n)
+ local s = screen_physical(n)
if s then
awful.screen.focus(s)
end