In MacFreerdpClient, added support for the following

+ clipboard redirection
	+ audio redirection
	+ RAIL support (ongoing)
This commit is contained in:
Laxmikant Rashinkar 2012-06-20 09:57:20 -07:00
parent 1cbf3dab21
commit 924ed187c1
16 changed files with 4508 additions and 348 deletions

View File

@ -2,7 +2,7 @@
// MRDPCursor.h
// MacFreeRDP
//
// Created by Laxmikant Rashinkar on 3/28/12.
// Created by Laxmikant Rashinkar
// Copyright (c) 2012 FreeRDP.org All rights reserved.
//

View File

@ -2,7 +2,7 @@
// MRDPCursor.m
// MacFreeRDP
//
// Created by Laxmikant Rashinkar on 3/28/12.
// Created by Laxmikant Rashinkar
// Copyright (c) 2012 FreeRDP.org All rights reserved.
//

47
client/Mac/MRDPRailView.h Normal file
View File

@ -0,0 +1,47 @@
#import <Cocoa/Cocoa.h>
#define boolean int
#import "freerdp/gdi/gdi.h"
#import "freerdp/rail/rail.h"
@interface MRDPRailView : NSView
{
freerdp * rdp_instance;
rdpContext * context;
NSBitmapImageRep * bmiRep;
NSPoint savedDragLocation;
char * pixelData;
boolean mouseInClientArea;
int width;
int height;
int savedWindowId;
// store state info for some keys
int kdlshift;
int kdrshift;
int kdlctrl;
int kdrctrl;
int kdlalt;
int kdralt;
int kdlmeta;
int kdrmeta;
int kdcapslock;
@public
boolean isMoveSizeInProgress;
boolean saveInitialDragLoc;
boolean skipMoveWindowOnce;
}
- (void) updateDisplay;
- (void) setRdpInstance:(freerdp *) instance width:(int) w andHeight:(int) h windowID:(int) windowID;
- (BOOL) eventIsInClientArea :(NSEvent *) event :(int *) xptr :(int *) yptr;
- (void) setupBmiRep:(int) width :(int) height;
void mac_rail_MoveWindow(rdpRail *rail, rdpWindow *window);
void apple_to_windowMove(NSRect * r, RAIL_WINDOW_MOVE_ORDER * windowMove);
void mac_send_rail_client_event(rdpChannels *channels, uint16 event_type, void *param);
@end

669
client/Mac/MRDPRailView.m Normal file
View File

