Add output to window rule

This commit is contained in:
Ottatop 2023-09-07 17:42:03 -05:00
parent 946f732502
commit 178ee9464b
3 changed files with 20 additions and 6 deletions

View file

@ -13,6 +13,7 @@ local function convert_tag_params(cond)
---@diagnostic disable-next-line
tag = tag:id()
end
---@diagnostic disable-next-line
cond.tag = tag
end
@ -89,13 +90,12 @@ function window_rules.add(...)
local rules = { ... }
for _, rule in pairs(rules) do
---@diagnostic disable-next-line a lil cheating
---@diagnostic disable-next-line
rule.cond = convert_tag_params(rule.cond)
if rule.rule.tags then
local tags = {}
for _, tag in pairs(rule.rule.tags) do
---@type TagId|Tag|nil
local t = require("tag").create_tag_from_params(tag)
if t then
---@diagnostic disable-next-line
@ -106,7 +106,12 @@ function window_rules.add(...)
rule.rule.tags = tags
end
RPrint(rule)
if rule.rule.output and type(rule.rule.output) == "table" then
rule.rule.output = rule
.rule
.output--[[@as Output]]
:name()
end
SendMsg({
AddWindowRule = {

View file

@ -31,7 +31,7 @@
---@field location { [1]: integer, [2]: integer }? The location the window will spawn at. If the window spawns tiled, it will instead snap to this location when set to floating.
---@class WindowRule Attributes the window will be spawned with.
---@field output OutputName? The output this window will be spawned on. TODO:
---@field output (Output|OutputName)? The output this window will be spawned on. TODO:
---@field tags (Tag|TagTable|TagTableNamed|string)[]? The tags this window will be spawned with.
---@field floating_or_tiled ("Floating"|"Tiled")? Whether or not this window will be spawned floating or tiled.
---@field fullscreen_or_maximized FullscreenOrMaximized? Whether or not this window will be spawned fullscreen, maximized, or forced to neither.

View file

@ -127,8 +127,17 @@ impl XdgShellHandler for State {
location,
} = rule;
if let Some(_output_name) = output {
// TODO:
// TODO: If both `output` and `tags` are specified, `tags` will apply over
// | `output`.
if let Some(output_name) = output {
if let Some(output) = output_name.output(&data.state) {
let tags = output.with_state(|state| {
state.focused_tags().cloned().collect::<Vec<_>>()
});
window.with_state(|state| state.tags = tags.clone());
}
}
if let Some(tag_ids) = tags {