client/Mac: changes from LK2000

This commit is contained in:
Jay Sorg 2012-08-02 10:04:44 -07:00
parent a14930f091
commit 790bf99f3b
5 changed files with 221 additions and 107 deletions

View File

@ -87,23 +87,19 @@ if(APPLE)
endif() endif()
# OS X Interface Builder files # OS X Interface Builder files
set (MacFreeRDP_XIBS file (GLOB MacFreeRDP_XIBS
MainMenu.xib *.xib
Credits.rtf
) )
# Headers # Headers
set (MacFreeRDP_Headers file (GLOB MacFreeRDP_Headers
MRDPCursor.h *.h
MRDPView.h )
AppDelegate.h)
# Source # Source
set (MacFreeRDP_Source file (GLOB MacFreeRDP_Source
MRDPCursor.m *.m
MRDPView.m )
AppDelegate.m
main.m)
add_executable(MacFreeRDP add_executable(MacFreeRDP
${APP_TYPE} ${APP_TYPE}
@ -147,3 +143,4 @@ target_link_libraries(MacFreeRDP ${CMAKE_SOURCE_DIR}/../../xcode/libfreerdp-cach
target_link_libraries(MacFreeRDP ${CMAKE_SOURCE_DIR}/../../xcode/libfreerdp-gdi/Debug/libfreerdp-gdi.dylib) target_link_libraries(MacFreeRDP ${CMAKE_SOURCE_DIR}/../../xcode/libfreerdp-gdi/Debug/libfreerdp-gdi.dylib)
target_link_libraries(MacFreeRDP ${CMAKE_SOURCE_DIR}/../../xcode/libfreerdp-utils/Debug/libfreerdp-utils.dylib) target_link_libraries(MacFreeRDP ${CMAKE_SOURCE_DIR}/../../xcode/libfreerdp-utils/Debug/libfreerdp-utils.dylib)
target_link_libraries(MacFreeRDP ${CMAKE_SOURCE_DIR}/../../xcode/libfreerdp-codec/Debug/libfreerdp-codec.dylib) target_link_libraries(MacFreeRDP ${CMAKE_SOURCE_DIR}/../../xcode/libfreerdp-codec/Debug/libfreerdp-codec.dylib)
target_link_libraries(MacFreeRDP ${CMAKE_SOURCE_DIR}/../../xcode/libfreerdp-rail/Debug/libfreerdp-rail.dylib)

View File

@ -4,6 +4,7 @@
#import "freerdp/gdi/gdi.h" #import "freerdp/gdi/gdi.h"
#import "freerdp/rail/rail.h" #import "freerdp/rail/rail.h"
#import "MRDPRailWindow.h"
@interface MRDPRailView : NSView @interface MRDPRailView : NSView
{ {
@ -14,9 +15,11 @@
char * pixelData; char * pixelData;
boolean mouseInClientArea; boolean mouseInClientArea;
boolean titleBarClicked; boolean titleBarClicked;
boolean gestureEventInProgress;
int width; int width;
int height; int height;
int savedWindowId; int savedWindowId;
int scrollWheelCount;
// store state info for some keys // store state info for some keys
int kdlshift; int kdlshift;
@ -36,16 +39,23 @@
int localMoveType; int localMoveType;
} }
@property (assign) MRDPRailWindow * mrdpRailWindow;
@property (assign) int windowIndex;
@property (assign) boolean activateWindow;
- (void) windowDidMove:(NSNotification *) notification;
- (void) updateDisplay; - (void) updateDisplay;
- (void) setRdpInstance:(freerdp *) instance width:(int) w andHeight:(int) h windowID:(int) windowID; - (void) setRdpInstance:(freerdp *) instance width:(int) w andHeight:(int) h windowID:(int) windowID;
- (BOOL) eventIsInClientArea :(NSEvent *) event :(int *) xptr :(int *) yptr; - (BOOL) eventIsInClientArea :(NSEvent *) event :(int *) xptr :(int *) yptr;
- (void) setupBmiRep:(int) width :(int) height; - (void) setupBmiRep:(int) width :(int) height;
- (void) releaseResources;
void mac_rail_MoveWindow(rdpRail *rail, rdpWindow *window); void mac_rail_MoveWindow(rdpRail *rail, rdpWindow *window);
void apple_to_windowMove(NSRect * r, RAIL_WINDOW_MOVE_ORDER * windowMove); void apple_to_windowMove(NSRect * r, RAIL_WINDOW_MOVE_ORDER * windowMove);
void mac_send_rail_client_event(rdpChannels *channels, uint16 event_type, void *param); void mac_send_rail_client_event(rdpChannels *channels, uint16 event_type, void *param);
void windows_to_apple_cords(NSRect * r); void windows_to_apple_cords(NSRect * r);
void rail_MoveWindow(rdpRail * rail, rdpWindow * window); void rail_MoveWindow(rdpRail * rail, rdpWindow * window);
void mac_rail_send_activate(int window_id);
@end @end

View File

@ -4,6 +4,8 @@
@implementation MRDPRailView @implementation MRDPRailView
@synthesize mrdpRailWindow, windowIndex, activateWindow;
MRDPRailView * g_mrdpRailView; MRDPRailView * g_mrdpRailView;
struct kkey struct kkey
@ -19,20 +21,20 @@ extern struct kkey g_keys[];
boolean moveWindow = NO; boolean moveWindow = NO;
NSRect srcRectOuter; NSRect srcRectOuter;
NSRect destRectOuter; NSRect destRectOuter;
rdpGdi * gdi; rdpGdi * gdi;
if ((context == 0) || (context->gdi == 0)) if ((context == 0) || (context->gdi == 0))
return; return;
if (context->gdi->primary->hdc->hwnd->invalid->null) if (context->gdi->primary->hdc->hwnd->invalid->null)
return; return;
if (context->gdi->drawing != context->gdi->primary) if (context->gdi->drawing != context->gdi->primary)
return; return;
gdi = context->gdi; gdi = context->gdi;
srcRectOuter = NSMakeRect(0, 0, self->width, self->height); srcRectOuter = NSMakeRect(0, 0, self->width, self->height);
destRectOuter = [[self window] frame]; destRectOuter = [[self window] frame];
@ -42,15 +44,15 @@ extern struct kkey g_keys[];
destRectOuter.size.width = screenSize.size.width; destRectOuter.size.width = screenSize.size.width;
moveWindow = YES; moveWindow = YES;
} }
if (destRectOuter.size.height > screenSize.size.height) { if (destRectOuter.size.height > screenSize.size.height) {
destRectOuter.size.height = screenSize.size.height; destRectOuter.size.height = screenSize.size.height;
moveWindow = YES; moveWindow = YES;
} }
if (destRectOuter.origin.x + destRectOuter.size.width > width) if (destRectOuter.origin.x + destRectOuter.size.width > width)
destRectOuter.size.width = width - destRectOuter.origin.x; destRectOuter.size.width = width - destRectOuter.origin.x;
[self setupBmiRep:destRectOuter.size.width :destRectOuter.size.height]; [self setupBmiRep:destRectOuter.size.width :destRectOuter.size.height];
if (moveWindow) { if (moveWindow) {
@ -61,12 +63,12 @@ extern struct kkey g_keys[];
//skipMoveWindowOnce = TRUE; //skipMoveWindowOnce = TRUE;
//mac_send_rail_client_event(g_mrdpRailView->rdp_instance->context->channels, RDP_EVENT_TYPE_RAIL_CLIENT_WINDOW_MOVE, &newWndLoc); //mac_send_rail_client_event(g_mrdpRailView->rdp_instance->context->channels, RDP_EVENT_TYPE_RAIL_CLIENT_WINDOW_MOVE, &newWndLoc);
} }
destRectOuter.origin.y = height - destRectOuter.origin.y - destRectOuter.size.height; destRectOuter.origin.y = height - destRectOuter.origin.y - destRectOuter.size.height;
rail_convert_color_space(pixelData, (char *) gdi->primary_buffer, rail_convert_color_space(pixelData, (char *) gdi->primary_buffer,
&destRectOuter, self->width, self->height); &destRectOuter, self->width, self->height);
if (moveWindow) if (moveWindow)
[self setNeedsDisplayInRect:destRectOuter]; [self setNeedsDisplayInRect:destRectOuter];
else else
[self setNeedsDisplayInRect:[self frame]]; [self setNeedsDisplayInRect:[self frame]];
@ -81,7 +83,7 @@ extern struct kkey g_keys[];
- (void) drawRect:(NSRect)dirtyRect - (void) drawRect:(NSRect)dirtyRect
{ {
[bmiRep drawInRect:dirtyRect fromRect:dirtyRect operation:NSCompositeCopy fraction:1.0 respectFlipped:NO hints:nil]; [bmiRep drawInRect:dirtyRect fromRect:dirtyRect operation:NSCompositeCopy fraction:1.0 respectFlipped:NO hints:nil];
if (pixelData) { if (pixelData) {
free(pixelData); free(pixelData);
pixelData = NULL; pixelData = NULL;
@ -93,19 +95,24 @@ extern struct kkey g_keys[];
* become first responder so we can get keyboard and mouse events * become first responder so we can get keyboard and mouse events
***********************************************************************/ ***********************************************************************/
- (BOOL)acceptsFirstResponder - (BOOL)acceptsFirstResponder
{
return YES;
}
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
{ {
return YES; return NO;
} }
/** ********************************************************************* /** *********************************************************************
* called when a mouse move event occurrs * called when a mouse move event occurrs
* *
* ideally we want to be called when the mouse moves over NSView client area, * 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; * 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 * 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 * on Mac OS X v10.5 and higher; since we want to be compatible with older
* versions, we do this manually. * versions, we do this manually.
* *
* TODO: here is how it can be done using legacy methods * 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 * http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/EventOverview/MouseTrackingEvents/MouseTrackingEvents.html#//apple_ref/doc/uid/10000060i-CH11-SW1
@ -114,15 +121,15 @@ extern struct kkey g_keys[];
- (void) mouseMoved:(NSEvent *)event - (void) mouseMoved:(NSEvent *)event
{ {
[super mouseMoved:event]; [super mouseMoved:event];
NSRect winFrame = [[self window] frame]; NSRect winFrame = [[self window] frame];
NSPoint loc = [event locationInWindow]; NSPoint loc = [event locationInWindow];
int x = (int) (winFrame.origin.x + loc.x); int x = (int) (winFrame.origin.x + loc.x);
int y = (int) (winFrame.origin.y + loc.y); int y = (int) (winFrame.origin.y + loc.y);
y = height - y; y = height - y;
// send mouse motion event to RDP server // send mouse motion event to RDP server
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_MOVE, x, y); rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_MOVE, x, y);
} }
@ -134,7 +141,7 @@ extern struct kkey g_keys[];
- (void)mouseDown:(NSEvent *) event - (void)mouseDown:(NSEvent *) event
{ {
[super mouseDown:event]; [super mouseDown:event];
NSRect winFrame = [[self window] frame]; NSRect winFrame = [[self window] frame];
NSPoint loc = [event locationInWindow]; NSPoint loc = [event locationInWindow];
int x = (int) (winFrame.origin.x + loc.x); int x = (int) (winFrame.origin.x + loc.x);
@ -146,12 +153,12 @@ extern struct kkey g_keys[];
if ((yPos >= 4) && (yPos <= 20)) if ((yPos >= 4) && (yPos <= 20))
titleBarClicked = YES; titleBarClicked = YES;
else else
titleBarClicked = NO; titleBarClicked = NO;
savedDragLocation.x = loc.x; savedDragLocation.x = loc.x;
savedDragLocation.y = loc.y; savedDragLocation.y = loc.y;
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1, x, y); rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1, x, y);
} }
@ -168,7 +175,7 @@ extern struct kkey g_keys[];
int x = (int) (winFrame.origin.x + loc.x); int x = (int) (winFrame.origin.x + loc.x);
int y = (int) (winFrame.origin.y + loc.y); int y = (int) (winFrame.origin.y + loc.y);
y = height - y; y = height - y;
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_BUTTON1, x, y); rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_BUTTON1, x, y);
titleBarClicked = NO; titleBarClicked = NO;
} }
@ -203,7 +210,7 @@ extern struct kkey g_keys[];
int x = (int) (winFrame.origin.x + loc.x); int x = (int) (winFrame.origin.x + loc.x);
int y = (int) (winFrame.origin.y + loc.y); int y = (int) (winFrame.origin.y + loc.y);
y = height - y; y = height - y;
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_BUTTON2, x, y); rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_BUTTON2, x, y);
} }
@ -237,33 +244,33 @@ extern struct kkey g_keys[];
int x = (int) (winFrame.origin.x + loc.x); int x = (int) (winFrame.origin.x + loc.x);
int y = (int) (winFrame.origin.y + loc.y); int y = (int) (winFrame.origin.y + loc.y);
y = height - y; y = height - y;
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_BUTTON3, x, y); rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_BUTTON3, x, y);
} }
- (void) scrollWheel:(NSEvent *)event - (void) scrollWheel:(NSEvent *)event
{ {
uint16 flags; uint16 flags;
[super scrollWheel:event]; [super scrollWheel:event];
NSRect winFrame = [[self window] frame]; // we get more two finger trackpad scroll events
NSPoint loc = [event locationInWindow]; // than scrollWheel events, so we drop some
int x = (int) (winFrame.origin.x + loc.x);
int y = (int) (winFrame.origin.y + loc.y); if (gestureEventInProgress) {
y = height - y; scrollWheelCount++;
if (scrollWheelCount % 8 != 0)
flags = PTR_FLAGS_WHEEL; return;
}
if ([event scrollingDeltaY] < 0) { if ([event scrollingDeltaY] < 0) {
flags |= PTR_FLAGS_WHEEL_NEGATIVE | 0x0088; flags = PTR_FLAGS_WHEEL | PTR_FLAGS_WHEEL_NEGATIVE | 0x0088;
} }
else { else {
flags |= 0x0078; flags = PTR_FLAGS_WHEEL | 0x78;
} }
x += (int) [event scrollingDeltaX];
y += (int) [event scrollingDeltaY]; rdp_instance->input->MouseEvent(rdp_instance->input, flags, 0, 0);
rdp_instance->input->MouseEvent(rdp_instance->input, flags, x, y);
} }
/** ********************************************************************* /** *********************************************************************
@ -273,7 +280,7 @@ extern struct kkey g_keys[];
- (void) mouseDragged:(NSEvent *)event - (void) mouseDragged:(NSEvent *)event
{ {
[super mouseDragged:event]; [super mouseDragged:event];
NSRect winFrame = [[self window] frame]; NSRect winFrame = [[self window] frame];
NSPoint loc = [event locationInWindow]; NSPoint loc = [event locationInWindow];
int x = (int) loc.x; int x = (int) loc.x;
@ -283,13 +290,13 @@ extern struct kkey g_keys[];
// window is being dragged to a new location // window is being dragged to a new location
int newX = x - savedDragLocation.x; int newX = x - savedDragLocation.x;
int newY = y - savedDragLocation.y; int newY = y - savedDragLocation.y;
if ((newX == 0) && (newY == 0)) if ((newX == 0) && (newY == 0))
return; return;
winFrame.origin.x += newX; winFrame.origin.x += newX;
winFrame.origin.y += newY; winFrame.origin.y += newY;
[[self window] setFrame:winFrame display:YES]; [[self window] setFrame:winFrame display:YES];
return; return;
} }
@ -299,7 +306,7 @@ extern struct kkey g_keys[];
int diff = (int) (loc.x - savedDragLocation.x); int diff = (int) (loc.x - savedDragLocation.x);
if (diff == 0) if (diff == 0)
return; return;
if (diff < 0) { if (diff < 0) {
diff = abs(diff); diff = abs(diff);
winFrame.origin.x -= diff; winFrame.origin.x -= diff;
@ -309,7 +316,7 @@ extern struct kkey g_keys[];
winFrame.origin.x += diff; winFrame.origin.x += diff;
winFrame.size.width -= diff; winFrame.size.width -= diff;
} }
[[self window] setFrame:winFrame display:YES]; [[self window] setFrame:winFrame display:YES];
return; return;
} }
@ -319,10 +326,10 @@ extern struct kkey g_keys[];
int diff = (int) (loc.x - savedDragLocation.x); int diff = (int) (loc.x - savedDragLocation.x);
if (diff == 0) if (diff == 0)
return; return;
savedDragLocation.x = loc.x; savedDragLocation.x = loc.x;
savedDragLocation.y = loc.y; savedDragLocation.y = loc.y;
winFrame.size.width += diff; winFrame.size.width += diff;
[[self window] setFrame:winFrame display:YES]; [[self window] setFrame:winFrame display:YES];
return; return;
@ -333,21 +340,21 @@ extern struct kkey g_keys[];
int diff = (int) (loc.y - savedDragLocation.y); int diff = (int) (loc.y - savedDragLocation.y);
if (diff == 0) if (diff == 0)
return; return;
savedDragLocation.x = loc.x; savedDragLocation.x = loc.x;
savedDragLocation.y = loc.y; savedDragLocation.y = loc.y;
winFrame.size.height += diff; winFrame.size.height += diff;
[[self window] setFrame:winFrame display:YES]; [[self window] setFrame:winFrame display:YES];
return; return;
} }
if (localMoveType == RAIL_WMSZ_BOTTOM) { if (localMoveType == RAIL_WMSZ_BOTTOM) {
// bottom border resize taking place // bottom border resize taking place
int diff = (int) (loc.y - savedDragLocation.y); int diff = (int) (loc.y - savedDragLocation.y);
if (diff == 0) if (diff == 0)
return; return;
if (diff < 0) { if (diff < 0) {
diff = abs(diff); diff = abs(diff);
winFrame.origin.y -= diff; winFrame.origin.y -= diff;
@ -357,11 +364,11 @@ extern struct kkey g_keys[];
winFrame.origin.y += diff; winFrame.origin.y += diff;
winFrame.size.height -= diff; winFrame.size.height -= diff;
} }
[[self window] setFrame:winFrame display:YES]; [[self window] setFrame:winFrame display:YES];
return; return;
} }
if (localMoveType == RAIL_WMSZ_TOPLEFT) { if (localMoveType == RAIL_WMSZ_TOPLEFT) {
// top left border resize taking place // top left border resize taking place
int diff = (int) (loc.x - savedDragLocation.x); int diff = (int) (loc.x - savedDragLocation.x);
@ -382,7 +389,7 @@ extern struct kkey g_keys[];
savedDragLocation.y = loc.y; savedDragLocation.y = loc.y;
winFrame.size.height += diff; winFrame.size.height += diff;
} }
[[self window] setFrame:winFrame display:YES]; [[self window] setFrame:winFrame display:YES];
return; return;
} }
@ -393,7 +400,7 @@ extern struct kkey g_keys[];
if (diff != 0) { if (diff != 0) {
winFrame.size.width += diff; winFrame.size.width += diff;
} }
diff = (int) (loc.y - savedDragLocation.y); diff = (int) (loc.y - savedDragLocation.y);
if (diff != 0) { if (diff != 0) {
winFrame.size.height += diff; winFrame.size.height += diff;
@ -405,7 +412,7 @@ extern struct kkey g_keys[];
[[self window] setFrame:winFrame display:YES]; [[self window] setFrame:winFrame display:YES];
return; return;
} }
if (localMoveType == RAIL_WMSZ_BOTTOMLEFT) { if (localMoveType == RAIL_WMSZ_BOTTOMLEFT) {
// bottom left border resize taking place // bottom left border resize taking place
int diff = (int) (loc.x - savedDragLocation.x); int diff = (int) (loc.x - savedDragLocation.x);
@ -420,7 +427,7 @@ extern struct kkey g_keys[];
winFrame.size.width -= diff; winFrame.size.width -= diff;
} }
} }
diff = (int) (loc.y - savedDragLocation.y); diff = (int) (loc.y - savedDragLocation.y);
if (diff != 0) { if (diff != 0) {
if (diff < 0) { if (diff < 0) {
@ -433,11 +440,11 @@ extern struct kkey g_keys[];
winFrame.size.height -= diff; winFrame.size.height -= diff;
} }
} }
[[self window] setFrame:winFrame display:YES]; [[self window] setFrame:winFrame display:YES];
return; return;
} }
if (localMoveType == RAIL_WMSZ_BOTTOMRIGHT) { if (localMoveType == RAIL_WMSZ_BOTTOMRIGHT) {
// bottom right border resize taking place // bottom right border resize taking place
int diff = (int) (loc.x - savedDragLocation.x); int diff = (int) (loc.x - savedDragLocation.x);
@ -446,7 +453,7 @@ extern struct kkey g_keys[];
//savedDragLocation.y = loc.y; //savedDragLocation.y = loc.y;
winFrame.size.width += diff; winFrame.size.width += diff;
} }
diff = (int) (loc.y - savedDragLocation.y); diff = (int) (loc.y - savedDragLocation.y);
if (diff != 0) { if (diff != 0) {
if (diff < 0) { if (diff < 0) {
@ -459,15 +466,15 @@ extern struct kkey g_keys[];
winFrame.size.height -= diff; winFrame.size.height -= diff;
} }
} }
[[self window] setFrame:winFrame display:YES]; [[self window] setFrame:winFrame display:YES];
return; return;
} }
x = (int) (winFrame.origin.x + loc.x); x = (int) (winFrame.origin.x + loc.x);
y = (int) (winFrame.origin.y + loc.y); y = (int) (winFrame.origin.y + loc.y);
y = height - y; y = height - y;
// send mouse motion event to RDP server // send mouse motion event to RDP server
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_MOVE, x, y); rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_MOVE, x, y);
} }
@ -479,7 +486,7 @@ extern struct kkey g_keys[];
- (void) keyDown:(NSEvent *) event - (void) keyDown:(NSEvent *) event
{ {
int key; int key;
key = [event keyCode]; key = [event keyCode];
rdp_instance->input->KeyboardEvent(rdp_instance->input, g_keys[key].flags | KBD_FLAGS_DOWN, g_keys[key].key_code); rdp_instance->input->KeyboardEvent(rdp_instance->input, g_keys[key].flags | KBD_FLAGS_DOWN, g_keys[key].key_code);
} }
@ -503,7 +510,7 @@ extern struct kkey g_keys[];
- (void) flagsChanged:(NSEvent *) event - (void) flagsChanged:(NSEvent *) event
{ {
NSUInteger mf = [event modifierFlags]; NSUInteger mf = [event modifierFlags];
// caps lock // caps lock
if (mf == 0x10100) { if (mf == 0x10100) {
printf("TODO: caps lock is on\n"); printf("TODO: caps lock is on\n");
@ -524,7 +531,7 @@ extern struct kkey g_keys[];
rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_RELEASE, 0x2a); rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_RELEASE, 0x2a);
kdlshift = 0; kdlshift = 0;
} }
// right shift // right shift
if ((kdrshift == 0) && ((mf & 4) != 0)) { if ((kdrshift == 0) && ((mf & 4) != 0)) {
// right shift went down // right shift went down
@ -536,7 +543,7 @@ extern struct kkey g_keys[];
rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_RELEASE, 0x36); rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_RELEASE, 0x36);
kdrshift = 0; kdrshift = 0;
} }
// left ctrl // left ctrl
if ((kdlctrl == 0) && ((mf & 1) != 0)) { if ((kdlctrl == 0) && ((mf & 1) != 0)) {
// left ctrl went down // left ctrl went down
@ -548,7 +555,7 @@ extern struct kkey g_keys[];
rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_RELEASE, 0x1d); rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_RELEASE, 0x1d);
kdlctrl = 0; kdlctrl = 0;
} }
// right ctrl // right ctrl
if ((kdrctrl == 0) && ((mf & 0x2000) != 0)) { if ((kdrctrl == 0) && ((mf & 0x2000) != 0)) {
// right ctrl went down // right ctrl went down
@ -560,7 +567,7 @@ extern struct kkey g_keys[];
rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_RELEASE, 0x1d); rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_RELEASE, 0x1d);
kdrctrl = 0; kdrctrl = 0;
} }
// left alt // left alt
if ((kdlalt == 0) && ((mf & 0x20) != 0)) { if ((kdlalt == 0) && ((mf & 0x20) != 0)) {
// left alt went down // left alt went down
@ -572,7 +579,7 @@ extern struct kkey g_keys[];
rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_RELEASE, 0x38); rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_RELEASE, 0x38);
kdlalt = 0; kdlalt = 0;
} }
// right alt // right alt
if ((kdralt == 0) && ((mf & 0x40) != 0)) { if ((kdralt == 0) && ((mf & 0x40) != 0)) {
// right alt went down // right alt went down
@ -584,7 +591,7 @@ extern struct kkey g_keys[];
rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_RELEASE, 0x38); rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_RELEASE, 0x38);
kdralt = 0; kdralt = 0;
} }
// left meta // left meta
if ((kdlmeta == 0) && ((mf & 0x08) != 0)) { if ((kdlmeta == 0) && ((mf & 0x08) != 0)) {
// left meta went down // left meta went down
@ -596,7 +603,7 @@ extern struct kkey g_keys[];
rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_RELEASE, 0x5b); rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_RELEASE, 0x5b);
kdlmeta = 0; kdlmeta = 0;
} }
// right meta // right meta
if ((kdrmeta == 0) && ((mf & 0x10) != 0)) { if ((kdrmeta == 0) && ((mf & 0x10) != 0)) {
// right meta went down // right meta went down
@ -617,18 +624,28 @@ extern struct kkey g_keys[];
width = w; width = w;
height = h; height = h;
savedWindowId = windowID; savedWindowId = windowID;
NSRect tr = NSMakeRect(0, 0, NSRect tr = NSMakeRect(0, 0,
[[NSScreen mainScreen] frame].size.width, [[NSScreen mainScreen] frame].size.width,
[[NSScreen mainScreen] frame].size.height); [[NSScreen mainScreen] frame].size.height);
NSTrackingArea * trackingArea = [[NSTrackingArea alloc] initWithRect:tr options:NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingCursorUpdate | NSTrackingEnabledDuringMouseDrag | NSTrackingActiveAlways owner:self userInfo:nil]; NSTrackingArea * trackingArea = [[NSTrackingArea alloc] initWithRect:tr options:NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingCursorUpdate | NSTrackingEnabledDuringMouseDrag | NSTrackingActiveAlways owner:self userInfo:nil];
[self addTrackingArea:trackingArea]; [self addTrackingArea:trackingArea];
g_mrdpRailView = self; g_mrdpRailView = self;
[self becomeFirstResponder]; [self becomeFirstResponder];
[self setAcceptsTouchEvents:YES];
// we want to be notified when window resizes....
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidResize:) name:NSWindowDidResizeNotification object:nil];
// ...moves
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidMove:) name:NSWindowDidMoveNotification object:nil];
// ...and becomes the key window
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:nil];
} }
- (void) setupBmiRep:(int) frameWidth :(int) frameHeight - (void) setupBmiRep:(int) frameWidth :(int) frameHeight
@ -640,10 +657,10 @@ extern struct kkey g_keys[];
char blue; char blue;
char alpha; char alpha;
}; };
if (pixelData) if (pixelData)
free(pixelData); free(pixelData);
pixelData = (char *) malloc(frameWidth * frameHeight * sizeof(struct rgba_data)); pixelData = (char *) malloc(frameWidth * frameHeight * sizeof(struct rgba_data));
bmiRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:(unsigned char **) &pixelData bmiRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:(unsigned char **) &pixelData
pixelsWide:frameWidth pixelsWide:frameWidth
@ -657,6 +674,85 @@ extern struct kkey g_keys[];
bytesPerRow:frameWidth * sizeof(struct rgba_data) bytesPerRow:frameWidth * sizeof(struct rgba_data)
bitsPerPixel:0]; bitsPerPixel:0];
} }
- (void) beginGestureWithEvent:(NSEvent *)event
{
gestureEventInProgress = YES;
}
- (void) endGestureWithEvent:(NSEvent *)event
{
gestureEventInProgress = NO;
}
/**
* called when a bordered window changes size
*/
- (void) windowDidResize:(NSNotification *) notification
{
// if we are not the source of this notification, just return
if ([notification object] != [self mrdpRailWindow])
return;
// let RDP server know that window has moved
RAIL_WINDOW_MOVE_ORDER windowMove;
NSRect r = [[self window] frame];
int diffInHeight = [[self window] frame].size.height - [self frame].size.height;
r.size.height -= diffInHeight;
apple_to_windowMove(&r, &windowMove);
windowMove.windowId = self->savedWindowId;
mac_send_rail_client_event(self->context->channels, RDP_EVENT_TYPE_RAIL_CLIENT_WINDOW_MOVE, &windowMove);
}
/**
* called when user moves a bordered window
*/
- (void) windowDidMove:(NSNotification *) notification
{
// if we are not the source of this notification, just return
if ([notification object] != [self mrdpRailWindow])
return;
// let RDP server know that window has moved
RAIL_WINDOW_MOVE_ORDER windowMove;
NSRect r = [[self window] frame];
int diffInHeight = [[self window] frame].size.height - [self frame].size.height;
r.size.height -= diffInHeight;
apple_to_windowMove(&r, &windowMove);
windowMove.windowId = self->savedWindowId;
mac_send_rail_client_event(self->context->channels, RDP_EVENT_TYPE_RAIL_CLIENT_WINDOW_MOVE, &windowMove);
}
/**
* called when a NSWindow becomes the key window
*/
- (void) windowDidBecomeKey:(NSNotification *) notification
{
// if we are not the source of this notification, just return
if ([notification object] != [self mrdpRailWindow])
return;
if (![self activateWindow])
return;
[[self window] setAcceptsMouseMovedEvents: YES];
//if ([self activateWindow])
mac_rail_send_activate(savedWindowId);
set_current_window(windowIndex);
}
- (void) releaseResources
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
void rail_cvt_from_rect(char *dest, char *src, NSRect destRect, int destWidth, int destHeight, NSRect srcRect) void rail_cvt_from_rect(char *dest, char *src, NSRect destRect, int destWidth, int destHeight, NSRect srcRect)
{ {
@ -665,7 +761,7 @@ void rail_cvt_from_rect(char *dest, char *src, NSRect destRect, int destWidth, i
/** ********************************************************************* /** *********************************************************************
* color space conversion used specifically in RAIL * color space conversion used specifically in RAIL
***********************************************************************/ ***********************************************************************/
void rail_convert_color_space(char *destBuf, char * srcBuf, void rail_convert_color_space(char *destBuf, char * srcBuf,
NSRect * destRect, int width, int height) NSRect * destRect, int width, int height)
{ {
int i; int i;
@ -681,10 +777,10 @@ void rail_convert_color_space(char *destBuf, char * srcBuf,
int pixel2; int pixel2;
int * src32; int * src32;
int * dest32; int * dest32;
int destWidth = destRect->size.width; int destWidth = destRect->size.width;
int destHeight = destRect->size.height; int destHeight = destRect->size.height;
if ((!destBuf) || (!srcBuf)) { if ((!destBuf) || (!srcBuf)) {
return; return;
} }
@ -696,12 +792,12 @@ void rail_convert_color_space(char *destBuf, char * srcBuf,
srcY = destRect->origin.y; srcY = destRect->origin.y;
destX = 0; destX = 0;
destY = 0; destY = 0;
for (i = 0; i < numRows; i++) for (i = 0; i < numRows; i++)
{ {
src32 = (int *) (srcBuf + ((srcY + i) * width + srcX) * 4); src32 = (int *) (srcBuf + ((srcY + i) * width + srcX) * 4);
dest32 = (int *) (destBuf + ((destY + i) * destWidth + destX) * 4); dest32 = (int *) (destBuf + ((destY + i) * destWidth + destX) * 4);
for (j = 0; j < pixelsPerRow; j++) for (j = 0; j < pixelsPerRow; j++)
{ {
pixel = *src32; pixel = *src32;
@ -715,7 +811,7 @@ void rail_convert_color_space(char *destBuf, char * srcBuf,
dest32++; dest32++;
} }
} }
destRect->origin.y = destHeight - destRect->origin.y - destRect->size.height; destRect->origin.y = destHeight - destRect->origin.y - destRect->size.height;
return; return;
} }
@ -729,12 +825,12 @@ void rail_MoveWindow(rdpRail * rail, rdpWindow * window)
if (g_mrdpRailView->isMoveSizeInProgress) { if (g_mrdpRailView->isMoveSizeInProgress) {
return; return;
} }
if (g_mrdpRailView->skipMoveWindowOnce) { if (g_mrdpRailView->skipMoveWindowOnce) {
g_mrdpRailView->skipMoveWindowOnce = NO; g_mrdpRailView->skipMoveWindowOnce = NO;
return; return;
} }
// this rect is based on Windows co-ordinates... // this rect is based on Windows co-ordinates...
NSRect r; NSRect r;
r.origin.x = window->windowOffsetX; r.origin.x = window->windowOffsetX;
@ -746,4 +842,16 @@ void rail_MoveWindow(rdpRail * rail, rdpWindow * window)
[[g_mrdpRailView window] setFrame:r display:YES]; [[g_mrdpRailView window] setFrame:r display:YES];
} }
void mac_rail_send_activate(int window_id)
{
RAIL_ACTIVATE_ORDER activate;
activate.windowId = window_id;
activate.enabled = 1;
mac_send_rail_client_event(g_mrdpRailView->context->channels, RDP_EVENT_TYPE_RAIL_CLIENT_ACTIVATE, &activate);
}
@end @end

View File

@ -34,8 +34,7 @@
#import "MRDPView.h" #import "MRDPView.h"
#import "MRDPCursor.h" #import "MRDPCursor.h"
// Should be defined in Makefile #define RUN_IN_XCODE
// #define RUN_IN_XCODE
// LK_TODO // LK_TODO
#define GOT_HERE //printf("### got here: %s : %s() : %d\n", __FILE__, __func__, __LINE__) #define GOT_HERE //printf("### got here: %s : %s() : %d\n", __FILE__, __func__, __LINE__)
@ -1870,6 +1869,7 @@ void cliprdr_send_supported_format_list(freerdp *inst)
freerdp_channels_send_event(inst->context->channels, (RDP_EVENT*) event); freerdp_channels_send_event(inst->context->channels, (RDP_EVENT*) event);
} }
<<<<<<< HEAD
/**************************************************************************************** /****************************************************************************************
* * * *
* * * *

View File

@ -8,4 +8,3 @@
@synthesize view; @synthesize view;
@end @end