Skip to content

feat: enhance drag functionality with optional client coordinates and…#5

Open
aesopov wants to merge 3 commits into
Wargraphs:mainfrom
aesopov:main
Open

feat: enhance drag functionality with optional client coordinates and…#5
aesopov wants to merge 3 commits into
Wargraphs:mainfrom
aesopov:main

Conversation

@aesopov

@aesopov aesopov commented Sep 24, 2025

Copy link
Copy Markdown
Contributor

… update documentation

@aesopov

aesopov commented Sep 24, 2025

Copy link
Copy Markdown
Contributor Author

This PR closes #3

This pull request enhances the cross-platform window drag functionality by standardizing the API to accept optional client coordinates and improving platform-specific handling for Linux, macOS, and Windows. The changes make it easier to initiate window drags at precise locations and simplify usage across all platforms.

API Standardization and Usage Improvements

  • Updated the API documentation and implementation to accept optional client coordinates (x, y) for window drags, making the interface consistent across Windows, Linux, and macOS. Buffers from getNativeWindowHandle() are now preferred for Linux, deprecating legacy number IDs. (drag.h, drag.hL6-R8)
  • Refactored the test application to always pass the native window handle buffer and, when available, the mouse coordinates where the drag was initiated. This ensures consistent behavior and simplifies platform logic. (test/main.js, [1]; test/renderer.html, [2]

Platform-Specific Drag Handling

  • Linux: Improved StartDrag to accept either a buffer or a legacy number for the window handle, safely extracting the window ID. Added support for optional client coordinates, converting them to root coordinates for the drag event. (drag_linux.cc, [1] [2]
  • macOS: Modified drag event creation to use provided client coordinates if available, converting them to the macOS coordinate system (bottom-left origin). (drag_mac.mm, [1] [2]
  • Windows: Enhanced drag initiation to use provided client coordinates in window space, converting them to screen coordinates as needed. Improved logic for sending mouse events to ensure correct drag behavior. (drag_win.cc, [1] [2]

Dependency Update

  • Updated the electron development dependency to version ^37.5.1 for compatibility and stability improvements. (package.json, package.jsonL38-R38)

@aesopov

aesopov commented Sep 24, 2025

Copy link
Copy Markdown
Contributor Author

Note: I tested it only on macOS.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant