From 6b251e6fee1f9f437f0abc0609f0af5c75ec9dce Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Mon, 14 Nov 2022 23:38:41 -0500 Subject: [PATCH] Position buffer in center of screen --- backends/x/event.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/backends/x/event.go b/backends/x/event.go index 4195431..e55c61e 100644 --- a/backends/x/event.go +++ b/backends/x/event.go @@ -32,7 +32,19 @@ func (backend *Backend) handleConfigureNotify ( if sizeChanged { configureEvent = backend.compressConfigureNotify(configureEvent) - backend.application.SetSize(backend.calculateBufferSize()) + + // resize buffer + width, height := backend.calculateBufferSize() + backend.application.SetSize(width, height) + + // position buffer in the center of the screen + frameWidth := width * backend.metrics.cellWidth + frameHeight := height * backend.metrics.cellHeight + backend.metrics.paddingX = + (backend.metrics.windowWidth - frameWidth) / 2 + backend.metrics.paddingY = + (backend.metrics.windowHeight - frameHeight) / 2 + backend.channel <- stone.EventResize { } } }