fix [client/Mac]: UI API needs to be called in main thread
With recent SDKs the view won't update it the UI API is called
from a different thread.
@@ -291,7 +291,10 @@ DWORD WINAPI mac_client_thread(void* param)
- (void) setCursor: (NSCursor*) cursor
{
self->currentCursor = cursor;
+ dispatch_async(dispatch_get_main_queue(), ^
+ {
[[self window] invalidateCursorRectsForView:self];
+ });
}
- (void) resetCursorRects
@@ -775,13 +778,14 @@ DWORD fixKeyCode(DWORD keyCode, unichar keyChar, enum APPLE_KEYBOARD_TYPE type)
dispatch_async(dispatch_get_main_queue(), ^
{
self->pasteboard_timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(onPasteboardTimerFired:) userInfo:nil repeats:YES];
- });
+
NSTrackingArea* trackingArea = [[NSTrackingArea alloc] initWithRect:[self
visibleRect] options:NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved |
NSTrackingCursorUpdate | NSTrackingEnabledDuringMouseDrag |
NSTrackingActiveWhenFirstResponder owner:self userInfo:nil];
[self addTrackingArea:trackingArea];
[trackingArea release];
+ });
}
- (void) setScrollOffset:(int)xOffset y:(int)yOffset w:(int)width h:(int)height
@@ -937,8 +941,10 @@ static BOOL mac_authenticate_int(NSString* title, freerdp* instance, char** user
dialog.domain = [NSString stringWithCString:*domain encoding:
NSUTF8StringEncoding];
- [dialog performSelectorOnMainThread:@selector(runModal:) withObject:[view
- window] waitUntilDone:TRUE];
+ dispatch_sync(dispatch_get_main_queue(), ^
+ {
+ [dialog performSelectorOnMainThread:@selector(runModal:) withObject:[view window] waitUntilDone:TRUE];
+ });
BOOL ok = dialog.modalCode;
if (ok)
@@ -1307,7 +1313,10 @@ BOOL mac_end_paint(rdpContext* context)
}
windows_to_apple_cords(mfc->view, &newDrawRect);
+ dispatch_sync(dispatch_get_main_queue(), ^
+ {
[view setNeedsDisplayInRect:newDrawRect];
+ });
gdi->primary->hdc->hwnd->ninvalid = 0;
return TRUE;
}
@@ -1385,8 +1394,11 @@ void input_activity_cb(freerdp* instance)
*/
void windows_to_apple_cords(MRDPView* view, NSRect* r)
+{
+ dispatch_sync(dispatch_get_main_queue(), ^
{
r->origin.y = [view frame].size.height - (r->origin.y + r->size.height);
+ });
}
void sync_keyboard_state(freerdp* instance)
