mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-31 23:11:28 +01:00
don't use app.Emit(), instead dispatch to individual windows for synchronous event dispatch
This commit is contained in:
parent
eab6afb91a
commit
8573a415c0
@ -63,6 +63,18 @@ func emitEventToWindow(event WindowEvent) {
|
||||
}
|
||||
}
|
||||
|
||||
func emitEventToAllWindows(event *application.WailsEvent) {
|
||||
globalLock.Lock()
|
||||
wins := make([]*application.WebviewWindow, 0, len(wailsWindowMap))
|
||||
for _, window := range wailsWindowMap {
|
||||
wins = append(wins, window)
|
||||
}
|
||||
globalLock.Unlock()
|
||||
for _, window := range wins {
|
||||
window.DispatchWailsEvent(event)
|
||||
}
|
||||
}
|
||||
|
||||
func SendEvent(event application.WailsEvent) {
|
||||
EventCh <- event
|
||||
}
|
||||
@ -107,10 +119,7 @@ func processEvents() {
|
||||
for {
|
||||
select {
|
||||
case event := <-EventCh:
|
||||
// no lock needed for wailsApp since it is never updated
|
||||
if wailsApp != nil {
|
||||
wailsApp.Events.Emit(&event)
|
||||
}
|
||||
emitEventToAllWindows(&event)
|
||||
case windowEvent := <-WindowEventCh:
|
||||
emitEventToWindow(windowEvent)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user