libfreerdp-core: refactoring of context pointers into rdpContext

This commit is contained in:
Marc-André Moreau 2011-10-16 00:50:10 -04:00
parent 9c20a9d350
commit c639ec8593
28 changed files with 480 additions and 363 deletions

View File

@ -184,15 +184,15 @@ void df_send_keyboard_event(rdpInput* input, boolean down, uint8 keycode)
boolean df_event_process(freerdp* instance, DFBEvent* event)
{
GDI* gdi;
rdpGdi* gdi;
dfInfo* dfi;
int pointer_x;
int pointer_y;
int flags;
DFBInputEvent* input_event;
dfi = GET_DFI(instance);
gdi = GET_GDI(instance->update);
gdi = instance->context->gdi;
dfi = ((dfContext*) instance->context)->dfi;
dfi->layer->GetCursorPosition(dfi->layer, &pointer_x, &pointer_y);

View File

@ -39,21 +39,34 @@ struct thread_data
freerdp* instance;
};
void df_context_size(freerdp* instance, uint32* size)
{
*size = sizeof(dfContext);
}
void df_context_new(freerdp* instance, dfContext* context)
{
context->chanman = freerdp_chanman_new();
}
void df_context_free(freerdp* instance, dfContext* context)
{
}
void df_begin_paint(rdpUpdate* update)
{
GDI* gdi;
gdi = GET_GDI(update);
rdpGdi* gdi = update->context->gdi;
gdi->primary->hdc->hwnd->invalid->null = 1;
}
void df_end_paint(rdpUpdate* update)
{
GDI* gdi;
rdpGdi* gdi;
dfInfo* dfi;
gdi = GET_GDI(update);
dfi = GET_DFI(update);
gdi = update->context->gdi;
dfi = ((dfContext*) update->context)->dfi;
if (gdi->primary->hdc->hwnd->invalid->null)
return;
@ -77,7 +90,7 @@ boolean df_get_fds(freerdp* instance, void** rfds, int* rcount, void** wfds, int
{
dfInfo* dfi;
dfi = GET_DFI(instance);
dfi = ((dfContext*) instance->context)->dfi;
rfds[*rcount] = (void*)(long)(dfi->read_fds);
(*rcount)++;
@ -89,7 +102,7 @@ boolean df_check_fds(freerdp* instance, fd_set* set)
{
dfInfo* dfi;
dfi = GET_DFI(instance);
dfi = ((dfContext*) instance->context)->dfi;
if (!FD_ISSET(dfi->read_fds, set))
return True;
@ -103,10 +116,12 @@ boolean df_check_fds(freerdp* instance, fd_set* set)
boolean df_pre_connect(freerdp* instance)
{
dfInfo* dfi;
dfContext* context;
rdpSettings* settings;
dfi = (dfInfo*) xzalloc(sizeof(dfInfo));
SET_DFI(instance, dfi);
context = ((dfContext*) instance->context);
context->dfi = dfi;
settings = instance->settings;
@ -133,21 +148,22 @@ boolean df_pre_connect(freerdp* instance)
settings->order_support[NEG_ELLIPSE_SC_INDEX] = False;
settings->order_support[NEG_ELLIPSE_CB_INDEX] = False;
freerdp_chanman_pre_connect(GET_CHANMAN(instance), instance);
freerdp_chanman_pre_connect(context->chanman, instance);
return True;
}
boolean df_post_connect(freerdp* instance)
{
GDI* gdi;
rdpGdi* gdi;
dfInfo* dfi;
dfContext* context;
dfi = GET_DFI(instance);
SET_DFI(instance->update, dfi);
context = ((dfContext*) instance->context);
dfi = context->dfi;
gdi_init(instance, CLRCONV_ALPHA | CLRBUF_16BPP | CLRBUF_32BPP, NULL);
gdi = GET_GDI(instance->update);
gdi = instance->context->gdi;
dfi->err = DirectFBCreate(&(dfi->dfb));
@ -185,7 +201,7 @@ boolean df_post_connect(freerdp* instance)
df_keyboard_init();
freerdp_chanman_post_connect(GET_CHANMAN(instance), instance);
freerdp_chanman_post_connect(context->chanman, instance);
return True;
}
@ -227,6 +243,7 @@ df_process_channel_event(rdpChanMan* chanman, freerdp* instance)
RDP_EVENT* event;
event = freerdp_chanman_pop_event(chanman);
if (event)
{
switch (event->event_type)
@ -238,6 +255,7 @@ df_process_channel_event(rdpChanMan* chanman, freerdp* instance)
printf("df_process_channel_event: unknown event type %d\n", event->event_type);
break;
}
freerdp_event_free(event);
}
}
@ -260,6 +278,7 @@ int dfreerdp_run(freerdp* instance)
fd_set rfds_set;
fd_set wfds_set;
dfInfo* dfi;
dfContext* context;
rdpChanMan* chanman;
memset(rfds, 0, sizeof(rfds));
@ -268,8 +287,10 @@ int dfreerdp_run(freerdp* instance)
if (!instance->Connect(instance))
return 0;
dfi = GET_DFI(instance);
chanman = GET_CHANMAN(instance);
context = (dfContext*) instance->context;
dfi = context->dfi;
chanman = context->chanman;
while (1)
{
@ -373,6 +394,7 @@ int main(int argc, char* argv[])
{
pthread_t thread;
freerdp* instance;
dfContext* context;
struct thread_data* data;
rdpChanMan* chanman;
@ -387,8 +409,13 @@ int main(int argc, char* argv[])
instance->PostConnect = df_post_connect;
instance->ReceiveChannelData = df_receive_channel_data;
chanman = freerdp_chanman_new();
SET_CHANMAN(instance, chanman);
instance->ContextSize = (pcContextSize) df_context_size;
instance->ContextNew = (pcContextNew) df_context_new;
instance->ContextFree = (pcContextFree) df_context_free;
freerdp_context_new(instance);
context = (dfContext*) instance->context;
chanman = context->chanman;
DirectFBInit(&argc, &argv);
freerdp_parse_args(instance->settings, argc, argv, df_process_plugin_args, chanman, NULL, NULL);

View File

@ -28,11 +28,17 @@
#include <freerdp/chanman/chanman.h>
#include <freerdp/gdi/gdi.h>
#define SET_DFI(_instance, _dfi) (_instance)->client = _dfi
#define GET_DFI(_instance) ((dfInfo*) ((_instance)->client))
typedef struct df_info dfInfo;
#define SET_CHANMAN(_instance, _chanman) (_instance)->chanman = _chanman
#define GET_CHANMAN(_instance) ((rdpChanMan*) ((_instance)->chanman))
struct df_context
{
rdpContext _p;
dfInfo* dfi;
rdpChanMan* chanman;
rdpSettings* settings;
};
typedef struct df_context dfContext;
struct df_info
{
@ -47,6 +53,5 @@ struct df_info
IDirectFBDisplayLayer* layer;
IDirectFBEventBuffer* event_buffer;
};
typedef struct df_info dfInfo;
#endif /* __DFREERDP_H */

View File

@ -59,7 +59,7 @@ int wf_create_console(void)
void wf_sw_begin_paint(rdpUpdate* update)
{
GDI* gdi;
rdpGdi* gdi;
gdi = GET_GDI(update);
gdi->primary->hdc->hwnd->invalid->null = 1;
gdi->primary->hdc->hwnd->ninvalid = 0;
@ -68,7 +68,7 @@ void wf_sw_begin_paint(rdpUpdate* update)
void wf_sw_end_paint(rdpUpdate* update)
{
int i;
GDI* gdi;
rdpGdi* gdi;
wfInfo* wfi;
sint32 x, y;
uint32 w, h;
@ -259,7 +259,7 @@ boolean wf_pre_connect(freerdp* instance)
boolean wf_post_connect(freerdp* instance)
{
GDI* gdi;
rdpGdi* gdi;
wfInfo* wfi;
int width, height;
wchar_t win_title[64];

View File

@ -87,8 +87,9 @@ boolean xf_event_Expose(xfInfo* xfi, XEvent* event, boolean app)
{
xfWindow* xfw;
rdpWindow* window;
rdpRail* rail = ((rdpContext*) xfi->context)->rail;
window = window_list_get_by_extra_id(xfi->rail->list, (void*) event->xexpose.window);
window = window_list_get_by_extra_id(rail->list, (void*) event->xexpose.window);
if (window != NULL)
{
@ -116,8 +117,9 @@ boolean xf_event_VisibilityNotify(xfInfo* xfi, XEvent* event, boolean app)
{
xfWindow* xfw;
rdpWindow* window;
rdpRail* rail = ((rdpContext*) xfi->context)->rail;
window = window_list_get_by_extra_id(xfi->rail->list, (void*) event->xvisibility.window);
window = window_list_get_by_extra_id(rail->list, (void*) event->xvisibility.window);
if (window != NULL)
{
@ -153,7 +155,9 @@ boolean xf_event_MotionNotify(xfInfo* xfi, XEvent* event, boolean app)
rdpWindow* window;
int x = event->xmotion.x;
int y = event->xmotion.y;
window = window_list_get_by_extra_id(xfi->rail->list, (void*) event->xmotion.window);
rdpRail* rail = ((rdpContext*) xfi->context)->rail;
window = window_list_get_by_extra_id(rail->list, (void*) event->xmotion.window);
if (window != NULL)
{
@ -228,7 +232,9 @@ boolean xf_event_ButtonPress(xfInfo* xfi, XEvent* event, boolean app)
if (app)
{
rdpWindow* window;
window = window_list_get_by_extra_id(xfi->rail->list, (void*) event->xbutton.window);
rdpRail* rail = ((rdpContext*) xfi->context)->rail;
window = window_list_get_by_extra_id(rail->list, (void*) event->xbutton.window);
if (window != NULL)
{
@ -286,7 +292,9 @@ boolean xf_event_ButtonRelease(xfInfo* xfi, XEvent* event, boolean app)
if (app)
{
rdpWindow* window;
window = window_list_get_by_extra_id(xfi->rail->list, (void*) event->xbutton.window);
rdpRail* rail = ((rdpContext*) xfi->context)->rail;
window = window_list_get_by_extra_id(rail->list, (void*) event->xbutton.window);
if (window != NULL)
{
@ -393,8 +401,9 @@ boolean xf_event_ClientMessage(xfInfo* xfi, XEvent* event, boolean app)
if (app)
{
rdpWindow* window;
rdpRail* rail = ((rdpContext*) xfi->context)->rail;
window = window_list_get_by_extra_id(xfi->rail->list, (void*) event->xclient.window);
window = window_list_get_by_extra_id(rail->list, (void*) event->xclient.window);
if (window != NULL)
{
@ -442,8 +451,9 @@ boolean xf_event_LeaveNotify(xfInfo* xfi, XEvent* event, boolean app)
boolean xf_event_ConfigureNotify(xfInfo* xfi, XEvent* event, boolean app)
{
rdpWindow* window;
rdpRail* rail = ((rdpContext*) xfi->context)->rail;
window = window_list_get_by_extra_id(xfi->rail->list, (void*) event->xconfigure.window);
window = window_list_get_by_extra_id(rail->list, (void*) event->xconfigure.window);
if (window != NULL)
{
@ -476,11 +486,12 @@ boolean xf_event_ConfigureNotify(xfInfo* xfi, XEvent* event, boolean app)
boolean xf_event_MapNotify(xfInfo* xfi, XEvent* event, boolean app)
{
rdpWindow* window;
rdpRail* rail = ((rdpContext*) xfi->context)->rail;
if (app != True)
return True;
window = window_list_get_by_extra_id(xfi->rail->list, (void*) event->xany.window);
window = window_list_get_by_extra_id(rail->list, (void*) event->xany.window);
if (window != NULL)
{
@ -539,7 +550,7 @@ boolean xf_event_process(freerdp* instance, XEvent* event)
{
boolean app = False;
boolean status = True;
xfInfo* xfi = GET_XFI(instance);
xfInfo* xfi = ((xfContext*) instance->context)->xfi;
if (xfi->remote_app == True)
{

View File

@ -290,7 +290,7 @@ void xf_gdi_bitmap_update(rdpUpdate* update, BITMAP_UPDATE* bitmap)
uint8* data;
XImage* image;
rdpBitmap* bmp;
xfInfo* xfi = GET_XFI(update);
xfInfo* xfi = ((xfContext*) update->context)->xfi;
for (i = 0; i < bitmap->number; i++)
{
@ -323,7 +323,7 @@ void xf_gdi_palette_update(rdpUpdate* update, PALETTE_UPDATE* palette)
void xf_gdi_set_bounds(rdpUpdate* update, BOUNDS* bounds)
{
XRectangle clip;
xfInfo* xfi = GET_XFI(update);
xfInfo* xfi = ((xfContext*) update->context)->xfi;
if (bounds != NULL)
{
@ -341,7 +341,7 @@ void xf_gdi_set_bounds(rdpUpdate* update, BOUNDS* bounds)
void xf_gdi_dstblt(rdpUpdate* update, DSTBLT_ORDER* dstblt)
{
xfInfo* xfi = GET_XFI(update);
xfInfo* xfi = ((xfContext*) update->context)->xfi;
xf_set_rop3(xfi, gdi_rop3_code(dstblt->bRop));
@ -368,7 +368,8 @@ void xf_gdi_patblt(rdpUpdate* update, PATBLT_ORDER* patblt)
Pixmap pattern;
uint32 foreColor;
uint32 backColor;
xfInfo* xfi = GET_XFI(update);
xfInfo* xfi = ((xfContext*) update->context)->xfi;
rdpCache* cache = update->context->cache;
brush = &patblt->brush;
xf_set_rop3(xfi, gdi_rop3_code(patblt->bRop));
@ -378,7 +379,7 @@ void xf_gdi_patblt(rdpUpdate* update, PATBLT_ORDER* patblt)
if (brush->style & CACHED_BRUSH)
{
brush->data = brush_get(xfi->cache->brush, brush->index, &brush->bpp);
brush->data = brush_get(cache->brush, brush->index, &brush->bpp);
brush->style = GDI_BS_PATTERN;
}
@ -441,7 +442,7 @@ void xf_gdi_patblt(rdpUpdate* update, PATBLT_ORDER* patblt)
void xf_gdi_scrblt(rdpUpdate* update, SCRBLT_ORDER* scrblt)
{
xfInfo* xfi = GET_XFI(update);
xfInfo* xfi = ((xfContext*) update->context)->xfi;
xf_set_rop3(xfi, gdi_rop3_code(scrblt->bRop));
@ -474,7 +475,7 @@ void xf_gdi_scrblt(rdpUpdate* update, SCRBLT_ORDER* scrblt)
void xf_gdi_opaque_rect(rdpUpdate* update, OPAQUE_RECT_ORDER* opaque_rect)
{
uint32 color;
xfInfo* xfi = GET_XFI(update);
xfInfo* xfi = ((xfContext*) update->context)->xfi;
color = freerdp_color_convert(opaque_rect->color, xfi->srcBpp, xfi->bpp, xfi->clrconv);
@ -503,7 +504,7 @@ void xf_gdi_multi_opaque_rect(rdpUpdate* update, MULTI_OPAQUE_RECT_ORDER* multi_
int i;
uint32 color;
DELTA_RECT* rectangle;
xfInfo* xfi = GET_XFI(update);
xfInfo* xfi = ((xfContext*) update->context)->xfi;
color = freerdp_color_convert(multi_opaque_rect->color, xfi->srcBpp, xfi->bpp, xfi->clrconv);
@ -535,7 +536,7 @@ void xf_gdi_multi_opaque_rect(rdpUpdate* update, MULTI_OPAQUE_RECT_ORDER* multi_
void xf_gdi_line_to(rdpUpdate* update, LINE_TO_ORDER* line_to)
{
uint32 color;
xfInfo* xfi = GET_XFI(update);
xfInfo* xfi = ((xfContext*) update->context)->xfi;
xf_set_rop2(xfi, line_to->bRop2);
color = freerdp_color_convert(line_to->penColor, xfi->srcBpp, 32, xfi->clrconv);
@ -579,7 +580,7 @@ void xf_gdi_polyline(rdpUpdate* update, POLYLINE_ORDER* polyline)
uint32 color;
XPoint* points;
int width, height;
xfInfo* xfi = GET_XFI(update);
xfInfo* xfi = ((xfContext*) update->context)->xfi;
xf_set_rop2(xfi, polyline->bRop2);
color = freerdp_color_convert(polyline->penColor, xfi->srcBpp, 32, xfi->clrconv);
@ -633,7 +634,7 @@ void xf_gdi_polyline(rdpUpdate* update, POLYLINE_ORDER* polyline)
void xf_gdi_memblt(rdpUpdate* update, MEMBLT_ORDER* memblt)
{
xfBitmap* bitmap;
xfInfo* xfi = GET_XFI(update);
xfInfo* xfi = ((xfContext*) update->context)->xfi;
bitmap = (xfBitmap*) memblt->bitmap;
xf_set_rop3(xfi, gdi_rop3_code(memblt->bRop));
@ -672,7 +673,8 @@ void xf_gdi_fast_index(rdpUpdate* update, FAST_INDEX_ORDER* fast_index)
GLYPH_DATA* glyph;
GLYPH_DATA** glyphs;
GLYPH_FRAGMENT* fragment;
xfInfo* xfi = GET_XFI(update);
xfInfo* xfi = ((xfContext*) update->context)->xfi;
rdpCache* cache = update->context->cache;
fgcolor = freerdp_color_convert(fast_index->foreColor, xfi->srcBpp, 32, xfi->clrconv);
bgcolor = freerdp_color_convert(fast_index->backColor, xfi->srcBpp, 32, xfi->clrconv);
@ -714,14 +716,14 @@ void xf_gdi_fast_index(rdpUpdate* update, FAST_INDEX_ORDER* fast_index)
if (fragment->operation == GLYPH_FRAGMENT_USE)
{
fragment->indices = (GLYPH_FRAGMENT_INDEX*) glyph_fragment_get(xfi->cache->glyph,
fragment->indices = (GLYPH_FRAGMENT_INDEX*) glyph_fragment_get(cache->glyph,
fragment->index, &fragment->nindices, (void**) &bmps);
glyphs = (GLYPH_DATA**) xmalloc(sizeof(GLYPH_DATA*) * fragment->nindices);
for (j = 0; j < fragment->nindices; j++)
{
glyphs[j] = glyph_get(xfi->cache->glyph, fast_index->cacheId, fragment->indices[j].index, (void**) &bmps[j]);
glyphs[j] = glyph_get(cache->glyph, fast_index->cacheId, fragment->indices[j].index, (void**) &bmps[j]);
}
}
else
@ -731,7 +733,7 @@ void xf_gdi_fast_index(rdpUpdate* update, FAST_INDEX_ORDER* fast_index)
for (j = 0; j < fragment->nindices; j++)
{
glyphs[j] = glyph_get(xfi->cache->glyph, fast_index->cacheId, fragment->indices[j].index, (void**) &bmps[j]);
glyphs[j] = glyph_get(cache->glyph, fast_index->cacheId, fragment->indices[j].index, (void**) &bmps[j]);
}
}
@ -767,7 +769,7 @@ void xf_gdi_fast_index(rdpUpdate* update, FAST_INDEX_ORDER* fast_index)
if (fragment->operation == GLYPH_FRAGMENT_ADD)
{
glyph_fragment_put(xfi->cache->glyph, fragment->index,
glyph_fragment_put(cache->glyph, fragment->index,
fragment->nindices, (void*) fragment->indices, (void*) bmps);
}
}
@ -799,13 +801,14 @@ void xf_gdi_cache_glyph(rdpUpdate* update, CACHE_GLYPH_ORDER* cache_glyph)
int i;
Pixmap bitmap;
GLYPH_DATA* glyph;
xfInfo* xfi = GET_XFI(update);
xfInfo* xfi = ((xfContext*) update->context)->xfi;
rdpCache* cache = update->context->cache;
for (i = 0; i < cache_glyph->cGlyphs; i++)
{
glyph = cache_glyph->glyphData[i];
bitmap = xf_glyph_new(xfi, glyph->cx, glyph->cy, glyph->aj);
glyph_put(xfi->cache->glyph, cache_glyph->cacheId, glyph->cacheIndex, glyph, (void*) bitmap);
glyph_put(cache->glyph, cache_glyph->cacheId, glyph->cacheIndex, glyph, (void*) bitmap);
}
}
@ -816,8 +819,8 @@ void xf_gdi_cache_glyph_v2(rdpUpdate* update, CACHE_GLYPH_V2_ORDER* cache_glyph_
void xf_gdi_cache_brush(rdpUpdate* update, CACHE_BRUSH_ORDER* cache_brush)
{
xfInfo* xfi = GET_XFI(update);
brush_put(xfi->cache->brush, cache_brush->index, cache_brush->data, cache_brush->bpp);
rdpCache* cache = update->context->cache;
brush_put(cache->brush, cache_brush->index, cache_brush->data, cache_brush->bpp);
}
void xf_gdi_surface_bits(rdpUpdate* update, SURFACE_BITS_COMMAND* surface_bits_command)
@ -825,7 +828,7 @@ void xf_gdi_surface_bits(rdpUpdate* update, SURFACE_BITS_COMMAND* surface_bits_c
int i, tx, ty;
XImage* image;
RFX_MESSAGE* message;
xfInfo* xfi = GET_XFI(update);
xfInfo* xfi = ((xfContext*) update->context)->xfi;
RFX_CONTEXT* context = (RFX_CONTEXT*) xfi->rfx_context;
NSC_CONTEXT* ncontext = (NSC_CONTEXT*) xfi->nsc_context;

View File

@ -214,7 +214,7 @@ void xf_rail_send_windowmove(xfInfo* xfi, uint32 windowId, uint32 left, uint32 t
rdpChanMan* chanman;
RAIL_WINDOW_MOVE_ORDER window_move;
chanman = GET_CHANMAN(xfi->instance);
chanman = xfi->context->chanman;
window_move.windowId = windowId;
window_move.left = left;
@ -227,14 +227,18 @@ void xf_rail_send_windowmove(xfInfo* xfi, uint32 windowId, uint32 left, uint32 t
void xf_rail_send_activate(xfInfo* xfi, Window xwindow, boolean enabled)
{
rdpRail* rail;
rdpChanMan* chanman;
rdpWindow* rail_window;
RAIL_ACTIVATE_ORDER activate;
chanman = GET_CHANMAN(xfi->instance);
rail_window = window_list_get_by_extra_id(xfi->rail->list, (void*)xwindow);
chanman = xfi->context->chanman;
rail = ((rdpContext*) xfi->context)->rail;
if (rail_window == NULL) return;
rail_window = window_list_get_by_extra_id(rail->list, (void*) xwindow);
if (rail_window == NULL)
return;
activate.windowId = rail_window->windowId;
activate.enabled = enabled;
@ -247,7 +251,7 @@ void xf_rail_send_client_system_command(xfInfo* xfi, uint32 windowId, uint16 com
rdpChanMan* chanman;
RAIL_SYSCOMMAND_ORDER syscommand;
chanman = GET_CHANMAN(xfi->instance);
chanman = xfi->context->chanman;
syscommand.windowId = windowId;
syscommand.command = command;
@ -316,10 +320,12 @@ void xf_process_rail_server_sysparam_event(xfInfo* xfi, rdpChanMan* chanman, RDP
void xf_process_rail_server_minmaxinfo_event(xfInfo* xfi, rdpChanMan* chanman, RDP_EVENT* event)
{
RAIL_MINMAXINFO_ORDER* minmax = (RAIL_MINMAXINFO_ORDER*)event->user_data;
rdpRail* rail;
rdpWindow* rail_window = NULL;
RAIL_MINMAXINFO_ORDER* minmax = (RAIL_MINMAXINFO_ORDER*) event->user_data;
rail_window = window_list_get_by_id(xfi->rail->list, minmax->windowId);
rail = ((rdpContext*) xfi->context)->rail;
rail_window = window_list_get_by_id(rail->list, minmax->windowId);
if (rail_window != NULL)
{
@ -356,10 +362,12 @@ const char* movetype_names[] =
void xf_process_rail_server_localmovesize_event(xfInfo* xfi, rdpChanMan* chanman, RDP_EVENT* event)
{
rdpRail* rail;
rdpWindow* rail_window = NULL;
RAIL_LOCALMOVESIZE_ORDER* movesize = (RAIL_LOCALMOVESIZE_ORDER*) event->user_data;
rail_window = window_list_get_by_id(xfi->rail->list, movesize->windowId);
rail = ((rdpContext*) xfi->context)->rail;
rail_window = window_list_get_by_id(rail->list, movesize->windowId);
if (rail_window != NULL)
{

View File

@ -74,23 +74,39 @@ struct thread_data
freerdp* instance;
};
void xf_context_size(freerdp* instance, uint32* size)
{
*size = sizeof(xfContext);
}
void xf_context_new(freerdp* instance, xfContext* context)
{
context->chanman = freerdp_chanman_new();
}
void xf_context_free(freerdp* instance, xfContext* context)
{
}
void xf_sw_begin_paint(rdpUpdate* update)
{
GDI* gdi;
gdi = GET_GDI(update);
rdpGdi* gdi = update->context->gdi;
gdi->primary->hdc->hwnd->invalid->null = 1;
gdi->primary->hdc->hwnd->ninvalid = 0;
}
void xf_sw_end_paint(rdpUpdate* update)
{
GDI* gdi;
rdpGdi* gdi;
xfInfo* xfi;
sint32 x, y;
uint32 w, h;
xfContext* context;
gdi = GET_GDI(update);
xfi = GET_XFI(update);
context = (xfContext*) update->context;
gdi = update->context->gdi;
xfi = context->xfi;
if (xfi->remote_app != True)
{
@ -143,7 +159,7 @@ void xf_sw_end_paint(rdpUpdate* update)
w = gdi->primary->hdc->hwnd->invalid->w;
h = gdi->primary->hdc->hwnd->invalid->h;
xf_rail_paint(xfi, update->rail, x, y, x + w - 1, y + h - 1);
xf_rail_paint(xfi, update->context->rail, x, y, x + w - 1, y + h - 1);
}
}
@ -152,12 +168,12 @@ void xf_sw_desktop_resize(rdpUpdate* update)
xfInfo* xfi;
rdpSettings* settings;
xfi = GET_XFI(update);
xfi = ((xfContext*) update->context)->xfi;
settings = xfi->instance->settings;
if (xfi->fullscreen != True)
{
GDI* gdi = GET_GDI(update);
rdpGdi* gdi = update->context->gdi;
gdi_resize(gdi, xfi->width, xfi->height);
if (xfi->image)
@ -173,7 +189,7 @@ void xf_sw_desktop_resize(rdpUpdate* update)
void xf_hw_begin_paint(rdpUpdate* update)
{
xfInfo* xfi;
xfi = GET_XFI(update);
xfi = ((xfContext*) update->context)->xfi;
xfi->hdc->hwnd->invalid->null = 1;
xfi->hdc->hwnd->ninvalid = 0;
}
@ -184,7 +200,7 @@ void xf_hw_end_paint(rdpUpdate* update)
sint32 x, y;
uint32 w, h;
xfi = GET_XFI(update);
xfi = ((xfContext*) update->context)->xfi;
if (xfi->remote_app)
{
@ -196,7 +212,7 @@ void xf_hw_end_paint(rdpUpdate* update)
w = xfi->hdc->hwnd->invalid->w;
h = xfi->hdc->hwnd->invalid->h;
xf_rail_paint(xfi, update->rail, x, y, x + w - 1, y + h - 1);
xf_rail_paint(xfi, update->context->rail, x, y, x + w - 1, y + h - 1);
}
}
@ -206,7 +222,7 @@ void xf_hw_desktop_resize(rdpUpdate* update)
boolean same;
rdpSettings* settings;
xfi = GET_XFI(update);
xfi = ((xfContext*) update->context)->xfi;
settings = xfi->instance->settings;
if (xfi->fullscreen != True)
@ -242,7 +258,7 @@ void xf_bitmap_new(rdpUpdate* update, xfBitmap* bitmap)
uint8* cdata;
XImage* image;
rdpBitmap* _bitmap;
xfInfo* xfi = GET_XFI(update);
xfInfo* xfi = ((xfContext*) update->context)->xfi;
_bitmap = (rdpBitmap*) &bitmap->bitmap;
bitmap->pixmap = XCreatePixmap(xfi->display, xfi->drawable, _bitmap->width, _bitmap->height, xfi->depth);
@ -266,7 +282,7 @@ void xf_bitmap_new(rdpUpdate* update, xfBitmap* bitmap)
void xf_offscreen_bitmap_new(rdpUpdate* update, xfBitmap* bitmap)
{
rdpBitmap* _bitmap;
xfInfo* xfi = GET_XFI(update);
xfInfo* xfi = ((xfContext*) update->context)->xfi;
_bitmap = (rdpBitmap*) &bitmap->bitmap;
bitmap->pixmap = XCreatePixmap(xfi->display, xfi->drawable, _bitmap->width, _bitmap->height, xfi->depth);
@ -274,7 +290,7 @@ void xf_offscreen_bitmap_new(rdpUpdate* update, xfBitmap* bitmap)
void xf_set_surface(rdpUpdate* update, xfBitmap* bitmap, boolean primary)
{
xfInfo* xfi = GET_XFI(update);
xfInfo* xfi = ((xfContext*) update->context)->xfi;
if (primary)
xfi->drawing = xfi->primary;
@ -284,7 +300,7 @@ void xf_set_surface(rdpUpdate* update, xfBitmap* bitmap, boolean primary)
void xf_bitmap_free(rdpUpdate* update, xfBitmap* bitmap)
{
xfInfo* xfi = GET_XFI(update);
xfInfo* xfi = ((xfContext*) update->context)->xfi;
if (bitmap->pixmap != 0)
XFreePixmap(xfi->display, bitmap->pixmap);
@ -297,7 +313,7 @@ void xf_pointer_size(rdpUpdate* update, uint32* size)
void xf_pointer_set(rdpUpdate* update, xfPointer* pointer)
{
xfInfo* xfi = GET_XFI(update);
xfInfo* xfi = ((xfContext*) update->context)->xfi;
if (xfi->remote_app != True)
XDefineCursor(xfi->display, xfi->window->handle, pointer->cursor);
@ -309,7 +325,7 @@ void xf_pointer_new(rdpUpdate* update, xfPointer* pointer)
XcursorImage ci;
rdpPointer* _pointer;
xfi = GET_XFI(update);
xfi = ((xfContext*) update->context)->xfi;
_pointer = (rdpPointer*) &pointer->pointer;
memset(&ci, 0, sizeof(ci));
@ -339,7 +355,7 @@ void xf_pointer_new(rdpUpdate* update, xfPointer* pointer)
void xf_pointer_free(rdpUpdate* update, xfPointer* pointer)
{
xfInfo* xfi = GET_XFI(update);
xfInfo* xfi = ((xfContext*) update->context)->xfi;
if (pointer->cursor != 0)
XFreeCursor(xfi->display, pointer->cursor);
@ -347,7 +363,7 @@ void xf_pointer_free(rdpUpdate* update, xfPointer* pointer)
boolean xf_get_fds(freerdp* instance, void** rfds, int* rcount, void** wfds, int* wcount)
{
xfInfo* xfi = GET_XFI(instance);
xfInfo* xfi = ((xfContext*) instance->context)->xfi;
rfds[*rcount] = (void*)(long)(xfi->xfds);
(*rcount)++;
@ -358,7 +374,7 @@ boolean xf_get_fds(freerdp* instance, void** rfds, int* rcount, void** wfds, int
boolean xf_check_fds(freerdp* instance, fd_set* set)
{
XEvent xevent;
xfInfo* xfi = GET_XFI(instance);
xfInfo* xfi = ((xfContext*) instance->context)->xfi;
while (XPending(xfi->display))
{
@ -510,8 +526,9 @@ boolean xf_pre_connect(freerdp* instance)
rdpSettings* settings;
xfi = (xfInfo*) xzalloc(sizeof(xfInfo));
SET_XFI(instance, xfi);
((xfContext*) instance->context)->xfi = xfi;
xfi->context = (xfContext*) instance->context;
xfi->context->settings = instance->settings;
xfi->instance = instance;
settings = instance->settings;
@ -542,7 +559,7 @@ boolean xf_pre_connect(freerdp* instance)
settings->order_support[NEG_ELLIPSE_SC_INDEX] = False;
settings->order_support[NEG_ELLIPSE_CB_INDEX] = False;
freerdp_chanman_pre_connect(GET_CHANMAN(instance), instance);
freerdp_chanman_pre_connect(xfi->context->chanman, instance);
xfi->display = XOpenDisplay(NULL);
@ -579,9 +596,7 @@ boolean xf_pre_connect(freerdp* instance)
xfi->clrconv->invert = 0;
xfi->clrconv->rgb555 = 0;
xfi->cache = cache_new(instance->settings);
instance->update->cache = (void*) xfi->cache;
instance->cache = instance->update->cache;
instance->context->cache = cache_new(instance->settings);
xfi->xfds = ConnectionNumber(xfi->display);
xfi->screen_number = DefaultScreen(xfi->display);
@ -607,16 +622,19 @@ boolean xf_post_connect(freerdp* instance)
{
xfInfo* xfi;
XGCValues gcv;
rdpCache* cache;
rdpChanMan* chanman;
xfi = GET_XFI(instance);
SET_XFI(instance->update, xfi);
xfi = ((xfContext*) instance->context)->xfi;
cache = instance->context->cache;
chanman = xfi->context->chanman;
if (xf_get_pixmap_info(xfi) != True)
return False;
if (xfi->sw_gdi)
{
GDI* gdi;
rdpGdi* gdi;
uint32 flags;
flags = CLRCONV_ALPHA;
@ -627,7 +645,7 @@ boolean xf_post_connect(freerdp* instance)
flags |= CLRBUF_16BPP;
gdi_init(instance, flags, NULL);
gdi = GET_GDI(instance->update);
gdi = instance->context->gdi;
xfi->primary_buffer = gdi->primary_buffer;
}
else
@ -697,36 +715,35 @@ boolean xf_post_connect(freerdp* instance)
}
pointer_cache_register_callbacks(instance->update);
xfi->cache->pointer->PointerSize = (cbPointerSize) xf_pointer_size;
xfi->cache->pointer->PointerSet = (cbPointerSet) xf_pointer_set;
xfi->cache->pointer->PointerNew = (cbPointerNew) xf_pointer_new;
xfi->cache->pointer->PointerFree = (cbPointerFree) xf_pointer_free;
cache->pointer->PointerSize = (cbPointerSize) xf_pointer_size;
cache->pointer->PointerSet = (cbPointerSet) xf_pointer_set;
cache->pointer->PointerNew = (cbPointerNew) xf_pointer_new;
cache->pointer->PointerFree = (cbPointerFree) xf_pointer_free;
if (xfi->sw_gdi != True)
{
bitmap_cache_register_callbacks(instance->update);
xfi->cache->bitmap->BitmapSize = (cbBitmapSize) xf_bitmap_size;
xfi->cache->bitmap->BitmapNew = (cbBitmapNew) xf_bitmap_new;
xfi->cache->bitmap->BitmapFree = (cbBitmapFree) xf_bitmap_free;
cache->bitmap->BitmapSize = (cbBitmapSize) xf_bitmap_size;
cache->bitmap->BitmapNew = (cbBitmapNew) xf_bitmap_new;
cache->bitmap->BitmapFree = (cbBitmapFree) xf_bitmap_free;
offscreen_cache_register_callbacks(instance->update);
xfi->cache->offscreen->OffscreenBitmapSize = (cbOffscreenBitmapSize) xf_bitmap_size;
xfi->cache->offscreen->OffscreenBitmapNew = (cbOffscreenBitmapNew) xf_offscreen_bitmap_new;
xfi->cache->offscreen->OffscreenBitmapFree = (cbOffscreenBitmapFree) xf_bitmap_free;
xfi->cache->offscreen->SetSurface = (cbSetSurface) xf_set_surface;
cache->offscreen->OffscreenBitmapSize = (cbOffscreenBitmapSize) xf_bitmap_size;
cache->offscreen->OffscreenBitmapNew = (cbOffscreenBitmapNew) xf_offscreen_bitmap_new;
cache->offscreen->OffscreenBitmapFree = (cbOffscreenBitmapFree) xf_bitmap_free;
cache->offscreen->SetSurface = (cbSetSurface) xf_set_surface;
}
xfi->rail = rail_new(instance->settings);
instance->update->rail = (void*) xfi->rail;
rail_register_update_callbacks(xfi->rail, instance->update);
xf_rail_register_callbacks(xfi, xfi->rail);
instance->context->rail = rail_new(instance->settings);
rail_register_update_callbacks(instance->context->rail, instance->update);
xf_rail_register_callbacks(xfi, instance->context->rail);
freerdp_chanman_post_connect(GET_CHANMAN(instance), instance);
freerdp_chanman_post_connect(chanman, instance);
xf_tsmf_init(xfi, xv_port);
if (xfi->remote_app != True)
xf_cliprdr_init(xfi, GET_CHANMAN(instance));
xf_cliprdr_init(xfi, chanman);
return True;
}
@ -799,7 +816,7 @@ void xf_process_channel_event(rdpChanMan* chanman, freerdp* instance)
xfInfo* xfi;
RDP_EVENT* event;
xfi = GET_XFI(instance);
xfi = ((xfContext*) instance->context)->xfi;
event = freerdp_chanman_pop_event(chanman);
@ -829,6 +846,8 @@ void xf_process_channel_event(rdpChanMan* chanman, freerdp* instance)
void xf_window_free(xfInfo* xfi)
{
rdpContext* context = xfi->instance->context;
XFreeModifiermap(xfi->modifier_map);
xfi->modifier_map = 0;
@ -851,14 +870,14 @@ void xf_window_free(xfInfo* xfi)
xfi->image = NULL;
}
if (xfi->cache)
if (context->cache)
{
cache_free(xfi->cache);
xfi->cache = NULL;
cache_free(context->cache);
context->cache = NULL;
}
xfree(xfi->clrconv);
rail_free(xfi->rail);
rail_free(context->rail);
xf_tsmf_uninit(xfi);
xf_cliprdr_uninit(xfi);
@ -891,8 +910,8 @@ int xfreerdp_run(freerdp* instance)
if (!instance->Connect(instance))
return 0;
xfi = GET_XFI(instance);
chanman = GET_CHANMAN(instance);
xfi = ((xfContext*) instance->context)->xfi;
chanman = ((xfContext*) instance->context)->chanman;
while (1)
{
@ -996,7 +1015,7 @@ int main(int argc, char* argv[])
{
pthread_t thread;
freerdp* instance;
rdpChanMan* chanman;
xfContext* context;
struct thread_data* data;
freerdp_handle_signals();
@ -1013,13 +1032,16 @@ int main(int argc, char* argv[])
instance->Authenticate = xf_authenticate;
instance->ReceiveChannelData = xf_receive_channel_data;
chanman = freerdp_chanman_new();
SET_CHANMAN(instance, chanman);
instance->ContextSize = (pcContextSize) xf_context_size;
instance->ContextNew = (pcContextNew) xf_context_new;
instance->ContextFree = (pcContextFree) xf_context_free;
freerdp_context_new(instance);
instance->settings->sw_gdi = False;
context = (xfContext*) instance->context;
if (freerdp_parse_args(instance->settings, argc, argv,
xf_process_plugin_args, chanman, xf_process_ui_args, NULL) < 0)
xf_process_plugin_args, context->chanman, xf_process_ui_args, NULL) < 0)
return 1;
data = (struct thread_data*) xzalloc(sizeof(struct thread_data));

View File

@ -35,12 +35,6 @@ typedef struct xf_info xfInfo;
#include "xf_window.h"
#include "xf_monitor.h"
#define SET_XFI(_instance, _xfi) (_instance)->client = _xfi
#define GET_XFI(_instance) ((xfInfo*) ((_instance)->client))
#define SET_CHANMAN(_instance, _chanman) (_instance)->chanman = _chanman
#define GET_CHANMAN(_instance) ((rdpChanMan*) ((_instance)->chanman))
struct xf_WorkArea
{
uint32 x;
@ -64,8 +58,21 @@ struct xf_bitmap
};
typedef struct xf_bitmap xfBitmap;
struct xf_context
{
rdpContext _p;
xfInfo* xfi;
rdpChanMan* chanman;
rdpSettings* settings;
};
typedef struct xf_context xfContext;
struct xf_info
{
freerdp* instance;
xfContext* context;
GC gc;
int bpp;
int xfds;
@ -90,14 +97,11 @@ struct xf_info
boolean grab_keyboard;
boolean unobscured;
boolean decorations;
freerdp* instance;
xfWindow* window;
xfWorkArea workArea;
int current_desktop;
boolean remote_app;
HCLRCONV clrconv;
rdpRail* rail;
rdpCache* cache;
HGDI_DC hdc;
boolean sw_gdi;

View File

@ -39,18 +39,21 @@
#include <freerdp/chanman/chanman.h>
#include <freerdp/plugins/cliprdr.h>
#define SET_TFI(_instance, _tfi) (_instance)->client = _tfi
#define GET_TFI(_instance) ((tfInfo*) ((_instance)->client))
#define SET_CHANMAN(_instance, _chanman) (_instance)->chanman = _chanman
#define GET_CHANMAN(_instance) ((rdpChanMan*) ((_instance)->chanman))
struct tf_info
{
void* data;
};
typedef struct tf_info tfInfo;
struct tf_context
{
rdpContext _p;
tfInfo* tfi;
rdpChanMan* chanman;
};
typedef struct tf_context tfContext;
freerdp_sem g_sem;
static int g_thread_count = 0;
@ -62,19 +65,30 @@ struct thread_data
#include <freerdp/freerdp.h>
#include <freerdp/utils/args.h>
void tf_context_size(freerdp* instance, uint32* size)
{
*size = sizeof(tfContext);
}
void tf_context_new(freerdp* instance, tfContext* context)
{
context->chanman = freerdp_chanman_new();
}
void tf_context_free(freerdp* instance, tfContext* context)
{
}
void tf_begin_paint(rdpUpdate* update)
{
GDI* gdi = GET_GDI(update);
rdpGdi* gdi = update->context->gdi;
gdi->primary->hdc->hwnd->invalid->null = 1;
}
void tf_end_paint(rdpUpdate* update)
{
GDI* gdi;
tfInfo* tfi;
gdi = GET_GDI(update);
tfi = GET_TFI(update);
rdpGdi* gdi = update->context->gdi;
if (gdi->primary->hdc->hwnd->invalid->null)
return;
@ -113,6 +127,7 @@ void tf_process_channel_event(rdpChanMan* chanman, freerdp* instance)
RDP_EVENT* event;
event = freerdp_chanman_pop_event(chanman);
if (event)
{
switch (event->event_type)
@ -124,6 +139,7 @@ void tf_process_channel_event(rdpChanMan* chanman, freerdp* instance)
printf("tf_process_channel_event: unknown event type %d\n", event->event_type);
break;
}
freerdp_event_free(event);
}
}
@ -131,10 +147,12 @@ void tf_process_channel_event(rdpChanMan* chanman, freerdp* instance)
boolean tf_pre_connect(freerdp* instance)
{
tfInfo* tfi;
tfContext* context;
rdpSettings* settings;
context = (tfContext*) instance->context;
tfi = (tfInfo*) xzalloc(sizeof(tfInfo));
SET_TFI(instance, tfi);
context->tfi = tfi;
settings = instance->settings;
@ -161,26 +179,25 @@ boolean tf_pre_connect(freerdp* instance)
settings->order_support[NEG_ELLIPSE_SC_INDEX] = True;
settings->order_support[NEG_ELLIPSE_CB_INDEX] = True;
freerdp_chanman_pre_connect(GET_CHANMAN(instance), instance);
freerdp_chanman_pre_connect(context->chanman, instance);
return True;
}
boolean tf_post_connect(freerdp* instance)
{
GDI* gdi;
tfInfo* tfi;
rdpGdi* gdi;
tfContext* context;
tfi = GET_TFI(instance);
SET_TFI(instance->update, tfi);
context = (tfContext*) instance->context;
gdi_init(instance, CLRCONV_ALPHA | CLRBUF_16BPP | CLRBUF_32BPP, NULL);
gdi = GET_GDI(instance->update);
gdi = instance->context->gdi;
instance->update->BeginPaint = tf_begin_paint;
instance->update->EndPaint = tf_end_paint;
freerdp_chanman_post_connect(GET_CHANMAN(instance), instance);
freerdp_chanman_post_connect(context->chanman, instance);
return True;
}
@ -196,12 +213,14 @@ int tfreerdp_run(freerdp* instance)
void* wfds[32];
fd_set rfds_set;
fd_set wfds_set;
tfContext* context;
rdpChanMan* chanman;
memset(rfds, 0, sizeof(rfds));
memset(wfds, 0, sizeof(wfds));
chanman = GET_CHANMAN(instance);
context = (tfContext*) instance->context;
chanman = context->chanman;
instance->Connect(instance);
@ -293,6 +312,7 @@ int main(int argc, char* argv[])
{
pthread_t thread;
freerdp* instance;
tfContext* context;
struct thread_data* data;
rdpChanMan* chanman;
@ -305,8 +325,13 @@ int main(int argc, char* argv[])
instance->PostConnect = tf_post_connect;
instance->ReceiveChannelData = tf_receive_channel_data;
chanman = freerdp_chanman_new();
SET_CHANMAN(instance, chanman);
instance->ContextSize = (pcContextSize) tf_context_size;
instance->ContextNew = (pcContextNew) tf_context_new;
instance->ContextFree = (pcContextFree) tf_context_free;
freerdp_context_new(instance);
context = (tfContext*) instance->context;
chanman = context->chanman;
freerdp_parse_args(instance->settings, argc, argv, tf_process_plugin_args, chanman, NULL, NULL);

View File

@ -25,8 +25,6 @@
#include <freerdp/update.h>
#include <freerdp/utils/stream.h>
typedef struct rdp_cache rdpCache;
#include <freerdp/cache/glyph.h>
#include <freerdp/cache/brush.h>
#include <freerdp/cache/pointer.h>

View File

@ -20,7 +20,12 @@
#ifndef __FREERDP_H
#define __FREERDP_H
typedef struct rdp_rdp rdpRdp;
typedef struct rdp_gdi rdpGdi;
typedef struct rdp_rail rdpRail;
typedef struct rdp_cache rdpCache;
typedef struct rdp_freerdp freerdp;
typedef struct rdp_context rdpContext;
#include <freerdp/api.h>
#include <freerdp/types.h>
@ -47,18 +52,32 @@ typedef int (*pcSendChannelData)(freerdp* instance, int channelId, uint8* data,
typedef int (*pcReceiveChannelData)(freerdp* instance, int channelId, uint8* data, int size, int flags, int total_size);
typedef void (*pcDisconnect)(freerdp* instance);
typedef void (*pcContextSize)(freerdp* instance, uint32* size);
typedef void (*pcContextNew)(freerdp* instance, rdpContext* context);
typedef void (*pcContextFree)(freerdp* instance, rdpContext* context);
struct rdp_context
{
freerdp* instance;
rdpRdp* rdp;
rdpGdi* gdi;
rdpRail* rail;
rdpCache* cache;
};
struct rdp_freerdp
{
void* rdp;
void* cache;
void* client;
void* chanman;
void* param4;
rdpContext* context;
rdpInput* input;
rdpUpdate* update;
rdpSettings* settings;
pcContextSize ContextSize;
pcContextNew ContextNew;
pcContextFree ContextFree;
pcConnect Connect;
pcPreConnect PreConnect;
pcPostConnect PostConnect;
@ -70,6 +89,9 @@ struct rdp_freerdp
pcDisconnect Disconnect;
};
FREERDP_API void freerdp_context_new(freerdp* instance);
FREERDP_API void freerdp_context_free(freerdp* instance);
FREERDP_API freerdp* freerdp_new();
FREERDP_API void freerdp_free(freerdp* instance);

View File

@ -230,8 +230,10 @@ struct gdi_bitmap
};
typedef struct gdi_bitmap gdiBitmap;
struct _GDI
struct rdp_gdi
{
rdpContext* context;
int width;
int height;
int dstBpp;
@ -250,24 +252,19 @@ struct _GDI
void* nsc_context;
gdiBitmap* tile;
gdiBitmap* image;
rdpCache* cache;
};
typedef struct _GDI GDI;
FREERDP_API uint32 gdi_rop3_code(uint8 code);
FREERDP_API uint8* gdi_get_bitmap_pointer(HGDI_DC hdcBmp, int x, int y);
FREERDP_API uint8* gdi_get_brush_pointer(HGDI_DC hdcBrush, int x, int y);
FREERDP_API int gdi_is_mono_pixel_set(uint8* data, int x, int y, int width);
FREERDP_API gdiBitmap* gdi_bitmap_new_ex(GDI *gdi, int width, int height, int bpp, uint8* data);
FREERDP_API void gdi_bitmap_free_ex(gdiBitmap *gdi_bmp);
FREERDP_API void gdi_resize(GDI* gdi, int width, int height);
FREERDP_API gdiBitmap* gdi_bitmap_new_ex(rdpGdi* gdi, int width, int height, int bpp, uint8* data);
FREERDP_API void gdi_bitmap_free_ex(gdiBitmap* gdi_bmp);
FREERDP_API void gdi_resize(rdpGdi* gdi, int width, int height);
FREERDP_API int gdi_init(freerdp* instance, uint32 flags, uint8* buffer);
FREERDP_API void gdi_free(freerdp* instance);
#define SET_GDI(_instance, _gdi) (_instance)->gdi = _gdi
#define GET_GDI(_instance) ((GDI*) ((_instance)->gdi))
#ifdef WITH_DEBUG_GDI
#define DEBUG_GDI(fmt, ...) DEBUG_CLASS(GDI, fmt, ## __VA_ARGS__)
#else

View File

@ -20,6 +20,10 @@
#ifndef __INPUT_API_H
#define __INPUT_API_H
typedef struct rdp_input rdpInput;
#include <freerdp/freerdp.h>
/* keyboard Flags */
#define KBD_FLAGS_EXTENDED 0x0100
#define KBD_FLAGS_DOWN 0x4000
@ -48,8 +52,6 @@
#define RDP_CLIENT_INPUT_PDU_HEADER_LENGTH 4
typedef struct rdp_input rdpInput;
typedef void (*pcSynchronizeEvent)(rdpInput* input, uint32 flags);
typedef void (*pcKeyboardEvent)(rdpInput* input, uint16 flags, uint16 code);
typedef void (*pcUnicodeKeyboardEvent)(rdpInput* input, uint16 code);
@ -58,15 +60,15 @@ typedef void (*pcExtendedMouseEvent)(rdpInput* input, uint16 flags, uint16 x, ui
struct rdp_input
{
void* rdp;
void* param1;
void* param2;
rdpContext* context;
pcSynchronizeEvent SynchronizeEvent;
pcKeyboardEvent KeyboardEvent;
pcUnicodeKeyboardEvent UnicodeKeyboardEvent;
pcMouseEvent MouseEvent;
pcExtendedMouseEvent ExtendedMouseEvent;
void* param1;
};
#endif /* __INPUT_API_H */

View File

@ -24,11 +24,10 @@
#include <freerdp/rail.h>
#include <freerdp/types.h>
#include <freerdp/update.h>
#include <freerdp/freerdp.h>
#include <freerdp/utils/stream.h>
#include <freerdp/codec/color.h>
typedef struct rdp_rail rdpRail;
#include <freerdp/rail/icon.h>
#include <freerdp/rail/window.h>
#include <freerdp/rail/window_list.h>

View File

@ -20,8 +20,11 @@
#ifndef __UPDATE_API_H
#define __UPDATE_API_H
typedef struct rdp_update rdpUpdate;
#include <freerdp/rail.h>
#include <freerdp/types.h>
#include <freerdp/freerdp.h>
#include <freerdp/utils/pcap.h>
#include <freerdp/utils/stream.h>
@ -1036,8 +1039,6 @@ typedef struct _SURFACE_BITS_COMMAND SURFACE_BITS_COMMAND;
/* Update Interface */
typedef struct rdp_update rdpUpdate;
typedef void (*pcBeginPaint)(rdpUpdate* update);
typedef void (*pcEndPaint)(rdpUpdate* update);
typedef void (*pcSetBounds)(rdpUpdate* update, BOUNDS* bounds);
@ -1114,12 +1115,7 @@ typedef void (*pcBitmapDecompress)(rdpUpdate* update, rdpBitmap* bitmap);
struct rdp_update
{
void* rdp;
void* gdi;
void* rail;
void* cache;
void* client;
void* chanman;
rdpContext* context;
boolean dump_rfx;
boolean play_rfx;

View File

@ -36,7 +36,7 @@ void bitmap_free(rdpBitmap* bitmap)
void update_gdi_memblt(rdpUpdate* update, MEMBLT_ORDER* memblt)
{
rdpBitmap* bitmap;
rdpCache* cache = (rdpCache*) update->cache;
rdpCache* cache = update->context->cache;
if (memblt->cacheId == 0xFF)
bitmap = offscreen_cache_get(cache->offscreen, memblt->cacheIndex);
@ -50,7 +50,7 @@ void update_gdi_memblt(rdpUpdate* update, MEMBLT_ORDER* memblt)
void update_gdi_mem3blt(rdpUpdate* update, MEM3BLT_ORDER* mem3blt)
{
rdpBitmap* bitmap;
rdpCache* cache = (rdpCache*) update->cache;
rdpCache* cache = update->context->cache;
if (mem3blt->cacheId == 0xFF)
bitmap = offscreen_cache_get(cache->offscreen, mem3blt->cacheIndex);
@ -66,7 +66,7 @@ void update_gdi_cache_bitmap(rdpUpdate* update, CACHE_BITMAP_V2_ORDER* cache_bit
rdpBitmap* bitmap;
rdpBitmap* prevBitmap;
uint32 size = sizeof(rdpBitmap);
rdpCache* cache = (rdpCache*) update->cache;
rdpCache* cache = update->context->cache;
bitmap = cache_bitmap->bitmap;
IFCALL(cache->bitmap->BitmapSize, update, &size);
@ -132,7 +132,7 @@ void bitmap_cache_put(rdpBitmapCache* bitmap_cache, uint8 id, uint16 index, rdpB
void bitmap_cache_register_callbacks(rdpUpdate* update)
{
rdpCache* cache = (rdpCache*) update->cache;
rdpCache* cache = update->context->cache;
cache->bitmap->MemBlt = update->MemBlt;
cache->bitmap->Mem3Blt = update->Mem3Blt;

View File

@ -41,7 +41,7 @@ void update_pointer_new(rdpUpdate* update, POINTER_NEW_UPDATE* pointer_new)
{
rdpPointer* pointer;
uint32 size = sizeof(rdpPointer);
rdpCache* cache = (rdpCache*) update->cache;
rdpCache* cache = (rdpCache*) update->context->cache;
IFCALL(cache->pointer->PointerSize, update, &size);
@ -68,7 +68,7 @@ void update_pointer_new(rdpUpdate* update, POINTER_NEW_UPDATE* pointer_new)
void update_pointer_cached(rdpUpdate* update, POINTER_CACHED_UPDATE* pointer_cached)
{
rdpPointer* pointer;
rdpCache* cache = (rdpCache*) update->cache;
rdpCache* cache = (rdpCache*) update->context->cache;
pointer = pointer_cache_get(cache->pointer, pointer_cached->cacheIndex);
IFCALL(cache->pointer->PointerSet, update, pointer);

View File

@ -80,8 +80,8 @@ set(LIBFREERDP_CORE_SRCS
transport.h
update.c
update.h
vchan.c
vchan.h
channel.c
channel.h
window.c
window.h
listener.c

View File

@ -26,28 +26,28 @@
#include <freerdp/utils/stream.h>
#include "rdp.h"
#include "vchan.h"
#include "channel.h"
boolean vchan_send(rdpVchan* vchan, uint16 channel_id, uint8* data, int size)
boolean freerdp_channel_send(freerdp* instance, uint16 channel_id, uint8* data, int size)
{
STREAM* s;
uint32 flags;
rdpChan* channel = NULL;
int i;
int i, left;
int chunk_size;
int left;
rdpChan* channel = NULL;
for (i = 0; i < vchan->instance->settings->num_channels; i++)
for (i = 0; i < instance->settings->num_channels; i++)
{
if (vchan->instance->settings->channels[i].chan_id == channel_id)
if (instance->settings->channels[i].chan_id == channel_id)
{
channel = &vchan->instance->settings->channels[i];
channel = &instance->settings->channels[i];
break;
}
}
if (channel == NULL)
{
printf("vchan_send: unknown channel_id %d\n", channel_id);
printf("freerdp_channel_send: unknown channel_id %d\n", channel_id);
return False;
}
@ -55,11 +55,11 @@ boolean vchan_send(rdpVchan* vchan, uint16 channel_id, uint8* data, int size)
left = size;
while (left > 0)
{
s = rdp_send_stream_init(vchan->instance->rdp);
s = rdp_send_stream_init(instance->context->rdp);
if (left > (int) vchan->instance->settings->vc_chunk_size)
if (left > (int) instance->settings->vc_chunk_size)
{
chunk_size = vchan->instance->settings->vc_chunk_size;
chunk_size = instance->settings->vc_chunk_size;
}
else
{
@ -76,7 +76,7 @@ boolean vchan_send(rdpVchan* vchan, uint16 channel_id, uint8* data, int size)
stream_check_size(s, chunk_size);
stream_write(s, data, chunk_size);
rdp_send(vchan->instance->rdp, s, channel_id);
rdp_send(instance->context->rdp, s, channel_id);
data += chunk_size;
left -= chunk_size;
@ -86,7 +86,7 @@ boolean vchan_send(rdpVchan* vchan, uint16 channel_id, uint8* data, int size)
return True;
}
void vchan_process(rdpVchan* vchan, STREAM* s, uint16 channel_id)
void freerdp_channel_process(freerdp* instance, STREAM* s, uint16 channel_id)
{
uint32 length;
uint32 flags;
@ -96,21 +96,7 @@ void vchan_process(rdpVchan* vchan, STREAM* s, uint16 channel_id)
stream_read_uint32(s, flags);
chunk_length = stream_get_left(s);
IFCALL(vchan->instance->ReceiveChannelData, vchan->instance,
IFCALL(instance->ReceiveChannelData, instance,
channel_id, stream_get_tail(s), chunk_length, flags, length);
}
rdpVchan* vchan_new(freerdp* instance)
{
rdpVchan* vchan;
vchan = xnew(rdpVchan);
vchan->instance = instance;
return vchan;
}
void vchan_free(rdpVchan* vchan)
{
xfree(vchan);
}

View File

@ -17,19 +17,10 @@
* limitations under the License.
*/
#ifndef __VCHAN_H
#define __VCHAN_H
#ifndef __CHANNEL_H
#define __CHANNEL_H
struct rdp_vchan
{
freerdp* instance;
};
typedef struct rdp_vchan rdpVchan;
boolean freerdp_channel_send(freerdp* instance, uint16 channel_id, uint8* data, int size);
void freerdp_channel_process(freerdp* instance, STREAM* s, uint16 channel_id);
boolean vchan_send(rdpVchan* vchan, uint16 channel_id, uint8* data, int size);
void vchan_process(rdpVchan* vchan, STREAM* s, uint16 channel_id);
rdpVchan* vchan_new(freerdp* instance);
void vchan_free(rdpVchan* vchan);
#endif /* __VCHAN_H */
#endif /* __CHANNEL_H */

View File

@ -32,11 +32,11 @@ boolean freerdp_connect(freerdp* instance)
rdpRdp* rdp;
boolean status;
rdp = (rdpRdp*) instance->rdp;
rdp = instance->context->rdp;
IFCALL(instance->PreConnect, instance);
status = rdp_client_connect((rdpRdp*) instance->rdp);
status = rdp_client_connect(rdp);
if (status)
{
@ -87,7 +87,7 @@ boolean freerdp_get_fds(freerdp* instance, void** rfds, int* rcount, void** wfds
{
rdpRdp* rdp;
rdp = (rdpRdp*) instance->rdp;
rdp = instance->context->rdp;
transport_get_fds(rdp->transport, rfds, rcount);
return True;
@ -95,12 +95,13 @@ boolean freerdp_get_fds(freerdp* instance, void** rfds, int* rcount, void** wfds
boolean freerdp_check_fds(freerdp* instance)
{
rdpRdp* rdp;
int status;
rdpRdp* rdp;
rdp = (rdpRdp*) instance->rdp;
rdp = instance->context->rdp;
status = rdp_check_fds(rdp);
if (status < 0)
return False;
@ -109,17 +110,45 @@ boolean freerdp_check_fds(freerdp* instance)
static int freerdp_send_channel_data(freerdp* instance, int channel_id, uint8* data, int size)
{
return rdp_send_channel_data(instance->rdp, channel_id, data, size);
return rdp_send_channel_data(instance->context->rdp, channel_id, data, size);
}
void freerdp_disconnect(freerdp* instance)
{
rdpRdp* rdp;
rdp = (rdpRdp*) instance->rdp;
rdp = instance->context->rdp;
transport_disconnect(rdp->transport);
}
void freerdp_context_new(freerdp* instance)
{
rdpRdp* rdp;
uint32 size = sizeof(rdpContext);
rdp = rdp_new(instance);
instance->input = rdp->input;
instance->update = rdp->update;
instance->settings = rdp->settings;
IFCALL(instance->ContextSize, instance, &size);
instance->context = (rdpContext*) xzalloc(size);
instance->context->instance = instance;
instance->context->rdp = rdp;
instance->update->context = instance->context;
instance->input->context = instance->context;
input_register_client_callbacks(rdp->input);
IFCALL(instance->ContextNew, instance, instance->context);
}
void freerdp_context_free(freerdp* instance)
{
IFCALL(instance->ContextFree, instance, instance->context);
}
freerdp* freerdp_new()
{
freerdp* instance;
@ -128,19 +157,11 @@ freerdp* freerdp_new()
if (instance != NULL)
{
rdpRdp* rdp = rdp_new(instance);
instance->rdp = (void*) rdp;
instance->input = rdp->input;
instance->update = rdp->update;
instance->settings = rdp->settings;
instance->Connect = freerdp_connect;
instance->GetFileDescriptor = freerdp_get_fds;
instance->CheckFileDescriptor = freerdp_check_fds;
instance->SendChannelData = freerdp_send_channel_data;
instance->Disconnect = freerdp_disconnect;
input_register_client_callbacks(rdp->input);
}
return instance;
@ -150,7 +171,7 @@ void freerdp_free(freerdp* freerdp)
{
if (freerdp)
{
rdp_free(freerdp->rdp);
rdp_free(freerdp->context->rdp);
xfree(freerdp);
}
}

View File

@ -54,9 +54,11 @@ void input_write_synchronize_event(STREAM* s, uint32 flags)
void input_send_synchronize_event(rdpInput* input, uint32 flags)
{
STREAM* s;
s = rdp_client_input_pdu_init(input->rdp, INPUT_EVENT_SYNC);
rdpRdp* rdp = input->context->rdp;
s = rdp_client_input_pdu_init(rdp, INPUT_EVENT_SYNC);
input_write_synchronize_event(s, flags);
rdp_send_client_input_pdu(input->rdp, s);
rdp_send_client_input_pdu(rdp, s);
}
void input_write_keyboard_event(STREAM* s, uint16 flags, uint16 code)
@ -69,9 +71,11 @@ void input_write_keyboard_event(STREAM* s, uint16 flags, uint16 code)
void input_send_keyboard_event(rdpInput* input, uint16 flags, uint16 code)
{
STREAM* s;
s = rdp_client_input_pdu_init(input->rdp, INPUT_EVENT_SCANCODE);
rdpRdp* rdp = input->context->rdp;
s = rdp_client_input_pdu_init(rdp, INPUT_EVENT_SCANCODE);
input_write_keyboard_event(s, flags, code);
rdp_send_client_input_pdu(input->rdp, s);
rdp_send_client_input_pdu(rdp, s);
}
void input_write_unicode_keyboard_event(STREAM* s, uint16 code)
@ -84,9 +88,11 @@ void input_write_unicode_keyboard_event(STREAM* s, uint16 code)
void input_send_unicode_keyboard_event(rdpInput* input, uint16 code)
{
STREAM* s;
s = rdp_client_input_pdu_init(input->rdp, INPUT_EVENT_UNICODE);
rdpRdp* rdp = input->context->rdp;
s = rdp_client_input_pdu_init(rdp, INPUT_EVENT_UNICODE);
input_write_unicode_keyboard_event(s, code);
rdp_send_client_input_pdu(input->rdp, s);
rdp_send_client_input_pdu(rdp, s);
}
void input_write_mouse_event(STREAM* s, uint16 flags, uint16 x, uint16 y)
@ -99,9 +105,11 @@ void input_write_mouse_event(STREAM* s, uint16 flags, uint16 x, uint16 y)
void input_send_mouse_event(rdpInput* input, uint16 flags, uint16 x, uint16 y)
{
STREAM* s;
s = rdp_client_input_pdu_init(input->rdp, INPUT_EVENT_MOUSE);
rdpRdp* rdp = input->context->rdp;
s = rdp_client_input_pdu_init(rdp, INPUT_EVENT_MOUSE);
input_write_mouse_event(s, flags, x, y);
rdp_send_client_input_pdu(input->rdp, s);
rdp_send_client_input_pdu(rdp, s);
}
void input_write_extended_mouse_event(STREAM* s, uint16 flags, uint16 x, uint16 y)
@ -114,26 +122,28 @@ void input_write_extended_mouse_event(STREAM* s, uint16 flags, uint16 x, uint16
void input_send_extended_mouse_event(rdpInput* input, uint16 flags, uint16 x, uint16 y)
{
STREAM* s;
s = rdp_client_input_pdu_init(input->rdp, INPUT_EVENT_MOUSEX);
rdpRdp* rdp = input->context->rdp;
s = rdp_client_input_pdu_init(rdp, INPUT_EVENT_MOUSEX);
input_write_extended_mouse_event(s, flags, x, y);
rdp_send_client_input_pdu(input->rdp, s);
rdp_send_client_input_pdu(rdp, s);
}
void input_send_fastpath_synchronize_event(rdpInput* input, uint32 flags)
{
rdpRdp* rdp = (rdpRdp*)input->rdp;
STREAM* s;
rdpRdp* rdp = input->context->rdp;
/* The FastPath Synchronization eventFlags has identical values as SlowPath */
s = fastpath_input_pdu_init(rdp->fastpath, (uint8)flags, FASTPATH_INPUT_EVENT_SYNC);
s = fastpath_input_pdu_init(rdp->fastpath, (uint8) flags, FASTPATH_INPUT_EVENT_SYNC);
fastpath_send_input_pdu(rdp->fastpath, s);
}
void input_send_fastpath_keyboard_event(rdpInput* input, uint16 flags, uint16 code)
{
rdpRdp* rdp = (rdpRdp*)input->rdp;
STREAM* s;
uint8 eventFlags = 0;
rdpRdp* rdp = input->context->rdp;
eventFlags |= (flags & KBD_FLAGS_RELEASE) ? FASTPATH_INPUT_KBDFLAGS_RELEASE : 0;
eventFlags |= (flags & KBD_FLAGS_EXTENDED) ? FASTPATH_INPUT_KBDFLAGS_EXTENDED : 0;
@ -144,8 +154,8 @@ void input_send_fastpath_keyboard_event(rdpInput* input, uint16 flags, uint16 co
void input_send_fastpath_unicode_keyboard_event(rdpInput* input, uint16 code)
{
rdpRdp* rdp = (rdpRdp*)input->rdp;
STREAM* s;
rdpRdp* rdp = input->context->rdp;
s = fastpath_input_pdu_init(rdp->fastpath, 0, FASTPATH_INPUT_EVENT_UNICODE);
stream_write_uint16(s, code); /* unicodeCode (2 bytes) */
@ -154,8 +164,8 @@ void input_send_fastpath_unicode_keyboard_event(rdpInput* input, uint16 code)
void input_send_fastpath_mouse_event(rdpInput* input, uint16 flags, uint16 x, uint16 y)
{
rdpRdp* rdp = (rdpRdp*)input->rdp;
STREAM* s;
rdpRdp* rdp = input->context->rdp;
s = fastpath_input_pdu_init(rdp->fastpath, 0, FASTPATH_INPUT_EVENT_MOUSE);
input_write_mouse_event(s, flags, x, y);
@ -164,8 +174,8 @@ void input_send_fastpath_mouse_event(rdpInput* input, uint16 flags, uint16 x, ui
void input_send_fastpath_extended_mouse_event(rdpInput* input, uint16 flags, uint16 x, uint16 y)
{
rdpRdp* rdp = (rdpRdp*)input->rdp;
STREAM* s;
rdpRdp* rdp = input->context->rdp;
s = fastpath_input_pdu_init(rdp->fastpath, 0, FASTPATH_INPUT_EVENT_MOUSEX);
input_write_extended_mouse_event(s, flags, x, y);
@ -174,7 +184,7 @@ void input_send_fastpath_extended_mouse_event(rdpInput* input, uint16 flags, uin
void input_register_client_callbacks(rdpInput* input)
{
rdpRdp* rdp = (rdpRdp*)input->rdp;
rdpRdp* rdp = input->context->rdp;
if (rdp->settings->fastpath_input)
{
@ -202,7 +212,7 @@ rdpInput* input_new(rdpRdp* rdp)
if (input != NULL)
{
input->rdp = rdp;
}
return input;

View File

@ -650,7 +650,7 @@ static boolean rdp_recv_tpkt_pdu(rdpRdp* rdp, STREAM* s)
if (channelId != MCS_GLOBAL_CHANNEL_ID)
{
vchan_process(rdp->vchan, s, channelId);
freerdp_channel_process(rdp->instance, s, channelId);
}
else
{
@ -774,7 +774,7 @@ static boolean rdp_recv_callback(rdpTransport* transport, STREAM* s, void* extra
int rdp_send_channel_data(rdpRdp* rdp, int channel_id, uint8* data, int size)
{
return vchan_send(rdp->vchan, channel_id, data, size);
return freerdp_channel_send(rdp->instance, channel_id, data, size);
}
/**
@ -807,6 +807,7 @@ rdpRdp* rdp_new(freerdp* instance)
if (rdp != NULL)
{
rdp->instance = instance;
rdp->settings = settings_new((void*) instance);
rdp->transport = transport_new(rdp->settings);
rdp->license = license_new(rdp);
@ -815,7 +816,6 @@ rdpRdp* rdp_new(freerdp* instance)
rdp->fastpath = fastpath_new(rdp);
rdp->nego = nego_new(rdp->transport);
rdp->mcs = mcs_new(rdp->transport);
rdp->vchan = vchan_new(instance);
rdp->redirection = redirection_new();
rdp->mppc = mppc_new(rdp);
}
@ -840,7 +840,6 @@ void rdp_free(rdpRdp* rdp)
fastpath_free(rdp->fastpath);
nego_free(rdp->nego);
mcs_free(rdp->mcs);
vchan_free(rdp->vchan);
redirection_free(rdp->redirection);
mppc_free(rdp);
xfree(rdp);

View File

@ -20,8 +20,6 @@
#ifndef __RDP_H
#define __RDP_H
typedef struct rdp_rdp rdpRdp;
#include "mcs.h"
#include "tpkt.h"
#include "fastpath.h"
@ -36,7 +34,7 @@ typedef struct rdp_rdp rdpRdp;
#include "connection.h"
#include "redirection.h"
#include "capabilities.h"
#include "vchan.h"
#include "channel.h"
#include "mppc.h"
#include <freerdp/freerdp.h>
@ -117,6 +115,7 @@ typedef struct rdp_rdp rdpRdp;
struct rdp_rdp
{
int state;
freerdp* instance;
struct rdp_mcs* mcs;
struct rdp_nego* nego;
struct rdp_input* input;
@ -126,7 +125,6 @@ struct rdp_rdp
struct rdp_redirection* redirection;
struct rdp_settings* settings;
struct rdp_transport* transport;
struct rdp_vchan* vchan;
struct rdp_mppc* mppc;
struct crypto_rc4_struct* rc4_decrypt_key;
int decrypt_use_count;

View File

@ -344,20 +344,20 @@ static void update_end_paint(rdpUpdate* update)
static void update_send_surface_command(rdpUpdate* update, STREAM* s)
{
rdpRdp* rdp = (rdpRdp*) update->rdp;
rdpRdp* rdp = update->context->rdp;
fastpath_send_fragmented_update_pdu(rdp->fastpath, s);
}
static void update_send_surface_bits(rdpUpdate* update, SURFACE_BITS_COMMAND* surface_bits_command)
{
rdpRdp* rdp = (rdpRdp*)update->rdp;
rdpRdp* rdp = update->context->rdp;
fastpath_send_surfcmd_surface_bits(rdp->fastpath, surface_bits_command);
}
static void update_send_synchronize(rdpUpdate* update)
{
rdpRdp* rdp = (rdpRdp*)update->rdp;
STREAM* s;
rdpRdp* rdp = update->context->rdp;
s = fastpath_update_pdu_init(rdp->fastpath);
stream_write_uint8(s, FASTPATH_UPDATETYPE_SYNCHRONIZE); /* updateHeader (1 byte) */
@ -367,15 +367,15 @@ static void update_send_synchronize(rdpUpdate* update)
static void update_send_desktop_resize(rdpUpdate* update)
{
rdpRdp* rdp = (rdpRdp*)update->rdp;
rdpRdp* rdp = update->context->rdp;
rdp_server_reactivate(rdp);
}
static void update_send_pointer_system(rdpUpdate* update, POINTER_SYSTEM_UPDATE* pointer_system)
{
rdpRdp* rdp = (rdpRdp*)update->rdp;
STREAM* s;
rdpRdp* rdp = update->context->rdp;
s = fastpath_update_pdu_init(rdp->fastpath);
/* updateHeader (1 byte) */
@ -406,8 +406,6 @@ rdpUpdate* update_new(rdpRdp* rdp)
if (update != NULL)
{
update->rdp = (void*) rdp;
update->bitmap_update.count = 64;
update->bitmap_update.bitmaps = (rdpBitmap*) xzalloc(sizeof(rdpBitmap) * update->bitmap_update.count);
}

View File

@ -363,7 +363,7 @@ INLINE int gdi_is_mono_pixel_set(uint8* data, int x, int y, int width)
return (data[byte] & (0x80 >> shift)) != 0;
}
HGDI_BITMAP gdi_create_bitmap(GDI* gdi, int width, int height, int bpp, uint8* data)
HGDI_BITMAP gdi_create_bitmap(rdpGdi* gdi, int width, int height, int bpp, uint8* data)
{
uint8* bmpData;
HGDI_BITMAP bitmap;
@ -374,7 +374,7 @@ HGDI_BITMAP gdi_create_bitmap(GDI* gdi, int width, int height, int bpp, uint8* d
return bitmap;
}
gdiBitmap* gdi_bitmap_new_ex(GDI* gdi, int width, int height, int bpp, uint8* data)
gdiBitmap* gdi_bitmap_new_ex(rdpGdi* gdi, int width, int height, int bpp, uint8* data)
{
gdiBitmap* bitmap;
@ -414,7 +414,7 @@ void gdi_bitmap_new(rdpUpdate* update, gdiBitmap* bitmap)
{
uint8* data;
rdpBitmap* _bitmap;
GDI* gdi = GET_GDI(update);
rdpGdi* gdi = update->context->gdi;
_bitmap = &(bitmap->_p);
bitmap->hdc = gdi_CreateCompatibleDC(gdi->hdc);
@ -433,7 +433,7 @@ void gdi_bitmap_new(rdpUpdate* update, gdiBitmap* bitmap)
void gdi_offscreen_bitmap_new(rdpUpdate* update, gdiBitmap* bitmap)
{
rdpBitmap* _bitmap;
GDI* gdi = GET_GDI(update);
rdpGdi* gdi = update->context->gdi;
_bitmap = &(bitmap->_p);
bitmap->hdc = gdi_CreateCompatibleDC(gdi->hdc);
@ -446,7 +446,7 @@ void gdi_offscreen_bitmap_new(rdpUpdate* update, gdiBitmap* bitmap)
void gdi_set_surface(rdpUpdate* update, gdiBitmap* bitmap, boolean primary)
{
GDI* gdi = GET_GDI(update);
rdpGdi* gdi = update->context->gdi;
if (primary)
gdi->drawing = gdi->primary;
@ -464,7 +464,7 @@ void gdi_bitmap_free(rdpUpdate* update, gdiBitmap* bitmap)
}
}
gdiBitmap* gdi_glyph_new(GDI* gdi, GLYPH_DATA* glyph)
gdiBitmap* gdi_glyph_new(rdpGdi* gdi, GLYPH_DATA* glyph)
{
uint8* extra;
gdiBitmap* gdi_bmp;
@ -502,7 +502,7 @@ void gdi_bitmap_update(rdpUpdate* update, BITMAP_UPDATE* bitmap)
int i;
rdpBitmap* bmp;
gdiBitmap* gdi_bmp;
GDI* gdi = GET_GDI(update);
rdpGdi* gdi = update->context->gdi;
for (i = 0; i < bitmap->number; i++)
{
@ -525,7 +525,7 @@ void gdi_palette_update(rdpUpdate* update, PALETTE_UPDATE* palette)
void gdi_set_bounds(rdpUpdate* update, BOUNDS* bounds)
{
GDI* gdi = GET_GDI(update);
rdpGdi* gdi = update->context->gdi;
if (bounds != NULL)
{
@ -540,7 +540,7 @@ void gdi_set_bounds(rdpUpdate* update, BOUNDS* bounds)
void gdi_dstblt(rdpUpdate* update, DSTBLT_ORDER* dstblt)
{
GDI* gdi = GET_GDI(update);
rdpGdi* gdi = update->context->gdi;
gdi_BitBlt(gdi->drawing->hdc, dstblt->nLeftRect, dstblt->nTopRect,
dstblt->nWidth, dstblt->nHeight, NULL, 0, 0, gdi_rop3_code(dstblt->bRop));
@ -551,13 +551,14 @@ void gdi_patblt(rdpUpdate* update, PATBLT_ORDER* patblt)
uint8* data;
BRUSH* brush;
HGDI_BRUSH originalBrush;
GDI* gdi = GET_GDI(update);
rdpGdi* gdi = update->context->gdi;
rdpCache* cache = update->context->cache;
brush = &patblt->brush;
if (brush->style & CACHED_BRUSH)
{
brush->data = brush_get(gdi->cache->brush, brush->index, &brush->bpp);
brush->data = brush_get(cache->brush, brush->index, &brush->bpp);
brush->style = GDI_BS_PATTERN;
}
@ -608,7 +609,7 @@ void gdi_patblt(rdpUpdate* update, PATBLT_ORDER* patblt)
void gdi_scrblt(rdpUpdate* update, SCRBLT_ORDER* scrblt)
{
GDI* gdi = GET_GDI(update);
rdpGdi* gdi = update->context->gdi;
gdi_BitBlt(gdi->drawing->hdc, scrblt->nLeftRect, scrblt->nTopRect,
scrblt->nWidth, scrblt->nHeight, gdi->primary->hdc,
@ -620,7 +621,7 @@ void gdi_opaque_rect(rdpUpdate* update, OPAQUE_RECT_ORDER* opaque_rect)
GDI_RECT rect;
HGDI_BRUSH hBrush;
uint32 brush_color;
GDI *gdi = GET_GDI(update);
rdpGdi *gdi = update->context->gdi;
gdi_CRgnToRect(opaque_rect->nLeftRect, opaque_rect->nTopRect,
opaque_rect->nWidth, opaque_rect->nHeight, &rect);
@ -640,7 +641,7 @@ void gdi_multi_opaque_rect(rdpUpdate* update, MULTI_OPAQUE_RECT_ORDER* multi_opa
HGDI_BRUSH hBrush;
uint32 brush_color;
DELTA_RECT* rectangle;
GDI *gdi = GET_GDI(update);
rdpGdi *gdi = update->context->gdi;
for (i = 1; i < multi_opaque_rect->numRectangles + 1; i++)
{
@ -662,7 +663,7 @@ void gdi_line_to(rdpUpdate* update, LINE_TO_ORDER* line_to)
{
uint32 color;
HGDI_PEN hPen;
GDI *gdi = GET_GDI(update);
rdpGdi *gdi = update->context->gdi;
color = freerdp_color_convert(line_to->penColor, gdi->srcBpp, 32, gdi->clrconv);
hPen = gdi_CreatePen(line_to->penStyle, line_to->penWidth, (GDI_COLOR) color);
@ -681,7 +682,7 @@ void gdi_polyline(rdpUpdate* update, POLYLINE_ORDER* polyline)
uint32 color;
HGDI_PEN hPen;
DELTA_POINT* points;
GDI* gdi = GET_GDI(update);
rdpGdi* gdi = update->context->gdi;
color = freerdp_color_convert(polyline->penColor, gdi->srcBpp, 32, gdi->clrconv);
hPen = gdi_CreatePen(0, 1, (GDI_COLOR) color);
@ -703,7 +704,7 @@ void gdi_polyline(rdpUpdate* update, POLYLINE_ORDER* polyline)
void gdi_memblt(rdpUpdate* update, MEMBLT_ORDER* memblt)
{
gdiBitmap* bitmap;
GDI* gdi = GET_GDI(update);
rdpGdi* gdi = update->context->gdi;
bitmap = (gdiBitmap*) memblt->bitmap;
@ -730,7 +731,8 @@ void gdi_fast_index(rdpUpdate* update, FAST_INDEX_ORDER* fast_index)
GLYPH_DATA* glyph;
GLYPH_DATA** glyphs;
GLYPH_FRAGMENT* fragment;
GDI* gdi = GET_GDI(update);
rdpGdi* gdi = update->context->gdi;
rdpCache* cache = update->context->cache;
x = fast_index->bkLeft;
y = fast_index->y;
@ -753,14 +755,14 @@ void gdi_fast_index(rdpUpdate* update, FAST_INDEX_ORDER* fast_index)
if (fragment->operation == GLYPH_FRAGMENT_USE)
{
fragment->indices = (GLYPH_FRAGMENT_INDEX*) glyph_fragment_get(gdi->cache->glyph,
fragment->indices = (GLYPH_FRAGMENT_INDEX*) glyph_fragment_get(cache->glyph,
fragment->index, &fragment->nindices, (void**) &bmps);
glyphs = (GLYPH_DATA**) xmalloc(sizeof(GLYPH_DATA*) * fragment->nindices);
for (j = 0; j < fragment->nindices; j++)
{
glyphs[j] = glyph_get(gdi->cache->glyph, fast_index->cacheId, fragment->indices[j].index, (void**) &bmps[j]);
glyphs[j] = glyph_get(cache->glyph, fast_index->cacheId, fragment->indices[j].index, (void**) &bmps[j]);
}
}
else
@ -770,7 +772,7 @@ void gdi_fast_index(rdpUpdate* update, FAST_INDEX_ORDER* fast_index)
for (j = 0; j < fragment->nindices; j++)
{
glyphs[j] = glyph_get(gdi->cache->glyph, fast_index->cacheId, fragment->indices[j].index, (void**) &bmps[j]);
glyphs[j] = glyph_get(cache->glyph, fast_index->cacheId, fragment->indices[j].index, (void**) &bmps[j]);
}
}
@ -807,7 +809,7 @@ void gdi_fast_index(rdpUpdate* update, FAST_INDEX_ORDER* fast_index)
if (fragment->operation == GLYPH_FRAGMENT_ADD)
{
glyph_fragment_put(gdi->cache->glyph, fragment->index,
glyph_fragment_put(cache->glyph, fragment->index,
fragment->nindices, (void*) fragment->indices, (void*) bmps);
}
}
@ -818,8 +820,9 @@ void gdi_fast_index(rdpUpdate* update, FAST_INDEX_ORDER* fast_index)
void gdi_cache_color_table(rdpUpdate* update, CACHE_COLOR_TABLE_ORDER* cache_color_table)
{
GDI* gdi = GET_GDI(update);
color_table_put(gdi->cache->color_table, cache_color_table->cacheIndex, (void*) cache_color_table->colorTable);
rdpCache* cache = update->context->cache;
color_table_put(cache->color_table, cache_color_table->cacheIndex, (void*) cache_color_table->colorTable);
}
void gdi_cache_glyph(rdpUpdate* update, CACHE_GLYPH_ORDER* cache_glyph)
@ -827,13 +830,14 @@ void gdi_cache_glyph(rdpUpdate* update, CACHE_GLYPH_ORDER* cache_glyph)
int i;
GLYPH_DATA* glyph;
gdiBitmap* gdi_bmp;
GDI* gdi = GET_GDI(update);
rdpGdi* gdi = update->context->gdi;
rdpCache* cache = update->context->cache;
for (i = 0; i < cache_glyph->cGlyphs; i++)
{
glyph = cache_glyph->glyphData[i];
gdi_bmp = gdi_glyph_new(gdi, glyph);
glyph_put(gdi->cache->glyph, cache_glyph->cacheId, glyph->cacheIndex, glyph, (void*) gdi_bmp);
glyph_put(cache->glyph, cache_glyph->cacheId, glyph->cacheIndex, glyph, (void*) gdi_bmp);
}
}
@ -843,7 +847,7 @@ void gdi_cache_glyph_v2(rdpUpdate* update, CACHE_GLYPH_V2_ORDER* cache_glyph_v2)
uint8* extra;
GLYPH_DATA_V2* glyph;
gdiBitmap* gdi_bmp;
GDI* gdi = GET_GDI(update);
rdpCache* cache = update->context->cache;
for (i = 0; i < cache_glyph_v2->cGlyphs; i++)
{
@ -862,14 +866,14 @@ void gdi_cache_glyph_v2(rdpUpdate* update, CACHE_GLYPH_V2_ORDER* cache_glyph_v2)
gdi_SelectObject(gdi_bmp->hdc, (HGDIOBJECT) gdi_bmp->bitmap);
gdi_bmp->org_bitmap = NULL;
glyph_put(gdi->cache->glyph, cache_glyph_v2->cacheId, glyph->cacheIndex, glyph, (void*) gdi_bmp);
glyph_put(cache->glyph, cache_glyph_v2->cacheId, glyph->cacheIndex, glyph, (void*) gdi_bmp);
}
}
void gdi_cache_brush(rdpUpdate* update, CACHE_BRUSH_ORDER* cache_brush)
{
GDI* gdi = GET_GDI(update);
brush_put(gdi->cache->brush, cache_brush->index, cache_brush->data, cache_brush->bpp);
rdpCache* cache = update->context->cache;
brush_put(cache->brush, cache_brush->index, cache_brush->data, cache_brush->bpp);
}
int tilenum = 0;
@ -880,11 +884,10 @@ void gdi_surface_bits(rdpUpdate* update, SURFACE_BITS_COMMAND* surface_bits_comm
int tx, ty;
char* tile_bitmap;
RFX_MESSAGE* message;
GDI* gdi = GET_GDI(update);
rdpGdi* gdi = update->context->gdi;
RFX_CONTEXT* context = (RFX_CONTEXT*) gdi->rfx_context;
NSC_CONTEXT* ncontext = (NSC_CONTEXT*) gdi->nsc_context;
DEBUG_GDI("destLeft %d destTop %d destRight %d destBottom %d "
"bpp %d codecID %d width %d height %d length %d",
surface_bits_command->destLeft, surface_bits_command->destTop,
@ -1063,7 +1066,7 @@ void gdi_register_update_callbacks(rdpUpdate* update)
update->BitmapDecompress = gdi_bitmap_decompress;
}
void gdi_init_primary(GDI* gdi)
void gdi_init_primary(rdpGdi* gdi)
{
gdi->primary = gdi_bitmap_new_ex(gdi, gdi->width, gdi->height, gdi->dstBpp, gdi->primary_buffer);
gdi->primary_buffer = gdi->primary->bitmap->data;
@ -1080,7 +1083,7 @@ void gdi_init_primary(GDI* gdi)
gdi->primary->hdc->hwnd->ninvalid = 0;
}
void gdi_resize(GDI* gdi, int width, int height)
void gdi_resize(rdpGdi* gdi, int width, int height)
{
if (gdi && gdi->primary)
{
@ -1105,9 +1108,14 @@ void gdi_resize(GDI* gdi, int width, int height)
int gdi_init(freerdp* instance, uint32 flags, uint8* buffer)
{
GDI* gdi = (GDI*) malloc(sizeof(GDI));
memset(gdi, 0, sizeof(GDI));
SET_GDI(instance->update, gdi);
rdpGdi* gdi;
rdpCache* cache;
gdi = (rdpGdi*) malloc(sizeof(rdpGdi));
memset(gdi, 0, sizeof(rdpGdi));
instance->context->gdi = gdi;
cache = instance->context->cache;
gdi->width = instance->settings->width;
gdi->height = instance->settings->height;
@ -1169,26 +1177,24 @@ int gdi_init(freerdp* instance, uint32 flags, uint8* buffer)
gdi->tile = gdi_bitmap_new_ex(gdi, 64, 64, 32, NULL);
gdi->image = gdi_bitmap_new_ex(gdi, 64, 64, 32, NULL);
if (instance->cache == NULL)
if (cache == NULL)
{
instance->cache = (void*) cache_new(instance->settings);
instance->update->cache = instance->cache;
cache = cache_new(instance->settings);
instance->context->cache = cache;
}
gdi->cache = (rdpCache*) instance->cache;
gdi_register_update_callbacks(instance->update);
bitmap_cache_register_callbacks(instance->update);
gdi->cache->bitmap->BitmapSize = (cbBitmapSize) gdi_bitmap_size;
gdi->cache->bitmap->BitmapNew = (cbBitmapNew) gdi_bitmap_new;
gdi->cache->bitmap->BitmapFree = (cbBitmapFree) gdi_bitmap_free;
cache->bitmap->BitmapSize = (cbBitmapSize) gdi_bitmap_size;
cache->bitmap->BitmapNew = (cbBitmapNew) gdi_bitmap_new;
cache->bitmap->BitmapFree = (cbBitmapFree) gdi_bitmap_free;
offscreen_cache_register_callbacks(instance->update);
gdi->cache->offscreen->OffscreenBitmapSize = (cbOffscreenBitmapSize) gdi_bitmap_size;
gdi->cache->offscreen->OffscreenBitmapNew = (cbOffscreenBitmapNew) gdi_offscreen_bitmap_new;
gdi->cache->offscreen->OffscreenBitmapFree = (cbOffscreenBitmapFree) gdi_bitmap_free;
gdi->cache->offscreen->SetSurface = (cbSetSurface) gdi_set_surface;
cache->offscreen->OffscreenBitmapSize = (cbOffscreenBitmapSize) gdi_bitmap_size;
cache->offscreen->OffscreenBitmapNew = (cbOffscreenBitmapNew) gdi_offscreen_bitmap_new;
cache->offscreen->OffscreenBitmapFree = (cbOffscreenBitmapFree) gdi_bitmap_free;
cache->offscreen->SetSurface = (cbSetSurface) gdi_set_surface;
gdi->rfx_context = rfx_context_new();
gdi->nsc_context = nsc_context_new();
@ -1198,7 +1204,7 @@ int gdi_init(freerdp* instance, uint32 flags, uint8* buffer)
void gdi_free(freerdp* instance)
{
GDI *gdi = GET_GDI(instance->update);
rdpGdi* gdi = instance->context->gdi;
if (gdi)
{
@ -1206,12 +1212,11 @@ void gdi_free(freerdp* instance)
gdi_bitmap_free_ex(gdi->tile);
gdi_bitmap_free_ex(gdi->image);
gdi_DeleteDC(gdi->hdc);
cache_free(gdi->cache);
rfx_context_free((RFX_CONTEXT*)gdi->rfx_context);
free(gdi->clrconv);
free(gdi);
}
SET_GDI(instance->update, NULL);
instance->context->gdi = (rdpGdi*) NULL;
}

View File

@ -27,31 +27,27 @@
static void rail_WindowCreate(rdpUpdate* update, WINDOW_ORDER_INFO* orderInfo, WINDOW_STATE_ORDER* window_state)
{
rdpRail* rail;
rail = (rdpRail*) update->rail;
rdpRail* rail = update->context->rail;
window_list_create(rail->list, orderInfo, window_state);
}
static void rail_WindowUpdate(rdpUpdate* update, WINDOW_ORDER_INFO* orderInfo, WINDOW_STATE_ORDER* window_state)
{
rdpRail* rail;
rail = (rdpRail*) update->rail;
rdpRail* rail = update->context->rail;
window_list_update(rail->list, orderInfo, window_state);
}
static void rail_WindowDelete(rdpUpdate* update, WINDOW_ORDER_INFO* orderInfo)
{
rdpRail* rail;
rail = (rdpRail*) update->rail;
rdpRail* rail = update->context->rail;
window_list_delete(rail->list, orderInfo);
}
static void rail_WindowIcon(rdpUpdate* update, WINDOW_ORDER_INFO* orderInfo, WINDOW_ICON_ORDER* window_icon)
{
rdpRail* rail;
rdpIcon* icon;
rdpWindow* window;
rail = (rdpRail*) update->rail;
rdpRail* rail = update->context->rail;
if (window_icon->iconInfo->cacheEntry != 0xFFFF)
{
@ -78,38 +74,32 @@ static void rail_WindowIcon(rdpUpdate* update, WINDOW_ORDER_INFO* orderInfo, WIN
static void rail_WindowCachedIcon(rdpUpdate* update, WINDOW_ORDER_INFO* orderInfo, WINDOW_CACHED_ICON_ORDER* window_cached_icon)
{
rdpRail* rail;
rail = (rdpRail*) update->rail;
}
static void rail_NotifyIconCreate(rdpUpdate* update, WINDOW_ORDER_INFO* orderInfo, NOTIFY_ICON_STATE_ORDER* notify_icon_state)
{
rdpRail* rail;
rail = (rdpRail*) update->rail;
}
static void rail_NotifyIconUpdate(rdpUpdate* update, WINDOW_ORDER_INFO* orderInfo, NOTIFY_ICON_STATE_ORDER* notify_icon_state)
{
rdpRail* rail;
rail = (rdpRail*) update->rail;
}
static void rail_NotifyIconDelete(rdpUpdate* update, WINDOW_ORDER_INFO* orderInfo)
{
rdpRail* rail;
rail = (rdpRail*) update->rail;
}
static void rail_MonitoredDesktop(rdpUpdate* update, WINDOW_ORDER_INFO* orderInfo, MONITORED_DESKTOP_ORDER* monitored_desktop)
{
rdpRail* rail;
rail = (rdpRail*) update->rail;
}
static void rail_NonMonitoredDesktop(rdpUpdate* update, WINDOW_ORDER_INFO* orderInfo)
{
rdpRail* rail;
rail = (rdpRail*) update->rail;
}
void rail_register_update_callbacks(rdpRail* rail, rdpUpdate* update)