mirror of
https://github.com/pinnacle-comp/pinnacle.git
synced 2024-12-26 21:58:10 +01:00
Recurse through lua window rule cond to extract id
This commit is contained in:
parent
eea10c60a3
commit
4b509b5bc1
1 changed files with 45 additions and 23 deletions
|
@ -199,6 +199,49 @@ local _fullscreen_or_maximized_keys = {
|
||||||
[3] = "maximized",
|
[3] = "maximized",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
---@param rule WindowRule
|
||||||
|
local function process_window_rule(rule)
|
||||||
|
if rule.output then
|
||||||
|
---@diagnostic disable-next-line: assign-type-mismatch
|
||||||
|
rule.output = rule.output.name
|
||||||
|
end
|
||||||
|
|
||||||
|
if rule.tags then
|
||||||
|
local ids = {}
|
||||||
|
for _, tg in ipairs(rule.tags) do
|
||||||
|
table.insert(ids, tg.id)
|
||||||
|
end
|
||||||
|
rule.tags = ids
|
||||||
|
end
|
||||||
|
|
||||||
|
if rule.fullscreen_or_maximized then
|
||||||
|
rule.fullscreen_or_maximized = _fullscreen_or_maximized[rule.fullscreen_or_maximized]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param cond WindowRuleCondition
|
||||||
|
local function process_window_rule_cond(cond)
|
||||||
|
if cond.tags then
|
||||||
|
local ids = {}
|
||||||
|
for _, tg in ipairs(cond.tags) do
|
||||||
|
table.insert(ids, tg.id)
|
||||||
|
end
|
||||||
|
cond.tags = ids
|
||||||
|
end
|
||||||
|
|
||||||
|
if cond.all then
|
||||||
|
for _, con in ipairs(cond.all) do
|
||||||
|
process_window_rule_cond(con)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if cond.any then
|
||||||
|
for _, con in ipairs(cond.any) do
|
||||||
|
process_window_rule_cond(con)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
---Add a window rule.
|
---Add a window rule.
|
||||||
---
|
---
|
||||||
---A window rule defines what properties a window will spawn with given certain conditions.
|
---A window rule defines what properties a window will spawn with given certain conditions.
|
||||||
|
@ -289,30 +332,9 @@ local _fullscreen_or_maximized_keys = {
|
||||||
---
|
---
|
||||||
---@param rule { cond: WindowRuleCondition, rule: WindowRule } The condition and rule
|
---@param rule { cond: WindowRuleCondition, rule: WindowRule } The condition and rule
|
||||||
function window.add_window_rule(rule)
|
function window.add_window_rule(rule)
|
||||||
if rule.cond.tags then
|
process_window_rule(rule.rule)
|
||||||
local ids = {}
|
|
||||||
for _, tg in ipairs(rule.cond.tags) do
|
|
||||||
table.insert(ids, tg.id)
|
|
||||||
end
|
|
||||||
rule.cond.tags = ids
|
|
||||||
end
|
|
||||||
|
|
||||||
if rule.rule.output then
|
process_window_rule_cond(rule.cond)
|
||||||
---@diagnostic disable-next-line: assign-type-mismatch
|
|
||||||
rule.rule.output = rule.rule.output.name
|
|
||||||
end
|
|
||||||
|
|
||||||
if rule.rule.tags then
|
|
||||||
local ids = {}
|
|
||||||
for _, tg in ipairs(rule.rule.tags) do
|
|
||||||
table.insert(ids, tg.id)
|
|
||||||
end
|
|
||||||
rule.rule.tags = ids
|
|
||||||
end
|
|
||||||
|
|
||||||
if rule.rule.fullscreen_or_maximized then
|
|
||||||
rule.rule.fullscreen_or_maximized = _fullscreen_or_maximized[rule.rule.fullscreen_or_maximized]
|
|
||||||
end
|
|
||||||
|
|
||||||
client.unary_request(build_grpc_request_params("AddWindowRule", {
|
client.unary_request(build_grpc_request_params("AddWindowRule", {
|
||||||
cond = rule.cond,
|
cond = rule.cond,
|
||||||
|
|
Loading…
Reference in a new issue