From 05ffc9da10a0b09c9007caffa3c6ae841c24da20 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 22 Apr 2025 16:01:26 -0400 Subject: [PATCH] Constrain aspect ratio When parceling out the screen real estate, avoid either the height or the width from getting way out of proportion. Better to let screen be unused than abuse it to distort the aspect ratio too much. --- confluent_client/bin/nodeconsole | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/confluent_client/bin/nodeconsole b/confluent_client/bin/nodeconsole index 01bbd98f..36aa8807 100755 --- a/confluent_client/bin/nodeconsole +++ b/confluent_client/bin/nodeconsole @@ -125,8 +125,18 @@ def indirect_console(): termios.tcsetattr(sys.stdin.fileno(), termios.TCSANOW, oldtcattr) def determine_tile_size(numnodes): + # for now, smash everything to a common aspect ratio. 16:11 + # is pretty much wrong for everything, making 4:3 a bit too wide + # and 16:9 significantly too narrow, but it is serviceable + # An improvement could come with us owning the scaling + # instead of delegating to Kitty, which says if we specify both, + # we get stretching. In theory we should be able to get aspect correct + # from kitty by omitting, but: + # then we don't know how much to move the cursor left after draw_image + # Konsole won't scale at all with only partial scaling specified cheight, cwidth, pixwidth, pixheight = sq.get_screengeom() - ratio = (pixwidth / 16) / (pixheight / 10) + # 16:12 is to roughly account for the 'titles' of the tiles + ratio = (pixwidth / 16) / (pixheight / 12) bestdeviation = None bestdims = [] for i in range(1, numnodes + 1): @@ -144,6 +154,14 @@ def determine_tile_size(numnodes): bestdims = [columns, rows] cellswide = cwidth // bestdims[0] cellshigh = cheight // bestdims[1] + tilewidth = cellswide * pixwidth / cwidth + tileheight = cellshigh * pixheight / cheight + if tilewidth > (tileheight * 16 / 11): + tilewidth = tileheight * 16 / 11 + cellswide = int(tilewidth // (pixwidth / cwidth)) + if tileheight > (tilewidth * 11 /16): + tileheight = tilewidth * 11 / 16 + cellshigh = int(tileheight // (pixheight / cheight)) bestdims = bestdims + [cellswide, cellshigh] return bestdims