diff --git a/internal/icons/fallback/icon.go b/internal/icons/fallback/icon.go index d697dde..e2a0594 100644 --- a/internal/icons/fallback/icon.go +++ b/internal/icons/fallback/icon.go @@ -505,11 +505,12 @@ func (this *iconSet) MimeIcon (mime data.Mime, size tomo.IconSize) canvas.Textur } } -func (this *iconSet) Close () { +func (this *iconSet) Close () error { if this.atlasSmall != nil { this.atlasSmall.Close() } if this.atlasLarge != nil { this.atlasLarge.Close() } + return nil } diff --git a/internal/icons/xdg/icon.go b/internal/icons/xdg/icon.go index e63c438..bfa3ca8 100644 --- a/internal/icons/xdg/icon.go +++ b/internal/icons/xdg/icon.go @@ -101,7 +101,7 @@ func (this *iconTheme) MimeIcon (mime data.Mime, size tomo.IconSize) canvas.Text } } -func (this *iconTheme) Close () { +func (this *iconTheme) Close () error { closeAllIn := func (mp map[tomo.Icon] canvas.TextureCloser) { for _, texture := range mp { if texture != nil { @@ -112,6 +112,7 @@ func (this *iconTheme) Close () { closeAllIn(this.texturesSmall) closeAllIn(this.texturesMedium) closeAllIn(this.texturesLarge) + return nil } func (this *iconTheme) icon (icon tomo.Icon, size tomo.IconSize) canvas.TextureCloser { diff --git a/internal/styles/fallback/wintergreen.go b/internal/styles/fallback/wintergreen.go index 9fb44d6..a9caa4a 100644 --- a/internal/styles/fallback/wintergreen.go +++ b/internal/styles/fallback/wintergreen.go @@ -1,6 +1,5 @@ package fallbackStyle -import "io" import "bytes" import "image" import _ "embed" @@ -47,12 +46,6 @@ var borderColorShade = [4]color.Color { colorShade, colorShade, col //go:embed assets/atlas.png var atlasBytes []byte -type closerCookie struct { io.Closer } -func (cookie closerCookie) Close () { cookie.Closer.Close() } -func newCloserCookie (closer io.Closer) event.Cookie { - return closerCookie { Closer: closer } -} - // New returns Wintergreen, the default Tomo style. It is neutral-gray with // green and turquoise accents. func New () (*style.Style, event.Cookie) { @@ -66,7 +59,7 @@ func New () (*style.Style, event.Cookie) { textureHandleVertical := atlasTexture.SubTexture(image.Rect(28, 0, 29, 2)) textureHandleHorizontal := atlasTexture.SubTexture(image.Rect(28, 0, 30, 1)) - cookie := event.MultiCookie(newCloserCookie(atlasTexture)) + cookie := event.MultiCookie(atlasTexture) rules := []style.Rule { // *.* diff --git a/internal/styles/tss/build.go b/internal/styles/tss/build.go index d807aa6..d0defa0 100644 --- a/internal/styles/tss/build.go +++ b/internal/styles/tss/build.go @@ -1,7 +1,6 @@ package tss import "os" -import "io" import "fmt" import "image" import "errors" @@ -81,7 +80,7 @@ func (this *styleBuilder) build () (*style.Style, event.Cookie, error) { // add each texture to the cookies list for _, texture := range this.textures { - cookies = append(cookies, closerCookie { Closer: texture }) + cookies = append(cookies, texture) } return sty, event.MultiCookie(cookies...), nil @@ -398,10 +397,3 @@ func copyBorderValue[T any, U ~[]T] (destination, source U) bool { return false } } - -type closerCookie struct { - io.Closer -} -func (cookie closerCookie) Close () { - cookie.Closer.Close() -} diff --git a/manager.go b/manager.go index 5cd99df..2f7916f 100644 --- a/manager.go +++ b/manager.go @@ -7,11 +7,6 @@ var manager struct { count int } -type funcCookie func () -func (cookie funcCookie) Close () { - cookie() -} - // WaitFor ensures that the application will stay running while the given window // is open. func WaitFor (window tomo.Window) event.Cookie { @@ -27,7 +22,12 @@ func WaitFor (window tomo.Window) event.Cookie { } } + handleWaitClose := func () error { + handleClose(); + return nil + } + return event.MultiCookie ( window.OnClose(handleClose), - funcCookie(handleClose)) + event.FuncCookie(handleWaitClose)) }