macosx: respect 'disable-screensaver' option (closes #16670)
authorFelix Paul Kühne <fkuehne@videolan.org>
Wed, 24 Feb 2016 07:53:05 +0000 (08:53 +0100)
committerFelix Paul Kühne <fkuehne@videolan.org>
Wed, 24 Feb 2016 07:53:05 +0000 (08:53 +0100)
modules/gui/macosx/InputManager.m

index 7815de5..c6ddbcd 100644 (file)
@@ -284,11 +284,14 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
             }
         }
 
+        BOOL shouldDisableScreensaver = var_InheritInteger(p_intf, "disable-screensaver");
+
         /* Declare user activity.
          This wakes the display if it is off, and postpones display sleep according to the users system preferences
          Available from 10.7.3 */
+
 #ifdef MAC_OS_X_VERSION_10_7
-        if ([o_main activeVideoPlayback] && &IOPMAssertionDeclareUserActivity)
+        if ([o_main activeVideoPlayback] && &IOPMAssertionDeclareUserActivity && shouldDisableScreensaver)
         {
             CFStringRef reasonForActivity = CFStringCreateWithCString(kCFAllocatorDefault, _("VLC media playback"), kCFStringEncodingUTF8);
             IOPMAssertionDeclareUserActivity(reasonForActivity,
@@ -308,14 +311,14 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
         /* work-around a bug in 10.7.4 and 10.7.5, so check for 10.7.x < 10.7.4 and 10.8 */
         if ((NSAppKitVersionNumber >= 1115.2 && NSAppKitVersionNumber < 1138.45) || OSX_MOUNTAIN_LION || OSX_MAVERICKS || OSX_YOSEMITE || OSX_EL_CAPITAN) {
             CFStringRef reasonForActivity = CFStringCreateWithCString(kCFAllocatorDefault, _("VLC media playback"), kCFStringEncodingUTF8);
-            if ([o_main activeVideoPlayback])
+            if ([o_main activeVideoPlayback] && shouldDisableScreensaver)
                 success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, reasonForActivity, &systemSleepAssertionID);
             else
                 success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, reasonForActivity, &systemSleepAssertionID);
             CFRelease(reasonForActivity);
         } else {
             /* fall-back on the 10.5 mode, which also works on 10.7.4 and 10.7.5 */
-            if ([o_main activeVideoPlayback])
+            if ([o_main activeVideoPlayback] && shouldDisableScreensaver)
                 success = IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &systemSleepAssertionID);
             else
                 success = IOPMAssertionCreate(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &systemSleepAssertionID);