From c0f2a31366e37a4260540626b0633262ef0ab7ee Mon Sep 17 00:00:00 2001 From: Dannii Willis Date: Sat, 19 Oct 2024 15:18:04 +1000 Subject: [PATCH] [Protocol change] When a window has no internal size, mark it as hidden to ensure it also has no padding --- src/common/protocol.ts | 4 +++- src/glkapi/glkapi.ts | 10 +++++----- src/glkapi/windows.ts | 7 +++++-- src/glkote/web/windows.css | 4 ++++ src/glkote/web/windows.ts | 1 + 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/common/protocol.ts b/src/common/protocol.ts index b9cc520..a3969e9 100644 --- a/src/common/protocol.ts +++ b/src/common/protocol.ts @@ -3,7 +3,7 @@ The GlkOte protocol =================== -Copyright (c) 2023 Dannii Willis +Copyright (c) 2024 Dannii Willis MIT licenced https://github.com/curiousdannii/asyncglk @@ -450,6 +450,8 @@ export interface WindowUpdate { /** Grid width (chars) */ gridwidth?: number, height: number, + /** Whether the window should be completely hidden, though could potentially still respond to character events */ + hidden?: boolean, /** Window ID */ id: number, /** Left position */ diff --git a/src/glkapi/glkapi.ts b/src/glkapi/glkapi.ts index 1794e5c..463d8c0 100644 --- a/src/glkapi/glkapi.ts +++ b/src/glkapi/glkapi.ts @@ -1834,21 +1834,21 @@ export class AsyncGlk implements Interface.GlkApi { switch (win.key!.type) { case 'buffer': if (win.vertical) { - split = win.size * metrics.buffercharwidth + metrics.buffermarginx + split = win.size ? (win.size * metrics.buffercharwidth + metrics.buffermarginx) : 0 } else { - split = win.size * metrics.buffercharheight + metrics.buffermarginy + split = win.size ? (win.size * metrics.buffercharheight + metrics.buffermarginy) : 0 } break case 'graphics': - split = win.size + (win.vertical ? metrics.graphicsmarginx : metrics.graphicsmarginy) + split = win.size ? (win.size + (win.vertical ? metrics.graphicsmarginx : metrics.graphicsmarginy)) : 0 break case 'grid': if (win.vertical) { - split = win.size * metrics.gridcharwidth + metrics.gridmarginx + split = win.size ? (win.size * metrics.gridcharwidth + metrics.gridmarginx) : 0 } else { - split = win.size * metrics.gridcharheight + metrics.gridmarginy + split = win.size ? (win.size * metrics.gridcharheight + metrics.gridmarginy) : 0 } break } diff --git a/src/glkapi/windows.ts b/src/glkapi/windows.ts index fd93006..f0c7001 100644 --- a/src/glkapi/windows.ts +++ b/src/glkapi/windows.ts @@ -81,17 +81,20 @@ abstract class WindowBase implements GlkWindow { copy_prop(this.input, input_update, 'mouse') const box = this.box + const height = box.bottom - box.top + const width = box.right - box.left return { content: null, input: input_update, size: { - height: box.bottom - box.top, + height, + hidden: height === 0 || width === 0, id: this.disprock, left: box.left, rock: this.rock, top: box.top, type: this.type, - width: box.right - box.left, + width, }, } } diff --git a/src/glkote/web/windows.css b/src/glkote/web/windows.css index 6f9d8a3..1d92acb 100644 --- a/src/glkote/web/windows.css +++ b/src/glkote/web/windows.css @@ -17,6 +17,10 @@ https://github.com/curiousdannii/asyncglk position: absolute; } +.WindowFrame.hidden { + padding: 0; +} + .BufferWindow { color: var(--glkote-buffer-fg); font-family: var(--glkote-prop-family); diff --git a/src/glkote/web/windows.ts b/src/glkote/web/windows.ts index 5749fa8..418d050 100644 --- a/src/glkote/web/windows.ts +++ b/src/glkote/web/windows.ts @@ -892,6 +892,7 @@ export default class Windows extends Map { top: update.top, width: update.width, }) + .toggleClass('hidden', update.hidden) if (win.type === 'buffer') { win.scroll_to_bottom(true) }