From fe34a529d5da0a45336dfc5d82ebd1c235c20265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 21 Feb 2013 21:09:42 -0500 Subject: [PATCH 1/6] freerdp: fix build and warnings on Mac OS X --- .gitignore | 1 + channels/audin/server/CMakeLists.txt | 2 +- channels/audin/server/audin.c | 6 ++++-- channels/parallel/client/parallel_main.c | 3 ++- channels/rdpsnd/server/rdpsnd.c | 3 ++- channels/serial/client/serial_main.c | 3 ++- channels/server/CMakeLists.txt | 2 +- client/Mac/MRDPView.m | 6 +----- libfreerdp/locale/keyboard_keymap.c | 6 ++++-- libfreerdp/locale/keyboard_x11.c | 2 +- libfreerdp/utils/CMakeLists.txt | 2 +- winpr/libwinpr/sysinfo/CMakeLists.txt | 2 +- winpr/libwinpr/utils/collections/CountdownEvent.c | 9 +++------ 13 files changed, 24 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index 10fe97360..cafaa421d 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,7 @@ client/X11/xfreerdp.1 # Mac OS X .DS_Store *.xcodeproj/ +DerivedData/ # Windows *.vcxproj diff --git a/channels/audin/server/CMakeLists.txt b/channels/audin/server/CMakeLists.txt index 6afda4d4a..7da71e81c 100644 --- a/channels/audin/server/CMakeLists.txt +++ b/channels/audin/server/CMakeLists.txt @@ -27,6 +27,6 @@ set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS MONOLITHIC ${MONOLITHIC_BUILD} MODULE freerdp - MODULES freerdp-utils) + MODULES freerdp-codec freerdp-utils) set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Server") diff --git a/channels/audin/server/audin.c b/channels/audin/server/audin.c index ec6eb4ffb..e97c1e892 100644 --- a/channels/audin/server/audin.c +++ b/channels/audin/server/audin.c @@ -284,7 +284,8 @@ static void* audin_server_thread_func(void* arg) /* Wait for the client to confirm that the Audio Input dynamic channel is ready */ while (1) { - freerdp_thread_wait(thread); + if (freerdp_thread_wait(thread) < 0) + break; if (freerdp_thread_is_stopped(thread)) break; @@ -309,7 +310,8 @@ static void* audin_server_thread_func(void* arg) while (ready) { - freerdp_thread_wait(thread); + if (freerdp_thread_wait(thread) < 0) + break; if (freerdp_thread_is_stopped(thread)) break; diff --git a/channels/parallel/client/parallel_main.c b/channels/parallel/client/parallel_main.c index 9ac56a8ca..5b3d1d7c2 100644 --- a/channels/parallel/client/parallel_main.c +++ b/channels/parallel/client/parallel_main.c @@ -268,7 +268,8 @@ static void* parallel_thread_func(void* arg) while (1) { - freerdp_thread_wait(parallel->thread); + if (freerdp_thread_wait(parallel->thread) < 0) + break; if (freerdp_thread_is_stopped(parallel->thread)) break; diff --git a/channels/rdpsnd/server/rdpsnd.c b/channels/rdpsnd/server/rdpsnd.c index 0215369e7..22af082c3 100644 --- a/channels/rdpsnd/server/rdpsnd.c +++ b/channels/rdpsnd/server/rdpsnd.c @@ -184,7 +184,8 @@ static void* rdpsnd_server_thread_func(void* arg) while (1) { - freerdp_thread_wait(thread); + if (freerdp_thread_wait(thread) < 0) + break; if (freerdp_thread_is_stopped(thread)) break; diff --git a/channels/serial/client/serial_main.c b/channels/serial/client/serial_main.c index 043dedbac..bbcdbeba7 100644 --- a/channels/serial/client/serial_main.c +++ b/channels/serial/client/serial_main.c @@ -341,7 +341,8 @@ static void* serial_thread_func(void* arg) while (1) { - freerdp_thread_wait_timeout(serial->thread, 500); + if (freerdp_thread_wait_timeout(serial->thread, 500) < 0) + break; serial->nfds = 1; FD_ZERO(&serial->read_fds); diff --git a/channels/server/CMakeLists.txt b/channels/server/CMakeLists.txt index 5e248110d..fbe33d668 100644 --- a/channels/server/CMakeLists.txt +++ b/channels/server/CMakeLists.txt @@ -35,7 +35,7 @@ set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVER set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS MONOLITHIC ${MONOLITHIC_BUILD} MODULE freerdp - MODULES freerdp-utils) + MODULES freerdp-codec freerdp-utils) set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS MONOLITHIC ${MONOLITHIC_BUILD} diff --git a/client/Mac/MRDPView.m b/client/Mac/MRDPView.m index dcc36e93e..f9307e5de 100644 --- a/client/Mac/MRDPView.m +++ b/client/Mac/MRDPView.m @@ -2159,9 +2159,8 @@ void mac_process_rail_exec_result_event(rdpChannels* channels, RDP_EVENT* event) void mac_process_rail_server_minmaxinfo_event(rdpChannels* channels, RDP_EVENT* event) { - RAIL_MINMAXINFO_ORDER * minmax = (RAIL_MINMAXINFO_ORDER*) event->user_data; - #if 0 + RAIL_MINMAXINFO_ORDER * minmax = (RAIL_MINMAXINFO_ORDER*) event->user_data; printf("minmax_info: maxPosX=%d maxPosY=%d maxWidth=%d maxHeight=%d minTrackWidth=%d minTrackHeight=%d maxTrackWidth=%d maxTrackHeight=%d\n", minmax->maxPosX, minmax->maxPosY, minmax->maxWidth, minmax->maxHeight, minmax->minTrackWidth, minmax->minTrackHeight, minmax->maxTrackWidth, minmax->maxTrackHeight); @@ -2225,9 +2224,6 @@ void mac_process_rail_server_localmovesize_event(freerdp *inst, RDP_EVENT *event [g_mrdpview->currentWindow view]->isMoveSizeInProgress = NO; [g_mrdpview->currentWindow view]->saveInitialDragLoc = NO; - //NSRect rect = [[g_mrdpview->currentWindow view] frame]; - NSRect rect = [[[g_mrdpview->currentWindow view] window] frame]; - // let RDP server know where this window is located mac_send_rail_client_event(inst->context->channels, RDP_EVENT_TYPE_RAIL_CLIENT_WINDOW_MOVE, &windowMove); diff --git a/libfreerdp/locale/keyboard_keymap.c b/libfreerdp/locale/keyboard_keymap.c index 18e9ecf96..af4d6f294 100644 --- a/libfreerdp/locale/keyboard_keymap.c +++ b/libfreerdp/locale/keyboard_keymap.c @@ -27,6 +27,8 @@ #include #include +#include + #include #include #include @@ -128,7 +130,7 @@ int freerdp_keyboard_load_map(UINT32 keycode_to_vkcode[256], char* name) keycode = atoi(keycode_string); /* Make sure it is a valid keycode */ - if (keycode < 0 || keycode > 255) + if (keycode > 255) break; /* Load this key mapping in the keyboard mapping */ @@ -185,7 +187,7 @@ void freerdp_keyboard_load_maps(UINT32 keycode_to_vkcode[256], char* names) char* names_end; int keymap_loaded = 0; - memset(keycode_to_vkcode, 0, sizeof(keycode_to_vkcode)); + ZeroMemory(keycode_to_vkcode, sizeof(UINT32) * 256); kbd = names; names_end = names + strlen(names); diff --git a/libfreerdp/locale/keyboard_x11.c b/libfreerdp/locale/keyboard_x11.c index d432f31ff..a4030946e 100644 --- a/libfreerdp/locale/keyboard_x11.c +++ b/libfreerdp/locale/keyboard_x11.c @@ -481,7 +481,7 @@ UINT32 freerdp_keyboard_init_x11(UINT32 keyboardLayoutId, RDP_SCANCODE x11_keyco UINT32 keycode_to_vkcode[256]; ZeroMemory(keycode_to_vkcode, sizeof(keycode_to_vkcode)); - ZeroMemory(x11_keycode_to_rdp_scancode, sizeof(x11_keycode_to_rdp_scancode)); + ZeroMemory(x11_keycode_to_rdp_scancode, sizeof(RDP_SCANCODE) * 256); #ifdef __APPLE__ /* Apple X11 breaks XKB detection */ diff --git a/libfreerdp/utils/CMakeLists.txt b/libfreerdp/utils/CMakeLists.txt index 73b37e78a..55b3b7e46 100644 --- a/libfreerdp/utils/CMakeLists.txt +++ b/libfreerdp/utils/CMakeLists.txt @@ -62,7 +62,7 @@ endif() set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS MONOLITHIC ${MONOLITHIC_BUILD} MODULE winpr - MODULES winpr-crt winpr-synch winpr-thread) + MODULES winpr-crt winpr-synch winpr-thread winpr-utils) if(MONOLITHIC_BUILD) set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) diff --git a/winpr/libwinpr/sysinfo/CMakeLists.txt b/winpr/libwinpr/sysinfo/CMakeLists.txt index 4ba8c6760..a331f6df3 100644 --- a/winpr/libwinpr/sysinfo/CMakeLists.txt +++ b/winpr/libwinpr/sysinfo/CMakeLists.txt @@ -31,7 +31,7 @@ add_complex_library(MODULE ${MODULE_NAME} TYPE "OBJECT" set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") -if(NOT WIN32) +if((NOT WIN32) AND (NOT APPLE)) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} rt) endif() diff --git a/winpr/libwinpr/utils/collections/CountdownEvent.c b/winpr/libwinpr/utils/collections/CountdownEvent.c index 0e9df2b35..787c7e31b 100644 --- a/winpr/libwinpr/utils/collections/CountdownEvent.c +++ b/winpr/libwinpr/utils/collections/CountdownEvent.c @@ -116,13 +116,10 @@ BOOL CountdownEvent_Signal(wCountdownEvent* countdown, DWORD signalCount) if (WaitForSingleObject(countdown->event, 0) == WAIT_OBJECT_0) oldStatus = TRUE; - countdown->count -= signalCount; - - if (countdown->count < 0) - { - printf("CountdownEvent_Signal warning: count is less than zero\n"); + if (signalCount <= countdown->count) + countdown->count -= signalCount; + else countdown->count = 0; - } if (countdown->count == 0) newStatus = TRUE; From e10367ac9e6b878eab32c3184a714a2260a6166c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 21 Feb 2013 21:42:47 -0500 Subject: [PATCH 2/6] mfreerdp: fix indentation --- client/Mac/AppDelegate.h | 1 - client/Mac/AppDelegate.m | 2 +- client/Mac/MRDPCursor.h | 10 +- client/Mac/MRDPRailView.h | 57 +- client/Mac/MRDPRailView.m | 1300 +++++++------- client/Mac/MRDPRailWindow.m | 2 +- client/Mac/MRDPView.h | 116 +- client/Mac/MRDPView.m | 3238 +++++++++++++++++------------------ 8 files changed, 2311 insertions(+), 2415 deletions(-) diff --git a/client/Mac/AppDelegate.h b/client/Mac/AppDelegate.h index d868d1564..56dcd53dc 100644 --- a/client/Mac/AppDelegate.h +++ b/client/Mac/AppDelegate.h @@ -14,6 +14,5 @@ @property (assign) IBOutlet MRDPView *mrdpView; @property (assign) IBOutlet NSWindow *window; - int rdp_connect(void); @end diff --git a/client/Mac/AppDelegate.m b/client/Mac/AppDelegate.m index 755f02de6..3918d4ac4 100644 --- a/client/Mac/AppDelegate.m +++ b/client/Mac/AppDelegate.m @@ -21,7 +21,7 @@ - (void) applicationWillTerminate:(NSNotification *)notification { - //[mrdpView releaseResources]; + //[mrdpView releaseResources]; } @end diff --git a/client/Mac/MRDPCursor.h b/client/Mac/MRDPCursor.h index 6fd2cd580..5368e0df7 100644 --- a/client/Mac/MRDPCursor.h +++ b/client/Mac/MRDPCursor.h @@ -13,11 +13,11 @@ @interface MRDPCursor : NSObject { @public - rdpPointer *pointer; - BYTE *cursor_data; // bitmapped pixel data - NSBitmapImageRep *bmiRep; - NSCursor *nsCursor; - NSImage *nsImage; + rdpPointer *pointer; + BYTE *cursor_data; // bitmapped pixel data + NSBitmapImageRep *bmiRep; + NSCursor *nsCursor; + NSImage *nsImage; } @end diff --git a/client/Mac/MRDPRailView.h b/client/Mac/MRDPRailView.h index 0a6c56218..c242054bf 100644 --- a/client/Mac/MRDPRailView.h +++ b/client/Mac/MRDPRailView.h @@ -7,35 +7,34 @@ @interface MRDPRailView : NSView { - freerdp* rdp_instance; - rdpContext* context; - NSBitmapImageRep* bmiRep; - NSPoint savedDragLocation; - char* pixelData; - BOOL mouseInClientArea; - BOOL titleBarClicked; - BOOL gestureEventInProgress; - int width; - int height; - int savedWindowId; - int scrollWheelCount; - - /* 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 - BOOL isMoveSizeInProgress; - BOOL saveInitialDragLoc; - BOOL skipMoveWindowOnce; - int localMoveType; + freerdp* rdp_instance; + rdpContext* context; + NSBitmapImageRep* bmiRep; + NSPoint savedDragLocation; + char* pixelData; + BOOL mouseInClientArea; + BOOL titleBarClicked; + BOOL gestureEventInProgress; + int width; + int height; + int savedWindowId; + int scrollWheelCount; + + int kdlshift; + int kdrshift; + int kdlctrl; + int kdrctrl; + int kdlalt; + int kdralt; + int kdlmeta; + int kdrmeta; + int kdcapslock; + +@public + BOOL isMoveSizeInProgress; + BOOL saveInitialDragLoc; + BOOL skipMoveWindowOnce; + int localMoveType; } @property (assign) MRDPRailWindow* mrdpRailWindow; diff --git a/client/Mac/MRDPRailView.m b/client/Mac/MRDPRailView.m index c8510cc5e..699a49058 100644 --- a/client/Mac/MRDPRailView.m +++ b/client/Mac/MRDPRailView.m @@ -10,70 +10,70 @@ MRDPRailView * g_mrdpRailView; struct kkey { - int key_code; - int flags; + int key_code; + int flags; }; extern struct kkey g_keys[]; - (void) updateDisplay { - BOOL moveWindow = NO; - 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; - } - - if (destRectOuter.size.height > screenSize.size.height) { - destRectOuter.size.height = screenSize.size.height; - moveWindow = YES; - } - - if (destRectOuter.origin.x + destRectOuter.size.width > width) - destRectOuter.size.width = width - destRectOuter.origin.x; - - [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); - } - - destRectOuter.origin.y = height - destRectOuter.origin.y - destRectOuter.size.height; - rail_convert_color_space(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; + BOOL moveWindow = NO; + 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; + } + + if (destRectOuter.size.height > screenSize.size.height) { + destRectOuter.size.height = screenSize.size.height; + moveWindow = YES; + } + + if (destRectOuter.origin.x + destRectOuter.size.width > width) + destRectOuter.size.width = width - destRectOuter.origin.x; + + [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); + } + + destRectOuter.origin.y = height - destRectOuter.origin.y - destRectOuter.size.height; + rail_convert_color_space(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; } /** ********************************************************************* @@ -82,37 +82,37 @@ extern struct kkey g_keys[]; - (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; + [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; +- (BOOL)acceptsFirstResponder +{ + return YES; } - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent { - return NO; + return NO; } /** ********************************************************************* * called when a mouse move event occurs - * + * * 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. + * 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 @@ -120,18 +120,18 @@ extern struct kkey g_keys[]; - (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); + [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); } /** ********************************************************************* @@ -140,25 +140,25 @@ extern struct kkey g_keys[]; - (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); - int yPos = (int) (winFrame.size.height - loc.y); - - y = height - y; - - if ((yPos >= 4) && (yPos <= 20)) - titleBarClicked = YES; - else - titleBarClicked = NO; - - savedDragLocation.x = loc.x; - savedDragLocation.y = loc.y; - - rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1, x, y); + [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); + int yPos = (int) (winFrame.size.height - loc.y); + + y = height - y; + + if ((yPos >= 4) && (yPos <= 20)) + titleBarClicked = YES; + else + titleBarClicked = NO; + + savedDragLocation.x = loc.x; + savedDragLocation.y = loc.y; + + rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1, x, y); } /** ********************************************************************* @@ -167,16 +167,16 @@ extern struct kkey g_keys[]; - (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); - titleBarClicked = NO; + [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); + titleBarClicked = NO; } /** ********************************************************************* @@ -185,15 +185,15 @@ extern struct kkey g_keys[]; - (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); + [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); } /** ********************************************************************* @@ -202,15 +202,15 @@ extern struct kkey g_keys[]; - (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); + [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); } /** ********************************************************************* @@ -219,15 +219,15 @@ extern struct kkey g_keys[]; - (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); + [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); } /** ********************************************************************* @@ -236,40 +236,40 @@ extern struct kkey g_keys[]; - (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); + [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]; - - // we get more two finger trackpad scroll events - // than scrollWheel events, so we drop some - - if (gestureEventInProgress) { - scrollWheelCount++; - if (scrollWheelCount % 8 != 0) - return; - } - - if ([event scrollingDeltaY] < 0) { - flags = PTR_FLAGS_WHEEL | PTR_FLAGS_WHEEL_NEGATIVE | 0x0088; - } - else { - flags = PTR_FLAGS_WHEEL | 0x78; - } - - rdp_instance->input->MouseEvent(rdp_instance->input, flags, 0, 0); + uint16 flags; + + [super scrollWheel:event]; + + // we get more two finger trackpad scroll events + // than scrollWheel events, so we drop some + + if (gestureEventInProgress) { + scrollWheelCount++; + if (scrollWheelCount % 8 != 0) + return; + } + + if ([event scrollingDeltaY] < 0) { + flags = PTR_FLAGS_WHEEL | PTR_FLAGS_WHEEL_NEGATIVE | 0x0088; + } + else { + flags = PTR_FLAGS_WHEEL | 0x78; + } + + rdp_instance->input->MouseEvent(rdp_instance->input, flags, 0, 0); } /** ********************************************************************* @@ -278,204 +278,204 @@ extern struct kkey g_keys[]; ***********************************************************************/ - (void) mouseDragged:(NSEvent *)event { - [super mouseDragged:event]; - - NSRect winFrame = [[self window] frame]; - NSPoint loc = [event locationInWindow]; - int x = (int) loc.x; - int y = (int) loc.y; - - if (titleBarClicked) { - // window is being dragged to a new location - int newX = x - savedDragLocation.x; - int newY = y - savedDragLocation.y; - - if ((newX == 0) && (newY == 0)) - return; - - winFrame.origin.x += newX; - winFrame.origin.y += newY; - - [[self window] setFrame:winFrame display:YES]; - return; - } - - if (localMoveType == RAIL_WMSZ_LEFT) { - // left border resize taking place - int diff = (int) (loc.x - savedDragLocation.x); - if (diff == 0) - return; - - if (diff < 0) { - diff = abs(diff); - winFrame.origin.x -= diff; - winFrame.size.width += diff; - } - else { - winFrame.origin.x += diff; - winFrame.size.width -= diff; - } - - [[self window] setFrame:winFrame display:YES]; - return; - } - - if (localMoveType == RAIL_WMSZ_RIGHT) { - // right border resize taking place - int diff = (int) (loc.x - savedDragLocation.x); - if (diff == 0) - return; - - savedDragLocation.x = loc.x; - savedDragLocation.y = loc.y; - - winFrame.size.width += diff; - [[self window] setFrame:winFrame display:YES]; - return; - } - - if (localMoveType == RAIL_WMSZ_TOP) { - // top border resize taking place - int diff = (int) (loc.y - savedDragLocation.y); - if (diff == 0) - return; - - savedDragLocation.x = loc.x; - savedDragLocation.y = loc.y; - - winFrame.size.height += diff; - [[self window] setFrame:winFrame display:YES]; - return; - } - - if (localMoveType == RAIL_WMSZ_BOTTOM) { - // bottom border resize taking place - int diff = (int) (loc.y - savedDragLocation.y); - if (diff == 0) - return; - - if (diff < 0) { - diff = abs(diff); - winFrame.origin.y -= diff; - winFrame.size.height += diff; - } - else { - winFrame.origin.y += diff; - winFrame.size.height -= diff; - } - - [[self window] setFrame:winFrame display:YES]; - return; - } - - if (localMoveType == RAIL_WMSZ_TOPLEFT) { - // top left border resize taking place - int diff = (int) (loc.x - savedDragLocation.x); - if (diff != 0) { - if (diff < 0) { - diff = abs(diff); - winFrame.origin.x -= diff; - winFrame.size.width += diff; - } - else { - winFrame.origin.x += diff; - winFrame.size.width -= diff; - } - } - - diff = (int) (loc.y - savedDragLocation.y); - if (diff != 0) { - savedDragLocation.y = loc.y; - winFrame.size.height += diff; - } - - [[self window] setFrame:winFrame display:YES]; - return; - } - - if (localMoveType == RAIL_WMSZ_TOPRIGHT) { - // top right border resize taking place - int diff = (int) (loc.x - savedDragLocation.x); - if (diff != 0) { - winFrame.size.width += diff; - } - - diff = (int) (loc.y - savedDragLocation.y); - if (diff != 0) { - winFrame.size.height += diff; - } - - savedDragLocation.x = loc.x; - savedDragLocation.y = loc.y; - - [[self window] setFrame:winFrame display:YES]; - return; - } - - if (localMoveType == RAIL_WMSZ_BOTTOMLEFT) { - // bottom left border resize taking place - int diff = (int) (loc.x - savedDragLocation.x); - if (diff != 0) { - if (diff < 0) { - diff = abs(diff); - winFrame.origin.x -= diff; - winFrame.size.width += diff; - } - else { - winFrame.origin.x += diff; - winFrame.size.width -= diff; - } - } - - diff = (int) (loc.y - savedDragLocation.y); - if (diff != 0) { - if (diff < 0) { - diff = abs(diff); - winFrame.origin.y -= diff; - winFrame.size.height += diff; - } - else { - winFrame.origin.y += diff; - winFrame.size.height -= diff; - } - } - - [[self window] setFrame:winFrame display:YES]; - return; - } - - if (localMoveType == RAIL_WMSZ_BOTTOMRIGHT) { - // bottom right border resize taking place - int diff = (int) (loc.x - savedDragLocation.x); - if (diff != 0) { - savedDragLocation.x = loc.x; - //savedDragLocation.y = loc.y; - winFrame.size.width += diff; - } - - diff = (int) (loc.y - savedDragLocation.y); - if (diff != 0) { - if (diff < 0) { - diff = abs(diff); - winFrame.origin.y -= diff; - winFrame.size.height += diff; - } - else { - winFrame.origin.y += diff; - winFrame.size.height -= diff; - } - } - - [[self window] setFrame:winFrame display:YES]; - return; - } - - 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); + [super mouseDragged:event]; + + NSRect winFrame = [[self window] frame]; + NSPoint loc = [event locationInWindow]; + int x = (int) loc.x; + int y = (int) loc.y; + + if (titleBarClicked) { + // window is being dragged to a new location + int newX = x - savedDragLocation.x; + int newY = y - savedDragLocation.y; + + if ((newX == 0) && (newY == 0)) + return; + + winFrame.origin.x += newX; + winFrame.origin.y += newY; + + [[self window] setFrame:winFrame display:YES]; + return; + } + + if (localMoveType == RAIL_WMSZ_LEFT) { + // left border resize taking place + int diff = (int) (loc.x - savedDragLocation.x); + if (diff == 0) + return; + + if (diff < 0) { + diff = abs(diff); + winFrame.origin.x -= diff; + winFrame.size.width += diff; + } + else { + winFrame.origin.x += diff; + winFrame.size.width -= diff; + } + + [[self window] setFrame:winFrame display:YES]; + return; + } + + if (localMoveType == RAIL_WMSZ_RIGHT) { + // right border resize taking place + int diff = (int) (loc.x - savedDragLocation.x); + if (diff == 0) + return; + + savedDragLocation.x = loc.x; + savedDragLocation.y = loc.y; + + winFrame.size.width += diff; + [[self window] setFrame:winFrame display:YES]; + return; + } + + if (localMoveType == RAIL_WMSZ_TOP) { + // top border resize taking place + int diff = (int) (loc.y - savedDragLocation.y); + if (diff == 0) + return; + + savedDragLocation.x = loc.x; + savedDragLocation.y = loc.y; + + winFrame.size.height += diff; + [[self window] setFrame:winFrame display:YES]; + return; + } + + if (localMoveType == RAIL_WMSZ_BOTTOM) { + // bottom border resize taking place + int diff = (int) (loc.y - savedDragLocation.y); + if (diff == 0) + return; + + if (diff < 0) { + diff = abs(diff); + winFrame.origin.y -= diff; + winFrame.size.height += diff; + } + else { + winFrame.origin.y += diff; + winFrame.size.height -= diff; + } + + [[self window] setFrame:winFrame display:YES]; + return; + } + + if (localMoveType == RAIL_WMSZ_TOPLEFT) { + // top left border resize taking place + int diff = (int) (loc.x - savedDragLocation.x); + if (diff != 0) { + if (diff < 0) { + diff = abs(diff); + winFrame.origin.x -= diff; + winFrame.size.width += diff; + } + else { + winFrame.origin.x += diff; + winFrame.size.width -= diff; + } + } + + diff = (int) (loc.y - savedDragLocation.y); + if (diff != 0) { + savedDragLocation.y = loc.y; + winFrame.size.height += diff; + } + + [[self window] setFrame:winFrame display:YES]; + return; + } + + if (localMoveType == RAIL_WMSZ_TOPRIGHT) { + // top right border resize taking place + int diff = (int) (loc.x - savedDragLocation.x); + if (diff != 0) { + winFrame.size.width += diff; + } + + diff = (int) (loc.y - savedDragLocation.y); + if (diff != 0) { + winFrame.size.height += diff; + } + + savedDragLocation.x = loc.x; + savedDragLocation.y = loc.y; + + [[self window] setFrame:winFrame display:YES]; + return; + } + + if (localMoveType == RAIL_WMSZ_BOTTOMLEFT) { + // bottom left border resize taking place + int diff = (int) (loc.x - savedDragLocation.x); + if (diff != 0) { + if (diff < 0) { + diff = abs(diff); + winFrame.origin.x -= diff; + winFrame.size.width += diff; + } + else { + winFrame.origin.x += diff; + winFrame.size.width -= diff; + } + } + + diff = (int) (loc.y - savedDragLocation.y); + if (diff != 0) { + if (diff < 0) { + diff = abs(diff); + winFrame.origin.y -= diff; + winFrame.size.height += diff; + } + else { + winFrame.origin.y += diff; + winFrame.size.height -= diff; + } + } + + [[self window] setFrame:winFrame display:YES]; + return; + } + + if (localMoveType == RAIL_WMSZ_BOTTOMRIGHT) { + // bottom right border resize taking place + int diff = (int) (loc.x - savedDragLocation.x); + if (diff != 0) { + savedDragLocation.x = loc.x; + //savedDragLocation.y = loc.y; + winFrame.size.width += diff; + } + + diff = (int) (loc.y - savedDragLocation.y); + if (diff != 0) { + if (diff < 0) { + diff = abs(diff); + winFrame.origin.y -= diff; + winFrame.size.height += diff; + } + else { + winFrame.origin.y += diff; + winFrame.size.height -= diff; + } + } + + [[self window] setFrame:winFrame display:YES]; + return; + } + + 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); } /** ********************************************************************* @@ -484,10 +484,10 @@ extern struct kkey g_keys[]; - (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); + int key; + + key = [event keyCode]; + rdp_instance->input->KeyboardEvent(rdp_instance->input, g_keys[key].flags | KBD_FLAGS_DOWN, g_keys[key].key_code); } /** ********************************************************************* @@ -496,10 +496,10 @@ extern struct kkey g_keys[]; - (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); + int key; + + key = [event keyCode]; + rdp_instance->input->KeyboardEvent(rdp_instance->input, g_keys[key].flags | KBD_FLAGS_RELEASE, g_keys[key].key_code); } /** ********************************************************************* @@ -508,179 +508,179 @@ extern struct kkey g_keys[]; - (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; - } + 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]; - [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]; + 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]; + [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 { - 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]; + 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) beginGestureWithEvent:(NSEvent *)event { - gestureEventInProgress = YES; + gestureEventInProgress = YES; } - (void) endGestureWithEvent:(NSEvent *)event { - gestureEventInProgress = NO; + gestureEventInProgress = NO; } /** @@ -689,20 +689,20 @@ extern struct kkey g_keys[]; - (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); + // 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); } /** @@ -711,20 +711,20 @@ extern struct kkey g_keys[]; - (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); + // 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); } /** @@ -733,24 +733,24 @@ extern struct kkey g_keys[]; - (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]) + // 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); // ? code mis-merge? + + // set_current_window(windowIndex); // ? code mis-merge? } - (void) releaseResources { - [[NSNotificationCenter defaultCenter] removeObserver:self]; + [[NSNotificationCenter defaultCenter] removeObserver:self]; } void rail_cvt_from_rect(char *dest, char *src, NSRect destRect, int destWidth, int destHeight, NSRect srcRect) @@ -760,59 +760,59 @@ void rail_cvt_from_rect(char *dest, char *src, NSRect destRect, int destWidth, i /** ********************************************************************* * color space conversion used specifically in RAIL ***********************************************************************/ -void rail_convert_color_space(char *destBuf, char * srcBuf, - NSRect * destRect, int width, int height) +void rail_convert_color_space(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 = (destRect->origin.y + destHeight > height) ? height - destRect->origin.y : destHeight; - pixelsPerRow = destWidth; - - srcX = destRect->origin.x; - srcY = destRect->origin.y; - destX = 0; - destY = 0; - - 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; + 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 = (destRect->origin.y + destHeight > height) ? height - destRect->origin.y : destHeight; + pixelsPerRow = destWidth; + + srcX = destRect->origin.x; + srcY = destRect->origin.y; + destX = 0; + destY = 0; + + 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; } /** @@ -821,35 +821,35 @@ void rail_convert_color_space(char *destBuf, char * srcBuf, 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]; + 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]; } 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); + 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 diff --git a/client/Mac/MRDPRailWindow.m b/client/Mac/MRDPRailWindow.m index 9cab180f4..9db211364 100644 --- a/client/Mac/MRDPRailWindow.m +++ b/client/Mac/MRDPRailWindow.m @@ -12,7 +12,7 @@ - (BOOL) canBecomeKeyWindow { - return YES; + return YES; } @end diff --git a/client/Mac/MRDPView.h b/client/Mac/MRDPView.h index 4efdb970f..d2c2f7b83 100644 --- a/client/Mac/MRDPView.h +++ b/client/Mac/MRDPView.h @@ -24,52 +24,52 @@ @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; - BOOL mouseInClientArea; - BOOL isRemoteApp; - BOOL firstCreateWindow; - BOOL isMoveSizeInProgress; - BOOL skipResizeOnce; - BOOL saveInitialDragLoc; - BOOL 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; - + 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; + BOOL mouseInClientArea; + BOOL isRemoteApp; + BOOL firstCreateWindow; + BOOL isMoveSizeInProgress; + BOOL skipResizeOnce; + BOOL saveInitialDragLoc; + BOOL 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 + 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) rdpConnectError; @@ -147,30 +147,30 @@ void apple_to_windowMove(NSRect * r, RAIL_WINDOW_MOVE_ORDER * windowMove); struct mac_context { - // *must* have this - do not delete - rdpContext _p; + // *must* have this - do not delete + rdpContext _p; }; struct cursor { - rdpPointer *pointer; - BYTE *cursor_data; // bitmapped pixel data - void *bmiRep; // NSBitmapImageRep - void *nsCursor; // NSCursor - void *nsImage; // NSImage + rdpPointer *pointer; + BYTE *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; + char red; + char green; + char blue; + char alpha; }; struct kkey { - int key_code; - int flags; + int key_code; + int flags; }; diff --git a/client/Mac/MRDPView.m b/client/Mac/MRDPView.m index f9307e5de..859e6d9dd 100644 --- a/client/Mac/MRDPView.m +++ b/client/Mac/MRDPView.m @@ -18,25 +18,23 @@ * - all funcs same as above * - PolygonSc seems to create a transparent rect * - ensure mouse cursor changes are working ok after moving to NSTracking area - * - RAIL: - * - - * - + * - RAIL: + * - + * - * - tool tips to be correctly positioned * - dragging is slightly of * - resize after dragging not working * - dragging app from macbook to monitor gives exec/access err * - unable to drag rect out of monitor boundaries - * - - * - - * - + * - + * - + * - */ - + #import "MRDPView.h" #import "MRDPCursor.h" -#define RUN_IN_XCODE - -// LK_TODO +// LK_TODO #define GOT_HERE //printf("### got here: %s : %s() : %d\n", __FILE__, __func__, __LINE__) // RAIL_TODO DELETE WHEN DONE TESTING @@ -53,178 +51,178 @@ void convert_color_space(char *dest, char *src, NSRect* drawRect, int width, int const char* error_code_names[] = { - "RAIL_EXEC_S_OK", - "RAIL_EXEC_E_HOOK_NOT_LOADED", - "RAIL_EXEC_E_DECODE_FAILED", - "RAIL_EXEC_E_NOT_IN_ALLOWLIST", - "RAIL_EXEC_E_FILE_NOT_FOUND", - "RAIL_EXEC_E_FAIL", - "RAIL_EXEC_E_SESSION_LOCKED" + "RAIL_EXEC_S_OK", + "RAIL_EXEC_E_HOOK_NOT_LOADED", + "RAIL_EXEC_E_DECODE_FAILED", + "RAIL_EXEC_E_NOT_IN_ALLOWLIST", + "RAIL_EXEC_E_FILE_NOT_FOUND", + "RAIL_EXEC_E_FAIL", + "RAIL_EXEC_E_SESSION_LOCKED" }; struct kkey g_keys[256] = { - { 0x1e, 0 }, // a 0 - { 0x1f, 0 }, // s - { 0x20, 0 }, // d - { 0x21, 0 }, // f - { 0x23, 0 }, // h - { 0x22, 0 }, // g - { 0x2c, 0 }, // z - { 0x2d, 0 }, // x - { 0x2e, 0 }, // c - { 0x2f, 0 }, // v - { 0x00, 0 }, // 10 - { 0x30, 0 }, // b - { 0x10, 0 }, // q - { 0x11, 0 }, // w - { 0x12, 0 }, // e - { 0x13, 0 }, // r - { 0x15, 0 }, // y - { 0x14, 0 }, // t - { 0x02, 0 }, // 1 - { 0x03, 0 }, // 2 - { 0x04, 0 }, // 3 20 - { 0x05, 0 }, // 4 - { 0x07, 0 }, // 6 - { 0x06, 0 }, // 5 - { 0x0d, 0 }, // = or + - { 0x0a, 0 }, // 9 - { 0x08, 0 }, // 7 - { 0x0c, 0 }, // - or _ - { 0x09, 0 }, // 8 - { 0x0b, 0 }, // 0 - { 0x1b, 0 }, // ] or } 30 - { 0x18, 0 }, // o - { 0x16, 0 }, // u - { 0x1a, 0 }, // [ or { - { 0x17, 0 }, // i - { 0x19, 0 }, // p - { 0x1c, 0 }, // enter - { 0x26, 0 }, // l - { 0x24, 0 }, // j - { 0x28, 0 }, // ' or " - { 0x25, 0 }, // k 40 - { 0x27, 0 }, // ; or : - { 0x2b, 0 }, // \ or | - { 0x33, 0 }, // , or < - { 0x35, 0 }, // / or ? - { 0x31, 0 }, // n - { 0x32, 0 }, // m - { 0x34, 0 }, // . or > - { 0x0f, 0 }, // tab - { 0x39, 0 }, // space - { 0x29, 0 }, // ` or ~ 50 - { 0x0e, 0 }, // backspace - { 0x00, 0 }, // - { 0x01, 0 }, // esc - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, // 60 - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x53, 0 }, // KP. - { 0x00, 0 }, - { 0x37, 0 }, // KP* - { 0x00, 0 }, - { 0x4e, 0 }, // KP+ - { 0x00, 0 }, // 70 - { 0x45, 0 }, // num lock - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x35, 1 }, // KP/ - { 0x1c, 1 }, // KPEnter - { 0x00, 0 }, - { 0x4a, 0 }, // KP- - { 0x00, 0 }, - { 0x00, 0 }, // 80 - { 0x00, 0 }, - { 0x52, 0 }, // KP0 - { 0x4f, 0 }, // KP1 - { 0x50, 0 }, // KP2 - { 0x51, 0 }, // KP3 - { 0x4b, 0 }, // KP4 - { 0x4c, 0 }, // KP5 - { 0x4d, 0 }, // KP6 - { 0x47, 0 }, // KP7 - { 0x00, 0 }, // 90 - { 0x48, 0 }, // KP8 - { 0x49, 0 }, // KP9 - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, // 100 - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x5d, 1 }, // menu 110 - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x52, 1 }, // Insert - { 0x47, 1 }, // Home - { 0x49, 1 }, // PgUp - { 0x53, 1 }, // Delete - { 0x00, 0 }, - { 0x4f, 1 }, // End - { 0x00, 0 }, // 120 - { 0x51, 1 }, // PgDown - { 0x3b, 0 }, // f1 - { 0x4b, 1 }, // left - { 0x4d, 1 }, // right - { 0x50, 1 }, // down - { 0x48, 1 }, // up - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, - { 0x00, 0 }, + { 0x1e, 0 }, // a 0 + { 0x1f, 0 }, // s + { 0x20, 0 }, // d + { 0x21, 0 }, // f + { 0x23, 0 }, // h + { 0x22, 0 }, // g + { 0x2c, 0 }, // z + { 0x2d, 0 }, // x + { 0x2e, 0 }, // c + { 0x2f, 0 }, // v + { 0x00, 0 }, // 10 + { 0x30, 0 }, // b + { 0x10, 0 }, // q + { 0x11, 0 }, // w + { 0x12, 0 }, // e + { 0x13, 0 }, // r + { 0x15, 0 }, // y + { 0x14, 0 }, // t + { 0x02, 0 }, // 1 + { 0x03, 0 }, // 2 + { 0x04, 0 }, // 3 20 + { 0x05, 0 }, // 4 + { 0x07, 0 }, // 6 + { 0x06, 0 }, // 5 + { 0x0d, 0 }, // = or + + { 0x0a, 0 }, // 9 + { 0x08, 0 }, // 7 + { 0x0c, 0 }, // - or _ + { 0x09, 0 }, // 8 + { 0x0b, 0 }, // 0 + { 0x1b, 0 }, // ] or } 30 + { 0x18, 0 }, // o + { 0x16, 0 }, // u + { 0x1a, 0 }, // [ or { + { 0x17, 0 }, // i + { 0x19, 0 }, // p + { 0x1c, 0 }, // enter + { 0x26, 0 }, // l + { 0x24, 0 }, // j + { 0x28, 0 }, // ' or " + { 0x25, 0 }, // k 40 + { 0x27, 0 }, // ; or : + { 0x2b, 0 }, // \ or | + { 0x33, 0 }, // , or < + { 0x35, 0 }, // / or ? + { 0x31, 0 }, // n + { 0x32, 0 }, // m + { 0x34, 0 }, // . or > + { 0x0f, 0 }, // tab + { 0x39, 0 }, // space + { 0x29, 0 }, // ` or ~ 50 + { 0x0e, 0 }, // backspace + { 0x00, 0 }, // + { 0x01, 0 }, // esc + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, // 60 + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x53, 0 }, // KP. + { 0x00, 0 }, + { 0x37, 0 }, // KP* + { 0x00, 0 }, + { 0x4e, 0 }, // KP+ + { 0x00, 0 }, // 70 + { 0x45, 0 }, // num lock + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x35, 1 }, // KP/ + { 0x1c, 1 }, // KPEnter + { 0x00, 0 }, + { 0x4a, 0 }, // KP- + { 0x00, 0 }, + { 0x00, 0 }, // 80 + { 0x00, 0 }, + { 0x52, 0 }, // KP0 + { 0x4f, 0 }, // KP1 + { 0x50, 0 }, // KP2 + { 0x51, 0 }, // KP3 + { 0x4b, 0 }, // KP4 + { 0x4c, 0 }, // KP5 + { 0x4d, 0 }, // KP6 + { 0x47, 0 }, // KP7 + { 0x00, 0 }, // 90 + { 0x48, 0 }, // KP8 + { 0x49, 0 }, // KP9 + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, // 100 + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x5d, 1 }, // menu 110 + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x52, 1 }, // Insert + { 0x47, 1 }, // Home + { 0x49, 1 }, // PgUp + { 0x53, 1 }, // Delete + { 0x00, 0 }, + { 0x4f, 1 }, // End + { 0x00, 0 }, // 120 + { 0x51, 1 }, // PgDown + { 0x3b, 0 }, // f1 + { 0x4b, 1 }, // left + { 0x4d, 1 }, // right + { 0x50, 1 }, // down + { 0x48, 1 }, // up + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, }; /************************************************************************ - methods we override -************************************************************************/ + methods we override + ************************************************************************/ /** ********************************************************************* * create MRDPView with specified rectangle @@ -232,12 +230,12 @@ struct kkey g_keys[256] = - (id)initWithFrame:(NSRect)frame { - self = [super initWithFrame:frame]; - if (self) { - // Initialization code here. - } - - return self; + self = [super initWithFrame:frame]; + if (self) { + // Initialization code here. + } + + return self; } /** ********************************************************************* @@ -246,80 +244,80 @@ struct kkey g_keys[256] = - (void) awakeFromNib { - g_mrdpview = self; - - // 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]; - - firstCreateWindow = TRUE; - skipResizeOnce = YES; - windows = [[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]; - - // windows in RemoteApp (RAIL) mode cannot have title bars - NSArray * args = [[NSProcessInfo processInfo] arguments]; - for (NSString * str in args) - { - if ([str compare:@"--app"] == NSOrderedSame) { - isRemoteApp = TRUE; - break; - } - } - - if (!isRemoteApp) - [self addTrackingArea:trackingArea]; - - mouseInClientArea = YES; + g_mrdpview = self; + + // 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]; + + firstCreateWindow = TRUE; + skipResizeOnce = YES; + windows = [[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]; + + // windows in RemoteApp (RAIL) mode cannot have title bars + NSArray * args = [[NSProcessInfo processInfo] arguments]; + for (NSString * str in args) + { + if ([str compare:@"--app"] == NSOrderedSame) { + isRemoteApp = TRUE; + break; + } + } + + if (!isRemoteApp) + [self addTrackingArea:trackingArea]; + + mouseInClientArea = YES; } /** ********************************************************************* * become first responder so we can get keyboard and mouse events ***********************************************************************/ -- (BOOL)acceptsFirstResponder -{ - return YES; +- (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. + * 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 + +- (void) mouseMoved:(NSEvent *)event { - [super mouseMoved:event]; - - if (!is_connected) - return; - - NSPoint loc = [event locationInWindow]; - int x = (int) loc.x; - int y = (int) loc.y; - - y = height - y; - - // send mouse motion event to RDP server - rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_MOVE, x, y); + [super mouseMoved:event]; + + if (!is_connected) + return; + + NSPoint loc = [event locationInWindow]; + int x = (int) loc.x; + int y = (int) loc.y; + + y = height - y; + + // send mouse motion event to RDP server + rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_MOVE, x, y); } /** ********************************************************************* @@ -328,18 +326,18 @@ struct kkey g_keys[256] = - (void)mouseDown:(NSEvent *) event { - [super mouseDown:event]; - - if (!is_connected) - return; - - NSPoint loc = [event locationInWindow]; - int x = (int) loc.x; - int y = (int) loc.y; - - y = height - y; - - rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1, x, y); + [super mouseDown:event]; + + if (!is_connected) + return; + + NSPoint loc = [event locationInWindow]; + int x = (int) loc.x; + int y = (int) loc.y; + + y = height - y; + + rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1, x, y); } /** ********************************************************************* @@ -348,18 +346,18 @@ struct kkey g_keys[256] = - (void) mouseUp:(NSEvent *) event { - [super mouseUp:event]; - - if (!is_connected) - return; - - NSPoint loc = [event locationInWindow]; - int x = (int) loc.x; - int y = (int) loc.y; - - y = height - y; - - rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_BUTTON1, x, y); + [super mouseUp:event]; + + if (!is_connected) + return; + + NSPoint loc = [event locationInWindow]; + int x = (int) loc.x; + int y = (int) loc.y; + + y = height - y; + + rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_BUTTON1, x, y); } /** ********************************************************************* @@ -368,18 +366,18 @@ struct kkey g_keys[256] = - (void) rightMouseDown:(NSEvent *)event { - [super rightMouseDown:event]; - - if (!is_connected) - return; - - NSPoint loc = [event locationInWindow]; - int x = (int) loc.x; - int y = (int) loc.y; - - y = height - y; - - rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON2, x, y); + [super rightMouseDown:event]; + + if (!is_connected) + return; + + NSPoint loc = [event locationInWindow]; + int x = (int) loc.x; + int y = (int) loc.y; + + y = height - y; + + rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON2, x, y); } /** ********************************************************************* @@ -388,18 +386,18 @@ struct kkey g_keys[256] = - (void) rightMouseUp:(NSEvent *)event { - [super rightMouseUp:event]; - - if (!is_connected) - return; - - NSPoint loc = [event locationInWindow]; - int x = (int) loc.x; - int y = (int) loc.y; - - y = height - y; - - rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_BUTTON2, x, y); + [super rightMouseUp:event]; + + if (!is_connected) + return; + + NSPoint loc = [event locationInWindow]; + int x = (int) loc.x; + int y = (int) loc.y; + + y = height - y; + + rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_BUTTON2, x, y); } /** ********************************************************************* @@ -408,18 +406,18 @@ struct kkey g_keys[256] = - (void) otherMouseDown:(NSEvent *)event { - [super otherMouseDown:event]; - - if (!is_connected) - return; - - NSPoint loc = [event locationInWindow]; - int x = (int) loc.x; - int y = (int) loc.y; - - y = height - y; - - rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON3, x, y); + [super otherMouseDown:event]; + + if (!is_connected) + return; + + NSPoint loc = [event locationInWindow]; + int x = (int) loc.x; + int y = (int) loc.y; + + y = height - y; + + rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON3, x, y); } /** ********************************************************************* @@ -428,45 +426,45 @@ struct kkey g_keys[256] = - (void) otherMouseUp:(NSEvent *)event { - [super otherMouseUp:event]; - - if (!is_connected) - return; - - NSPoint loc = [event locationInWindow]; - int x = (int) loc.x; - int y = (int) loc.y; - - y = height - y; - - rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_BUTTON3, x, y); + [super otherMouseUp:event]; + + if (!is_connected) + return; + + NSPoint loc = [event locationInWindow]; + int x = (int) loc.x; + int y = (int) 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]; - - if (!is_connected) - return; - - NSPoint loc = [event locationInWindow]; - int x = (int) loc.x; - int y = (int) 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); + uint16 flags; + + [super scrollWheel:event]; + + if (!is_connected) + return; + + NSPoint loc = [event locationInWindow]; + int x = (int) loc.x; + int y = (int) 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); } /** ********************************************************************* @@ -476,37 +474,37 @@ struct kkey g_keys[256] = - (void) mouseDragged:(NSEvent *)event { - [super mouseDragged:event]; - - if (!is_connected) - return; - - NSPoint loc = [event locationInWindow]; - int x = (int) loc.x; - int y = (int) loc.y; - - // RAIL_TODO delete this if not reqd - if ((isRemoteApp) && (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; - [[g_mrdpview window] setFrame:r display:YES]; - } - - y = height - y; - - // send mouse motion event to RDP server - rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_MOVE, x, y); + [super mouseDragged:event]; + + if (!is_connected) + return; + + NSPoint loc = [event locationInWindow]; + int x = (int) loc.x; + int y = (int) loc.y; + + // RAIL_TODO delete this if not reqd + if ((isRemoteApp) && (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; + [[g_mrdpview window] setFrame:r display:YES]; + } + + y = height - y; + + // send mouse motion event to RDP server + rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_MOVE, x, y); } /** ********************************************************************* @@ -515,14 +513,14 @@ struct kkey g_keys[256] = - (void) keyDown:(NSEvent *) event { - int key; - - if (!is_connected) { - return; - } - - key = [event keyCode]; - rdp_instance->input->KeyboardEvent(rdp_instance->input, g_keys[key].flags | KBD_FLAGS_DOWN, g_keys[key].key_code); + int key; + + if (!is_connected) { + return; + } + + key = [event keyCode]; + rdp_instance->input->KeyboardEvent(rdp_instance->input, g_keys[key].flags | KBD_FLAGS_DOWN, g_keys[key].key_code); } /** ********************************************************************* @@ -531,14 +529,14 @@ struct kkey g_keys[256] = - (void) keyUp:(NSEvent *) event { - int key; - - if (!is_connected) { - return; - } - - key = [event keyCode]; - rdp_instance->input->KeyboardEvent(rdp_instance->input, g_keys[key].flags | KBD_FLAGS_RELEASE, g_keys[key].key_code); + int key; + + if (!is_connected) { + return; + } + + key = [event keyCode]; + rdp_instance->input->KeyboardEvent(rdp_instance->input, g_keys[key].flags | KBD_FLAGS_RELEASE, g_keys[key].key_code); } /** ********************************************************************* @@ -547,147 +545,147 @@ struct kkey g_keys[256] = - (void) flagsChanged:(NSEvent *) event { - NSUInteger mf = [event modifierFlags]; - - if (!is_connected) { - return; - } - - // 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; - } + NSUInteger mf = [event modifierFlags]; + + if (!is_connected) { + return; + } + + // 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) releaseResources { - int i; - - for (i = 0; i < argc; i++) - { - if (argv[i]) - free(argv[i]); - } - - for (MRDPWindow * w in windows) - { - [w setWindow:nil]; - [w setView:nil]; - } - - if (!is_connected) - return; - - freerdp_channels_global_uninit(); - - if (pixel_data) - free(pixel_data); - - if (run_loop_src != 0) - CFRunLoopRemoveSource(CFRunLoopGetCurrent(), run_loop_src_channels, kCFRunLoopDefaultMode); - - if (run_loop_src != 0) - CFRunLoopRemoveSource(CFRunLoopGetCurrent(), run_loop_src, kCFRunLoopDefaultMode); + int i; + + for (i = 0; i < argc; i++) + { + if (argv[i]) + free(argv[i]); + } + + for (MRDPWindow * w in windows) + { + [w setWindow:nil]; + [w setView:nil]; + } + + if (!is_connected) + return; + + freerdp_channels_global_uninit(); + + if (pixel_data) + free(pixel_data); + + if (run_loop_src != 0) + CFRunLoopRemoveSource(CFRunLoopGetCurrent(), run_loop_src_channels, kCFRunLoopDefaultMode); + + if (run_loop_src != 0) + CFRunLoopRemoveSource(CFRunLoopGetCurrent(), run_loop_src, kCFRunLoopDefaultMode); } /** ********************************************************************* @@ -696,34 +694,34 @@ struct kkey g_keys[256] = - (void) drawRect:(NSRect)dirtyRect { - if (!rdp_context) - return; - - if (g_mrdpview->isRemoteApp && g_mrdpview->currentWindow) { - return; - } - - if (!bmiRep) { - pixel_data = (char *) malloc(width * height * sizeof(struct rgba_data)); - bmiRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:(unsigned char **) &pixel_data - pixelsWide:width - pixelsHigh:height - bitsPerSample:8 - samplesPerPixel:sizeof(struct rgba_data) - hasAlpha:YES - isPlanar:NO - colorSpaceName:NSDeviceRGBColorSpace - bitmapFormat:0 //NSAlphaFirstBitmapFormat - bytesPerRow:width * sizeof(struct rgba_data) - bitsPerPixel:0]; - } - - [bmiRep drawInRect:dirtyRect fromRect:dirtyRect operation:NSCompositeCopy fraction:1.0 respectFlipped:NO hints:nil]; + if (!rdp_context) + return; + + if (g_mrdpview->isRemoteApp && g_mrdpview->currentWindow) { + return; + } + + if (!bmiRep) { + pixel_data = (char *) malloc(width * height * sizeof(struct rgba_data)); + bmiRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:(unsigned char **) &pixel_data + pixelsWide:width + pixelsHigh:height + bitsPerSample:8 + samplesPerPixel:sizeof(struct rgba_data) + hasAlpha:YES + isPlanar:NO + colorSpaceName:NSDeviceRGBColorSpace + bitmapFormat:0 //NSAlphaFirstBitmapFormat + bytesPerRow:width * sizeof(struct rgba_data) + bitsPerPixel:0]; + } + + [bmiRep drawInRect:dirtyRect fromRect:dirtyRect operation:NSCompositeCopy fraction:1.0 respectFlipped:NO hints:nil]; } /************************************************************************ - instance methods -************************************************************************/ + instance methods + ************************************************************************/ /** ********************************************************************* * called when RDP server wants us to update a rect with new data @@ -731,55 +729,55 @@ struct kkey g_keys[256] = - (void) my_draw_rect:(void *)context { - int w; - int h; - - rdpContext * ctx = (rdpContext *) context; - - struct rgba_data - { - char red; - char green; - char blue; - char alpha; - }; - - if (isRemoteApp && currentWindow) { - NSRect vrect = [ [currentWindow view] frame]; - [[currentWindow view] setNeedsDisplayInRect:vrect]; - // actual drawing will be done in MRDPRailView:drawRect() - return; - } - - w = width; - h = height; - rect.origin.x = 0; - rect.origin.y = 0; - rect.size.width = w; - rect.size.height = h; - - if (!bmiRep) { - pixel_data = (char *) malloc(w * h * sizeof(struct rgba_data)); - bmiRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:(unsigned char **) &pixel_data - pixelsWide:w - pixelsHigh:h - bitsPerSample:8 - samplesPerPixel:sizeof(struct rgba_data) - hasAlpha:YES - isPlanar:NO - colorSpaceName:NSDeviceRGBColorSpace - bitmapFormat:0 //NSAlphaFirstBitmapFormat - bytesPerRow:w * sizeof(struct rgba_data) - bitsPerPixel:0]; - } - + int w; + int h; + + rdpContext * ctx = (rdpContext *) context; + + struct rgba_data + { + char red; + char green; + char blue; + char alpha; + }; + + if (isRemoteApp && currentWindow) { + NSRect vrect = [ [currentWindow view] frame]; + [[currentWindow view] setNeedsDisplayInRect:vrect]; + // actual drawing will be done in MRDPRailView:drawRect() + return; + } + + w = width; + h = height; + rect.origin.x = 0; + rect.origin.y = 0; + rect.size.width = w; + rect.size.height = h; + + if (!bmiRep) { + pixel_data = (char *) malloc(w * h * sizeof(struct rgba_data)); + bmiRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:(unsigned char **) &pixel_data + pixelsWide:w + pixelsHigh:h + bitsPerSample:8 + samplesPerPixel:sizeof(struct rgba_data) + hasAlpha:YES + isPlanar:NO + colorSpaceName:NSDeviceRGBColorSpace + bitmapFormat:0 //NSAlphaFirstBitmapFormat + bytesPerRow:w * sizeof(struct rgba_data) + bitsPerPixel:0]; + } + #ifdef MRDP_DRAW_INDIVIDUAL_RECTS - [self setNeedsDisplayInRect:rect]; - return; + [self setNeedsDisplayInRect:rect]; + return; #endif - - convert_color_space(pixel_data, (char *) ctx->gdi->primary_buffer, &rect, w, h); - [self setNeedsDisplayInRect:rect]; + + convert_color_space(pixel_data, (char *) ctx->gdi->primary_buffer, &rect, w, h); + [self setNeedsDisplayInRect:rect]; } /** ********************************************************************* @@ -788,8 +786,8 @@ struct kkey g_keys[256] = - (void) saveStateInfo:(freerdp *) instance:(rdpContext *) context { - rdp_instance = instance; - rdp_context = context; + rdp_instance = instance; + rdp_context = context; } /** ********************************************************************* @@ -798,36 +796,36 @@ struct kkey g_keys[256] = - (BOOL) eventIsInClientArea :(NSEvent *) event :(int *) xptr :(int *) yptr { - NSPoint loc = [event locationInWindow]; - int x = (int) loc.x; - int y = (int) loc.y; - - if ((x < 0) || (y < 0)) { - if (mouseInClientArea) { - // set default cursor before leaving client area - mouseInClientArea = NO; - NSCursor *cur = [NSCursor arrowCursor]; - [cur set]; - } - return NO; - } - if ((x > width) || (y > height)) { - if (mouseInClientArea) { - // set default cursor before leaving client area - mouseInClientArea = NO; - NSCursor *cur = [NSCursor arrowCursor]; - [cur set]; - } - return NO; - } - - // on Mac origin is at lower left, but we want it on upper left - y = height - y; - - *xptr = x; - *yptr = y; - mouseInClientArea = YES; - return YES; + NSPoint loc = [event locationInWindow]; + int x = (int) loc.x; + int y = (int) loc.y; + + if ((x < 0) || (y < 0)) { + if (mouseInClientArea) { + // set default cursor before leaving client area + mouseInClientArea = NO; + NSCursor *cur = [NSCursor arrowCursor]; + [cur set]; + } + return NO; + } + if ((x > width) || (y > height)) { + if (mouseInClientArea) { + // set default cursor before leaving client area + mouseInClientArea = NO; + NSCursor *cur = [NSCursor arrowCursor]; + [cur set]; + } + return NO; + } + + // on Mac origin is at lower left, but we want it on upper left + y = height - y; + + *xptr = x; + *yptr = y; + mouseInClientArea = YES; + return YES; } /** ********************************************************************* @@ -836,13 +834,13 @@ struct kkey g_keys[256] = - (void) rdpConnectError { - - NSAlert *alert = [[NSAlert alloc] init]; - [alert setMessageText:@"Error connecting to server"]; - [alert beginSheetModalForWindow:[g_mrdpview window] - modalDelegate:g_mrdpview - didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) - contextInfo:nil]; + + NSAlert *alert = [[NSAlert alloc] init]; + [alert setMessageText:@"Error connecting to server"]; + [alert beginSheetModalForWindow:[g_mrdpview window] + modalDelegate:g_mrdpview + didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) + contextInfo:nil]; } /** ********************************************************************* @@ -851,119 +849,119 @@ struct kkey g_keys[256] = - (void) rdpRemoteAppError { - NSAlert *alert = [[NSAlert alloc] init]; - [alert setMessageText:@"Error starting remote app on specified server"]; - [alert beginSheetModalForWindow:[g_mrdpview window] - modalDelegate:g_mrdpview - didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) - contextInfo:nil]; + NSAlert *alert = [[NSAlert alloc] init]; + [alert setMessageText:@"Error starting remote app on specified server"]; + [alert beginSheetModalForWindow:[g_mrdpview window] + modalDelegate:g_mrdpview + didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) + contextInfo:nil]; } /** ********************************************************************* * just a terminate selector for above call ***********************************************************************/ -- (void) alertDidEnd:(NSAlert *)a returnCode:(NSInteger)rc contextInfo:(void *)ci +- (void) alertDidEnd:(NSAlert *)a returnCode:(NSInteger)rc contextInfo:(void *)ci { - [NSApp terminate:nil]; + [NSApp terminate:nil]; } - (void) onPasteboardTimerFired :(NSTimer *) timer { - NSArray *types; - int i; - - i = (int) [pasteboard_rd changeCount]; - if (i != pasteboard_changecount) - { - pasteboard_changecount = i; - types = [NSArray arrayWithObject:NSStringPboardType]; - NSString *str = [pasteboard_rd availableTypeFromArray:types]; - if (str != nil) - { - cliprdr_send_supported_format_list(rdp_instance); - } - } + NSArray *types; + int i; + + i = (int) [pasteboard_rd changeCount]; + if (i != pasteboard_changecount) + { + pasteboard_changecount = i; + types = [NSArray arrayWithObject:NSStringPboardType]; + NSString *str = [pasteboard_rd availableTypeFromArray:types]; + if (str != nil) + { + cliprdr_send_supported_format_list(rdp_instance); + } + } } - (void) setViewSize : (int) w : (int) h { - // store current dimensions - width = w; - height = h; - - // compute difference between window and client area - NSRect outerRect = [[g_mrdpview window] frame]; - NSRect innerRect = [g_mrdpview frame]; - - int widthDiff = outerRect.size.width - innerRect.size.width; - int heightDiff = outerRect.size.height - innerRect.size.height; - - if (!g_mrdpview->isRemoteApp) { - // we are not in RemoteApp mode, disable resizing - outerRect.size.width = w + widthDiff; - outerRect.size.height = h + heightDiff; - [[g_mrdpview window] setMaxSize:outerRect.size]; - [[g_mrdpview window] setMinSize:outerRect.size]; - [[g_mrdpview window] setFrame:outerRect display:YES]; - - // set client area to specified dimensions - innerRect.size.width = w; - innerRect.size.height = h; - [g_mrdpview setFrame:innerRect]; - - return; - } - - // we are in RemoteApp mode - - outerRect.origin.x = 0; - outerRect.origin.y = 0; - outerRect.size.width = width + widthDiff; - outerRect.size.height = height + heightDiff; - [[g_mrdpview window] setFrame:outerRect display:YES]; + // store current dimensions + width = w; + height = h; + + // compute difference between window and client area + NSRect outerRect = [[g_mrdpview window] frame]; + NSRect innerRect = [g_mrdpview frame]; + + int widthDiff = outerRect.size.width - innerRect.size.width; + int heightDiff = outerRect.size.height - innerRect.size.height; + + if (!g_mrdpview->isRemoteApp) { + // we are not in RemoteApp mode, disable resizing + outerRect.size.width = w + widthDiff; + outerRect.size.height = h + heightDiff; + [[g_mrdpview window] setMaxSize:outerRect.size]; + [[g_mrdpview window] setMinSize:outerRect.size]; + [[g_mrdpview window] setFrame:outerRect display:YES]; + + // set client area to specified dimensions + innerRect.size.width = w; + innerRect.size.height = h; + [g_mrdpview setFrame:innerRect]; + + return; + } + + // we are in RemoteApp mode + + outerRect.origin.x = 0; + outerRect.origin.y = 0; + outerRect.size.width = width + widthDiff; + outerRect.size.height = height + heightDiff; + [[g_mrdpview window] setFrame:outerRect display:YES]; - // set client area to specified dimensions - innerRect.size.width = width; - innerRect.size.height = height; - [g_mrdpview setFrame:innerRect]; - - // main window displays desktop background - hide it - [[g_mrdpview window] orderOut:g_mrdpview]; + // set client area to specified dimensions + innerRect.size.width = width; + innerRect.size.height = height; + [g_mrdpview setFrame:innerRect]; + + // main window displays desktop background - hide it + [[g_mrdpview window] orderOut:g_mrdpview]; } // RAIL_TODO is this func required - (void) windowDidResize:(NSNotification *) notification { - RAIL_WINDOW_MOVE_ORDER windowMove; - - printf("RAIL_TODO: MRDPView: windowDidResize() - not yet implemented\n"); - - return; - - // window resize valid only in RemoteApp mode - if (!g_mrdpview->isRemoteApp) - return; - - // window has resized, let server know - - NSRect r = [[g_mrdpview window] frame]; - printf("----- LK_TODO: MRDPView:windowDidResize (%d,%d %dx%d)\n", - (int) r.origin.x, (int) r.origin.y, - (int) r.size.width, (int) r.size.height); - - - windowMove.windowId = [currentWindow windowID]; - - windowMove.left = (uint16) r.origin.x; // x-cordinate of top left corner - windowMove.right = (uint16) (windowMove.left + r.size.width); // x-cordinate of bottom right corner - windowMove.top = (uint16) r.origin.y; // y-cordinate of top left corner - windowMove.bottom = (uint16) (windowMove.top + r.size.height); // y-cordinate of bottom right corner - - printf("----- LK_TODO: MRDPView:windowDidResize windowID=%d left=%d top=%d right=%d bottom=x%d width=%f height=%f\n", - [currentWindow windowID], windowMove.left, windowMove.top, windowMove.right, windowMove.bottom, r.size.width, r.size.height); - - //mac_send_rail_client_event(g_mrdpview->rdp_instance->context->channels, RDP_EVENT_TYPE_RAIL_CLIENT_WINDOW_MOVE, &windowMove); + RAIL_WINDOW_MOVE_ORDER windowMove; + + printf("RAIL_TODO: MRDPView: windowDidResize() - not yet implemented\n"); + + return; + + // window resize valid only in RemoteApp mode + if (!g_mrdpview->isRemoteApp) + return; + + // window has resized, let server know + + NSRect r = [[g_mrdpview window] frame]; + printf("----- LK_TODO: MRDPView:windowDidResize (%d,%d %dx%d)\n", + (int) r.origin.x, (int) r.origin.y, + (int) r.size.width, (int) r.size.height); + + + windowMove.windowId = [currentWindow windowID]; + + windowMove.left = (uint16) r.origin.x; // x-cordinate of top left corner + windowMove.right = (uint16) (windowMove.left + r.size.width); // x-cordinate of bottom right corner + windowMove.top = (uint16) r.origin.y; // y-cordinate of top left corner + windowMove.bottom = (uint16) (windowMove.top + r.size.height); // y-cordinate of bottom right corner + + printf("----- LK_TODO: MRDPView:windowDidResize windowID=%d left=%d top=%d right=%d bottom=x%d width=%f height=%f\n", + [currentWindow windowID], windowMove.left, windowMove.top, windowMove.right, windowMove.bottom, r.size.width, r.size.height); + + //mac_send_rail_client_event(g_mrdpview->rdp_instance->context->channels, RDP_EVENT_TYPE_RAIL_CLIENT_WINDOW_MOVE, &windowMove); } /************************************************************************ @@ -980,35 +978,35 @@ struct kkey g_keys[256] = int rdp_connect() { - freerdp *inst; - int status; - - freerdp_channels_global_init(); - - inst = freerdp_new(); - inst->PreConnect = mac_pre_connect; - inst->PostConnect = mac_post_connect; - inst->context_size = sizeof(struct mac_context); - inst->ContextNew = mac_context_new; - inst->ContextFree = mac_context_free; - inst->ReceiveChannelData = receive_channel_data; - freerdp_context_new(inst); - - status = freerdp_connect(inst); - if(status) { - freerdp_check_fds(inst); - [g_mrdpview setIs_connected:1]; - return 0; - } - [g_mrdpview setIs_connected:0]; - [g_mrdpview rdpConnectError]; - return -1; + freerdp *inst; + int status; + + freerdp_channels_global_init(); + + inst = freerdp_new(); + inst->PreConnect = mac_pre_connect; + inst->PostConnect = mac_post_connect; + inst->context_size = sizeof(struct mac_context); + inst->ContextNew = mac_context_new; + inst->ContextFree = mac_context_free; + inst->ReceiveChannelData = receive_channel_data; + freerdp_context_new(inst); + + status = freerdp_connect(inst); + if(status) { + freerdp_check_fds(inst); + [g_mrdpview setIs_connected:1]; + return 0; + } + [g_mrdpview setIs_connected:0]; + [g_mrdpview rdpConnectError]; + return -1; } /** ********************************************************************* * a callback given to freerdp_connect() to process the pre-connect operations. * - * @param inst - pointer to a rdp_freerdp struct that contains the connection's parameters, and + * @param inst - pointer to a rdp_freerdp struct that contains the connection's parameters, and * will be filled with the appropriate informations. * * @return true if successful. false otherwise. @@ -1017,203 +1015,103 @@ int rdp_connect() BOOL mac_pre_connect(freerdp *inst) { int status; - char *cptr; - int len; - int i; - - inst->settings->OffscreenSupportLevel = FALSE; - inst->settings->GlyphSupportLevel = GLYPH_SUPPORT_FULL; - inst->settings->OrderSupport[NEG_GLYPH_INDEX_INDEX] = TRUE; - inst->settings->OrderSupport[NEG_FAST_GLYPH_INDEX] = FALSE; - inst->settings->OrderSupport[NEG_FAST_INDEX_INDEX] = FALSE; - inst->settings->OrderSupport[NEG_SCRBLT_INDEX] = TRUE; - inst->settings->OrderSupport[NEG_SAVEBITMAP_INDEX] = FALSE; - - inst->settings->BitmapCacheEnabled = TRUE; - inst->settings->OrderSupport[NEG_MEMBLT_INDEX] = TRUE; - inst->settings->OrderSupport[NEG_MEMBLT_V2_INDEX] = TRUE; - inst->settings->OrderSupport[NEG_MEM3BLT_INDEX] = FALSE; - inst->settings->OrderSupport[NEG_MEM3BLT_V2_INDEX] = FALSE; - inst->settings->BitmapCacheV2NumCells = 3; // 5; - inst->settings->BitmapCacheV2CellInfo[0].numEntries = 0x78; // 600; - inst->settings->BitmapCacheV2CellInfo[0].persistent = FALSE; - inst->settings->BitmapCacheV2CellInfo[1].numEntries = 0x78; // 600; - inst->settings->BitmapCacheV2CellInfo[1].persistent = FALSE; - inst->settings->BitmapCacheV2CellInfo[2].numEntries = 0x150; // 2048; - inst->settings->BitmapCacheV2CellInfo[2].persistent = FALSE; - inst->settings->BitmapCacheV2CellInfo[3].numEntries = 0; // 4096; - inst->settings->BitmapCacheV2CellInfo[3].persistent = FALSE; - inst->settings->BitmapCacheV2CellInfo[4].numEntries = 0; // 2048; - inst->settings->BitmapCacheV2CellInfo[4].persistent = FALSE; - - inst->settings->OrderSupport[NEG_MULTIDSTBLT_INDEX] = FALSE; - inst->settings->OrderSupport[NEG_MULTIPATBLT_INDEX] = FALSE; - inst->settings->OrderSupport[NEG_MULTISCRBLT_INDEX] = FALSE; - inst->settings->OrderSupport[NEG_MULTIOPAQUERECT_INDEX] = FALSE; - inst->settings->OrderSupport[NEG_POLYLINE_INDEX] = FALSE; - inst->settings->ColorDepth = 24; - inst->settings->SoftwareGdi = 1; - - // setup callbacks - inst->update->BeginPaint = mac_begin_paint; - inst->update->EndPaint = mac_end_paint; - inst->update->SetBounds = mac_set_bounds; - inst->update->BitmapUpdate = mac_bitmap_update; - - NSArray *args = [[NSProcessInfo processInfo] arguments]; - -#ifdef RUN_IN_XCODE - g_mrdpview->argc = 30; -#else - g_mrdpview->argc = (int) [args count]; -#endif - - g_mrdpview->argv = malloc(sizeof(char *) * g_mrdpview->argc); - if (g_mrdpview->argv == NULL) { - return FALSE; - } - -#ifdef RUN_IN_XCODE - - // create our own cmd line args - i = 0; - - NSString *sptr = [args objectAtIndex:0]; - len = [sptr length] + 1; - cptr = (char *) malloc(len); - strcpy(cptr, [sptr UTF8String]); - g_mrdpview->argv[i++] = cptr; - - cptr = (char *)malloc(80); - strcpy(cptr, "-g"); - g_mrdpview->argv[i++] = cptr; - - cptr = (char *)malloc(80); - strcpy(cptr, "1280x800"); - g_mrdpview->argv[i++] = cptr; - - cptr = (char *)malloc(80); - strcpy(cptr, "--sec"); - g_mrdpview->argv[i++] = cptr; - - cptr = (char *)malloc(80); - strcpy(cptr, "rdp"); - g_mrdpview->argv[i++] = cptr; - - cptr = (char *)malloc(80); - strcpy(cptr, "--plugin"); - g_mrdpview->argv[i++] = cptr; - - cptr = (char *)malloc(80); - strcpy(cptr, "cliprdr"); - g_mrdpview->argv[i++] = cptr; - - cptr = (char *)malloc(80); - strcpy(cptr, "--plugin"); - g_mrdpview->argv[i++] = cptr; - - cptr = (char *)malloc(80); - strcpy(cptr, "rdpsnd"); - g_mrdpview->argv[i++] = cptr; - - cptr = (char *)malloc(80); - strcpy(cptr, "-u"); - g_mrdpview->argv[i++] = cptr; - - cptr = (char *)malloc(80); - strcpy(cptr, "lk"); - g_mrdpview->argv[i++] = cptr; - - cptr = (char *)malloc(80); - strcpy(cptr, "-p"); - g_mrdpview->argv[i++] = cptr; - - cptr = (char *)malloc(80); - strcpy(cptr, "abc@@@123"); - g_mrdpview->argv[i++] = cptr; - -#if 1 - // for RemoteApp (RAIL) testing - cptr = (char *)malloc(80); - strcpy(cptr, "--app"); - g_mrdpview->argv[i++] = cptr; - g_mrdpview->isRemoteApp = TRUE; - - cptr = (char *)malloc(80); - strcpy(cptr, "--plugin"); - g_mrdpview->argv[i++] = cptr; - - cptr = (char *)malloc(80); - strcpy(cptr, "rail"); - g_mrdpview->argv[i++] = cptr; - - cptr = (char *)malloc(80); - strcpy(cptr, "--data"); - g_mrdpview->argv[i++] = cptr; - - cptr = (char *)malloc(80); - strcpy(cptr, "||WordPad"); - g_mrdpview->argv[i++] = cptr; - - cptr = (char *)malloc(80); - strcpy(cptr, "--"); - g_mrdpview->argv[i++] = cptr; -#endif - - cptr = (char *)malloc(80); - strcpy(cptr, "192.168.1.69:45990"); - g_mrdpview->argv[i++] = cptr; - - g_mrdpview->argc = i; - -#else - // MacFreeRDP was not run in Xcode - i = 0; - - // in RemoteApp (RAIL) mode, we connect to RDP server at max screen resolution; - // in order to achieve this, we need to modify the cmd line args entered by the user; - - if (g_mrdpview->isRemoteApp) { - BOOL gotGeometry = NO; - - // get dimensions of screen that has keyboard focus; - // we use these dimensions when connecting to RDP server - inst->settings->DesktopWidth = [[NSScreen mainScreen] frame].size.width; - inst->settings->DesktopHeight = [[NSScreen mainScreen] frame].size.height - g_mrdpview->titleBarHeight; - g_mrdpview->width = inst->settings->DesktopWidth; - g_mrdpview->height = inst->settings->DesktopHeight; - - for (NSString * str in args) - { - if (gotGeometry) { - gotGeometry = NO; - cptr = (char *) malloc(20); - sprintf(cptr, "%dx%d", g_mrdpview->width, g_mrdpview->height); - g_mrdpview->argv[i++] = cptr; - continue; - } - - len = (int) ([str length] + 1); - cptr = (char *) malloc(len); - strcpy(cptr, [str UTF8String]); - g_mrdpview->argv[i++] = cptr; - - // -g is the cmd line arg to specify screen resolution/geometry - if ([str compare:@"-g"] == NSOrderedSame) { - gotGeometry = YES; - } - } - } - else { - for (NSString * str in args) - { - len = (int) ([str length] + 1); - cptr = (char *) malloc(len); - strcpy(cptr, [str UTF8String]); - g_mrdpview->argv[i++] = cptr; - } - } -#endif + char *cptr; + int len; + int i; + + inst->settings->OffscreenSupportLevel = FALSE; + inst->settings->GlyphSupportLevel = GLYPH_SUPPORT_FULL; + inst->settings->OrderSupport[NEG_GLYPH_INDEX_INDEX] = TRUE; + inst->settings->OrderSupport[NEG_FAST_GLYPH_INDEX] = FALSE; + inst->settings->OrderSupport[NEG_FAST_INDEX_INDEX] = FALSE; + inst->settings->OrderSupport[NEG_SCRBLT_INDEX] = TRUE; + inst->settings->OrderSupport[NEG_SAVEBITMAP_INDEX] = FALSE; + + inst->settings->BitmapCacheEnabled = TRUE; + inst->settings->OrderSupport[NEG_MEMBLT_INDEX] = TRUE; + inst->settings->OrderSupport[NEG_MEMBLT_V2_INDEX] = TRUE; + inst->settings->OrderSupport[NEG_MEM3BLT_INDEX] = FALSE; + inst->settings->OrderSupport[NEG_MEM3BLT_V2_INDEX] = FALSE; + inst->settings->BitmapCacheV2NumCells = 3; // 5; + inst->settings->BitmapCacheV2CellInfo[0].numEntries = 0x78; // 600; + inst->settings->BitmapCacheV2CellInfo[0].persistent = FALSE; + inst->settings->BitmapCacheV2CellInfo[1].numEntries = 0x78; // 600; + inst->settings->BitmapCacheV2CellInfo[1].persistent = FALSE; + inst->settings->BitmapCacheV2CellInfo[2].numEntries = 0x150; // 2048; + inst->settings->BitmapCacheV2CellInfo[2].persistent = FALSE; + inst->settings->BitmapCacheV2CellInfo[3].numEntries = 0; // 4096; + inst->settings->BitmapCacheV2CellInfo[3].persistent = FALSE; + inst->settings->BitmapCacheV2CellInfo[4].numEntries = 0; // 2048; + inst->settings->BitmapCacheV2CellInfo[4].persistent = FALSE; + + inst->settings->OrderSupport[NEG_MULTIDSTBLT_INDEX] = FALSE; + inst->settings->OrderSupport[NEG_MULTIPATBLT_INDEX] = FALSE; + inst->settings->OrderSupport[NEG_MULTISCRBLT_INDEX] = FALSE; + inst->settings->OrderSupport[NEG_MULTIOPAQUERECT_INDEX] = FALSE; + inst->settings->OrderSupport[NEG_POLYLINE_INDEX] = FALSE; + inst->settings->ColorDepth = 24; + inst->settings->SoftwareGdi = 1; + + // setup callbacks + inst->update->BeginPaint = mac_begin_paint; + inst->update->EndPaint = mac_end_paint; + inst->update->SetBounds = mac_set_bounds; + inst->update->BitmapUpdate = mac_bitmap_update; + + NSArray *args = [[NSProcessInfo processInfo] arguments]; + + g_mrdpview->argc = (int) [args count]; + + g_mrdpview->argv = malloc(sizeof(char *) * g_mrdpview->argc); + + if (g_mrdpview->argv == NULL) + return FALSE; + + i = 0; + + // in RemoteApp (RAIL) mode, we connect to RDP server at max screen resolution; + // in order to achieve this, we need to modify the cmd line args entered by the user; + + if (g_mrdpview->isRemoteApp) { + BOOL gotGeometry = NO; + + // get dimensions of screen that has keyboard focus; + // we use these dimensions when connecting to RDP server + inst->settings->DesktopWidth = [[NSScreen mainScreen] frame].size.width; + inst->settings->DesktopHeight = [[NSScreen mainScreen] frame].size.height - g_mrdpview->titleBarHeight; + g_mrdpview->width = inst->settings->DesktopWidth; + g_mrdpview->height = inst->settings->DesktopHeight; + + for (NSString * str in args) + { + if (gotGeometry) { + gotGeometry = NO; + cptr = (char *) malloc(20); + sprintf(cptr, "%dx%d", g_mrdpview->width, g_mrdpview->height); + g_mrdpview->argv[i++] = cptr; + continue; + } + + len = (int) ([str length] + 1); + cptr = (char *) malloc(len); + strcpy(cptr, [str UTF8String]); + g_mrdpview->argv[i++] = cptr; + + // -g is the cmd line arg to specify screen resolution/geometry + if ([str compare:@"-g"] == NSOrderedSame) { + gotGeometry = YES; + } + } + } + else { + for (NSString * str in args) + { + len = (int) ([str length] + 1); + cptr = (char *) malloc(len); + strcpy(cptr, [str UTF8String]); + g_mrdpview->argv[i++] = cptr; + } + } inst->context->argc = g_mrdpview->argc; inst->context->argv = g_mrdpview->argv; @@ -1227,16 +1125,16 @@ BOOL mac_pre_connect(freerdp *inst) } freerdp_client_load_addins(inst->context->channels, inst->settings); - - [g_mrdpview setViewSize:inst->settings->DesktopWidth :inst->settings->DesktopHeight]; - - freerdp_channels_pre_connect(inst->context->channels, inst); - return TRUE; + + [g_mrdpview setViewSize:inst->settings->DesktopWidth :inst->settings->DesktopHeight]; + + freerdp_channels_pre_connect(inst->context->channels, inst); + return TRUE; } /** ********************************************************************* * a callback registered with freerdp_connect() to perform post-connection operations. - * we get called only if the connection was initialized properly, and will continue + * we get called only if the connection was initialized properly, and will continue * the initialization based on the newly created connection. * * @param inst - pointer to a rdp_freerdp struct @@ -1247,71 +1145,71 @@ BOOL mac_pre_connect(freerdp *inst) BOOL mac_post_connect(freerdp *inst) { - uint32 flags; - rdpPointer rdp_pointer; - void *rd_fds[32]; - void *wr_fds[32]; - int rd_count = 0; - int wr_count = 0; - int index; - int fds[32]; - - memset(&rdp_pointer, 0, sizeof(rdpPointer)); - rdp_pointer.size = sizeof(rdpPointer); - rdp_pointer.New = pointer_new; - rdp_pointer.Free = pointer_free; - rdp_pointer.Set = pointer_set; - rdp_pointer.SetNull = pointer_setNull; - rdp_pointer.SetDefault = pointer_setDefault; - - flags = CLRCONV_ALPHA; - flags |= CLRBUF_32BPP; - - gdi_init(inst, flags, NULL); - pointer_cache_register_callbacks(inst->update); - graphics_register_pointer(inst->context->graphics, &rdp_pointer); - - // register file descriptors with the RunLoop - if (!freerdp_get_fds(inst, rd_fds, &rd_count, 0, 0)) - { - printf("mac_post_connect: freerdp_get_fds() failed!\n"); - } - - for (index = 0; index < rd_count; index++) - { - fds[index] = (int)(long)rd_fds[index]; - } - register_fds(fds, rd_count, inst); - - // register channel manager file descriptors with the RunLoop - if (!freerdp_channels_get_fds(inst->context->channels, inst, rd_fds, &rd_count, wr_fds, &wr_count)) - { - printf("ERROR: freerdp_channels_get_fds() failed\n"); - } - for (index = 0; index < rd_count; index++) - { - fds[index] = (int)(long)rd_fds[index]; - } - register_channel_fds(fds, rd_count, inst); - freerdp_channels_post_connect(inst->context->channels, inst); - - // setup RAIL (remote app) - inst->context->rail = rail_new(inst->settings); - rail_register_update_callbacks(inst->context->rail, inst->update); - mac_rail_register_callbacks(inst, inst->context->rail); - - // setup pasteboard (aka clipboard) for copy operations (write only) - g_mrdpview->pasteboard_wr = [NSPasteboard generalPasteboard]; - - // setup pasteboard for read operations - g_mrdpview->pasteboard_rd = [NSPasteboard generalPasteboard]; - g_mrdpview->pasteboard_changecount = (int) [g_mrdpview->pasteboard_rd changeCount]; - g_mrdpview->pasteboard_timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:g_mrdpview selector:@selector(onPasteboardTimerFired:) userInfo:nil repeats:YES]; - - // we want to be notified when window resizes - [[NSNotificationCenter defaultCenter] addObserver:g_mrdpview selector:@selector(windowDidResize:) name:NSWindowDidResizeNotification object:nil]; - - return TRUE; + uint32 flags; + rdpPointer rdp_pointer; + void *rd_fds[32]; + void *wr_fds[32]; + int rd_count = 0; + int wr_count = 0; + int index; + int fds[32]; + + memset(&rdp_pointer, 0, sizeof(rdpPointer)); + rdp_pointer.size = sizeof(rdpPointer); + rdp_pointer.New = pointer_new; + rdp_pointer.Free = pointer_free; + rdp_pointer.Set = pointer_set; + rdp_pointer.SetNull = pointer_setNull; + rdp_pointer.SetDefault = pointer_setDefault; + + flags = CLRCONV_ALPHA; + flags |= CLRBUF_32BPP; + + gdi_init(inst, flags, NULL); + pointer_cache_register_callbacks(inst->update); + graphics_register_pointer(inst->context->graphics, &rdp_pointer); + + // register file descriptors with the RunLoop + if (!freerdp_get_fds(inst, rd_fds, &rd_count, 0, 0)) + { + printf("mac_post_connect: freerdp_get_fds() failed!\n"); + } + + for (index = 0; index < rd_count; index++) + { + fds[index] = (int)(long)rd_fds[index]; + } + register_fds(fds, rd_count, inst); + + // register channel manager file descriptors with the RunLoop + if (!freerdp_channels_get_fds(inst->context->channels, inst, rd_fds, &rd_count, wr_fds, &wr_count)) + { + printf("ERROR: freerdp_channels_get_fds() failed\n"); + } + for (index = 0; index < rd_count; index++) + { + fds[index] = (int)(long)rd_fds[index]; + } + register_channel_fds(fds, rd_count, inst); + freerdp_channels_post_connect(inst->context->channels, inst); + + // setup RAIL (remote app) + inst->context->rail = rail_new(inst->settings); + rail_register_update_callbacks(inst->context->rail, inst->update); + mac_rail_register_callbacks(inst, inst->context->rail); + + // setup pasteboard (aka clipboard) for copy operations (write only) + g_mrdpview->pasteboard_wr = [NSPasteboard generalPasteboard]; + + // setup pasteboard for read operations + g_mrdpview->pasteboard_rd = [NSPasteboard generalPasteboard]; + g_mrdpview->pasteboard_changecount = (int) [g_mrdpview->pasteboard_rd changeCount]; + g_mrdpview->pasteboard_timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:g_mrdpview selector:@selector(onPasteboardTimerFired:) userInfo:nil repeats:YES]; + + // we want to be notified when window resizes + [[NSNotificationCenter defaultCenter] addObserver:g_mrdpview selector:@selector(windowDidResize:) name:NSWindowDidResizeNotification object:nil]; + + return TRUE; } /** ********************************************************************* @@ -1324,58 +1222,58 @@ BOOL mac_post_connect(freerdp *inst) void pointer_new(rdpContext* context, rdpPointer* pointer) { - MRDPCursor *mrdpCursor = [[MRDPCursor alloc] init]; - uint8 *cursor_data; - - NSRect rect; - rect.size.width = pointer->width; - rect.size.height = pointer->height; - rect.origin.x = pointer->xPos; - rect.origin.y = pointer->yPos; - - cursor_data = (uint8 *) malloc(rect.size.width * rect.size.height * 4); - mrdpCursor->cursor_data = cursor_data; - - freerdp_alpha_cursor_convert(cursor_data, pointer->xorMaskData, pointer->andMaskData, - pointer->width, pointer->height, pointer->xorBpp, context->gdi->clrconv); - - // TODO if xorBpp is > 24 need to call freerdp_image_swap_color_order - // see file df_graphics.c - - // store cursor bitmap image in representation - required by NSImage - NSBitmapImageRep *bmiRep; - bmiRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:(unsigned char **) &cursor_data - pixelsWide:rect.size.width - pixelsHigh:rect.size.height - bitsPerSample:8 - samplesPerPixel:sizeof(struct rgba_data) - hasAlpha:YES - isPlanar:NO - colorSpaceName:NSDeviceRGBColorSpace - bitmapFormat:0 - bytesPerRow:rect.size.width * 4 - bitsPerPixel:0]; - mrdpCursor->bmiRep = bmiRep; - - // create an image using above representation - NSImage *image = [[NSImage alloc] initWithSize:[bmiRep size]]; - [image addRepresentation: bmiRep]; - [image setFlipped:NO]; - mrdpCursor->nsImage = image; - - // need hotspot to create cursor - NSPoint hotSpot; - hotSpot.x = pointer->xPos; - hotSpot.y = pointer->yPos; - - NSCursor *cursor = [[NSCursor alloc] initWithImage: image hotSpot:hotSpot]; - mrdpCursor->nsCursor = cursor; - mrdpCursor->pointer = pointer; - - // save cursor for later use in pointer_set() - NSMutableArray *ma = g_mrdpview->cursors; - [ma addObject:mrdpCursor]; -} + MRDPCursor *mrdpCursor = [[MRDPCursor alloc] init]; + uint8 *cursor_data; + + NSRect rect; + rect.size.width = pointer->width; + rect.size.height = pointer->height; + rect.origin.x = pointer->xPos; + rect.origin.y = pointer->yPos; + + cursor_data = (uint8 *) malloc(rect.size.width * rect.size.height * 4); + mrdpCursor->cursor_data = cursor_data; + + freerdp_alpha_cursor_convert(cursor_data, pointer->xorMaskData, pointer->andMaskData, + pointer->width, pointer->height, pointer->xorBpp, context->gdi->clrconv); + + // TODO if xorBpp is > 24 need to call freerdp_image_swap_color_order + // see file df_graphics.c + + // store cursor bitmap image in representation - required by NSImage + NSBitmapImageRep *bmiRep; + bmiRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:(unsigned char **) &cursor_data + pixelsWide:rect.size.width + pixelsHigh:rect.size.height + bitsPerSample:8 + samplesPerPixel:sizeof(struct rgba_data) + hasAlpha:YES + isPlanar:NO + colorSpaceName:NSDeviceRGBColorSpace + bitmapFormat:0 + bytesPerRow:rect.size.width * 4 + bitsPerPixel:0]; + mrdpCursor->bmiRep = bmiRep; + + // create an image using above representation + NSImage *image = [[NSImage alloc] initWithSize:[bmiRep size]]; + [image addRepresentation: bmiRep]; + [image setFlipped:NO]; + mrdpCursor->nsImage = image; + + // need hotspot to create cursor + NSPoint hotSpot; + hotSpot.x = pointer->xPos; + hotSpot.y = pointer->yPos; + + NSCursor *cursor = [[NSCursor alloc] initWithImage: image hotSpot:hotSpot]; + mrdpCursor->nsCursor = cursor; + mrdpCursor->pointer = pointer; + + // save cursor for later use in pointer_set() + NSMutableArray *ma = g_mrdpview->cursors; + [ma addObject:mrdpCursor]; +} /** ********************************************************************* * release resources on specified cursor @@ -1383,19 +1281,19 @@ void pointer_new(rdpContext* context, rdpPointer* pointer) void pointer_free(rdpContext* context, rdpPointer* pointer) { - NSMutableArray *ma = g_mrdpview->cursors; - - for (MRDPCursor *cursor in ma) - { - if (cursor->pointer == pointer) { - cursor->nsImage = nil; - cursor->nsCursor = nil; - cursor->bmiRep = nil; - free(cursor->cursor_data); - [ma removeObject:cursor]; - return; - } - } + NSMutableArray *ma = g_mrdpview->cursors; + + for (MRDPCursor *cursor in ma) + { + if (cursor->pointer == pointer) { + cursor->nsImage = nil; + cursor->nsCursor = nil; + cursor->bmiRep = nil; + free(cursor->cursor_data); + [ma removeObject:cursor]; + return; + } + } } /** ********************************************************************* @@ -1404,20 +1302,20 @@ void pointer_free(rdpContext* context, rdpPointer* pointer) void pointer_set(rdpContext* context, rdpPointer* pointer) { - NSMutableArray *ma = g_mrdpview->cursors; - - if (!g_mrdpview->mouseInClientArea) - { - return; // not in client area - } - - for (MRDPCursor *cursor in ma) - { - if (cursor->pointer == pointer) { - [cursor->nsCursor set]; - return; - } - } + NSMutableArray *ma = g_mrdpview->cursors; + + if (!g_mrdpview->mouseInClientArea) + { + return; // not in client area + } + + for (MRDPCursor *cursor in ma) + { + if (cursor->pointer == pointer) { + [cursor->nsCursor set]; + return; + } + } } /** ********************************************************************* @@ -1442,8 +1340,8 @@ void pointer_setDefault(rdpContext* context) void mac_context_new(freerdp *inst, rdpContext *context) { - [g_mrdpview saveStateInfo:inst :context]; - context->channels = freerdp_channels_new(); + [g_mrdpview saveStateInfo:inst :context]; + context->channels = freerdp_channels_new(); } /** ********************************************************************* @@ -1476,8 +1374,8 @@ void mac_bitmap_update(rdpContext *context, BITMAP_UPDATE *bitmap) void mac_begin_paint(rdpContext *context) { - rdpGdi* gdi = context->gdi; - gdi->primary->hdc->hwnd->invalid->null = 1; + rdpGdi* gdi = context->gdi; + gdi->primary->hdc->hwnd->invalid->null = 1; } /** ********************************************************************* @@ -1486,38 +1384,38 @@ void mac_begin_paint(rdpContext *context) void mac_end_paint(rdpContext* context) { - int i; - NSRect drawRect; - 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 = g_mrdpview->rdp_context->gdi; - - if (g_mrdpview->isRemoteApp && g_mrdpview->currentWindow) { - [[g_mrdpview->currentWindow view] updateDisplay]; - 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; - - convert_color_space(g_mrdpview->pixel_data, (char *) gdi->primary_buffer, &drawRect, g_mrdpview->width, g_mrdpview->height); - - [g_mrdpview setNeedsDisplayInRect:drawRect]; - } - gdi->primary->hdc->hwnd->ninvalid = 0; + int i; + NSRect drawRect; + 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 = g_mrdpview->rdp_context->gdi; + + if (g_mrdpview->isRemoteApp && g_mrdpview->currentWindow) { + [[g_mrdpview->currentWindow view] updateDisplay]; + 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; + + convert_color_space(g_mrdpview->pixel_data, (char *) gdi->primary_buffer, &drawRect, g_mrdpview->width, g_mrdpview->height); + + [g_mrdpview setNeedsDisplayInRect:drawRect]; + } + gdi->primary->hdc->hwnd->ninvalid = 0; } /** ********************************************************************* @@ -1532,10 +1430,10 @@ void skt_activity_cb( void *info ) { - if (!freerdp_check_fds(info)) { - // lost connection or did not connect - [NSApp terminate:nil]; - } + if (!freerdp_check_fds(info)) { + // lost connection or did not connect + [NSApp terminate:nil]; + } } /** ********************************************************************* @@ -1543,32 +1441,32 @@ void skt_activity_cb( ***********************************************************************/ void channel_activity_cb( - CFSocketRef s, - CFSocketCallBackType callbackType, - CFDataRef address, - const void *data, - void *info - ) + CFSocketRef s, + CFSocketCallBackType callbackType, + CFDataRef address, + const void *data, + void *info + ) { - freerdp *inst = (freerdp *) info; - RDP_EVENT* event; - - GOT_HERE; - - freerdp_channels_check_fds(inst->context->channels, inst); - event = freerdp_channels_pop_event(inst->context->channels); - if (event) { - switch (event->event_class) - { - case RDP_EVENT_CLASS_RAIL: - mac_process_rail_event(inst, event); - break; - - case RDP_EVENT_CLASS_CLIPRDR: - process_cliprdr_event(inst, event); - break; - } - } + freerdp *inst = (freerdp *) info; + RDP_EVENT* event; + + GOT_HERE; + + freerdp_channels_check_fds(inst->context->channels, inst); + event = freerdp_channels_pop_event(inst->context->channels); + if (event) { + switch (event->event_class) + { + case RDP_EVENT_CLASS_RAIL: + mac_process_rail_event(inst, event); + break; + + case RDP_EVENT_CLASS_CLIPRDR: + process_cliprdr_event(inst, event); + break; + } + } } /** ********************************************************************* @@ -1577,38 +1475,38 @@ void channel_activity_cb( int register_fds(int *fds, int count, void *inst) { - int i; - CFSocketRef skt_ref; - CFSocketContext skt_context = { 0, inst, NULL, NULL, NULL }; - - for (i = 0; i < count; i++) - { - skt_ref = CFSocketCreateWithNative(NULL, fds[i], kCFSocketReadCallBack, skt_activity_cb, &skt_context); - g_mrdpview->run_loop_src = CFSocketCreateRunLoopSource(NULL, skt_ref, 0); - CFRunLoopAddSource(CFRunLoopGetCurrent(), g_mrdpview->run_loop_src, kCFRunLoopDefaultMode); - CFRelease(skt_ref); - } - return 0; + int i; + CFSocketRef skt_ref; + CFSocketContext skt_context = { 0, inst, NULL, NULL, NULL }; + + for (i = 0; i < count; i++) + { + skt_ref = CFSocketCreateWithNative(NULL, fds[i], kCFSocketReadCallBack, skt_activity_cb, &skt_context); + g_mrdpview->run_loop_src = CFSocketCreateRunLoopSource(NULL, skt_ref, 0); + CFRunLoopAddSource(CFRunLoopGetCurrent(), g_mrdpview->run_loop_src, kCFRunLoopDefaultMode); + CFRelease(skt_ref); + } + return 0; } /** ********************************************************************* - * setup callbacks for data availability on channels + * setup callbacks for data availability on channels ***********************************************************************/ int register_channel_fds(int *fds, int count, void *inst) { - int i; - CFSocketRef skt_ref; - CFSocketContext skt_context = { 0, inst, NULL, NULL, NULL }; - - for (i = 0; i < count; i++) - { - skt_ref = CFSocketCreateWithNative(NULL, fds[i], kCFSocketReadCallBack, channel_activity_cb, &skt_context); - g_mrdpview->run_loop_src_channels = CFSocketCreateRunLoopSource(NULL, skt_ref, 0); - CFRunLoopAddSource(CFRunLoopGetCurrent(), g_mrdpview->run_loop_src_channels, kCFRunLoopDefaultMode); - CFRelease(skt_ref); - } - return 0; + int i; + CFSocketRef skt_ref; + CFSocketContext skt_context = { 0, inst, NULL, NULL, NULL }; + + for (i = 0; i < count; i++) + { + skt_ref = CFSocketCreateWithNative(NULL, fds[i], kCFSocketReadCallBack, channel_activity_cb, &skt_context); + g_mrdpview->run_loop_src_channels = CFSocketCreateRunLoopSource(NULL, skt_ref, 0); + CFRunLoopAddSource(CFRunLoopGetCurrent(), g_mrdpview->run_loop_src_channels, kCFRunLoopDefaultMode); + CFRelease(skt_ref); + } + return 0; } /** ********************************************************************* @@ -1617,7 +1515,7 @@ int register_channel_fds(int *fds, int count, void *inst) int receive_channel_data(freerdp *inst, int chan_id, uint8 *data, int size, int flags, int total_size) { - return freerdp_channels_data(inst, chan_id, data, size, flags, total_size); + return freerdp_channels_data(inst, chan_id, data, size, flags, total_size); } /** ********************************************************************* @@ -1626,66 +1524,66 @@ int receive_channel_data(freerdp *inst, int chan_id, uint8 *data, int size, int void convert_color_space(char *dest, char *src, NSRect* drawRect, int width, int height) { - int i; - int j; - int x; - int y; - int cx; - int cy; - int pixel; - int pixel1; - int pixel2; - int* src32; - int* dst32; - - if ((!dest) || (!src)) { - return; - } - - x = drawRect->origin.x; - y = drawRect->origin.y; - cx = drawRect->size.width; - cy = drawRect->size.height; - - for (j = 0; j < cy; j++) - { - src32 = (int*)(src + ((y + j) * width + x) * 4); - dst32 = (int*)(dest + ((y + j) * width + x) * 4); - for (i = 0; i < cx; i++) - { - pixel = *src32; - pixel1 = (pixel & 0x00ff0000) >> 16; - pixel2 = (pixel & 0x000000ff) << 16; - pixel = (pixel & 0xff00ff00) | pixel1 | pixel2; - *dst32 = pixel; - src32++; - dst32++; - } - } - - drawRect->origin.y = height - drawRect->origin.y - drawRect->size.height; + int i; + int j; + int x; + int y; + int cx; + int cy; + int pixel; + int pixel1; + int pixel2; + int* src32; + int* dst32; + + if ((!dest) || (!src)) { + return; + } + + x = drawRect->origin.x; + y = drawRect->origin.y; + cx = drawRect->size.width; + cy = drawRect->size.height; + + for (j = 0; j < cy; j++) + { + src32 = (int*)(src + ((y + j) * width + x) * 4); + dst32 = (int*)(dest + ((y + j) * width + x) * 4); + for (i = 0; i < cx; i++) + { + pixel = *src32; + pixel1 = (pixel & 0x00ff0000) >> 16; + pixel2 = (pixel & 0x000000ff) << 16; + pixel = (pixel & 0xff00ff00) | pixel1 | pixel2; + *dst32 = pixel; + src32++; + dst32++; + } + } + + drawRect->origin.y = height - drawRect->origin.y - drawRect->size.height; } -/** +/** * Used to load plugins based on the commandline parameters. * This function is provided as a parameter to freerdp_parse_args(), that will call it * each time a plugin name is found on the command line. * This function just calls freerdp_channels_load_plugin() for the given plugin, and always returns 1. - * + * * @param settings * @param name * @param plugin_data * @param user_data - * + * * @return 1 */ int process_plugin_args(rdpSettings* settings, const char* name, RDP_PLUGIN_DATA* plugin_data, void* user_data) { - rdpChannels* channels = (rdpChannels*) user_data; - - freerdp_channels_load_plugin(channels, settings, name, plugin_data); - return 1; + rdpChannels* channels = (rdpChannels*) user_data; + + freerdp_channels_load_plugin(channels, settings, name, plugin_data); + return 1; } /* @@ -1698,38 +1596,38 @@ int process_plugin_args(rdpSettings* settings, const char* name, RDP_PLUGIN_DATA void cliprdr_process_cb_data_request_event(freerdp *inst) { - RDP_CB_DATA_RESPONSE_EVENT *event; - NSArray *types; - int len; - - event = (RDP_CB_DATA_RESPONSE_EVENT*) freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR, - RDP_EVENT_TYPE_CB_DATA_RESPONSE, NULL, NULL); - types = [NSArray arrayWithObject:NSStringPboardType]; - NSString *str = [g_mrdpview->pasteboard_rd availableTypeFromArray:types]; - if (str == nil) - { - event->data = NULL; - event->size = 0; - } - else - { - NSString *data = [g_mrdpview->pasteboard_rd stringForType:NSStringPboardType]; - len = (int) ([data length] * 2 + 2); - event->data = malloc(len); - [data getCString:(char *) event->data maxLength:len encoding:NSUnicodeStringEncoding]; - event->size = len; - } - freerdp_channels_send_event(inst->context->channels, (RDP_EVENT*) event); + RDP_CB_DATA_RESPONSE_EVENT *event; + NSArray *types; + int len; + + event = (RDP_CB_DATA_RESPONSE_EVENT*) freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR, + RDP_EVENT_TYPE_CB_DATA_RESPONSE, NULL, NULL); + types = [NSArray arrayWithObject:NSStringPboardType]; + NSString *str = [g_mrdpview->pasteboard_rd availableTypeFromArray:types]; + if (str == nil) + { + event->data = NULL; + event->size = 0; + } + else + { + NSString *data = [g_mrdpview->pasteboard_rd stringForType:NSStringPboardType]; + len = (int) ([data length] * 2 + 2); + event->data = malloc(len); + [data getCString:(char *) event->data maxLength:len encoding:NSUnicodeStringEncoding]; + event->size = len; + } + freerdp_channels_send_event(inst->context->channels, (RDP_EVENT*) event); } void cliprdr_send_data_request(freerdp *inst, uint32 format) { - RDP_CB_DATA_REQUEST_EVENT* event; - - event = (RDP_CB_DATA_REQUEST_EVENT *) freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR, - RDP_EVENT_TYPE_CB_DATA_REQUEST, NULL, NULL); - event->format = format; - freerdp_channels_send_event(inst->context->channels, (RDP_EVENT*) event); + RDP_CB_DATA_REQUEST_EVENT* event; + + event = (RDP_CB_DATA_REQUEST_EVENT *) freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR, + RDP_EVENT_TYPE_CB_DATA_REQUEST, NULL, NULL); + event->format = format; + freerdp_channels_send_event(inst->context->channels, (RDP_EVENT*) event); } /** @@ -1740,32 +1638,32 @@ void cliprdr_send_data_request(freerdp *inst, uint32 format) void cliprdr_process_cb_data_response_event(freerdp *inst, RDP_CB_DATA_RESPONSE_EVENT *event) { - NSString *str; - NSArray *types; - - if (event->size == 0) { - return; - } - - if (g_mrdpview->pasteboard_format == CB_FORMAT_TEXT || g_mrdpview->pasteboard_format == CB_FORMAT_UNICODETEXT) { - str = [[NSString alloc] initWithCharacters:(unichar *) event->data length:event->size / 2]; - types = [[NSArray alloc] initWithObjects:NSStringPboardType, nil]; - [g_mrdpview->pasteboard_wr declareTypes:types owner:g_mrdpview]; - [g_mrdpview->pasteboard_wr setString:str forType:NSStringPboardType]; - } + NSString *str; + NSArray *types; + + if (event->size == 0) { + return; + } + + if (g_mrdpview->pasteboard_format == CB_FORMAT_TEXT || g_mrdpview->pasteboard_format == CB_FORMAT_UNICODETEXT) { + str = [[NSString alloc] initWithCharacters:(unichar *) event->data length:event->size / 2]; + types = [[NSArray alloc] initWithObjects:NSStringPboardType, nil]; + [g_mrdpview->pasteboard_wr declareTypes:types owner:g_mrdpview]; + [g_mrdpview->pasteboard_wr setString:str forType:NSStringPboardType]; + } } void cliprdr_process_cb_monitor_ready_event(freerdp* inst) { - RDP_EVENT* event; - RDP_CB_FORMAT_LIST_EVENT* format_list_event; - - event = freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR, RDP_EVENT_TYPE_CB_FORMAT_LIST, NULL, NULL); - - format_list_event = (RDP_CB_FORMAT_LIST_EVENT*)event; - format_list_event->num_formats = 0; - - freerdp_channels_send_event(inst->context->channels, event); + RDP_EVENT* event; + RDP_CB_FORMAT_LIST_EVENT* format_list_event; + + event = freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR, RDP_EVENT_TYPE_CB_FORMAT_LIST, NULL, NULL); + + format_list_event = (RDP_CB_FORMAT_LIST_EVENT*)event; + format_list_event->num_formats = 0; + + freerdp_channels_send_event(inst->context->channels, event); } /** @@ -1776,104 +1674,104 @@ void cliprdr_process_cb_monitor_ready_event(freerdp* inst) void cliprdr_process_cb_format_list_event(freerdp *inst, RDP_CB_FORMAT_LIST_EVENT* event) { - int i; - - if (event->num_formats == 0) { - return; - } - - for (i = 0; i < event->num_formats; i++) - { - switch (event->formats[i]) - { - case CB_FORMAT_RAW: - printf("CB_FORMAT_RAW: not yet supported\n"); - break; - - case CB_FORMAT_TEXT: - case CB_FORMAT_UNICODETEXT: - g_mrdpview->pasteboard_format = CB_FORMAT_UNICODETEXT; - cliprdr_send_data_request(inst, CB_FORMAT_UNICODETEXT); - return; - break; - - case CB_FORMAT_DIB: - printf("CB_FORMAT_DIB: not yet supported\n"); - break; - - case CB_FORMAT_HTML: - printf("CB_FORMAT_HTML\n"); - break; - - case CB_FORMAT_PNG: - printf("CB_FORMAT_PNG: not yet supported\n"); - break; - - case CB_FORMAT_JPEG: - printf("CB_FORMAT_JPEG: not yet supported\n"); - break; - - case CB_FORMAT_GIF: - printf("CB_FORMAT_GIF: not yet supported\n"); - break; - } - } + int i; + + if (event->num_formats == 0) { + return; + } + + for (i = 0; i < event->num_formats; i++) + { + switch (event->formats[i]) + { + case CB_FORMAT_RAW: + printf("CB_FORMAT_RAW: not yet supported\n"); + break; + + case CB_FORMAT_TEXT: + case CB_FORMAT_UNICODETEXT: + g_mrdpview->pasteboard_format = CB_FORMAT_UNICODETEXT; + cliprdr_send_data_request(inst, CB_FORMAT_UNICODETEXT); + return; + break; + + case CB_FORMAT_DIB: + printf("CB_FORMAT_DIB: not yet supported\n"); + break; + + case CB_FORMAT_HTML: + printf("CB_FORMAT_HTML\n"); + break; + + case CB_FORMAT_PNG: + printf("CB_FORMAT_PNG: not yet supported\n"); + break; + + case CB_FORMAT_JPEG: + printf("CB_FORMAT_JPEG: not yet supported\n"); + break; + + case CB_FORMAT_GIF: + printf("CB_FORMAT_GIF: not yet supported\n"); + break; + } + } } void process_cliprdr_event(freerdp *inst, RDP_EVENT *event) { - if (event) { - switch (event->event_type) - { - // Monitor Ready PDU is sent by server to indicate that it has been - // inited and is ready. This PDU is transmitted by the server after it has sent - // Clipboard Capabilities PDU - case RDP_EVENT_TYPE_CB_MONITOR_READY: - cliprdr_process_cb_monitor_ready_event(inst); - break; - - // The Format List PDU is sent either by the client or the server when its - // local system clipboard is updated with new clipboard data. This PDU - // contains the Clipboard Format ID and name pairs of the new Clipboard - // Formats on the clipboard - case RDP_EVENT_TYPE_CB_FORMAT_LIST: - cliprdr_process_cb_format_list_event(inst, (RDP_CB_FORMAT_LIST_EVENT*) event); - break; - - // The Format Data Request PDU is sent by the receipient of the Format List PDU. - // It is used to request the data for one of the formats that was listed in the - // Format List PDU - case RDP_EVENT_TYPE_CB_DATA_REQUEST: - cliprdr_process_cb_data_request_event(inst); - break; - - // The Format Data Response PDU is sent as a reply to the Format Data Request PDU. - // It is used to indicate whether processing of the Format Data Request PDU - // was successful. If the processing was successful, the Format Data Response PDU - // includes the contents of the requested clipboard data - case RDP_EVENT_TYPE_CB_DATA_RESPONSE: - cliprdr_process_cb_data_response_event(inst, (RDP_CB_DATA_RESPONSE_EVENT*) event); - break; - - default: - printf("process_cliprdr_event: unknown event type %d\n", event->event_type); - break; - } - freerdp_event_free(event); - } + if (event) { + switch (event->event_type) + { + // Monitor Ready PDU is sent by server to indicate that it has been + // inited and is ready. This PDU is transmitted by the server after it has sent + // Clipboard Capabilities PDU + case RDP_EVENT_TYPE_CB_MONITOR_READY: + cliprdr_process_cb_monitor_ready_event(inst); + break; + + // The Format List PDU is sent either by the client or the server when its + // local system clipboard is updated with new clipboard data. This PDU + // contains the Clipboard Format ID and name pairs of the new Clipboard + // Formats on the clipboard + case RDP_EVENT_TYPE_CB_FORMAT_LIST: + cliprdr_process_cb_format_list_event(inst, (RDP_CB_FORMAT_LIST_EVENT*) event); + break; + + // The Format Data Request PDU is sent by the receipient of the Format List PDU. + // It is used to request the data for one of the formats that was listed in the + // Format List PDU + case RDP_EVENT_TYPE_CB_DATA_REQUEST: + cliprdr_process_cb_data_request_event(inst); + break; + + // The Format Data Response PDU is sent as a reply to the Format Data Request PDU. + // It is used to indicate whether processing of the Format Data Request PDU + // was successful. If the processing was successful, the Format Data Response PDU + // includes the contents of the requested clipboard data + case RDP_EVENT_TYPE_CB_DATA_RESPONSE: + cliprdr_process_cb_data_response_event(inst, (RDP_CB_DATA_RESPONSE_EVENT*) event); + break; + + default: + printf("process_cliprdr_event: unknown event type %d\n", event->event_type); + break; + } + freerdp_event_free(event); + } } void cliprdr_send_supported_format_list(freerdp *inst) { - RDP_CB_FORMAT_LIST_EVENT* event; - - event = (RDP_CB_FORMAT_LIST_EVENT*) freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR, - RDP_EVENT_TYPE_CB_FORMAT_LIST, NULL, NULL); - - event->formats = (uint32 *) malloc(sizeof(uint32) * 1); - event->num_formats = 1; - event->formats[0] = CB_FORMAT_UNICODETEXT; - freerdp_channels_send_event(inst->context->channels, (RDP_EVENT*) event); + RDP_CB_FORMAT_LIST_EVENT* event; + + event = (RDP_CB_FORMAT_LIST_EVENT*) freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR, + RDP_EVENT_TYPE_CB_FORMAT_LIST, NULL, NULL); + + event->formats = (uint32 *) malloc(sizeof(uint32) * 1); + event->num_formats = 1; + event->formats[0] = CB_FORMAT_UNICODETEXT; + freerdp_channels_send_event(inst->context->channels, (RDP_EVENT*) event); } /**************************************************************************************** @@ -1882,143 +1780,143 @@ void cliprdr_send_supported_format_list(freerdp *inst) * RemoteApp (RAIL) related stuff goes here * * * * * - ****************************************************************************************/ + ****************************************************************************************/ void mac_process_rail_event(freerdp *inst, RDP_EVENT *event) { - switch (event->event_type) - { - case RDP_EVENT_TYPE_RAIL_CHANNEL_GET_SYSPARAMS: - mac_process_rail_get_sysparams_event(inst->context->channels, event); - break; - - case RDP_EVENT_TYPE_RAIL_CHANNEL_EXEC_RESULTS: - mac_process_rail_exec_result_event(inst->context->channels, event); - break; - - case RDP_EVENT_TYPE_RAIL_CHANNEL_SERVER_SYSPARAM: - mac_process_rail_server_sysparam_event(inst->context->channels, event); - break; - - case RDP_EVENT_TYPE_RAIL_CHANNEL_SERVER_MINMAXINFO: - mac_process_rail_server_minmaxinfo_event(inst->context->channels, event); - break; - - case RDP_EVENT_TYPE_RAIL_CHANNEL_SERVER_LOCALMOVESIZE: - mac_process_rail_server_localmovesize_event(inst, event); - break; - - case RDP_EVENT_TYPE_RAIL_CHANNEL_APPID_RESP: - GOT_HERE; - //xf_process_rail_appid_resp_event(xfi, channels, event); - break; - - case RDP_EVENT_TYPE_RAIL_CHANNEL_LANGBARINFO: - GOT_HERE; - //xf_process_rail_langbarinfo_event(xfi, channels, event); - break; - } + switch (event->event_type) + { + case RDP_EVENT_TYPE_RAIL_CHANNEL_GET_SYSPARAMS: + mac_process_rail_get_sysparams_event(inst->context->channels, event); + break; + + case RDP_EVENT_TYPE_RAIL_CHANNEL_EXEC_RESULTS: + mac_process_rail_exec_result_event(inst->context->channels, event); + break; + + case RDP_EVENT_TYPE_RAIL_CHANNEL_SERVER_SYSPARAM: + mac_process_rail_server_sysparam_event(inst->context->channels, event); + break; + + case RDP_EVENT_TYPE_RAIL_CHANNEL_SERVER_MINMAXINFO: + mac_process_rail_server_minmaxinfo_event(inst->context->channels, event); + break; + + case RDP_EVENT_TYPE_RAIL_CHANNEL_SERVER_LOCALMOVESIZE: + mac_process_rail_server_localmovesize_event(inst, event); + break; + + case RDP_EVENT_TYPE_RAIL_CHANNEL_APPID_RESP: + GOT_HERE; + //xf_process_rail_appid_resp_event(xfi, channels, event); + break; + + case RDP_EVENT_TYPE_RAIL_CHANNEL_LANGBARINFO: + GOT_HERE; + //xf_process_rail_langbarinfo_event(xfi, channels, event); + break; + } } void mac_rail_CreateWindow(rdpRail *rail, rdpWindow *window) { - BOOL centerWindow = NO; - BOOL moveWindow = NO; - BOOL displayAsModal = NO; - NSMutableArray * ma = g_mrdpview->windows; - - // make sure window fits resolution - if (window->windowWidth > g_mrdpview->width) - window->windowWidth = g_mrdpview->width; - - if (window->windowHeight > g_mrdpview->height) - window->windowHeight = g_mrdpview->height; - - // center main window, which is the first to be created - if ([ma count] == 0) { - centerWindow = YES; - moveWindow = YES; - } - - if ((window->extendedStyle & WS_EX_TOPMOST) || (window->extendedStyle & WS_EX_TOOLWINDOW)) { - [g_mrdpview->currentWindow view]->skipMoveWindowOnce = TRUE; - moveWindow = YES; - } - else if (window->style & WS_POPUP) { - centerWindow = YES; - moveWindow = YES; - } - else { - } - - // create NSWindow - NSRect winFrame = NSMakeRect(window->windowOffsetX, window->windowOffsetY, - window->windowWidth, window->windowHeight); - if (centerWindow) - apple_center_window(&winFrame); - - MRDPRailWindow * newWindow = [[MRDPRailWindow alloc] initWithContentRect:winFrame - styleMask:NSTitledWindowMask | NSResizableWindowMask - backing:NSBackingStoreBuffered - defer:NO]; - - // this does not work if specified during window creation in above code - [newWindow setStyleMask:NSBorderlessWindowMask]; - - if (moveWindow) { - // let RDP server know that window has moved - RAIL_WINDOW_MOVE_ORDER windowMove; - apple_to_windowMove(&winFrame, &windowMove); - windowMove.windowId = window->windowId; - mac_send_rail_client_event(g_mrdpview->rdp_instance->context->channels, RDP_EVENT_TYPE_RAIL_CLIENT_WINDOW_MOVE, &windowMove); - } - - // create MRDPRailView and add to above window - NSRect viewFrame = NSMakeRect(window->clientOffsetX, window->clientOffsetY, - window->clientAreaWidth, window->clientAreaHeight); - - MRDPRailView * newView = [[MRDPRailView alloc] initWithFrame:viewFrame]; - [newView setRdpInstance:g_mrdpview->rdp_instance width:g_mrdpview->width andHeight:g_mrdpview->height windowID: window->windowId]; - [newWindow setContentView:newView]; - - // save new window - MRDPWindow * mrdpWindow = [[MRDPWindow alloc] init]; - [mrdpWindow setWindowID:window->windowId]; - [mrdpWindow setWindow:newWindow]; - [mrdpWindow setView:newView]; - - // add to list of windows - [ma addObject:mrdpWindow]; - - // make new window current - g_mrdpview->currentWindow = mrdpWindow; - - if (displayAsModal) { - // display as modal window - NSModalSession session = [NSApp beginModalSessionForWindow:newWindow]; - while (1) - { - if ([NSApp runModalSession:session] != NSRunContinuesResponse) - break; - } - [NSApp endModalSession:session]; - } - else { - [newWindow makeKeyAndOrderFront:NSApp]; - [[g_mrdpview window] resignFirstResponder]; - [g_mrdpview resignFirstResponder]; - [[g_mrdpview window] setNextResponder:newWindow]; - } - - return; + BOOL centerWindow = NO; + BOOL moveWindow = NO; + BOOL displayAsModal = NO; + NSMutableArray * ma = g_mrdpview->windows; + + // make sure window fits resolution + if (window->windowWidth > g_mrdpview->width) + window->windowWidth = g_mrdpview->width; + + if (window->windowHeight > g_mrdpview->height) + window->windowHeight = g_mrdpview->height; + + // center main window, which is the first to be created + if ([ma count] == 0) { + centerWindow = YES; + moveWindow = YES; + } + + if ((window->extendedStyle & WS_EX_TOPMOST) || (window->extendedStyle & WS_EX_TOOLWINDOW)) { + [g_mrdpview->currentWindow view]->skipMoveWindowOnce = TRUE; + moveWindow = YES; + } + else if (window->style & WS_POPUP) { + centerWindow = YES; + moveWindow = YES; + } + else { + } + + // create NSWindow + NSRect winFrame = NSMakeRect(window->windowOffsetX, window->windowOffsetY, + window->windowWidth, window->windowHeight); + if (centerWindow) + apple_center_window(&winFrame); + + MRDPRailWindow * newWindow = [[MRDPRailWindow alloc] initWithContentRect:winFrame + styleMask:NSTitledWindowMask | NSResizableWindowMask + backing:NSBackingStoreBuffered + defer:NO]; + + // this does not work if specified during window creation in above code + [newWindow setStyleMask:NSBorderlessWindowMask]; + + if (moveWindow) { + // let RDP server know that window has moved + RAIL_WINDOW_MOVE_ORDER windowMove; + apple_to_windowMove(&winFrame, &windowMove); + windowMove.windowId = window->windowId; + mac_send_rail_client_event(g_mrdpview->rdp_instance->context->channels, RDP_EVENT_TYPE_RAIL_CLIENT_WINDOW_MOVE, &windowMove); + } + + // create MRDPRailView and add to above window + NSRect viewFrame = NSMakeRect(window->clientOffsetX, window->clientOffsetY, + window->clientAreaWidth, window->clientAreaHeight); + + MRDPRailView * newView = [[MRDPRailView alloc] initWithFrame:viewFrame]; + [newView setRdpInstance:g_mrdpview->rdp_instance width:g_mrdpview->width andHeight:g_mrdpview->height windowID: window->windowId]; + [newWindow setContentView:newView]; + + // save new window + MRDPWindow * mrdpWindow = [[MRDPWindow alloc] init]; + [mrdpWindow setWindowID:window->windowId]; + [mrdpWindow setWindow:newWindow]; + [mrdpWindow setView:newView]; + + // add to list of windows + [ma addObject:mrdpWindow]; + + // make new window current + g_mrdpview->currentWindow = mrdpWindow; + + if (displayAsModal) { + // display as modal window + NSModalSession session = [NSApp beginModalSessionForWindow:newWindow]; + while (1) + { + if ([NSApp runModalSession:session] != NSRunContinuesResponse) + break; + } + [NSApp endModalSession:session]; + } + else { + [newWindow makeKeyAndOrderFront:NSApp]; + [[g_mrdpview window] resignFirstResponder]; + [g_mrdpview resignFirstResponder]; + [[g_mrdpview window] setNextResponder:newWindow]; + } + + return; } void mac_rail_MoveWindow(rdpRail *rail, rdpWindow *window) { - if (g_mrdpview->currentWindow) { - rail_MoveWindow(rail, window); - return; - } + if (g_mrdpview->currentWindow) { + rail_MoveWindow(rail, window); + return; + } } void mac_rail_ShowWindow(rdpRail *rail, rdpWindow *window, uint8 state) @@ -2047,44 +1945,44 @@ void mac_rail_SetWindowVisibilityRects(rdpRail *rail, rdpWindow *window) void mac_rail_DestroyWindow(rdpRail *rail, rdpWindow *window) { - int count = 0; - - for (MRDPWindow * win in g_mrdpview->windows) - { - if ([win windowID] == window->windowId) { - //[[win window] close]; - [win setView:nil]; - [win setWindow:nil]; - [g_mrdpview->windows removeObject:win]; - count = [g_mrdpview->windows count]; - if (count) { - g_mrdpview->currentWindow = [g_mrdpview->windows objectAtIndex:count - 1]; - //[[g_mrdpview window] makeKeyAndOrderFront:[g_mrdpview->currentWindow window]]; - [[g_mrdpview->currentWindow window] makeKeyAndOrderFront:NSApp]; - } - else { - g_mrdpview->currentWindow = nil; - // RAIL_TODO [[g_mrdpview window] makeKeyAndOrderFront:[g_mrdpview window]]; - [NSApp terminate:nil]; - } - return; - } - } + int count = 0; + + for (MRDPWindow * win in g_mrdpview->windows) + { + if ([win windowID] == window->windowId) { + //[[win window] close]; + [win setView:nil]; + [win setWindow:nil]; + [g_mrdpview->windows removeObject:win]; + count = [g_mrdpview->windows count]; + if (count) { + g_mrdpview->currentWindow = [g_mrdpview->windows objectAtIndex:count - 1]; + //[[g_mrdpview window] makeKeyAndOrderFront:[g_mrdpview->currentWindow window]]; + [[g_mrdpview->currentWindow window] makeKeyAndOrderFront:NSApp]; + } + else { + g_mrdpview->currentWindow = nil; + // RAIL_TODO [[g_mrdpview window] makeKeyAndOrderFront:[g_mrdpview window]]; + [NSApp terminate:nil]; + } + return; + } + } } void mac_rail_register_callbacks(freerdp *inst, rdpRail *rail) { - GOT_HERE; - - rail->extra = (void *) inst; - rail->rail_CreateWindow = mac_rail_CreateWindow; - rail->rail_MoveWindow = mac_rail_MoveWindow; - rail->rail_ShowWindow = mac_rail_ShowWindow; - rail->rail_SetWindowText = mac_rail_SetWindowText; - rail->rail_SetWindowIcon = mac_rail_SetWindowIcon; - rail->rail_SetWindowRects = mac_rail_SetWindowRects; - rail->rail_SetWindowVisibilityRects = mac_rail_SetWindowVisibilityRects; - rail->rail_DestroyWindow = mac_rail_DestroyWindow; + GOT_HERE; + + rail->extra = (void *) inst; + rail->rail_CreateWindow = mac_rail_CreateWindow; + rail->rail_MoveWindow = mac_rail_MoveWindow; + rail->rail_ShowWindow = mac_rail_ShowWindow; + rail->rail_SetWindowText = mac_rail_SetWindowText; + rail->rail_SetWindowIcon = mac_rail_SetWindowIcon; + rail->rail_SetWindowRects = mac_rail_SetWindowRects; + rail->rail_SetWindowVisibilityRects = mac_rail_SetWindowVisibilityRects; + rail->rail_DestroyWindow = mac_rail_DestroyWindow; } /** ********************************************************************* @@ -2094,38 +1992,38 @@ void mac_rail_register_callbacks(freerdp *inst, rdpRail *rail) void mac_process_rail_get_sysparams_event(rdpChannels *channels, RDP_EVENT *event) { - RAIL_SYSPARAM_ORDER * sysparam; - sysparam = (RAIL_SYSPARAM_ORDER *) event->user_data; - - sysparam->workArea.left = 0; - sysparam->workArea.top = 22; - sysparam->workArea.right = g_mrdpview->width; - sysparam->workArea.bottom = g_mrdpview->height - 22; - - sysparam->taskbarPos.left = 0; - sysparam->taskbarPos.top = 0; - sysparam->taskbarPos.right = 0; - sysparam->taskbarPos.bottom = 0; - - sysparam->dragFullWindows = FALSE; - - mac_send_rail_client_event(channels, RDP_EVENT_TYPE_RAIL_CLIENT_SET_SYSPARAMS, sysparam); + RAIL_SYSPARAM_ORDER * sysparam; + sysparam = (RAIL_SYSPARAM_ORDER *) event->user_data; + + sysparam->workArea.left = 0; + sysparam->workArea.top = 22; + sysparam->workArea.right = g_mrdpview->width; + sysparam->workArea.bottom = g_mrdpview->height - 22; + + sysparam->taskbarPos.left = 0; + sysparam->taskbarPos.top = 0; + sysparam->taskbarPos.right = 0; + sysparam->taskbarPos.bottom = 0; + + sysparam->dragFullWindows = FALSE; + + mac_send_rail_client_event(channels, RDP_EVENT_TYPE_RAIL_CLIENT_SET_SYSPARAMS, sysparam); } void mac_process_rail_server_sysparam_event(rdpChannels* channels, RDP_EVENT* event) { - RAIL_SYSPARAM_ORDER* sysparam = (RAIL_SYSPARAM_ORDER*) event->user_data; - - GOT_HERE; - - switch (sysparam->param) - { - case SPI_SET_SCREEN_SAVE_ACTIVE: - break; - - case SPI_SET_SCREEN_SAVE_SECURE: - break; - } + RAIL_SYSPARAM_ORDER* sysparam = (RAIL_SYSPARAM_ORDER*) event->user_data; + + GOT_HERE; + + switch (sysparam->param) + { + case SPI_SET_SCREEN_SAVE_ACTIVE: + break; + + case SPI_SET_SCREEN_SAVE_SECURE: + break; + } } /** ********************************************************************* @@ -2134,21 +2032,21 @@ void mac_process_rail_server_sysparam_event(rdpChannels* channels, RDP_EVENT* ev void mac_process_rail_exec_result_event(rdpChannels* channels, RDP_EVENT* event) { - RAIL_EXEC_RESULT_ORDER* exec_result; - - GOT_HERE; - - exec_result = (RAIL_EXEC_RESULT_ORDER*) event->user_data; - - if (exec_result->execResult != RAIL_EXEC_S_OK) { - printf("RAIL exec error: execResult=%s NtError=0x%X\n", - error_code_names[exec_result->execResult], exec_result->rawResult); - g_mrdpview->is_connected = FALSE; - [g_mrdpview rdpRemoteAppError]; - } - else { - mac_rail_enable_remoteapp_mode(); - } + RAIL_EXEC_RESULT_ORDER* exec_result; + + GOT_HERE; + + exec_result = (RAIL_EXEC_RESULT_ORDER*) event->user_data; + + if (exec_result->execResult != RAIL_EXEC_S_OK) { + printf("RAIL exec error: execResult=%s NtError=0x%X\n", + error_code_names[exec_result->execResult], exec_result->rawResult); + g_mrdpview->is_connected = FALSE; + [g_mrdpview rdpRemoteAppError]; + } + else { + mac_rail_enable_remoteapp_mode(); + } } /** ********************************************************************* @@ -2160,10 +2058,10 @@ void mac_process_rail_exec_result_event(rdpChannels* channels, RDP_EVENT* event) void mac_process_rail_server_minmaxinfo_event(rdpChannels* channels, RDP_EVENT* event) { #if 0 - RAIL_MINMAXINFO_ORDER * minmax = (RAIL_MINMAXINFO_ORDER*) event->user_data; - printf("minmax_info: maxPosX=%d maxPosY=%d maxWidth=%d maxHeight=%d minTrackWidth=%d minTrackHeight=%d maxTrackWidth=%d maxTrackHeight=%d\n", - minmax->maxPosX, minmax->maxPosY, minmax->maxWidth, minmax->maxHeight, - minmax->minTrackWidth, minmax->minTrackHeight, minmax->maxTrackWidth, minmax->maxTrackHeight); + RAIL_MINMAXINFO_ORDER * minmax = (RAIL_MINMAXINFO_ORDER*) event->user_data; + printf("minmax_info: maxPosX=%d maxPosY=%d maxWidth=%d maxHeight=%d minTrackWidth=%d minTrackHeight=%d maxTrackWidth=%d maxTrackHeight=%d\n", + minmax->maxPosX, minmax->maxPosY, minmax->maxWidth, minmax->maxHeight, + minmax->minTrackWidth, minmax->minTrackHeight, minmax->maxTrackWidth, minmax->maxTrackHeight); #endif } @@ -2175,108 +2073,108 @@ void mac_process_rail_server_minmaxinfo_event(rdpChannels* channels, RDP_EVENT* void mac_process_rail_server_localmovesize_event(freerdp *inst, RDP_EVENT *event) { - RAIL_LOCALMOVESIZE_ORDER * moveSize = (RAIL_LOCALMOVESIZE_ORDER *) event->user_data; - RAIL_WINDOW_MOVE_ORDER windowMove; - - switch (moveSize->moveSizeType) { - case RAIL_WMSZ_LEFT: - printf("!!!! RAIL_WMSZ_LEFT\n"); - break; - - case RAIL_WMSZ_RIGHT: - printf("!!!! RAIL_WMSZ_RIGHT\n"); - break; - - case RAIL_WMSZ_TOP: - printf("!!!! RAIL_WMSZ_TOP\n"); - break; - - case RAIL_WMSZ_TOPLEFT: - printf("!!!! RAIL_WMSZ_TOPLEFT\n"); - break; - - case RAIL_WMSZ_TOPRIGHT: - printf("!!!! RAIL_WMSZ_TOPRIGHT\n"); - break; - - case RAIL_WMSZ_BOTTOM: - printf("!!!! RAIL_WMSZ_BOTTOM\n"); - break; - - case RAIL_WMSZ_BOTTOMLEFT: - printf("!!!! RAIL_WMSZ_BOTTOMLEFT\n"); - break; - - case RAIL_WMSZ_BOTTOMRIGHT: - printf("!!!! RAIL_WMSZ_BOTTOMRIGHT\n"); - break; - - case RAIL_WMSZ_MOVE: - if (moveSize->isMoveSizeStart) { - // local window move in progress - [g_mrdpview->currentWindow view]->isMoveSizeInProgress = YES; - [g_mrdpview->currentWindow view]->saveInitialDragLoc = YES; - - return; - } - - // local move has completed - [g_mrdpview->currentWindow view]->isMoveSizeInProgress = NO; - [g_mrdpview->currentWindow view]->saveInitialDragLoc = NO; - - // let RDP server know where this window is located - mac_send_rail_client_event(inst->context->channels, RDP_EVENT_TYPE_RAIL_CLIENT_WINDOW_MOVE, &windowMove); - - // the event we just sent will cause an extra MoveWindow() to be invoked which we need to ignore - [g_mrdpview->currentWindow view]->skipMoveWindowOnce = YES; - - break; - - case RAIL_WMSZ_KEYMOVE: - printf("!!!! RAIL_WMSZ_KEYMOVE\n"); - break; - - case RAIL_WMSZ_KEYSIZE: - printf("!!!! RAIL_WMSZ_KEYSIZE\n"); - break; - - default: - break; - } - return; + RAIL_LOCALMOVESIZE_ORDER * moveSize = (RAIL_LOCALMOVESIZE_ORDER *) event->user_data; + RAIL_WINDOW_MOVE_ORDER windowMove; + + switch (moveSize->moveSizeType) { + case RAIL_WMSZ_LEFT: + printf("!!!! RAIL_WMSZ_LEFT\n"); + break; + + case RAIL_WMSZ_RIGHT: + printf("!!!! RAIL_WMSZ_RIGHT\n"); + break; + + case RAIL_WMSZ_TOP: + printf("!!!! RAIL_WMSZ_TOP\n"); + break; + + case RAIL_WMSZ_TOPLEFT: + printf("!!!! RAIL_WMSZ_TOPLEFT\n"); + break; + + case RAIL_WMSZ_TOPRIGHT: + printf("!!!! RAIL_WMSZ_TOPRIGHT\n"); + break; + + case RAIL_WMSZ_BOTTOM: + printf("!!!! RAIL_WMSZ_BOTTOM\n"); + break; + + case RAIL_WMSZ_BOTTOMLEFT: + printf("!!!! RAIL_WMSZ_BOTTOMLEFT\n"); + break; + + case RAIL_WMSZ_BOTTOMRIGHT: + printf("!!!! RAIL_WMSZ_BOTTOMRIGHT\n"); + break; + + case RAIL_WMSZ_MOVE: + if (moveSize->isMoveSizeStart) { + // local window move in progress + [g_mrdpview->currentWindow view]->isMoveSizeInProgress = YES; + [g_mrdpview->currentWindow view]->saveInitialDragLoc = YES; + + return; + } + + // local move has completed + [g_mrdpview->currentWindow view]->isMoveSizeInProgress = NO; + [g_mrdpview->currentWindow view]->saveInitialDragLoc = NO; + + // let RDP server know where this window is located + mac_send_rail_client_event(inst->context->channels, RDP_EVENT_TYPE_RAIL_CLIENT_WINDOW_MOVE, &windowMove); + + // the event we just sent will cause an extra MoveWindow() to be invoked which we need to ignore + [g_mrdpview->currentWindow view]->skipMoveWindowOnce = YES; + + break; + + case RAIL_WMSZ_KEYMOVE: + printf("!!!! RAIL_WMSZ_KEYMOVE\n"); + break; + + case RAIL_WMSZ_KEYSIZE: + printf("!!!! RAIL_WMSZ_KEYSIZE\n"); + break; + + default: + break; + } + return; } void mac_send_rail_client_event(rdpChannels *channels, uint16 event_type, void *param) { - RDP_EVENT *out_event = NULL; - void *payload = NULL; - - GOT_HERE; - - payload = rail_clone_order(event_type, param); - if (payload != NULL) { - out_event = freerdp_event_new(RDP_EVENT_CLASS_RAIL, event_type, - mac_on_free_rail_client_event, payload); - freerdp_channels_send_event(channels, out_event); - } + RDP_EVENT *out_event = NULL; + void *payload = NULL; + + GOT_HERE; + + payload = rail_clone_order(event_type, param); + if (payload != NULL) { + out_event = freerdp_event_new(RDP_EVENT_CLASS_RAIL, event_type, + mac_on_free_rail_client_event, payload); + freerdp_channels_send_event(channels, out_event); + } } void mac_on_free_rail_client_event(RDP_EVENT* event) { - GOT_HERE; - - if (event->event_class == RDP_EVENT_CLASS_RAIL) - { - rail_free_cloned_order(event->event_type, event->user_data); - } + GOT_HERE; + + if (event->event_class == RDP_EVENT_CLASS_RAIL) + { + rail_free_cloned_order(event->event_type, event->user_data); + } } void mac_rail_enable_remoteapp_mode() { - GOT_HERE; - - if (!g_mrdpview->isRemoteApp) - g_mrdpview->isRemoteApp = TRUE; + GOT_HERE; + + if (!g_mrdpview->isRemoteApp) + g_mrdpview->isRemoteApp = TRUE; } /** @@ -2286,7 +2184,7 @@ void mac_rail_enable_remoteapp_mode() void apple_to_windows_cords(NSRect * r) { - r->origin.y = g_mrdpview->height - (r->origin.y + r->size.height); + r->origin.y = g_mrdpview->height - (r->origin.y + r->size.height); } /** @@ -2296,21 +2194,21 @@ void apple_to_windows_cords(NSRect * r) void windows_to_apple_cords(NSRect * r) { - r->origin.y = g_mrdpview->height - (r->origin.y + r->size.height); + r->origin.y = g_mrdpview->height - (r->origin.y + r->size.height); } void apple_center_window(NSRect * r) { - r->origin.x = (g_mrdpview->width - r->size.width) / 2; - r->origin.y = (g_mrdpview->height - r->size.height) / 2; + r->origin.x = (g_mrdpview->width - r->size.width) / 2; + r->origin.y = (g_mrdpview->height - r->size.height) / 2; } void apple_to_windowMove(NSRect * r, RAIL_WINDOW_MOVE_ORDER * windowMove) { - windowMove->left = (uint16) r->origin.x; // x-cord of top left corner - windowMove->top = (uint16) g_mrdpview->height - (r->origin.y + r->size.height); // y-cord of top left corner - windowMove->right = (uint16) (windowMove->left + r->size.width); // x-cord of bottom right corner - windowMove->bottom = (uint16) (windowMove->top + r->size.height); // y-cord of bottom right corner + windowMove->left = (uint16) r->origin.x; // x-cord of top left corner + windowMove->top = (uint16) g_mrdpview->height - (r->origin.y + r->size.height); // y-cord of top left corner + windowMove->right = (uint16) (windowMove->left + r->size.width); // x-cord of bottom right corner + windowMove->bottom = (uint16) (windowMove->top + r->size.height); // y-cord of bottom right corner } @end From c79014db5ca08e18a7ec993eabfceb3be1ddd3b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 21 Feb 2013 22:04:09 -0500 Subject: [PATCH 3/6] mfreerdp: code style cleanup --- client/Mac/MRDPView.m | 219 +++++++++++++++++++++++------------------- 1 file changed, 119 insertions(+), 100 deletions(-) diff --git a/client/Mac/MRDPView.m b/client/Mac/MRDPView.m index 859e6d9dd..5cc79c445 100644 --- a/client/Mac/MRDPView.m +++ b/client/Mac/MRDPView.m @@ -34,9 +34,6 @@ #import "MRDPView.h" #import "MRDPCursor.h" -// LK_TODO -#define GOT_HERE //printf("### got here: %s : %s() : %d\n", __FILE__, __func__, __LINE__) - // RAIL_TODO DELETE WHEN DONE TESTING #define MRDP_DRAW_INDIVIDUAL_RECTS @@ -231,7 +228,9 @@ struct kkey g_keys[256] = - (id)initWithFrame:(NSRect)frame { self = [super initWithFrame:frame]; - if (self) { + + if (self) + { // Initialization code here. } @@ -456,14 +455,15 @@ struct kkey g_keys[256] = y = height - y; flags = PTR_FLAGS_WHEEL; - if ([event deltaY] < 0) { + + if ([event deltaY] < 0) flags |= PTR_FLAGS_WHEEL_NEGATIVE | 0x0088; - } - else { + else flags |= 0x0078; - } + x += (int) [event deltaX]; y += (int) [event deltaY]; + rdp_instance->input->MouseEvent(rdp_instance->input, flags, x, y); } @@ -484,8 +484,10 @@ struct kkey g_keys[256] = int y = (int) loc.y; // RAIL_TODO delete this if not reqd - if ((isRemoteApp) && (isMoveSizeInProgress)) { - if (saveInitialDragLoc) { + if ((isRemoteApp) && (isMoveSizeInProgress)) + { + if (saveInitialDragLoc) + { saveInitialDragLoc = NO; savedDragLocation.x = x; savedDragLocation.y = y; @@ -515,9 +517,8 @@ struct kkey g_keys[256] = { int key; - if (!is_connected) { + if (!is_connected) return; - } key = [event keyCode]; rdp_instance->input->KeyboardEvent(rdp_instance->input, g_keys[key].flags | KBD_FLAGS_DOWN, g_keys[key].key_code); @@ -531,9 +532,8 @@ struct kkey g_keys[256] = { int key; - if (!is_connected) { + if (!is_connected) return; - } key = [event keyCode]; rdp_instance->input->KeyboardEvent(rdp_instance->input, g_keys[key].flags | KBD_FLAGS_RELEASE, g_keys[key].key_code); @@ -697,11 +697,11 @@ struct kkey g_keys[256] = if (!rdp_context) return; - if (g_mrdpview->isRemoteApp && g_mrdpview->currentWindow) { + if (g_mrdpview->isRemoteApp && g_mrdpview->currentWindow) return; - } - if (!bmiRep) { + if (!bmiRep) + { pixel_data = (char *) malloc(width * height * sizeof(struct rgba_data)); bmiRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:(unsigned char **) &pixel_data pixelsWide:width @@ -727,12 +727,12 @@ struct kkey g_keys[256] = * called when RDP server wants us to update a rect with new data ***********************************************************************/ -- (void) my_draw_rect:(void *)context +- (void) my_draw_rect:(void*)context { int w; int h; - rdpContext * ctx = (rdpContext *) context; + rdpContext* ctx = (rdpContext*) context; struct rgba_data { @@ -742,7 +742,8 @@ struct kkey g_keys[256] = char alpha; }; - if (isRemoteApp && currentWindow) { + if (isRemoteApp && currentWindow) + { NSRect vrect = [ [currentWindow view] frame]; [[currentWindow view] setNeedsDisplayInRect:vrect]; // actual drawing will be done in MRDPRailView:drawRect() @@ -756,7 +757,8 @@ struct kkey g_keys[256] = rect.size.width = w; rect.size.height = h; - if (!bmiRep) { + if (!bmiRep) + { pixel_data = (char *) malloc(w * h * sizeof(struct rgba_data)); bmiRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:(unsigned char **) &pixel_data pixelsWide:w @@ -800,22 +802,29 @@ struct kkey g_keys[256] = int x = (int) loc.x; int y = (int) loc.y; - if ((x < 0) || (y < 0)) { - if (mouseInClientArea) { + if ((x < 0) || (y < 0)) + { + if (mouseInClientArea) + { // set default cursor before leaving client area mouseInClientArea = NO; NSCursor *cur = [NSCursor arrowCursor]; [cur set]; } + return NO; } - if ((x > width) || (y > height)) { - if (mouseInClientArea) { + + if ((x > width) || (y > height)) + { + if (mouseInClientArea) + { // set default cursor before leaving client area mouseInClientArea = NO; NSCursor *cur = [NSCursor arrowCursor]; [cur set]; } + return NO; } @@ -872,6 +881,7 @@ struct kkey g_keys[256] = int i; i = (int) [pasteboard_rd changeCount]; + if (i != pasteboard_changecount) { pasteboard_changecount = i; @@ -897,7 +907,8 @@ struct kkey g_keys[256] = int widthDiff = outerRect.size.width - innerRect.size.width; int heightDiff = outerRect.size.height - innerRect.size.height; - if (!g_mrdpview->isRemoteApp) { + if (!g_mrdpview->isRemoteApp) + { // we are not in RemoteApp mode, disable resizing outerRect.size.width = w + widthDiff; outerRect.size.height = h + heightDiff; @@ -993,13 +1004,17 @@ int rdp_connect() freerdp_context_new(inst); status = freerdp_connect(inst); - if(status) { + + if (status) + { freerdp_check_fds(inst); [g_mrdpview setIs_connected:1]; return 0; } + [g_mrdpview setIs_connected:0]; [g_mrdpview rdpConnectError]; + return -1; } @@ -1072,7 +1087,8 @@ BOOL mac_pre_connect(freerdp *inst) // in RemoteApp (RAIL) mode, we connect to RDP server at max screen resolution; // in order to achieve this, we need to modify the cmd line args entered by the user; - if (g_mrdpview->isRemoteApp) { + if (g_mrdpview->isRemoteApp) + { BOOL gotGeometry = NO; // get dimensions of screen that has keyboard focus; @@ -1084,7 +1100,8 @@ BOOL mac_pre_connect(freerdp *inst) for (NSString * str in args) { - if (gotGeometry) { + if (gotGeometry) + { gotGeometry = NO; cptr = (char *) malloc(20); sprintf(cptr, "%dx%d", g_mrdpview->width, g_mrdpview->height); @@ -1098,12 +1115,14 @@ BOOL mac_pre_connect(freerdp *inst) g_mrdpview->argv[i++] = cptr; // -g is the cmd line arg to specify screen resolution/geometry - if ([str compare:@"-g"] == NSOrderedSame) { + if ([str compare:@"-g"] == NSOrderedSame) + { gotGeometry = YES; } } } - else { + else + { for (NSString * str in args) { len = (int) ([str length] + 1); @@ -1143,7 +1162,7 @@ BOOL mac_pre_connect(freerdp *inst) * ************************************************************************/ -BOOL mac_post_connect(freerdp *inst) +BOOL mac_post_connect(freerdp* inst) { uint32 flags; rdpPointer rdp_pointer; @@ -1190,6 +1209,7 @@ BOOL mac_post_connect(freerdp *inst) { fds[index] = (int)(long)rd_fds[index]; } + register_channel_fds(fds, rd_count, inst); freerdp_channels_post_connect(inst->context->channels, inst); @@ -1243,7 +1263,7 @@ void pointer_new(rdpContext* context, rdpPointer* pointer) // store cursor bitmap image in representation - required by NSImage NSBitmapImageRep *bmiRep; bmiRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:(unsigned char **) &cursor_data - pixelsWide:rect.size.width + pixelsWide:rect.size.width pixelsHigh:rect.size.height bitsPerSample:8 samplesPerPixel:sizeof(struct rgba_data) @@ -1285,7 +1305,8 @@ void pointer_free(rdpContext* context, rdpPointer* pointer) for (MRDPCursor *cursor in ma) { - if (cursor->pointer == pointer) { + if (cursor->pointer == pointer) + { cursor->nsImage = nil; cursor->nsCursor = nil; cursor->bmiRep = nil; @@ -1311,7 +1332,8 @@ void pointer_set(rdpContext* context, rdpPointer* pointer) for (MRDPCursor *cursor in ma) { - if (cursor->pointer == pointer) { + if (cursor->pointer == pointer) + { [cursor->nsCursor set]; return; } @@ -1399,7 +1421,8 @@ void mac_end_paint(rdpContext* context) gdi = g_mrdpview->rdp_context->gdi; - if (g_mrdpview->isRemoteApp && g_mrdpview->currentWindow) { + if (g_mrdpview->isRemoteApp && g_mrdpview->currentWindow) + { [[g_mrdpview->currentWindow view] updateDisplay]; return; } @@ -1415,6 +1438,7 @@ void mac_end_paint(rdpContext* context) [g_mrdpview setNeedsDisplayInRect:drawRect]; } + gdi->primary->hdc->hwnd->ninvalid = 0; } @@ -1422,15 +1446,11 @@ void mac_end_paint(rdpContext* context) * called when data is available on a socket ***********************************************************************/ -void skt_activity_cb( - CFSocketRef s, - CFSocketCallBackType callbackType, - CFDataRef address, - const void *data, - void *info - ) +void skt_activity_cb(CFSocketRef s, CFSocketCallBackType callbackType, + CFDataRef address, const void* data, void* info) { - if (!freerdp_check_fds(info)) { + if (!freerdp_check_fds(info)) + { // lost connection or did not connect [NSApp terminate:nil]; } @@ -1440,22 +1460,17 @@ void skt_activity_cb( * called when data is available on a virtual channel ***********************************************************************/ -void channel_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) { - freerdp *inst = (freerdp *) info; + freerdp* inst = (freerdp*) info; RDP_EVENT* event; - GOT_HERE; - freerdp_channels_check_fds(inst->context->channels, inst); event = freerdp_channels_pop_event(inst->context->channels); - if (event) { + + if (event) + { switch (event->event_class) { case RDP_EVENT_CLASS_RAIL: @@ -1486,6 +1501,7 @@ int register_fds(int *fds, int count, void *inst) CFRunLoopAddSource(CFRunLoopGetCurrent(), g_mrdpview->run_loop_src, kCFRunLoopDefaultMode); CFRelease(skt_ref); } + return 0; } @@ -1506,6 +1522,7 @@ int register_channel_fds(int *fds, int count, void *inst) CFRunLoopAddSource(CFRunLoopGetCurrent(), g_mrdpview->run_loop_src_channels, kCFRunLoopDefaultMode); CFRelease(skt_ref); } + return 0; } @@ -1600,10 +1617,11 @@ void cliprdr_process_cb_data_request_event(freerdp *inst) NSArray *types; int len; - event = (RDP_CB_DATA_RESPONSE_EVENT*) freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR, - RDP_EVENT_TYPE_CB_DATA_RESPONSE, NULL, NULL); + event = (RDP_CB_DATA_RESPONSE_EVENT*) freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR, RDP_EVENT_TYPE_CB_DATA_RESPONSE, NULL, NULL); + types = [NSArray arrayWithObject:NSStringPboardType]; NSString *str = [g_mrdpview->pasteboard_rd availableTypeFromArray:types]; + if (str == nil) { event->data = NULL; @@ -1617,6 +1635,7 @@ void cliprdr_process_cb_data_request_event(freerdp *inst) [data getCString:(char *) event->data maxLength:len encoding:NSUnicodeStringEncoding]; event->size = len; } + freerdp_channels_send_event(inst->context->channels, (RDP_EVENT*) event); } @@ -1641,11 +1660,11 @@ void cliprdr_process_cb_data_response_event(freerdp *inst, RDP_CB_DATA_RESPONSE_ NSString *str; NSArray *types; - if (event->size == 0) { + if (event->size == 0) return; - } - if (g_mrdpview->pasteboard_format == CB_FORMAT_TEXT || g_mrdpview->pasteboard_format == CB_FORMAT_UNICODETEXT) { + if (g_mrdpview->pasteboard_format == CB_FORMAT_TEXT || g_mrdpview->pasteboard_format == CB_FORMAT_UNICODETEXT) + { str = [[NSString alloc] initWithCharacters:(unichar *) event->data length:event->size / 2]; types = [[NSArray alloc] initWithObjects:NSStringPboardType, nil]; [g_mrdpview->pasteboard_wr declareTypes:types owner:g_mrdpview]; @@ -1720,7 +1739,8 @@ void cliprdr_process_cb_format_list_event(freerdp *inst, RDP_CB_FORMAT_LIST_EVEN void process_cliprdr_event(freerdp *inst, RDP_EVENT *event) { - if (event) { + if (event) + { switch (event->event_type) { // Monitor Ready PDU is sent by server to indicate that it has been @@ -1757,6 +1777,7 @@ void process_cliprdr_event(freerdp *inst, RDP_EVENT *event) printf("process_cliprdr_event: unknown event type %d\n", event->event_type); break; } + freerdp_event_free(event); } } @@ -1765,10 +1786,9 @@ void cliprdr_send_supported_format_list(freerdp *inst) { RDP_CB_FORMAT_LIST_EVENT* event; - event = (RDP_CB_FORMAT_LIST_EVENT*) freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR, - RDP_EVENT_TYPE_CB_FORMAT_LIST, NULL, NULL); + event = (RDP_CB_FORMAT_LIST_EVENT*) freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR, RDP_EVENT_TYPE_CB_FORMAT_LIST, NULL, NULL); - event->formats = (uint32 *) malloc(sizeof(uint32) * 1); + event->formats = (UINT32*) malloc(sizeof(uint32) * 1); event->num_formats = 1; event->formats[0] = CB_FORMAT_UNICODETEXT; freerdp_channels_send_event(inst->context->channels, (RDP_EVENT*) event); @@ -1807,12 +1827,10 @@ void mac_process_rail_event(freerdp *inst, RDP_EVENT *event) break; case RDP_EVENT_TYPE_RAIL_CHANNEL_APPID_RESP: - GOT_HERE; //xf_process_rail_appid_resp_event(xfi, channels, event); break; case RDP_EVENT_TYPE_RAIL_CHANNEL_LANGBARINFO: - GOT_HERE; //xf_process_rail_langbarinfo_event(xfi, channels, event); break; } @@ -1833,20 +1851,25 @@ void mac_rail_CreateWindow(rdpRail *rail, rdpWindow *window) window->windowHeight = g_mrdpview->height; // center main window, which is the first to be created - if ([ma count] == 0) { + if ([ma count] == 0) + { centerWindow = YES; moveWindow = YES; } - if ((window->extendedStyle & WS_EX_TOPMOST) || (window->extendedStyle & WS_EX_TOOLWINDOW)) { + if ((window->extendedStyle & WS_EX_TOPMOST) || (window->extendedStyle & WS_EX_TOOLWINDOW)) + { [g_mrdpview->currentWindow view]->skipMoveWindowOnce = TRUE; moveWindow = YES; } - else if (window->style & WS_POPUP) { + else if (window->style & WS_POPUP) + { centerWindow = YES; moveWindow = YES; } - else { + else + { + } // create NSWindow @@ -1891,7 +1914,8 @@ void mac_rail_CreateWindow(rdpRail *rail, rdpWindow *window) // make new window current g_mrdpview->currentWindow = mrdpWindow; - if (displayAsModal) { + if (displayAsModal) + { // display as modal window NSModalSession session = [NSApp beginModalSessionForWindow:newWindow]; while (1) @@ -1913,7 +1937,8 @@ void mac_rail_CreateWindow(rdpRail *rail, rdpWindow *window) void mac_rail_MoveWindow(rdpRail *rail, rdpWindow *window) { - if (g_mrdpview->currentWindow) { + if (g_mrdpview->currentWindow) + { rail_MoveWindow(rail, window); return; } @@ -1971,10 +1996,8 @@ void mac_rail_DestroyWindow(rdpRail *rail, rdpWindow *window) } void mac_rail_register_callbacks(freerdp *inst, rdpRail *rail) -{ - GOT_HERE; - - rail->extra = (void *) inst; +{ + rail->extra = (void*) inst; rail->rail_CreateWindow = mac_rail_CreateWindow; rail->rail_MoveWindow = mac_rail_MoveWindow; rail->rail_ShowWindow = mac_rail_ShowWindow; @@ -1990,10 +2013,10 @@ void mac_rail_register_callbacks(freerdp *inst, rdpRail *rail) * by the system taskbar or by application desktop toolbars ************************************************************************/ -void mac_process_rail_get_sysparams_event(rdpChannels *channels, RDP_EVENT *event) +void mac_process_rail_get_sysparams_event(rdpChannels* channels, RDP_EVENT* event) { RAIL_SYSPARAM_ORDER * sysparam; - sysparam = (RAIL_SYSPARAM_ORDER *) event->user_data; + sysparam = (RAIL_SYSPARAM_ORDER*) event->user_data; sysparam->workArea.left = 0; sysparam->workArea.top = 22; @@ -2014,8 +2037,6 @@ void mac_process_rail_server_sysparam_event(rdpChannels* channels, RDP_EVENT* ev { RAIL_SYSPARAM_ORDER* sysparam = (RAIL_SYSPARAM_ORDER*) event->user_data; - GOT_HERE; - switch (sysparam->param) { case SPI_SET_SCREEN_SAVE_ACTIVE: @@ -2034,17 +2055,17 @@ void mac_process_rail_exec_result_event(rdpChannels* channels, RDP_EVENT* event) { RAIL_EXEC_RESULT_ORDER* exec_result; - GOT_HERE; - exec_result = (RAIL_EXEC_RESULT_ORDER*) event->user_data; - if (exec_result->execResult != RAIL_EXEC_S_OK) { + if (exec_result->execResult != RAIL_EXEC_S_OK) + { printf("RAIL exec error: execResult=%s NtError=0x%X\n", error_code_names[exec_result->execResult], exec_result->rawResult); g_mrdpview->is_connected = FALSE; [g_mrdpview rdpRemoteAppError]; } - else { + else + { mac_rail_enable_remoteapp_mode(); } } @@ -2073,10 +2094,11 @@ void mac_process_rail_server_minmaxinfo_event(rdpChannels* channels, RDP_EVENT* void mac_process_rail_server_localmovesize_event(freerdp *inst, RDP_EVENT *event) { - RAIL_LOCALMOVESIZE_ORDER * moveSize = (RAIL_LOCALMOVESIZE_ORDER *) event->user_data; + RAIL_LOCALMOVESIZE_ORDER* moveSize = (RAIL_LOCALMOVESIZE_ORDER*) event->user_data; RAIL_WINDOW_MOVE_ORDER windowMove; - switch (moveSize->moveSizeType) { + switch (moveSize->moveSizeType) + { case RAIL_WMSZ_LEFT: printf("!!!! RAIL_WMSZ_LEFT\n"); break; @@ -2110,7 +2132,8 @@ void mac_process_rail_server_localmovesize_event(freerdp *inst, RDP_EVENT *event break; case RAIL_WMSZ_MOVE: - if (moveSize->isMoveSizeStart) { + if (moveSize->isMoveSizeStart) + { // local window move in progress [g_mrdpview->currentWindow view]->isMoveSizeInProgress = YES; [g_mrdpview->currentWindow view]->saveInitialDragLoc = YES; @@ -2141,28 +2164,26 @@ void mac_process_rail_server_localmovesize_event(freerdp *inst, RDP_EVENT *event default: break; } + return; } void mac_send_rail_client_event(rdpChannels *channels, uint16 event_type, void *param) { - RDP_EVENT *out_event = NULL; - void *payload = NULL; - - GOT_HERE; + RDP_EVENT* out_event = NULL; + void* payload = NULL; payload = rail_clone_order(event_type, param); - if (payload != NULL) { - out_event = freerdp_event_new(RDP_EVENT_CLASS_RAIL, event_type, - mac_on_free_rail_client_event, payload); + + if (payload != NULL) + { + out_event = freerdp_event_new(RDP_EVENT_CLASS_RAIL, event_type, mac_on_free_rail_client_event, payload); freerdp_channels_send_event(channels, out_event); } } void mac_on_free_rail_client_event(RDP_EVENT* event) -{ - GOT_HERE; - +{ if (event->event_class == RDP_EVENT_CLASS_RAIL) { rail_free_cloned_order(event->event_type, event->user_data); @@ -2170,9 +2191,7 @@ void mac_on_free_rail_client_event(RDP_EVENT* event) } void mac_rail_enable_remoteapp_mode() -{ - GOT_HERE; - +{ if (!g_mrdpview->isRemoteApp) g_mrdpview->isRemoteApp = TRUE; } From e4f1ef06207ede69e5ba6692d8284addd22ae961 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 21 Feb 2013 23:07:35 -0500 Subject: [PATCH 4/6] mfreerdp: cleanup --- client/Mac/MRDPView.m | 339 +++++++++++++++++++++--------------------- 1 file changed, 169 insertions(+), 170 deletions(-) diff --git a/client/Mac/MRDPView.m b/client/Mac/MRDPView.m index 5cc79c445..9b7b377be 100644 --- a/client/Mac/MRDPView.m +++ b/client/Mac/MRDPView.m @@ -44,6 +44,7 @@ MRDPView *g_mrdpview; @synthesize is_connected; struct kkey g_keys[]; + void convert_color_space(char *dest, char *src, NSRect* drawRect, int width, int height); const char* error_code_names[] = @@ -441,7 +442,7 @@ struct kkey g_keys[256] = - (void) scrollWheel:(NSEvent *)event { - uint16 flags; + UINT16 flags; [super scrollWheel:event]; @@ -543,13 +544,12 @@ struct kkey g_keys[256] = * called when shift, control, alt and meta keys are pressed/released ***********************************************************************/ -- (void) flagsChanged:(NSEvent *) event +- (void) flagsChanged:(NSEvent*) event { NSUInteger mf = [event modifierFlags]; - if (!is_connected) { + if (!is_connected) return; - } // caps lock if (mf == 0x10100) { @@ -729,8 +729,8 @@ struct kkey g_keys[256] = - (void) my_draw_rect:(void*)context { - int w; - int h; + int w; + int h; rdpContext* ctx = (rdpContext*) context; @@ -875,10 +875,10 @@ struct kkey g_keys[256] = [NSApp terminate:nil]; } -- (void) onPasteboardTimerFired :(NSTimer *) timer +- (void) onPasteboardTimerFired :(NSTimer*) timer { - NSArray *types; - int i; + int i; + NSArray* types; i = (int) [pasteboard_rd changeCount]; @@ -942,7 +942,7 @@ struct kkey g_keys[256] = } // RAIL_TODO is this func required -- (void) windowDidResize:(NSNotification *) notification +- (void) windowDidResize:(NSNotification*) notification { RAIL_WINDOW_MOVE_ORDER windowMove; @@ -964,10 +964,10 @@ struct kkey g_keys[256] = windowMove.windowId = [currentWindow windowID]; - windowMove.left = (uint16) r.origin.x; // x-cordinate of top left corner - windowMove.right = (uint16) (windowMove.left + r.size.width); // x-cordinate of bottom right corner - windowMove.top = (uint16) r.origin.y; // y-cordinate of top left corner - windowMove.bottom = (uint16) (windowMove.top + r.size.height); // y-cordinate of bottom right corner + windowMove.left = (UINT16) r.origin.x; // x-cordinate of top left corner + windowMove.right = (UINT16) (windowMove.left + r.size.width); // x-cordinate of bottom right corner + windowMove.top = (UINT16) r.origin.y; // y-cordinate of top left corner + windowMove.bottom = (UINT16) (windowMove.top + r.size.height); // y-cordinate of bottom right corner printf("----- LK_TODO: MRDPView:windowDidResize windowID=%d left=%d top=%d right=%d bottom=x%d width=%f height=%f\n", [currentWindow windowID], windowMove.left, windowMove.top, windowMove.right, windowMove.bottom, r.size.width, r.size.height); @@ -989,25 +989,25 @@ struct kkey g_keys[256] = int rdp_connect() { - freerdp *inst; - int status; + int status; + freerdp* instance; freerdp_channels_global_init(); - inst = freerdp_new(); - inst->PreConnect = mac_pre_connect; - inst->PostConnect = mac_post_connect; - inst->context_size = sizeof(struct mac_context); - inst->ContextNew = mac_context_new; - inst->ContextFree = mac_context_free; - inst->ReceiveChannelData = receive_channel_data; - freerdp_context_new(inst); + instance = freerdp_new(); + instance->PreConnect = mac_pre_connect; + instance->PostConnect = mac_post_connect; + instance->context_size = sizeof(struct mac_context); + instance->ContextNew = mac_context_new; + instance->ContextFree = mac_context_free; + instance->ReceiveChannelData = receive_channel_data; + freerdp_context_new(instance); - status = freerdp_connect(inst); + status = freerdp_connect(instance); if (status) { - freerdp_check_fds(inst); + freerdp_check_fds(instance); [g_mrdpview setIs_connected:1]; return 0; } @@ -1027,51 +1027,51 @@ int rdp_connect() * @return true if successful. false otherwise. ************************************************************************/ -BOOL mac_pre_connect(freerdp *inst) +BOOL mac_pre_connect(freerdp* instance) { + int i; + int len; int status; - char *cptr; - int len; - int i; + char* cptr; - inst->settings->OffscreenSupportLevel = FALSE; - inst->settings->GlyphSupportLevel = GLYPH_SUPPORT_FULL; - inst->settings->OrderSupport[NEG_GLYPH_INDEX_INDEX] = TRUE; - inst->settings->OrderSupport[NEG_FAST_GLYPH_INDEX] = FALSE; - inst->settings->OrderSupport[NEG_FAST_INDEX_INDEX] = FALSE; - inst->settings->OrderSupport[NEG_SCRBLT_INDEX] = TRUE; - inst->settings->OrderSupport[NEG_SAVEBITMAP_INDEX] = FALSE; + instance->settings->OffscreenSupportLevel = FALSE; + instance->settings->GlyphSupportLevel = GLYPH_SUPPORT_FULL; + instance->settings->OrderSupport[NEG_GLYPH_INDEX_INDEX] = TRUE; + instance->settings->OrderSupport[NEG_FAST_GLYPH_INDEX] = FALSE; + instance->settings->OrderSupport[NEG_FAST_INDEX_INDEX] = FALSE; + instance->settings->OrderSupport[NEG_SCRBLT_INDEX] = TRUE; + instance->settings->OrderSupport[NEG_SAVEBITMAP_INDEX] = FALSE; - inst->settings->BitmapCacheEnabled = TRUE; - inst->settings->OrderSupport[NEG_MEMBLT_INDEX] = TRUE; - inst->settings->OrderSupport[NEG_MEMBLT_V2_INDEX] = TRUE; - inst->settings->OrderSupport[NEG_MEM3BLT_INDEX] = FALSE; - inst->settings->OrderSupport[NEG_MEM3BLT_V2_INDEX] = FALSE; - inst->settings->BitmapCacheV2NumCells = 3; // 5; - inst->settings->BitmapCacheV2CellInfo[0].numEntries = 0x78; // 600; - inst->settings->BitmapCacheV2CellInfo[0].persistent = FALSE; - inst->settings->BitmapCacheV2CellInfo[1].numEntries = 0x78; // 600; - inst->settings->BitmapCacheV2CellInfo[1].persistent = FALSE; - inst->settings->BitmapCacheV2CellInfo[2].numEntries = 0x150; // 2048; - inst->settings->BitmapCacheV2CellInfo[2].persistent = FALSE; - inst->settings->BitmapCacheV2CellInfo[3].numEntries = 0; // 4096; - inst->settings->BitmapCacheV2CellInfo[3].persistent = FALSE; - inst->settings->BitmapCacheV2CellInfo[4].numEntries = 0; // 2048; - inst->settings->BitmapCacheV2CellInfo[4].persistent = FALSE; + instance->settings->BitmapCacheEnabled = TRUE; + instance->settings->OrderSupport[NEG_MEMBLT_INDEX] = TRUE; + instance->settings->OrderSupport[NEG_MEMBLT_V2_INDEX] = TRUE; + instance->settings->OrderSupport[NEG_MEM3BLT_INDEX] = FALSE; + instance->settings->OrderSupport[NEG_MEM3BLT_V2_INDEX] = FALSE; + instance->settings->BitmapCacheV2NumCells = 3; // 5; + instance->settings->BitmapCacheV2CellInfo[0].numEntries = 0x78; // 600; + instance->settings->BitmapCacheV2CellInfo[0].persistent = FALSE; + instance->settings->BitmapCacheV2CellInfo[1].numEntries = 0x78; // 600; + instance->settings->BitmapCacheV2CellInfo[1].persistent = FALSE; + instance->settings->BitmapCacheV2CellInfo[2].numEntries = 0x150; // 2048; + instance->settings->BitmapCacheV2CellInfo[2].persistent = FALSE; + instance->settings->BitmapCacheV2CellInfo[3].numEntries = 0; // 4096; + instance->settings->BitmapCacheV2CellInfo[3].persistent = FALSE; + instance->settings->BitmapCacheV2CellInfo[4].numEntries = 0; // 2048; + instance->settings->BitmapCacheV2CellInfo[4].persistent = FALSE; - inst->settings->OrderSupport[NEG_MULTIDSTBLT_INDEX] = FALSE; - inst->settings->OrderSupport[NEG_MULTIPATBLT_INDEX] = FALSE; - inst->settings->OrderSupport[NEG_MULTISCRBLT_INDEX] = FALSE; - inst->settings->OrderSupport[NEG_MULTIOPAQUERECT_INDEX] = FALSE; - inst->settings->OrderSupport[NEG_POLYLINE_INDEX] = FALSE; - inst->settings->ColorDepth = 24; - inst->settings->SoftwareGdi = 1; + instance->settings->OrderSupport[NEG_MULTIDSTBLT_INDEX] = FALSE; + instance->settings->OrderSupport[NEG_MULTIPATBLT_INDEX] = FALSE; + instance->settings->OrderSupport[NEG_MULTISCRBLT_INDEX] = FALSE; + instance->settings->OrderSupport[NEG_MULTIOPAQUERECT_INDEX] = FALSE; + instance->settings->OrderSupport[NEG_POLYLINE_INDEX] = FALSE; + instance->settings->ColorDepth = 24; + instance->settings->SoftwareGdi = 1; // setup callbacks - inst->update->BeginPaint = mac_begin_paint; - inst->update->EndPaint = mac_end_paint; - inst->update->SetBounds = mac_set_bounds; - inst->update->BitmapUpdate = mac_bitmap_update; + instance->update->BeginPaint = mac_begin_paint; + instance->update->EndPaint = mac_end_paint; + instance->update->SetBounds = mac_set_bounds; + instance->update->BitmapUpdate = mac_bitmap_update; NSArray *args = [[NSProcessInfo processInfo] arguments]; @@ -1093,10 +1093,10 @@ BOOL mac_pre_connect(freerdp *inst) // get dimensions of screen that has keyboard focus; // we use these dimensions when connecting to RDP server - inst->settings->DesktopWidth = [[NSScreen mainScreen] frame].size.width; - inst->settings->DesktopHeight = [[NSScreen mainScreen] frame].size.height - g_mrdpview->titleBarHeight; - g_mrdpview->width = inst->settings->DesktopWidth; - g_mrdpview->height = inst->settings->DesktopHeight; + instance->settings->DesktopWidth = [[NSScreen mainScreen] frame].size.width; + instance->settings->DesktopHeight = [[NSScreen mainScreen] frame].size.height - g_mrdpview->titleBarHeight; + g_mrdpview->width = instance->settings->DesktopWidth; + g_mrdpview->height = instance->settings->DesktopHeight; for (NSString * str in args) { @@ -1132,10 +1132,10 @@ BOOL mac_pre_connect(freerdp *inst) } } - inst->context->argc = g_mrdpview->argc; - inst->context->argv = g_mrdpview->argv; + instance->context->argc = g_mrdpview->argc; + instance->context->argv = g_mrdpview->argv; - status = freerdp_client_parse_command_line_arguments(inst->context->argc, inst->context->argv, inst->settings); + status = freerdp_client_parse_command_line_arguments(instance->context->argc, instance->context->argv, instance->settings); if (status < 0) { @@ -1143,11 +1143,11 @@ BOOL mac_pre_connect(freerdp *inst) return TRUE; } - freerdp_client_load_addins(inst->context->channels, inst->settings); + freerdp_client_load_addins(instance->context->channels, instance->settings); - [g_mrdpview setViewSize:inst->settings->DesktopWidth :inst->settings->DesktopHeight]; + [g_mrdpview setViewSize:instance->settings->DesktopWidth :instance->settings->DesktopHeight]; - freerdp_channels_pre_connect(inst->context->channels, inst); + freerdp_channels_pre_connect(instance->context->channels, instance); return TRUE; } @@ -1162,16 +1162,16 @@ BOOL mac_pre_connect(freerdp *inst) * ************************************************************************/ -BOOL mac_post_connect(freerdp* inst) +BOOL mac_post_connect(freerdp* instance) { - uint32 flags; + int index; + int fds[32]; + UINT32 flags; + int rd_count = 0; + int wr_count = 0; + void* rd_fds[32]; + void* wr_fds[32]; rdpPointer rdp_pointer; - void *rd_fds[32]; - void *wr_fds[32]; - int rd_count = 0; - int wr_count = 0; - int index; - int fds[32]; memset(&rdp_pointer, 0, sizeof(rdpPointer)); rdp_pointer.size = sizeof(rdpPointer); @@ -1184,12 +1184,12 @@ BOOL mac_post_connect(freerdp* inst) flags = CLRCONV_ALPHA; flags |= CLRBUF_32BPP; - gdi_init(inst, flags, NULL); - pointer_cache_register_callbacks(inst->update); - graphics_register_pointer(inst->context->graphics, &rdp_pointer); + gdi_init(instance, flags, NULL); + pointer_cache_register_callbacks(instance->update); + graphics_register_pointer(instance->context->graphics, &rdp_pointer); // register file descriptors with the RunLoop - if (!freerdp_get_fds(inst, rd_fds, &rd_count, 0, 0)) + if (!freerdp_get_fds(instance, rd_fds, &rd_count, 0, 0)) { printf("mac_post_connect: freerdp_get_fds() failed!\n"); } @@ -1198,10 +1198,10 @@ BOOL mac_post_connect(freerdp* inst) { fds[index] = (int)(long)rd_fds[index]; } - register_fds(fds, rd_count, inst); + register_fds(fds, rd_count, instance); // register channel manager file descriptors with the RunLoop - if (!freerdp_channels_get_fds(inst->context->channels, inst, rd_fds, &rd_count, wr_fds, &wr_count)) + if (!freerdp_channels_get_fds(instance->context->channels, instance, rd_fds, &rd_count, wr_fds, &wr_count)) { printf("ERROR: freerdp_channels_get_fds() failed\n"); } @@ -1210,13 +1210,13 @@ BOOL mac_post_connect(freerdp* inst) fds[index] = (int)(long)rd_fds[index]; } - register_channel_fds(fds, rd_count, inst); - freerdp_channels_post_connect(inst->context->channels, inst); + register_channel_fds(fds, rd_count, instance); + freerdp_channels_post_connect(instance->context->channels, instance); // setup RAIL (remote app) - inst->context->rail = rail_new(inst->settings); - rail_register_update_callbacks(inst->context->rail, inst->update); - mac_rail_register_callbacks(inst, inst->context->rail); + instance->context->rail = rail_new(instance->settings); + rail_register_update_callbacks(instance->context->rail, instance->update); + mac_rail_register_callbacks(instance, instance->context->rail); // setup pasteboard (aka clipboard) for copy operations (write only) g_mrdpview->pasteboard_wr = [NSPasteboard generalPasteboard]; @@ -1242,8 +1242,8 @@ BOOL mac_post_connect(freerdp* inst) void pointer_new(rdpContext* context, rdpPointer* pointer) { + BYTE* cursor_data; MRDPCursor *mrdpCursor = [[MRDPCursor alloc] init]; - uint8 *cursor_data; NSRect rect; rect.size.width = pointer->width; @@ -1301,9 +1301,9 @@ void pointer_new(rdpContext* context, rdpPointer* pointer) void pointer_free(rdpContext* context, rdpPointer* pointer) { - NSMutableArray *ma = g_mrdpview->cursors; + NSMutableArray* ma = g_mrdpview->cursors; - for (MRDPCursor *cursor in ma) + for (MRDPCursor* cursor in ma) { if (cursor->pointer == pointer) { @@ -1323,14 +1323,12 @@ void pointer_free(rdpContext* context, rdpPointer* pointer) void pointer_set(rdpContext* context, rdpPointer* pointer) { - NSMutableArray *ma = g_mrdpview->cursors; + NSMutableArray* ma = g_mrdpview->cursors; if (!g_mrdpview->mouseInClientArea) - { - return; // not in client area - } + return; - for (MRDPCursor *cursor in ma) + for (MRDPCursor* cursor in ma) { if (cursor->pointer == pointer) { @@ -1360,9 +1358,9 @@ void pointer_setDefault(rdpContext* context) * create a new context - but all we really need to do is save state info ***********************************************************************/ -void mac_context_new(freerdp *inst, rdpContext *context) +void mac_context_new(freerdp* instance, rdpContext* context) { - [g_mrdpview saveStateInfo:inst :context]; + [g_mrdpview saveStateInfo:instance :context]; context->channels = freerdp_channels_new(); } @@ -1370,7 +1368,7 @@ void mac_context_new(freerdp *inst, rdpContext *context) * we don't do much over here ***********************************************************************/ -void mac_context_free(freerdp *inst, rdpContext *context) +void mac_context_free(freerdp* instance, rdpContext* context) { } @@ -1378,7 +1376,7 @@ void mac_context_free(freerdp *inst, rdpContext *context) * clip drawing surface so nothing is drawn outside specified bounds ***********************************************************************/ -void mac_set_bounds(rdpContext *context, rdpBounds *bounds) +void mac_set_bounds(rdpContext* context, rdpBounds* bounds) { } @@ -1386,7 +1384,7 @@ void mac_set_bounds(rdpContext *context, rdpBounds *bounds) * we don't do much over here ***********************************************************************/ -void mac_bitmap_update(rdpContext *context, BITMAP_UPDATE *bitmap) +void mac_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmap) { } @@ -1394,7 +1392,7 @@ void mac_bitmap_update(rdpContext *context, BITMAP_UPDATE *bitmap) * we don't do much over here ***********************************************************************/ -void mac_begin_paint(rdpContext *context) +void mac_begin_paint(rdpContext* context) { rdpGdi* gdi = context->gdi; gdi->primary->hdc->hwnd->invalid->null = 1; @@ -1406,9 +1404,9 @@ void mac_begin_paint(rdpContext *context) void mac_end_paint(rdpContext* context) { - int i; - NSRect drawRect; - rdpGdi * gdi; + int i; + rdpGdi* gdi; + NSRect drawRect; if ((context == 0) || (context->gdi == 0)) return; @@ -1463,22 +1461,22 @@ void skt_activity_cb(CFSocketRef s, CFSocketCallBackType callbackType, void channel_activity_cb(CFSocketRef s, CFSocketCallBackType callbackType, CFDataRef address, const void* data, void* info) { - freerdp* inst = (freerdp*) info; RDP_EVENT* event; + freerdp* instance = (freerdp*) info; - freerdp_channels_check_fds(inst->context->channels, inst); - event = freerdp_channels_pop_event(inst->context->channels); + freerdp_channels_check_fds(instance->context->channels, instance); + event = freerdp_channels_pop_event(instance->context->channels); if (event) { switch (event->event_class) { case RDP_EVENT_CLASS_RAIL: - mac_process_rail_event(inst, event); + mac_process_rail_event(instance, event); break; case RDP_EVENT_CLASS_CLIPRDR: - process_cliprdr_event(inst, event); + process_cliprdr_event(instance, event); break; } } @@ -1488,11 +1486,11 @@ void channel_activity_cb(CFSocketRef s, CFSocketCallBackType callbackType, * setup callbacks for data availability on sockets ***********************************************************************/ -int register_fds(int *fds, int count, void *inst) +int register_fds(int* fds, int count, void* instance) { int i; CFSocketRef skt_ref; - CFSocketContext skt_context = { 0, inst, NULL, NULL, NULL }; + CFSocketContext skt_context = { 0, instance, NULL, NULL, NULL }; for (i = 0; i < count; i++) { @@ -1509,11 +1507,11 @@ int register_fds(int *fds, int count, void *inst) * setup callbacks for data availability on channels ***********************************************************************/ -int register_channel_fds(int *fds, int count, void *inst) +int register_channel_fds(int* fds, int count, void* instance) { int i; CFSocketRef skt_ref; - CFSocketContext skt_context = { 0, inst, NULL, NULL, NULL }; + CFSocketContext skt_context = { 0, instance, NULL, NULL, NULL }; for (i = 0; i < count; i++) { @@ -1530,16 +1528,16 @@ int register_channel_fds(int *fds, int count, void *inst) * called when channel data is available ***********************************************************************/ -int receive_channel_data(freerdp *inst, int chan_id, uint8 *data, int size, int flags, int total_size) +int receive_channel_data(freerdp* instance, int chan_id, BYTE* data, int size, int flags, int total_size) { - return freerdp_channels_data(inst, chan_id, data, size, flags, total_size); + return freerdp_channels_data(instance, chan_id, data, size, flags, total_size); } /** ********************************************************************* * convert an array containing ARGB data to RGBA ***********************************************************************/ -void convert_color_space(char *dest, char *src, NSRect* drawRect, int width, int height) +void convert_color_space(char* dest, char* src, NSRect* drawRect, int width, int height) { int i; int j; @@ -1553,9 +1551,8 @@ void convert_color_space(char *dest, char *src, NSRect* drawRect, int width, int int* src32; int* dst32; - if ((!dest) || (!src)) { + if ((!dest) || (!src)) return; - } x = drawRect->origin.x; y = drawRect->origin.y; @@ -1566,6 +1563,7 @@ void convert_color_space(char *dest, char *src, NSRect* drawRect, int width, int { src32 = (int*)(src + ((y + j) * width + x) * 4); dst32 = (int*)(dest + ((y + j) * width + x) * 4); + for (i = 0; i < cx; i++) { pixel = *src32; @@ -1600,6 +1598,7 @@ int process_plugin_args(rdpSettings* settings, const char* name, RDP_PLUGIN_DATA rdpChannels* channels = (rdpChannels*) user_data; freerdp_channels_load_plugin(channels, settings, name, plugin_data); + return 1; } @@ -1611,16 +1610,16 @@ int process_plugin_args(rdpSettings* settings, const char* name, RDP_PLUGIN_DATA * remote system has requested clipboard data from local system */ -void cliprdr_process_cb_data_request_event(freerdp *inst) +void cliprdr_process_cb_data_request_event(freerdp* instance) { - RDP_CB_DATA_RESPONSE_EVENT *event; - NSArray *types; - int len; + int len; + NSArray* types; + RDP_CB_DATA_RESPONSE_EVENT* event; event = (RDP_CB_DATA_RESPONSE_EVENT*) freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR, RDP_EVENT_TYPE_CB_DATA_RESPONSE, NULL, NULL); types = [NSArray arrayWithObject:NSStringPboardType]; - NSString *str = [g_mrdpview->pasteboard_rd availableTypeFromArray:types]; + NSString* str = [g_mrdpview->pasteboard_rd availableTypeFromArray:types]; if (str == nil) { @@ -1629,24 +1628,24 @@ void cliprdr_process_cb_data_request_event(freerdp *inst) } else { - NSString *data = [g_mrdpview->pasteboard_rd stringForType:NSStringPboardType]; + NSString* data = [g_mrdpview->pasteboard_rd stringForType:NSStringPboardType]; len = (int) ([data length] * 2 + 2); event->data = malloc(len); [data getCString:(char *) event->data maxLength:len encoding:NSUnicodeStringEncoding]; event->size = len; } - freerdp_channels_send_event(inst->context->channels, (RDP_EVENT*) event); + freerdp_channels_send_event(instance->context->channels, (RDP_EVENT*) event); } -void cliprdr_send_data_request(freerdp *inst, uint32 format) +void cliprdr_send_data_request(freerdp* instance, UINT32 format) { RDP_CB_DATA_REQUEST_EVENT* event; - event = (RDP_CB_DATA_REQUEST_EVENT *) freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR, - RDP_EVENT_TYPE_CB_DATA_REQUEST, NULL, NULL); + event = (RDP_CB_DATA_REQUEST_EVENT*) freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR, RDP_EVENT_TYPE_CB_DATA_REQUEST, NULL, NULL); + event->format = format; - freerdp_channels_send_event(inst->context->channels, (RDP_EVENT*) event); + freerdp_channels_send_event(instance->context->channels, (RDP_EVENT*) event); } /** @@ -1655,10 +1654,10 @@ void cliprdr_send_data_request(freerdp *inst, uint32 format) * CB_FORMAT_UNICODETEXT */ -void cliprdr_process_cb_data_response_event(freerdp *inst, RDP_CB_DATA_RESPONSE_EVENT *event) +void cliprdr_process_cb_data_response_event(freerdp* instance, RDP_CB_DATA_RESPONSE_EVENT* event) { - NSString *str; - NSArray *types; + NSString* str; + NSArray* types; if (event->size == 0) return; @@ -1672,7 +1671,7 @@ void cliprdr_process_cb_data_response_event(freerdp *inst, RDP_CB_DATA_RESPONSE_ } } -void cliprdr_process_cb_monitor_ready_event(freerdp* inst) +void cliprdr_process_cb_monitor_ready_event(freerdp* instance) { RDP_EVENT* event; RDP_CB_FORMAT_LIST_EVENT* format_list_event; @@ -1682,7 +1681,7 @@ void cliprdr_process_cb_monitor_ready_event(freerdp* inst) format_list_event = (RDP_CB_FORMAT_LIST_EVENT*)event; format_list_event->num_formats = 0; - freerdp_channels_send_event(inst->context->channels, event); + freerdp_channels_send_event(instance->context->channels, event); } /** @@ -1691,13 +1690,12 @@ void cliprdr_process_cb_monitor_ready_event(freerdp* inst) * CB_FORMAT_UNICODETEXT */ -void cliprdr_process_cb_format_list_event(freerdp *inst, RDP_CB_FORMAT_LIST_EVENT* event) +void cliprdr_process_cb_format_list_event(freerdp* instance, RDP_CB_FORMAT_LIST_EVENT* event) { int i; - if (event->num_formats == 0) { + if (event->num_formats == 0) return; - } for (i = 0; i < event->num_formats; i++) { @@ -1710,7 +1708,7 @@ void cliprdr_process_cb_format_list_event(freerdp *inst, RDP_CB_FORMAT_LIST_EVEN case CB_FORMAT_TEXT: case CB_FORMAT_UNICODETEXT: g_mrdpview->pasteboard_format = CB_FORMAT_UNICODETEXT; - cliprdr_send_data_request(inst, CB_FORMAT_UNICODETEXT); + cliprdr_send_data_request(instance, CB_FORMAT_UNICODETEXT); return; break; @@ -1737,7 +1735,7 @@ void cliprdr_process_cb_format_list_event(freerdp *inst, RDP_CB_FORMAT_LIST_EVEN } } -void process_cliprdr_event(freerdp *inst, RDP_EVENT *event) +void process_cliprdr_event(freerdp* instance, RDP_EVENT* event) { if (event) { @@ -1747,7 +1745,7 @@ void process_cliprdr_event(freerdp *inst, RDP_EVENT *event) // inited and is ready. This PDU is transmitted by the server after it has sent // Clipboard Capabilities PDU case RDP_EVENT_TYPE_CB_MONITOR_READY: - cliprdr_process_cb_monitor_ready_event(inst); + cliprdr_process_cb_monitor_ready_event(instance); break; // The Format List PDU is sent either by the client or the server when its @@ -1755,14 +1753,14 @@ void process_cliprdr_event(freerdp *inst, RDP_EVENT *event) // contains the Clipboard Format ID and name pairs of the new Clipboard // Formats on the clipboard case RDP_EVENT_TYPE_CB_FORMAT_LIST: - cliprdr_process_cb_format_list_event(inst, (RDP_CB_FORMAT_LIST_EVENT*) event); + cliprdr_process_cb_format_list_event(instance, (RDP_CB_FORMAT_LIST_EVENT*) event); break; // The Format Data Request PDU is sent by the receipient of the Format List PDU. // It is used to request the data for one of the formats that was listed in the // Format List PDU case RDP_EVENT_TYPE_CB_DATA_REQUEST: - cliprdr_process_cb_data_request_event(inst); + cliprdr_process_cb_data_request_event(instance); break; // The Format Data Response PDU is sent as a reply to the Format Data Request PDU. @@ -1770,7 +1768,7 @@ void process_cliprdr_event(freerdp *inst, RDP_EVENT *event) // was successful. If the processing was successful, the Format Data Response PDU // includes the contents of the requested clipboard data case RDP_EVENT_TYPE_CB_DATA_RESPONSE: - cliprdr_process_cb_data_response_event(inst, (RDP_CB_DATA_RESPONSE_EVENT*) event); + cliprdr_process_cb_data_response_event(instance, (RDP_CB_DATA_RESPONSE_EVENT*) event); break; default: @@ -1782,16 +1780,17 @@ void process_cliprdr_event(freerdp *inst, RDP_EVENT *event) } } -void cliprdr_send_supported_format_list(freerdp *inst) +void cliprdr_send_supported_format_list(freerdp* instance) { RDP_CB_FORMAT_LIST_EVENT* event; event = (RDP_CB_FORMAT_LIST_EVENT*) freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR, RDP_EVENT_TYPE_CB_FORMAT_LIST, NULL, NULL); - event->formats = (UINT32*) malloc(sizeof(uint32) * 1); + event->formats = (UINT32*) malloc(sizeof(UINT32) * 1); event->num_formats = 1; event->formats[0] = CB_FORMAT_UNICODETEXT; - freerdp_channels_send_event(inst->context->channels, (RDP_EVENT*) event); + + freerdp_channels_send_event(instance->context->channels, (RDP_EVENT*) event); } /**************************************************************************************** @@ -1802,28 +1801,28 @@ void cliprdr_send_supported_format_list(freerdp *inst) * * ****************************************************************************************/ -void mac_process_rail_event(freerdp *inst, RDP_EVENT *event) +void mac_process_rail_event(freerdp* instance, RDP_EVENT* event) { switch (event->event_type) { case RDP_EVENT_TYPE_RAIL_CHANNEL_GET_SYSPARAMS: - mac_process_rail_get_sysparams_event(inst->context->channels, event); + mac_process_rail_get_sysparams_event(instance->context->channels, event); break; case RDP_EVENT_TYPE_RAIL_CHANNEL_EXEC_RESULTS: - mac_process_rail_exec_result_event(inst->context->channels, event); + mac_process_rail_exec_result_event(instance->context->channels, event); break; case RDP_EVENT_TYPE_RAIL_CHANNEL_SERVER_SYSPARAM: - mac_process_rail_server_sysparam_event(inst->context->channels, event); + mac_process_rail_server_sysparam_event(instance->context->channels, event); break; case RDP_EVENT_TYPE_RAIL_CHANNEL_SERVER_MINMAXINFO: - mac_process_rail_server_minmaxinfo_event(inst->context->channels, event); + mac_process_rail_server_minmaxinfo_event(instance->context->channels, event); break; case RDP_EVENT_TYPE_RAIL_CHANNEL_SERVER_LOCALMOVESIZE: - mac_process_rail_server_localmovesize_event(inst, event); + mac_process_rail_server_localmovesize_event(instance, event); break; case RDP_EVENT_TYPE_RAIL_CHANNEL_APPID_RESP: @@ -1836,7 +1835,7 @@ void mac_process_rail_event(freerdp *inst, RDP_EVENT *event) } } -void mac_rail_CreateWindow(rdpRail *rail, rdpWindow *window) +void mac_rail_CreateWindow(rdpRail* rail, rdpWindow* window) { BOOL centerWindow = NO; BOOL moveWindow = NO; @@ -2092,7 +2091,7 @@ void mac_process_rail_server_minmaxinfo_event(rdpChannels* channels, RDP_EVENT* * corresponding local window ************************************************************************/ -void mac_process_rail_server_localmovesize_event(freerdp *inst, RDP_EVENT *event) +void mac_process_rail_server_localmovesize_event(freerdp* instance, RDP_EVENT *event) { RAIL_LOCALMOVESIZE_ORDER* moveSize = (RAIL_LOCALMOVESIZE_ORDER*) event->user_data; RAIL_WINDOW_MOVE_ORDER windowMove; @@ -2146,7 +2145,7 @@ void mac_process_rail_server_localmovesize_event(freerdp *inst, RDP_EVENT *event [g_mrdpview->currentWindow view]->saveInitialDragLoc = NO; // let RDP server know where this window is located - mac_send_rail_client_event(inst->context->channels, RDP_EVENT_TYPE_RAIL_CLIENT_WINDOW_MOVE, &windowMove); + mac_send_rail_client_event(instance->context->channels, RDP_EVENT_TYPE_RAIL_CLIENT_WINDOW_MOVE, &windowMove); // the event we just sent will cause an extra MoveWindow() to be invoked which we need to ignore [g_mrdpview->currentWindow view]->skipMoveWindowOnce = YES; @@ -2168,7 +2167,7 @@ void mac_process_rail_server_localmovesize_event(freerdp *inst, RDP_EVENT *event return; } -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) { RDP_EVENT* out_event = NULL; void* payload = NULL; @@ -2201,7 +2200,7 @@ void mac_rail_enable_remoteapp_mode() * convert it to a rect with 0,0 at the top left (windows cords) */ -void apple_to_windows_cords(NSRect * r) +void apple_to_windows_cords(NSRect* r) { r->origin.y = g_mrdpview->height - (r->origin.y + r->size.height); } @@ -2211,23 +2210,23 @@ void apple_to_windows_cords(NSRect * r) * convert it to a rect with 0,0 at the bottom left (apple cords) */ -void windows_to_apple_cords(NSRect * r) +void windows_to_apple_cords(NSRect* r) { r->origin.y = g_mrdpview->height - (r->origin.y + r->size.height); } -void apple_center_window(NSRect * r) +void apple_center_window(NSRect* r) { r->origin.x = (g_mrdpview->width - r->size.width) / 2; r->origin.y = (g_mrdpview->height - r->size.height) / 2; } -void apple_to_windowMove(NSRect * r, RAIL_WINDOW_MOVE_ORDER * windowMove) +void apple_to_windowMove(NSRect* r, RAIL_WINDOW_MOVE_ORDER* windowMove) { - windowMove->left = (uint16) r->origin.x; // x-cord of top left corner - windowMove->top = (uint16) g_mrdpview->height - (r->origin.y + r->size.height); // y-cord of top left corner - windowMove->right = (uint16) (windowMove->left + r->size.width); // x-cord of bottom right corner - windowMove->bottom = (uint16) (windowMove->top + r->size.height); // y-cord of bottom right corner + windowMove->left = (UINT16) r->origin.x; // x-cord of top left corner + windowMove->top = (UINT16) g_mrdpview->height - (r->origin.y + r->size.height); // y-cord of top left corner + windowMove->right = (UINT16) (windowMove->left + r->size.width); // x-cord of bottom right corner + windowMove->bottom = (UINT16) (windowMove->top + r->size.height); // y-cord of bottom right corner } @end From d81870dcd7d19e723d1db0cd1ef2e9f3fa1d3df9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 21 Feb 2013 23:42:36 -0500 Subject: [PATCH 5/6] mfreerdp: fix headers --- client/Mac/AppDelegate.h | 25 +++-- client/Mac/MRDPCursor.h | 25 +++-- client/Mac/MRDPRailView.h | 19 ++++ client/Mac/MRDPRailView.m | 149 +++++++++++++++++++---------- client/Mac/MRDPRailWindow.h | 25 +++-- client/Mac/MRDPView.h | 181 +++++++++++++++++++----------------- client/Mac/MRDPView.m | 55 ++++++----- 7 files changed, 297 insertions(+), 182 deletions(-) diff --git a/client/Mac/AppDelegate.h b/client/Mac/AppDelegate.h index 56dcd53dc..a050c8d6c 100644 --- a/client/Mac/AppDelegate.h +++ b/client/Mac/AppDelegate.h @@ -1,10 +1,21 @@ -// -// AppDelegate.h -// MacFreeRDP -// -// Created by Thomas Goddard on 5/8/12. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * MacFreeRDP + * + * Copyright 2012 Thomas Goddard + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #import #import "MRDPView.h" diff --git a/client/Mac/MRDPCursor.h b/client/Mac/MRDPCursor.h index 5368e0df7..7c193e684 100644 --- a/client/Mac/MRDPCursor.h +++ b/client/Mac/MRDPCursor.h @@ -1,10 +1,21 @@ -// -// MRDPCursor.h -// MacFreeRDP -// -// Created by Laxmikant Rashinkar -// Copyright (c) 2012 FreeRDP.org All rights reserved. -// +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * MacFreeRDP + * + * Copyright 2012 Thomas Goddard + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #import diff --git a/client/Mac/MRDPRailView.h b/client/Mac/MRDPRailView.h index c242054bf..84d4c55ee 100644 --- a/client/Mac/MRDPRailView.h +++ b/client/Mac/MRDPRailView.h @@ -1,3 +1,22 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * MacFreeRDP + * + * Copyright 2012 Thomas Goddard + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #import #import "freerdp/gdi/gdi.h" diff --git a/client/Mac/MRDPRailView.m b/client/Mac/MRDPRailView.m index 699a49058..1e1ecc8a6 100644 --- a/client/Mac/MRDPRailView.m +++ b/client/Mac/MRDPRailView.m @@ -6,7 +6,7 @@ @synthesize mrdpRailWindow, windowIndex, activateWindow; -MRDPRailView * g_mrdpRailView; +MRDPRailView* g_mrdpRailView; struct kkey { @@ -18,11 +18,11 @@ extern struct kkey g_keys[]; - (void) updateDisplay { - BOOL moveWindow = NO; - NSRect srcRectOuter; - NSRect destRectOuter; + BOOL moveWindow = NO; + NSRect srcRectOuter; + NSRect destRectOuter; - rdpGdi * gdi; + rdpGdi* gdi; if ((context == 0) || (context->gdi == 0)) return; @@ -40,12 +40,15 @@ extern struct kkey g_keys[]; // cannot be bigger than our current screen size NSRect screenSize = [[NSScreen mainScreen] frame]; - if (destRectOuter.size.width > screenSize.size.width) { + + if (destRectOuter.size.width > screenSize.size.width) + { destRectOuter.size.width = screenSize.size.width; moveWindow = YES; } - if (destRectOuter.size.height > screenSize.size.height) { + if (destRectOuter.size.height > screenSize.size.height) + { destRectOuter.size.height = screenSize.size.height; moveWindow = YES; } @@ -55,7 +58,8 @@ extern struct kkey g_keys[]; [self setupBmiRep:destRectOuter.size.width :destRectOuter.size.height]; - if (moveWindow) { + if (moveWindow) + { moveWindow = NO; RAIL_WINDOW_MOVE_ORDER newWndLoc; apple_to_windowMove(&destRectOuter, &newWndLoc); @@ -84,10 +88,12 @@ extern struct kkey g_keys[]; { [bmiRep drawInRect:dirtyRect fromRect:dirtyRect operation:NSCompositeCopy fraction:1.0 respectFlipped:NO hints:nil]; - if (pixelData) { + if (pixelData) + { free(pixelData); pixelData = NULL; } + bmiRep = nil; } @@ -256,16 +262,20 @@ extern struct kkey g_keys[]; // we get more two finger trackpad scroll events // than scrollWheel events, so we drop some - if (gestureEventInProgress) { + if (gestureEventInProgress) + { scrollWheelCount++; + if (scrollWheelCount % 8 != 0) return; } - if ([event scrollingDeltaY] < 0) { + if ([event scrollingDeltaY] < 0) + { flags = PTR_FLAGS_WHEEL | PTR_FLAGS_WHEEL_NEGATIVE | 0x0088; } - else { + else + { flags = PTR_FLAGS_WHEEL | 0x78; } @@ -285,7 +295,8 @@ extern struct kkey g_keys[]; int x = (int) loc.x; int y = (int) loc.y; - if (titleBarClicked) { + if (titleBarClicked) + { // window is being dragged to a new location int newX = x - savedDragLocation.x; int newY = y - savedDragLocation.y; @@ -300,18 +311,22 @@ extern struct kkey g_keys[]; return; } - if (localMoveType == RAIL_WMSZ_LEFT) { + if (localMoveType == RAIL_WMSZ_LEFT) + { // left border resize taking place int diff = (int) (loc.x - savedDragLocation.x); + if (diff == 0) return; - if (diff < 0) { + if (diff < 0) + { diff = abs(diff); winFrame.origin.x -= diff; winFrame.size.width += diff; } - else { + else + { winFrame.origin.x += diff; winFrame.size.width -= diff; } @@ -320,9 +335,11 @@ extern struct kkey g_keys[]; return; } - if (localMoveType == RAIL_WMSZ_RIGHT) { + if (localMoveType == RAIL_WMSZ_RIGHT) + { // right border resize taking place int diff = (int) (loc.x - savedDragLocation.x); + if (diff == 0) return; @@ -331,12 +348,15 @@ extern struct kkey g_keys[]; winFrame.size.width += diff; [[self window] setFrame:winFrame display:YES]; + return; } - if (localMoveType == RAIL_WMSZ_TOP) { + if (localMoveType == RAIL_WMSZ_TOP) + { // top border resize taking place int diff = (int) (loc.y - savedDragLocation.y); + if (diff == 0) return; @@ -345,21 +365,26 @@ extern struct kkey g_keys[]; winFrame.size.height += diff; [[self window] setFrame:winFrame display:YES]; + return; } - if (localMoveType == RAIL_WMSZ_BOTTOM) { + if (localMoveType == RAIL_WMSZ_BOTTOM) + { // bottom border resize taking place int diff = (int) (loc.y - savedDragLocation.y); + if (diff == 0) return; - if (diff < 0) { + if (diff < 0) + { diff = abs(diff); winFrame.origin.y -= diff; winFrame.size.height += diff; } - else { + else + { winFrame.origin.y += diff; winFrame.size.height -= diff; } @@ -368,23 +393,30 @@ extern struct kkey g_keys[]; return; } - if (localMoveType == RAIL_WMSZ_TOPLEFT) { + if (localMoveType == RAIL_WMSZ_TOPLEFT) + { // top left border resize taking place int diff = (int) (loc.x - savedDragLocation.x); - if (diff != 0) { - if (diff < 0) { + + if (diff != 0) + { + if (diff < 0) + { diff = abs(diff); winFrame.origin.x -= diff; winFrame.size.width += diff; } - else { + else + { winFrame.origin.x += diff; winFrame.size.width -= diff; } } diff = (int) (loc.y - savedDragLocation.y); - if (diff != 0) { + + if (diff != 0) + { savedDragLocation.y = loc.y; winFrame.size.height += diff; } @@ -393,17 +425,18 @@ extern struct kkey g_keys[]; return; } - if (localMoveType == RAIL_WMSZ_TOPRIGHT) { + if (localMoveType == RAIL_WMSZ_TOPRIGHT) + { // top right border resize taking place int diff = (int) (loc.x - savedDragLocation.x); - if (diff != 0) { + + if (diff != 0) winFrame.size.width += diff; - } diff = (int) (loc.y - savedDragLocation.y); - if (diff != 0) { + + if (diff != 0) winFrame.size.height += diff; - } savedDragLocation.x = loc.x; savedDragLocation.y = loc.y; @@ -412,29 +445,38 @@ extern struct kkey g_keys[]; return; } - if (localMoveType == RAIL_WMSZ_BOTTOMLEFT) { + if (localMoveType == RAIL_WMSZ_BOTTOMLEFT) + { // bottom left border resize taking place int diff = (int) (loc.x - savedDragLocation.x); - if (diff != 0) { - if (diff < 0) { + + if (diff != 0) + { + if (diff < 0) + { diff = abs(diff); winFrame.origin.x -= diff; winFrame.size.width += diff; } - else { + else + { winFrame.origin.x += diff; winFrame.size.width -= diff; } } diff = (int) (loc.y - savedDragLocation.y); - if (diff != 0) { - if (diff < 0) { + + if (diff != 0) + { + if (diff < 0) + { diff = abs(diff); winFrame.origin.y -= diff; winFrame.size.height += diff; } - else { + else + { winFrame.origin.y += diff; winFrame.size.height -= diff; } @@ -444,23 +486,30 @@ extern struct kkey g_keys[]; return; } - if (localMoveType == RAIL_WMSZ_BOTTOMRIGHT) { + if (localMoveType == RAIL_WMSZ_BOTTOMRIGHT) + { // bottom right border resize taking place int diff = (int) (loc.x - savedDragLocation.x); - if (diff != 0) { + + if (diff != 0) + { savedDragLocation.x = loc.x; //savedDragLocation.y = loc.y; winFrame.size.width += diff; } diff = (int) (loc.y - savedDragLocation.y); - if (diff != 0) { - if (diff < 0) { + + if (diff != 0) + { + if (diff < 0) + { diff = abs(diff); winFrame.origin.y -= diff; winFrame.size.height += diff; } - else { + else + { winFrame.origin.y += diff; winFrame.size.height -= diff; } @@ -753,15 +802,14 @@ extern struct kkey g_keys[]; [[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) { } /** ********************************************************************* * color space conversion used specifically in RAIL ***********************************************************************/ -void rail_convert_color_space(char *destBuf, char * srcBuf, - NSRect * destRect, int width, int height) +void rail_convert_color_space(char* destBuf, char* srcBuf, NSRect* destRect, int width, int height) { int i; int j; @@ -780,9 +828,8 @@ void rail_convert_color_space(char *destBuf, char * srcBuf, int destWidth = destRect->size.width; int destHeight = destRect->size.height; - if ((!destBuf) || (!srcBuf)) { + if ((!destBuf) || (!srcBuf)) return; - } numRows = (destRect->origin.y + destHeight > height) ? height - destRect->origin.y : destHeight; pixelsPerRow = destWidth; @@ -821,11 +868,11 @@ void rail_convert_color_space(char *destBuf, char * srcBuf, void rail_MoveWindow(rdpRail * rail, rdpWindow * window) { - if (g_mrdpRailView->isMoveSizeInProgress) { + if (g_mrdpRailView->isMoveSizeInProgress) return; - } - if (g_mrdpRailView->skipMoveWindowOnce) { + if (g_mrdpRailView->skipMoveWindowOnce) + { g_mrdpRailView->skipMoveWindowOnce = NO; return; } diff --git a/client/Mac/MRDPRailWindow.h b/client/Mac/MRDPRailWindow.h index 629dc819c..52f1c045a 100644 --- a/client/Mac/MRDPRailWindow.h +++ b/client/Mac/MRDPRailWindow.h @@ -1,10 +1,21 @@ -// -// MRDPRailWindow.h -// Mac -// -// Created by Laxmikant Rashinkar -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * MacFreeRDP + * + * Copyright 2012 Thomas Goddard + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #import diff --git a/client/Mac/MRDPView.h b/client/Mac/MRDPView.h index d2c2f7b83..e8bb0f153 100644 --- a/client/Mac/MRDPView.h +++ b/client/Mac/MRDPView.h @@ -1,10 +1,21 @@ -// -// MRDPView.h -// MacFreeRDP -// -// Created by Laxmikant Rashinkar -// Copyright (c) 2012 FreeRDP.org All rights reserved. -// +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * MacFreeRDP + * + * Copyright 2012 Thomas Goddard + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #import @@ -26,50 +37,50 @@ { 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; + NSBitmapImageRep* bmiRep; + NSMutableArray* cursors; + NSMutableArray* windows; + NSTimer* pasteboard_timer; + NSRect rect; + NSRect prevWinPosition; + int titleBarHeight; + freerdp* rdp_instance; + rdpContext* rdp_context; + char* pixel_data; + int width; + int height; + int argc; + char** argv; // RAIL stuff - MRDPWindow *currentWindow; - NSPoint savedDragLocation; - BOOL mouseInClientArea; - BOOL isRemoteApp; - BOOL firstCreateWindow; - BOOL isMoveSizeInProgress; - BOOL skipResizeOnce; - BOOL saveInitialDragLoc; - BOOL skipMoveWindowOnce; + MRDPWindow* currentWindow; + NSPoint savedDragLocation; + BOOL mouseInClientArea; + BOOL isRemoteApp; + BOOL firstCreateWindow; + BOOL isMoveSizeInProgress; + BOOL skipResizeOnce; + BOOL saveInitialDragLoc; + BOOL 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; + 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 + 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) rdpConnectError; @@ -100,50 +111,50 @@ void pointer_set(rdpContext* context, rdpPointer* pointer); void pointer_setNull(rdpContext* context); void pointer_setDefault(rdpContext* context); int rdp_connect(void); -BOOL mac_pre_connect(freerdp *inst); -BOOL 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); +BOOL mac_pre_connect(freerdp* instance); +BOOL mac_post_connect(freerdp* instance); +void mac_context_new(freerdp* instance, rdpContext* context); +void mac_context_free(freerdp* instance, 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); +void mac_save_state_info(freerdp* instance, 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* instance); +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, BYTE *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); +int receive_channel_data(freerdp* instance, int chan_id, BYTE* data, int size, int flags, int total_size); +void process_cliprdr_event(freerdp* instance, RDP_EVENT* event); +void cliprdr_process_cb_format_list_event(freerdp* instance, RDP_CB_FORMAT_LIST_EVENT* event); +void cliprdr_send_data_request(freerdp* instance, 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, BYTE *data, int len); -void cliprdr_send_supported_format_list(freerdp *inst); -int register_channel_fds(int *fds, int count, void *inst); +void cliprdr_process_cb_data_response_event(freerdp* instance, RDP_CB_DATA_RESPONSE_EVENT* event); +void cliprdr_process_text(freerdp* instance, BYTE* data, int len); +void cliprdr_send_supported_format_list(freerdp* instance); +int register_channel_fds(int* fds, int count, void* instance); -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, BYTE 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_process_rail_event(freerdp* instance, RDP_EVENT* event); +void mac_rail_register_callbacks(freerdp* instance, 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, BYTE 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); 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); +void mac_process_rail_server_localmovesize_event(freerdp* instance, RDP_EVENT* event); +void apple_center_window(NSRect* r); +void apple_to_windowMove(NSRect* r, RAIL_WINDOW_MOVE_ORDER * windowMove); struct mac_context { @@ -153,11 +164,11 @@ struct mac_context struct cursor { - rdpPointer *pointer; - BYTE *cursor_data; // bitmapped pixel data - void *bmiRep; // NSBitmapImageRep - void *nsCursor; // NSCursor - void *nsImage; // NSImage + rdpPointer* pointer; + BYTE* cursor_data; // bitmapped pixel data + void* bmiRep; // NSBitmapImageRep + void* nsCursor; // NSCursor + void* nsImage; // NSImage }; struct rgba_data diff --git a/client/Mac/MRDPView.m b/client/Mac/MRDPView.m index 9b7b377be..12a1e405f 100644 --- a/client/Mac/MRDPView.m +++ b/client/Mac/MRDPView.m @@ -1251,7 +1251,7 @@ void pointer_new(rdpContext* context, rdpPointer* pointer) rect.origin.x = pointer->xPos; rect.origin.y = pointer->yPos; - cursor_data = (uint8 *) malloc(rect.size.width * rect.size.height * 4); + cursor_data = (BYTE *) malloc(rect.size.width * rect.size.height * 4); mrdpCursor->cursor_data = cursor_data; freerdp_alpha_cursor_convert(cursor_data, pointer->xorMaskData, pointer->andMaskData, @@ -1934,7 +1934,7 @@ void mac_rail_CreateWindow(rdpRail* rail, rdpWindow* window) return; } -void mac_rail_MoveWindow(rdpRail *rail, rdpWindow *window) +void mac_rail_MoveWindow(rdpRail* rail, rdpWindow* window) { if (g_mrdpview->currentWindow) { @@ -1943,23 +1943,23 @@ void mac_rail_MoveWindow(rdpRail *rail, rdpWindow *window) } } -void mac_rail_ShowWindow(rdpRail *rail, rdpWindow *window, uint8 state) +void mac_rail_ShowWindow(rdpRail* rail, rdpWindow* window, BYTE state) { } -void mac_rail_SetWindowText(rdpRail *rail, rdpWindow *window) +void mac_rail_SetWindowText(rdpRail* rail, rdpWindow* window) { } -void mac_rail_SetWindowIcon(rdpRail *rail, rdpWindow *window, rdpIcon *icon) +void mac_rail_SetWindowIcon(rdpRail* rail, rdpWindow* window, rdpIcon* icon) { } -void mac_rail_SetWindowRects(rdpRail *rail, rdpWindow *window) +void mac_rail_SetWindowRects(rdpRail* rail, rdpWindow* window) { } -void mac_rail_SetWindowVisibilityRects(rdpRail *rail, rdpWindow *window) +void mac_rail_SetWindowVisibilityRects(rdpRail* rail, rdpWindow* window) { } @@ -1967,36 +1967,41 @@ void mac_rail_SetWindowVisibilityRects(rdpRail *rail, rdpWindow *window) * destroy window created in mac_rail_CreateWindow() ***********************************************************************/ -void mac_rail_DestroyWindow(rdpRail *rail, rdpWindow *window) +void mac_rail_DestroyWindow(rdpRail* rail, rdpWindow* window) { int count = 0; for (MRDPWindow * win in g_mrdpview->windows) { - if ([win windowID] == window->windowId) { + if ([win windowID] == window->windowId) + { //[[win window] close]; [win setView:nil]; [win setWindow:nil]; [g_mrdpview->windows removeObject:win]; count = [g_mrdpview->windows count]; - if (count) { + + if (count) + { g_mrdpview->currentWindow = [g_mrdpview->windows objectAtIndex:count - 1]; //[[g_mrdpview window] makeKeyAndOrderFront:[g_mrdpview->currentWindow window]]; [[g_mrdpview->currentWindow window] makeKeyAndOrderFront:NSApp]; } - else { + else + { g_mrdpview->currentWindow = nil; // RAIL_TODO [[g_mrdpview window] makeKeyAndOrderFront:[g_mrdpview window]]; [NSApp terminate:nil]; } + return; } } } -void mac_rail_register_callbacks(freerdp *inst, rdpRail *rail) +void mac_rail_register_callbacks(freerdp* instance, rdpRail* rail) { - rail->extra = (void*) inst; + rail->extra = (void*) instance; rail->rail_CreateWindow = mac_rail_CreateWindow; rail->rail_MoveWindow = mac_rail_MoveWindow; rail->rail_ShowWindow = mac_rail_ShowWindow; @@ -2099,35 +2104,35 @@ void mac_process_rail_server_localmovesize_event(freerdp* instance, RDP_EVENT *e switch (moveSize->moveSizeType) { case RAIL_WMSZ_LEFT: - printf("!!!! RAIL_WMSZ_LEFT\n"); + printf("RAIL_WMSZ_LEFT\n"); break; case RAIL_WMSZ_RIGHT: - printf("!!!! RAIL_WMSZ_RIGHT\n"); + printf("RAIL_WMSZ_RIGHT\n"); break; case RAIL_WMSZ_TOP: - printf("!!!! RAIL_WMSZ_TOP\n"); + printf("RAIL_WMSZ_TOP\n"); break; case RAIL_WMSZ_TOPLEFT: - printf("!!!! RAIL_WMSZ_TOPLEFT\n"); + printf("RAIL_WMSZ_TOPLEFT\n"); break; case RAIL_WMSZ_TOPRIGHT: - printf("!!!! RAIL_WMSZ_TOPRIGHT\n"); + printf("RAIL_WMSZ_TOPRIGHT\n"); break; case RAIL_WMSZ_BOTTOM: - printf("!!!! RAIL_WMSZ_BOTTOM\n"); + printf("RAIL_WMSZ_BOTTOM\n"); break; case RAIL_WMSZ_BOTTOMLEFT: - printf("!!!! RAIL_WMSZ_BOTTOMLEFT\n"); + printf("RAIL_WMSZ_BOTTOMLEFT\n"); break; case RAIL_WMSZ_BOTTOMRIGHT: - printf("!!!! RAIL_WMSZ_BOTTOMRIGHT\n"); + printf("RAIL_WMSZ_BOTTOMRIGHT\n"); break; case RAIL_WMSZ_MOVE: @@ -2153,11 +2158,11 @@ void mac_process_rail_server_localmovesize_event(freerdp* instance, RDP_EVENT *e break; case RAIL_WMSZ_KEYMOVE: - printf("!!!! RAIL_WMSZ_KEYMOVE\n"); + printf("RAIL_WMSZ_KEYMOVE\n"); break; case RAIL_WMSZ_KEYSIZE: - printf("!!!! RAIL_WMSZ_KEYSIZE\n"); + printf("RAIL_WMSZ_KEYSIZE\n"); break; default: @@ -2169,12 +2174,12 @@ void mac_process_rail_server_localmovesize_event(freerdp* instance, RDP_EVENT *e void mac_send_rail_client_event(rdpChannels* channels, UINT16 event_type, void* param) { - RDP_EVENT* out_event = NULL; void* payload = NULL; + RDP_EVENT* out_event = NULL; payload = rail_clone_order(event_type, param); - if (payload != NULL) + if (payload) { out_event = freerdp_event_new(RDP_EVENT_CLASS_RAIL, event_type, mac_on_free_rail_client_event, payload); freerdp_channels_send_event(channels, out_event); From 1b030caf5f7a4ecda741105f325165b8f9939e01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 21 Feb 2013 23:52:51 -0500 Subject: [PATCH 6/6] mfreerdp: fix headers --- client/Mac/AppDelegate.m | 29 ++++++++++++++++++++--------- client/Mac/MRDPCursor.m | 25 ++++++++++++++++++------- client/Mac/MRDPRailView.m | 19 +++++++++++++++++++ client/Mac/MRDPRailWindow.m | 25 ++++++++++++++++++------- client/Mac/MRDPView.m | 25 ++++++++++++++++++------- client/Mac/MRDPWindow.h | 22 ++++++++++++++++++++-- client/Mac/MRDPWindow.m | 18 ++++++++++++++++++ client/Mac/main.m | 25 ++++++++++++++++++------- 8 files changed, 149 insertions(+), 39 deletions(-) diff --git a/client/Mac/AppDelegate.m b/client/Mac/AppDelegate.m index 3918d4ac4..029d055d1 100644 --- a/client/Mac/AppDelegate.m +++ b/client/Mac/AppDelegate.m @@ -1,10 +1,21 @@ -// -// AppDelegate.m -// MacFreeRDP -// -// Created by Thomas Goddard on 5/8/12. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * MacFreeRDP + * + * Copyright 2012 Thomas Goddard + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #import "AppDelegate.h" @@ -14,12 +25,12 @@ @synthesize mrdpView; -- (void)applicationDidFinishLaunching:(NSNotification *)aNotification +- (void)applicationDidFinishLaunching:(NSNotification*)aNotification { rdp_connect(); } -- (void) applicationWillTerminate:(NSNotification *)notification +- (void) applicationWillTerminate:(NSNotification*)notification { //[mrdpView releaseResources]; } diff --git a/client/Mac/MRDPCursor.m b/client/Mac/MRDPCursor.m index 29a93c808..86e1c2d9b 100644 --- a/client/Mac/MRDPCursor.m +++ b/client/Mac/MRDPCursor.m @@ -1,10 +1,21 @@ -// -// MRDPCursor.m -// MacFreeRDP -// -// Created by Laxmikant Rashinkar -// Copyright (c) 2012 FreeRDP.org All rights reserved. -// +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * MacFreeRDP + * + * Copyright 2012 Thomas Goddard + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #import "MRDPCursor.h" diff --git a/client/Mac/MRDPRailView.m b/client/Mac/MRDPRailView.m index 1e1ecc8a6..f9e0e0655 100644 --- a/client/Mac/MRDPRailView.m +++ b/client/Mac/MRDPRailView.m @@ -1,3 +1,22 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * MacFreeRDP + * + * Copyright 2012 Thomas Goddard + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "MRDPRailView.h" #define USE_RAIL_CVT diff --git a/client/Mac/MRDPRailWindow.m b/client/Mac/MRDPRailWindow.m index 9db211364..f714d610e 100644 --- a/client/Mac/MRDPRailWindow.m +++ b/client/Mac/MRDPRailWindow.m @@ -1,10 +1,21 @@ -// -// MRDPRailWindow.m -// Mac -// -// Created by Laxmikant Rashinkar -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * MacFreeRDP + * + * Copyright 2012 Thomas Goddard + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #import "MRDPRailWindow.h" diff --git a/client/Mac/MRDPView.m b/client/Mac/MRDPView.m index 12a1e405f..d4f79c1ff 100644 --- a/client/Mac/MRDPView.m +++ b/client/Mac/MRDPView.m @@ -1,10 +1,21 @@ -// -// MRDPView.m -// MacFreeRDP -// -// Created by Laxmikant Rashinkar -// Copyright (c) 2012 FreeRDP.org All rights reserved. -// +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * MacFreeRDP + * + * Copyright 2012 Thomas Goddard + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* * TODO diff --git a/client/Mac/MRDPWindow.h b/client/Mac/MRDPWindow.h index cef1ab09e..0e7e26b97 100644 --- a/client/Mac/MRDPWindow.h +++ b/client/Mac/MRDPWindow.h @@ -1,3 +1,21 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * MacFreeRDP + * + * Copyright 2012 Thomas Goddard + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #import #import "MRDPRailView.h" @@ -8,8 +26,8 @@ } @property (assign) int windowID; -@property (retain) MRDPRailWindow * window; -@property (retain) MRDPRailView * view; +@property (retain) MRDPRailWindow* window; +@property (retain) MRDPRailView* view; @end diff --git a/client/Mac/MRDPWindow.m b/client/Mac/MRDPWindow.m index 77b99728c..e5e5e402f 100644 --- a/client/Mac/MRDPWindow.m +++ b/client/Mac/MRDPWindow.m @@ -1,3 +1,21 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * MacFreeRDP + * + * Copyright 2012 Thomas Goddard + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #include "MRDPWindow.h" diff --git a/client/Mac/main.m b/client/Mac/main.m index a7ee86852..4cba6cfc1 100644 --- a/client/Mac/main.m +++ b/client/Mac/main.m @@ -1,10 +1,21 @@ -// -// main.m -// MacFreeRDP -// -// Created by Thomas Goddard on 5/8/12. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * MacFreeRDP + * + * Copyright 2012 Thomas Goddard + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #import