aboutsummaryrefslogtreecommitdiff
path: root/xA/xA.go
diff options
context:
space:
mode:
Diffstat (limited to 'xA/xA.go')
-rw-r--r--xA/xA.go48
1 files changed, 33 insertions, 15 deletions
diff --git a/xA/xA.go b/xA/xA.go
index 17a0400..b4f796c 100644
--- a/xA/xA.go
+++ b/xA/xA.go
@@ -1,4 +1,4 @@
-// Copyright (c) 2024, Přemysl Eric Janouch <p@janouch.name>
+// Copyright (c) 2024 - 2025, Přemysl Eric Janouch <p@janouch.name>
// SPDX-License-Identifier: 0BSD
package main
@@ -122,6 +122,10 @@ func (t *customTheme) Color(
variant = theme.VariantDark
}
*/
+ /*
+ // Fyne 2.6.0 has a different bug, the Light variant is not applied:
+ variant = theme.VariantLight
+ */
// Fuck this low contrast shit, text must be black.
if name == theme.ColorNameForeground &&
@@ -281,7 +285,11 @@ func beep() {
}
go func() {
<-otoReady
- otoContext.NewPlayer(bytes.NewReader(beepSample)).Play()
+ p := otoContext.NewPlayer(bytes.NewReader(beepSample))
+ p.Play()
+ for p.IsPlaying() {
+ time.Sleep(time.Second)
+ }
}()
}
@@ -329,9 +337,14 @@ func relaySend(data RelayCommandData, callback callback) bool {
CommandSeq: commandSeq,
Data: data,
}
- if callback != nil {
- commandCallbacks[m.CommandSeq] = callback
+ if callback == nil {
+ callback = func(err string, response *RelayResponseData) {
+ if response == nil {
+ showErrorMessage(err)
+ }
+ }
}
+ commandCallbacks[m.CommandSeq] = callback
commandSeq++
// TODO(p): Handle errors better.
@@ -398,10 +411,7 @@ func refreshIcon() {
break
}
}
-
- // Prevent deadlocks (though it might have a race condition).
- // https://github.com/fyne-io/fyne/issues/5266
- go func() { wWindow.SetIcon(resource) }()
+ wWindow.SetIcon(resource)
}
func refreshTopic(topic []bufferLineItem) {
@@ -1090,7 +1100,10 @@ func relayRun() {
fyne.CurrentApp().Preferences().SetString(preferenceAddress, backendAddress)
backendLock.Lock()
- relayResetState()
+ fyne.DoAndWait(func() {
+ relayResetState()
+ })
+
backendContext, backendCancel = context.WithCancel(context.Background())
defer backendCancel()
var err error
@@ -1098,8 +1111,10 @@ func relayRun() {
backendLock.Unlock()
if err != nil {
- wConnect.Show()
- showErrorMessage("Connection failed: " + err.Error())
+ fyne.DoAndWait(func() {
+ wConnect.Show()
+ showErrorMessage("Connection failed: " + err.Error())
+ })
return
}
defer backendConn.Close()
@@ -1119,12 +1134,15 @@ Loop:
if !ok {
break Loop
}
- relayProcessMessage(&m)
+ fyne.DoAndWait(func() {
+ relayProcessMessage(&m)
+ })
}
}
-
- wConnect.Show()
- showErrorMessage("Disconnected")
+ fyne.DoAndWait(func() {
+ wConnect.Show()
+ showErrorMessage("Disconnected")
+ })
}
// --- Input line --------------------------------------------------------------