mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 09:55:40 +00:00
app: ignore Invalidate for Windows not yet created
While here, don't overflow the Windows event queue. Fixes: https://todo.sr.ht/~eliasnaur/gio/596 Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -9,7 +9,6 @@ import (
|
||||
"errors"
|
||||
"unsafe"
|
||||
|
||||
"gioui.org/io/event"
|
||||
"gioui.org/io/pointer"
|
||||
)
|
||||
|
||||
@@ -57,35 +56,12 @@ func newWindow(window *callbacks, options []Option) {
|
||||
errFirst = err
|
||||
}
|
||||
}
|
||||
window.SetDriver(&dummyDriver{
|
||||
win: window,
|
||||
wakeups: make(chan event.Event, 1),
|
||||
})
|
||||
if errFirst == nil {
|
||||
errFirst = errors.New("app: no window driver available")
|
||||
}
|
||||
window.ProcessEvent(DestroyEvent{Err: errFirst})
|
||||
}
|
||||
|
||||
type dummyDriver struct {
|
||||
win *callbacks
|
||||
wakeups chan event.Event
|
||||
}
|
||||
|
||||
func (d *dummyDriver) Event() event.Event {
|
||||
if e, ok := d.win.nextEvent(); ok {
|
||||
return e
|
||||
}
|
||||
return <-d.wakeups
|
||||
}
|
||||
|
||||
func (d *dummyDriver) Invalidate() {
|
||||
select {
|
||||
case d.wakeups <- wakeupEvent{}:
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
// xCursor contains mapping from pointer.Cursor to XCursor.
|
||||
var xCursor = [...]string{
|
||||
pointer.CursorDefault: "left_ptr",
|
||||
|
||||
Reference in New Issue
Block a user