feat(hyprlua): size a fresh workspace's initial column count to monitor width
A workspace with no seeded/published column count used to always start at a hardcoded 2, regardless of monitor size. Now it picks floor(usable_width / 700), so ~700px per column — 1080p still lands on 2, wider monitors start with more instead of one cramped column.main
parent
c313f0694c
commit
2fd7b510ef
|
|
@ -99,11 +99,23 @@ local function seed(wsid)
|
|||
return out
|
||||
end
|
||||
|
||||
local function ws_state(wsid)
|
||||
-- First-ever layout of a workspace (no seeded/published state) picks its starting
|
||||
-- column count from the monitor's usable width, ~COL_TARGET_WIDTH px per column, so a
|
||||
-- wide monitor doesn't start out with one cramped default column and a narrow one
|
||||
-- doesn't start out overcrowded. 1080p (1920px) / 700 -> 2 columns.
|
||||
local COL_TARGET_WIDTH = 700
|
||||
|
||||
local function ws_state(wsid, area)
|
||||
local s = state[wsid]
|
||||
if not s then
|
||||
local sd = seed(wsid)
|
||||
s = { ncols = sd.ncols or 2, rows = sd.rows or 2, orient = sd.orient or "h",
|
||||
local orient = sd.orient or "h"
|
||||
local ncols = sd.ncols
|
||||
if not ncols then
|
||||
local len = area and ((orient == "h") and area.w or area.h)
|
||||
ncols = (len and len > 0) and math.max(1, math.floor(len / COL_TARGET_WIDTH)) or 2
|
||||
end
|
||||
s = { ncols = ncols, rows = sd.rows or 2, orient = orient,
|
||||
assign = {}, seq = {}, nextseq = 1, colw = {}, winh = {}, pan = {}, pair = {} }
|
||||
state[wsid] = s
|
||||
publish()
|
||||
|
|
@ -222,7 +234,7 @@ local function recalculate(ctx)
|
|||
if type(t) ~= "table" or not t[1] then return end
|
||||
local A = ctx.area
|
||||
if type(A) ~= "table" then return end
|
||||
local s = ws_state(win_ws_id(t[1].window))
|
||||
local s = ws_state(win_ws_id(t[1].window), A)
|
||||
local cols, tgt_of, foc = columnize(s, t)
|
||||
local horizontal = (s.orient ~= "v")
|
||||
local rows = math.max(1, s.rows)
|
||||
|
|
|
|||
Loading…
Reference in New Issue