Add a travis build definition for building without XFT
[notion.git] / mod_xrandr / mod_xrandr.lua
blobe394b57c59a6dbb85c20dd2ecb8d4afb10354134
1 --
3 if package.loaded["mod_xrandr"] then return end
5 if not notioncore.load_module("mod_xrandr") then
6 return
7 end
9 local mod_xrandr=_G["mod_xrandr"]
11 assert(mod_xrandr)
13 if not package.loaded["mod_xinerama"] then
14 dopath("mod_xinerama")
15 end
17 function filter(t, predicate)
18 local result = {}
19 for k,v in pairs(t) do
20 if predicate(v) then
21 result[k]=v
22 end
23 end
24 return result
25 end
27 function mod_xrandr.get_outputs(screen)
28 -- get outputs based on geometry of this screen
29 return mod_xrandr.get_outputs_for_geom(screen:geom())
30 end
32 function falls_within(geom)
33 return function(output)
34 local result = output.x >= geom.x and output.y <= geom.y
35 and output.x + output.w <= geom.x + geom.w
36 and output.y + output.h <= geom.y + geom.h
37 return result;
38 end
39 end
41 function mod_xrandr.get_outputs_within(all_outputs, screen)
42 return filter(all_outputs, falls_within(screen:geom()))
43 end
45 -- Mark ourselves loaded.
46 package.loaded["mod_xrandr"]=true
48 -- Load configuration file
49 dopath("cfg_xrandr", true)