MacFreeRDP: Moved setViewSize logic out of the framework to the CLI app, because the content resizes the parent window, which interferes with other applications using the framework.

This commit is contained in:
Benoît LeBlanc 2013-09-27 17:36:53 -04:00
parent 136cff5765
commit 05febe9d03
4 changed files with 77 additions and 50 deletions

View File

@ -76,8 +76,6 @@
int kdcapslock;
BOOL initialized;
NSImageView* imageView;
@public
NSPasteboard* pasteboard_rd; /* for reading from clipboard */
@ -92,7 +90,6 @@
- (void) onPasteboardTimerFired :(NSTimer *) timer;
- (void) releaseResources;
- (void) setViewSize : (int) w : (int) h;
@property (assign) int is_connected;

View File

@ -138,7 +138,6 @@ struct rgba_data
e.embed = TRUE;
e.handle = (void*) self;
PubSub_OnEmbedWindow(context->pubSub, context, &e);
[self setViewSize :instance->settings->DesktopWidth :instance->settings->DesktopHeight];
mfc->thread = CreateThread(NULL, 0, mac_client_thread, (void*) context, 0, &mfc->mainThreadId);
@ -290,8 +289,6 @@ DWORD mac_client_thread(void* param)
{
self->currentCursor = cursor;
[[self window] invalidateCursorRectsForView:self];
[imageView setImage:[currentCursor image]];
}
@ -703,19 +700,19 @@ DWORD mac_client_thread(void* param)
return;
if (self->bitmap_context)
{
{
CGContextRef cgContext = [[NSGraphicsContext currentContext] graphicsPort];
CGImageRef cgImage = CGBitmapContextCreateImage(self->bitmap_context);
CGContextClipToRect(cgContext, CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height));
CGContextDrawImage(cgContext, CGRectMake(0, 0, [self bounds].size.width, [self bounds].size.height), cgImage);
CGContextClipToRect(cgContext, CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height));
CGContextDrawImage(cgContext, CGRectMake(0, 0, [self bounds].size.width, [self bounds].size.height), cgImage);
CGImageRelease(cgImage);
}
CGImageRelease(cgImage);
}
else
{
// just clear the screen with black
[[NSColor redColor] set];
[[NSColor blackColor] set];
NSRectFill([self bounds]);
}
}
@ -743,41 +740,6 @@ DWORD mac_client_thread(void* param)
}
}
- (void) setViewSize : (int) w : (int) h
{
// store current dimensions
width = w;
height = h;
// compute difference between window and client area
NSRect outerRect = [[self window] frame];
NSRect innerRect = [self frame];
int widthDiff = outerRect.size.width - innerRect.size.width;
int heightDiff = outerRect.size.height - innerRect.size.height;
// we are not in RemoteApp mode, disable resizing
outerRect.size.width = w + widthDiff;
outerRect.size.height = h + heightDiff;
[[self window] setMaxSize:outerRect.size];
[[self window] setMinSize:outerRect.size];
@try
{
[[self window] setFrame:outerRect display:YES];
}
@catch (NSException * e) {
NSLog(@"Exception: %@", e);
}
@finally {
}
// set client area to specified dimensions
innerRect.size.width = w;
innerRect.size.height = h;
[self setFrame:innerRect];
}
/************************************************************************
* *
* C functions *
@ -1134,7 +1096,7 @@ void mac_end_paint(rdpContext* context)
drawRect.origin.y = gdi->primary->hdc->hwnd->cinvalid[i].y - 1;
drawRect.size.width = gdi->primary->hdc->hwnd->cinvalid[i].w + 1;
drawRect.size.height = gdi->primary->hdc->hwnd->cinvalid[i].h + 1;
windows_to_apple_cords(mfc->view, &drawRect);
windows_to_apple_cords(mfc->view, &drawRect);
[view setNeedsDisplayInRect:drawRect];
}

View File

@ -9,11 +9,14 @@
#import "AppDelegate.h"
#import "MacFreeRDP/mfreerdp.h"
#import "MacFreeRDP/mf_client.h"
#import "MacFreeRDP/MRDPView.h"
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
@ -103,12 +106,24 @@ void AppDelegate_ErrorInfoEventHandler(void* ctx, ErrorInfoEventArgs* e);
clientEntryPoints.Version = RDP_CLIENT_INTERFACE_VERSION;
RdpClientEntry(&clientEntryPoints);
clientEntryPoints.ClientStart = mac_client_start;
context = freerdp_client_context_new(&clientEntryPoints);
}
- (void) ReleaseContext
{
mfContext* mfc;
MRDPView* view;
mfc = (mfContext*) context;
view = (MRDPView*) mfc->view;
[view releaseResources];
[view release];
mfc->view = nil;
freerdp_client_context_free(context);
context = nil;
}
@ -156,6 +171,9 @@ void AppDelegate_EmbedWindowEventHandler(void* ctx, EmbedWindowEventArgs* e)
{
[[_singleDelegate->window contentView] addSubview:mfc->view];
}
mac_set_view_size(context, mfc->view);
}
}
@ -201,4 +219,55 @@ void AppDelegate_ErrorInfoEventHandler(void* ctx, ErrorInfoEventArgs* e)
[_singleDelegate performSelectorOnMainThread:@selector(rdpConnectError:) withObject:message waitUntilDone:TRUE];
[message release];
}
}
}
void mac_set_view_size(rdpContext* context, MRDPView* view)
{
// compute difference between window and client area
NSRect outerRect = [[view window] frame];
NSRect innerRect = [view frame];
int widthDiff = outerRect.size.width - innerRect.size.width;
int heightDiff = outerRect.size.height - innerRect.size.height;
NSSize desktopSize;
desktopSize.width = context->settings->DesktopWidth;
desktopSize.height = context->settings->DesktopHeight;
// we are not in RemoteApp mode, disable resizing
outerRect.size.width = desktopSize.width + widthDiff;
outerRect.size.height = desktopSize.height + heightDiff;
[[view window] setMaxSize:outerRect.size];
[[view window] setMinSize:outerRect.size];
@try
{
[[view window] setFrame:outerRect display:YES];
}
@catch (NSException * e) {
NSLog(@"Exception: %@", e);
}
@finally {
}
// set client area to specified dimensions
innerRect.size.width = desktopSize.width;
innerRect.size.height = desktopSize.height;
[view setFrame:innerRect];
}
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;
}

View File

@ -25,7 +25,6 @@
#include <freerdp/constants.h>
#include <freerdp/utils/signal.h>
#include <freerdp/client/cmdline.h>
#import "MRDPView.h"
/**
* Client Interface