Include mod_xrandr instead of using submodules
[notion/jeffpc.git] / contrib / scripts / zoom.lua
blob6ee752173e00f263ce83373f09d49d76b789c3e9
1 -- Authors: Rene van Bevern <rvb@pro-linux.de>, Etan Reisner <deryni@gmail.com>
2 -- License: Public domain
3 -- Last Changed: Unknown
4 --
5 -- zoom.lua
6 --
7 -- exchanges current client window with the active client window of the frame
8 -- called 'zoomframe' -- resembling the behavior of larswm
9 --
10 -- +---------------------------------------------------+-----------------+
11 -- | | |
12 -- | | |
13 -- | | |
14 -- | | Client 1 |
15 -- | | |
16 -- | | |
17 -- | Z o o m f r a m e w i t h +-----------------+
18 -- | z o o m e d C l i e nt | |
19 -- | | |
20 -- | | Client 2 |
21 -- | | |
22 -- | | |
23 -- | | |
24 -- +--------------------------------+------------------+-----------------+
25 -- | | |
26 -- | | |
27 -- | Client 4 | Client 3 |
28 -- | | |
29 -- | | |
30 -- +--------------------------------+------------------------------------+
32 -- Example: zoom_client on "Client 2" will put "Client 2" into the zoom frame
33 -- and "zoomed Client" into the frame of "Client 2"
35 -- By Rene van Bevern <rvb@pro-linux.de>, 2005
36 -- Modifications by Etan Reisner <deryni in #ion>
37 -- Public Domain
39 -- Example keybindings:
41 -- defbindings("WFrame", {
42 -- kpress(META.."z", "zoom_client(_, _sub)")
43 -- kpress(META.."z", "zoom_client(_, _sub, {swap=true})")
44 -- kpress(META.."z", "zoom_client(_, _sub, {swap=false, goto=true})")
45 -- }
47 -- zoom_client accepts a table that may contain the options 'swap'
48 -- and 'goto'. Both are by default set to 'true'.
50 -- 'goto' controls whether to switch to the zoomframe
52 -- 'swap' controls whether to bring the zoomframe's active client
53 -- into the current frame
56 -- Example configuration setup:
58 -- zoom_client_set({zoomframename = 'foo'})
60 local settings = {
61 zoomframename = 'zoomframe'
64 function zoom_client_set(tab)
65 settings = table.join(tab, settings)
66 end
68 function zoom_client(curframe, curclient, options)
69 local zoomframe = ioncore.lookup_region(settings.zoomframename, 'WFrame')
70 if options == nil then
71 options = {}
72 end
73 if options.goto == nil then
74 options.goto = true
75 end
76 if options.swap == nil then
77 options.swap = true
78 end
79 if (not zoomframe) or (curframe == zoomframe) then
80 return
81 end
82 local zoomclient = zoomframe:mx_current()
83 if curclient then
84 zoomframe:attach(curclient)
85 end
86 if zoomclient and options.swap then
87 curframe:attach(zoomclient)
88 end
89 if zoomclient and options.goto then
90 zoomclient:goto() -- make it activated in the frame
91 end
92 if curclient and options.goto then
93 curclient:goto()
94 end
95 end