/*****************************************************************************
* intf.m: MacOS X interface module
*****************************************************************************
- * Copyright (C) 2002-2012 VLC authors and VideoLAN
+ * Copyright (C) 2002-2013 VLC authors and VideoLAN
* $Id$
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
int i_full = 1;
SEL sel = @selector(setFullscreen:forWindow:);
- NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[[VLCMain sharedInstance] methodSignatureForSelector:sel]];
- [inv setTarget:[VLCMain sharedInstance]];
+ NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[[[VLCMain sharedInstance] voutController] methodSignatureForSelector:sel]];
+ [inv setTarget:[[VLCMain sharedInstance] voutController]];
[inv setSelector:sel];
[inv setArgument:&i_full atIndex:2];
[inv setArgument:&p_wnd atIndex:3];
int i_full = va_arg(args, int);
SEL sel = @selector(setFullscreen:forWindow:);
- NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[[VLCMain sharedInstance] methodSignatureForSelector:sel]];
- [inv setTarget:[VLCMain sharedInstance]];
+ NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[[[VLCMain sharedInstance] voutController] methodSignatureForSelector:sel]];
+ [inv setTarget:[[VLCMain sharedInstance] voutController]];
[inv setSelector:sel];
[inv setArgument:&i_full atIndex:2]; // starting at 2!
[inv setArgument:&p_wnd atIndex:3];
* then -informInputChanged on this non-main thread. */
[o_plItemChangedLock lock];
[[VLCMain sharedInstance] performSelectorOnMainThread:@selector(PlaylistItemChanged) withObject:nil waitUntilDone:YES];
- [[VLCMain sharedInstance] informInputChanged];
+ [[VLCMain sharedInstance] performSelectorOnMainThread:@selector(informInputChanged) withObject:nil waitUntilDone:YES];
[o_plItemChangedLock unlock];
[o_pool release];
b_nativeFullscreenMode = var_InheritBool(p_intf, "macosx-nativefullscreenmode");
#endif
- /* recover stored audio device, if set
- * in case it was unplugged in the meantime, auhal will fall back on the default */
- int i_value = config_GetInt(p_intf, "macosx-audio-device");
- if (i_value > 0)
- var_SetInteger(pl_Get(VLCIntf), "audio-device", i_value);
-
if (config_GetInt(VLCIntf, "macosx-icon-change")) {
/* After day 354 of the year, the usual VLC cone is replaced by another cone
* wearing a Father Xmas hat.
int keyRepeat = (keyFlags & 0x1);
if (keyCode == NX_KEYTYPE_PLAY && keyState == 0)
- [[VLCCoreInteraction sharedInstance] play];
+ [[VLCCoreInteraction sharedInstance] playOrPause];
if ((keyCode == NX_KEYTYPE_FAST || keyCode == NX_KEYTYPE_NEXT) && !b_mediakeyJustJumped) {
if (keyState == 0 && keyRepeat == 0)
[[VLCCoreInteraction sharedInstance] backward];
break;
case kRemoteButtonVolume_Plus_Hold:
- if (p_intf)
- var_SetInteger(p_intf->p_libvlc, "key-action", ACTIONID_VOL_UP);
+ [[VLCCoreInteraction sharedInstance] volumeUp];
break;
case kRemoteButtonVolume_Minus_Hold:
- if (p_intf)
- var_SetInteger(p_intf->p_libvlc, "key-action", ACTIONID_VOL_DOWN);
+ [[VLCCoreInteraction sharedInstance] volumeDown];
break;
}
if (b_remote_button_hold) {
[[VLCCoreInteraction sharedInstance] toggleFullscreen];
break;
case k2009RemoteButtonPlay:
- [[VLCCoreInteraction sharedInstance] play];
+ [[VLCCoreInteraction sharedInstance] playOrPause];
break;
case kRemoteButtonPlay:
if (count >= 2)
[[VLCCoreInteraction sharedInstance] toggleFullscreen];
else
- [[VLCCoreInteraction sharedInstance] play];
+ [[VLCCoreInteraction sharedInstance] playOrPause];
break;
case kRemoteButtonVolume_Plus:
if (config_GetInt(VLCIntf, "macosx-appleremote-sysvol"))
}
if (key == 0x0020) { // space key
- [[VLCCoreInteraction sharedInstance] play];
+ [[VLCCoreInteraction sharedInstance] playOrPause];
return YES;
}
#pragma mark -
#pragma mark Interface updaters
-- (void)setFullscreen:(int)i_full forWindow:(vout_window_t *)p_wnd
-{
- if (!p_intf || (!b_nativeFullscreenMode && !p_wnd))
- return;
- playlist_t * p_playlist = pl_Get(p_intf);
- BOOL b_fullscreen = i_full;
-
- if (!var_GetBool(p_playlist, "fullscreen") != !b_fullscreen)
- var_SetBool(p_playlist, "fullscreen", b_fullscreen);
-
- if (b_nativeFullscreenMode) {
- // this is called twice in certain situations, so only toogle if we really need to
- if ((b_fullscreen && !([NSApp currentSystemPresentationOptions] & NSApplicationPresentationFullScreen)) ||
- (!b_fullscreen && ([NSApp currentSystemPresentationOptions] & NSApplicationPresentationFullScreen)))
- [o_mainwindow toggleFullScreen: self];
-
- if (b_fullscreen)
- [NSApp setPresentationOptions:(NSApplicationPresentationFullScreen | NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
- else
- [NSApp setPresentationOptions:(NSApplicationPresentationDefault)];
- } else {
- assert(p_wnd);
-
- if (b_fullscreen) {
- input_thread_t * p_input = pl_CurrentInput(p_intf);
- if (p_input != NULL && [self activeVideoPlayback]) {
- // activate app, as method can also be triggered from outside the app (prevents nasty window layout)
- [NSApp activateIgnoringOtherApps:YES];
- [o_vout_controller updateWindow:p_wnd withSelector:@selector(enterFullscreen)];
-
- }
- if (p_input)
- vlc_object_release(p_input);
- } else {
- // leaving fullscreen is always allowed
- [o_vout_controller updateWindow:p_wnd withSelector:@selector(leaveFullscreen)];
- }
- }
-}
- (void)PlaylistItemChanged
{
if (p_input) {
int state = var_GetInteger(p_input, "state");
if (state == PLAYING_S) {
+ /* 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 ([self activeVideoPlayback] && IOPMAssertionDeclareUserActivity)
+ {
+ CFStringRef reasonForActivity = CFStringCreateWithCString(kCFAllocatorDefault, _("VLC media playback"), kCFStringEncodingUTF8);
+ IOPMAssertionDeclareUserActivity(reasonForActivity,
+ kIOPMUserActiveLocal,
+ &userActivityAssertionID);
+ CFRelease(reasonForActivity);
+ }
+#endif
+
/* prevent the system from sleeping */
if (systemSleepAssertionID > 0) {
msg_Dbg(VLCIntf, "releasing old sleep blocker (%i)" , systemSleepAssertionID);