Ophestra Umiker
380d1f4585
All checks were successful
test / test (push) Successful in 29s
Values used in the Wayland mediation implementation is stored in various struct fields strewn across multiple app structs and checks are messy and confusing. This commit unifies them into a single struct and access it using much better looking methods. Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
36 lines
489 B
Go
36 lines
489 B
Go
package shim
|
|
|
|
import (
|
|
"net"
|
|
"sync"
|
|
)
|
|
|
|
// Wayland implements wayland mediation.
|
|
type Wayland struct {
|
|
// wayland socket path
|
|
Path string
|
|
|
|
// wayland connection
|
|
*net.UnixConn
|
|
|
|
connErr error
|
|
sync.Once
|
|
// wait for wayland client to exit
|
|
done chan struct{}
|
|
}
|
|
|
|
func (wl *Wayland) Close() error {
|
|
wl.Do(func() {
|
|
close(wl.done)
|
|
wl.connErr = wl.UnixConn.Close()
|
|
})
|
|
|
|
return wl.connErr
|
|
}
|
|
|
|
func NewWayland() *Wayland {
|
|
wl := new(Wayland)
|
|
wl.done = make(chan struct{})
|
|
return wl
|
|
}
|