@@ -23,6 +23,16 @@ func newQueue() *queue {
23
23
}
24
24
}
25
25
26
+ func newInvalidateTrampoline (window * app.Window ) chan struct {} {
27
+ c := make (chan struct {}, 1 )
28
+ go func () {
29
+ for range c {
30
+ window .Invalidate ()
31
+ }
32
+ }()
33
+ return c
34
+ }
35
+
26
36
// Plugin is the main interface for the plugins.
27
37
type Plugin struct {
28
38
window * app.Window
@@ -34,8 +44,6 @@ type Plugin struct {
34
44
eventsCustomNext * queue
35
45
eventsCustomCurrent * queue
36
46
37
- eventsPool []event.Event
38
-
39
47
RedirectEvent map [reflect.Type ][]int
40
48
RedirectOp map [reflect.Type ][]int
41
49
RedirectCommands map [reflect.Type ][]int
@@ -47,6 +55,8 @@ type Plugin struct {
47
55
48
56
OriginalFrame func (ops * op.Ops )
49
57
OriginalSource input.Source
58
+
59
+ invalidator chan struct {}
50
60
}
51
61
52
62
// NewPlugin creates a new plugin.
@@ -60,6 +70,10 @@ func NewPlugin(w *app.Window) *Plugin {
60
70
RedirectEvent : make (map [reflect.Type ][]int , 128 ),
61
71
eventsCustomNext : newQueue (),
62
72
eventsCustomCurrent : newQueue (),
73
+
74
+ // That is required to prevent deadlock when sending events
75
+ // in the main-thread. Gio bug.
76
+ invalidator : newInvalidateTrampoline (w ),
63
77
}
64
78
65
79
for index , pf := range registeredPlugins {
@@ -102,7 +116,7 @@ func (l *Plugin) SendEvent(tag event.Tag, data event.Event) {
102
116
l .eventsCustomNext .taggedEvents [tag ] = append (l .eventsCustomNext .taggedEvents [tag ], data )
103
117
104
118
if ! l .Invalidated .Load () {
105
- l .window . Invalidate ()
119
+ l .invalidator <- struct {}{}
106
120
l .Invalidated .Store (true )
107
121
}
108
122
}
@@ -119,7 +133,7 @@ func (l *Plugin) SendEventUntagged(tag uint64, data event.Event) {
119
133
l .eventsCustomNext .untaggedEvents [tag ] = append (l .eventsCustomNext .untaggedEvents [tag ], data )
120
134
121
135
if ! l .Invalidated .Load () {
122
- l .window . Invalidate ()
136
+ l .invalidator <- struct {}{}
123
137
l .Invalidated .Store (true )
124
138
}
125
139
}
0 commit comments