@ -0,0 +1,669 @@
#include "MRDPRailView.h"
#define USE_RAIL_CVT
@implementation MRDPRailView
MRDPRailView * g_mrdpRailView;
struct kkey
{
int key_code;
int flags;
};
extern struct kkey g_keys[];
- (void) updateDisplay
{
boolean moveWindow = NO;
int i;
NSRect drawRect;
NSRect srcRectOuter;
NSRect destRectOuter;
rdpGdi * gdi;
if ((context == 0) || (context->gdi == 0))
return;
if (context->gdi->primary->hdc->hwnd->invalid->null)
return;
if (context->gdi->drawing != context->gdi->primary)
return;
gdi = context->gdi;
srcRectOuter = NSMakeRect(0, 0, self->width, self->height);
destRectOuter = [[self window] frame];
// cannot be bigger than our current screen size
NSRect screenSize = [[NSScreen mainScreen] frame];
if (destRectOuter.size.width > screenSize.size.width) {
destRectOuter.size.width = screenSize.size.width;
moveWindow = YES;
}
// RAIL_TODO do not hardcode to 22
if (destRectOuter.size.height > screenSize.size.height) {
destRectOuter.size.height = screenSize.size.height;
moveWindow = YES;
}
// cannot have negative cords
if (destRectOuter.origin.x < 0) {
destRectOuter.origin.x = 0;
moveWindow = YES;
}
if (destRectOuter.origin.y < 0) {
destRectOuter.origin.y = 0;
moveWindow = YES;
}
[self setupBmiRep:destRectOuter.size.width :destRectOuter.size.height];
if (moveWindow) {
moveWindow = NO;
RAIL_WINDOW_MOVE_ORDER newWndLoc;
apple_to_windowMove(&destRectOuter, &newWndLoc);
newWndLoc.windowId = savedWindowId;
//skipMoveWindowOnce = TRUE;
//mac_send_rail_client_event(g_mrdpRailView->rdp_instance->context->channels, RDP_EVENT_TYPE_RAIL_CLIENT_WINDOW_MOVE, &newWndLoc);
}
//printf("MRDPRailView : updateDisplay : drawing %d rectangles\n", gdi->primary->hdc->hwnd->ninvalid);
// if src and dest rect are not the same size, copy the entire
// rectangle in one go instead of in many small rectangles
//if (destRectOuter.size.width != self->width) {
if (1) {
destRectOuter.origin.y = height - destRectOuter.origin.y - destRectOuter.size.height;
rail_convert_color_space1(pixelData, (char *) gdi->primary_buffer,
&destRectOuter, self->width, self->height);
if (moveWindow)
[self setNeedsDisplayInRect:destRectOuter];
else
[self setNeedsDisplayInRect:[self frame]];
gdi->primary->hdc->hwnd->ninvalid = 0;
return;
}
for (i = 0; i < gdi->primary->hdc->hwnd->ninvalid; i++)
{
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;
rail_convert_color_space(pixelData, (char *) gdi->primary_buffer,
&drawRect, &destRectOuter,
&drawRect, &srcRectOuter);
[self setNeedsDisplayInRect:drawRect];
}
gdi->primary->hdc->hwnd->ninvalid = 0;
}
/** *********************************************************************
* called when our view needs to be redrawn
***********************************************************************/
- (void) drawRect:(NSRect)dirtyRect
{
[bmiRep drawInRect:dirtyRect fromRect:dirtyRect operation:NSCompositeCopy fraction:1.0 respectFlipped:NO hints:nil];
if (pixelData) {
free(pixelData);
pixelData = NULL;
}
bmiRep = nil;
}
/** *********************************************************************
* become first responder so we can get keyboard and mouse events
***********************************************************************/
- (BOOL)acceptsFirstResponder
{
return YES;
}
/** *********************************************************************
* called when a mouse move event occurrs
*
* ideally we want to be called when the mouse moves over NSView client area,
* but in reality we get called any time the mouse moves anywhere on the screen;
* we could use NSTrackingArea class to handle this but this class is available
* on Mac OS X v10.5 and higher; since we want to be compatible with older
* versions, we do this manually.
*
* TODO: here is how it can be done using legacy methods
* http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/EventOverview/MouseTrackingEvents/MouseTrackingEvents.html#//apple_ref/doc/uid/10000060i-CH11-SW1
***********************************************************************/
- (void) mouseMoved:(NSEvent *)event
{
[super mouseMoved:event];
NSRect winFrame = [[self window] frame];
NSPoint loc = [event locationInWindow];
int x = (int) (winFrame.origin.x + loc.x);
int y = (int) (winFrame.origin.y + loc.y);
y = height - y;
// send mouse motion event to RDP server
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_MOVE, x, y);
}
/** *********************************************************************
* called when left mouse button is pressed down
***********************************************************************/
- (void)mouseDown:(NSEvent *) event
{
[super mouseDown:event];
NSRect winFrame = [[self window] frame];
NSPoint loc = [event locationInWindow];
int x = (int) (winFrame.origin.x + loc.x);
int y = (int) (winFrame.origin.y + loc.y);
y = height - y;
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1, x, y);
}
/** *********************************************************************
* called when left mouse button is released
***********************************************************************/
- (void) mouseUp:(NSEvent *) event
{
[super mouseUp:event];
NSRect winFrame = [[self window] frame];
NSPoint loc = [event locationInWindow];
int x = (int) (winFrame.origin.x + loc.x);
int y = (int) (winFrame.origin.y + loc.y);
y = height - y;
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_BUTTON1, x, y);
}
/** *********************************************************************
* called when right mouse button is pressed down
***********************************************************************/
- (void) rightMouseDown:(NSEvent *)event
{
[super rightMouseDown:event];
NSRect winFrame = [[self window] frame];
NSPoint loc = [event locationInWindow];
int x = (int) (winFrame.origin.x + loc.x);
int y = (int) (winFrame.origin.y + loc.y);
y = height - y;
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON2, x, y);
}
/** *********************************************************************
* called when right mouse button is released
***********************************************************************/
- (void) rightMouseUp:(NSEvent *)event
{
[super rightMouseUp:event];
NSRect winFrame = [[self window] frame];
NSPoint loc = [event locationInWindow];
int x = (int) (winFrame.origin.x + loc.x);
int y = (int) (winFrame.origin.y + loc.y);
y = height - y;
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_BUTTON2, x, y);
}
/** *********************************************************************
* called when middle mouse button is pressed
***********************************************************************/
- (void) otherMouseDown:(NSEvent *)event
{
[super otherMouseDown:event];
NSRect winFrame = [[self window] frame];
NSPoint loc = [event locationInWindow];
int x = (int) (winFrame.origin.x + loc.x);
int y = (int) (winFrame.origin.y + loc.y);
y = height - y;
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON3, x, y);
}
/** *********************************************************************
* called when middle mouse button is released
***********************************************************************/
- (void) otherMouseUp:(NSEvent *)event
{
[super otherMouseUp:event];
NSRect winFrame = [[self window] frame];
NSPoint loc = [event locationInWindow];
int x = (int) (winFrame.origin.x + loc.x);
int y = (int) (winFrame.origin.y + loc.y);
y = height - y;
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_BUTTON3, x, y);
}
- (void) scrollWheel:(NSEvent *)event
{
uint16 flags;
[super scrollWheel:event];
NSRect winFrame = [[self window] frame];
NSPoint loc = [event locationInWindow];
int x = (int) (winFrame.origin.x + loc.x);
int y = (int) (winFrame.origin.y + loc.y);
y = height - y;
flags = PTR_FLAGS_WHEEL;
if ([event deltaY] < 0) {
flags |= PTR_FLAGS_WHEEL_NEGATIVE | 0x0088;
}
else {
flags |= 0x0078;
}
x += (int) [event deltaX];
y += (int) [event deltaY];
rdp_instance->input->MouseEvent(rdp_instance->input, flags, x, y);
}
/** *********************************************************************
* called when mouse is moved with left button pressed
* note: invocation order is: mouseDown, mouseDragged, mouseUp
***********************************************************************/
- (void) mouseDragged:(NSEvent *)event
{
[super mouseDragged:event];
NSPoint loc = [event locationInWindow];
int x = (int) loc.x;
int y = (int) loc.y;
if (isMoveSizeInProgress) {
if (saveInitialDragLoc) {
saveInitialDragLoc = NO;
savedDragLocation.x = x;
savedDragLocation.y = y;
return;
}
int newX = x - savedDragLocation.x;
int newY = y - savedDragLocation.y;
NSRect r = [[self window] frame];
r.origin.x += newX;
r.origin.y += newY;
[[self window] setFrame:r display:YES];
return;
}
NSRect winFrame = [[self window] frame];
x = (int) (winFrame.origin.x + loc.x);
y = (int) (winFrame.origin.y + loc.y);
y = height - y;
// send mouse motion event to RDP server
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_MOVE, x, y);
}
/** *********************************************************************
* called when a key is pressed
***********************************************************************/
- (void) keyDown:(NSEvent *) event
{
int key;
key = [event keyCode];
rdp_instance->input->KeyboardEvent(rdp_instance->input, g_keys[key].flags | KBD_FLAGS_DOWN, g_keys[key].key_code);
}
/** *********************************************************************
* called when a key is released
***********************************************************************/
- (void) keyUp:(NSEvent *) event
{
int key;
key = [event keyCode];
rdp_instance->input->KeyboardEvent(rdp_instance->input, g_keys[key].flags | KBD_FLAGS_RELEASE, g_keys[key].key_code);
}
/** *********************************************************************
* called when shift, control, alt and meta keys are pressed/released
***********************************************************************/
- (void) flagsChanged:(NSEvent *) event
{
NSUInteger mf = [event modifierFlags];
// caps lock
if (mf == 0x10100) {
printf("TODO: caps lock is on\n");
kdcapslock = 1;
}
if (kdcapslock && (mf == 0x100)) {
kdcapslock = 0;
printf("TODO: caps lock is off\n");
}
// left shift
if ((kdlshift == 0) && ((mf & 2) != 0)) {
// left shift went down
rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_DOWN, 0x2a);
kdlshift = 1;
}
if ((kdlshift != 0) && ((mf & 2) == 0)) {
// left shift went up
rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_RELEASE, 0x2a);
kdlshift = 0;
}
// right shift
if ((kdrshift == 0) && ((mf & 4) != 0)) {
// right shift went down
rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_DOWN, 0x36);
kdrshift = 1;
}
if ((kdrshift != 0) && ((mf & 4) == 0)) {
// right shift went up
rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_RELEASE, 0x36);
kdrshift = 0;
}
// left ctrl
if ((kdlctrl == 0) && ((mf & 1) != 0)) {
// left ctrl went down
rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_DOWN, 0x1d);
kdlctrl = 1;
}
if ((kdlctrl != 0) && ((mf & 1) == 0)) {
// left ctrl went up
rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_RELEASE, 0x1d);
kdlctrl = 0;
}
// right ctrl
if ((kdrctrl == 0) && ((mf & 0x2000) != 0)) {
// right ctrl went down
rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_DOWN, 0x1d);
kdrctrl = 1;
}
if ((kdrctrl != 0) && ((mf & 0x2000) == 0)) {
// right ctrl went up
rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_RELEASE, 0x1d);
kdrctrl = 0;
}
// left alt
if ((kdlalt == 0) && ((mf & 0x20) != 0)) {
// left alt went down
rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_DOWN, 0x38);
kdlalt = 1;
}
if ((kdlalt != 0) && ((mf & 0x20) == 0)) {
// left alt went up
rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_RELEASE, 0x38);
kdlalt = 0;
}
// right alt
if ((kdralt == 0) && ((mf & 0x40) != 0)) {
// right alt went down
rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_DOWN, 0x38);
kdralt = 1;
}
if ((kdralt != 0) && ((mf & 0x40) == 0)) {
// right alt went up
rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_RELEASE, 0x38);
kdralt = 0;
}
// left meta
if ((kdlmeta == 0) && ((mf & 0x08) != 0)) {
// left meta went down
rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_DOWN, 0x5b);
kdlmeta = 1;
}
if ((kdlmeta != 0) && ((mf & 0x08) == 0)) {
// left meta went up
rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_RELEASE, 0x5b);
kdlmeta = 0;
}
// right meta
if ((kdrmeta == 0) && ((mf & 0x10) != 0)) {
// right meta went down
rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_DOWN, 0x5c);
kdrmeta = 1;
}
if ((kdrmeta != 0) && ((mf & 0x10) == 0)) {
// right meta went up
rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_RELEASE, 0x5c);
kdrmeta = 0;
}
}
- (void) setRdpInstance:(freerdp *) instance width:(int) w andHeight:(int) h windowID:(int) windowID
{
rdp_instance = instance;
context = instance->context;
width = w;
height = h;
savedWindowId = windowID;
NSRect tr = NSMakeRect(0, 0,
[[NSScreen mainScreen] frame].size.width,
[[NSScreen mainScreen] frame].size.height);
NSTrackingArea * trackingArea = [[NSTrackingArea alloc] initWithRect:tr options:NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingCursorUpdate | NSTrackingEnabledDuringMouseDrag | NSTrackingActiveAlways owner:self userInfo:nil];
[self addTrackingArea:trackingArea];
g_mrdpRailView = self;
[self becomeFirstResponder];
}
- (void) setupBmiRep:(int) frameWidth :(int) frameHeight
{
struct rgba_data
{
char red;
char green;
char blue;
char alpha;
};
if (pixelData)
free(pixelData);
pixelData = (char *) malloc(frameWidth * frameHeight * sizeof(struct rgba_data));
bmiRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:(unsigned char **) &pixelData
pixelsWide:frameWidth
pixelsHigh:frameHeight
bitsPerSample:8
samplesPerPixel:sizeof(struct rgba_data)
hasAlpha:YES
isPlanar:NO
colorSpaceName:NSDeviceRGBColorSpace
bitmapFormat:0
bytesPerRow:frameWidth * sizeof(struct rgba_data)
bitsPerPixel:0];
}
void rail_cvt_from_rect(char *dest, char *src, NSRect destRect, int destWidth, int destHeight, NSRect srcRect)
{
}
/** *********************************************************************
* color space conversion used specifically in RAIL
***********************************************************************/
int rail_convert_color_space(char * destBuf, char * srcBuf,
NSRect * destRect, NSRect * destRectOuter,
NSRect * srcRect, NSRect * srcRectOuter)
{
int i;
int j;
int numRows;
int srcX;
int srcY;
int destX;
int destY;
int pixelsPerRow;
int pixel;
int pixel1;
int pixel2;
int * src32;
int * dest32;
int destWidth = destRectOuter->size.width;
int destHeight = destRectOuter->size.height;
int srcWidth = srcRectOuter->size.width;
int srcHeight = srcRectOuter->size.height;
if ((!destBuf) || (!srcBuf)) {
return 1;
}
if ((destRect->size.width != srcRect->size.width) || (destRect->size.height != srcRect->size.height)) {
printf("##### RAIL_TODO: rail_convert_color_space : destRect & srcRect dimensions don't match\n");
return 1;
}
numRows = srcRect->size.height;
srcX = srcRect->origin.x;
srcY = srcRect->origin.y;
destX = destRect->origin.x;
destY = destRect->origin.y;
pixelsPerRow = destRect->size.width;
for (i = 0; i < numRows; i++)
{
src32 = (int *) (srcBuf + ((srcY + i) * srcWidth + srcX) * 4);
dest32 = (int *) (destBuf + ((destY + i) * destWidth + destX) * 4);
for (j = 0; j < pixelsPerRow; j++)
{
pixel = *src32;
pixel1 = (pixel & 0x00ff0000) >> 16;
pixel2 = (pixel & 0x000000ff) << 16;
pixel = (pixel & 0xff00ff00) | pixel1 | pixel2;
*dest32 = pixel;
src32++;
dest32++;
}
}
destRect->origin.y = destHeight - destRect->origin.y - destRect->size.height;
return 0;
}
// RAIL_TODO rename this func
void rail_convert_color_space1(char *destBuf, char * srcBuf,
NSRect * destRect, int width, int height)
{
int i;
int j;
int numRows;
int srcX;
int srcY;
int destX;
int destY;
int pixelsPerRow;
int pixel;
int pixel1;
int pixel2;
int * src32;
int * dest32;
int destWidth = destRect->size.width;
int destHeight = destRect->size.height;
if ((!destBuf) || (!srcBuf)) {
return;
}
numRows = destHeight;
srcX = destRect->origin.x;
srcY = destRect->origin.y;
destX = 0;
destY = 0;
pixelsPerRow = destWidth;
for (i = 0; i < numRows; i++)
{
src32 = (int *) (srcBuf + ((srcY + i) * width + srcX) * 4);
dest32 = (int *) (destBuf + ((destY + i) * destWidth + destX) * 4);
for (j = 0; j < pixelsPerRow; j++)
{
pixel = *src32;
pixel1 = (pixel & 0x00ff0000) >> 16;
pixel2 = (pixel & 0x000000ff) << 16;
pixel = (pixel & 0xff00ff00) | pixel1 | pixel2;
*dest32 = pixel;
src32++;
dest32++;
}
}
destRect->origin.y = destHeight - destRect->origin.y - destRect->size.height;
return;
}
/**
* let RDP server know that window has moved
*/
void rail_MoveWindow(rdpRail * rail, rdpWindow * window)
{
if (g_mrdpRailView->isMoveSizeInProgress) {
return;
}
if (g_mrdpRailView->skipMoveWindowOnce) {
g_mrdpRailView->skipMoveWindowOnce = NO;
return;
}
// this rect is based on Windows co-ordinates...
NSRect r;
r.origin.x = window->windowOffsetX;
r.origin.y = window->windowOffsetY;
r.size.width = window->windowWidth;
r.size.height = window->windowHeight;
windows_to_apple_cords(&r);
[[g_mrdpRailView window] setFrame:r display:YES];
}
@end

