Commit 7f84f44d authored by David Fuhrmann's avatar David Fuhrmann

macosx: move fullscreen logic to VLCVoutController and remove now unneeded helper methods

parent cf04d7a8
...@@ -622,7 +622,7 @@ static VLCCoreInteraction *_o_sharedInstance = nil; ...@@ -622,7 +622,7 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
vlc_object_release(p_vout); vlc_object_release(p_vout);
} else { // e.g. lion fullscreen toggle } else { // e.g. lion fullscreen toggle
BOOL b_fs = var_ToggleBool(pl_Get(p_intf), "fullscreen"); BOOL b_fs = var_ToggleBool(pl_Get(p_intf), "fullscreen");
[[VLCMain sharedInstance] setFullscreen:b_fs forWindow:nil]; [[[VLCMain sharedInstance] voutController] setFullscreen:b_fs forWindow:nil];
} }
} }
......
...@@ -45,16 +45,13 @@ ...@@ -45,16 +45,13 @@
- (VLCVoutView *)setupVoutForWindow:(vout_window_t *)p_wnd withProposedVideoViewPosition:(NSRect)videoViewPosition; - (VLCVoutView *)setupVoutForWindow:(vout_window_t *)p_wnd withProposedVideoViewPosition:(NSRect)videoViewPosition;
- (void)removeVoutforDisplay:(NSValue *)o_key; - (void)removeVoutforDisplay:(NSValue *)o_key;
- (void)setNativeVideoSize:(NSSize)size forWindow:(vout_window_t *)p_wnd;
- (void)setWindowLevel:(NSInteger)i_level forWindow:(vout_window_t *)p_wnd;
- (void)setFullscreen:(int)i_full forWindow:(vout_window_t *)p_wnd;
- (void)updateWindowsControlsBarWithSelector:(SEL)aSel; - (void)updateWindowsControlsBarWithSelector:(SEL)aSel;
- (VLCVideoWindowCommon *)getWindow:(vout_window_t *)p_wnd;
- (void)updateWindowsUsingBlock:(void (^)(VLCVideoWindowCommon *o_window))windowUpdater; - (void)updateWindowsUsingBlock:(void (^)(VLCVideoWindowCommon *o_window))windowUpdater;
- (void)updateWindow:(vout_window_t *)p_wnd withSelector:(SEL)aSel;
- (void)setNativeVideoSize:(NSSize)size forWindow:(vout_window_t *)p_wnd;
- (void)setWindowLevel:(NSInteger)i_level forWindow:(vout_window_t *)p_wnd;
- (void)updateWindowLevelForHelperWindows:(NSInteger)i_level; - (void)updateWindowLevelForHelperWindows:(NSInteger)i_level;
@end @end
...@@ -53,6 +53,8 @@ ...@@ -53,6 +53,8 @@
[super dealloc]; [super dealloc];
} }
#pragma mark -
#pragma mark Methods for vout provider
- (VLCVoutView *)setupVoutForWindow:(vout_window_t *)p_wnd withProposedVideoViewPosition:(NSRect)videoViewPosition - (VLCVoutView *)setupVoutForWindow:(vout_window_t *)p_wnd withProposedVideoViewPosition:(NSRect)videoViewPosition
{ {
...@@ -217,43 +219,6 @@ ...@@ -217,43 +219,6 @@
[[VLCMain sharedInstance] setActiveVideoPlayback:NO]; [[VLCMain sharedInstance] setActiveVideoPlayback:NO];
} }
- (void)updateWindowsControlsBarWithSelector:(SEL)aSel
{
[o_vout_dict enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
if ([obj respondsToSelector:@selector(controlsBar)]) {
id o_controlsBar = [obj controlsBar];
if (o_controlsBar)
[o_controlsBar performSelector:aSel];
}
}];
}
- (void)updateWindow:(vout_window_t *)p_wnd withSelector:(SEL)aSel;
{
VLCVideoWindowCommon *o_window = [o_vout_dict objectForKey:[NSValue valueWithPointer:p_wnd]];
if (!o_window) {
msg_Err(VLCIntf, "Cannot call selector for nonexisting window");
return;
}
[o_window performSelector:aSel];
}
- (VLCVideoWindowCommon *)getWindow:(vout_window_t *)p_wnd
{
VLCVideoWindowCommon *o_window = [o_vout_dict objectForKey:[NSValue valueWithPointer:p_wnd]];
assert(o_window);
return o_window;
}
- (void)updateWindowsUsingBlock:(void (^)(VLCVideoWindowCommon *o_window))windowUpdater
{
[o_vout_dict enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
if ([obj isKindOfClass: [NSWindow class]])
windowUpdater(obj);
}];
}
- (void)setNativeVideoSize:(NSSize)size forWindow:(vout_window_t *)p_wnd - (void)setNativeVideoSize:(NSSize)size forWindow:(vout_window_t *)p_wnd
{ {
...@@ -288,6 +253,83 @@ ...@@ -288,6 +253,83 @@
[o_window setWindowLevel:i_level]; [o_window setWindowLevel:i_level];
} }
- (void)setFullscreen:(int)i_full forWindow:(vout_window_t *)p_wnd
{
intf_thread_t *p_intf = VLCIntf;
BOOL b_nativeFullscreenMode = [[VLCMain sharedInstance] nativeFullscreenMode];
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);
VLCVideoWindowCommon *o_current_window = nil;
if(p_wnd)
o_current_window = [o_vout_dict objectForKey:[NSValue valueWithPointer:p_wnd]];
if (b_nativeFullscreenMode) {
if(!o_current_window)
o_current_window = [VLCMainWindow sharedInstance];
assert(o_current_window);
// fullscreen might be triggered twice (vout event)
// so ignore duplicate events here
if((b_fullscreen && !([o_current_window fullscreen] || [o_current_window enteringFullscreenTransition])) ||
(!b_fullscreen && [o_current_window fullscreen])) {
[o_current_window toggleFullScreen:self];
}
if (b_fullscreen)
[NSApp setPresentationOptions:(NSApplicationPresentationFullScreen | NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
else
[NSApp setPresentationOptions:(NSApplicationPresentationDefault)];
} else {
assert(o_current_window);
if (b_fullscreen) {
input_thread_t * p_input = pl_CurrentInput(p_intf);
if (p_input != NULL && [[VLCMain sharedInstance] activeVideoPlayback]) {
// activate app, as method can also be triggered from outside the app (prevents nasty window layout)
[NSApp activateIgnoringOtherApps:YES];
[o_current_window enterFullscreen];
}
if (p_input)
vlc_object_release(p_input);
} else {
// leaving fullscreen is always allowed
[o_current_window leaveFullscreen];
}
}
}
#pragma mark -
#pragma mark Misc methods
- (void)updateWindowsControlsBarWithSelector:(SEL)aSel
{
[o_vout_dict enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
if ([obj respondsToSelector:@selector(controlsBar)]) {
id o_controlsBar = [obj controlsBar];
if (o_controlsBar)
[o_controlsBar performSelector:aSel];
}
}];
}
- (void)updateWindowsUsingBlock:(void (^)(VLCVideoWindowCommon *o_window))windowUpdater
{
[o_vout_dict enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
if ([obj isKindOfClass: [NSWindow class]])
windowUpdater(obj);
}];
}
- (void)updateWindowLevelForHelperWindows:(NSInteger)i_level - (void)updateWindowLevelForHelperWindows:(NSInteger)i_level
{ {
if (var_InheritBool(VLCIntf, "video-wallpaper")) if (var_InheritBool(VLCIntf, "video-wallpaper"))
......
...@@ -177,8 +177,6 @@ struct intf_sys_t ...@@ -177,8 +177,6 @@ struct intf_sys_t
- (void)updateCurrentlyUsedHotkeys; - (void)updateCurrentlyUsedHotkeys;
- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event force:(BOOL)b_force; - (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event force:(BOOL)b_force;
- (void)setFullscreen:(int)i_full forWindow:(vout_window_t *)p_wnd;
- (void)PlaylistItemChanged; - (void)PlaylistItemChanged;
- (void)playbackStatusUpdated; - (void)playbackStatusUpdated;
- (void)sendDistributedNotificationWithUpdatedPlaybackStatus; - (void)sendDistributedNotificationWithUpdatedPlaybackStatus;
......
...@@ -172,8 +172,8 @@ int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg) ...@@ -172,8 +172,8 @@ int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg)
int i_full = 1; int i_full = 1;
SEL sel = @selector(setFullscreen:forWindow:); SEL sel = @selector(setFullscreen:forWindow:);
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[[VLCMain sharedInstance] methodSignatureForSelector:sel]]; NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[[[VLCMain sharedInstance] voutController] methodSignatureForSelector:sel]];
[inv setTarget:[VLCMain sharedInstance]]; [inv setTarget:[[VLCMain sharedInstance] voutController]];
[inv setSelector:sel]; [inv setSelector:sel];
[inv setArgument:&i_full atIndex:2]; [inv setArgument:&i_full atIndex:2];
[inv setArgument:&p_wnd atIndex:3]; [inv setArgument:&p_wnd atIndex:3];
...@@ -236,8 +236,8 @@ static int WindowControl(vout_window_t *p_wnd, int i_query, va_list args) ...@@ -236,8 +236,8 @@ static int WindowControl(vout_window_t *p_wnd, int i_query, va_list args)
int i_full = va_arg(args, int); int i_full = va_arg(args, int);
SEL sel = @selector(setFullscreen:forWindow:); SEL sel = @selector(setFullscreen:forWindow:);
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[[VLCMain sharedInstance] methodSignatureForSelector:sel]]; NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[[[VLCMain sharedInstance] voutController] methodSignatureForSelector:sel]];
[inv setTarget:[VLCMain sharedInstance]]; [inv setTarget:[[VLCMain sharedInstance] voutController]];
[inv setSelector:sel]; [inv setSelector:sel];
[inv setArgument:&i_full atIndex:2]; // starting at 2! [inv setArgument:&i_full atIndex:2]; // starting at 2!
[inv setArgument:&p_wnd atIndex:3]; [inv setArgument:&p_wnd atIndex:3];
...@@ -1253,54 +1253,6 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -1253,54 +1253,6 @@ static VLCMain *_o_sharedMainInstance = nil;
#pragma mark - #pragma mark -
#pragma mark Interface updaters #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) {
VLCVideoWindowCommon *o_active_window = nil;
if(p_wnd)
o_active_window = [o_vout_controller getWindow: p_wnd];
else
o_active_window = o_mainwindow;
// fullscreen might be triggered twice (vout event)
// so ignore duplicate events here
if((b_fullscreen && !([o_active_window fullscreen] || [o_active_window enteringFullscreenTransition])) ||
(!b_fullscreen && [o_active_window fullscreen])) {
[o_active_window 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 - (void)PlaylistItemChanged
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment