omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

Quake console: a console floated with Super+T keeps the size of the monitor it was floated on and is cropped on a smaller one

Open andrew-roci opened this issue 5 days ago • 1 comments

System details

Apple M1 MacBook Air (aarch64-apple, Asahi), Omarchy 4.5.0-3 on the stable channel, Hyprland 0.56.2. Two monitors of different sizes: an LG ultrawide at 3440x1440, scale 1 (DP-2), and the built-in panel at 2560x1600, scale 2, so 1280x800 logical (eDP-1). The bar reserves 26 px at the top of both.

What's wrong?

The Quake console is sized by gaps, so the tiled console always fits the screen it opens on. A console floated with Super+T does not: it keeps the size of the monitor it was floated on, and on the smaller monitor only the middle of it is visible.

Steps

  1. With the external monitor connected, open the console on it (Super+grave). The agent window is tiled at 1013,26 with size 1414x707.
  2. Press Super+T. The window floats at 0,0 with size 3440x1440: the whole monitor, the strip under the bar included.
  3. Unplug the external monitor.
  4. Close the console and reopen it on the laptop.

What happens

On the laptop the window is still 3440x1440, centered at -640,1120. The laptop's usable area is 1280x774, so a little over a third of its width and about half of its height show, and the rest of the text is cut off.

Two variants of the same thing:

  • The unplug is not needed. With that console opened on the laptop, Super+T floats it at 3440x1440 as well (-1720,800), because Hyprland floats a window at the size it was last laid out with.
  • Plugging the external monitor back in and reopening the console there puts it mostly off that screen too (-1081,-321).

The positions and sizes come from replaying this in a nested Hyprland 0.56.2 on the same binary, with two outputs set up like mine and a 26 px bar on each. On the hardware itself I have only seen the result.

Expected

A floated console fits the screen it is shown on, the way the tiled one does.

Cause

default/hypr/qconsole.lua sizes the console with workspace gaps, and gaps only lay out tiled windows: alone() counts the tiled ones and fit() writes the gaps. Floating windows are never looked at. Hyprland does not do it either: it carries a floating window to another monitor at the same offset, or centers one whose middle has left the screen (CMonitor::setSpecialWorkspace and CWorkspacePlacementController::moveWorkspaceToMonitor in 0.56.2), but never resizes one.

The sizing code on quattro is the same as in 4.5.0 (the file only differs in how the console is seeded and in one animation curve), so I expect this is present there too. I checked the source; I am not running that branch.

Suggested fix

Cut the floating windows on the console down to the monitor's work area in refit(), each side only as far as it has to, and center them there. Only while the console is on screen: monitor.focused fires on every hop between monitors, and a window is never grown back, so a hidden console must not be cut down for whichever monitor the pointer is over.

Diff against quattro (fa265f4) for default/hypr/qconsole.lua
diff --git a/default/hypr/qconsole.lua w/default/hypr/qconsole.lua
index 66f0e66..dd6f964 100644
--- i/default/hypr/qconsole.lua
+++ b/default/hypr/qconsole.lua
@@ -81,6 +81,33 @@ local function alone()
   return tiled <= 1
 end
 
+-- The monitor's work area in logical pixels: its box less the reserved strips
+-- (the bar). Width and height are the panel's own pixels, so a monitor turned
+-- on its side still reports them the way the panel is built. The odd transforms
+-- are the quarter turns, and those are the ones that swap the work area.
+-- Monitor dimensions are physical; gaps and windows are logical, so the scale
+-- has to come out before the reserved area (already logical) comes off.
+--
+-- A monitor handle whose output has gone away answers nil to every field, and
+-- layout changes are exactly when that happens, so the scale guard has to come
+-- before anything else is read off it.
+local function work_area(monitor)
+  if not monitor or not monitor.scale or monitor.scale <= 0 then
+    return nil
+  end
+
+  local width, height = monitor.width, monitor.height
+  if monitor.transform % 2 == 1 then
+    width, height = height, width
+  end
+
+  local reserved = monitor.reserved
+  return {
+    width = width / monitor.scale - reserved.left - reserved.right,
+    height = height / monitor.scale - reserved.top - reserved.bottom,
+  }
+end
+
 -- Sizing the console with a window rule would freeze it at whatever the screen
 -- measured when it first opened, because Hyprland resolves those expressions
 -- once, as the window maps. Rescaling the monitor afterwards would leave a
@@ -88,34 +115,41 @@ end
 -- instead, so the console is sized by the area left around it, and that area is
 -- recomputed whenever the monitor it opens on changes.
 local function fit(monitor)
-  -- A monitor handle whose output has gone away answers nil to every field, and
-  -- layout changes are exactly when that happens, so this also covers reading
-  -- width, height and reserved below.
-  if not monitor or not monitor.scale or monitor.scale <= 0 then
+  local area = work_area(monitor)
+  if not area then
     return false
   end
 
-  -- Width and height are the panel's own pixels, so a monitor turned on its
-  -- side still reports them the way the panel is built. The odd transforms are
-  -- the quarter turns, and those are the ones that swap the work area.
-  local width, height = monitor.width, monitor.height
-  if monitor.transform % 2 == 1 then
-    width, height = height, width
-  end
-
-  -- Monitor dimensions are in physical pixels; gaps are logical, so the scale
-  -- has to come out before the reserved area (already logical) comes off.
-  local reserved = monitor.reserved
-  height = height / monitor.scale - reserved.top - reserved.bottom
-  width = width / monitor.scale - reserved.left - reserved.right
-
-  local tall = math.floor(height * share)
-  local wide = width
+  local tall = math.floor(area.height * share)
+  local wide = area.width
   if alone() then
-    wide = math.min(width, tall * box)
+    wide = math.min(area.width, tall * box)
   end
 
-  return cover(math.floor((width - wide) / 2), math.floor(height - tall))
+  return cover(math.floor((area.width - wide) / 2), math.floor(area.height - tall))
+end
+
+-- The gaps lay out only the tiled console. A window floated on it (Super+T)
+-- keeps whatever size Hyprland last laid it out with -- for the console's own
+-- window, the whole of the screen it first opened on -- and Hyprland carries a
+-- floating window to another monitor at the same offset, or centers it, but
+-- never resizes one. So a console floated on a 3440x1440 monitor and opened on
+-- a 1280x800 laptop shows only its middle. It is cut down to the work area
+-- instead, each side only as far as it has to, and centered in it.
+--
+-- Only windows that are still on screen: this runs on window.destroy too,
+-- where the window on its way out is still listed, and one that is gone has no
+-- layout left to resize. Pinned ones follow monitors on their own account, and
+-- a fullscreen one already covers exactly the monitor.
+local function fit_floating(area)
+  for _, window in ipairs(hl.get_workspace_windows(CONSOLE)) do
+    local size = window.mapped and window.floating and not window.pinned and (window.fullscreen or 0) == 0 and window.size
+    if size and (size.x > area.width or size.y > area.height) then
+      local target = "address:" .. window.address
+      hl.dispatch(hl.dsp.window.resize({ x = math.min(size.x, math.floor(area.width)), y = math.min(size.y, math.floor(area.height)), relative = false, window = target }))
+      hl.dispatch(hl.dsp.window.center({ window = target }))
+    end
+  end
 end
 
 -- The console keeps the geometry of the output it is open on: a follow_mouse hop
@@ -133,11 +167,27 @@ local function console_monitor()
 end
 
 local function refit(monitor)
-  if fit(monitor or console_monitor()) then
+  local mon = monitor or console_monitor()
+
+  -- Read the work area for the floating windows before the rule is written:
+  -- writing it schedules a state refresh, and measured on Hyprland 0.56.2 a
+  -- monitor plugged in during the session can read as not yet placed (no
+  -- position, no reserved area) for a moment after one.
+  local ws = hl.get_workspace(CONSOLE)
+  local area = ws and ws.visible and work_area(mon) or nil
+
+  if fit(mon) then
     -- Land the new gaps in this pass rather than a frame later, so the console
     -- does not visibly resize itself once it has already dropped down.
     hl.exec_scheduled_prop_refresh_immediately()
   end
+
+  -- Only while the console is on screen. It is refitted on its way in, and a
+  -- window is only ever cut down here, never grown back, so a hidden console
+  -- must not be cut down for whichever monitor the pointer is over.
+  if area then
+    fit_floating(area)
+  end
 end
 
 -- Until a monitor can be read, cover the whole work area rather than leaving
@@ -179,6 +229,11 @@ end)
 -- those always reads the settled count; the earlier ones refit to what the rule
 -- already is, which cover() skips.
 --
+-- The bar arriving on the monitor changes the work area under a console that is
+-- already open: the shell's bar on a monitor plugged in a moment ago, or after
+-- the shell restarts. Hyprland has taken the reserved area into account by the
+-- time layer.opened fires, and nothing else refits for it.
+--
 -- Only while it is on screen, though. A hidden console is refitted on its way in
 -- by workspace.special_active, and every window opened anywhere on the desktop
 -- would otherwise rewrite the rule.
@@ -193,6 +248,7 @@ hl.on("window.open", recount)
 hl.on("window.destroy", recount)
 hl.on("window.move_to_workspace", recount)
 hl.on("window.update_rules", recount)
+hl.on("layer.opened", recount)
 
 -- The direction names the edge the offset is measured from, not where the
 -- workspace goes: "slide top" drops it down into view, and "slide bottom"

The work-area arithmetic moves out of fit() into a work_area() helper so the panel and the floats use the same numbers. layer.opened joins the events that refit, so a bar arriving under a console that is already open (on a monitor plugged in a moment ago, or after the shell restarts) is accounted for.

Test to go with it, in test/shell.d/hyprland-qconsole-test.sh
diff --git a/test/shell.d/hyprland-qconsole-test.sh w/test/shell.d/hyprland-qconsole-test.sh
index 4aca4fc..c5c880e 100755
--- i/test/shell.d/hyprland-qconsole-test.sh
+++ b/test/shell.d/hyprland-qconsole-test.sh
@@ -11,7 +11,7 @@ require_command lua
 # base-test.sh does not set -e, so the assertions have to fail the file
 # themselves rather than leaving the pass below to run regardless.
 OMARCHY_PATH="$ROOT" lua - <<'LUA' || fail "the console is a centered panel until a second app joins it"
-local rules, handlers, spawned = {}, {}, {}
+local rules, handlers, spawned, placed = {}, {}, {}, {}
 local monitor = nil
 local workspace = nil
 
@@ -23,15 +23,26 @@ hl = {
   get_active_monitor = function() return monitor end,
   get_workspace = function() return workspace end,
   -- workspace.windows is the tiled count here and workspace.floats the floating
-  -- one, so the fixtures can say which kind of window is on the console.
+  -- one, so the fixtures can say which kind of window is on the console. A
+  -- floating one is workspace.float_size, which is what the console has to fit.
   get_workspace_windows = function()
     local list = {}
     for _ = 1, workspace and workspace.windows or 0 do table.insert(list, { floating = false }) end
-    for _ = 1, workspace and workspace.floats or 0 do table.insert(list, { floating = true }) end
+    for _ = 1, workspace and workspace.floats or 0 do
+      table.insert(list, { floating = true, mapped = workspace.float_mapped ~= false, address = "0x5", size = workspace and workspace.float_size })
+    end
     return list
   end,
   exec_scheduled_prop_refresh_immediately = function() end,
   exec_cmd = function(cmd, rules) table.insert(spawned, { cmd = cmd, rules = rules }) end,
+  -- What the console asks Hyprland to do to a window, in order.
+  dispatch = function(dispatcher) table.insert(placed, dispatcher) end,
+  dsp = {
+    window = {
+      resize = function(args) return { kind = "resize", args = args } end,
+      center = function(args) return { kind = "center", args = args } end,
+    },
+  },
 }
 
 dofile(os.getenv("OMARCHY_PATH") .. "/default/hypr/bootstrap.lua")
@@ -279,6 +290,84 @@ handlers["window.move_to_workspace"]()
 top, right, bottom, left = gaps()
 assert(left == 435 and right == 435, "moving it back off recenters the panel")
 
+-- The gaps cannot size a window floated on the console (Super+T): Hyprland
+-- floats it at whatever size it last laid it out with, the whole of whichever
+-- screen that was, and never shrinks a floating window. Opened on a screen with
+-- no room for it, it is cut down to the work area and centered there.
+placed = {}
+workspace = { name = "special:qconsole", visible = true, monitor = acer, windows = 0, floats = 1, float_size = { x = 3440, y = 1440 } }
+handlers["workspace.special_active"]({ name = "special:qconsole" }, acer)
+local resized, centered = placed[1], placed[2]
+assert(#placed == 2 and resized.kind == "resize" and centered.kind == "center",
+  "a console floated on a bigger screen is cut down to the work area and centered")
+-- The Acer is 1920x1080 with a 30px bar.
+assert(resized.args.x == 1920 and resized.args.y == 1050 and resized.args.relative == false and resized.args.window == "address:0x5",
+  "and cut down to the work area, not the whole screen")
+assert(centered.args.window == "address:0x5", "the window centered is the one that was cut down")
+
+-- Each side only as far as it has to: too wide keeps its height.
+placed = {}
+workspace.float_size = { x = 2560, y = 600 }
+handlers["window.update_rules"]()
+assert(#placed == 2 and placed[1].args.x == 1920 and placed[1].args.y == 600, "a side with room is not cut")
+
+-- One that already fits is left exactly as it is.
+placed = {}
+workspace.float_size = { x = 800, y = 500 }
+handlers["window.update_rules"]()
+assert(#placed == 0, "a floating window that fits is left alone")
+
+-- The gaps still size the tiled console around it: a floating window too big
+-- for the screen does not make it a workspace.
+top, right, bottom, left = gaps()
+assert(left == 435 and right == 435, "and fitting the float leaves the panel alone")
+
+-- A hidden console is not cut down for whichever monitor happens to be
+-- focused: focus alone hops between screens, and a window is never grown back.
+-- It is fitted on its way in instead.
+placed = {}
+workspace = { name = "special:qconsole", visible = false, monitor = dell, floats = 1, float_size = { x = 3440, y = 1440 } }
+monitor = acer
+handlers["monitor.focused"](acer)
+handlers["monitor.layout_changed"]()
+assert(#placed == 0, "a hidden console's floating window is not cut down for the focused monitor")
+workspace.visible, workspace.monitor = true, acer
+handlers["workspace.special_active"]({ name = "special:qconsole" }, acer)
+assert(#placed == 2 and placed[1].args.x == 1920 and placed[1].args.y == 1050,
+  "opening the console on the smaller screen is what cuts the float down")
+
+-- This also runs on window.destroy, where the window on its way out is still
+-- listed. One that is no longer mapped has no layout left to resize, so nothing
+-- is asked of Hyprland for it, however big it still reads.
+placed = {}
+workspace = { name = "special:qconsole", visible = true, monitor = acer, windows = 0, floats = 1, float_size = { x = 3440, y = 1440 }, float_mapped = false }
+handlers["window.destroy"]()
+assert(#placed == 0, "a window on its way out is not resized")
+
+-- The bar can arrive under a console that is already open, on a monitor plugged
+-- in a moment ago. The float then has to be cut down for the area that is left.
+placed = {}
+local bare = { width = 1920, height = 1080, scale = 1, transform = 0, reserved = { top = 0, bottom = 0, left = 0, right = 0 } }
+workspace = { name = "special:qconsole", visible = true, monitor = bare, windows = 0, floats = 1, float_size = { x = 1920, y = 1080 } }
+handlers["workspace.special_active"]({ name = "special:qconsole" }, bare)
+assert(#placed == 0, "a float that fills the screen while it has no bar is left alone")
+bare.reserved.top = 30
+handlers["layer.opened"]()
+assert(#placed == 2 and placed[1].args.x == 1920 and placed[1].args.y == 1050, "the bar arriving cuts the float down to the area that is left")
+top, right, bottom, left = gaps()
+assert(bottom == 525, "and the panel under the console is refitted for the bar too")
+
+-- The output it is showing on can go away mid-layout-change, as above for the
+-- panel. The window is cut down for the monitor that is still there, and
+-- nothing is read off the dead handle to do it. The Dell is 6144x2560 with a
+-- 30px bar.
+placed = {}
+workspace = { name = "special:qconsole", visible = true, monitor = expired, floats = 1, float_size = { x = 8000, y = 4000 } }
+monitor = dell
+handlers["monitor.focused"](dell)
+assert(#placed == 2 and placed[1].args.x == 6144 and placed[1].args.y == 2530,
+  "a console whose output vanished has its float cut down for the monitor that is still there")
+
 -- window.close still counts the window on its way out, and window.destroy
 -- follows it with the settled count, so only destroy is hooked.
 assert(handlers["window.close"] == nil, "window.close counts the window on its way out")

How it was checked

  • bash test/shell.d/hyprland-qconsole-test.sh passes on quattro as it is, fails once the test above is added (a console floated on a bigger screen is cut down to the work area and centered), and passes again with the change.
  • The change was also broken one way at a time to see the test go red for each: cutting both sides instead of only the ones with no room, not centering, fitting a hidden console, ignoring the bar, dropping the layer.opened hook, and resizing a window that is no longer mapped.
  • The test files that load this module, the whole default config, or its neighbours (bar, default-agent, config, hyprland-binding-conflicts, hyprland-corners, hyprland-default-config, hyprland-keyboard-layout, hyprland-pop, hyprland-floating-workspaces, hyprland-monitor-workspaces, hyprland-software-rendering, keybindings-menu, theme-staging) all pass on both trees with the same counts. I did not run ./test/all.
  • The changed module was run in place of the packaged one in the nested Hyprland described above, with no other change to the config:
Step quattro as it is with the change
Super+T on the external monitor 3440x1440 at 0,0, top of it under the bar 3440x1414 at 0,26
External monitor unplugged while the console is open 3440x1440 on the laptop 1280x774, at once
Closed and reopened on the laptop 3440x1440 at -640,1120 1280x774
Super+T on the laptop, nothing unplugged 3440x1440 at -1720,800 1280x774
External monitor plugged back in 3440x1440 at -1081,-321 1280x774, see below

A floating console that already fits, including one resized by hand, and the tiled console are left as they are.

Trade-off, and a possible follow-up

The change only ever cuts a window down. Back on the external monitor the console stays 1280x774 until it is resized by hand, and Super+T twice does not give it a fresh size.

The version I run is a user module under ~/.config/hypr/, since default/ is package-owned. It does the same and also remembers the size a window was cut down from, as a tag on the window so that it survives config reloads, and gives it back on a screen that has room for it. I left that out of the diff to keep it small. Happy to send it, or to open a PR with either version.

That user module is installed here and fixes it for me with a real unplug. The diff above is the same logic, but I have checked it with the test and in the nested compositor, not on the hardware.

I have not attached omarchy-debug output, since it is mostly network addresses and the package list from my machine and nothing in it bears on this. Say the word if you would like any of it, or a recording of the bug.

This was put together with an AI coding agent (OpenCode). The workaround is what I ran and confirmed on the hardware myself.

andrew-roci avatar Nov 27 '26 22:11 andrew-roci

GPT-6 High in Codex reproduced the clipping on an Omarchy ISO worker running Hyprland 0.57.2. On the smaller output, PR #20492 fits the floating terminal to 1,280 × 774 below the bar, including when the larger output is removed while the console is open. Opus 5.5 High reviewed the revised fix, and CI passed. The pull request is with the maintainer.

Before — the starts of the terminal lines are clipped

After — the terminal fits below the bar and each line starts on screen

omarchybot avatar Nov 27 '26 23:11 omarchybot