Update Hyprland scratchpad workarea cache

This commit is contained in:
2026-05-05 13:23:14 -07:00
parent d3912fc060
commit fc293e079a

View File

@@ -1269,21 +1269,12 @@ local function split_tsv(line)
return fields
end
local function monitor_from_reserved_cache(monitor)
if verify_config or not monitor or not monitor.name then
local function monitor_from_reserved_fields(monitor, fields)
if not monitor or not monitor.name or fields[1] ~= monitor.name or #fields < 10 then
return nil
end
local file = io.open(monitor_reserved_cache_path, "r")
if not file then
return nil
end
local cached = nil
for line in file:lines() do
local fields = split_tsv(line)
if fields[1] == monitor.name and #fields >= 10 then
cached = {
return {
name = monitor.name,
x = tonumber(fields[2]),
y = tonumber(fields[3]),
@@ -1297,9 +1288,33 @@ local function monitor_from_reserved_cache(monitor)
tonumber(fields[10]),
},
}
break
end
local function monitor_from_reserved_lines(monitor, lines)
if not monitor or not monitor.name then
return nil
end
for line in lines do
local cached = monitor_from_reserved_fields(monitor, split_tsv(line))
if cached then
return cached
end
end
return nil
end
local function monitor_from_reserved_cache(monitor)
if verify_config or not monitor or not monitor.name then
return nil
end
local file = io.open(monitor_reserved_cache_path, "r")
if not file then
return nil
end
local cached = monitor_from_reserved_lines(monitor, file:lines())
file:close()
return cached
end
@@ -2272,6 +2287,11 @@ hl.on("config.reloaded", apply_hyprexpo_config)
hl.on("config.reloaded", apply_hyprwinview_config)
hl.on("config.reloaded", apply_rules)
hl.on("config.reloaded", refresh_shell_workarea_and_scratchpads)
hl.on("layer.opened", refresh_shell_workarea_and_scratchpads)
hl.on("layer.closed", refresh_shell_workarea_and_scratchpads)
hl.on("monitor.added", refresh_shell_workarea_and_scratchpads)
hl.on("monitor.removed", refresh_shell_workarea_and_scratchpads)
hl.on("monitor.layout_changed", refresh_shell_workarea_and_scratchpads)
hl.on("window.open", schedule_nstack_count_update)
hl.on("window.destroy", schedule_nstack_count_update)