Commit b04f1e54 authored by David Fuhrmann's avatar David Fuhrmann
Browse files

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

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