Let default name function depend on the icon name.
This commit is contained in:
parent
9f9a558b2f
commit
946494ecf0
|
@ -71,7 +71,7 @@ Use `local layout = machi.layout.create(args)` to instantiate the layout with an
|
||||||
- `new_placement_cb`: a callback `function(c, instance, areas, geometry)` that fits new client `c` into the areas.
|
- `new_placement_cb`: a callback `function(c, instance, areas, geometry)` that fits new client `c` into the areas.
|
||||||
This is a new and experimental feature. The interface is subject to changes.
|
This is a new and experimental feature. The interface is subject to changes.
|
||||||
|
|
||||||
If `name` and `name_func` are both nil a default name function will be used, which splits the state based on the tag names.
|
If `name` and `name_func` are both nil, a default name function will be used, which depends on the tag names, screen geometries, and `icon_name`.
|
||||||
|
|
||||||
The function is compatible with the previous `machi.layout.create(name, editor, default_cmd)` calls.
|
The function is compatible with the previous `machi.layout.create(name, editor, default_cmd)` calls.
|
||||||
|
|
||||||
|
|
15
layout.lua
15
layout.lua
|
@ -121,16 +121,16 @@ function module.set_geometry(c, area_lu, area_rd, useless_gap, border_width)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function module.default_name_func(tag)
|
-- TODO: the string need to be updated when its screen geometry changed.
|
||||||
if tag.machi_name_cache == nil then
|
local function get_machi_tag_string(tag)
|
||||||
tag.machi_name_cache =
|
if tag.machi_tag_string == nil then
|
||||||
|
tag.machi_tag_string =
|
||||||
tostring(tag.screen.geometry.width) .. "x" .. tostring(tag.screen.geometry.height) .. "+" ..
|
tostring(tag.screen.geometry.width) .. "x" .. tostring(tag.screen.geometry.height) .. "+" ..
|
||||||
tostring(tag.screen.geometry.x) .. "+" .. tostring(tag.screen.geometry.y) .. '+' .. tag.name
|
tostring(tag.screen.geometry.x) .. "+" .. tostring(tag.screen.geometry.y) .. '+' .. tag.name
|
||||||
end
|
end
|
||||||
return tag.machi_name_cache
|
return tag.machi_tag_string
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function module.create(args_or_name, editor, default_cmd)
|
function module.create(args_or_name, editor, default_cmd)
|
||||||
local args
|
local args
|
||||||
if type(args_or_name) == "string" then
|
if type(args_or_name) == "string" then
|
||||||
|
@ -147,7 +147,10 @@ function module.create(args_or_name, editor, default_cmd)
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
if args.name == nil and args.name_func == nil then
|
if args.name == nil and args.name_func == nil then
|
||||||
args.name_func = module.default_name_func
|
local prefix = args.icon_name and (args.icon_name.."-") or ""
|
||||||
|
args.name_func = function (tag)
|
||||||
|
return prefix..get_machi_tag_string(tag)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
args.editor = args.editor or editor or machi_editor.default_editor
|
args.editor = args.editor or editor or machi_editor.default_editor
|
||||||
args.default_cmd = args.default_cmd or default_cmd or global_default_cmd
|
args.default_cmd = args.default_cmd or default_cmd or global_default_cmd
|
||||||
|
|
Loading…
Reference in New Issue