diff options
author | Anton Khirnov <anton@khirnov.net> | 2020-12-02 17:51:10 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2020-12-02 17:51:10 +0100 |
commit | 5a1465b5c97d457591e154cd3de04113b6166ccc (patch) | |
tree | c2833b3f6ff12c4aca3d51b1c82da7b0e18d918c /workspace.lua | |
parent | ce845ee2aa0efbfc0b8706e7933b1dff5749f24f (diff) |
workspace: add a function to find an empty page on desk
Diffstat (limited to 'workspace.lua')
-rw-r--r-- | workspace.lua | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/workspace.lua b/workspace.lua index cb0eff1..bfdc02e 100644 --- a/workspace.lua +++ b/workspace.lua @@ -7,6 +7,16 @@ local timer = require("gears.timer") local Workspace = {} +local function desk_find_empty_page(desk) + for i, page in ipairs(desk.pages) do + if #page:clients() == 0 then + return i + end + end + + return nil +end + function Workspace:add_desktop(idx, name, nb_pages) local desk = object() @@ -22,6 +32,8 @@ function Workspace:add_desktop(idx, name, nb_pages) desk.screen_map = {} + desk.find_empty_page = desk_find_empty_page + self.desktops[idx] = desk return idx end |