Added simpler method of detecting window bounds change on draw

This commit is contained in:
Sasha Koshka 2022-11-16 11:14:30 -05:00
parent cab280a371
commit 81a0c60943
3 changed files with 9 additions and 15 deletions

View File

@ -11,21 +11,16 @@ func (backend *Backend) Draw () {
backend.lock.Lock() backend.lock.Lock()
defer backend.lock.Unlock() defer backend.lock.Unlock()
boundsChanged := if backend.windowBoundsClean {
backend.memory.windowWidth != backend.metrics.windowWidth || backend.canvas.XPaintRects (
backend.memory.windowHeight != backend.metrics.windowHeight backend.window.Id,
backend.memory.windowWidth = backend.metrics.windowWidth backend.drawCells(false)...)
backend.memory.windowHeight = backend.metrics.windowHeight } else {
if boundsChanged {
backend.reallocateCanvas() backend.reallocateCanvas()
backend.drawCells(true) backend.drawCells(true)
backend.canvas.XDraw() backend.canvas.XDraw()
backend.canvas.XPaint(backend.window.Id) backend.canvas.XPaint(backend.window.Id)
} else { backend.windowBoundsClean = true
backend.canvas.XPaintRects (
backend.window.Id,
backend.drawCells(false)...)
} }
} }

View File

@ -46,6 +46,8 @@ func (backend *Backend) handleConfigureNotify (
(backend.metrics.windowWidth - frameWidth) / 2 (backend.metrics.windowWidth - frameWidth) / 2
backend.metrics.paddingY = backend.metrics.paddingY =
(backend.metrics.windowHeight - frameHeight) / 2 (backend.metrics.windowHeight - frameHeight) / 2
backend.windowBoundsClean = false
} }
backend.lock.Unlock() backend.lock.Unlock()

View File

@ -43,10 +43,7 @@ type Backend struct {
descent int descent int
} }
memory struct { windowBoundsClean bool
windowWidth int
windowHeight int
}
} }
func (backend *Backend) SetTitle (title string) (err error) { func (backend *Backend) SetTitle (title string) (err error) {