Update Hyprland scratchpad workarea cache
This commit is contained in:
@@ -1269,21 +1269,12 @@ local function split_tsv(line)
|
|||||||
return fields
|
return fields
|
||||||
end
|
end
|
||||||
|
|
||||||
local function monitor_from_reserved_cache(monitor)
|
local function monitor_from_reserved_fields(monitor, fields)
|
||||||
if verify_config or not monitor or not monitor.name then
|
if not monitor or not monitor.name or fields[1] ~= monitor.name or #fields < 10 then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local file = io.open(monitor_reserved_cache_path, "r")
|
return {
|
||||||
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 = {
|
|
||||||
name = monitor.name,
|
name = monitor.name,
|
||||||
x = tonumber(fields[2]),
|
x = tonumber(fields[2]),
|
||||||
y = tonumber(fields[3]),
|
y = tonumber(fields[3]),
|
||||||
@@ -1297,9 +1288,33 @@ local function monitor_from_reserved_cache(monitor)
|
|||||||
tonumber(fields[10]),
|
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
|
||||||
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()
|
file:close()
|
||||||
return cached
|
return cached
|
||||||
end
|
end
|
||||||
@@ -2272,6 +2287,11 @@ hl.on("config.reloaded", apply_hyprexpo_config)
|
|||||||
hl.on("config.reloaded", apply_hyprwinview_config)
|
hl.on("config.reloaded", apply_hyprwinview_config)
|
||||||
hl.on("config.reloaded", apply_rules)
|
hl.on("config.reloaded", apply_rules)
|
||||||
hl.on("config.reloaded", refresh_shell_workarea_and_scratchpads)
|
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.open", schedule_nstack_count_update)
|
||||||
hl.on("window.destroy", schedule_nstack_count_update)
|
hl.on("window.destroy", schedule_nstack_count_update)
|
||||||
|
|||||||
Reference in New Issue
Block a user