summaryrefslogtreecommitdiff
path: root/workspace.lua
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2020-04-10 16:14:11 +0200
committerAnton Khirnov <anton@khirnov.net>2020-04-10 16:14:11 +0200
commit044a445cdc2f25f9f069eb95113812cd19f1c0fe (patch)
tree324364ee33cb6cb5216221f492f0e4352a949580 /workspace.lua
parent2f496835549fb3bfe457a22722fe476de93b0bfb (diff)
workspace: merge with desktop
The desktop API is not really standalone anyway.
Diffstat (limited to 'workspace.lua')
-rw-r--r--workspace.lua37
1 files changed, 33 insertions, 4 deletions
diff --git a/workspace.lua b/workspace.lua
index ad985df..768293f 100644
--- a/workspace.lua
+++ b/workspace.lua
@@ -1,13 +1,42 @@
local M = {}
local awful = require("awful")
-local desktop = require("desktop")
local object = require("gears.object")
local Workspace = {}
+local function desktop_show(self, screen, page_idx)
+ if page_idx == nil then
+ local page_hist = self.page_history[screen]
+ if page_hist ~= nil then
+ page_idx = page_hist
+ else
+ page_idx = 1
+ end
+ end
+
+ local page = self.pages[page_idx]
+
+ if page then
+ self.page_history[screen] = page_idx
+ end
+ return page_idx
+end
+
function Workspace:add_desktop(idx, name, nb_pages)
- self.desktops[idx] = desktop.new(idx, name, nb_pages, self.layouts[1])
+ local desk = object()
+
+ desk.name = name
+
+ desk.pages = {}
+ for i = 1, nb_pages do
+ desk.pages[i] = awful.tag.add(name .. i, { layout = self.layouts[1] })
+ end
+
+ -- page_history[i] is the last page viewed on screen i
+ desk.page_history = {}
+
+ self.desktops[idx] = desk
return idx
end
@@ -63,7 +92,7 @@ function Workspace:view(screen, desktop, page_idx)
end
-- the page to display on the target screen
- page_idx = self.desktops[desktop]:show(screen, page_idx)
+ page_idx = desktop_show(self.desktops[desktop], screen, page_idx)
local page_new = nil
if page_idx then
page_new = self.desktops[desktop].pages[page_idx]
@@ -84,7 +113,7 @@ function Workspace:view(screen, desktop, page_idx)
if screen_cur then
local desk_prev = self.screen_state[screen_cur].desktop
- old.page_idx = self.desktops[old.desk]:show(screen_cur, old.page_idx)
+ old.page_idx = desktop_show(self.desktops[old.desk], screen_cur, old.page_idx)
self.screen_state[screen_cur] = { page = old.page_idx, desktop = old.desk }
if desk_prev ~= old.desk then