shadow: further consolidate old X11 server code

This commit is contained in:
Marc-André Moreau 2014-07-11 18:00:33 -04:00
parent 43e9f6de58
commit 63f94ef150
8 changed files with 184 additions and 182 deletions

View File

@ -48,22 +48,22 @@
#ifdef WITH_XDAMAGE
void x11_shadow_xdamage_init(xfInfo* xfi)
void x11_shadow_xdamage_init(x11ShadowServer* server)
{
int damage_event;
int damage_error;
int major, minor;
XGCValues values;
if (XDamageQueryExtension(xfi->display, &damage_event, &damage_error) == 0)
if (XDamageQueryExtension(server->display, &damage_event, &damage_error) == 0)
{
fprintf(stderr, "XDamageQueryExtension failed\n");
return;
}
XDamageQueryVersion(xfi->display, &major, &minor);
XDamageQueryVersion(server->display, &major, &minor);
if (XDamageQueryVersion(xfi->display, &major, &minor) == 0)
if (XDamageQueryVersion(server->display, &major, &minor) == 0)
{
fprintf(stderr, "XDamageQueryVersion failed\n");
return;
@ -74,42 +74,42 @@ void x11_shadow_xdamage_init(xfInfo* xfi)
return;
}
xfi->xdamage_notify_event = damage_event + XDamageNotify;
xfi->xdamage = XDamageCreate(xfi->display, xfi->root_window, XDamageReportDeltaRectangles);
server->xdamage_notify_event = damage_event + XDamageNotify;
server->xdamage = XDamageCreate(server->display, server->root_window, XDamageReportDeltaRectangles);
if (xfi->xdamage == None)
if (server->xdamage == None)
{
fprintf(stderr, "XDamageCreate failed\n");
return;
}
#ifdef WITH_XFIXES
xfi->xdamage_region = XFixesCreateRegion(xfi->display, NULL, 0);
server->xdamage_region = XFixesCreateRegion(server->display, NULL, 0);
if (xfi->xdamage_region == None)
if (server->xdamage_region == None)
{
fprintf(stderr, "XFixesCreateRegion failed\n");
XDamageDestroy(xfi->display, xfi->xdamage);
xfi->xdamage = None;
XDamageDestroy(server->display, server->xdamage);
server->xdamage = None;
return;
}
#endif
values.subwindow_mode = IncludeInferiors;
xfi->xdamage_gc = XCreateGC(xfi->display, xfi->root_window, GCSubwindowMode, &values);
XSetFunction(xfi->display, xfi->xdamage_gc, GXcopy);
server->xdamage_gc = XCreateGC(server->display, server->root_window, GCSubwindowMode, &values);
XSetFunction(server->display, server->xdamage_gc, GXcopy);
}
#endif
int x11_shadow_xshm_init(xfInfo* xfi)
int x11_shadow_xshm_init(x11ShadowServer* server)
{
Bool pixmaps;
int major, minor;
if (XShmQueryExtension(xfi->display) != False)
if (XShmQueryExtension(server->display) != False)
{
XShmQueryVersion(xfi->display, &major, &minor, &pixmaps);
XShmQueryVersion(server->display, &major, &minor, &pixmaps);
if (pixmaps != True)
{
@ -123,65 +123,55 @@ int x11_shadow_xshm_init(xfInfo* xfi)
return -1;
}
xfi->fb_shm_info.shmid = -1;
xfi->fb_shm_info.shmaddr = (char*) -1;
server->fb_shm_info.shmid = -1;
server->fb_shm_info.shmaddr = (char*) -1;
xfi->fb_image = XShmCreateImage(xfi->display, xfi->visual, xfi->depth,
ZPixmap, NULL, &(xfi->fb_shm_info), xfi->width, xfi->height);
server->fb_image = XShmCreateImage(server->display, server->visual, server->depth,
ZPixmap, NULL, &(server->fb_shm_info), server->width, server->height);
if (!xfi->fb_image)
if (!server->fb_image)
{
fprintf(stderr, "XShmCreateImage failed\n");
return -1;
}
xfi->fb_shm_info.shmid = shmget(IPC_PRIVATE,
xfi->fb_image->bytes_per_line * xfi->fb_image->height, IPC_CREAT | 0600);
server->fb_shm_info.shmid = shmget(IPC_PRIVATE,
server->fb_image->bytes_per_line * server->fb_image->height, IPC_CREAT | 0600);
if (xfi->fb_shm_info.shmid == -1)
if (server->fb_shm_info.shmid == -1)
{
fprintf(stderr, "shmget failed\n");
return -1;
}
xfi->fb_shm_info.readOnly = False;
xfi->fb_shm_info.shmaddr = shmat(xfi->fb_shm_info.shmid, 0, 0);
xfi->fb_image->data = xfi->fb_shm_info.shmaddr;
server->fb_shm_info.readOnly = False;
server->fb_shm_info.shmaddr = shmat(server->fb_shm_info.shmid, 0, 0);
server->fb_image->data = server->fb_shm_info.shmaddr;
if (xfi->fb_shm_info.shmaddr == ((char*) -1))
if (server->fb_shm_info.shmaddr == ((char*) -1))
{
fprintf(stderr, "shmat failed\n");
return -1;
}
XShmAttach(xfi->display, &(xfi->fb_shm_info));
XSync(xfi->display, False);
XShmAttach(server->display, &(server->fb_shm_info));
XSync(server->display, False);
shmctl(xfi->fb_shm_info.shmid, IPC_RMID, 0);
shmctl(server->fb_shm_info.shmid, IPC_RMID, 0);
fprintf(stderr, "display: %p root_window: %p width: %d height: %d depth: %d\n",
xfi->display, (void*) xfi->root_window, xfi->fb_image->width, xfi->fb_image->height, xfi->fb_image->depth);
server->display, (void*) server->root_window, server->fb_image->width, server->fb_image->height, server->fb_image->depth);
xfi->fb_pixmap = XShmCreatePixmap(xfi->display,
xfi->root_window, xfi->fb_image->data, &(xfi->fb_shm_info),
xfi->fb_image->width, xfi->fb_image->height, xfi->fb_image->depth);
server->fb_pixmap = XShmCreatePixmap(server->display,
server->root_window, server->fb_image->data, &(server->fb_shm_info),
server->fb_image->width, server->fb_image->height, server->fb_image->depth);
return 0;
}
void x11_shadow_info_free(xfInfo *info)
{
if (info->display)
XCloseDisplay(info->display);
freerdp_clrconv_free(info->clrconv);
free(info);
}
xfInfo* x11_shadow_info_init()
void x11_shadow_peer_context_new(freerdp_peer* client, xfPeerContext* context)
{
int i;
xfInfo* xfi;
int pf_count;
int vi_count;
XVisualInfo* vi;
@ -189,38 +179,40 @@ xfInfo* x11_shadow_info_init()
XVisualInfo template;
XPixmapFormatValues* pf;
XPixmapFormatValues* pfs;
x11ShadowServer* server;
xfi = (xfInfo*) calloc(1, sizeof(xfInfo));
server = (x11ShadowServer*) client->context;
context->server = server;
/**
* Recent X11 servers drop support for shared pixmaps
* To see if your X11 server supports shared pixmaps, use:
* xdpyinfo -ext MIT-SHM | grep "shared pixmaps"
*/
xfi->use_xshm = TRUE;
server->use_xshm = TRUE;
setenv("DISPLAY", ":0", 1); /* Set DISPLAY variable if not already set */
if (!XInitThreads())
fprintf(stderr, "warning: XInitThreads() failure\n");
xfi->display = XOpenDisplay(NULL);
server->display = XOpenDisplay(NULL);
if (!xfi->display)
if (!server->display)
{
fprintf(stderr, "failed to open display: %s\n", XDisplayName(NULL));
exit(1);
}
xfi->xfds = ConnectionNumber(xfi->display);
xfi->number = DefaultScreen(xfi->display);
xfi->screen = ScreenOfDisplay(xfi->display, xfi->number);
xfi->depth = DefaultDepthOfScreen(xfi->screen);
xfi->width = WidthOfScreen(xfi->screen);
xfi->height = HeightOfScreen(xfi->screen);
xfi->root_window = DefaultRootWindow(xfi->display);
server->xfds = ConnectionNumber(server->display);
server->number = DefaultScreen(server->display);
server->screen = ScreenOfDisplay(server->display, server->number);
server->depth = DefaultDepthOfScreen(server->screen);
server->width = WidthOfScreen(server->screen);
server->height = HeightOfScreen(server->screen);
server->root_window = DefaultRootWindow(server->display);
pfs = XListPixmapFormats(xfi->display, &pf_count);
pfs = XListPixmapFormats(server->display, &pf_count);
if (!pfs)
{
@ -232,10 +224,10 @@ xfInfo* x11_shadow_info_init()
{
pf = pfs + i;
if (pf->depth == xfi->depth)
if (pf->depth == server->depth)
{
xfi->bpp = pf->bits_per_pixel;
xfi->scanline_pad = pf->scanline_pad;
server->bpp = pf->bits_per_pixel;
server->scanline_pad = pf->scanline_pad;
break;
}
}
@ -243,9 +235,9 @@ xfInfo* x11_shadow_info_init()
ZeroMemory(&template, sizeof(template));
template.class = TrueColor;
template.screen = xfi->number;
template.screen = server->number;
vis = XGetVisualInfo(xfi->display, VisualClassMask | VisualScreenMask, &template, &vi_count);
vis = XGetVisualInfo(server->display, VisualClassMask | VisualScreenMask, &template, &vi_count);
if (!vis)
{
@ -257,48 +249,42 @@ xfInfo* x11_shadow_info_init()
{
vi = vis + i;
if (vi->depth == xfi->depth)
if (vi->depth == server->depth)
{
xfi->visual = vi->visual;
server->visual = vi->visual;
break;
}
}
XFree(vis);
xfi->clrconv = freerdp_clrconv_new(CLRCONV_ALPHA | CLRCONV_INVERT);
server->clrconv = freerdp_clrconv_new(CLRCONV_ALPHA | CLRCONV_INVERT);
XSelectInput(xfi->display, xfi->root_window, SubstructureNotifyMask);
XSelectInput(server->display, server->root_window, SubstructureNotifyMask);
if (xfi->use_xshm)
if (server->use_xshm)
{
if (x11_shadow_xshm_init(xfi) < 0)
xfi->use_xshm = FALSE;
if (x11_shadow_xshm_init(server) < 0)
server->use_xshm = FALSE;
}
if (xfi->use_xshm)
if (server->use_xshm)
printf("Using X Shared Memory Extension (XShm)\n");
#ifdef WITH_XDAMAGE
x11_shadow_xdamage_init(xfi);
x11_shadow_xdamage_init(server);
#endif
x11_shadow_cursor_init(xfi);
x11_shadow_cursor_init(server);
xfi->bytesPerPixel = 4;
xfi->activePeerCount = 0;
server->bytesPerPixel = 4;
server->activePeerCount = 0;
freerdp_keyboard_init(0);
return xfi;
}
void x11_shadow_peer_context_new(freerdp_peer* client, xfPeerContext* context)
{
context->info = x11_shadow_info_init();
context->rfx_context = rfx_context_new(TRUE);
context->rfx_context->mode = RLGR3;
context->rfx_context->width = context->info->width;
context->rfx_context->height = context->info->height;
context->rfx_context->width = server->width;
context->rfx_context->height = server->height;
rfx_context_set_pixel_format(context->rfx_context, RDP_PIXEL_FORMAT_B8G8R8A8);
@ -311,9 +297,16 @@ void x11_shadow_peer_context_new(freerdp_peer* client, xfPeerContext* context)
void x11_shadow_peer_context_free(freerdp_peer* client, xfPeerContext* context)
{
x11ShadowServer* server;
if (context)
{
x11_shadow_info_free(context->info);
server = context->server;
if (server->display)
XCloseDisplay(server->display);
freerdp_clrconv_free(server->clrconv);
CloseHandle(context->updateReadyEvent);
CloseHandle(context->updateSentEvent);
@ -325,7 +318,6 @@ void x11_shadow_peer_context_free(freerdp_peer* client, xfPeerContext* context)
void x11_shadow_peer_init(freerdp_peer* client)
{
xfInfo* xfi;
xfPeerContext* xfp;
client->ContextSize = sizeof(xfPeerContext);
@ -336,8 +328,6 @@ void x11_shadow_peer_init(freerdp_peer* client)
xfp = (xfPeerContext*) client->context;
xfp->fps = 16;
xfi = xfp->info;
xfp->mutex = CreateMutex(NULL, FALSE, NULL);
}
@ -369,11 +359,9 @@ BOOL x11_shadow_peer_get_fds(freerdp_peer* client, void** rfds, int* rcount)
BOOL x11_shadow_peer_check_fds(freerdp_peer* client)
{
xfInfo* xfi;
xfPeerContext* xfp;
xfp = (xfPeerContext*) client->context;
xfi = xfp->info;
if (WaitForSingleObject(xfp->updateReadyEvent, 0) == WAIT_OBJECT_0)
{
@ -396,11 +384,11 @@ BOOL x11_shadow_peer_capabilities(freerdp_peer* client)
BOOL x11_shadow_peer_post_connect(freerdp_peer* client)
{
xfInfo* xfi;
xfPeerContext* xfp;
x11ShadowServer* server;
xfp = (xfPeerContext*) client->context;
xfi = (xfInfo*) xfp->info;
server = xfp->server;
fprintf(stderr, "Client %s is activated", client->hostname);
if (client->settings->AutoLogonEnabled)
@ -422,8 +410,8 @@ BOOL x11_shadow_peer_post_connect(freerdp_peer* client)
/* A real server should tag the peer as activated here and start sending updates in main loop. */
client->settings->DesktopWidth = xfi->width;
client->settings->DesktopHeight = xfi->height;
client->settings->DesktopWidth = server->width;
client->settings->DesktopHeight = server->height;
client->update->DesktopResize(client->update->context);
@ -434,11 +422,12 @@ BOOL x11_shadow_peer_post_connect(freerdp_peer* client)
BOOL x11_shadow_peer_activate(freerdp_peer* client)
{
xfPeerContext* xfp = (xfPeerContext*) client->context;
x11ShadowServer* server = xfp->server;
rfx_context_reset(xfp->rfx_context);
xfp->activated = TRUE;
xfp->info->activePeerCount++;
server->activePeerCount++;
xfp->monitorThread = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE) x11_shadow_update_thread, (void*) client, 0, NULL);
@ -511,6 +500,7 @@ static void* x11_shadow_peer_main_loop(void* arg)
fprintf(stderr, "We've got a client %s\n", client->hostname);
x11_shadow_peer_init(client);
xfp = (xfPeerContext*) client->context;
settings = client->settings;
@ -608,5 +598,6 @@ void x11_shadow_peer_accepted(freerdp_listener* instance, freerdp_peer* client)
{
HANDLE thread;
thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) x11_shadow_peer_main_loop, client, 0, NULL);
thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)
x11_shadow_peer_main_loop, client, 0, NULL);
}

View File

@ -30,21 +30,21 @@
#include "x11_shadow.h"
int x11_shadow_cursor_init(xfInfo* xfi)
int x11_shadow_cursor_init(x11ShadowServer* server)
{
#ifdef WITH_XFIXES
int event;
int error;
if (!XFixesQueryExtension(xfi->display, &event, &error))
if (!XFixesQueryExtension(server->display, &event, &error))
{
fprintf(stderr, "XFixesQueryExtension failed\n");
return -1;
}
xfi->xfixes_notify_event = event + XFixesCursorNotify;
server->xfixes_notify_event = event + XFixesCursorNotify;
XFixesSelectCursorInput(xfi->display, DefaultRootWindow(xfi->display), XFixesDisplayCursorNotifyMask);
XFixesSelectCursorInput(server->display, DefaultRootWindow(server->display), XFixesDisplayCursorNotifyMask);
#endif
return 0;
@ -62,7 +62,7 @@ void x11_shadow_input_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
DWORD keycode;
BOOL extended = FALSE;
xfPeerContext* xfp = (xfPeerContext*) input->context;
xfInfo* xfi = xfp->info;
x11ShadowServer* server = xfp->server;
if (flags & KBD_FLAGS_EXTENDED)
extended = TRUE;
@ -75,14 +75,14 @@ void x11_shadow_input_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
if (keycode != 0)
{
XTestGrabControl(xfi->display, True);
XTestGrabControl(server->display, True);
if (flags & KBD_FLAGS_DOWN)
XTestFakeKeyEvent(xfi->display, keycode, True, 0);
XTestFakeKeyEvent(server->display, keycode, True, 0);
else if (flags & KBD_FLAGS_RELEASE)
XTestFakeKeyEvent(xfi->display, keycode, False, 0);
XTestFakeKeyEvent(server->display, keycode, False, 0);
XTestGrabControl(xfi->display, False);
XTestGrabControl(server->display, False);
}
#endif
}
@ -95,12 +95,12 @@ void x11_shadow_input_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT
void x11_shadow_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
{
#ifdef WITH_XTEST
xfPeerContext* xfp = (xfPeerContext*) input->context;
int button = 0;
BOOL down = FALSE;
xfInfo* xfi = xfp->info;
xfPeerContext* xfp = (xfPeerContext*) input->context;
x11ShadowServer* server = xfp->server;
XTestGrabControl(xfi->display, True);
XTestGrabControl(server->display, True);
if (flags & PTR_FLAGS_WHEEL)
{
@ -111,13 +111,13 @@ void x11_shadow_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT1
button = (negative) ? 5 : 4;
XTestFakeButtonEvent(xfi->display, button, True, 0);
XTestFakeButtonEvent(xfi->display, button, False, 0);
XTestFakeButtonEvent(server->display, button, True, 0);
XTestFakeButtonEvent(server->display, button, False, 0);
}
else
{
if (flags & PTR_FLAGS_MOVE)
XTestFakeMotionEvent(xfi->display, 0, x, y, 0);
XTestFakeMotionEvent(server->display, 0, x, y, 0);
if (flags & PTR_FLAGS_BUTTON1)
button = 1;
@ -130,23 +130,23 @@ void x11_shadow_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT1
down = TRUE;
if (button != 0)
XTestFakeButtonEvent(xfi->display, button, down, 0);
XTestFakeButtonEvent(server->display, button, down, 0);
}
XTestGrabControl(xfi->display, False);
XTestGrabControl(server->display, False);
#endif
}
void x11_shadow_input_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
{
#ifdef WITH_XTEST
xfPeerContext* xfp = (xfPeerContext*) input->context;
int button = 0;
BOOL down = FALSE;
xfInfo* xfi = xfp->info;
xfPeerContext* xfp = (xfPeerContext*) input->context;
x11ShadowServer* server = xfp->server;
XTestGrabControl(xfi->display, True);
XTestFakeMotionEvent(xfi->display, 0, x, y, CurrentTime);
XTestGrabControl(server->display, True);
XTestFakeMotionEvent(server->display, 0, x, y, CurrentTime);
if (flags & PTR_XFLAGS_BUTTON1)
button = 8;
@ -157,9 +157,9 @@ void x11_shadow_input_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16
down = TRUE;
if (button != 0)
XTestFakeButtonEvent(xfi->display, button, down, 0);
XTestFakeButtonEvent(server->display, button, down, 0);
XTestGrabControl(xfi->display, False);
XTestGrabControl(server->display, False);
#endif
}

View File

@ -37,10 +37,10 @@ void* x11_shadow_server_thread(void* param)
int rcount;
void* rfds[32];
fd_set rfds_set;
xfServer* server;
x11ShadowServer* server;
freerdp_listener* listener;
server = (xfServer*) param;
server = (x11ShadowServer*) param;
listener = server->listener;
while (1)
@ -95,7 +95,7 @@ void* x11_shadow_server_thread(void* param)
return NULL;
}
int x11_shadow_server_start(xfServer* server)
int x11_shadow_server_start(x11ShadowServer* server)
{
server->thread = NULL;
@ -108,7 +108,7 @@ int x11_shadow_server_start(xfServer* server)
return 0;
}
int x11_shadow_server_stop(xfServer* server)
int x11_shadow_server_stop(x11ShadowServer* server)
{
if (server->thread)
{
@ -121,16 +121,16 @@ int x11_shadow_server_stop(xfServer* server)
return 0;
}
HANDLE x11_shadow_server_get_thread(xfServer* server)
HANDLE x11_shadow_server_get_thread(x11ShadowServer* server)
{
return server->thread;
}
xfServer* x11_shadow_server_new(int argc, char** argv)
x11ShadowServer* x11_shadow_server_new(int argc, char** argv)
{
xfServer* server;
x11ShadowServer* server;
server = (xfServer*) malloc(sizeof(xfServer));
server = (x11ShadowServer*) malloc(sizeof(x11ShadowServer));
if (server)
{
@ -143,7 +143,7 @@ xfServer* x11_shadow_server_new(int argc, char** argv)
return server;
}
void x11_shadow_server_free(xfServer* server)
void x11_shadow_server_free(x11ShadowServer* server)
{
if (server)
{

View File

@ -24,27 +24,19 @@
#include <freerdp/api.h>
#include <freerdp/freerdp.h>
typedef struct x11_shadow_info xfInfo;
typedef struct x11_shadow_server xfServer;
typedef struct x11_shadow_server x11ShadowServer;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Server Interface
*/
FREERDP_API int x11_shadow_server_start(x11ShadowServer* server);
FREERDP_API int x11_shadow_server_stop(x11ShadowServer* server);
FREERDP_API int x11_shadow_server_global_init();
FREERDP_API int x11_shadow_server_global_uninit();
FREERDP_API HANDLE x11_shadow_server_get_thread(x11ShadowServer* server);
FREERDP_API int x11_shadow_server_start(xfServer* server);
FREERDP_API int x11_shadow_server_stop(xfServer* server);
FREERDP_API HANDLE x11_shadow_server_get_thread(xfServer* server);
FREERDP_API xfServer* x11_shadow_server_new(int argc, char** argv);
FREERDP_API void x11_shadow_server_free(xfServer* server);
FREERDP_API x11ShadowServer* x11_shadow_server_new(int argc, char** argv);
FREERDP_API void x11_shadow_server_free(x11ShadowServer* server);
#ifdef __cplusplus
}
@ -73,8 +65,12 @@ FREERDP_API void x11_shadow_server_free(xfServer* server);
#include <X11/extensions/Xdamage.h>
#endif
struct x11_shadow_info
struct x11_shadow_server
{
DWORD port;
HANDLE thread;
freerdp_listener* listener;
int bpp;
int xfds;
int depth;
@ -108,13 +104,6 @@ struct x11_shadow_info
#endif
};
struct x11_shadow_server
{
DWORD port;
HANDLE thread;
freerdp_listener* listener;
};
#include <winpr/crt.h>
#include <winpr/synch.h>
#include <winpr/thread.h>
@ -142,13 +131,13 @@ struct x11_shadow_peer_context
int fps;
wStream* s;
xfInfo* info;
HANDLE mutex;
BOOL activated;
HANDLE monitorThread;
HANDLE updateReadyEvent;
HANDLE updateSentEvent;
RFX_CONTEXT* rfx_context;
x11ShadowServer* server;
};
void x11_shadow_peer_accepted(freerdp_listener* instance, freerdp_peer* client);
@ -157,17 +146,10 @@ void* x11_shadow_server_thread(void* param);
void* x11_shadow_update_thread(void* param);
int x11_shadow_cursor_init(xfInfo* xfi);
int x11_shadow_cursor_init(x11ShadowServer* server);
XImage* x11_shadow_snapshot(xfPeerContext* xfp, int x, int y, int width, int height);
void x11_shadow_xdamage_subtract_region(xfPeerContext* xfp, int x, int y, int width, int height);
int x11_shadow_update_encode(freerdp_peer* client, int x, int y, int width, int height);
void x11_shadow_input_synchronize_event(rdpInput* input, UINT32 flags);
void x11_shadow_input_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code);
void x11_shadow_input_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code);
void x11_shadow_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y);
void x11_shadow_input_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y);
void x11_shadow_input_register_callbacks(rdpInput* input);
int x11_shadow_update_encode(freerdp_peer* client, int x, int y, int width, int height);
#endif /* FREERDP_SHADOW_SERVER_X11_H */

