1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-30 16:32:50 -05:00

clipboard: move cl receive to main wlcontext goroutine

This commit is contained in:
bbedward
2025-12-13 00:16:34 -05:00
parent 119e084e52
commit 7641171a01
2 changed files with 39 additions and 17 deletions

View File

@@ -497,7 +497,13 @@ func (m *Manager) receiveData(offer *ext_data_control.ExtDataControlOfferV1, mim
} }
defer r.Close() defer r.Close()
if err := offer.Receive(mimeType, int(w.Fd())); err != nil { receiveErr := make(chan error, 1)
m.post(func() {
err := offer.Receive(mimeType, int(w.Fd()))
receiveErr <- err
})
if err := <-receiveErr; err != nil {
w.Close() w.Close()
return nil, err return nil, err
} }
@@ -516,7 +522,7 @@ func (m *Manager) receiveData(offer *ext_data_control.ExtDataControlOfferV1, mim
select { select {
case res := <-done: case res := <-done:
return res.data, res.err return res.data, res.err
case <-time.After(100 * time.Millisecond): case <-time.After(500 * time.Millisecond):
return nil, fmt.Errorf("timeout reading clipboard data") return nil, fmt.Errorf("timeout reading clipboard data")
} }
} }

View File

@@ -125,21 +125,47 @@ func (m *Manager) ApplyConfiguration(heads []HeadConfig, test bool) error {
return return
} }
statusChan := make(chan error, 1) responded := false
config.SetSucceededHandler(func(e wlr_output_management.ZwlrOutputConfigurationV1SucceededEvent) { config.SetSucceededHandler(func(e wlr_output_management.ZwlrOutputConfigurationV1SucceededEvent) {
if responded {
return
}
responded = true
log.Info("WlrOutput: configuration succeeded") log.Info("WlrOutput: configuration succeeded")
statusChan <- nil config.Destroy()
resultChan <- nil
}) })
config.SetFailedHandler(func(e wlr_output_management.ZwlrOutputConfigurationV1FailedEvent) { config.SetFailedHandler(func(e wlr_output_management.ZwlrOutputConfigurationV1FailedEvent) {
if responded {
return
}
responded = true
log.Warn("WlrOutput: configuration failed") log.Warn("WlrOutput: configuration failed")
statusChan <- fmt.Errorf("compositor rejected configuration") config.Destroy()
resultChan <- fmt.Errorf("compositor rejected configuration")
}) })
config.SetCancelledHandler(func(e wlr_output_management.ZwlrOutputConfigurationV1CancelledEvent) { config.SetCancelledHandler(func(e wlr_output_management.ZwlrOutputConfigurationV1CancelledEvent) {
if responded {
return
}
responded = true
log.Warn("WlrOutput: configuration cancelled") log.Warn("WlrOutput: configuration cancelled")
statusChan <- fmt.Errorf("configuration cancelled (outdated serial)") config.Destroy()
resultChan <- fmt.Errorf("configuration cancelled (outdated serial)")
})
time.AfterFunc(time.Second, func() {
m.post(func() {
if responded {
return
}
responded = true
config.Destroy()
resultChan <- fmt.Errorf("timeout waiting for configuration response")
})
}) })
headsByName := make(map[string]*headState) headsByName := make(map[string]*headState)
@@ -241,6 +267,7 @@ func (m *Manager) ApplyConfiguration(heads []HeadConfig, test bool) error {
} }
if applyErr != nil { if applyErr != nil {
responded = true
config.Destroy() config.Destroy()
action := "apply" action := "apply"
if test { if test {
@@ -249,17 +276,6 @@ func (m *Manager) ApplyConfiguration(heads []HeadConfig, test bool) error {
resultChan <- fmt.Errorf("failed to %s configuration: %w", action, applyErr) resultChan <- fmt.Errorf("failed to %s configuration: %w", action, applyErr)
return return
} }
go func() {
select {
case err := <-statusChan:
config.Destroy()
resultChan <- err
case <-time.After(5 * time.Second):
config.Destroy()
resultChan <- fmt.Errorf("timeout waiting for configuration response")
}
}()
}) })
return <-resultChan return <-resultChan