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