Skip to content

Commit 90cae41

Browse files
authored
fix negative relative mouse moves (#80)
fixes this error: ``` Internal_error: {"message":"failed during drag movement: mousemove_relative: unrecognized option '-60'\nUsage: mousemove_relative [options] \u003cx\u003e \u003cy\u003e\n-c, --clearmodifiers - reset active modifiers (alt, etc) while typing\n-p, --polar - Use polar coordinates. X as an angle, Y as distance\n--sync - only exit once the mouse has moved\n\nUsing polar coordinate mode makes 'x' the angle (in degrees) and\n'y' the distance.\n\nIf you want to use negative numbers for a coordinate, you'll need to\ninvoke it this way (with the '--'):\n mousemove_relative -- - 20 -15\notherwise, normal usage looks like this:\n mousemove_relative 100 140\n"} . ``` tested manually: https://screen.studio/share/lM76bBHd <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Ensure negative relative mouse moves use the "--" separator when building xdotool drag steps to avoid option parsing errors. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 8d5ee87. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 145ef64 commit 90cae41

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

server/cmd/api/api/computer.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,13 @@ func (s *ApiService) DragMouse(ctx context.Context, request oapi.DragMouseReques
700700
x0, y0 := prev[0], prev[1]
701701
x1, y1 := pt[0], pt[1]
702702
for _, step := range generateRelativeSteps(x1-x0, y1-y0, stepsPerSegment) {
703-
args2 = append(args2, "mousemove_relative", strconv.Itoa(step[0]), strconv.Itoa(step[1]))
703+
xStr := strconv.Itoa(step[0])
704+
yStr := strconv.Itoa(step[1])
705+
if step[0] < 0 || step[1] < 0 {
706+
args2 = append(args2, "mousemove_relative", "--", xStr, yStr)
707+
} else {
708+
args2 = append(args2, "mousemove_relative", xStr, yStr)
709+
}
704710
// add a tiny delay between moves, but not after the last step
705711
if stepIndex < totalSteps-1 && stepDelayMs > 0 {
706712
args2 = append(args2, "sleep", stepDelaySeconds)

0 commit comments

Comments
 (0)