1--
2-- Advanced float handler
3--
4-- Kept here as a means to start removing policy from tiler.lua
5-- and letting more parts of the codebase be "opt out"
6--
7-- Since it is rather big, it have been split out into multiple subscripts,
8-- while this one is kept as an entry point for consolidating menu
9-- mapping and configuration keys.
10--
11-- cactions : cursor regions - path activation on mouse behavior
12-- gridfit  : split the screen into a 9-cell region for pseudo-tiler
13-- autolay  : automatic reposition/relayouting heuristics
14-- spawnctl : intercept and regulate initial window position and size
15-- minimize : minimize- target controls
16-- bginput  : input handlers for the wallpaper image (if one is set)
17--
18
19local floatmenu = {
20{
21	kind = "value",
22	name = "spawn_action",
23	initial = gconfig_get("advfloat_spawn"),
24	label = "Spawn Method",
25	description = "Change how new windows are being sized and positioned",
26-- missing (split/share selected) or join selected
27	set = {"click", "cursor", "draw", "auto"},
28	handler = function(ctx, val)
29		mode = val;
30		gconfig_set("advfloat_spawn", val);
31	end
32},
33};
34
35menus_register("global", "settings/wspaces",
36{
37	kind = "action",
38	name = "float",
39	submenu = true,
40	label = "Float",
41	description = "Advanced float workspace layout",
42	handler = floatmenu
43});
44system_load("tools/advfloat/cactions.lua")();
45system_load("tools/advfloat/minimize.lua")();
46system_load("tools/advfloat/spawnctl.lua")();
47system_load("tools/advfloat/bginput.lua")();
48
49local workspace_menu = {
50{
51	kind = "action",
52	submenu = true,
53	name = "autolayout",
54	label = "Layouter",
55	description = "Apply an automatic layouting technique",
56	handler = system_load("tools/advfloat/autolay.lua")()
57}
58};
59
60menus_register("target", "window",
61{
62	kind = "action",
63	submenu = true,
64	name = "gridalign",
65	label = "Grid-Fit",
66	eval = function()
67		local wnd = active_display().selected;
68		return (wnd and wnd.space.mode == "float");
69	end,
70	description = "Size and fit the current window to a virtual grid cell",
71	handler = system_load("tools/advfloat/gridfit.lua")()
72});
73
74menus_register("target", "window/move_resize",
75{
76	kind = "action",
77	submenu = false,
78	name = "drawrz",
79	eval = function()
80		return active_display().selected.space.mode == "float";
81	end,
82	label = "Draw-Resize",
83	handler = system_load("tools/advfloat/rzctl.lua")()
84});
85
86menus_register("global", "workspace",
87{
88	kind = "action",
89	name = "float",
90	label = "Float",
91	submenu = true,
92	description = "(advfloat-tool) active workspace specific actions",
93	eval = function()
94		return active_display().spaces[active_display().space_ind].mode == "float";
95	end,
96	handler = workspace_menu
97});
98