1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-29 07:52:50 -05:00

core/wlcontext: use infinite poll timeout

This commit is contained in:
bbedward
2026-01-12 11:26:35 -05:00
parent 4e2ce82c0a
commit 2bbe9a0c45

View File

@@ -124,27 +124,23 @@ func (sc *SharedContext) eventDispatcher() {
} }
for { for {
sc.drainCmdQueue()
select { select {
case <-sc.stopChan: case <-sc.stopChan:
return return
default: default:
} }
sc.drainCmdQueue() _, err := unix.Poll(pollFds, -1)
switch {
n, err := unix.Poll(pollFds, 50) case err == unix.EINTR:
if err != nil { continue
if err == unix.EINTR { case err != nil:
continue
}
log.Errorf("Poll error: %v", err) log.Errorf("Poll error: %v", err)
return return
} }
if n == 0 {
continue
}
if pollFds[1].Revents&unix.POLLIN != 0 { if pollFds[1].Revents&unix.POLLIN != 0 {
var buf [64]byte var buf [64]byte
if _, err := unix.Read(sc.wakeR, buf[:]); err != nil && err != unix.EAGAIN { if _, err := unix.Read(sc.wakeR, buf[:]); err != nil && err != unix.EAGAIN {
@@ -152,13 +148,13 @@ func (sc *SharedContext) eventDispatcher() {
} }
} }
if pollFds[0].Revents&unix.POLLIN != 0 { if pollFds[0].Revents&unix.POLLIN == 0 {
if err := ctx.Dispatch(); err != nil { continue
if !os.IsTimeout(err) { }
log.Errorf("Wayland connection error: %v", err)
return if err := ctx.Dispatch(); err != nil && !os.IsTimeout(err) {
} log.Errorf("Wayland connection error: %v", err)
} return
} }
} }
} }
@@ -176,12 +172,16 @@ func (sc *SharedContext) drainCmdQueue() {
func (sc *SharedContext) Close() { func (sc *SharedContext) Close() {
close(sc.stopChan) close(sc.stopChan)
if _, err := unix.Write(sc.wakeW, []byte{1}); err != nil && err != unix.EAGAIN {
log.Errorf("wake pipe write error on close: %v", err)
}
sc.wg.Wait() sc.wg.Wait()
unix.Close(sc.wakeR) unix.Close(sc.wakeR)
unix.Close(sc.wakeW) unix.Close(sc.wakeW)
if sc.display != nil { if sc.display == nil {
sc.display.Context().Close() return
} }
sc.display.Context().Close()
} }