forked from joejulian/gio
app: queue system actions before first call to Event()
This commit ensures that attempting to perform a system window action prior to the first call to Event() does not panic. It adopts a similar strategy to handling Option() prior to the first call to Event(): make a slice of the arguments and apply them during window initialization. Fixes: https://todo.sr.ht/~eliasnaur/gio/593 Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
+10
-1
@@ -41,7 +41,8 @@ type Option func(unit.Metric, *Config)
|
||||
//
|
||||
// More than one Window is not supported on iOS, Android, WebAssembly.
|
||||
type Window struct {
|
||||
initialOpts []Option
|
||||
initialOpts []Option
|
||||
initialActions []system.Action
|
||||
|
||||
ctx context
|
||||
gpu gpu.GPU
|
||||
@@ -727,6 +728,10 @@ func (w *Window) init() {
|
||||
w.imeState.compose = key.Range{Start: -1, End: -1}
|
||||
w.semantic.ids = make(map[input.SemanticID]input.SemanticNode)
|
||||
newWindow(&callbacks{w}, options)
|
||||
for _, acts := range w.initialActions {
|
||||
w.Perform(acts)
|
||||
}
|
||||
w.initialActions = nil
|
||||
}
|
||||
|
||||
func (w *Window) updateCursor() {
|
||||
@@ -826,6 +831,10 @@ func (w *Window) Perform(actions system.Action) {
|
||||
if acts == 0 {
|
||||
return
|
||||
}
|
||||
if w.basic == nil {
|
||||
w.initialActions = append(w.initialActions, acts)
|
||||
return
|
||||
}
|
||||
w.Run(func() {
|
||||
w.driver.Perform(actions)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user