[client] ds: refactor app and cursor state into app.c and core.c

This commit is contained in:
Geoffrey McRae
2021-01-29 05:13:26 +11:00
parent 33fed48277
commit 4e1c0cc0d0
7 changed files with 210 additions and 219 deletions

View File

@@ -297,10 +297,8 @@ static int sdlEventFilter(void * userdata, SDL_Event * event)
break;
app_updateCursorPos(event->motion.x, event->motion.y);
if (app_cursorIsGrabbed())
app_handleMouseGrabbed(event->motion.xrel, event->motion.yrel);
else
app_handleMouseNormal(event->motion.xrel, event->motion.yrel);
app_handleMouseRelitive(event->motion.xrel, event->motion.yrel,
event->motion.xrel, event->motion.yrel);
break;
case SDL_MOUSEBUTTONDOWN:
@@ -457,8 +455,7 @@ static void sdlWarpPointer(int x, int y, bool exiting)
static void sdlRealignPointer(void)
{
// no need to care about grab, realign only happens in normal mode
app_handleMouseNormal(0, 0);
app_handleMouseRelitive(0.0, 0.0, 0.0, 0.0);
}
static bool sdlIsValidPointerPos(int x, int y)

View File

@@ -808,7 +808,7 @@ static void x11GenericEvent(XGenericEventCookie *cookie)
app_updateCursorPos(device->event_x, device->event_y);
if (!x11.pointerGrabbed)
app_handleMouseNormal(0.0, 0.0);
app_handleMouseRelitive(0.0, 0.0, 0.0, 0.0);
return;
}
@@ -857,17 +857,7 @@ static void x11GenericEvent(XGenericEventCookie *cookie)
prev_axis[0] = axis[0];
prev_axis[1] = axis[1];
if (app_cursorIsGrabbed())
{
if (app_cursorWantsRaw())
app_handleMouseGrabbed(raw_axis[0], raw_axis[1]);
else
app_handleMouseGrabbed(axis[0], axis[1]);
}
else
if (app_cursorInWindow())
app_handleMouseNormal(axis[0], axis[1]);
app_handleMouseRelitive(axis[0], axis[1], raw_axis[0], raw_axis[1]);
return;
}
}
@@ -1077,7 +1067,7 @@ static void x11WarpPointer(int x, int y, bool exiting)
static void x11RealignPointer(void)
{
app_handleMouseNormal(0, 0);
app_handleMouseRelitive(0.0, 0.0, 0.0, 0.0);
}
static bool x11IsValidPointerPos(int x, int y)