mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-10 08:38:20 +00:00
[client] move remaining code in core.c
into the SDL backend
This commit is contained in:
parent
bf583290a4
commit
6b1e310343
@ -163,6 +163,11 @@ static bool sdlEventFilter(SDL_Event * event)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void sdlShowPointer(bool show)
|
||||||
|
{
|
||||||
|
SDL_ShowCursor(show ? SDL_ENABLE : SDL_DISABLE);
|
||||||
|
}
|
||||||
|
|
||||||
static void sdlGrabPointer(void)
|
static void sdlGrabPointer(void)
|
||||||
{
|
{
|
||||||
SDL_SetWindowGrab(app_getWindow(), SDL_TRUE);
|
SDL_SetWindowGrab(app_getWindow(), SDL_TRUE);
|
||||||
@ -222,6 +227,20 @@ static void sdlRealignPointer(void)
|
|||||||
app_handleMouseNormal(0, 0);
|
app_handleMouseNormal(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool sdlIsValidPointerPos(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;
|
||||||
|
}
|
||||||
|
|
||||||
static void sdlInhibitIdle(void)
|
static void sdlInhibitIdle(void)
|
||||||
{
|
{
|
||||||
SDL_DisableScreenSaver();
|
SDL_DisableScreenSaver();
|
||||||
@ -242,12 +261,14 @@ struct LG_DisplayServerOps LGDS_SDL =
|
|||||||
.free = sdlFree,
|
.free = sdlFree,
|
||||||
.getProp = sdlGetProp,
|
.getProp = sdlGetProp,
|
||||||
.eventFilter = sdlEventFilter,
|
.eventFilter = sdlEventFilter,
|
||||||
|
.showPointer = sdlShowPointer,
|
||||||
.grabPointer = sdlGrabPointer,
|
.grabPointer = sdlGrabPointer,
|
||||||
.ungrabPointer = sdlUngrabPointer,
|
.ungrabPointer = sdlUngrabPointer,
|
||||||
.grabKeyboard = sdlGrabKeyboard,
|
.grabKeyboard = sdlGrabKeyboard,
|
||||||
.ungrabKeyboard = sdlUngrabKeyboard,
|
.ungrabKeyboard = sdlUngrabKeyboard,
|
||||||
.warpPointer = sdlWarpPointer,
|
.warpPointer = sdlWarpPointer,
|
||||||
.realignPointer = sdlRealignPointer,
|
.realignPointer = sdlRealignPointer,
|
||||||
|
.isValidPointerPos = sdlIsValidPointerPos,
|
||||||
.inhibitIdle = sdlInhibitIdle,
|
.inhibitIdle = sdlInhibitIdle,
|
||||||
.uninhibitIdle = sdlUninhibitIdle,
|
.uninhibitIdle = sdlUninhibitIdle,
|
||||||
|
|
||||||
|
@ -87,6 +87,7 @@ struct LG_DisplayServerOps
|
|||||||
bool (*eventFilter)(SDL_Event * event);
|
bool (*eventFilter)(SDL_Event * event);
|
||||||
|
|
||||||
/* dm specific cursor implementations */
|
/* dm specific cursor implementations */
|
||||||
|
void (*showPointer)(bool show);
|
||||||
void (*grabPointer)();
|
void (*grabPointer)();
|
||||||
void (*ungrabPointer)();
|
void (*ungrabPointer)();
|
||||||
void (*grabKeyboard)();
|
void (*grabKeyboard)();
|
||||||
@ -100,6 +101,9 @@ struct LG_DisplayServerOps
|
|||||||
* deltas */
|
* deltas */
|
||||||
void (*realignPointer)();
|
void (*realignPointer)();
|
||||||
|
|
||||||
|
/* returns true if the position specified is actually valid */
|
||||||
|
bool (*isValidPointerPos)(int x, int y);
|
||||||
|
|
||||||
/* called to disable/enable the screensaver */
|
/* called to disable/enable the screensaver */
|
||||||
void (*inhibitIdle)();
|
void (*inhibitIdle)();
|
||||||
void (*uninhibitIdle)();
|
void (*uninhibitIdle)();
|
||||||
|
@ -32,6 +32,5 @@ void util_cursorToInt(double ex, double ey, int *x, int *y);
|
|||||||
bool util_guestCurToLocal(struct DoublePoint *local);
|
bool util_guestCurToLocal(struct DoublePoint *local);
|
||||||
void util_localCurToGuest(struct DoublePoint *guest);
|
void util_localCurToGuest(struct DoublePoint *guest);
|
||||||
void util_rotatePoint(struct DoublePoint *point);
|
void util_rotatePoint(struct DoublePoint *point);
|
||||||
bool util_isValidCursorLocation(int x, int y);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -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 tx = (local.x <= 0.0) ? floor(local.x) : ceil(local.x);
|
||||||
const int ty = (local.y <= 0.0) ? floor(local.y) : ceil(local.y);
|
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.x + g_state.border.x + tx,
|
||||||
g_state.windowPos.y + g_state.border.y + ty))
|
g_state.windowPos.y + g_state.border.y + ty))
|
||||||
{
|
{
|
||||||
|
@ -57,7 +57,7 @@ void core_setCursorInView(bool enable)
|
|||||||
if (enable)
|
if (enable)
|
||||||
{
|
{
|
||||||
if (g_params.hideMouse)
|
if (g_params.hideMouse)
|
||||||
SDL_ShowCursor(SDL_DISABLE);
|
g_state.ds->showPointer(false);
|
||||||
|
|
||||||
if (warpSupport && !g_params.captureInputOnly)
|
if (warpSupport && !g_params.captureInputOnly)
|
||||||
g_state.ds->grabPointer();
|
g_state.ds->grabPointer();
|
||||||
@ -65,7 +65,7 @@ void core_setCursorInView(bool enable)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (g_params.hideMouse)
|
if (g_params.hideMouse)
|
||||||
SDL_ShowCursor(SDL_ENABLE);
|
g_state.ds->showPointer(true);
|
||||||
|
|
||||||
if (warpSupport)
|
if (warpSupport)
|
||||||
g_state.ds->ungrabPointer();
|
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 */
|
/* we always do this so that at init the cursor is in the right state */
|
||||||
if (g_params.captureInputOnly && g_params.hideMouse)
|
if (g_params.captureInputOnly && g_params.hideMouse)
|
||||||
SDL_ShowCursor(enable ? SDL_DISABLE : SDL_ENABLE);
|
g_state.ds->showPointer(!enable);
|
||||||
|
|
||||||
if (g_cursor.grab == enable)
|
if (g_cursor.grab == enable)
|
||||||
return;
|
return;
|
||||||
@ -260,3 +260,8 @@ void core_alignToGuest(void)
|
|||||||
if (core_warpPointer(round(local.x), round(local.y), false))
|
if (core_warpPointer(round(local.x), round(local.y), false))
|
||||||
core_setCursorInView(true);
|
core_setCursorInView(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool core_isValidPointerPos(int x, int y)
|
||||||
|
{
|
||||||
|
return g_state.ds->isValidPointerPos(x, y);
|
||||||
|
}
|
||||||
|
@ -28,5 +28,6 @@ void core_setGrabQuiet(bool enable);
|
|||||||
bool core_warpPointer(int x, int y, bool exiting);
|
bool core_warpPointer(int x, int y, bool exiting);
|
||||||
void core_updatePositionInfo(void);
|
void core_updatePositionInfo(void);
|
||||||
void core_alignToGuest(void);
|
void core_alignToGuest(void);
|
||||||
|
bool core_isValidPointerPos(int x, int y);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -831,10 +831,12 @@ static int lg_run(void)
|
|||||||
SET_FALLBACK(shutdown);
|
SET_FALLBACK(shutdown);
|
||||||
SET_FALLBACK(free);
|
SET_FALLBACK(free);
|
||||||
SET_FALLBACK(eventFilter);
|
SET_FALLBACK(eventFilter);
|
||||||
|
SET_FALLBACK(showPointer);
|
||||||
SET_FALLBACK(grabPointer);
|
SET_FALLBACK(grabPointer);
|
||||||
SET_FALLBACK(ungrabKeyboard);
|
SET_FALLBACK(ungrabKeyboard);
|
||||||
SET_FALLBACK(warpPointer);
|
SET_FALLBACK(warpPointer);
|
||||||
SET_FALLBACK(realignPointer);
|
SET_FALLBACK(realignPointer);
|
||||||
|
SET_FALLBACK(isValidPointerPos);
|
||||||
SET_FALLBACK(inhibitIdle);
|
SET_FALLBACK(inhibitIdle);
|
||||||
SET_FALLBACK(uninhibitIdle);
|
SET_FALLBACK(uninhibitIdle);
|
||||||
SET_FALLBACK(cbInit);
|
SET_FALLBACK(cbInit);
|
||||||
|
@ -206,17 +206,3 @@ void util_rotatePoint(struct DoublePoint *point)
|
|||||||
break;
|
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;
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user