1 -- Authors: Canaan Hadley-Voth <ugggg@hotmail.com>
3 -- Last Changed: Unknown
7 -- written by Canaan Hadley-Voth, ugggg at hotmail
9 -- Sends a clientwin to another workspace.
11 -- On a tiled workspace, the frame sent to will be the most recently active.
12 -- Maximized windows are skipped over in search of an actual workspace.
13 -- Focus follows if jumpto is set.
15 -- send_to_ws(cwin, action, jumpto)
16 -- send_to_new_ws(cwin, wstype, jumpto)
18 -- The action argument can be a specific workspace number OR it can be
19 -- 'left', 'right', or 'any'.
21 -- Workspace numbers start at 0 because WScreen.switch_nth starts at 0.
22 -- (In both cases the bindings make it look like they start at 1.)
26 -- These are the bindings I use, as an example.
27 defbindings("WMPlex", {
29 submap("bracketleft", {
30 kpress("H", "send_to_ws(_sub, 'left', true)"),
31 kpress("L", "send_to_ws(_sub, 'right', true)"),
32 kpress("1", "send_to_ws(_sub, 0, true)"),
33 kpress("2", "send_to_ws(_sub, 1, true)"),
34 kpress("3", "send_to_ws(_sub, 2, true)"),
35 kpress("4", "send_to_ws(_sub, 3, true)"),
36 kpress("5", "send_to_ws(_sub, 4, true)"),
37 kpress("6", "send_to_ws(_sub, 5, true)"),
38 kpress("7", "send_to_ws(_sub, 6, true)"),
39 kpress("8", "send_to_ws(_sub, 7, true)"),
40 kpress("9", "send_to_ws(_sub, 8, true)"),
41 kpress("F", "send_to_new_ws(_sub, 'WGroupWS')"),
47 function send_to_ws(cwin
, action
, jumpto
)
48 local destws
, destwsindex
, destwstype
50 local scr
=cwin
:screen_of()
51 local curws
=cwin
:manager()
52 while curws
:manager()~=scr
do
55 local curwsindex
=scr
:get_index(curws
)
57 if type(action
)=="string" then
58 if action
=="left" then
60 elseif action
=="right" then
62 elseif action
=="any" then
63 -- send to the right if a workspace exists there, otherwise left
64 if not(WMPlex
.mx_nth(scr
, curwsindex
+1)) then
65 send_to_ws(cwin
, 'left', jumpto
)
68 send_to_ws(cwin
, 'right', jumpto
)
73 -- Skip over fullscreen client windows or frames or whatever else,
74 -- until an actual workspace is found.
75 destwsindex
=curwsindex
76 destws
=scr
:mx_nth(destwsindex
+offset
)
77 destwstype
=obj_typename(destws
)
78 while destwstype
~="WGroupWS" and destwstype
~="WTiling" do
79 destwsindex
=destwsindex
+offset
80 destws
=scr
:mx_nth(destwsindex
)
81 destwstype
=obj_typename(destws
)
82 -- If there are no workspaces to the right, make one.
83 -- (workspace type created can be set to "WGroupWS" instead.
84 -- If there are no workspaces to the left, give up.
85 if destwsindex
>scr
:mx_count() then
86 send_to_new_ws(cwin
, "WTiling")
88 elseif destwsindex
<0 then
92 elseif type(action
)=="number" then
94 destws
=scr
:mx_nth(destwsindex
)
95 destwstype
=obj_typename(destws
)
96 if destwsindex
==curwsindex
then return end
99 if destwstype
=="WTiling" then
100 destws
:current():attach(cwin
, {switchto
=true})
101 elseif destwstype
=="WGroupWS" and obj_typename(destws
:current())=="WTiling" then
102 destws
:current():current():attach(cwin
, {switchto
=true})
103 elseif destwstype
=="WGroupWS" then
104 destws
:attach_framed(cwin
)
113 function send_to_new_ws(cwin
, wstype
, jumpto
)
114 local scr
=cwin
:screen_of()
115 local n
=scr
:mx_count()
118 if wstype
=="WGroupWS" then
119 newws
=scr
:attach_new
{type="WGroupWS"}
120 newws
:attach_framed(cwin
)
122 newws
=scr
:attach_new
{type="WTiling"}
123 newws
:current():attach(cwin
)
125 if jumpto
then cwin
:goto() end