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
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/events/Windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
The-Briel-Deal marked this conversation as resolved.
Show resolved Hide resolved
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.

}

void Events::listener_unmapWindow(void* owner, void* data) {
Expand Down
Loading