mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 05:27:20 +00:00
[client] more cursor tweaks for better integration with the WM
This commit is contained in:
parent
80f3c7934a
commit
05dc713dac
@ -271,6 +271,18 @@ static int cursorThread(void * unused)
|
|||||||
{
|
{
|
||||||
if (status == LGMP_ERR_QUEUE_EMPTY)
|
if (status == LGMP_ERR_QUEUE_EMPTY)
|
||||||
{
|
{
|
||||||
|
if (state.updateCursor)
|
||||||
|
{
|
||||||
|
state.updateCursor = false;
|
||||||
|
state.lgr->on_mouse_event
|
||||||
|
(
|
||||||
|
state.lgrData,
|
||||||
|
state.cursorVisible && state.drawCursor,
|
||||||
|
state.cursor.x,
|
||||||
|
state.cursor.y
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
usleep(params.cursorPollInterval);
|
usleep(params.cursorPollInterval);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -284,11 +296,12 @@ static int cursorThread(void * unused)
|
|||||||
state.cursor.x = cursor->x;
|
state.cursor.x = cursor->x;
|
||||||
state.cursor.y = cursor->y;
|
state.cursor.y = cursor->y;
|
||||||
state.cursorVisible = cursor->visible;
|
state.cursorVisible = cursor->visible;
|
||||||
|
state.haveCursorPos = true;
|
||||||
|
|
||||||
if (!state.haveCursorPos)
|
if (!state.haveAligned && state.haveSrcSize && state.haveCurLocal)
|
||||||
{
|
{
|
||||||
state.haveCursorPos = true;
|
|
||||||
alignMouseWithHost();
|
alignMouseWithHost();
|
||||||
|
state.haveAligned = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg.udata == 1)
|
if (msg.udata == 1)
|
||||||
@ -321,10 +334,11 @@ static int cursorThread(void * unused)
|
|||||||
}
|
}
|
||||||
|
|
||||||
lgmpClientMessageDone(queue);
|
lgmpClientMessageDone(queue);
|
||||||
|
state.updateCursor = false;
|
||||||
state.lgr->on_mouse_event
|
state.lgr->on_mouse_event
|
||||||
(
|
(
|
||||||
state.lgrData,
|
state.lgrData,
|
||||||
state.cursorVisible,
|
state.cursorVisible && state.drawCursor,
|
||||||
state.cursor.x,
|
state.cursor.x,
|
||||||
state.cursor.y
|
state.cursor.y
|
||||||
);
|
);
|
||||||
@ -424,7 +438,6 @@ static int frameThread(void * unused)
|
|||||||
SDL_SetWindowSize(state.window, frame->width, frame->height);
|
SDL_SetWindowSize(state.window, frame->width, frame->height);
|
||||||
|
|
||||||
updatePositionInfo();
|
updatePositionInfo();
|
||||||
alignMouseWithGuest();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FrameBuffer fb = (FrameBuffer)(frame + 1);
|
FrameBuffer fb = (FrameBuffer)(frame + 1);
|
||||||
@ -636,12 +649,13 @@ static void handleMouseMoveEvent(int ex, int ey)
|
|||||||
static bool wrapping = false;
|
static bool wrapping = false;
|
||||||
static int wrapX, wrapY;
|
static int wrapX, wrapY;
|
||||||
|
|
||||||
|
state.curLocalX = ex;
|
||||||
|
state.curLocalY = ey;
|
||||||
|
state.haveCurLocal = true;
|
||||||
|
|
||||||
if (state.ignoreInput || !params.useSpiceInput)
|
if (state.ignoreInput || !params.useSpiceInput)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
state.curlocalX = ex;
|
|
||||||
state.curlocalY = ey;
|
|
||||||
|
|
||||||
if (state.serverMode)
|
if (state.serverMode)
|
||||||
{
|
{
|
||||||
if (wrapping)
|
if (wrapping)
|
||||||
@ -727,12 +741,12 @@ static void alignMouseWithHost()
|
|||||||
|
|
||||||
state.curLastX = (int)round((float)state.cursor.x / state.scaleX) + state.dstRect.x;
|
state.curLastX = (int)round((float)state.cursor.x / state.scaleX) + state.dstRect.x;
|
||||||
state.curLastY = (int)round((float)state.cursor.y / state.scaleY) + state.dstRect.y;
|
state.curLastY = (int)round((float)state.cursor.y / state.scaleY) + state.dstRect.y;
|
||||||
handleMouseMoveEvent(state.curlocalX, state.curlocalY);
|
handleMouseMoveEvent(state.curLocalX, state.curLocalY);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handleResizeEvent(unsigned int w, unsigned int h)
|
static void handleResizeEvent(unsigned int w, unsigned int h)
|
||||||
{
|
{
|
||||||
if (state.windowW == w || state.windowH == w)
|
if (state.windowW == w && state.windowH == h)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
state.windowW = w;
|
state.windowW = w;
|
||||||
@ -740,6 +754,25 @@ static void handleResizeEvent(unsigned int w, unsigned int h)
|
|||||||
updatePositionInfo();
|
updatePositionInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handleWindowLeave()
|
||||||
|
{
|
||||||
|
if (!params.useSpiceInput)
|
||||||
|
return;
|
||||||
|
|
||||||
|
state.drawCursor = false;
|
||||||
|
state.updateCursor = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handleWindowEnter()
|
||||||
|
{
|
||||||
|
if (!params.useSpiceInput)
|
||||||
|
return;
|
||||||
|
|
||||||
|
alignMouseWithHost();
|
||||||
|
state.drawCursor = true;
|
||||||
|
state.updateCursor = true;
|
||||||
|
}
|
||||||
|
|
||||||
int eventFilter(void * userdata, SDL_Event * event)
|
int eventFilter(void * userdata, SDL_Event * event)
|
||||||
{
|
{
|
||||||
switch(event->type)
|
switch(event->type)
|
||||||
@ -759,7 +792,13 @@ int eventFilter(void * userdata, SDL_Event * event)
|
|||||||
switch(event->window.event)
|
switch(event->window.event)
|
||||||
{
|
{
|
||||||
case SDL_WINDOWEVENT_ENTER:
|
case SDL_WINDOWEVENT_ENTER:
|
||||||
alignMouseWithHost();
|
if (state.wminfo.subsystem != SDL_SYSWM_X11)
|
||||||
|
handleWindowEnter();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDL_WINDOWEVENT_LEAVE:
|
||||||
|
if (state.wminfo.subsystem != SDL_SYSWM_X11)
|
||||||
|
handleWindowLeave();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||||
@ -793,6 +832,14 @@ int eventFilter(void * userdata, SDL_Event * event)
|
|||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
handleMouseMoveEvent(xe.xmotion.x, xe.xmotion.y);
|
handleMouseMoveEvent(xe.xmotion.x, xe.xmotion.y);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case EnterNotify:
|
||||||
|
handleWindowEnter();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LeaveNotify:
|
||||||
|
handleWindowLeave();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1083,6 +1130,7 @@ static int lg_run()
|
|||||||
state.scaleX = 1.0f;
|
state.scaleX = 1.0f;
|
||||||
state.scaleY = 1.0f;
|
state.scaleY = 1.0f;
|
||||||
state.resizeDone = true;
|
state.resizeDone = true;
|
||||||
|
state.drawCursor = true;
|
||||||
|
|
||||||
state.mouseSens = params.mouseSens;
|
state.mouseSens = params.mouseSens;
|
||||||
if (state.mouseSens < -9) state.mouseSens = -9;
|
if (state.mouseSens < -9) state.mouseSens = -9;
|
||||||
|
@ -46,12 +46,16 @@ struct AppState
|
|||||||
|
|
||||||
bool serverMode;
|
bool serverMode;
|
||||||
bool haveCursorPos;
|
bool haveCursorPos;
|
||||||
|
bool drawCursor;
|
||||||
|
bool updateCursor;
|
||||||
float scaleX, scaleY;
|
float scaleX, scaleY;
|
||||||
float accX, accY;
|
float accX, accY;
|
||||||
int curLastX;
|
int curLastX;
|
||||||
int curLastY;
|
int curLastY;
|
||||||
int curlocalX;
|
bool haveCurLocal;
|
||||||
int curlocalY;
|
int curLocalX;
|
||||||
|
int curLocalY;
|
||||||
|
bool haveAligned;
|
||||||
|
|
||||||
const LG_Renderer * lgr;
|
const LG_Renderer * lgr;
|
||||||
void * lgrData;
|
void * lgrData;
|
||||||
|
Loading…
Reference in New Issue
Block a user