1 -- Authors: David Tweed, Cas Cremers, David Roundy, John Schreiner
3 -- Last Changed: 2007-02-22
8 lua code to auto show/hide tabs as the number of windows in an ion frame
10 this affects windows on WIonWS and WPaneWS workspaces but leave
11 windows on WFloatWS's alone
13 Originally created by David Tweed
15 22 Feb 2007 John Schreiner: ignore transients to prevent empty frames
16 14 Dec 2006 David Roundy: modified to work with latest ion3
17 11 Feb 2005 David Tweed: modified to work with ion3 svn versions
18 15 Feb 2005 Cas Cremers: only frames with one window hide the tabbar
20 01 Sep 2005 Cas Cremers: single client windows that are tagged still
23 - Easier to work with using a style with slightly wider frame
24 borders and more vivid "active frame" colours.
25 - The keybinding META..T is defined at the end of the file: this
26 should override the normal binging, thus min_tabs should be
27 loaded *after* the normal definition of META..T. It is not
28 appropriate to have key bindings hard-coded in extensions, but I
29 don't currently know of a better way.
30 - Currently supports ion3 with old toggling as well as new
31 toggling function conventions; this can be removed later on.
33 one way to enable this is by adding
39 function show_only_necessary_tabs_in_frame(fp
)
40 if WFrame
.mode(fp
) == 'floating' then
41 -- Escape: floatws thing should not be handled
46 -- First the logic, then the propagation back to ion
48 -- It should *not* be shown if there is only one app
49 -- However, this (single) app should not be tagged,
50 -- because then we would want to show it.
52 -- Assume the tabbar should be shown.
54 if WMPlex
.mx_count(fp
) == 1 then
55 local rg
= fp
:mx_nth(0)
56 if not rg
:is_tagged() then
62 ioncore
.defer(function()
63 -- don't touch transient frames
64 if fp
:mode() ~= "transient" then
68 fp
:set_mode("tiled-alt")
76 function show_only_necessary_tabs_in_frame_wrapper(ftable
)
77 show_only_necessary_tabs_in_frame(ftable
.reg
)
82 function min_tabs_setup_hook()
83 local hk
=ioncore
.get_hook("frame_managed_changed_hook")
84 hk
:add(show_only_necessary_tabs_in_frame_wrapper
)
89 function min_tabs_tag_wrapper(fr
,reg
)
91 -- Note the ugly code: this actually caters for two versions of ion3
92 -- I am only including this because I like Ubuntu [CC]
94 local oldversion
= (reg
["toggle_tag"] ~= nil)
97 -- old version (for Ubuntu, can be removed later on)
103 reg
:set_tagged("toggle")
107 -- recompute tabbar state
108 show_only_necessary_tabs_in_frame(fr
)
113 Special keybinding override for this extension
116 defbindings("WMPlex.toplevel", {
117 bdoc("Tag current object within the frame."),
118 kpress(META
.."T", "min_tabs_tag_wrapper(_,_sub)", "_sub:non-nil"),
123 min_tabs_setup_hook()