Combine scroll and scroll finish commands
This commit is contained in:
parent
1f3aa58568
commit
ad3847f5aa
6 changed files with 19 additions and 32 deletions
|
|
@ -76,6 +76,5 @@ type Backend interface {
|
|||
KeyboardKey(key Key) error
|
||||
PointerButton(button PointerButton, press bool) error
|
||||
PointerMove(deltaX, deltaY int) error
|
||||
PointerScroll(deltaHorizontal, deltaVertical int) error
|
||||
PointerScrollFinish() error
|
||||
PointerScroll(deltaHorizontal, deltaVertical int, finish bool) error
|
||||
}
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ func (p *portalBackend) PointerMove(deltaX, deltaY int) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (p *portalBackend) pointerScrollFull(deltaHorizontal, deltaVertical int, finish bool) error {
|
||||
func (p *portalBackend) PointerScroll(deltaHorizontal, deltaVertical int, finish bool) error {
|
||||
p.lock.RLock()
|
||||
defer p.lock.RUnlock()
|
||||
if p.bus == nil {
|
||||
|
|
@ -282,11 +282,3 @@ func (p *portalBackend) pointerScrollFull(deltaHorizontal, deltaVertical int, fi
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *portalBackend) PointerScroll(deltaHorizontal, deltaVertical int) error {
|
||||
return p.pointerScrollFull(deltaHorizontal, deltaVertical, false)
|
||||
}
|
||||
|
||||
func (p *portalBackend) PointerScrollFinish() error {
|
||||
return p.pointerScrollFull(0, 0, true)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ func (p *windowsBackend) PointerMove(deltaX, deltaY int) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (p *windowsBackend) PointerScroll(deltaHorizontal, deltaVertical int) error {
|
||||
func (p *windowsBackend) PointerScroll(deltaHorizontal, deltaVertical int, finish bool) error {
|
||||
inputs := make([]mouseInput, 0, 2)
|
||||
if deltaHorizontal != 0 {
|
||||
inputs = append(inputs, mouseInput{
|
||||
|
|
@ -239,7 +239,3 @@ func (p *windowsBackend) PointerScroll(deltaHorizontal, deltaVertical int) error
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *windowsBackend) PointerScrollFinish() error {
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -299,12 +299,17 @@ func (p *x11Backend) PointerMove(deltaX, deltaY int) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (p *x11Backend) PointerScroll(deltaHorizontal, deltaVertical int) error {
|
||||
func (p *x11Backend) PointerScroll(deltaHorizontal, deltaVertical int, finish bool) error {
|
||||
p.lock.Lock()
|
||||
stepsHorizontal := (p.scrollHorizontal + deltaHorizontal) / scrollDiv
|
||||
stepsVertical := (p.scrollVertical + deltaVertical) / scrollDiv
|
||||
if finish {
|
||||
p.scrollHorizontal = 0
|
||||
p.scrollVertical = 0
|
||||
} else {
|
||||
p.scrollHorizontal = (p.scrollHorizontal + deltaHorizontal) % scrollDiv
|
||||
p.scrollVertical = (p.scrollVertical + deltaVertical) % scrollDiv
|
||||
}
|
||||
p.lock.Unlock()
|
||||
var buttonHorizontal uint = 7
|
||||
if stepsHorizontal < 0 {
|
||||
|
|
@ -334,11 +339,3 @@ func (p *x11Backend) PointerScroll(deltaHorizontal, deltaVertical int) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *x11Backend) PointerScrollFinish() error {
|
||||
p.lock.Lock()
|
||||
defer p.lock.Unlock()
|
||||
p.scrollHorizontal = 0
|
||||
p.scrollVertical = 0
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
9
main.go
9
main.go
|
|
@ -53,8 +53,8 @@ func processCommand(backend Backend, command string) error {
|
|||
if len(command) == 0 {
|
||||
return errors.New("empty command")
|
||||
}
|
||||
if command == "sf" {
|
||||
return backend.PointerScrollFinish()
|
||||
if command == "S" {
|
||||
return backend.PointerScroll(0, 0, true)
|
||||
}
|
||||
if command[0] == 't' {
|
||||
text := command[1:]
|
||||
|
|
@ -89,7 +89,10 @@ func processCommand(backend Backend, command string) error {
|
|||
return backend.PointerMove(int(x), int(y))
|
||||
}
|
||||
if command[0] == 's' {
|
||||
return backend.PointerScroll(int(x), int(y))
|
||||
return backend.PointerScroll(int(x), int(y), false)
|
||||
}
|
||||
if command[0] == 'S' {
|
||||
return backend.PointerScroll(int(x), int(y), true)
|
||||
}
|
||||
if command[0] == 'b' {
|
||||
if x < 0 || x >= int64(PointerButtonLimit) {
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ function handleStart(evt) {
|
|||
dragging = true;
|
||||
}
|
||||
if (scrolling) {
|
||||
ws.send("sf");
|
||||
ws.send("S");
|
||||
scrolling = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -220,7 +220,7 @@ function handleEnd(evt) {
|
|||
touchReleasedCount += 1;
|
||||
touchLastEnd = evt.timeStamp;
|
||||
if (scrolling) {
|
||||
ws.send("sf");
|
||||
ws.send("S");
|
||||
scrolling = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue