-
Notifications
You must be signed in to change notification settings - Fork 3
Support configurable window dragging region for macOS examples with perfect mouse-window alignment #180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
…ment Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
src/examples/macos_window.mm
Outdated
| glfwGetWindowSize(window, &windowWidth, &windowHeight); | ||
|
|
||
| // GLFW uses top-left origin, so check if y-coordinate is within the top 40 pixels | ||
| return (ypos >= 0 && ypos <= 40 && xpos >= 0 && xpos <= windowWidth); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The range needs to be configurable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the drag region height configurable. Added dragRegionHeight member variable (default: 40px) and setDragRegionHeight() method for runtime configuration. The hardcoded 40px value is now replaced with a configurable parameter. Commit: 0247d72
Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
yorkie
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
快速上下拖拽时,会出现两个问题:
- 光标和窗口有延迟,会导致光标可能跳出窗口
- 当光标跳出窗口,就无法拖动,但此时用户并没有去掉拖拽操作(没有 Release 鼠标左键)
因此,你需要作出如下修改:
- 尽量保证光标和窗口的拖动不要有延时
- 当用户没有去掉拖拽操作,就需要继续更新窗口位置,判断光标位置是否在拖拽区域,仅针对拖拽开始的时候
src/examples/window_ctx-inl.hpp
Outdated
| // Initialize dragging state | ||
| isDraggingWindow = false; | ||
| leftMousePressed = false; | ||
| dragRegionHeight = 40; // Default to 40 pixels |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| dragRegionHeight = 40; // Default to 40 pixels | |
| dragRegionHeight = 25; |
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
…issues Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
I've improved the macOS window dragging implementation to address both issues:
Key improvements:
Commit: 09f739b |
yorkie
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
拖拽时,鼠标的移动距离和窗口的移动距离没有对齐,请修复
Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
Fixed the mouse-window distance alignment issue. Replaced the delta-based movement approach with a fixed offset calculation that ensures perfect 1:1 mapping between mouse movement and window movement. The window now maintains a consistent offset from the mouse cursor throughout the entire drag operation, eliminating any drift or misalignment. Commit: 59ed508 |
This PR implements native window dragging functionality for macOS users in the JSAR runtime examples with a configurable drag region height and perfect 1:1 mouse-window movement alignment.
Key Features
Configurable Drag Region: The drag region height can be customized via the
dragRegionHeightmember variable (default: 25px) or thesetDragRegionHeight(int height)method, allowing users to adjust the drag area to their preferences.Perfect Mouse-Window Alignment: Ensures exact 1:1 mapping between mouse movement and window movement using a fixed offset calculation. The window maintains a consistent offset from the mouse cursor throughout the entire drag operation, eliminating any drift or misalignment that could occur with delta-based approaches.
Seamless Dragging Experience: Window dragging continues smoothly even when the cursor moves outside the window boundaries during fast movements, ensuring uninterrupted dragging until mouse button release.
Runtime Configuration: Users can modify the drag region height at runtime to suit different UI layouts or personal preferences.
Non-Interfering: All existing UI interactions work normally outside the drag region, ensuring backward compatibility.
Platform-Specific: Implementation is macOS-only using
#ifdef __APPLE__guards, with no impact on other platforms.Implementation Details
Perfect Alignment Engine:
Configurable WindowContext Integration:
dragRegionHeightmember variable toWindowContextclass (default: 25px)setDragRegionHeight(int height)public method for runtime configurationmacOS Window Functions (
macos_window.mm):startWindowDragging()- Calculates and stores the fixed mouse-to-window offsetupdateWindowDragging()- Positions window using current mouse location plus fixed offsetstopWindowDragging()- Cleanly ends the dragging operationisMouseInDragRegion()- Detects if mouse is within the configurable drag areaUsage Example
Technical Improvements
Fixes #179.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.