View File

@ -0,0 +1,13 @@
//
// MRDPRailWindow.h
// Mac
//
// Created by Laxmikant Rashinkar
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface MRDPRailWindow : NSWindow
@end

View File

@ -0,0 +1,18 @@
//
// MRDPRailWindow.m
// Mac
//
// Created by Laxmikant Rashinkar
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import "MRDPRailWindow.h"
@implementation MRDPRailWindow
- (BOOL) canBecomeKeyWindow
{
return YES;
}
@end

View File

@ -2,7 +2,7 @@
// MRDPView.h
// MacFreeRDP
//
// Created by Laxmikant Rashinkar on 3/28/12.
// Created by Laxmikant Rashinkar
// Copyright (c) 2012 FreeRDP.org All rights reserved.
//
@ -10,14 +10,18 @@
typedef int boolean;
#include "freerdp/freerdp.h"
#include "freerdp/types.h"
#include "freerdp/channels/channels.h"
#include "freerdp/gdi/gdi.h"
#include "freerdp/graphics.h"
#include "freerdp/utils/event.h"
#include "freerdp/plugins/cliprdr.h"
#include "freerdp/utils/args.h"
#import "MRDPWindow.h"
#import "freerdp/freerdp.h"
#import "freerdp/types.h"
#import "freerdp/channels/channels.h"
#import "freerdp/gdi/gdi.h"
#import "freerdp/graphics.h"
#import "freerdp/utils/event.h"
#import "freerdp/plugins/cliprdr.h"
#import "freerdp/utils/args.h"
#import "freerdp/rail/rail.h"
#import "freerdp/rail.h"
#import "freerdp/utils/rail.h"
@interface MRDPView : NSView
{
@ -25,17 +29,30 @@ typedef int boolean;
CFRunLoopSourceRef run_loop_src_channels;
NSBitmapImageRep *bmiRep;
NSMutableArray *cursors;
NSMutableArray *windows;
NSTimer *pasteboard_timer;
NSRect rect;
NSRect prevWinPosition;
freerdp *rdp_instance;
rdpContext *rdp_context;
boolean mouseInClientArea;
char *pixel_data;
int width;
int height;
int argc;
int titleBarHeight;
char **argv;
// RAIL stuff
MRDPWindow *currentWindow;
NSPoint savedDragLocation;
boolean mouseInClientArea;
boolean isRemoteApp;
boolean firstCreateWindow;
boolean isMoveSizeInProgress;
boolean skipResizeOnce;
boolean saveInitialDragLoc;
boolean skipMoveWindowOnce;
// store state info for some keys
int kdlshift;
int kdrshift;
@ -57,11 +74,12 @@ typedef int boolean;
}
- (void) rdpConnectEror;
- (void) rdpRemoteAppError;
- (void) saveStateInfo :(freerdp *) instance :(rdpContext *) context;
- (BOOL) eventIsInClientArea :(NSEvent *) event :(int *) xptr :(int *) yptr;
- (void) onPasteboardTimerFired :(NSTimer *) timer;
- (void) my_draw_rect :(void *) context;
- (void) releaseResources;
- (void) setViewSize : (int) width : (int) height;
@property (assign) int is_connected;
@ -98,7 +116,7 @@ int register_fds(int *fds, int count, void *inst);
int invoke_draw_rect(rdpContext *context);
int process_plugin_args(rdpSettings* settings, const char* name, RDP_PLUGIN_DATA* plugin_data, void* user_data);
int receive_channel_data(freerdp *inst, int chan_id, uint8 *data, int size, int flags, int total_size);
void process_cliprdr_event(freerdp *inst);
void process_cliprdr_event(freerdp *inst, RDP_EVENT *event);
void cliprdr_process_cb_format_list_event(freerdp *inst, RDP_CB_FORMAT_LIST_EVENT* event);
void cliprdr_send_data_request(freerdp *inst, uint32 format);
void cliprdr_process_cb_monitor_ready_event(freerdp* inst);
@ -107,11 +125,26 @@ void cliprdr_process_text(freerdp *inst, uint8 *data, int len);
void cliprdr_send_supported_format_list(freerdp *inst);
int register_channel_fds(int *fds, int count, void *inst);
/* LK_TODO
int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
ProcessPluginArgs plugin_callback, void* plugin_user_data,
ProcessUIArgs ui_callback, void* ui_user_data);
*/
void mac_process_rail_event(freerdp *inst, RDP_EVENT *event);
void mac_rail_register_callbacks(freerdp *inst, rdpRail *rail);
void mac_rail_CreateWindow(rdpRail *rail, rdpWindow *window);
void mac_rail_MoveWindow(rdpRail *rail, rdpWindow *window);
void mac_rail_ShowWindow(rdpRail *rail, rdpWindow *window, uint8 state);
void mac_rail_SetWindowText(rdpRail *rail, rdpWindow *window);
void mac_rail_SetWindowIcon(rdpRail *rail, rdpWindow *window, rdpIcon *icon);
void mac_rail_SetWindowRects(rdpRail *rail, rdpWindow *window);
void mac_rail_SetWindowVisibilityRects(rdpRail *rail, rdpWindow *window);
void mac_rail_DestroyWindow(rdpRail *rail, rdpWindow *window);
void mac_process_rail_get_sysparams_event(rdpChannels *channels, RDP_EVENT *event);
void mac_send_rail_client_event(rdpChannels *channels, uint16 event_type, void *param);
void mac_on_free_rail_client_event(RDP_EVENT* event);
void mac_process_rail_server_sysparam_event(rdpChannels* channels, RDP_EVENT* event);
void mac_process_rail_exec_result_event(rdpChannels* channels, RDP_EVENT* event);
void mac_rail_enable_remoteapp_mode();
void mac_process_rail_server_minmaxinfo_event(rdpChannels* channels, RDP_EVENT* event);
void mac_process_rail_server_localmovesize_event(freerdp *inst, RDP_EVENT *event);
void apple_center_window(NSRect * r);
void apple_to_windowMove(NSRect * r, RAIL_WINDOW_MOVE_ORDER * windowMove);
struct mac_context
{

File diff suppressed because it is too large Load Diff

15
client/Mac/MRDPWindow.h Normal file
View File

@ -0,0 +1,15 @@
#import <Foundation/Foundation.h>
#import "MRDPRailView.h"
#import "MRDPRailWindow.h"
@interface MRDPWindow : NSObject
{
}
@property (assign) int windowID;
@property (retain) MRDPRailWindow * window;
@property (retain) MRDPRailView * view;
@end

11
client/Mac/MRDPWindow.m Normal file
View File

@ -0,0 +1,11 @@
#include "MRDPWindow.h"
@implementation MRDPWindow
@synthesize windowID;
@synthesize window;
@synthesize view;
@end

View File

@ -0,0 +1,25 @@
//
// MRDPCursor.h
// MacFreeRDP
//
// Created by Laxmikant Rashinkar
// Copyright (c) 2012 FreeRDP.org All rights reserved.
//
#import <Foundation/Foundation.h>
#define boolean int
#include "freerdp/graphics.h"
@interface MRDPCursor : NSObject
{
@public
rdpPointer *pointer;
uint8 *cursor_data; // bitmapped pixel data
NSBitmapImageRep *bmiRep;
NSCursor *nsCursor;
NSImage *nsImage;
}
@end

View File

@ -0,0 +1,12 @@
//
// MRDPCursor.m
// MacFreeRDP
//
// Created by Laxmikant Rashinkar
// Copyright (c) 2012 FreeRDP.org All rights reserved.
//
#import "MRDPCursor.h"
@implementation MRDPCursor
@end

View File

@ -0,0 +1,13 @@
//
// MRDPRailWindow.h
// Mac
//
// Created by Laxmikant Rashinkar
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface MRDPRailWindow : NSWindow
@end

View File

@ -0,0 +1,18 @@
//
// MRDPRailWindow.m
// Mac
//
// Created by Laxmikant Rashinkar
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import "MRDPRailWindow.h"
@implementation MRDPRailWindow
- (BOOL) canBecomeKeyWindow
{
return YES;
}
@end

177
client/Mac/Mac/MRDPView.h Normal file
View File

@ -0,0 +1,177 @@
//
// MRDPView.h
// MacFreeRDP
//
// Created by Laxmikant Rashinkar
// Copyright (c) 2012 FreeRDP.org All rights reserved.
//
#import <Cocoa/Cocoa.h>
typedef int boolean;
#import "MRDPWindow.h"
#import "freerdp/freerdp.h"
#import "freerdp/types.h"
#import "freerdp/channels/channels.h"
#import "freerdp/gdi/gdi.h"
#import "freerdp/graphics.h"
#import "freerdp/utils/event.h"
#import "freerdp/plugins/cliprdr.h"
#import "freerdp/utils/args.h"
#import "freerdp/rail/rail.h"
#import "freerdp/rail.h"
#import "freerdp/utils/rail.h"
@interface MRDPView : NSView
{
CFRunLoopSourceRef run_loop_src;
CFRunLoopSourceRef run_loop_src_channels;
NSBitmapImageRep *bmiRep;
NSMutableArray *cursors;
NSMutableArray *windows;
NSTimer *pasteboard_timer;
NSRect rect;
NSRect prevWinPosition;
freerdp *rdp_instance;
rdpContext *rdp_context;
char *pixel_data;
int width;
int height;
int argc;
int titleBarHeight;
char **argv;
// RAIL stuff
MRDPWindow *currentWindow;
NSPoint savedDragLocation;
boolean mouseInClientArea;
boolean isRemoteApp;
boolean firstCreateWindow;
boolean isMoveSizeInProgress;
boolean skipResizeOnce;
boolean saveInitialDragLoc;
boolean skipMoveWindowOnce;
// store state info for some keys
int kdlshift;
int kdrshift;
int kdlctrl;
int kdrctrl;
int kdlalt;
int kdralt;
int kdlmeta;
int kdrmeta;
int kdcapslock;
@public
NSWindow *ourMainWindow;
NSPasteboard *pasteboard_rd; // for reading from clipboard
NSPasteboard *pasteboard_wr; // for writing to clipboard
int pasteboard_changecount;
int pasteboard_format;
int is_connected; // true when connected to RDP server
}
- (void) rdpConnectEror;
- (void) rdpRemoteAppError;
- (void) saveStateInfo :(freerdp *) instance :(rdpContext *) context;
- (void) onPasteboardTimerFired :(NSTimer *) timer;
- (void) my_draw_rect :(void *) context;
- (void) releaseResources;
- (void) setViewSize : (int) width : (int) height;
@property (assign) int is_connected;
@end
/* Pointer Flags */
#define PTR_FLAGS_WHEEL 0x0200
#define PTR_FLAGS_WHEEL_NEGATIVE 0x0100
#define PTR_FLAGS_MOVE 0x0800
#define PTR_FLAGS_DOWN 0x8000
#define PTR_FLAGS_BUTTON1 0x1000
#define PTR_FLAGS_BUTTON2 0x2000
#define PTR_FLAGS_BUTTON3 0x4000
#define WheelRotationMask 0x01FF
void pointer_new(rdpContext* context, rdpPointer* pointer);
void pointer_free(rdpContext* context, rdpPointer* pointer);
void pointer_set(rdpContext* context, rdpPointer* pointer);
void pointer_setNull(rdpContext* context);
void pointer_setDefault(rdpContext* context);
int rdp_connect();
boolean mac_pre_connect(freerdp *inst);
boolean mac_post_connect(freerdp *inst);
void mac_context_new(freerdp *inst, rdpContext *context);
void mac_context_free(freerdp *inst, rdpContext *context);
void mac_set_bounds(rdpContext *context, rdpBounds *bounds);
void mac_bitmap_update(rdpContext *context, BITMAP_UPDATE *bitmap);
void mac_begin_paint(rdpContext *context);
void mac_end_paint(rdpContext* context);
void mac_save_state_info(freerdp *inst, rdpContext *context);
void skt_activity_cb(CFSocketRef s, CFSocketCallBackType callbackType, CFDataRef address, const void *data, void *info);
void channel_activity_cb(CFSocketRef s, CFSocketCallBackType callbackType, CFDataRef address, const void *data, void *info);
int register_fds(int *fds, int count, void *inst);
int invoke_draw_rect(rdpContext *context);
int process_plugin_args(rdpSettings* settings, const char* name, RDP_PLUGIN_DATA* plugin_data, void* user_data);
int receive_channel_data(freerdp *inst, int chan_id, uint8 *data, int size, int flags, int total_size);
void process_cliprdr_event(freerdp *inst, RDP_EVENT *event);
void cliprdr_process_cb_format_list_event(freerdp *inst, RDP_CB_FORMAT_LIST_EVENT* event);
void cliprdr_send_data_request(freerdp *inst, uint32 format);
void cliprdr_process_cb_monitor_ready_event(freerdp* inst);
void cliprdr_process_cb_data_response_event(freerdp *inst, RDP_CB_DATA_RESPONSE_EVENT *event);
void cliprdr_process_text(freerdp *inst, uint8 *data, int len);
void cliprdr_send_supported_format_list(freerdp *inst);
int register_channel_fds(int *fds, int count, void *inst);
void mac_process_rail_event(freerdp *inst, RDP_EVENT *event);
void mac_rail_register_callbacks(freerdp *inst, rdpRail *rail);
void mac_rail_CreateWindow(rdpRail *rail, rdpWindow *window);
void mac_rail_MoveWindow(rdpRail *rail, rdpWindow *window);
void mac_rail_ShowWindow(rdpRail *rail, rdpWindow *window, uint8 state);
void mac_rail_SetWindowText(rdpRail *rail, rdpWindow *window);
void mac_rail_SetWindowIcon(rdpRail *rail, rdpWindow *window, rdpIcon *icon);
void mac_rail_SetWindowRects(rdpRail *rail, rdpWindow *window);
void mac_rail_SetWindowVisibilityRects(rdpRail *rail, rdpWindow *window);
void mac_rail_DestroyWindow(rdpRail *rail, rdpWindow *window);
void mac_process_rail_get_sysparams_event(rdpChannels *channels, RDP_EVENT *event);
void mac_send_rail_client_event(rdpChannels *channels, uint16 event_type, void *param);
void mac_on_free_rail_client_event(RDP_EVENT* event);
void mac_process_rail_server_sysparam_event(rdpChannels* channels, RDP_EVENT* event);
void mac_process_rail_exec_result_event(rdpChannels* channels, RDP_EVENT* event);
void mac_rail_enable_remoteapp_mode();
void mac_process_rail_server_minmaxinfo_event(rdpChannels* channels, RDP_EVENT* event);
void mac_process_rail_server_localmovesize_event(freerdp *inst, RDP_EVENT *event);
void apple_center_window(NSRect * r);
void apple_to_windowMove(NSRect * r, RAIL_WINDOW_MOVE_ORDER * windowMove);
struct mac_context
{
// *must* have this - do not delete
rdpContext _p;
};
struct cursor
{
rdpPointer *pointer;
uint8 *cursor_data; // bitmapped pixel data
void *bmiRep; // NSBitmapImageRep
void *nsCursor; // NSCursor
void *nsImage; // NSImage
};
struct rgba_data
{
char red;
char green;
char blue;
char alpha;
};
struct kkey
{
int key_code;
int flags;
};

2314
client/Mac/Mac/MRDPView.m Normal file

File diff suppressed because it is too large Load Diff