-
-
Notifications
You must be signed in to change notification settings - Fork 913
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
Warp cursor on openwindow/closewindow. #5777
base: main
Are you sure you want to change the base?
Conversation
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.
I like cursor warps but would absolutely hate this. IMO this should be configurable separately and off by default (probably in misc:
or something)
@@ -667,6 +667,9 @@ void Events::listener_mapWindow(void* owner, void* data) { | |||
|
|||
if (PMONITOR && PWINDOW->m_iX11Type == 2) | |||
PWINDOW->m_fX11SurfaceScaledBy = PMONITOR->scale; | |||
|
|||
// Move cursor to middle of new window if enabled. | |||
g_pCompositor->warpCursorTo(PWINDOW->middle()); |
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.
you're not checking if:
- there is a constraint
- the window gained focus
- the window is focusable (though if point 2 is true, this has to be true too)
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.
Good points, especially the checking if its gained focus. I definitely put this out a little per-maturely.
For the first point though, in
Lines 2425 to 2443 in 2e76376
void CCompositor::warpCursorTo(const Vector2D& pos, bool force) { | |
// warpCursorTo should only be used for warps that | |
// should be disabled with no_cursor_warps | |
static auto PNOWARPS = CConfigValue<Hyprlang::INT>("general:no_cursor_warps"); | |
if (*PNOWARPS && !force) | |
return; | |
if (!m_sSeat.mouse) | |
return; | |
wlr_cursor_warp(m_sWLRCursor, m_sSeat.mouse->mouse, pos.x, pos.y); | |
const auto PMONITORNEW = getMonitorFromVector(pos); | |
if (PMONITORNEW != m_pLastMonitor) | |
setActiveMonitor(PMONITORNEW); | |
} |
general:no_cursor_warps
in their config. I kind of figured it fell under the same bucket as the change focus warps.
I'm going to think on this some more and ideally try to integrate this solution with what changing focus uses.
Thanks for the feedback! Going to put this in Draft for a bit.
fb471b8
to
1237732
Compare
358e59e
to
3fd6c1b
Compare
1184395
to
b16fb97
Compare
Describe your PR, what does it fix/add?
Fixes/addresses #5745.
Currently when creating a new window, the cursor doesn't warp to the new window like it does on a window focus change. As such I used the same method (warpCursorTo) to warp the cursor. This will also be disabled with no_cursor_warps.
Is there anything you want to mention? (unchecked code, possible bugs, found problems, breaking compatibility, etc.)
This is a very straightforward change. It's unlikely this will introduce unexpected behavior as new windows are already focused, this just moves mouse too.
Is it ready for merging, or does it need work?
Ready for merging.