Skip to content

Comments

Fix: use drag event for macOS smooth drag#758

Open
PekingSpades wants to merge 1 commit intogo-vgo:masterfrom
PekingSpades:pr-macos-desktop-drag
Open

Fix: use drag event for macOS smooth drag#758
PekingSpades wants to merge 1 commit intogo-vgo:masterfrom
PekingSpades:pr-macos-desktop-drag

Conversation

@PekingSpades
Copy link
Contributor

@PekingSpades PekingSpades commented Jan 30, 2026

Please provide Issues links to:

Provide test code:

package main

import "github.com/go-vgo/robotgo"

func main() {
	robotgo.Sleep(2)
	robotgo.Move(900, 560)
	robotgo.MilliSleep(300)
	robotgo.DragSmooth(600, 560)
	robotgo.MilliSleep(300)
}

Reproduction

Before this change: Chrome drag works, and Drag can drag macOS desktop icons, but DragSmooth cannot smoothly drag desktop icons.

Description

  • Fix macOS smooth drag by sending drag events during smooth movement.
  • Add a drag-specific smooth path in C and use it from DragSmooth.
  • Keep MoveSmooth behavior unchanged; deprecated DragMouse now delegates to DragSmooth.

Summary by CodeRabbit

  • New Features
    • Added smooth dragging functionality with customizable mouse button selection
  • Improvements
    • Enhanced consistency and reliability in mouse movement operations

✏️ Tip: You can customize this high-level summary in your review settings.

@PekingSpades PekingSpades requested a review from vcaesar as a code owner January 30, 2026 06:04
@gemini-code-assist
Copy link

Important

Installation incomplete: to start using Gemini Code Assist, please ask the organization owner(s) to visit the Gemini Code Assist Admin Console and sign the Terms of Services.

@coderabbitai
Copy link

coderabbitai bot commented Jan 30, 2026

📝 Walkthrough

Walkthrough

The pull request refactors mouse movement operations by extracting common logic into internal helper functions and introducing new public dragging APIs. Both C and Go layers consolidate drag and non-drag movements through shared implementation patterns, simplifying control flow while maintaining backward compatibility.

Changes

Cohort / File(s) Summary
C Mouse Interface
mouse/mouse_c.h
Introduced internal smoothlyMoveMouseImpl as a generalized mouse movement function with drag and button parameters. Added public smoothlyDragMouse wrapper that delegates to the impl function. Reworked smoothlyMoveMouse to also delegate to impl with drag disabled.
Go Wrapper Layer
robotgo.go
Created internal smoothMove helper to consolidate smooth movement logic for drag and non-drag scenarios. Modified MoveSmooth and DragSmooth to delegate to smoothMove instead of containing separate implementations.
Go Function Implementation
robotgo_fn_v1.go
Simplified DragMouse control flow by replacing multi-step button toggle and sleep sequence with a single DragSmooth call, reducing code complexity.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

enhancement

Suggested reviewers

  • vcaesar

Poem

🐰 With refactored grace, the mouse now flows,
Drag or move—one path it knows,
Helper functions share the way,
Simpler code to code each day! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 44.44% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix: use drag event for macOS smooth drag' directly describes the main change: fixing smooth drag on macOS by using drag events, which aligns with the PR's core objective.
Description check ✅ Passed The PR description includes issue reference (#653), test code in Go, a clear reproduction section, and a detailed description of changes. It covers all essential requirements from the template.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

🧪 Unit Test Generation v2 is now available!

We have significantly improved our unit test generation capabilities.

To enable: Add this to your .coderabbit.yaml configuration:

reviews:
  finishing_touches:
    unit_tests:
      enabled: true

Try it out by using the @coderabbitai generate unit tests command on your code files or under ✨ Finishing Touches on the walkthrough!

Have feedback? Share your thoughts on our Discord thread!


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@vcaesar
Copy link
Member

vcaesar commented Jan 30, 2026

It is closed because you can use if runtime.GOOS == "darwin" { Drag() } else {...}, without modifying any APIs, Maybe I will add an encapsulation method.

@vcaesar vcaesar closed this Jan 30, 2026
@vcaesar vcaesar added the Mac label Jan 30, 2026
@vcaesar
Copy link
Member

vcaesar commented Jan 30, 2026

And this change broke the MoveSmooth() API code.

@vcaesar vcaesar reopened this Jan 30, 2026
@vcaesar vcaesar added this to the v1.10.0 milestone Jan 30, 2026
@PekingSpades
Copy link
Contributor Author

It does not introduce a breaking change to MoveSmooth.

  • We only refactored: MoveSmooth is now a thin wrapper over smoothMove.
  • smoothMove’s body is the same implementation that used to be inside MoveSmooth (just moved).
  • Signature, parameters, and behavior of MoveSmooth are unchanged.

The only behavior change is on the drag path: DragSmooth/DragMouse now use drag events on macOS. On Windows/Linux, dragMouse is already redirected to moveMouse in the C layer, so adding platform checks in Go would be redundant and would just spread conditional code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants