diff --git a/client/src/app.c b/client/src/app.c index 24720e00..12ffe2d0 100644 --- a/client/src/app.c +++ b/client/src/app.c @@ -907,7 +907,7 @@ void app_setOverlay(bool enable) g_state.io->ConfigFlags |= ImGuiConfigFlags_NoMouse; core_resetOverlayInputState(); core_setGrabQuiet(wasGrabbed); - core_invalidatePointer(); + core_invalidatePointer(true); app_invalidateWindow(false); } } diff --git a/client/src/core.c b/client/src/core.c index b2e77ed4..063d16da 100644 --- a/client/src/core.c +++ b/client/src/core.c @@ -31,21 +31,44 @@ #define RESIZE_TIMEOUT (10 * 1000) // 10ms +static bool isInView(void) +{ + return + g_cursor.pos.x >= g_state.dstRect.x && + g_cursor.pos.x < g_state.dstRect.x + g_state.dstRect.w && + g_cursor.pos.y >= g_state.dstRect.y && + g_cursor.pos.y < g_state.dstRect.y + g_state.dstRect.h; +} + bool core_inputEnabled(void) { return g_params.useSpiceInput && !g_state.ignoreInput && ((g_cursor.grab && g_params.captureInputOnly) || !g_params.captureInputOnly); } -void core_invalidatePointer(void) +void core_invalidatePointer(bool detectInView) { /* if the display server does not support warp, then we can not operate in * always relative mode and we should not grab the pointer */ enum LG_DSWarpSupport warpSupport = LG_DS_WARP_NONE; app_getProp(LG_DS_WARP_SUPPORT, &warpSupport); - g_cursor.warpState = g_cursor.inView ? WARP_STATE_ON : WARP_STATE_OFF; + if (detectInView) + { + bool inView = isInView(); + // do not allow the view to become active if any mouse buttons are being held, + // this fixes issues with meta window resizing. + if (inView && g_cursor.buttons) + return; + g_cursor.inView = inView; + } + + g_cursor.draw = (g_params.alwaysShowCursor || g_params.captureInputOnly) + ? true : g_cursor.inView; + g_cursor.redraw = true; + + g_cursor.warpState = g_cursor.inView ? WARP_STATE_ON : WARP_STATE_OFF; if (g_cursor.inView) { if (g_params.hideMouse) @@ -80,17 +103,8 @@ void core_setCursorInView(bool enable) if (enable && !g_state.focused) return; - // do not allow the view to become active if any mouse buttons are being held, - // this fixes issues with meta window resizing. - if (enable && g_cursor.buttons) - return; - g_cursor.inView = enable; - g_cursor.draw = (g_params.alwaysShowCursor || g_params.captureInputOnly) - ? true : enable; - g_cursor.redraw = true; - - core_invalidatePointer(); + core_invalidatePointer(false); } void core_setGrab(bool enable) @@ -401,15 +415,6 @@ void core_handleMouseGrabbed(double ex, double ey) DEBUG_ERROR("failed to send mouse motion message"); } -static bool isInView(void) -{ - return - g_cursor.pos.x >= g_state.dstRect.x && - g_cursor.pos.x < g_state.dstRect.x + g_state.dstRect.w && - g_cursor.pos.y >= g_state.dstRect.y && - g_cursor.pos.y < g_state.dstRect.y + g_state.dstRect.h; -} - void core_handleMouseNormal(double ex, double ey) { // prevent cursor handling outside of capture if the position is not known diff --git a/client/src/core.h b/client/src/core.h index 1cca2f11..a65aca16 100644 --- a/client/src/core.h +++ b/client/src/core.h @@ -24,7 +24,7 @@ #include bool core_inputEnabled(void); -void core_invalidatePointer(void); +void core_invalidatePointer(bool detectInView); void core_setCursorInView(bool enable); void core_setGrab(bool enable); void core_setGrabQuiet(bool enable);