From c92377f50b6a5dd23554d2945c3696e586c3b1e7 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sun, 26 May 2024 15:16:31 -0400 Subject: [PATCH] Add Visible, SetVisible to Window --- window.go | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/window.go b/window.go index 9e52c6a..0630daf 100644 --- a/window.go +++ b/window.go @@ -32,6 +32,7 @@ type window struct { modalParent *window hasModal bool shy bool + visible bool metrics struct { bounds image.Rectangle @@ -265,14 +266,21 @@ func (window *window) Paste (callback func (data.Data, error), accept ...data.Mi // TODO } -func (window *window) Show () { - window.xWindow.Map() - if window.shy { window.grabInput() } +func (window *window) SetVisible (visible bool) { + if this.visible == visible { return } + window.visible = visible + + if this.visible { + window.xWindow.Map() + if window.shy { window.grabInput() } + } else { + window.xWindow.Unmap() + if window.shy { window.ungrabInput() } + } } -func (window *window) Hide () { - window.xWindow.Unmap() - if window.shy { window.ungrabInput() } +func (window *window) Visible () bool { + return this.visible } func (window *window) Close () {