mirror of
				https://github.com/gnif/LookingGlass.git
				synced 2025-11-03 22:22:08 +00:00 
			
		
		
		
	[client] spice: adjust ordering to avoid dropping mouse input events
This commit is contained in:
		@@ -795,16 +795,6 @@ static void warpMouse(int x, int y)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static void handleMouseMoveEvent(int ex, int ey)
 | 
					static void handleMouseMoveEvent(int ex, int ey)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  if (!state.cursorInWindow)
 | 
					 | 
				
			||||||
    return;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (state.ignoreInput || !params.useSpiceInput)
 | 
					 | 
				
			||||||
    return;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  state.curLocalX    = ex;
 | 
					 | 
				
			||||||
  state.curLocalY    = ey;
 | 
					 | 
				
			||||||
  state.haveCurLocal = true;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  SDL_Point delta = {
 | 
					  SDL_Point delta = {
 | 
				
			||||||
    .x = ex - state.curLastX,
 | 
					    .x = ex - state.curLastX,
 | 
				
			||||||
    .y = ey - state.curLastY
 | 
					    .y = ey - state.curLastY
 | 
				
			||||||
@@ -813,8 +803,9 @@ static void handleMouseMoveEvent(int ex, int ey)
 | 
				
			|||||||
  if (delta.x == 0 && delta.y == 0)
 | 
					  if (delta.x == 0 && delta.y == 0)
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  state.curLastX = ex;
 | 
					  state.curLastX = state.curLocalX = ex;
 | 
				
			||||||
  state.curLastY = ey;
 | 
					  state.curLastY = state.curLocalX = ey;
 | 
				
			||||||
 | 
					  state.haveCurLocal = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (state.warpState == WARP_STATE_ACTIVE &&
 | 
					  if (state.warpState == WARP_STATE_ACTIVE &&
 | 
				
			||||||
      ex == state.warpToX && ey == state.warpToY)
 | 
					      ex == state.warpToX && ey == state.warpToY)
 | 
				
			||||||
@@ -823,21 +814,20 @@ static void handleMouseMoveEvent(int ex, int ey)
 | 
				
			|||||||
    return;
 | 
					    return;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!state.cursorInWindow)
 | 
					  if (!state.cursorInWindow || state.ignoreInput || !params.useSpiceInput)
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if ((state.haveCursorPos || state.grabMouse) &&
 | 
					 | 
				
			||||||
      (ex < 100 || ex > state.windowW - 100 ||
 | 
					 | 
				
			||||||
       ey < 100 || ey > state.windowH - 100))
 | 
					 | 
				
			||||||
  {
 | 
					 | 
				
			||||||
    warpMouse(state.windowW / 2, state.windowH / 2);
 | 
					 | 
				
			||||||
    return;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  /* if we don't have the current cursor pos just send cursor movements */
 | 
					  /* if we don't have the current cursor pos just send cursor movements */
 | 
				
			||||||
  if (!state.haveCursorPos)
 | 
					  if (!state.haveCursorPos)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
 | 
					    state.cursorInView = true;
 | 
				
			||||||
    spice_mouse_motion(delta.x, delta.y);
 | 
					    spice_mouse_motion(delta.x, delta.y);
 | 
				
			||||||
 | 
					    if ((state.haveCursorPos || state.grabMouse) &&
 | 
				
			||||||
 | 
					        (ex < 100 || ex > state.windowW - 100 ||
 | 
				
			||||||
 | 
					         ey < 100 || ey > state.windowH - 100))
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      warpMouse(state.windowW / 2, state.windowH / 2);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -851,7 +841,6 @@ static void handleMouseMoveEvent(int ex, int ey)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    if (params.useSpiceInput && !params.alwaysShowCursor)
 | 
					    if (params.useSpiceInput && !params.alwaysShowCursor)
 | 
				
			||||||
      state.drawCursor = false;
 | 
					      state.drawCursor = false;
 | 
				
			||||||
    return;
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!state.cursorInView)
 | 
					  if (!state.cursorInView)
 | 
				
			||||||
@@ -881,6 +870,14 @@ static void handleMouseMoveEvent(int ex, int ey)
 | 
				
			|||||||
    state.sensY -= delta.y;
 | 
					    state.sensY -= delta.y;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if ((state.haveCursorPos || state.grabMouse) &&
 | 
				
			||||||
 | 
					      (ex < 100 || ex > state.windowW - 100 ||
 | 
				
			||||||
 | 
					       ey < 100 || ey > state.windowH - 100))
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    warpMouse(state.windowW / 2, state.windowH / 2);
 | 
				
			||||||
 | 
					    return;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!state.grabMouse && state.warpState == WARP_STATE_ON)
 | 
					  if (!state.grabMouse && state.warpState == WARP_STATE_ON)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    /* check if the movement would exit the window */
 | 
					    /* check if the movement would exit the window */
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user