File: test_xrandr_remove_screen.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 (110 lines) | stat: -rw-r--r-- 2,879 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
-- {{{ mock notion context
function iter(t, cb)
  for i,o in pairs(t) do
    cb(o);
  end
end

function move(ws, from, to)
  if from[1] == ws then
    table.remove(from, 1)
    table.insert(to, ws)
  else
    assert(false);
  end
end

local workspaces1 = {}
local workspaces2 = {}
local firstscreen = {
    geom = function() return { x=0, y=0, w=1920, h=1080 } end,
    name = function() return "WScreen<1>" end,
    managed_i = function(screen, callback) iter(workspaces1, callback) end,
    attach = function(s, ws) move(ws, workspaces2, workspaces1); ws.screen = firstscreen end,
    rqclose = function() end,
    mx_count = function() return #workspaces1 end,
    id = function() return 0 end
}
local secondscreen = {
    geom = function() return { x=0, y=0, w=1920, h=1080 } end,
    name = function() return "WScreen" end,
    managed_i = function(screen, callback) iter(workspaces2, callback) end,
    attach = function(ws) move(ws, workspaces1, workspaces2); ws.screen = secondscreen end,
    rqclose = function() end,
    mx_count = function() return #workspaces2 end,
    id = function() return 1 end
}
local firstws = {
    screen_of = function() return firstscreen end,
    name = function() return "firstws" end
}
table.insert(workspaces1, firstws)

local secondws = {
    screen_of = function() return secondscreen end,
    name = function() return "secondws" end
}
table.insert(workspaces2, secondws)

function obj_is(o, t)
  if (o == firstws or o == secondws) and t == 'WGroupWS' then return true end
  return false
end

WGroupWS = {
  get_initial_outputs = function(ws)
    if ws == firstws then return { 'VGA1' } end
    if ws == secondws then return { 'VGA1' } end
    return nil
  end
}

notioncore = {
  rootwin = function() end,
  screens_updated = function(rootwin) end,
  load_module = function() return 1 end,
  get_hook = function() return { add = function() end; } end,
  region_i = function(callback, type)
      local next = callback(firstscreen)
      if next then callback(secondscreen) end
  end,
  find_screen_id = function(screen_id)
    if screen_id == 0 then return firstscreen
    else
      if screen_id == 1 then return secondscreen
      else return nil
        end
    end
  end
}

function dopath()
end

-- all outputs reported by xrander. Notably, the second screen is (now) missing.
local all_outputs = { VGA1 = { x=0, y=0, w=1680, h=1050, name='VGA1' } }

_G["mod_xinerama"] = {
  update_screen = function() end,
  query_screens = function() return { { x=0, y=0, w=1680, h=1050 } } end
}

_G["mod_xrandr"] = {
    get_all_outputs = function()
            return all_outputs;
        end
}

-- }}}

-- initial
assert(workspaces2[1] ~= nil);


-- load xrandr module lua code
dofile('../mod_xinerama/mod_xinerama.lua')
dofile('mod_xrandr.lua')
dofile('cfg_xrandr.lua')

mod_xrandr.rearrangeworkspaces(0)
assert(nilOrEmpty(workspaces2));