Commit dd86d6d4 authored by David Fuhrmann's avatar David Fuhrmann

macosx: adapt and fix fullscreen handling after latest changes

Now, every video window is responsible for the fullscreen handling for its own.
Furthermore, fullscreen now acts entirely in response to vout events, and not over the
playlist fullscreen variable callback anymore.
Native fullscreen mode should also work correctly, but of course only
for embedded video in mainwindow.
parent 6c1febea
...@@ -561,6 +561,8 @@ static VLCCoreInteraction *_o_sharedInstance = nil; ...@@ -561,6 +561,8 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
if (p_vout) { if (p_vout) {
var_SetBool(p_vout, "fullscreen", b_fs); var_SetBool(p_vout, "fullscreen", b_fs);
vlc_object_release(p_vout); vlc_object_release(p_vout);
} else { // e.g. lion fullscreen toggle
[[VLCMain sharedInstance] setFullscreen:b_fs forWindow:nil];
} }
} }
......
...@@ -89,27 +89,20 @@ ...@@ -89,27 +89,20 @@
BOOL b_nonembedded; BOOL b_nonembedded;
BOOL b_podcastView_displayed; BOOL b_podcastView_displayed;
VLCWindow * o_fullscreen_window;
NSViewAnimation * o_fullscreen_anim1;
NSViewAnimation * o_fullscreen_anim2;
NSViewAnimation * o_makekey_anim;
NSView * o_temp_view;
/* set to yes if we are fullscreen and all animations are over */ /* set to yes if we are fullscreen and all animations are over */
BOOL b_fullscreen; BOOL b_fullscreen;
BOOL b_window_is_invisible;
NSRecursiveLock * o_animation_lock;
NSTimer *t_hide_mouse_timer; NSTimer *t_hide_mouse_timer;
VLCColorView * o_color_backdrop; VLCColorView * o_color_backdrop;
NSInteger i_originalLevel;
id o_current_video_window;
NSRect frameBeforePlayback; NSRect frameBeforePlayback;
} }
+ (VLCMainWindow *)sharedInstance; + (VLCMainWindow *)sharedInstance;
@property (readonly) BOOL fullscreen; @property (readwrite) BOOL fullscreen;
@property (readonly) BOOL nativeFullscreenMode;
@property (readonly) VLCFSPanel* fsPanel;
- (VLCMainWindowControlsBar *)controlsBar; - (VLCMainWindowControlsBar *)controlsBar;
...@@ -135,22 +128,14 @@ ...@@ -135,22 +128,14 @@
- (void)setPlay; - (void)setPlay;
- (void)updateVolumeSlider; - (void)updateVolumeSlider;
- (void)showFullscreenController;
- (VLCVoutView *)setupVout:(vout_window_t *)p_wnd; - (VLCVoutView *)setupVout:(vout_window_t *)p_wnd;
- (void)setVideoplayEnabled; - (void)setVideoplayEnabled;
- (void)hideMouseCursor:(NSTimer *)timer; - (void)hideMouseCursor:(NSTimer *)timer;
- (void)recreateHideMouseTimer; - (void)recreateHideMouseTimer;
/* fullscreen handling */
- (void)showFullscreenController;
- (void)lockFullscreenAnimation;
- (void)unlockFullscreenAnimation;
- (void)enterFullscreen;
- (void)leaveFullscreen;
- (void)leaveFullscreenAndFadeOut: (BOOL)fadeout;
- (void)hasEndedFullscreen;
- (void)hasBecomeFullscreen;
/* lion's native fullscreen handling */ /* lion's native fullscreen handling */
- (void)windowWillEnterFullScreen:(NSNotification *)notification; - (void)windowWillEnterFullScreen:(NSNotification *)notification;
- (void)windowDidEnterFullScreen:(NSNotification *)notification; - (void)windowDidEnterFullScreen:(NSNotification *)notification;
......
This diff is collapsed.
...@@ -175,13 +175,14 @@ ...@@ -175,13 +175,14 @@
[[self window] performZoom: sender]; [[self window] performZoom: sender];
else if (sender == o_fullscreen_btn) { else if (sender == o_fullscreen_btn) {
// set fs directly to true, as the vars can be already true in some configs // set fs directly to true, as the vars can be already true in some configs
var_SetBool(pl_Get(VLCIntf), "fullscreen", true);
vout_thread_t *p_vout = getVout(); vout_thread_t *p_vout = getVout();
if (p_vout) { if (p_vout) {
var_SetBool(p_vout, "fullscreen", true); var_SetBool(p_vout, "fullscreen", true);
vlc_object_release(p_vout); vlc_object_release(p_vout);
} else { // e.g. lion fullscreen toggle
[[VLCMain sharedInstance] setFullscreen:true forWindow:nil];
} }
} else } else
msg_Err(VLCIntf, "unknown button action sender"); msg_Err(VLCIntf, "unknown button action sender");
......
...@@ -40,6 +40,8 @@ ...@@ -40,6 +40,8 @@
- (void)updateWindowsControlsBarWithSelector:(SEL)aSel; - (void)updateWindowsControlsBarWithSelector:(SEL)aSel;
- (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)setNativeVideoSize:(NSSize)size forWindow:(vout_window_t *)p_wnd;
@end @end
...@@ -54,6 +54,9 @@ ...@@ -54,6 +54,9 @@
return; return;
} }
if ([[VLCMainWindow sharedInstance] fullscreen] && ![[VLCMainWindow sharedInstance] nativeFullscreenMode])
[o_window leaveFullscreen];
if (![NSStringFromClass([o_window class]) isEqualToString:@"VLCMainWindow"]) { if (![NSStringFromClass([o_window class]) isEqualToString:@"VLCMainWindow"]) {
[o_window orderOut:self]; [o_window orderOut:self];
} }
...@@ -70,6 +73,17 @@ ...@@ -70,6 +73,17 @@
}]; }];
} }
- (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];
}
- (void)updateWindowsUsingBlock:(void (^)(VLCVideoWindowCommon *o_window))windowUpdater - (void)updateWindowsUsingBlock:(void (^)(VLCVideoWindowCommon *o_window))windowUpdater
{ {
[o_vout_dict enumerateKeysAndObjectsUsingBlock:^(id key, VLCVideoWindowCommon *o_window, BOOL *stop) { [o_vout_dict enumerateKeysAndObjectsUsingBlock:^(id key, VLCVideoWindowCommon *o_window, BOOL *stop) {
......
...@@ -69,7 +69,7 @@ static const float f_min_video_height = 70.0; ...@@ -69,7 +69,7 @@ static const float f_min_video_height = 70.0;
* Common code for main window, detached window and extra video window * Common code for main window, detached window and extra video window
*****************************************************************************/ *****************************************************************************/
@interface VLCVideoWindowCommon : VLCWindow <NSWindowDelegate> @interface VLCVideoWindowCommon : VLCWindow <NSWindowDelegate, NSAnimationDelegate>
{ {
NSRect previousSavedFrame; NSRect previousSavedFrame;
BOOL b_dark_interface; BOOL b_dark_interface;
...@@ -80,6 +80,20 @@ static const float f_min_video_height = 70.0; ...@@ -80,6 +80,20 @@ static const float f_min_video_height = 70.0;
IBOutlet VLCControlsBarCommon *o_controls_bar; IBOutlet VLCControlsBarCommon *o_controls_bar;
NSSize nativeVideoSize; NSSize nativeVideoSize;
// variables for fullscreen handling
VLCVideoWindowCommon *o_current_video_window;
VLCWindow * o_fullscreen_window;
NSViewAnimation * o_fullscreen_anim1;
NSViewAnimation * o_fullscreen_anim2;
NSViewAnimation * o_makekey_anim;
NSView * o_temp_view;
BOOL b_window_is_invisible;
NSRecursiveLock * o_animation_lock;
NSInteger i_originalLevel;
} }
@property (nonatomic, assign) VLCVoutView* videoView; @property (nonatomic, assign) VLCVoutView* videoView;
...@@ -90,4 +104,8 @@ static const float f_min_video_height = 70.0; ...@@ -90,4 +104,8 @@ static const float f_min_video_height = 70.0;
- (void)setTitle:(NSString *)title; - (void)setTitle:(NSString *)title;
/* fullscreen handling */
- (void)enterFullscreen;
- (void)leaveFullscreen;
@end @end
\ No newline at end of file
This diff is collapsed.
...@@ -172,9 +172,10 @@ struct intf_sys_t ...@@ -172,9 +172,10 @@ struct intf_sys_t
- (BOOL)activeVideoPlayback; - (BOOL)activeVideoPlayback;
- (void)applicationWillTerminate:(NSNotification *)notification; - (void)applicationWillTerminate:(NSNotification *)notification;
- (void)updateCurrentlyUsedHotkeys; - (void)updateCurrentlyUsedHotkeys;
- (void)fullscreenChanged;
- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event force:(BOOL)b_force; - (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event force:(BOOL)b_force;
- (void)checkFullscreenChange:(NSNumber *)o_full;
- (void)setFullscreen:(int)i_full forWindow:(vout_window_t *)p_wnd;
- (void)PlaylistItemChanged; - (void)PlaylistItemChanged;
- (void)playbackStatusUpdated; - (void)playbackStatusUpdated;
- (void)sendDistributedNotificationWithUpdatedPlaybackStatus; - (void)sendDistributedNotificationWithUpdatedPlaybackStatus;
......
...@@ -162,6 +162,20 @@ int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg) ...@@ -162,6 +162,20 @@ int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg)
[inv performSelectorOnMainThread:@selector(invoke) withObject:nil [inv performSelectorOnMainThread:@selector(invoke) withObject:nil
waitUntilDone:NO]; waitUntilDone:NO];
// TODO: find a cleaner way for "start in fullscreen"
if (var_GetBool(pl_Get(VLCIntf), "fullscreen")) {
int i_full = 1;
SEL sel = @selector(setFullscreen:forWindow:);
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[[VLCMain sharedInstance] methodSignatureForSelector:sel]];
[inv setTarget:[VLCMain sharedInstance]];
[inv setSelector:sel];
[inv setArgument:&i_full atIndex:2];
[inv setArgument:&p_wnd atIndex:3];
[inv performSelectorOnMainThread:@selector(invoke) withObject:nil
waitUntilDone:NO];
}
[[VLCMain sharedInstance] setActiveVideoPlayback: YES]; [[VLCMain sharedInstance] setActiveVideoPlayback: YES];
p_wnd->control = WindowControl; p_wnd->control = WindowControl;
p_wnd->sys = (vout_window_sys_t *)VLCIntf; p_wnd->sys = (vout_window_sys_t *)VLCIntf;
...@@ -202,7 +216,18 @@ static int WindowControl(vout_window_t *p_wnd, int i_query, va_list args) ...@@ -202,7 +216,18 @@ static int WindowControl(vout_window_t *p_wnd, int i_query, va_list args)
{ {
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
int i_full = va_arg(args, int); int i_full = va_arg(args, int);
[[VLCMain sharedInstance] performSelectorOnMainThread:@selector(checkFullscreenChange:) withObject:[NSNumber numberWithInt: i_full] waitUntilDone:NO];
SEL sel = @selector(setFullscreen:forWindow:);
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[[VLCMain sharedInstance] methodSignatureForSelector:sel]];
[inv setTarget:[VLCMain sharedInstance]];
[inv setSelector:sel];
[inv setArgument:&i_full atIndex:2]; // starting at 2!
[inv setArgument:&p_wnd atIndex:3];
[inv performSelectorOnMainThread:@selector(invoke) withObject:nil
waitUntilDone:NO];
//[[VLCMain sharedInstance] performSelectorOnMainThread:@selector(fullscreenChanged:) withObject:[NSValue valueWithPointer:p_wnd] waitUntilDone:NO];
[o_pool release]; [o_pool release];
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -411,22 +436,6 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable, ...@@ -411,22 +436,6 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
return VLC_SUCCESS; return VLC_SUCCESS;
} }
/*****************************************************************************
* FullscreenChanged: Callback triggered by the fullscreen-change playlist
* variable, to let the intf update the controller.
*****************************************************************************/
static int FullscreenChanged(vlc_object_t *p_this, const char *psz_variable,
vlc_value_t old_val, vlc_value_t new_val, void *param)
{
intf_thread_t * p_intf = VLCIntf;
if (p_intf) {
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
[[VLCMain sharedInstance] performSelectorOnMainThread:@selector(fullscreenChanged) withObject:nil waitUntilDone:NO];
[o_pool release];
}
return VLC_SUCCESS;
}
/***************************************************************************** /*****************************************************************************
* DialogCallback: Callback triggered by the "dialog-*" variables * DialogCallback: Callback triggered by the "dialog-*" variables
* to let the intf display error and interaction dialogs * to let the intf display error and interaction dialogs
...@@ -609,7 +618,6 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -609,7 +618,6 @@ static VLCMain *_o_sharedMainInstance = nil;
val.b_bool = false; val.b_bool = false;
var_AddCallback(p_playlist, "fullscreen", FullscreenChanged, self);
var_AddCallback(p_intf->p_libvlc, "intf-toggle-fscontrol", ShowController, self); var_AddCallback(p_intf->p_libvlc, "intf-toggle-fscontrol", ShowController, self);
var_AddCallback(p_intf->p_libvlc, "intf-show", ShowController, self); var_AddCallback(p_intf->p_libvlc, "intf-show", ShowController, self);
// var_AddCallback(p_playlist, "item-change", PLItemChanged, self); // var_AddCallback(p_playlist, "item-change", PLItemChanged, self);
...@@ -796,7 +804,6 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -796,7 +804,6 @@ static VLCMain *_o_sharedMainInstance = nil;
var_DelCallback(p_playlist, "loop", PlaybackModeUpdated, self); var_DelCallback(p_playlist, "loop", PlaybackModeUpdated, self);
var_DelCallback(p_playlist, "volume", VolumeUpdated, self); var_DelCallback(p_playlist, "volume", VolumeUpdated, self);
var_DelCallback(p_playlist, "mute", VolumeUpdated, self); var_DelCallback(p_playlist, "mute", VolumeUpdated, self);
var_DelCallback(p_playlist, "fullscreen", FullscreenChanged, self);
var_DelCallback(p_intf->p_libvlc, "intf-toggle-fscontrol", ShowController, self); var_DelCallback(p_intf->p_libvlc, "intf-toggle-fscontrol", ShowController, self);
var_DelCallback(p_intf->p_libvlc, "intf-show", ShowController, self); var_DelCallback(p_intf->p_libvlc, "intf-show", ShowController, self);
...@@ -1204,10 +1211,16 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -1204,10 +1211,16 @@ static VLCMain *_o_sharedMainInstance = nil;
#pragma mark - #pragma mark -
#pragma mark Interface updaters #pragma mark Interface updaters
- (void)fullscreenChanged - (void)setFullscreen:(int)i_full forWindow:(vout_window_t *)p_wnd
{ {
playlist_t * p_playlist = pl_Get(VLCIntf); if (!p_intf || (!b_nativeFullscreenMode && !p_wnd))
BOOL b_fullscreen = var_GetBool(p_playlist, "fullscreen"); 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) { if (b_nativeFullscreenMode) {
// this is called twice in certain situations, so only toogle if we really need to // this is called twice in certain situations, so only toogle if we really need to
...@@ -1220,30 +1233,25 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -1220,30 +1233,25 @@ static VLCMain *_o_sharedMainInstance = nil;
else else
[NSApp setPresentationOptions:(NSApplicationPresentationDefault)]; [NSApp setPresentationOptions:(NSApplicationPresentationDefault)];
} else { } else {
assert(p_wnd);
if (b_fullscreen) { if (b_fullscreen) {
input_thread_t * p_input = pl_CurrentInput(VLCIntf); input_thread_t * p_input = pl_CurrentInput(p_intf);
if (p_input != NULL && [self activeVideoPlayback]) { if (p_input != NULL && [self activeVideoPlayback]) {
// activate app, as method can also be triggered from outside the app (prevents nasty window layout) // activate app, as method can also be triggered from outside the app (prevents nasty window layout)
[NSApp activateIgnoringOtherApps:YES]; [NSApp activateIgnoringOtherApps:YES];
[o_mainwindow performSelectorOnMainThread:@selector(enterFullscreen) withObject:nil waitUntilDone:NO]; [o_vout_controller updateWindow:p_wnd withSelector:@selector(enterFullscreen)];
} }
if (p_input) if (p_input)
vlc_object_release(p_input); vlc_object_release(p_input);
} else { } else {
// leaving fullscreen is always allowed // leaving fullscreen is always allowed
[o_mainwindow performSelectorOnMainThread:@selector(leaveFullscreen) withObject:nil waitUntilDone:NO]; [o_vout_controller updateWindow:p_wnd withSelector:@selector(leaveFullscreen)];
} }
} }
} }
- (void)checkFullscreenChange:(NSNumber *)o_full
{
BOOL b_full = [o_full boolValue];
if (p_intf && !var_GetBool(pl_Get(p_intf), "fullscreen") != !b_full) {
var_SetBool(pl_Get(p_intf), "fullscreen", b_full);
}
}
- (void)PlaylistItemChanged - (void)PlaylistItemChanged
{ {
if (p_current_input && (p_current_input->b_dead || !vlc_object_alive(p_current_input))) { if (p_current_input && (p_current_input->b_dead || !vlc_object_alive(p_current_input))) {
......
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