WaykClient (Mac): integrated MRDPView (allocated at runtime)

This commit is contained in:
Benoît LeBlanc
2013-06-26 13:45:12 -04:00
parent 2f310271c9
commit ed4a25d1ae
4 changed files with 46 additions and 22 deletions

View File

@@ -78,6 +78,8 @@
int kdlmeta;
int kdrmeta;
int kdcapslock;
BOOL initialized;
@public
NSPasteboard* pasteboard_rd; /* for reading from clipboard */

View File

@@ -129,11 +129,12 @@ struct rgba_data
rdpSettings* settings;
EmbedWindowEventArgs e;
[self initializeView];
context = rdp_context;
mfc = (mfContext*) rdp_context;
instance = context->instance;
settings = context->settings;
mfc->view = self;
EventArgsInit(&e, "mfreerdp");
e.embed = TRUE;
@@ -185,7 +186,7 @@ struct rgba_data
- (id)initWithFrame:(NSRect)frame
{
self = [super initWithFrame:frame];
self = [super initWithFrame:frame];
if (self)
{
@@ -203,22 +204,32 @@ struct rgba_data
// won't be called if the view is created dynamically
- (void) viewDidLoad
{
// store our window dimensions
width = [self frame].size.width;
height = [self frame].size.height;
titleBarHeight = 22;
[[self window] becomeFirstResponder];
[[self window] setAcceptsMouseMovedEvents:YES];
cursors = [[NSMutableArray alloc] initWithCapacity:10];
[self initializeView];
}
// setup a mouse tracking area
NSTrackingArea * trackingArea = [[NSTrackingArea alloc] initWithRect:[self visibleRect] options:NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingCursorUpdate | NSTrackingEnabledDuringMouseDrag | NSTrackingActiveWhenFirstResponder owner:self userInfo:nil];
[self addTrackingArea:trackingArea];
mouseInClientArea = YES;
- (void) initializeView
{
if (!initialized)
{
// store our window dimensions
width = [self frame].size.width;
height = [self frame].size.height;
titleBarHeight = 22;
[[self window] becomeFirstResponder];
[[self window] setAcceptsMouseMovedEvents:YES];
cursors = [[NSMutableArray alloc] initWithCapacity:10];
// setup a mouse tracking area
NSTrackingArea * trackingArea = [[NSTrackingArea alloc] initWithRect:[self visibleRect] options:NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingCursorUpdate | NSTrackingEnabledDuringMouseDrag | NSTrackingActiveWhenFirstResponder owner:self userInfo:nil];
[self addTrackingArea:trackingArea];
mouseInClientArea = YES;
initialized = YES;
}
}
/** *********************************************************************
@@ -619,11 +630,6 @@ struct rgba_data
if (run_loop_src_channels != 0)
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), run_loop_src_channels, kCFRunLoopDefaultMode);
freerdp_client_stop(self->context);
freerdp_client_context_free(self->context);
}
/** *********************************************************************

View File

@@ -25,6 +25,7 @@
#include <freerdp/constants.h>
#include <freerdp/utils/signal.h>
#include <freerdp/client/cmdline.h>
#import "MRDPView.h"
/**
* Client Interface
@@ -46,6 +47,13 @@ int mfreerdp_client_start(rdpContext* context)
MRDPView* view;
mfContext* mfc = (mfContext*) context;
if (mfc->view == NULL)
{
// view not specified beforehand. Create view dynamically
mfc->view = [[MRDPView alloc] initWithFrame : NSMakeRect(0, 0, 300, 300)];
mfc->view_ownership = TRUE;
}
view = (MRDPView*) mfc->view;
[view rdpStart:context];
@@ -74,6 +82,13 @@ int mfreerdp_client_stop(rdpContext* context)
mfc->disconnect = TRUE;
}
if (mfc->view_ownership)
{
MRDPView* view = (MRDPView*) view;
[view releaseResources];
[view release];
}
return 0;
}

View File

@@ -28,6 +28,7 @@ struct mf_context
DEFINE_RDP_CLIENT_COMMON();
void* view;
BOOL view_ownership; // TRUE indicates that the window was created and should be freed by the API.
int width;
int height;