View File

@ -32,16 +32,16 @@
XImage* x11_shadow_snapshot(xfPeerContext* xfp, int x, int y, int width, int height)
{
XImage* image;
xfInfo* xfi = xfp->info;
x11ShadowServer* server = xfp->server;
if (xfi->use_xshm)
if (server->use_xshm)
{
XCopyArea(xfi->display, xfi->root_window, xfi->fb_pixmap, xfi->xdamage_gc, x, y, width, height, x, y);
image = xfi->fb_image;
XCopyArea(server->display, server->root_window, server->fb_pixmap, server->xdamage_gc, x, y, width, height, x, y);
image = server->fb_image;
}
else
{
image = XGetImage(xfi->display, xfi->root_window, x, y, width, height, AllPlanes, ZPixmap);
image = XGetImage(server->display, server->root_window, x, y, width, height, AllPlanes, ZPixmap);
}
return image;
@ -50,7 +50,7 @@ XImage* x11_shadow_snapshot(xfPeerContext* xfp, int x, int y, int width, int hei
void x11_shadow_xdamage_subtract_region(xfPeerContext* xfp, int x, int y, int width, int height)
{
XRectangle region;
xfInfo* xfi = xfp->info;
x11ShadowServer* server = xfp->server;
region.x = x;
region.y = y;
@ -58,8 +58,8 @@ void x11_shadow_xdamage_subtract_region(xfPeerContext* xfp, int x, int y, int wi
region.height = height;
#ifdef WITH_XFIXES
XFixesSetRegion(xfi->display, xfi->xdamage_region, &region, 1);
XDamageSubtract(xfi->display, xfi->xdamage, xfi->xdamage_region, None);
XFixesSetRegion(server->display, server->xdamage_region, &region, 1);
XDamageSubtract(server->display, server->xdamage, server->xdamage_region, None);
#endif
}
@ -67,17 +67,18 @@ int x11_shadow_update_encode(freerdp_peer* client, int x, int y, int width, int
{
wStream* s;
BYTE* data;
xfInfo* xfi;
RFX_RECT rect;
XImage* image;
rdpUpdate* update;
xfPeerContext* xfp;
x11ShadowServer* server;
SURFACE_BITS_COMMAND* cmd;
update = client->update;
xfp = (xfPeerContext*) client->context;
server = xfp->server;
update = client->update;
cmd = &update->surface_bits_command;
xfi = xfp->info;
if (width * height <= 0)
{
@ -89,7 +90,7 @@ int x11_shadow_update_encode(freerdp_peer* client, int x, int y, int width, int
Stream_Clear(s);
Stream_SetPosition(s, 0);
if (xfi->use_xshm)
if (server->use_xshm)
{
/**
* Passing an offset source rectangle to rfx_compose_message()
@ -148,34 +149,34 @@ int x11_shadow_update_encode(freerdp_peer* client, int x, int y, int width, int
void* x11_shadow_update_thread(void* param)
{
xfInfo* xfi;
HANDLE event;
XEvent xevent;
DWORD beg, end;
DWORD diff, rate;
xfPeerContext* xfp;
x11ShadowServer* server;
freerdp_peer* client;
int x, y, width, height;
XDamageNotifyEvent* notify;
client = (freerdp_peer*) param;
xfp = (xfPeerContext*) client->context;
xfi = xfp->info;
server = xfp->server;
rate = 1000 / xfp->fps;
event = CreateFileDescriptorEvent(NULL, FALSE, FALSE, xfi->xfds);
event = CreateFileDescriptorEvent(NULL, FALSE, FALSE, server->xfds);
while (WaitForSingleObject(event, INFINITE) == WAIT_OBJECT_0)
{
beg = GetTickCount();
while (XPending(xfi->display) > 0)
while (XPending(server->display) > 0)
{
ZeroMemory(&xevent, sizeof(xevent));
XNextEvent(xfi->display, &xevent);
XNextEvent(server->display, &xevent);
if (xevent.type == xfi->xdamage_notify_event)
if (xevent.type == server->xdamage_notify_event)
{
notify = (XDamageNotifyEvent*) &xevent;
@ -195,9 +196,9 @@ void* x11_shadow_update_thread(void* param)
}
}
#ifdef WITH_XFIXES
else if (xevent.type == xfi->xfixes_notify_event)
else if (xevent.type == server->xfixes_notify_event)
{
XFixesCursorImage* ci = XFixesGetCursorImage(xfi->display);
XFixesCursorImage* ci = XFixesGetCursorImage(server->display);
XFree(ci);
}
#endif

View File

@ -122,8 +122,8 @@ int main(int argc, char* argv[])
HANDLE thread;
DWORD dwExitCode;
#if 0
xfServer* server;
#if 1
x11ShadowServer* server;
server = x11_shadow_server_new(argc, argv);

View File

@ -16,6 +16,10 @@
* limitations under the License.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "shadow.h"
void shadow_input_synchronize_event(rdpInput* input, UINT32 flags)

View File

@ -0,0 +1,24 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
*
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "shadow.h"