Add Visible, SetVisible to Window

This commit is contained in:
Sasha Koshka 2024-05-26 15:16:31 -04:00
parent 8b44526c94
commit c92377f50b

View File

@ -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 () {