use 'git archive' to produce cleaner tarballs
[notion.git] / mod_xrandr / test_xrandr_remove_screen.lua
blobf3d0a1a8ece3062609eb44473ad0a5981edc39eb
1 -- {{{ mock notion context
2 function iter(t, cb)
3 for i,o in pairs(t) do
4 cb(o);
5 end
6 end
8 function move(ws, from, to)
9 if from[1] == ws then
10 table.remove(from, 1)
11 table.insert(to, ws)
12 else
13 assert(false);
14 end
15 end
17 local workspaces1 = {}
18 local workspaces2 = {}
19 local firstscreen = {
20 geom = function() return { x=0, y=0, w=1920, h=1080 } end,
21 name = function() return "WScreen<1>" end,
22 managed_i = function(screen, callback) iter(workspaces1, callback) end,
23 attach = function(s, ws) move(ws, workspaces2, workspaces1); ws.screen = firstscreen end,
24 rqclose = function() end,
25 mx_count = function() return #workspaces1 end,
26 id = function() return 0 end
28 local secondscreen = {
29 geom = function() return { x=0, y=0, w=1920, h=1080 } end,
30 name = function() return "WScreen" end,
31 managed_i = function(screen, callback) iter(workspaces2, callback) end,
32 attach = function(ws) move(ws, workspaces1, workspaces2); ws.screen = secondscreen end,
33 rqclose = function() end,
34 mx_count = function() return #workspaces2 end,
35 id = function() return 1 end
37 local firstws = {
38 screen_of = function() return firstscreen end,
39 name = function() return "firstws" end
41 table.insert(workspaces1, firstws)
43 local secondws = {
44 screen_of = function() return secondscreen end,
45 name = function() return "secondws" end
47 table.insert(workspaces2, secondws)
49 function obj_is(o, t)
50 if (o == firstws or o == secondws) and t == 'WGroupWS' then return true end
51 return false
52 end
54 WGroupWS = {
55 get_initial_outputs = function(ws)
56 if ws == firstws then return { 'VGA1' } end
57 if ws == secondws then return { 'VGA1' } end
58 return nil
59 end
62 notioncore = {
63 rootwin = function() end,
64 screens_updated = function(rootwin) end,
65 load_module = function() return 1 end,
66 get_hook = function() return { add = function() end; } end,
67 region_i = function(callback, type)
68 local next = callback(firstscreen)
69 if next then callback(secondscreen) end
70 end,
71 find_screen_id = function(screen_id)
72 if screen_id == 0 then return firstscreen
73 else
74 if screen_id == 1 then return secondscreen
75 else return nil
76 end
77 end
78 end
81 function dopath()
82 end
84 -- all outputs reported by xrander. Notably, the second screen is (now) missing.
85 local all_outputs = { VGA1 = { x=0, y=0, w=1680, h=1050, name='VGA1' } }
87 _G["mod_xinerama"] = {
88 update_screen = function() end,
89 query_screens = function() return { { x=0, y=0, w=1680, h=1050 } } end
92 _G["mod_xrandr"] = {
93 get_all_outputs = function()
94 return all_outputs;
95 end
98 -- }}}
100 -- initial
101 assert(workspaces2[1] ~= nil);
104 -- load xrandr module lua code
105 dofile('../mod_xinerama/mod_xinerama.lua')
106 dofile('mod_xrandr.lua')
107 dofile('cfg_xrandr.lua')
109 mod_xrandr.rearrangeworkspaces(0)
110 assert(nilOrEmpty(workspaces2));