(Wayland) Mouse grab cleanup (#15114)

This commit is contained in:
Colin Kinloch 2023-03-21 13:36:24 +00:00 committed by GitHub
parent 90694a3cf1
commit d2c40b48ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 55 deletions

View File

@ -84,12 +84,6 @@ static void input_wl_poll(void *data)
if (wl->gfx->locked_pointer)
{
/* Get effective 'absolute' pointer location
* (last position + delta, bounded by current
* application window dimensions) */
wl->mouse.x += wl->mouse.delta_x;
wl->mouse.y += wl->mouse.delta_y;
/* Clamp X */
if (wl->mouse.x < 0)
wl->mouse.x = 0;
@ -311,6 +305,7 @@ static int16_t input_wl_state(
struct video_viewport vp;
bool screen =
(device == RARCH_DEVICE_POINTER_SCREEN);
bool inside = false;
int16_t res_x = 0;
int16_t res_y = 0;
int16_t res_screen_x = 0;
@ -327,26 +322,22 @@ static int16_t input_wl_state(
wl->mouse.x, wl->mouse.y,
&res_x, &res_y, &res_screen_x, &res_screen_y))
{
if (screen)
{
res_x = res_screen_x;
res_y = res_screen_y;
}
inside = (res_x >= -0x7fff) && (res_y >= -0x7fff);
if (!inside)
return 0;
switch (id)
{
case RETRO_DEVICE_ID_POINTER_X:
if (screen)
{
res_x = res_screen_x;
res_y = res_screen_y;
}
if ((res_x >= -0x7fff) && (res_y >= -0x7fff)) /* Inside? */
return res_x;
break;
case RETRO_DEVICE_ID_POINTER_Y:
if (screen)
{
res_x = res_screen_x;
res_y = res_screen_y;
}
if ((res_x >= -0x7fff) && (res_y >= -0x7fff)) /* Inside? */
return res_y;
break;
case RETRO_DEVICE_ID_POINTER_PRESSED:
return wl->mouse.left;
case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN:
@ -431,7 +422,6 @@ static uint64_t input_wl_get_capabilities(void *data)
static void input_wl_grab_mouse(void *data, bool state)
{
input_ctx_wayland_data_t *wl = (input_ctx_wayland_data_t*)data;
gfx_ctx_wayland_data_t *gfx = (gfx_ctx_wayland_data_t*)wl->gfx;
if (gfx->pointer_constraints)