[client] move remaining code in core.c into the SDL backend

This commit is contained in:
Geoffrey McRae
2021-01-25 20:32:02 +11:00
parent bf583290a4
commit 6b1e310343
8 changed files with 53 additions and 35 deletions

View File

@@ -457,7 +457,7 @@ void app_handleMouseNormal(double ex, double ey)
const int tx = (local.x <= 0.0) ? floor(local.x) : ceil(local.x);
const int ty = (local.y <= 0.0) ? floor(local.y) : ceil(local.y);
if (util_isValidCursorLocation(
if (core_isValidPointerPos(
g_state.windowPos.x + g_state.border.x + tx,
g_state.windowPos.y + g_state.border.y + ty))
{

View File

@@ -57,7 +57,7 @@ void core_setCursorInView(bool enable)
if (enable)
{
if (g_params.hideMouse)
SDL_ShowCursor(SDL_DISABLE);
g_state.ds->showPointer(false);
if (warpSupport && !g_params.captureInputOnly)
g_state.ds->grabPointer();
@@ -65,7 +65,7 @@ void core_setCursorInView(bool enable)
else
{
if (g_params.hideMouse)
SDL_ShowCursor(SDL_ENABLE);
g_state.ds->showPointer(true);
if (warpSupport)
g_state.ds->ungrabPointer();
@@ -90,7 +90,7 @@ void core_setGrabQuiet(bool enable)
{
/* we always do this so that at init the cursor is in the right state */
if (g_params.captureInputOnly && g_params.hideMouse)
SDL_ShowCursor(enable ? SDL_DISABLE : SDL_ENABLE);
g_state.ds->showPointer(!enable);
if (g_cursor.grab == enable)
return;
@@ -260,3 +260,8 @@ void core_alignToGuest(void)
if (core_warpPointer(round(local.x), round(local.y), false))
core_setCursorInView(true);
}
bool core_isValidPointerPos(int x, int y)
{
return g_state.ds->isValidPointerPos(x, y);
}

View File

@@ -28,5 +28,6 @@ void core_setGrabQuiet(bool enable);
bool core_warpPointer(int x, int y, bool exiting);
void core_updatePositionInfo(void);
void core_alignToGuest(void);
bool core_isValidPointerPos(int x, int y);
#endif

View File

@@ -831,10 +831,12 @@ static int lg_run(void)
SET_FALLBACK(shutdown);
SET_FALLBACK(free);
SET_FALLBACK(eventFilter);
SET_FALLBACK(showPointer);
SET_FALLBACK(grabPointer);
SET_FALLBACK(ungrabKeyboard);
SET_FALLBACK(warpPointer);
SET_FALLBACK(realignPointer);
SET_FALLBACK(isValidPointerPos);
SET_FALLBACK(inhibitIdle);
SET_FALLBACK(uninhibitIdle);
SET_FALLBACK(cbInit);

View File

@@ -206,17 +206,3 @@ void util_rotatePoint(struct DoublePoint *point)
break;
}
}
bool util_isValidCursorLocation(int x, int y)
{
const int displays = SDL_GetNumVideoDisplays();
for(int i = 0; i < displays; ++i)
{
SDL_Rect r;
SDL_GetDisplayBounds(i, &r);
if ((x >= r.x && x < r.x + r.w) &&
(y >= r.y && y < r.y + r.h))
return true;
}
return false;
}