xfreerdp-server: fix event queuing

This commit is contained in:
Marc-André Moreau 2012-01-31 16:28:23 -05:00
parent d2a96e99d5
commit cfd54a4e38
2 changed files with 13 additions and 10 deletions

View File

@ -80,8 +80,8 @@ void xf_event_push(xfEventQueue* event_queue, xfEvent* event)
if (event_queue->count >= event_queue->size)
{
event_queue->size = event_queue->size * 2;
event_queue->events = xrealloc((void*) event_queue->events, event_queue->size);
event_queue->size *= 2;
event_queue->events = (xfEvent**) xrealloc((void*) event_queue->events, sizeof(xfEvent*) * event_queue->size);
}
event_queue->events[(event_queue->count)++] = event;
@ -109,7 +109,6 @@ xfEvent* xf_event_peek(xfEventQueue* event_queue)
xfEvent* xf_event_pop(xfEventQueue* event_queue)
{
int i;
xfEvent* event;
pthread_mutex_lock(&(event_queue->mutex));
@ -120,8 +119,7 @@ xfEvent* xf_event_pop(xfEventQueue* event_queue)
event = event_queue->events[0];
(event_queue->count)--;
for (i = 0; i < event_queue->count; i++)
event_queue->events[i] = event_queue->events[i + 1];
memmove(&event_queue->events[0], &event_queue->events[1], event_queue->count * sizeof(void*));
pthread_mutex_unlock(&(event_queue->mutex));

View File

@ -237,7 +237,7 @@ xfInfo* xf_info_init()
}
XFree(vis);
xfi->clrconv = (HCLRCONV) xnew(HCLRCONV);
xfi->clrconv = (HCLRCONV) xnew(CLRCONV);
xfi->clrconv->invert = 1;
xfi->clrconv->alpha = 1;
@ -315,6 +315,7 @@ void* xf_monitor_graphics(void* param)
XRectangle region;
xfPeerContext* xfp;
freerdp_peer* client;
int pending_events = 0;
int x, y, width, height;
XDamageNotifyEvent* notify;
xfEventRegion* event_region;
@ -330,11 +331,15 @@ void* xf_monitor_graphics(void* param)
while (1)
{
pthread_mutex_lock(&(xfp->mutex));
pending_events = XPending(xfi->display);
pthread_mutex_unlock(&(xfp->mutex));
while (XPending(xfi->display))
if (pending_events > 0)
{
pthread_mutex_lock(&(xfp->mutex));
memset(&xevent, 0, sizeof(xevent));
XNextEvent(xfi->display, &xevent);
pthread_mutex_unlock(&(xfp->mutex));
if (xevent.type == xfi->xdamage_notify_event)
{
@ -351,8 +356,10 @@ void* xf_monitor_graphics(void* param)
region.height = height;
#ifdef WITH_XFIXES
pthread_mutex_lock(&(xfp->mutex));
XFixesSetRegion(xfi->display, xfi->xdamage_region, &region, 1);
XDamageSubtract(xfi->display, xfi->xdamage, xfi->xdamage_region, None);
pthread_mutex_unlock(&(xfp->mutex));
#endif
event_region = xf_event_region_new(x, y, width, height);
@ -360,9 +367,7 @@ void* xf_monitor_graphics(void* param)
}
}
pthread_mutex_unlock(&(xfp->mutex));
freerdp_usleep(30);
freerdp_usleep(10);
}
return NULL;