Commit b04f1e54 authored by David Fuhrmann's avatar David Fuhrmann

macosx: only show fspanel when needed, additional fixed for lion fullscreen behavior

parent 60eba2be
...@@ -92,9 +92,6 @@ ...@@ -92,9 +92,6 @@
BOOL b_podcastView_displayed; BOOL b_podcastView_displayed;
/* set to yes if we are fullscreen and all animations are over */
BOOL b_fullscreen;
NSTimer *t_hide_mouse_timer; NSTimer *t_hide_mouse_timer;
VLCColorView * o_color_backdrop; VLCColorView * o_color_backdrop;
...@@ -102,7 +99,6 @@ ...@@ -102,7 +99,6 @@
NSRect frameBeforePlayback; NSRect frameBeforePlayback;
} }
+ (VLCMainWindow *)sharedInstance; + (VLCMainWindow *)sharedInstance;
@property (readwrite) BOOL fullscreen;
@property (readonly) BOOL nativeFullscreenMode; @property (readonly) BOOL nativeFullscreenMode;
@property (readwrite) BOOL nonembedded; @property (readwrite) BOOL nonembedded;
......
...@@ -56,7 +56,6 @@ ...@@ -56,7 +56,6 @@
@implementation VLCMainWindow @implementation VLCMainWindow
@synthesize fullscreen=b_fullscreen;
@synthesize nativeFullscreenMode=b_nativeFullscreenMode; @synthesize nativeFullscreenMode=b_nativeFullscreenMode;
@synthesize nonembedded=b_nonembedded; @synthesize nonembedded=b_nonembedded;
@synthesize fsPanel=o_fspanel; @synthesize fsPanel=o_fspanel;
...@@ -809,8 +808,18 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -809,8 +808,18 @@ static VLCMainWindow *_o_sharedInstance = nil;
- (void)showFullscreenController - (void)showFullscreenController
{ {
if (b_fullscreen && [[VLCMain sharedInstance] activeVideoPlayback])
[o_fspanel fadeIn]; id currentWindow = [NSApp keyWindow];
if ([currentWindow respondsToSelector:@selector(hasActiveVideo)] && [currentWindow hasActiveVideo]) {
if ([currentWindow respondsToSelector:@selector(fullscreen)] && [currentWindow fullscreen]) {
if ([[VLCMain sharedInstance] activeVideoPlayback])
[o_fspanel fadeIn];
}
}
} }
- (void)makeKeyAndOrderFront: (id)sender - (void)makeKeyAndOrderFront: (id)sender
......
...@@ -198,10 +198,12 @@ ...@@ -198,10 +198,12 @@
return; return;
} }
if ([[VLCMainWindow sharedInstance] fullscreen] && ![[VLCMainWindow sharedInstance] nativeFullscreenMode]) if ([o_window fullscreen] && ![[VLCMainWindow sharedInstance] nativeFullscreenMode])
[o_window leaveFullscreen]; [o_window leaveFullscreen];
if ([[VLCMainWindow sharedInstance] fullscreen] && [[VLCMainWindow sharedInstance] nativeFullscreenMode]) if (![NSStringFromClass([o_window class]) isEqualToString:@"VLCMainWindow"] &&
[o_window fullscreen] &&
[[VLCMainWindow sharedInstance] nativeFullscreenMode])
[o_window toggleFullScreen: self]; [o_window toggleFullScreen: self];
......
...@@ -319,7 +319,7 @@ ...@@ -319,7 +319,7 @@
// This is the result of [NSEvent standardMagnificationThreshold]. // This is the result of [NSEvent standardMagnificationThreshold].
// Unfortunately, this is a private API, currently. // Unfortunately, this is a private API, currently.
CGFloat f_threshold = 0.3; CGFloat f_threshold = 0.3;
BOOL b_fullscreen = [[VLCMainWindow sharedInstance] fullscreen]; BOOL b_fullscreen = [(VLCVideoWindowCommon *)[self window] fullscreen];
if ((f_cumulated_magnification > f_threshold && !b_fullscreen) || (f_cumulated_magnification < -f_threshold && b_fullscreen)) { if ((f_cumulated_magnification > f_threshold && !b_fullscreen) || (f_cumulated_magnification < -f_threshold && b_fullscreen)) {
f_cumulated_magnification = 0.0; f_cumulated_magnification = 0.0;
......
...@@ -40,10 +40,22 @@ ...@@ -40,10 +40,22 @@
BOOL b_canBecomeMainWindow; BOOL b_canBecomeMainWindow;
BOOL b_isset_canBecomeMainWindow; BOOL b_isset_canBecomeMainWindow;
NSViewAnimation *o_current_animation; NSViewAnimation *o_current_animation;
BOOL b_has_active_video;
/*
* normal fullscreen: YES when all animations are over
* lion fullscreen: toggled when fs animation starts
* for fullscreen window: always YES
*/
BOOL b_fullscreen;
} }
@property (readwrite) BOOL canBecomeKeyWindow; @property (readwrite) BOOL canBecomeKeyWindow;
@property (readwrite) BOOL canBecomeMainWindow; @property (readwrite) BOOL canBecomeMainWindow;
@property (nonatomic, readwrite) BOOL hasActiveVideo;
@property (nonatomic, readwrite) BOOL fullscreen;
/* animate mode is only supported in >=10.4 */ /* animate mode is only supported in >=10.4 */
- (void)orderFront: (id)sender animate: (BOOL)animate; - (void)orderFront: (id)sender animate: (BOOL)animate;
...@@ -95,12 +107,11 @@ static const float f_min_video_height = 70.0; ...@@ -95,12 +107,11 @@ static const float f_min_video_height = 70.0;
NSRecursiveLock * o_animation_lock; NSRecursiveLock * o_animation_lock;
NSInteger i_originalLevel; NSInteger i_originalLevel;
BOOL b_has_active_video; NSTimer *t_hide_mouse_timer;
} }
@property (nonatomic, assign) VLCVoutView* videoView; @property (nonatomic, assign) VLCVoutView* videoView;
@property (readonly) VLCControlsBarCommon* controlsBar; @property (readonly) VLCControlsBarCommon* controlsBar;
@property (nonatomic, readwrite) BOOL hasActiveVideo;
- (void)setWindowLevel:(NSInteger)i_state; - (void)setWindowLevel:(NSInteger)i_state;
......
...@@ -35,6 +35,10 @@ ...@@ -35,6 +35,10 @@
*****************************************************************************/ *****************************************************************************/
@implementation VLCWindow @implementation VLCWindow
@synthesize hasActiveVideo=b_has_active_video;
@synthesize fullscreen=b_fullscreen;
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)styleMask - (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)styleMask
backing:(NSBackingStoreType)backingType defer:(BOOL)flag backing:(NSBackingStoreType)backingType defer:(BOOL)flag
{ {
...@@ -239,7 +243,6 @@ ...@@ -239,7 +243,6 @@
@synthesize videoView=o_video_view; @synthesize videoView=o_video_view;
@synthesize controlsBar=o_controls_bar; @synthesize controlsBar=o_controls_bar;
@synthesize hasActiveVideo=b_has_active_video;
#pragma mark - #pragma mark -
#pragma mark Init #pragma mark Init
...@@ -503,7 +506,7 @@ ...@@ -503,7 +506,7 @@
- (void)resizeWindow - (void)resizeWindow
{ {
if ([[VLCMainWindow sharedInstance] fullscreen]) if ([self fullscreen])
return; return;
NSRect window_rect = [self getWindowRectForProposedVideoViewSize:nativeVideoSize]; NSRect window_rect = [self getWindowRectForProposedVideoViewSize:nativeVideoSize];
...@@ -524,7 +527,7 @@ ...@@ -524,7 +527,7 @@
return proposedFrameSize; return proposedFrameSize;
// needed when entering lion fullscreen mode // needed when entering lion fullscreen mode
if ([[VLCMainWindow sharedInstance] fullscreen]) if ([self fullscreen])
return proposedFrameSize; return proposedFrameSize;
if ([[VLCCoreInteraction sharedInstance] aspectRatioIsLocked]) { if ([[VLCCoreInteraction sharedInstance] aspectRatioIsLocked]) {
...@@ -545,11 +548,25 @@ ...@@ -545,11 +548,25 @@
#pragma mark - #pragma mark -
#pragma mark Lion native fullscreen handling #pragma mark Lion native fullscreen handling
- (void)becomeKeyWindow
{
[super becomeKeyWindow];
// change fspanel state for the case when multiple windows are in fullscreen
if ([self hasActiveVideo] && [self fullscreen])
[[[VLCMainWindow sharedInstance] fsPanel] setActive:nil];
else
[[[VLCMainWindow sharedInstance] fsPanel] setNonActive:nil];
}
- (void)windowWillEnterFullScreen:(NSNotification *)notification - (void)windowWillEnterFullScreen:(NSNotification *)notification
{ {
// workaround, see #6668 // workaround, see #6668
[NSApp setPresentationOptions:(NSApplicationPresentationFullScreen | NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)]; [NSApp setPresentationOptions:(NSApplicationPresentationFullScreen | NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
[self setFullscreen: YES];
var_SetBool(pl_Get(VLCIntf), "fullscreen", true); var_SetBool(pl_Get(VLCIntf), "fullscreen", true);
if ([self hasActiveVideo]) { if ([self hasActiveVideo]) {
...@@ -561,7 +578,6 @@ ...@@ -561,7 +578,6 @@
} }
[o_video_view setFrame: [[self contentView] frame]]; [o_video_view setFrame: [[self contentView] frame]];
[[VLCMainWindow sharedInstance] setFullscreen: YES];
[[VLCMainWindow sharedInstance] recreateHideMouseTimer]; [[VLCMainWindow sharedInstance] recreateHideMouseTimer];
i_originalLevel = [self level]; i_originalLevel = [self level];
...@@ -609,6 +625,8 @@ ...@@ -609,6 +625,8 @@
- (void)windowWillExitFullScreen:(NSNotification *)notification - (void)windowWillExitFullScreen:(NSNotification *)notification
{ {
[self setFullscreen: NO];
var_SetBool(pl_Get(VLCIntf), "fullscreen", false); var_SetBool(pl_Get(VLCIntf), "fullscreen", false);
if ([self hasActiveVideo]) { if ([self hasActiveVideo]) {
...@@ -621,11 +639,10 @@ ...@@ -621,11 +639,10 @@
[NSCursor setHiddenUntilMouseMoves: NO]; [NSCursor setHiddenUntilMouseMoves: NO];
[[[VLCMainWindow sharedInstance] fsPanel] setNonActive: nil]; [[[VLCMainWindow sharedInstance] fsPanel] setNonActive: nil];
[[[VLCMain sharedInstance] voutController] updateWindowLevelForHelperWindows: i_originalLevel]; [[[VLCMain sharedInstance] voutController] updateWindowLevelForHelperWindows: i_originalLevel];
[self setLevel:i_originalLevel]; [self setLevel:i_originalLevel];
[[VLCMainWindow sharedInstance] setFullscreen: NO];
if (b_dark_interface) { if (b_dark_interface) {
NSRect winrect; NSRect winrect;
CGFloat f_titleBarHeight = [o_titlebar_view frame].size.height; CGFloat f_titleBarHeight = [o_titlebar_view frame].size.height;
...@@ -712,6 +729,8 @@ ...@@ -712,6 +729,8 @@
[o_fullscreen_window setBackgroundColor: [NSColor blackColor]]; [o_fullscreen_window setBackgroundColor: [NSColor blackColor]];
[o_fullscreen_window setCanBecomeKeyWindow: YES]; [o_fullscreen_window setCanBecomeKeyWindow: YES];
[o_fullscreen_window setCanBecomeMainWindow: YES]; [o_fullscreen_window setCanBecomeMainWindow: YES];
[o_fullscreen_window setHasActiveVideo: YES];
[o_fullscreen_window setFullscreen: YES];
if (![self isVisible] || [self alphaValue] == 0.0) { if (![self isVisible] || [self alphaValue] == 0.0) {
/* We don't animate if we are not visible, instead we /* We don't animate if we are not visible, instead we
...@@ -761,7 +780,7 @@ ...@@ -761,7 +780,7 @@
} }
/* We are in fullscreen (and no animation is running) */ /* We are in fullscreen (and no animation is running) */
if ([[VLCMainWindow sharedInstance] fullscreen]) { if ([self fullscreen]) {
/* Make sure we are hidden */ /* Make sure we are hidden */
[self orderOut: self]; [self orderOut: self];
...@@ -834,7 +853,7 @@ ...@@ -834,7 +853,7 @@
if ([self isVisible]) if ([self isVisible])
[self orderOut: self]; [self orderOut: self];
[[VLCMainWindow sharedInstance] setFullscreen:YES]; [self setFullscreen:YES];
[self unlockFullscreenAnimation]; [self unlockFullscreenAnimation];
} }
...@@ -950,7 +969,7 @@ ...@@ -950,7 +969,7 @@
- (void)hasEndedFullscreen - (void)hasEndedFullscreen
{ {
[[VLCMainWindow sharedInstance] setFullscreen:NO]; [self setFullscreen:NO];
/* This function is private and should be only triggered at the end of the fullscreen change animation */ /* This function is private and should be only triggered at the end of the fullscreen change animation */
/* Make sure we don't see the o_video_view disappearing of the screen during this operation */ /* Make sure we don't see the o_video_view disappearing of the screen during this operation */
......
...@@ -184,12 +184,7 @@ ...@@ -184,12 +184,7 @@
{ {
b_nonActive = NO; b_nonActive = NO;
id currentWindow = [NSApp keyWindow]; [[VLCMain sharedInstance] showFullscreenController];
if ([currentWindow respondsToSelector:@selector(hasActiveVideo)]) {
if ([currentWindow hasActiveVideo]) {
[[VLCMain sharedInstance] showFullscreenController];
}
}
} }
/* This routine is called repeatedly to fade in the window */ /* This routine is called repeatedly to fade in the window */
......
...@@ -1264,14 +1264,18 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -1264,14 +1264,18 @@ static VLCMain *_o_sharedMainInstance = nil;
var_SetBool(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 VLCVideoWindowCommon *o_active_window = nil;
if ((b_fullscreen && !([NSApp currentSystemPresentationOptions] & NSApplicationPresentationFullScreen)) || if(p_wnd)
(!b_fullscreen && ([NSApp currentSystemPresentationOptions] & NSApplicationPresentationFullScreen))) { o_active_window = [o_vout_controller getWindow: p_wnd];
if(p_wnd) { else
VLCVideoWindowCommon *window = [o_vout_controller getWindow: p_wnd]; o_active_window = o_mainwindow;
[window toggleFullScreen:self];
} else // fullscreen might be triggered twice (vout event)
[o_mainwindow toggleFullScreen: self]; // TODO // so ignore duplicate events here
if((b_fullscreen && ![o_active_window fullscreen]) ||
(!b_fullscreen && [o_active_window fullscreen])) {
[o_active_window toggleFullScreen:self];
} }
if (b_fullscreen) if (b_fullscreen)
......
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