Fixed #5234: Added timer invalidate on application willresignactive
authorArmin Novak <armin.novak@thincast.com>
Tue, 12 Feb 2019 10:16:36 +0000 (11:16 +0100)
committerArmin Novak <armin.novak@thincast.com>
Tue, 12 Feb 2019 10:23:56 +0000 (11:23 +0100)
client/Mac/MRDPView.m
client/Mac/cli/AppDelegate.m

index ff79958..498a5b1 100644 (file)
@@ -233,6 +233,7 @@ DWORD WINAPI mac_client_thread(void* param)
                }
 
        disconnect:
+               [view setIs_connected:0];
                freerdp_disconnect(instance);
 
                if (settings->AsyncInput && inputThread)
@@ -794,6 +795,9 @@ DWORD fixKeyCode(DWORD keyCode, unichar keyChar, enum APPLE_KEYBOARD_TYPE type)
 
 - (void)resume
 {
+       if (!self.is_connected)
+               return;
+
        dispatch_async(dispatch_get_main_queue(), ^
        {
                self->pasteboard_timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(onPasteboardTimerFired:) userInfo:nil repeats:YES];
@@ -930,9 +934,16 @@ BOOL mac_post_connect(freerdp* instance)
 
 void mac_post_disconnect(freerdp*      instance)
 {
+       mfContext* mfc;
+       MRDPView* view;
        if (!instance || !instance->context)
                return;
 
+       mfc = (mfContext*) instance->context;
+       view = (MRDPView*) mfc->view;
+
+       [view pause];
+
        PubSub_UnsubscribeChannelConnected(instance->context->pubSub, mac_OnChannelConnectedEventHandler);
        PubSub_UnsubscribeChannelDisconnected(instance->context->pubSub,
                                              mac_OnChannelDisconnectedEventHandler);
index b868e12..65884b5 100644 (file)
@@ -82,6 +82,16 @@ void mac_set_view_size(rdpContext* context, MRDPView* view);
        }
 }
 
+- (void) applicationWillBecomeActive:(NSNotification*)notification
+{
+       [mrdpView resume];
+}
+
+- (void) applicationWillResignActive:(NSNotification*)notification
+{
+       [mrdpView pause];
+}
+
 - (void) applicationWillTerminate:(NSNotification*)notification
 {
        NSLog(@"Stopping...\n");