fix(wayland): allow bufferless commits before get_layer_surface
- commit
- 2f7d458d13c281540533ed405bdc989a02feac97
- author
- brice · · 2026-09-23 16:22 UTC
- parent
- c2ef3a9
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
3 files · +2 -8
M internal/adapters/wayland/layer.go +1 -1
| @@ -42,7 +42,7 @@ func (h layerShell) GetLayerSurface(r *wlrlayershell.ZwlrLayerShellV1, id uint32 | |||
| 42 | 42 | return | |
| 43 | 43 | } | |
| 44 | 44 | state := h.server.surfaces[w.Resource] | |
| 45 | - | if state.kind != roleNone || state.attached || state.current != nil || state.committed { | |
| 45 | + | if state.kind != roleNone || (state.attached && state.pending != nil) || state.current != nil { | |
| 46 | 46 | r.PostError(uint32(wlrlayershell.ZwlrLayerShellV1ErrorAlreadyConstructed), "surface already constructed") | |
| 47 | 47 | return | |
| 48 | 48 | } | |
| @@ -42,7 +42,7 @@ func (h layerShell) GetLayerSurface(r *wlrlayershell.ZwlrLayerShellV1, id uint32 | |||||
| 42 | return | 42 | return | ||
| 43 | } | 43 | } | ||
| 44 | state := h.server.surfaces[w.Resource] | 44 | state := h.server.surfaces[w.Resource] | ||
| 45 | - | if state.kind != roleNone || state.attached || state.current != nil || state.committed { | 45 | + | if state.kind != roleNone || (state.attached && state.pending != nil) || state.current != nil { |
| 46 | r.PostError(uint32(wlrlayershell.ZwlrLayerShellV1ErrorAlreadyConstructed), "surface already constructed") | 46 | r.PostError(uint32(wlrlayershell.ZwlrLayerShellV1ErrorAlreadyConstructed), "surface already constructed") | ||
| 47 | return | 47 | return | ||
| 48 | } | 48 | } | ||
M internal/adapters/wayland/layer_test.go +1 -5
| @@ -143,7 +143,7 @@ func TestWaybarLayer(t *testing.T) { | |||
| 143 | 143 | } | |
| 144 | 144 | ||
| 145 | 145 | func TestLayerAlreadyConstructed(t *testing.T) { | |
| 146 | - | for _, scenario := range []string{"role", "attached", "committed"} { | |
| 146 | + | for _, scenario := range []string{"role"} { | |
| 147 | 147 | t.Run(scenario, func(t *testing.T) { | |
| 148 | 148 | s, _, _, dir := lifecycleServer(t) | |
| 149 | 149 | c := protocolClient(t, s, dir) | |
| @@ -160,10 +160,6 @@ func TestLayerAlreadyConstructed(t *testing.T) { | |||
| 160 | 160 | registerProtocol(t, c, parent) | |
| 161 | 161 | id := c.AllocateID() | |
| 162 | 162 | requestProtocol(t, c, sub, wayland.SubcompositorRequestGetSubsurface, id, surf, parent) | |
| 163 | - | case "attached": | |
| 164 | - | requestProtocol(t, c, surf, wayland.SurfaceRequestAttach, uint32(0), int32(0), int32(0)) | |
| 165 | - | case "committed": | |
| 166 | - | requestProtocol(t, c, surf, wayland.SurfaceRequestCommit) | |
| 167 | 163 | } | |
| 168 | 164 | id := c.AllocateID() | |
| 169 | 165 | requestProtocol(t, c, shell, wlrlayershell.ZwlrLayerShellV1RequestGetLayerSurface, id, surf, uint32(0), uint32(ports.LayerTop), "test") | |
| @@ -143,7 +143,7 @@ func TestWaybarLayer(t *testing.T) { | |||||
| 143 | } | 143 | } | ||
| 144 | 144 | ||||
| 145 | func TestLayerAlreadyConstructed(t *testing.T) { | 145 | func TestLayerAlreadyConstructed(t *testing.T) { | ||
| 146 | - | for _, scenario := range []string{"role", "attached", "committed"} { | 146 | + | for _, scenario := range []string{"role"} { |
| 147 | t.Run(scenario, func(t *testing.T) { | 147 | t.Run(scenario, func(t *testing.T) { | ||
| 148 | s, _, _, dir := lifecycleServer(t) | 148 | s, _, _, dir := lifecycleServer(t) | ||
| 149 | c := protocolClient(t, s, dir) | 149 | c := protocolClient(t, s, dir) | ||
| @@ -160,10 +160,6 @@ func TestLayerAlreadyConstructed(t *testing.T) { | |||||
| 160 | registerProtocol(t, c, parent) | 160 | registerProtocol(t, c, parent) | ||
| 161 | id := c.AllocateID() | 161 | id := c.AllocateID() | ||
| 162 | requestProtocol(t, c, sub, wayland.SubcompositorRequestGetSubsurface, id, surf, parent) | 162 | requestProtocol(t, c, sub, wayland.SubcompositorRequestGetSubsurface, id, surf, parent) | ||
| 163 | - | case "attached": | |||
| 164 | - | requestProtocol(t, c, surf, wayland.SurfaceRequestAttach, uint32(0), int32(0), int32(0)) | |||
| 165 | - | case "committed": | |||
| 166 | - | requestProtocol(t, c, surf, wayland.SurfaceRequestCommit) | |||
| 167 | } | 163 | } | ||
| 168 | id := c.AllocateID() | 164 | id := c.AllocateID() | ||
| 169 | requestProtocol(t, c, shell, wlrlayershell.ZwlrLayerShellV1RequestGetLayerSurface, id, surf, uint32(0), uint32(ports.LayerTop), "test") | 165 | requestProtocol(t, c, shell, wlrlayershell.ZwlrLayerShellV1RequestGetLayerSurface, id, surf, uint32(0), uint32(ports.LayerTop), "test") | ||
M internal/adapters/wayland/surface.go +0 -2
| @@ -23,7 +23,6 @@ type surface struct { | |||
| 23 | 23 | server *Server | |
| 24 | 24 | current, pending *wayland.Buffer | |
| 25 | 25 | attached bool | |
| 26 | - | committed bool | |
| 27 | 26 | callbacks []*wayland.Callback | |
| 28 | 27 | role func(bool) | |
| 29 | 28 | destroyed bool | |
| @@ -52,7 +51,6 @@ func (s *surface) Frame(r *wayland.Surface, id uint32) { | |||
| 52 | 51 | } | |
| 53 | 52 | } | |
| 54 | 53 | func (s *surface) Commit(*wayland.Surface) { | |
| 55 | - | s.committed = true | |
| 56 | 54 | fresh := s.attached && s.pending != nil | |
| 57 | 55 | if s.layer != nil && s.attached && s.pending != nil && !s.layer.acked { | |
| 58 | 56 | s.layer.resource.PostError(uint32(wlrlayershell.ZwlrLayerSurfaceV1ErrorInvalidSurfaceState), "buffer before configure ack") | |
| @@ -23,7 +23,6 @@ type surface struct { | |||||
| 23 | server *Server | 23 | server *Server | ||
| 24 | current, pending *wayland.Buffer | 24 | current, pending *wayland.Buffer | ||
| 25 | attached bool | 25 | attached bool | ||
| 26 | - | committed bool | |||
| 27 | callbacks []*wayland.Callback | 26 | callbacks []*wayland.Callback | ||
| 28 | role func(bool) | 27 | role func(bool) | ||
| 29 | destroyed bool | 28 | destroyed bool | ||
| @@ -52,7 +51,6 @@ func (s *surface) Frame(r *wayland.Surface, id uint32) { | |||||
| 52 | } | 51 | } | ||
| 53 | } | 52 | } | ||
| 54 | func (s *surface) Commit(*wayland.Surface) { | 53 | func (s *surface) Commit(*wayland.Surface) { | ||
| 55 | - | s.committed = true | |||
| 56 | fresh := s.attached && s.pending != nil | 54 | fresh := s.attached && s.pending != nil | ||
| 57 | if s.layer != nil && s.attached && s.pending != nil && !s.layer.acked { | 55 | if s.layer != nil && s.attached && s.pending != nil && !s.layer.acked { | ||
| 58 | s.layer.resource.PostError(uint32(wlrlayershell.ZwlrLayerSurfaceV1ErrorInvalidSurfaceState), "buffer before configure ack") | 56 | s.layer.resource.PostError(uint32(wlrlayershell.ZwlrLayerSurfaceV1ErrorInvalidSurfaceState), "buffer before configure ack") | ||