mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
WaykClient (Mac): integrated MRDPView (allocated at runtime)
This commit is contained in:
@@ -78,6 +78,8 @@
|
||||
int kdlmeta;
|
||||
int kdrmeta;
|
||||
int kdcapslock;
|
||||
|
||||
BOOL initialized;
|
||||
|
||||
@public
|
||||
NSPasteboard* pasteboard_rd; /* for reading from clipboard */
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
/** *********************************************************************
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user