mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 17:35:36 +00:00
apps: remove use of app.Window.IsAlive
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -185,7 +185,7 @@ func (a *App) run() error {
|
|||||||
a.w.Profiling = *stats
|
a.w.Profiling = *stats
|
||||||
ops := new(ui.Ops)
|
ops := new(ui.Ops)
|
||||||
var lastMallocs uint64
|
var lastMallocs uint64
|
||||||
for a.w.IsAlive() {
|
for {
|
||||||
select {
|
select {
|
||||||
case users := <-a.updateUsers:
|
case users := <-a.updateUsers:
|
||||||
a.users = users
|
a.users = users
|
||||||
@@ -219,6 +219,9 @@ func (a *App) run() error {
|
|||||||
a.ctxCancel = nil
|
a.ctxCancel = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if e.Stage == app.StageDead {
|
||||||
|
return a.w.Err()
|
||||||
|
}
|
||||||
case *app.CommandEvent:
|
case *app.CommandEvent:
|
||||||
switch e.Type {
|
switch e.Type {
|
||||||
case app.CommandBack:
|
case app.CommandBack:
|
||||||
@@ -253,7 +256,6 @@ func (a *App) run() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return a.w.Err()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func newApp(w *app.Window) *App {
|
func newApp(w *app.Window) *App {
|
||||||
|
|||||||
+11
-6
@@ -32,12 +32,16 @@ func main() {
|
|||||||
func init() {
|
func init() {
|
||||||
go func() {
|
go func() {
|
||||||
for w := range app.Windows() {
|
for w := range app.Windows() {
|
||||||
go loop(w)
|
go func() {
|
||||||
|
if err := loop(w); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func loop(w *app.Window) {
|
func loop(w *app.Window) error {
|
||||||
regular, err := sfnt.Parse(goregular.TTF)
|
regular, err := sfnt.Parse(goregular.TTF)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("failed to load font")
|
panic("failed to load font")
|
||||||
@@ -48,9 +52,13 @@ func loop(w *app.Window) {
|
|||||||
face := faces.For(regular, ui.Sp(72))
|
face := faces.For(regular, ui.Sp(72))
|
||||||
message := "Hello, Gio"
|
message := "Hello, Gio"
|
||||||
ops := new(ui.Ops)
|
ops := new(ui.Ops)
|
||||||
for w.IsAlive() {
|
for {
|
||||||
e := <-w.Events()
|
e := <-w.Events()
|
||||||
switch e := e.(type) {
|
switch e := e.(type) {
|
||||||
|
case app.StageEvent:
|
||||||
|
if e.Stage == app.StageDead {
|
||||||
|
return w.Err()
|
||||||
|
}
|
||||||
case app.DrawEvent:
|
case app.DrawEvent:
|
||||||
cfg = e.Config
|
cfg = e.Config
|
||||||
cs := layout.ExactConstraints(w.Size())
|
cs := layout.ExactConstraints(w.Size())
|
||||||
@@ -63,7 +71,4 @@ func loop(w *app.Window) {
|
|||||||
faces.Frame()
|
faces.Frame()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := w.Err(); err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user