shadow: improve pointer updates

This commit is contained in:
Marc-André Moreau 2014-11-07 13:51:10 -05:00
parent a538e791b3
commit 04299bb18b
5 changed files with 72 additions and 26 deletions

View File

@ -87,6 +87,9 @@ struct rdp_shadow_client
rdpShadowEncoder* encoder;
rdpShadowSubsystem* subsystem;
UINT32 pointerX;
UINT32 pointerY;
HANDLE vcm;
EncomspServerContext* encomsp;
RemdeskServerContext* remdesk;
@ -145,6 +148,8 @@ struct _RDP_SHADOW_ENTRY_POINTS
REGION16 invalidRegion; \
wMessagePipe* MsgPipe; \
SYNCHRONIZATION_BARRIER barrier; \
UINT32 pointerX; \
UINT32 pointerY; \
\
pfnShadowSynchronizeEvent SynchronizeEvent; \
pfnShadowKeyboardEvent KeyboardEvent; \

View File

@ -231,11 +231,13 @@ void x11_shadow_input_keyboard_event(x11ShadowSubsystem* subsystem, UINT16 flags
XTestGrabControl(subsystem->display, True);
if (flags & KBD_FLAGS_DOWN)
XTestFakeKeyEvent(subsystem->display, keycode, True, 0);
XTestFakeKeyEvent(subsystem->display, keycode, True, CurrentTime);
else if (flags & KBD_FLAGS_RELEASE)
XTestFakeKeyEvent(subsystem->display, keycode, False, 0);
XTestFakeKeyEvent(subsystem->display, keycode, False, CurrentTime);
XTestGrabControl(subsystem->display, False);
XFlush(subsystem->display);
}
#endif
}
@ -276,13 +278,13 @@ void x11_shadow_input_mouse_event(x11ShadowSubsystem* subsystem, UINT16 flags, U
button = (negative) ? 5 : 4;
XTestFakeButtonEvent(subsystem->display, button, True, 0);
XTestFakeButtonEvent(subsystem->display, button, False, 0);
XTestFakeButtonEvent(subsystem->display, button, True, CurrentTime);
XTestFakeButtonEvent(subsystem->display, button, False, CurrentTime);
}
else
{
if (flags & PTR_FLAGS_MOVE)
XTestFakeMotionEvent(subsystem->display, 0, x, y, 0);
XTestFakeMotionEvent(subsystem->display, 0, x, y, CurrentTime);
if (flags & PTR_FLAGS_BUTTON1)
button = 1;
@ -295,10 +297,12 @@ void x11_shadow_input_mouse_event(x11ShadowSubsystem* subsystem, UINT16 flags, U
down = TRUE;
if (button)
XTestFakeButtonEvent(subsystem->display, button, down, 0);
XTestFakeButtonEvent(subsystem->display, button, down, CurrentTime);
}
XTestGrabControl(subsystem->display, False);
XFlush(subsystem->display);
#endif
}
@ -335,9 +339,11 @@ void x11_shadow_input_extended_mouse_event(x11ShadowSubsystem* subsystem, UINT16
down = TRUE;
if (button)
XTestFakeButtonEvent(subsystem->display, button, down, 0);
XTestFakeButtonEvent(subsystem->display, button, down, CurrentTime);
XTestGrabControl(subsystem->display, False);
XFlush(subsystem->display);
#endif
}
@ -352,8 +358,8 @@ int x11_shadow_pointer_position_update(x11ShadowSubsystem* subsystem)
if (!msg)
return -1;
msg->xPos = subsystem->cursorX;
msg->yPos = subsystem->cursorY;
msg->xPos = subsystem->pointerX;
msg->yPos = subsystem->pointerY;
MessageQueue_Post(MsgPipe->Out, NULL, msgId, (void*) msg, NULL);
@ -407,6 +413,9 @@ int x11_shadow_query_cursor(x11ShadowSubsystem* subsystem, BOOL getImage)
ci = XFixesGetCursorImage(subsystem->display);
if (!ci)
return -1;
x = ci->x;
y = ci->y;
@ -455,10 +464,13 @@ int x11_shadow_query_cursor(x11ShadowSubsystem* subsystem, BOOL getImage)
y = root_y;
}
subsystem->cursorX = x;
subsystem->cursorY = y;
if ((x != subsystem->pointerX) || (y != subsystem->pointerY))
{
subsystem->pointerX = x;
subsystem->pointerY = y;
x11_shadow_pointer_position_update(subsystem);
x11_shadow_pointer_position_update(subsystem);
}
return 1;
}
@ -469,13 +481,16 @@ int x11_shadow_handle_xevent(x11ShadowSubsystem* subsystem, XEvent* xevent)
{
}
#ifdef WITH_XFIXES
if (xevent->type == subsystem->xfixes_cursor_notify_event)
else if (xevent->type == subsystem->xfixes_cursor_notify_event)
{
x11_shadow_query_cursor(subsystem, TRUE);
}
#endif
else
{
}
return 1;
}
@ -526,8 +541,8 @@ int x11_shadow_blend_cursor(x11ShadowSubsystem* subsystem)
nWidth = subsystem->cursorWidth;
nHeight = subsystem->cursorHeight;
nXDst = subsystem->cursorX - surface->x - subsystem->cursorHotX;
nYDst = subsystem->cursorY - surface->y - subsystem->cursorHotY;
nXDst = subsystem->pointerX - surface->x - subsystem->cursorHotX;
nYDst = subsystem->pointerY - surface->y - subsystem->cursorHotY;
if (nXDst >= surface->width)
return 1;
@ -820,8 +835,8 @@ void* x11_shadow_subsystem_thread(x11ShadowSubsystem* subsystem)
if ((status == WAIT_TIMEOUT) || (GetTickCount64() > frameTime))
{
x11_shadow_query_cursor(subsystem, FALSE);
x11_shadow_screen_grab(subsystem);
x11_shadow_query_cursor(subsystem, FALSE);
dwInterval = 1000 / subsystem->captureFrameRate;
frameTime += dwInterval;
@ -857,7 +872,7 @@ int x11_shadow_subsystem_base_init(x11ShadowSubsystem* subsystem)
subsystem->depth = DefaultDepthOfScreen(subsystem->screen);
subsystem->width = WidthOfScreen(subsystem->screen);
subsystem->height = HeightOfScreen(subsystem->screen);
subsystem->root_window = DefaultRootWindow(subsystem->display);
subsystem->root_window = RootWindow(subsystem->display, subsystem->number);
return 1;
}
@ -877,7 +892,8 @@ int x11_shadow_xfixes_init(x11ShadowSubsystem* subsystem)
subsystem->xfixes_cursor_notify_event = xfixes_event + XFixesCursorNotify;
XFixesSelectCursorInput(subsystem->display, DefaultRootWindow(subsystem->display), XFixesDisplayCursorNotifyMask);
XFixesSelectCursorInput(subsystem->display, subsystem->root_window,
XFixesDisplayCursorNotifyMask);
return 1;
#else

