diff options
| author | Ophestra Umiker <cat@ophivana.moe> | 2024-10-20 22:54:47 +0900 |
|---|---|---|
| committer | Ophestra Umiker <cat@ophivana.moe> | 2024-10-21 18:46:06 +0900 |
| commit | 380d1f45851b7dffb963c51da96a17ba41f3cfb8 (patch) | |
| tree | 984c9b50d890157847e3f3bc942659e6431c03a9 /internal/shim/wayland.go | |
| parent | 133f23e0de77dc32de2753b23ed8173344a0e699 (diff) | |
app: move wayland mediation to shim package
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>
Diffstat (limited to 'internal/shim/wayland.go')
| -rw-r--r-- | internal/shim/wayland.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/internal/shim/wayland.go b/internal/shim/wayland.go new file mode 100644 index 00000000..05f04278 --- /dev/null +++ b/internal/shim/wayland.go @@ -0,0 +1,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 +} |
