File: mod_xrandr.lua

package info (click to toggle)
notion 4.0.2%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 4,676 kB
  • sloc: ansic: 47,508; sh: 2,096; makefile: 603; perl: 270
file content (49 lines) | stat: -rw-r--r-- 1,074 bytes parent folder | download | duplicates (4)
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
--

if package.loaded["mod_xrandr"] then return end

if not notioncore.load_module("mod_xrandr") then
    return
end

local mod_xrandr=_G["mod_xrandr"]

assert(mod_xrandr)

if not package.loaded["mod_xinerama"] then
    dopath("mod_xinerama")
end

function filter(t, predicate)
     local result = {}
     for k,v in pairs(t) do
         if predicate(v) then
	     result[k]=v
         end
     end
     return result
 end

function mod_xrandr.get_outputs(screen)
    -- get outputs based on geometry of this screen
    return mod_xrandr.get_outputs_for_geom(screen:geom())
end

function falls_within(geom)
    return function(output)
      local result = output.x >= geom.x and output.y <= geom.y
        and output.x + output.w <= geom.x + geom.w
        and output.y + output.h <= geom.y + geom.h
      return result;
    end
end

function mod_xrandr.get_outputs_within(all_outputs, screen)
    return filter(all_outputs, falls_within(screen:geom()))
end

-- Mark ourselves loaded.
package.loaded["mod_xrandr"]=true

-- Load configuration file
dopath("cfg_xrandr", true)