From 5a1465b5c97d457591e154cd3de04113b6166ccc Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 2 Dec 2020 17:51:10 +0100 Subject: workspace: add a function to find an empty page on desk --- workspace.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 -- cgit v1.2.3