]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/intf.m
boostrap: Fix previous commit (oops)
[vlc] / modules / gui / macosx / intf.m
index 58bd0a811d1a96c4bf470fa7ba3e02acef94e498..e7a6bad6a5e4a5b7f4a4f8429601a57f85a61fb9 100644 (file)
@@ -110,10 +110,21 @@ jmp_buf jmpbuffer;
 
 static void Run( intf_thread_t *p_intf )
 {
+    sigset_t set;
+
     /* Do it again - for some unknown reason, vlc_thread_create() often
      * fails to go to real-time priority with the first launched thread
      * (???) --Meuuh */
     vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW );
+
+    /* Make sure the "force quit" menu item does quit instantly.
+     * VLC overrides SIGTERM which is sent by the "force quit"
+     * menu item to make sure deamon mode quits gracefully, so
+     * we un-override SIGTERM here. */
+    sigemptyset( &set );
+    sigaddset( &set, SIGTERM );
+    pthread_sigmask( SIG_UNBLOCK, &set, NULL );
+
     [[VLCMain sharedInstance] setIntf: p_intf];
     [NSBundle loadNibNamed: @"MainMenu" owner: NSApp];
 
@@ -726,6 +737,20 @@ static VLCMain *_o_sharedMainInstance = nil;
     return YES;
 }
 
+- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
+{
+    /* Check for update silently on startup */
+    if ( !nib_update_loaded )
+        nib_update_loaded = [NSBundle loadNibNamed:@"Update" owner:self];
+
+    if([o_update shouldCheckForUpdate])
+        [NSThread detachNewThreadSelector:@selector(checkForUpdate) toTarget:o_update withObject:NULL];
+    /* Handle sleep notification */
+    [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(computerWillSleep:)
+           name:NSWorkspaceWillSleepNotification object:nil];
+}
+
 /* Listen to the remote in exclusive mode, only when VLC is the active
    application */
 - (void)applicationDidBecomeActive:(NSNotification *)aNotification
@@ -737,6 +762,18 @@ static VLCMain *_o_sharedMainInstance = nil;
     [o_remote stopListening: self];
 }
 
+/* Triggered when the computer goes to sleep */
+- (void)computerWillSleep: (NSNotification *)notification
+{
+    /* Pause */
+    if ( p_intf->p_sys->i_play_status == PLAYING_S )
+    {
+        vlc_value_t val;
+        val.i_int = config_GetInt( p_intf, "key-play-pause" );
+        var_Set( p_intf->p_libvlc, "key-pressed", val );
+    }
+}
+
 /* Helper method for the remote control interface in order to trigger forward/backward and volume
    increase/decrease as long as the user holds the left/right, plus/minus button */
 - (void) executeHoldActionForRemoteButton: (NSNumber*) buttonIdentifierNumber 
@@ -1680,7 +1717,7 @@ static VLCMain *_o_sharedMainInstance = nil;
     /* write cached user defaults to disk */
     [[NSUserDefaults standardUserDefaults] synchronize];
 
-    p_intf->b_die = VLC_TRUE;
+    vlc_object_kill( p_intf );
 
     /* Go back to Run() and make libvlc exit properly */
     longjmp( jmpbuffer, 1 );
@@ -1833,12 +1870,9 @@ static VLCMain *_o_sharedMainInstance = nil;
 - (IBAction)checkForUpdate:(id)sender
 {
     if ( !nib_update_loaded )
-    {
         nib_update_loaded = [NSBundle loadNibNamed:@"Update" owner:self];
-        [o_update showUpdateWindow];
-    } else {
-        [o_update showUpdateWindow];
-    }
+
+    [o_update showUpdateWindow];
 }
 
 - (IBAction)openReadMe:(id)sender