Include mod_xrandr instead of using submodules
[notion/jeffpc.git] / ioncore / ioncore_quasiact.lua
blob68f004d908bb9bed2001aff90759b7d87e157689
1 --
2 -- ion/share/ioncore_quasiact.lua -- Frame quasiactivation support
3 --
4 -- Copyright (c) Tuomo Valkonen 2007-2009.
5 --
6 -- See the included file LICENSE for details.
7 --
9 local qa_source={}
10 local qa_target={}
12 local function quasi_activated(frame, src)
13 local old=qa_source[frame]
14 if old then
15 qa_target[old]=nil
16 end
17 qa_source[frame]=src
18 qa_target[src]=frame
19 ioncore.defer(function() frame:set_grattr("quasiactive", "set") end)
20 end
22 local function quasi_inactivated(frame, src)
23 qa_source[frame]=nil
24 qa_target[src]=nil
25 ioncore.defer(function() frame:set_grattr("quasiactive", "unset") end)
26 end
28 local function activated(src)
29 local tgt=src:__return_target()
30 if obj_is(tgt, "WFrame") then
31 quasi_activated(tgt, src)
32 elseif obj_is(tgt, "WGroup") then
33 local mgr=tgt:manager()
34 if obj_is(mgr, "WFrame") then
35 quasi_activated(mgr, src)
36 end
37 end
38 end
40 local function inactivated(src)
41 local tgt=qa_target[src]
42 if tgt then
43 quasi_inactivated(tgt, src)
44 return true
45 end
46 end
48 local function deinit(tgt)
49 local src=qa_source[tgt]
50 if src then
51 qa_target[src]=nil
52 qa_source[tgt]=nil
53 end
54 end
56 local function quasiact_notify(reg, how)
57 if how=="activated" or how=="pseudoactivated" then
58 activated(reg)
59 elseif how=="inactivated" or how=="pseudoinactivated" then
60 inactivated(reg)
61 elseif how=="set_return" then
62 if reg:is_active(true--[[pseudoact--]]) then
63 activated(reg)
64 end
65 elseif how=="unset_return" then
66 inactivated(reg)
67 elseif how=="deinit" then
68 inactivated(reg)
69 deinit(reg)
70 end
71 end
74 ioncore.get_hook("region_notify_hook"):add(quasiact_notify)