mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 09:55:40 +00:00
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.
|
// More than one Window is not supported on iOS, Android, WebAssembly.
|
||||||
type Window struct {
|
type Window struct {
|
||||||
initialOpts []Option
|
initialOpts []Option
|
||||||
|
initialActions []system.Action
|
||||||
|
|
||||||
ctx context
|
ctx context
|
||||||
gpu gpu.GPU
|
gpu gpu.GPU
|
||||||
@@ -727,6 +728,10 @@ func (w *Window) init() {
|
|||||||
w.imeState.compose = key.Range{Start: -1, End: -1}
|
w.imeState.compose = key.Range{Start: -1, End: -1}
|
||||||
w.semantic.ids = make(map[input.SemanticID]input.SemanticNode)
|
w.semantic.ids = make(map[input.SemanticID]input.SemanticNode)
|
||||||
newWindow(&callbacks{w}, options)
|
newWindow(&callbacks{w}, options)
|
||||||
|
for _, acts := range w.initialActions {
|
||||||
|
w.Perform(acts)
|
||||||
|
}
|
||||||
|
w.initialActions = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) updateCursor() {
|
func (w *Window) updateCursor() {
|
||||||
@@ -826,6 +831,10 @@ func (w *Window) Perform(actions system.Action) {
|
|||||||
if acts == 0 {
|
if acts == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if w.basic == nil {
|
||||||
|
w.initialActions = append(w.initialActions, acts)
|
||||||
|
return
|
||||||
|
}
|
||||||
w.Run(func() {
|
w.Run(func() {
|
||||||
w.driver.Perform(actions)
|
w.driver.Perform(actions)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user