From 2fd7b510ef117244bfb1f4097054952035a1c150 Mon Sep 17 00:00:00 2001 From: The_miro Date: Thu, 16 Jul 2026 09:08:23 +0200 Subject: [PATCH] feat(hyprlua): size a fresh workspace's initial column count to monitor width MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- desktopenvs/hyprlua/hypr/layouts/columns.lua | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/desktopenvs/hyprlua/hypr/layouts/columns.lua b/desktopenvs/hyprlua/hypr/layouts/columns.lua index 94ba967..10c728b 100644 --- a/desktopenvs/hyprlua/hypr/layouts/columns.lua +++ b/desktopenvs/hyprlua/hypr/layouts/columns.lua @@ -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)