summaryrefslogtreecommitdiff
path: root/desktop.lua
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2017-01-26 12:25:52 +0100
committerAnton Khirnov <anton@khirnov.net>2017-01-26 12:25:52 +0100
commit9b322660ee6b7640af24def50a7fb8615a8ab126 (patch)
treea3064adc789a0ed91149432a15b86c66d7967c35 /desktop.lua
parente8bb1f4a1844f07fc2f6973f2e7b400f2ddf2f3d (diff)
Basic support for desktops/pages.
Diffstat (limited to 'desktop.lua')
-rw-r--r--desktop.lua42
1 files changed, 33 insertions, 9 deletions
diff --git a/desktop.lua b/desktop.lua
index 376410b..d714dc9 100644
--- a/desktop.lua
+++ b/desktop.lua
@@ -1,22 +1,46 @@
local M = {}
-local awful = require("awful")
+local awful = require("awful")
+local object = require("gears.object")
+
+local function desktop_show(self, screen, page_idx)
+ if page_idx == nil then
+ page_hist = self.page_history[screen]
+ if page_hist ~= nil then
+ page_idx = page_hist
+ else
+ page_idx = 1
+ end
+ end
+
+ page = self.pages[page_idx]
-local Desktop = {}
+ if page then
+ self.page_history[screen] = page_idx
+ end
+ return page_idx
+end
-function Desktop:new(name, nb_pages)
- o = setmetatable({}, self)
+local function desktop_new(idx, name, nb_pages, layout)
+ local ret = object()
- o.name = name
+ ret:add_signal("page:view")
- o.pages = {}
+ ret.show = desktop_show
+
+ ret.name = name
+
+ ret.pages = {}
for i = 1, nb_pages do
- o.pages[i] = awful.tag.add(name .. i)
+ ret.pages[i] = awful.tag.add(name .. i, { layout = layout })
end
- return o
+ -- page_history[i] is the last page viewed on screen i
+ ret.page_history = {}
+
+ return ret
end
-M.Desktop = Desktop
+M.new = desktop_new
return M