feat: cursor warps maintain relative position within a window #6338
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Enables hyprland to remember the position of the cursor relative to a window when the window is unfocused (unless caused by continuous cursor movement). later, when the window is refocused, the cursor will be warped back to its previously remembered position within that window, rather than to the centre of the window.
in addition, when moving a focused window, the relative cursor position would also be maintained instead of jumping to the centre. this includes
as a fallback, the cursor is still moved to the centre of the window when
this behaviour is controlled by
cursor:persistent_warps
.use case
improves usability for workflows where it is beneficial to maintain the cursor position within a window context, such as when frequently switching between multiple windows, e.g. between a browser and an ide.
this should be more noticeable to laptop users with trackpads, as these devices are relatively close to the keyboard and tend to be imprecise and require a lot of finger movement.
mechanism
terms
cursor position tracking
vector2d cwindow::m_vrelativecursorcoordsonlastwarp
stores the cursor position relative to the window. it was updated whenever the window was about to lose focus discontinuously.cursor warpping
void cwindow::warpcursor()
handles the logic for warping the cursor.g_pcompositor->warpcursorto(window->middle())
, i.e. warp the cursor to the middle of the window;integration with keybindings
updaterelativecursorcoords
will update the relative cursor position before the last focused window is about to discontinuously lose focus.updaterelativecursorcoords
before change of window position and to use thecwindow::warpcursor()
method instead of warping the cursor to the centre of the window directly.