Skip to content
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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

The-Briel-Deal
Copy link
Contributor

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.

Copy link
Member

@vaxerski vaxerski left a 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)

src/events/Windows.cpp Outdated Show resolved Hide resolved
@@ -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());
Copy link
Member

@vaxerski vaxerski Apr 27, 2024

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)

Copy link
Contributor Author

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

Hyprland/src/Compositor.cpp

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);
}
. I see that this is only going to warp if the user hasn't put 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.

@The-Briel-Deal The-Briel-Deal marked this pull request as draft April 28, 2024 04:04
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.

2 participants