mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-23 04:49:48 +01:00
Mouse no longer removes focus from constraining window
The window properly constrains the mouse now I do still notice a bug with moving the mouse in games, if you don't move the mouse fast enough, some games will not register the mouse movement. This doesn't happen in KDE so I know it's related somehow
This commit is contained in:
parent
f7e9a27c0a
commit
ee7900f819
1 changed files with 16 additions and 18 deletions
|
@ -47,28 +47,26 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
||||||
} else {
|
} else {
|
||||||
// Native Wayland apps know how 2 constrain themselves.
|
// Native Wayland apps know how 2 constrain themselves.
|
||||||
// XWayland, we just have to accept them. Might cause issues, but thats XWayland for ya.
|
// XWayland, we just have to accept them. Might cause issues, but thats XWayland for ya.
|
||||||
|
const auto CONSTRAINTPOS = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->x, CONSTRAINTWINDOW->m_uSurface.xwayland->y) : CONSTRAINTWINDOW->m_vRealPosition.vec();
|
||||||
const auto CONSTRAINTSIZE = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->width, CONSTRAINTWINDOW->m_uSurface.xwayland->height) : CONSTRAINTWINDOW->m_vRealSize.vec();
|
const auto CONSTRAINTSIZE = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->width, CONSTRAINTWINDOW->m_uSurface.xwayland->height) : CONSTRAINTWINDOW->m_vRealSize.vec();
|
||||||
const auto CONSTRAINTPOS = Vector2D((CONSTRAINTWINDOW->m_uSurface.xwayland->x + CONSTRAINTSIZE.x) / 2.0, (CONSTRAINTWINDOW->m_uSurface.xwayland->y + CONSTRAINTSIZE.y) / 2.0);
|
|
||||||
|
|
||||||
|
if (!VECINRECT(mouseCoords, CONSTRAINTPOS.x, CONSTRAINTPOS.y, CONSTRAINTPOS.x + CONSTRAINTSIZE.x, CONSTRAINTPOS.y + CONSTRAINTSIZE.y)) {
|
||||||
// I'm a worm and I added some code to override some annoying stuff :)
|
|
||||||
// CONSTRAINTSIZE = Vector2D(0.0, 0.0);
|
|
||||||
|
|
||||||
if (!VECINRECT(mouseCoords, CONSTRAINTPOS.x, CONSTRAINTPOS.y, CONSTRAINTPOS.x/* + CONSTRAINTSIZE.x*/, CONSTRAINTPOS.y/* + CONSTRAINTSIZE.y*/)) {
|
|
||||||
if (g_pCompositor->m_sSeat.mouse->constraintActive) {
|
if (g_pCompositor->m_sSeat.mouse->constraintActive) {
|
||||||
Vector2D deltaToFit;
|
Vector2D newConstrainedCoords = mouseCoords;
|
||||||
|
|
||||||
|
if (mouseCoords.x < CONSTRAINTPOS.x)
|
||||||
|
newConstrainedCoords.x = CONSTRAINTPOS.x;
|
||||||
|
else if (mouseCoords.x >= CONSTRAINTPOS.x + CONSTRAINTSIZE.x)
|
||||||
|
newConstrainedCoords.x = CONSTRAINTPOS.x + CONSTRAINTSIZE.x - 1.0;
|
||||||
|
|
||||||
// Instead of constraining the cursor to the entire window, like in the previous version, this keeps the cursor to the center of the window.
|
if (mouseCoords.y < CONSTRAINTPOS.y)
|
||||||
// This allows for maximum mouse movement to be captured by the application, while the mouse can still be freed and move around when it is supposed to be
|
newConstrainedCoords.y = CONSTRAINTPOS.y;
|
||||||
deltaToFit.x = CONSTRAINTPOS.x - mouseCoords.x;
|
else if (mouseCoords.y >= CONSTRAINTPOS.y + CONSTRAINTSIZE.y)
|
||||||
deltaToFit.y = CONSTRAINTPOS.y - mouseCoords.y;
|
newConstrainedCoords.y = CONSTRAINTPOS.y + CONSTRAINTSIZE.y - 1.0;
|
||||||
|
|
||||||
|
wlr_cursor_warp_closest(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, newConstrainedCoords.x, newConstrainedCoords.y);
|
||||||
|
|
||||||
wlr_cursor_move(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, deltaToFit.x, deltaToFit.y);
|
mouseCoords = newConstrainedCoords;
|
||||||
|
|
||||||
mouseCoords = mouseCoords + deltaToFit;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((!CONSTRAINTWINDOW->m_bIsX11 && PMONITOR && CONSTRAINTWINDOW->m_iWorkspaceID == PMONITOR->activeWorkspace) || (CONSTRAINTWINDOW->m_bIsX11)) {
|
if ((!CONSTRAINTWINDOW->m_bIsX11 && PMONITOR && CONSTRAINTWINDOW->m_iWorkspaceID == PMONITOR->activeWorkspace) || (CONSTRAINTWINDOW->m_bIsX11)) {
|
||||||
|
|
Loading…
Reference in a new issue