summaryrefslogtreecommitdiff
path: root/desktop.lua
blob: 4b252ab6c2fc9f0c1df9be7ca0de9c3dd3aac1a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
local M = {}

local awful  = require("awful")
local object = require("gears.object")

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

local function desktop_new(idx, name, nb_pages, layout)
    local ret = object()

    ret.show = desktop_show

    ret.name = name

    ret.pages = {}
    for i = 1, nb_pages do
        ret.pages[i] = awful.tag.add(name .. i, { layout = layout })
    end

    -- page_history[i] is the last page viewed on screen i
    ret.page_history = {}

    return ret
end

M.new = desktop_new

return M