x-backend #2
@ -1,7 +1,6 @@
|
||||
package x
|
||||
|
||||
import "image"
|
||||
import "image/color"
|
||||
// import "golang.org/x/image/font"
|
||||
// import "golang.org/x/image/font/basicfont"
|
||||
|
||||
@ -91,11 +90,52 @@ func (backend *Backend) handleXEvent (event xgb.Event) {
|
||||
backend.metrics.windowHeight = newHeight
|
||||
|
||||
if sizeChanged {
|
||||
// TODO: resize and rebind canvas
|
||||
// compress events
|
||||
configureEvent =
|
||||
backend.compressConfigureNotify(configureEvent)
|
||||
|
||||
// resize and rebind canvas
|
||||
backend.canvas.Destroy()
|
||||
backend.canvas = xgraphics.New (
|
||||
backend.connection,
|
||||
image.Rect (
|
||||
0, 0,
|
||||
backend.metrics.windowWidth,
|
||||
backend.metrics.windowHeight))
|
||||
// FIXME (?): this doesn't work. if it were to work, it
|
||||
// would possibly be a cleaner way to resize the canvas.
|
||||
// backend.canvas.Scale (
|
||||
// backend.metrics.windowWidth,
|
||||
// backend.metrics.windowHeight)
|
||||
backend.bindCanvas()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (backend *Backend) compressConfigureNotify (
|
||||
firstEvent xproto.ConfigureNotifyEvent,
|
||||
) (
|
||||
lastEvent xproto.ConfigureNotifyEvent,
|
||||
) {
|
||||
backend.connection.Sync()
|
||||
xevent.Read(backend.connection, false)
|
||||
lastEvent = firstEvent
|
||||
|
||||
for index, untypedEvent := range xevent.Peek(backend.connection) {
|
||||
if untypedEvent.Err != nil { continue }
|
||||
|
||||
typedEvent, ok := untypedEvent.Event.(xproto.ConfigureNotifyEvent)
|
||||
if !ok { continue }
|
||||
|
||||
lastEvent = typedEvent
|
||||
defer func (index int) {
|
||||
xevent.DequeueAt(backend.connection, index)
|
||||
} (index)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (backend *Backend) shutDown () {
|
||||
backend.channel <- stone.EventQuit { }
|
||||
}
|
||||
@ -160,10 +200,6 @@ func factory (application *stone.Application) (output stone.Backend, err error)
|
||||
0, 0,
|
||||
backend.metrics.windowWidth,
|
||||
backend.metrics.windowHeight))
|
||||
|
||||
for i := 8; i < 64; i ++ {
|
||||
backend.canvas.Set(8, i, color.RGBA { R: 0xFF, A: 0xFF })
|
||||
}
|
||||
backend.bindCanvas()
|
||||
|
||||
// attatch graceful close handler
|
||||
|
Loading…
Reference in New Issue
Block a user