aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/shim/wayland.go
blob: 05f04278fefadfd8a8b9da0551991c2e48da10b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
}