mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-15 18:22:08 -04:00
core/wayland: thread-safety meta fixes + cleanups + hypr workaround
- fork go-wayland/client and modify to make it thread-safe internally - use sync.Map and atomic values in many places to cut down on mutex boilerplate - do not create extworkspace client unless explicitly requested
This commit is contained in:
37
core/pkg/go-wayland/wayland/client/display.go
Normal file
37
core/pkg/go-wayland/wayland/client/display.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
)
|
||||
|
||||
// Roundtrip blocks until all pending request are processed by the server.
|
||||
// It is the implementation of [wl_display_roundtrip].
|
||||
//
|
||||
// [wl_display_roundtrip]: https://wayland.freedesktop.org/docs/html/apb.html#Client-classwl__display_1ab60f38c2f80980ac84f347e932793390
|
||||
func (i *Display) Roundtrip() error {
|
||||
callback, err := i.Sync()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to get sync callback: %w", err)
|
||||
}
|
||||
defer func() {
|
||||
if err2 := callback.Destroy(); err2 != nil {
|
||||
log.Printf("unable to destroy callback: %v\n", err2)
|
||||
}
|
||||
}()
|
||||
|
||||
done := false
|
||||
callback.SetDoneHandler(func(_ CallbackDoneEvent) {
|
||||
done = true
|
||||
})
|
||||
|
||||
// Wait for callback to return
|
||||
for !done {
|
||||
err := i.Context().GetDispatch()()
|
||||
if err != nil {
|
||||
return fmt.Errorf("roundtrip: failed to dispatch: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user