mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-10 01:01:30 +00:00
[client] wayland: constrain pointer only during capture
Some checks failed
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / module (push) Has been cancelled
build / host-linux (push) Has been cancelled
build / host-windows-cross (push) Has been cancelled
build / host-windows-native (push) Has been cancelled
build / idd (push) Has been cancelled
build / obs (clang) (push) Has been cancelled
build / obs (gcc) (push) Has been cancelled
build / docs (push) Has been cancelled
Some checks failed
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / module (push) Has been cancelled
build / host-linux (push) Has been cancelled
build / host-windows-cross (push) Has been cancelled
build / host-windows-native (push) Has been cancelled
build / idd (push) Has been cancelled
build / obs (clang) (push) Has been cancelled
build / obs (gcc) (push) Has been cancelled
build / docs (push) Has been cancelled
Remove the persistent confined-pointer workaround that emulated cursor warping on Wayland. Normal pointer motion now uses absolute input only. Create relative and locked pointer objects only during capture. Preserve the request across pointer capability changes, and suppress relative events until the compositor confirms the lock. On uncapture, publish the current absolute position instead of trying to warp the host cursor.
This commit is contained in:
@@ -269,7 +269,10 @@ void app_handleEnterEvent(bool entered)
|
||||
return;
|
||||
|
||||
g_cursor.realign = true;
|
||||
core_handleMouseAbsolute();
|
||||
if (g_cursor.grab)
|
||||
core_setCursorInView(true);
|
||||
else
|
||||
core_handleMouseAbsolute();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -652,58 +655,6 @@ void app_handleGrabEvent(bool active)
|
||||
core_handleGrabEvent(active);
|
||||
}
|
||||
|
||||
// On some display servers normal cursor logic does not work due to the lack of
|
||||
// cursor warp support. Instead, we attempt a best-effort emulation which works
|
||||
// with a 1:1 mouse movement patch applied in the guest. For anything fancy, use
|
||||
// capture mode.
|
||||
void app_handleMouseBasic(void)
|
||||
{
|
||||
/* do not pass mouse events to the guest if we do not have focus */
|
||||
if (!g_cursor.guest.valid || !g_state.haveSrcSize || !g_state.focused ||
|
||||
app_isOverlayMode())
|
||||
return;
|
||||
|
||||
if (!core_inputEnabled())
|
||||
return;
|
||||
|
||||
if (lgInput_supports(LG_INPUT_SUPPORT_MOUSE_ABSOLUTE))
|
||||
return;
|
||||
|
||||
const bool inView =
|
||||
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;
|
||||
|
||||
core_setCursorInView(inView);
|
||||
|
||||
/* translate the current position to guest coordinate space */
|
||||
struct DoublePoint guest;
|
||||
util_localCurToGuest(&guest);
|
||||
|
||||
int x = (int) round(util_clamp(guest.x, 0, g_state.srcSize.x) -
|
||||
g_cursor.projected.x);
|
||||
int y = (int) round(util_clamp(guest.y, 0, g_state.srcSize.y) -
|
||||
g_cursor.projected.y);
|
||||
|
||||
if (!x && !y)
|
||||
return;
|
||||
|
||||
g_cursor.projected.x += x;
|
||||
g_cursor.projected.y += y;
|
||||
|
||||
if (!lgInput_mouseMotion(x, y))
|
||||
DEBUG_ERROR("failed to send mouse motion message");
|
||||
}
|
||||
|
||||
void app_resyncMouseBasic(void)
|
||||
{
|
||||
if (!g_cursor.guest.valid)
|
||||
return;
|
||||
g_cursor.projected.x = g_cursor.guest.x + g_cursor.guest.hx;
|
||||
g_cursor.projected.y = g_cursor.guest.y + g_cursor.guest.hy;
|
||||
}
|
||||
|
||||
void app_updateWindowPos(int x, int y)
|
||||
{
|
||||
g_state.windowPos.x = x;
|
||||
|
||||
@@ -327,10 +327,13 @@ void core_setGrabQuiet(bool enable)
|
||||
/* ensure the local mouse is inside the window before we capture, this fixes
|
||||
* odd UI behaviour if the user is using focus follows mouse and the window
|
||||
* was focused without the cursor being in window already */
|
||||
struct DoublePoint local;
|
||||
const bool valid = util_guestCurToLocal(&local);
|
||||
MTRACE("grab align valid=%d", valid);
|
||||
core_warpPointer(local.x, local.y, true);
|
||||
if (warpSupport != LG_DS_WARP_NONE)
|
||||
{
|
||||
struct DoublePoint local;
|
||||
const bool valid = util_guestCurToLocal(&local);
|
||||
MTRACE("grab align valid=%d", valid);
|
||||
core_warpPointer(local.x, local.y, true);
|
||||
}
|
||||
|
||||
if (g_params.grabKeyboard)
|
||||
g_state.ds->grabKeyboard();
|
||||
@@ -348,13 +351,18 @@ void core_setGrabQuiet(bool enable)
|
||||
|
||||
g_state.ds->uncapturePointer();
|
||||
|
||||
if (!g_params.captureInputOnly && warpSupport != LG_DS_WARP_NONE)
|
||||
applyView(g_state.ds->isPointerGrabbed(), false);
|
||||
if (warpSupport == LG_DS_WARP_NONE)
|
||||
core_handleMouseAbsolute();
|
||||
else
|
||||
{
|
||||
if (!g_params.captureInputOnly)
|
||||
applyView(g_state.ds->isPointerGrabbed(), false);
|
||||
|
||||
/* if exiting capture when input on capture only we need to align the local
|
||||
* cursor to the guest's location before it is shown. */
|
||||
if (g_params.captureInputOnly || !g_params.hideMouse)
|
||||
core_alignToGuest();
|
||||
/* if exiting capture when input on capture only we need to align the
|
||||
* local cursor to the guest's location before it is shown. */
|
||||
if (g_params.captureInputOnly || !g_params.hideMouse)
|
||||
core_alignToGuest();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,6 +380,14 @@ bool core_warpPointer(int x, int y, bool exiting)
|
||||
return false;
|
||||
}
|
||||
|
||||
enum LG_DSWarpSupport warpSupport = LG_DS_WARP_NONE;
|
||||
app_getProp(LG_DS_WARP_SUPPORT, &warpSupport);
|
||||
if (warpSupport == LG_DS_WARP_NONE)
|
||||
{
|
||||
MTRACE("warp drop=support target=%d,%d exit=%d", x, y, exiting);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!exiting && g_cursor.warpState == WARP_STATE_OFF)
|
||||
{
|
||||
MTRACE("warp drop=state target=%d,%d exit=%d", x, y, exiting);
|
||||
|
||||
@@ -1150,15 +1150,9 @@ int main_cursorThread(void * unused)
|
||||
g_cursor.guest.y = pointer.y;
|
||||
g_cursor.guest.valid = true;
|
||||
if (!wasValid && core_inputEnabled())
|
||||
{
|
||||
core_alignToGuest();
|
||||
app_resyncMouseBasic();
|
||||
}
|
||||
}
|
||||
|
||||
if (hotspotChanged)
|
||||
app_resyncMouseBasic();
|
||||
|
||||
if ((pointer.flags & LG_TRANSPORT_POINTER_POSITION) || hotspotChanged)
|
||||
core_handleGuestMouseUpdate();
|
||||
|
||||
|
||||
@@ -343,9 +343,6 @@ struct CursorState
|
||||
|
||||
/* the guest's cursor position */
|
||||
struct CursorInfo guest;
|
||||
|
||||
/* the projected position after move, for app_handleMouseBasic only */
|
||||
struct Point projected;
|
||||
};
|
||||
|
||||
// forwards
|
||||
|
||||
Reference in New Issue
Block a user