Removed the need for a quit handler
This commit is contained in:
parent
e030f8632b
commit
cab280a371
@ -12,7 +12,7 @@ func (backend *Backend) Run () {
|
||||
backend.callbackManager.RunStart()
|
||||
backend.Draw()
|
||||
xevent.Main(backend.connection)
|
||||
backend.shutDown()
|
||||
backend.callbackManager.RunQuit()
|
||||
}
|
||||
|
||||
func (backend *Backend) handleConfigureNotify (
|
||||
@ -125,7 +125,3 @@ func (backend *Backend) compressConfigureNotify (
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (backend *Backend) shutDown () {
|
||||
backend.callbackManager.RunQuit()
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ func factory (
|
||||
// attatch graceful close handler
|
||||
backend.window.WMGracefulClose (func (window *xwindow.Window) {
|
||||
backend.window.Destroy()
|
||||
backend.shutDown()
|
||||
xevent.Quit(backend.connection)
|
||||
})
|
||||
|
||||
// attatch event handlers
|
||||
|
@ -10,7 +10,7 @@ import _ "git.tebibyte.media/sashakoshka/stone/backends/x"
|
||||
var application = &stone.Application { }
|
||||
|
||||
func main () {
|
||||
application.SetTitle("hellorld")
|
||||
application.SetTitle("color demo")
|
||||
application.SetSize(12, 7)
|
||||
|
||||
iconFile16, err := os.Open("assets/scaffold16.png")
|
||||
@ -26,21 +26,19 @@ func main () {
|
||||
|
||||
application.SetIcon([]image.Image { icon16, icon32 })
|
||||
|
||||
channel, err := application.Run()
|
||||
application.OnStart(onStart)
|
||||
application.OnResize(onResize)
|
||||
|
||||
err = application.Run()
|
||||
if err != nil { panic(err) }
|
||||
}
|
||||
|
||||
func onStart () {
|
||||
redraw()
|
||||
}
|
||||
|
||||
for {
|
||||
event := <- channel
|
||||
switch event.(type) {
|
||||
case stone.EventQuit:
|
||||
os.Exit(0)
|
||||
|
||||
case stone.EventResize:
|
||||
func onResize () {
|
||||
redraw()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func redraw () {
|
||||
@ -69,6 +67,4 @@ func redraw () {
|
||||
application.SetRune(x, height - 1, '=')
|
||||
application.SetColor(x, height - 1, stone.ColorRed)
|
||||
}
|
||||
|
||||
application.Draw()
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ func main () {
|
||||
application.OnPress(onPress)
|
||||
application.OnRelease(onRelease)
|
||||
application.OnMouseMove(onMouseMove)
|
||||
application.OnQuit(onQuit)
|
||||
|
||||
err = application.Run()
|
||||
if err != nil { panic(err) }
|
||||
@ -56,7 +55,3 @@ func onMouseMove (x, y int) { if mousePressed {
|
||||
application.Draw()
|
||||
}
|
||||
}
|
||||
|
||||
func onQuit () {
|
||||
os.Exit(0)
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import _ "git.tebibyte.media/sashakoshka/stone/backends/x"
|
||||
|
||||
var application = &stone.Application { }
|
||||
var currentTime = time.Time { }
|
||||
var tickPing = make(chan(struct { }))
|
||||
|
||||
func main () {
|
||||
application.SetTitle("hellorld")
|
||||
@ -29,27 +28,20 @@ func main () {
|
||||
|
||||
application.SetIcon([]image.Image { icon16, icon32 })
|
||||
|
||||
channel, err := application.Run()
|
||||
if err != nil { panic(err) }
|
||||
application.OnStart(onStart)
|
||||
application.OnResize(onResize)
|
||||
|
||||
err = application.Run()
|
||||
if err != nil { panic(err) }
|
||||
}
|
||||
|
||||
func onStart () {
|
||||
redraw()
|
||||
go tick()
|
||||
}
|
||||
|
||||
for {
|
||||
select {
|
||||
case <- tickPing:
|
||||
func onResize () {
|
||||
redraw()
|
||||
|
||||
case event := <- channel:
|
||||
switch event.(type) {
|
||||
case stone.EventQuit:
|
||||
os.Exit(0)
|
||||
|
||||
case stone.EventResize:
|
||||
redraw()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func redraw () {
|
||||
@ -70,13 +62,12 @@ func redraw () {
|
||||
application.SetRune(5, 1, ':')
|
||||
application.SetRune(6, 1, rune(second / 10 + 48))
|
||||
application.SetRune(7, 1, rune(second % 10 + 48))
|
||||
|
||||
application.Draw()
|
||||
}
|
||||
|
||||
func tick () {
|
||||
for {
|
||||
tickPing <- struct { } { }
|
||||
redraw()
|
||||
application.Draw()
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user