mfreerdp: code cleanup

This commit is contained in:
Marc-André Moreau 2013-12-11 14:31:54 -05:00
parent 9d745cc038
commit bf094ed997
2 changed files with 44 additions and 104 deletions

View File

@ -59,6 +59,8 @@
#import "freerdp/types.h"
#import "freerdp/channels/channels.h"
#import "freerdp/gdi/gdi.h"
#import "freerdp/gdi/dc.h"
#import "freerdp/gdi/region.h"
#import "freerdp/graphics.h"
#import "freerdp/utils/event.h"
#import "freerdp/client/cliprdr.h"
@ -745,7 +747,6 @@ DWORD mac_client_thread(void* param)
BOOL mac_pre_connect(freerdp* instance)
{
rdpSettings* settings;
BOOL bitmap_cache;
// setup callbacks
instance->update->BeginPaint = mac_begin_paint;
@ -762,6 +763,9 @@ BOOL mac_pre_connect(freerdp* instance)
return -1;
}
settings->ColorDepth = 32;
settings->SoftwareGdi = TRUE;
settings->OsMajorType = OSMAJORTYPE_MACINTOSH;
settings->OsMinorType = OSMINORTYPE_MACINTOSH;
@ -793,44 +797,6 @@ BOOL mac_pre_connect(freerdp* instance)
freerdp_client_load_addins(instance->context->channels, instance->settings);
settings = instance->settings;
bitmap_cache = settings->BitmapCacheEnabled;
instance->settings->ColorDepth = 32;
instance->settings->SoftwareGdi = TRUE;
settings->OsMajorType = OSMAJORTYPE_UNIX;
settings->OsMinorType = OSMINORTYPE_NATIVE_XSERVER;
settings->OrderSupport[NEG_DSTBLT_INDEX] = TRUE;
settings->OrderSupport[NEG_PATBLT_INDEX] = TRUE;
settings->OrderSupport[NEG_SCRBLT_INDEX] = TRUE;
settings->OrderSupport[NEG_OPAQUE_RECT_INDEX] = TRUE;
settings->OrderSupport[NEG_DRAWNINEGRID_INDEX] = FALSE;
settings->OrderSupport[NEG_MULTIDSTBLT_INDEX] = FALSE;
settings->OrderSupport[NEG_MULTIPATBLT_INDEX] = FALSE;
settings->OrderSupport[NEG_MULTISCRBLT_INDEX] = FALSE;
settings->OrderSupport[NEG_MULTIOPAQUERECT_INDEX] = TRUE;
settings->OrderSupport[NEG_MULTI_DRAWNINEGRID_INDEX] = FALSE;
settings->OrderSupport[NEG_LINETO_INDEX] = TRUE;
settings->OrderSupport[NEG_POLYLINE_INDEX] = TRUE;
settings->OrderSupport[NEG_MEMBLT_INDEX] = bitmap_cache;
settings->OrderSupport[NEG_MEM3BLT_INDEX] = (settings->SoftwareGdi) ? TRUE : FALSE;
settings->OrderSupport[NEG_MEMBLT_V2_INDEX] = bitmap_cache;
settings->OrderSupport[NEG_MEM3BLT_V2_INDEX] = FALSE;
settings->OrderSupport[NEG_SAVEBITMAP_INDEX] = FALSE;
settings->OrderSupport[NEG_GLYPH_INDEX_INDEX] = TRUE;
settings->OrderSupport[NEG_FAST_INDEX_INDEX] = TRUE;
settings->OrderSupport[NEG_FAST_GLYPH_INDEX] = TRUE;
settings->OrderSupport[NEG_POLYGON_SC_INDEX] = (settings->SoftwareGdi) ? FALSE : TRUE;
settings->OrderSupport[NEG_POLYGON_CB_INDEX] = (settings->SoftwareGdi) ? FALSE : TRUE;
settings->OrderSupport[NEG_ELLIPSE_SC_INDEX] = FALSE;
settings->OrderSupport[NEG_ELLIPSE_CB_INDEX] = FALSE;
freerdp_channels_pre_connect(instance->context->channels, instance);
return TRUE;
@ -886,7 +852,6 @@ BOOL mac_post_connect(freerdp* instance)
return TRUE;
}
BOOL mac_authenticate(freerdp* instance, char** username, char** password, char** domain)
{
PasswordDialog* dialog = [PasswordDialog new];
@ -1093,9 +1058,9 @@ void mac_begin_paint(rdpContext* context)
void mac_end_paint(rdpContext* context)
{
int i;
rdpGdi* gdi;
NSRect drawRect;
HGDI_RGN invalid;
NSRect newDrawRect;
int ww, wh, dw, dh;
mfContext* mfc = (mfContext*) context;
MRDPView* view = (MRDPView*) mfc->view;
@ -1110,7 +1075,7 @@ void mac_end_paint(rdpContext* context)
dw = mfc->context.settings->DesktopWidth;
dh = mfc->context.settings->DesktopHeight;
if ((context == 0) || (context->gdi == 0))
if ((!context) || (!context->gdi))
return;
if (context->gdi->primary->hdc->hwnd->invalid->null)
@ -1119,36 +1084,32 @@ void mac_end_paint(rdpContext* context)
if (context->gdi->drawing != context->gdi->primary)
return;
for (i = 0; i < gdi->primary->hdc->hwnd->ninvalid; i++)
invalid = gdi->primary->hdc->hwnd->invalid;
newDrawRect.origin.x = invalid->x;
newDrawRect.origin.y = invalid->y;
newDrawRect.size.width = invalid->w;
newDrawRect.size.height = invalid->h;
if (mfc->context.settings->SmartSizing && (ww != dw || wh != dh))
{
drawRect.origin.x = gdi->primary->hdc->hwnd->cinvalid[i].x;
drawRect.origin.y = gdi->primary->hdc->hwnd->cinvalid[i].y;
drawRect.size.width = gdi->primary->hdc->hwnd->cinvalid[i].w;
drawRect.size.height = gdi->primary->hdc->hwnd->cinvalid[i].h;
if (mfc->context.settings->SmartSizing && (ww != dw || wh != dh))
{
drawRect.origin.y = drawRect.origin.y * wh / dh - 1;
drawRect.size.height = drawRect.size.height * wh / dh + 1;
drawRect.origin.x = drawRect.origin.x * ww / dw - 1;
drawRect.size.width = drawRect.size.width * ww / dw + 1;
}
else
{
drawRect.origin.y = drawRect.origin.y - 1;
drawRect.size.height = drawRect.size.height + 1;
drawRect.origin.x = drawRect.origin.x - 1;
drawRect.size.width = drawRect.size.width + 1;
}
windows_to_apple_cords(mfc->view, &drawRect);
// Note: The xCurrentScroll and yCurrentScroll values do not need to be taken into account
// because the current frame is always at full size, since the scrolling is handled by the external container.
[view setNeedsDisplayInRect:drawRect];
newDrawRect.origin.y = newDrawRect.origin.y * wh / dh - 1;
newDrawRect.size.height = newDrawRect.size.height * wh / dh + 1;
newDrawRect.origin.x = newDrawRect.origin.x * ww / dw - 1;
newDrawRect.size.width = newDrawRect.size.width * ww / dw + 1;
}
else
{
newDrawRect.origin.y = newDrawRect.origin.y - 1;
newDrawRect.size.height = newDrawRect.size.height + 1;
newDrawRect.origin.x = newDrawRect.origin.x - 1;
newDrawRect.size.width = newDrawRect.size.width + 1;
}
windows_to_apple_cords(mfc->view, &newDrawRect);
[view setNeedsDisplayInRect:newDrawRect];
gdi->primary->hdc->hwnd->ninvalid = 0;
}

View File

@ -16,7 +16,6 @@ static AppDelegate* _singleDelegate = nil;
void AppDelegate_EmbedWindowEventHandler(void* context, EmbedWindowEventArgs* e);
void AppDelegate_ConnectionResultEventHandler(void* context, ConnectionResultEventArgs* e);
void AppDelegate_ErrorInfoEventHandler(void* ctx, ErrorInfoEventArgs* e);
int mac_client_start(rdpContext* context);
void mac_set_view_size(rdpContext* context, MRDPView* view);
@implementation AppDelegate
@ -61,7 +60,7 @@ void mac_set_view_size(rdpContext* context, MRDPView* view);
- (void) applicationWillTerminate:(NSNotification*)notification
{
[mrdpView releaseResources];
_singleDelegate = nil;
_singleDelegate = nil;
}
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
@ -114,8 +113,6 @@ void mac_set_view_size(rdpContext* context, MRDPView* view);
clientEntryPoints.Version = RDP_CLIENT_INTERFACE_VERSION;
RdpClientEntry(&clientEntryPoints);
clientEntryPoints.ClientStart = mac_client_start;
context = freerdp_client_context_new(&clientEntryPoints);
}
@ -170,19 +167,18 @@ void AppDelegate_EmbedWindowEventHandler(void* ctx, EmbedWindowEventArgs* e)
{
rdpContext* context = (rdpContext*) ctx;
if (_singleDelegate)
{
mfContext* mfc = (mfContext*) context;
_singleDelegate->mrdpView = mfc->view;
if (_singleDelegate->window)
{
[[_singleDelegate->window contentView] addSubview:mfc->view];
}
if (_singleDelegate)
{
mfContext* mfc = (mfContext*) context;
_singleDelegate->mrdpView = mfc->view;
if (_singleDelegate->window)
{
[[_singleDelegate->window contentView] addSubview:mfc->view];
}
mac_set_view_size(context, mfc->view);
}
}
}
/** *********************************************************************
@ -228,7 +224,6 @@ void AppDelegate_ErrorInfoEventHandler(void* ctx, ErrorInfoEventArgs* e)
}
}
void mac_set_view_size(rdpContext* context, MRDPView* view)
{
// set client area to specified dimensions
@ -249,22 +244,6 @@ void mac_set_view_size(rdpContext* context, MRDPView* view)
// set window to given area
[[view window] setFrame:outerRect display:YES];
if(context->settings->Fullscreen)
if (context->settings->Fullscreen)
[[view window] toggleFullScreen:nil];
}
int mac_client_start(rdpContext* context)
{
mfContext* mfc;
MRDPView* view;
mfc = (mfContext*) context;
view = [[MRDPView alloc] initWithFrame : NSMakeRect(0, 0, context->settings->DesktopWidth, context->settings->DesktopHeight)];
mfc->view = view;
[view rdpStart:context];
mac_set_view_size(context, view);
return 0;
}