mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-01-22 20:57:06 +00:00
[client] spice: added new input:autoCapture
mode
This new mode if enabled (disabled by default) will cause the client to attempt to hold onto the mouse when a title/game has it captured in the guest. This is best effort and is not a replacement for full capture mode.
This commit is contained in:
parent
6c8eba5f54
commit
2789e73296
@ -296,6 +296,13 @@ static struct Option options[] =
|
|||||||
.type = OPTION_TYPE_BOOL,
|
.type = OPTION_TYPE_BOOL,
|
||||||
.value.x_bool = true,
|
.value.x_bool = true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.module = "input",
|
||||||
|
.name = "autoCapture",
|
||||||
|
.description = "Try to keep the mouse captured when needed",
|
||||||
|
.type = OPTION_TYPE_BOOL,
|
||||||
|
.value.x_bool = false
|
||||||
|
},
|
||||||
|
|
||||||
// spice options
|
// spice options
|
||||||
{
|
{
|
||||||
@ -462,6 +469,7 @@ bool config_load(int argc, char * argv[])
|
|||||||
params.mouseSens = option_get_int ("input", "mouseSens" );
|
params.mouseSens = option_get_int ("input", "mouseSens" );
|
||||||
params.rawMouse = option_get_bool("input", "rawMouse" );
|
params.rawMouse = option_get_bool("input", "rawMouse" );
|
||||||
params.mouseRedraw = option_get_bool("input", "mouseRedraw" );
|
params.mouseRedraw = option_get_bool("input", "mouseRedraw" );
|
||||||
|
params.autoCapture = option_get_bool("input", "autoCapture" );
|
||||||
|
|
||||||
params.minimizeOnFocusLoss = option_get_bool("win", "minimizeOnFocusLoss");
|
params.minimizeOnFocusLoss = option_get_bool("win", "minimizeOnFocusLoss");
|
||||||
|
|
||||||
|
@ -365,8 +365,8 @@ static int cursorThread(void * unused)
|
|||||||
|
|
||||||
if (msg.udata & CURSOR_FLAG_POSITION)
|
if (msg.udata & CURSOR_FLAG_POSITION)
|
||||||
{
|
{
|
||||||
g_cursor.guest.x = cursor->x;
|
g_cursor.guest.x = cursor->x;
|
||||||
g_cursor.guest.y = cursor->y;
|
g_cursor.guest.y = cursor->y;
|
||||||
g_cursor.guest.valid = true;
|
g_cursor.guest.valid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -979,11 +979,29 @@ static void handleMouseNormal(double ex, double ey)
|
|||||||
if (x == 0 && y == 0)
|
if (x == 0 && y == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* assume the mouse will move to the location we attempt to move it to so we
|
if (params.autoCapture)
|
||||||
* avoid warp out of window issues. The cursorThread will correct this if
|
{
|
||||||
* wrong after the movement has ocurred on the guest */
|
g_cursor.delta.x += x;
|
||||||
g_cursor.guest.x += x;
|
g_cursor.delta.y += y;
|
||||||
g_cursor.guest.y += y;
|
|
||||||
|
if (abs(g_cursor.delta.x) > 50 || abs(g_cursor.delta.y) > 50)
|
||||||
|
{
|
||||||
|
g_cursor.delta.x = 0;
|
||||||
|
g_cursor.delta.y = 0;
|
||||||
|
warpMouse(g_state.windowCX, g_state.windowCY, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_cursor.guest.x = g_state.srcSize.x / 2;
|
||||||
|
g_cursor.guest.y = g_state.srcSize.y / 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* assume the mouse will move to the location we attempt to move it to so we
|
||||||
|
* avoid warp out of window issues. The cursorThread will correct this if
|
||||||
|
* wrong after the movement has ocurred on the guest */
|
||||||
|
g_cursor.guest.x += x;
|
||||||
|
g_cursor.guest.y += y;
|
||||||
|
}
|
||||||
|
|
||||||
if (!spice_mouse_motion(x, y))
|
if (!spice_mouse_motion(x, y))
|
||||||
DEBUG_ERROR("failed to send mouse motion message");
|
DEBUG_ERROR("failed to send mouse motion message");
|
||||||
|
@ -138,6 +138,7 @@ struct AppParams
|
|||||||
bool mouseRedraw;
|
bool mouseRedraw;
|
||||||
int mouseSens;
|
int mouseSens;
|
||||||
bool rawMouse;
|
bool rawMouse;
|
||||||
|
bool autoCapture;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CBRequest
|
struct CBRequest
|
||||||
@ -215,6 +216,9 @@ struct CursorState
|
|||||||
/* the local X & Y position */
|
/* the local X & Y position */
|
||||||
struct DoublePoint pos;
|
struct DoublePoint pos;
|
||||||
|
|
||||||
|
/* the delta since last warp when in auto capture mode */
|
||||||
|
struct DoublePoint delta;
|
||||||
|
|
||||||
/* the scale factor for the mouse sensitiviy */
|
/* the scale factor for the mouse sensitiviy */
|
||||||
int sens;
|
int sens;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user