xfreerdp-server: fix XShm auto-detection and fallback
This commit is contained in:
parent
d46dfabcfb
commit
0b57157065
@ -54,31 +54,11 @@
|
|||||||
|
|
||||||
void xf_xdamage_init(xfInfo* xfi)
|
void xf_xdamage_init(xfInfo* xfi)
|
||||||
{
|
{
|
||||||
Bool pixmaps;
|
|
||||||
int damage_event;
|
int damage_event;
|
||||||
int damage_error;
|
int damage_error;
|
||||||
int major, minor;
|
int major, minor;
|
||||||
XGCValues values;
|
XGCValues values;
|
||||||
|
|
||||||
if (xfi->use_xshm)
|
|
||||||
{
|
|
||||||
if (XShmQueryExtension(xfi->display) != False)
|
|
||||||
{
|
|
||||||
XShmQueryVersion(xfi->display, &major, &minor, &pixmaps);
|
|
||||||
|
|
||||||
if (pixmaps != True)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "XShmQueryVersion failed\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf(stderr, "XShmQueryExtension failed\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (XDamageQueryExtension(xfi->display, &damage_event, &damage_error) == 0)
|
if (XDamageQueryExtension(xfi->display, &damage_event, &damage_error) == 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "XDamageQueryExtension failed\n");
|
fprintf(stderr, "XDamageQueryExtension failed\n");
|
||||||
@ -128,6 +108,25 @@ void xf_xdamage_init(xfInfo* xfi)
|
|||||||
|
|
||||||
int xf_xshm_init(xfInfo* xfi)
|
int xf_xshm_init(xfInfo* xfi)
|
||||||
{
|
{
|
||||||
|
Bool pixmaps;
|
||||||
|
int major, minor;
|
||||||
|
|
||||||
|
if (XShmQueryExtension(xfi->display) != False)
|
||||||
|
{
|
||||||
|
XShmQueryVersion(xfi->display, &major, &minor, &pixmaps);
|
||||||
|
|
||||||
|
if (pixmaps != True)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "XShmQueryVersion failed\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "XShmQueryExtension failed\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
xfi->fb_shm_info.shmid = -1;
|
xfi->fb_shm_info.shmid = -1;
|
||||||
xfi->fb_shm_info.shmaddr = (char*) -1;
|
xfi->fb_shm_info.shmaddr = (char*) -1;
|
||||||
|
|
||||||
@ -244,7 +243,7 @@ xfInfo* xf_info_init()
|
|||||||
|
|
||||||
vis = XGetVisualInfo(xfi->display, VisualClassMask | VisualScreenMask, &template, &vi_count);
|
vis = XGetVisualInfo(xfi->display, VisualClassMask | VisualScreenMask, &template, &vi_count);
|
||||||
|
|
||||||
if (vis == NULL)
|
if (!vis)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "XGetVisualInfo failed\n");
|
fprintf(stderr, "XGetVisualInfo failed\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -266,10 +265,6 @@ xfInfo* xf_info_init()
|
|||||||
|
|
||||||
XSelectInput(xfi->display, xfi->root_window, SubstructureNotifyMask);
|
XSelectInput(xfi->display, xfi->root_window, SubstructureNotifyMask);
|
||||||
|
|
||||||
#ifdef WITH_XDAMAGE
|
|
||||||
xf_xdamage_init(xfi);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (xfi->use_xshm)
|
if (xfi->use_xshm)
|
||||||
{
|
{
|
||||||
if (xf_xshm_init(xfi) < 0)
|
if (xf_xshm_init(xfi) < 0)
|
||||||
@ -279,6 +274,10 @@ xfInfo* xf_info_init()
|
|||||||
if (xfi->use_xshm)
|
if (xfi->use_xshm)
|
||||||
printf("Using X Shared Memory Extension (XShm)\n");
|
printf("Using X Shared Memory Extension (XShm)\n");
|
||||||
|
|
||||||
|
#ifdef WITH_XDAMAGE
|
||||||
|
xf_xdamage_init(xfi);
|
||||||
|
#endif
|
||||||
|
|
||||||
xfi->bytesPerPixel = 4;
|
xfi->bytesPerPixel = 4;
|
||||||
xfi->activePeerCount = 0;
|
xfi->activePeerCount = 0;
|
||||||
|
|
||||||
@ -305,7 +304,7 @@ void xf_peer_context_free(freerdp_peer* client, xfPeerContext* context)
|
|||||||
{
|
{
|
||||||
if (context)
|
if (context)
|
||||||
{
|
{
|
||||||
stream_free(context->s);
|
Stream_Free(context->s, TRUE);
|
||||||
rfx_context_free(context->rfx_context);
|
rfx_context_free(context->rfx_context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -333,21 +332,6 @@ void xf_peer_init(freerdp_peer* client)
|
|||||||
xfp->mutex = CreateMutex(NULL, FALSE, NULL);
|
xfp->mutex = CreateMutex(NULL, FALSE, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
wStream* xf_peer_stream_init(xfPeerContext* context)
|
|
||||||
{
|
|
||||||
Stream_Clear(context->s);
|
|
||||||
Stream_SetPosition(context->s, 0);
|
|
||||||
return context->s;
|
|
||||||
}
|
|
||||||
|
|
||||||
void xf_peer_live_rfx(freerdp_peer* client)
|
|
||||||
{
|
|
||||||
xfPeerContext* xfp = (xfPeerContext*) client->context;
|
|
||||||
|
|
||||||
xfp->monitorThread = CreateThread(NULL, 0,
|
|
||||||
(LPTHREAD_START_ROUTINE) xf_update_thread, (void*) client, 0, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void xf_peer_rfx_update(freerdp_peer* client, int x, int y, int width, int height)
|
void xf_peer_rfx_update(freerdp_peer* client, int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
wStream* s;
|
wStream* s;
|
||||||
@ -367,7 +351,9 @@ void xf_peer_rfx_update(freerdp_peer* client, int x, int y, int width, int heigh
|
|||||||
if (width * height <= 0)
|
if (width * height <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
s = xf_peer_stream_init(xfp);
|
s = xfp->s;
|
||||||
|
Stream_Clear(s);
|
||||||
|
Stream_SetPosition(s, 0);
|
||||||
|
|
||||||
if (xfi->use_xshm)
|
if (xfi->use_xshm)
|
||||||
{
|
{
|
||||||
@ -525,7 +511,8 @@ BOOL xf_peer_activate(freerdp_peer* client)
|
|||||||
|
|
||||||
xfp->info->activePeerCount++;
|
xfp->info->activePeerCount++;
|
||||||
|
|
||||||
xf_peer_live_rfx(client);
|
xfp->monitorThread = CreateThread(NULL, 0,
|
||||||
|
(LPTHREAD_START_ROUTINE) xf_update_thread, (void*) client, 0, NULL);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -51,12 +51,12 @@ struct xf_peer_context
|
|||||||
wStream* s;
|
wStream* s;
|
||||||
HGDI_DC hdc;
|
HGDI_DC hdc;
|
||||||
xfInfo* info;
|
xfInfo* info;
|
||||||
|
HANDLE mutex;
|
||||||
|
HANDLE event;
|
||||||
int activations;
|
int activations;
|
||||||
BOOL activated;
|
BOOL activated;
|
||||||
HANDLE monitorThread;
|
HANDLE monitorThread;
|
||||||
HANDLE mutex;
|
|
||||||
RFX_CONTEXT* rfx_context;
|
RFX_CONTEXT* rfx_context;
|
||||||
|
|
||||||
wMessageQueue* queue;
|
wMessageQueue* queue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
#include <winpr/crt.h>
|
#include <winpr/crt.h>
|
||||||
#include <winpr/synch.h>
|
#include <winpr/synch.h>
|
||||||
#include <winpr/sysinfo.h>
|
#include <winpr/sysinfo.h>
|
||||||
|
@ -25,9 +25,10 @@
|
|||||||
#include <freerdp/api.h>
|
#include <freerdp/api.h>
|
||||||
#include <freerdp/freerdp.h>
|
#include <freerdp/freerdp.h>
|
||||||
#include <freerdp/listener.h>
|
#include <freerdp/listener.h>
|
||||||
|
|
||||||
#include <freerdp/codec/color.h>
|
#include <freerdp/codec/color.h>
|
||||||
|
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
#ifdef WITH_XSHM
|
#ifdef WITH_XSHM
|
||||||
#include <X11/extensions/XShm.h>
|
#include <X11/extensions/XShm.h>
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user