File: panel.lua

package info (click to toggle)
notion 3%2B2012042300-1
  • links: PTS, VCS
  • area: non-free
  • in suites: wheezy
  • size: 4,724 kB
  • sloc: ansic: 45,614; makefile: 544; sh: 409; perl: 113
file content (61 lines) | stat: -rw-r--r-- 1,331 bytes parent folder | download
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
--
-- This script allows making panels and other windows the stdisp.
--
-- Usage:
--
-- defwinprop { 
--      class = 'SomePanel',
--      instance = 'somepanel',
--      is_panel = true,
--      -- panel_fullsize = false,
--      -- panel_pos = 'bl',
--      -- min_size = { w = something, h = sensible },
-- }
--
-- Set panel.check_exists to disable checking for existing stdisp.
--

panel={}

panel.check_exists=true

local function dflt(x, y)
    if x~=nil then return x else return y end
end

function panel.manage(cwin, tab)
    local prop=ioncore.getwinprop(cwin)
    if prop and prop.is_panel then
        local scr=cwin:screen_of()
        local exists=false
        
        if panel.check_exists then
            local current=scr:get_stdisp()
            if current and current.reg then
                exists=true
            end
        end
        
        if not exists then
            return scr:set_stdisp{
                reg = cwin,
                fullsize = dflt(prop.panel_fullsize, true),
                pos = dflt(prop.panel_pos, 'bl'),
            }
        end
    end
    return false
end


function panel.reg()
    ioncore.get_hook("clientwin_do_manage_alt"):add(panel.manage)
end

function panel.unreg()
    ioncore.get_hook("clientwin_do_manage_alt"):remove(panel.manage)
end
    
panel.reg()