Compress motion notify events
This commit is contained in:
parent
19b744250f
commit
43696543d8
@ -101,7 +101,7 @@ func (backend *Backend) handleMotionNotify (
|
|||||||
connection *xgbutil.XUtil,
|
connection *xgbutil.XUtil,
|
||||||
event xevent.MotionNotifyEvent,
|
event xevent.MotionNotifyEvent,
|
||||||
) {
|
) {
|
||||||
motionEvent := *event.MotionNotifyEvent
|
motionEvent := backend.compressMotionNotify(*event.MotionNotifyEvent)
|
||||||
x, y := backend.cellAt (image.Point {
|
x, y := backend.cellAt (image.Point {
|
||||||
X: int(motionEvent.EventX),
|
X: int(motionEvent.EventX),
|
||||||
Y: int(motionEvent.EventY),
|
Y: int(motionEvent.EventY),
|
||||||
@ -132,3 +132,27 @@ func (backend *Backend) compressConfigureNotify (
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (backend *Backend) compressMotionNotify (
|
||||||
|
firstEvent xproto.MotionNotifyEvent,
|
||||||
|
) (
|
||||||
|
lastEvent xproto.MotionNotifyEvent,
|
||||||
|
) {
|
||||||
|
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.MotionNotifyEvent)
|
||||||
|
if !ok { continue }
|
||||||
|
|
||||||
|
lastEvent = typedEvent
|
||||||
|
defer func (index int) {
|
||||||
|
xevent.DequeueAt(backend.connection, index)
|
||||||
|
} (index)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user