Sus. Sus amongus.
amoogoos.
This commit is contained in:
parent
a68790d342
commit
636e5ce7e7
@ -161,6 +161,21 @@ func (backend *Backend) handleButtonRelease (
|
|||||||
backend.channel <- stone.EventRelease(buttonEvent.Detail)
|
backend.channel <- stone.EventRelease(buttonEvent.Detail)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (backend *Backend) handleMotionNotify (
|
||||||
|
connection *xgbutil.XUtil,
|
||||||
|
event xevent.MotionNotifyEvent,
|
||||||
|
) {
|
||||||
|
motionEvent := *event.MotionNotifyEvent
|
||||||
|
x, y := backend.cellAt (image.Point {
|
||||||
|
X: int(motionEvent.EventX),
|
||||||
|
Y: int(motionEvent.EventY),
|
||||||
|
})
|
||||||
|
backend.channel <- stone.EventMouseMove {
|
||||||
|
X: x,
|
||||||
|
Y: y,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (backend *Backend) compressConfigureNotify (
|
func (backend *Backend) compressConfigureNotify (
|
||||||
firstEvent xproto.ConfigureNotifyEvent,
|
firstEvent xproto.ConfigureNotifyEvent,
|
||||||
) (
|
) (
|
||||||
@ -292,6 +307,12 @@ func (backend *Backend) drawRune (x, y int, character rune) {
|
|||||||
draw.Over)
|
draw.Over)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (backend *Backend) cellAt (onScreen image.Point) (x, y int) {
|
||||||
|
x = (onScreen.X - backend.metrics.paddingX) / backend.metrics.cellWidth
|
||||||
|
y = (onScreen.Y - backend.metrics.paddingY) / backend.metrics.cellHeight
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (backend *Backend) cellSubImage (x, y int) (cell *xgraphics.Image) {
|
func (backend *Backend) cellSubImage (x, y int) (cell *xgraphics.Image) {
|
||||||
cell = backend.canvas.SubImage(backend.boundsOfCell(x, y)).(*xgraphics.Image)
|
cell = backend.canvas.SubImage(backend.boundsOfCell(x, y)).(*xgraphics.Image)
|
||||||
return
|
return
|
||||||
@ -375,7 +396,7 @@ func factory (application *stone.Application) (output stone.Backend, err error)
|
|||||||
// keyboard buttons (uncompressed)
|
// keyboard buttons (uncompressed)
|
||||||
err = backend.window.Listen (
|
err = backend.window.Listen (
|
||||||
xproto.EventMaskStructureNotify,
|
xproto.EventMaskStructureNotify,
|
||||||
// xproto.EventMaskPointerMotion,
|
xproto.EventMaskPointerMotion,
|
||||||
// xproto.EventMaskKeyPress,
|
// xproto.EventMaskKeyPress,
|
||||||
// xproto.EventMaskKeyRelease,
|
// xproto.EventMaskKeyRelease,
|
||||||
xproto.EventMaskButtonPress,
|
xproto.EventMaskButtonPress,
|
||||||
@ -400,6 +421,8 @@ func factory (application *stone.Application) (output stone.Backend, err error)
|
|||||||
Connect(backend.connection, backend.window.Id)
|
Connect(backend.connection, backend.window.Id)
|
||||||
xevent.ButtonReleaseFun(backend.handleButtonRelease).
|
xevent.ButtonReleaseFun(backend.handleButtonRelease).
|
||||||
Connect(backend.connection, backend.window.Id)
|
Connect(backend.connection, backend.window.Id)
|
||||||
|
xevent.MotionNotifyFun(backend.handleMotionNotify).
|
||||||
|
Connect(backend.connection, backend.window.Id)
|
||||||
|
|
||||||
output = backend
|
output = backend
|
||||||
return
|
return
|
||||||
|
@ -55,8 +55,10 @@ func main () {
|
|||||||
|
|
||||||
case stone.EventMouseMove:
|
case stone.EventMouseMove:
|
||||||
event := event.(stone.EventMouseMove)
|
event := event.(stone.EventMouseMove)
|
||||||
application.SetRune(event.X, event.Y, '#')
|
if mousePressed {
|
||||||
application.Draw()
|
application.SetRune(event.X, event.Y, '#')
|
||||||
|
application.Draw()
|
||||||
|
}
|
||||||
|
|
||||||
case stone.EventResize:
|
case stone.EventResize:
|
||||||
application.Draw()
|
application.Draw()
|
||||||
|
Loading…
Reference in New Issue
Block a user