View File

@ -80,8 +80,6 @@ struct x11_shadow_subsystem
Window root_window;
XShmSegmentInfo fb_shm_info;
int cursorX;
int cursorY;
int cursorHotX;
int cursorHotY;
int cursorWidth;

View File

@ -56,6 +56,8 @@ void shadow_client_context_new(freerdp_peer* peer, rdpShadowClient* client)
settings->DrawAllowColorSubsampling = TRUE;
settings->DrawAllowDynamicColorFidelity = TRUE;
settings->CompressionLevel = PACKET_COMPR_TYPE_RDP6;
settings->RdpSecurity = TRUE;
settings->TlsSecurity = TRUE;
settings->NlaSecurity = FALSE;
@ -830,9 +832,12 @@ int shadow_client_subsystem_process_message(rdpShadowClient* client, wMessage* m
pointerPosition.xPos = msg->xPos;
pointerPosition.yPos = msg->yPos;
if (0)
if ((msg->xPos != client->pointerX) || (msg->yPos != client->pointerY))
{
IFCALL(update->pointer->PointerPosition, context, &pointerPosition);
client->pointerX = msg->xPos;
client->pointerY = msg->yPos;
}
free(msg);
@ -841,6 +846,7 @@ int shadow_client_subsystem_process_message(rdpShadowClient* client, wMessage* m
{
POINTER_NEW_UPDATE pointerNew;
POINTER_COLOR_UPDATE* pointerColor;
POINTER_CACHED_UPDATE pointerCached;
SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE* msg = (SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE*) message->wParam;
ZeroMemory(&pointerNew, sizeof(POINTER_NEW_UPDATE));
@ -854,13 +860,16 @@ int shadow_client_subsystem_process_message(rdpShadowClient* client, wMessage* m
pointerColor->width = msg->width;
pointerColor->height = msg->height;
pointerCached.cacheIndex = pointerColor->cacheIndex;
shadow_client_convert_alpha_pointer_data(msg->pixels, msg->premultiplied,
msg->width, msg->height, pointerColor);
if (0)
{
IFCALL(update->pointer->PointerNew, context, &pointerNew);
}
IFCALL(update->pointer->PointerNew, context, &pointerNew);
IFCALL(update->pointer->PointerCached, context, &pointerCached);
free(pointerColor->xorMaskData);
free(pointerColor->andMaskData);
free(msg->pixels);
free(msg);

View File

@ -69,6 +69,21 @@ void shadow_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
rdpShadowClient* client = (rdpShadowClient*) input->context;
rdpShadowSubsystem* subsystem = client->server->subsystem;
if (!(flags & PTR_FLAGS_WHEEL))
{
client->pointerX = x;
client->pointerY = y;
if ((client->pointerX == subsystem->pointerX) &&
(client->pointerY == subsystem->pointerY))
{
flags &= ~PTR_FLAGS_MOVE;
if (!(flags & (PTR_FLAGS_BUTTON1 | PTR_FLAGS_BUTTON2 | PTR_FLAGS_BUTTON3)))
return;
}
}
if (!client->mayInteract)
return;
@ -83,6 +98,9 @@ void shadow_input_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x,
rdpShadowClient* client = (rdpShadowClient*) input->context;
rdpShadowSubsystem* subsystem = client->server->subsystem;
client->pointerX = x;
client->pointerY = y;
if (!client->mayInteract)
return;