Commit 4fdb3cc9 authored by David Fuhrmann's avatar David Fuhrmann

macosx: add lion fullscreen support for detached windows

parent b302bf06
......@@ -132,6 +132,22 @@
if ([[o_bottombar_view window] styleMask] & NSResizableWindowMask)
[o_resize_view removeFromSuperviewWithoutNeedingDisplay];
// remove fullscreen button for lion fullscreen
if (b_nativeFullscreenMode) {
float f_width = [o_fullscreen_btn frame].size.width;
NSRect frame = [o_time_fld frame];
frame.origin.x += f_width;
[o_time_fld setFrame: frame];
frame = [o_progress_view frame];
frame.size.width = f_width + frame.size.width;
[o_progress_view setFrame: frame];
[o_fullscreen_btn removeFromSuperviewWithoutNeedingDisplay];
}
}
#pragma mark -
......@@ -382,6 +398,7 @@
{
[super awakeFromNib];
[o_stop_btn setToolTip: _NS("Stop")];
[[o_stop_btn cell] accessibilitySetOverrideValue:_NS("Click to stop playback.") forAttribute:NSAccessibilityDescriptionAttribute];
[[o_stop_btn cell] accessibilitySetOverrideValue:[o_stop_btn toolTip] forAttribute:NSAccessibilityTitleAttribute];
......@@ -484,11 +501,14 @@
[o_volume_sld setEnabled: b_mute];
[o_volume_up_btn setEnabled: b_mute];
// remove fullscreen button for lion fullscreen
if (b_nativeFullscreenMode) {
NSRect frame;
float f_width = [o_fullscreen_btn frame].size.width;
// == [o_fullscreen_btn frame].size.width;
// button is already removed!
float f_width = 29.;
#define moveItem(item) \
frame = [item frame]; \
frame.origin.x = f_width + frame.origin.x; \
......@@ -499,15 +519,11 @@ frame.origin.x = f_width + frame.origin.x; \
moveItem(o_volume_sld);
moveItem(o_volume_track_view);
moveItem(o_volume_down_btn);
moveItem(o_time_fld);
#undef moveItem
frame = [o_progress_view frame];
frame.size.width = f_width + frame.size.width;
[o_progress_view setFrame: frame];
[o_fullscreen_btn removeFromSuperviewWithoutNeedingDisplay];
// time field and progress bar are moved in super method!
}
b_show_jump_buttons = config_GetInt(VLCIntf, "macosx-show-playback-buttons");
if (b_show_jump_buttons)
......@@ -518,6 +534,7 @@ frame.origin.x = f_width + frame.origin.x; \
[self removePlaymodeButtons:YES];
[[VLCMain sharedInstance] playbackModeUpdated];
}
#pragma mark -
......
......@@ -140,11 +140,6 @@
- (void)hideMouseCursor:(NSTimer *)timer;
- (void)recreateHideMouseTimer;
/* lion's native fullscreen handling */
- (void)windowWillEnterFullScreen:(NSNotification *)notification;
- (void)windowDidEnterFullScreen:(NSNotification *)notification;
- (void)windowWillExitFullScreen:(NSNotification *)notification;
@end
@interface VLCDetachedVideoWindow : VLCVideoWindowCommon
......
......@@ -148,6 +148,9 @@ static VLCMainWindow *_o_sharedInstance = nil;
- (void)awakeFromNib
{
// sets lion fullscreen behaviour
[super awakeFromNib];
BOOL b_splitviewShouldBeHidden = NO;
/* setup the styled interface */
......@@ -200,12 +203,6 @@ static VLCMainWindow *_o_sharedInstance = nil;
[o_dropzone_view setFrame: [o_playlist_table frame]];
[o_left_split_view setFrame: [o_sidebar_view frame]];
if (b_nativeFullscreenMode) {
[self setCollectionBehavior: NSWindowCollectionBehaviorFullScreenPrimary];
} else {
[o_titlebar_view setFullscreenButtonHidden: YES];
}
if (!OSX_SNOW_LEOPARD) {
/* the default small size of the search field is slightly different on Lion, let's work-around that */
NSRect frame;
......@@ -790,7 +787,23 @@ static VLCMainWindow *_o_sharedInstance = nil;
[NSCursor setHiddenUntilMouseMoves: YES];
}
#pragma mark -
#pragma mark Lion native fullscreen handling
- (void)windowWillEnterFullScreen:(NSNotification *)notification
{
[super windowWillEnterFullScreen:notification];
// update split view frame after removing title bar
[o_split_view setFrame: [o_video_view frame]];
}
- (void)windowWillExitFullScreen:(NSNotification *)notification
{
[super windowWillExitFullScreen: notification];
// update split view frame after readding title bar
[o_split_view setFrame: [o_video_view frame]];
}
#pragma mark -
#pragma mark Fullscreen support
......@@ -834,109 +847,6 @@ static VLCMainWindow *_o_sharedInstance = nil;
/* fullscreenAnimation will be unlocked when animation ends */
}
#pragma mark -
#pragma mark Lion native fullscreen handling
- (void)windowWillEnterFullScreen:(NSNotification *)notification
{
// workaround, see #6668
[NSApp setPresentationOptions:(NSApplicationPresentationFullScreen | NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
var_SetBool(pl_Get(VLCIntf), "fullscreen", true);
vout_thread_t *p_vout = getVout();
if (p_vout) {
var_SetBool(p_vout, "fullscreen", true);
vlc_object_release(p_vout);
}
[o_video_view setFrame: [[self contentView] frame]];
b_fullscreen = YES;
[self recreateHideMouseTimer];
i_originalLevel = [self level];
[[[VLCMain sharedInstance] voutController] updateWindowLevelForHelperWindows: NSNormalWindowLevel];
[self setLevel:NSNormalWindowLevel];
if (b_dark_interface) {
[o_titlebar_view removeFromSuperviewWithoutNeedingDisplay];
NSRect winrect;
CGFloat f_titleBarHeight = [o_titlebar_view frame].size.height;
winrect = [self frame];
winrect.size.height = winrect.size.height - f_titleBarHeight;
[self setFrame: winrect display:NO animate:NO];
winrect = [o_split_view frame];
winrect.size.height = winrect.size.height + f_titleBarHeight;
[o_split_view setFrame: winrect];
}
if ([[VLCMain sharedInstance] activeVideoPlayback])
[[o_controls_bar bottomBarView] setHidden: YES];
[self setMovableByWindowBackground: NO];
}
- (void)windowDidEnterFullScreen:(NSNotification *)notification
{
// Indeed, we somehow can have an "inactive" fullscreen (but a visible window!).
// But this creates some problems when leaving fs over remote intfs, so activate app here.
[NSApp activateIgnoringOtherApps:YES];
[o_fspanel setVoutWasUpdated: self];
[o_fspanel setActive: nil];
NSArray *subviews = [[self videoView] subviews];
NSUInteger count = [subviews count];
for (NSUInteger x = 0; x < count; x++) {
if ([[subviews objectAtIndex:x] respondsToSelector:@selector(reshape)])
[[subviews objectAtIndex:x] reshape];
}
}
- (void)windowWillExitFullScreen:(NSNotification *)notification
{
var_SetBool(pl_Get(VLCIntf), "fullscreen", false);
vout_thread_t *p_vout = getVout();
if (p_vout) {
var_SetBool(p_vout, "fullscreen", false);
vlc_object_release(p_vout);
}
[o_video_view setFrame: [o_split_view frame]];
[NSCursor setHiddenUntilMouseMoves: NO];
[o_fspanel setNonActive: nil];
[[[VLCMain sharedInstance] voutController] updateWindowLevelForHelperWindows: i_originalLevel];
[self setLevel:i_originalLevel];
b_fullscreen = NO;
if (b_dark_interface) {
NSRect winrect;
CGFloat f_titleBarHeight = [o_titlebar_view frame].size.height;
winrect = [self frame];
[o_titlebar_view setFrame: NSMakeRect(0, winrect.size.height - f_titleBarHeight,
winrect.size.width, f_titleBarHeight)];
[[self contentView] addSubview: o_titlebar_view];
winrect.size.height = winrect.size.height + f_titleBarHeight;
[self setFrame: winrect display:NO animate:NO];
winrect = [o_split_view frame];
winrect.size.height = winrect.size.height - f_titleBarHeight;
[o_split_view setFrame: winrect];
[o_video_view setFrame: winrect];
}
if ([[VLCMain sharedInstance] activeVideoPlayback])
[[o_controls_bar bottomBarView] setHidden: NO];
[self setMovableByWindowBackground: YES];
}
#pragma mark -
#pragma mark split view delegate
- (CGFloat)splitView:(NSSplitView *)splitView constrainMaxCoordinate:(CGFloat)proposedMax ofSubviewAt:(NSInteger)dividerIndex
......@@ -1349,6 +1259,8 @@ static VLCMainWindow *_o_sharedInstance = nil;
- (void)awakeFromNib
{
// sets lion fullscreen behaviour
[super awakeFromNib];
[self setAcceptsMouseMovedEvents: YES];
if (b_dark_interface) {
......@@ -1366,8 +1278,6 @@ static VLCMainWindow *_o_sharedInstance = nil;
[o_titlebar_view setFrame: NSMakeRect(0, winrect.size.height - f_titleBarHeight, winrect.size.width, f_titleBarHeight)];
[[self contentView] addSubview: o_titlebar_view positioned: NSWindowAbove relativeTo: nil];
// native fs not supported with detached view yet
[o_titlebar_view setFullscreenButtonHidden: YES];
} else {
[self setBackgroundColor: [NSColor blackColor]];
}
......
......@@ -174,14 +174,8 @@
else if (sender == o_green_btn)
[[self window] performZoom: sender];
else if (sender == o_fullscreen_btn) {
// set fs directly to true, as the vars can be already true in some configs
vout_thread_t *p_vout = getVout();
if (p_vout) {
var_SetBool(p_vout, "fullscreen", true);
vlc_object_release(p_vout);
} else { // e.g. lion fullscreen toggle
[[VLCMain sharedInstance] setFullscreen:true forWindow:nil];
}
// same action as native fs button
[[self window] toggleFullScreen:self];
} else
msg_Err(VLCIntf, "unknown button action sender");
......
......@@ -47,6 +47,7 @@
- (void)removeVoutforDisplay:(NSValue *)o_key;
- (void)updateWindowsControlsBarWithSelector:(SEL)aSel;
- (VLCVideoWindowCommon *)getWindow:(vout_window_t *)p_wnd;
- (void)updateWindowsUsingBlock:(void (^)(VLCVideoWindowCommon *o_window))windowUpdater;
- (void)updateWindow:(vout_window_t *)p_wnd withSelector:(SEL)aSel;
......
......@@ -122,7 +122,7 @@
[[VLCMainWindow sharedInstance] setNonembedded:YES];
b_nonembedded = YES;
} else {
if ((var_InheritBool(VLCIntf, "embedded-video") && !b_multiple_vout_windows) || b_nativeFullscreenMode) {
if ((var_InheritBool(VLCIntf, "embedded-video") && !b_multiple_vout_windows)) {
// setup embedded video
o_vout_view = [[[VLCMainWindow sharedInstance] videoView] retain];
o_new_video_window = [[VLCMainWindow sharedInstance] retain];
......@@ -233,6 +233,14 @@
[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) {
......
......@@ -114,4 +114,9 @@ static const float f_min_video_height = 70.0;
- (void)enterFullscreen;
- (void)leaveFullscreen;
/* lion fullscreen handling */
- (void)windowWillEnterFullScreen:(NSNotification *)notification;
- (void)windowDidEnterFullScreen:(NSNotification *)notification;
- (void)windowWillExitFullScreen:(NSNotification *)notification;
@end
......@@ -275,6 +275,23 @@
[super dealloc];
}
- (void)awakeFromNib
{
BOOL b_nativeFullscreenMode = NO;
#ifdef MAC_OS_X_VERSION_10_7
if (!OSX_SNOW_LEOPARD)
b_nativeFullscreenMode = var_InheritBool(VLCIntf, "macosx-nativefullscreenmode");
#endif
if (b_nativeFullscreenMode) {
[self setCollectionBehavior: NSWindowCollectionBehaviorFullScreenPrimary];
} else {
[o_titlebar_view setFullscreenButtonHidden: YES];
}
[super awakeFromNib];
}
- (void)setTitle:(NSString *)title
{
if (!title || [title length] < 1)
......@@ -524,6 +541,109 @@
return proposedFrameSize;
}
#pragma mark -
#pragma mark Lion native fullscreen handling
- (void)windowWillEnterFullScreen:(NSNotification *)notification
{
// workaround, see #6668
[NSApp setPresentationOptions:(NSApplicationPresentationFullScreen | NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
var_SetBool(pl_Get(VLCIntf), "fullscreen", true);
vout_thread_t *p_vout = getVoutForActiveWindow();
if (p_vout) {
var_SetBool(p_vout, "fullscreen", true);
vlc_object_release(p_vout);
}
[o_video_view setFrame: [[self contentView] frame]];
[[VLCMainWindow sharedInstance] setFullscreen: YES];
[[VLCMainWindow sharedInstance] recreateHideMouseTimer];
i_originalLevel = [self level];
[[[VLCMain sharedInstance] voutController] updateWindowLevelForHelperWindows: NSNormalWindowLevel];
[self setLevel:NSNormalWindowLevel];
if (b_dark_interface) {
[o_titlebar_view removeFromSuperviewWithoutNeedingDisplay];
NSRect winrect;
CGFloat f_titleBarHeight = [o_titlebar_view frame].size.height;
winrect = [self frame];
winrect.size.height = winrect.size.height - f_titleBarHeight;
[self setFrame: winrect display:NO animate:NO];
}
if ([[VLCMain sharedInstance] activeVideoPlayback])
[[o_controls_bar bottomBarView] setHidden: YES];
[self setMovableByWindowBackground: NO];
}
- (void)windowDidEnterFullScreen:(NSNotification *)notification
{
// Indeed, we somehow can have an "inactive" fullscreen (but a visible window!).
// But this creates some problems when leaving fs over remote intfs, so activate app here.
[NSApp activateIgnoringOtherApps:YES];
[[[VLCMainWindow sharedInstance] fsPanel] setVoutWasUpdated: self];
[[[VLCMainWindow sharedInstance] fsPanel] setActive: nil];
NSArray *subviews = [[self videoView] subviews];
NSUInteger count = [subviews count];
for (NSUInteger x = 0; x < count; x++) {
if ([[subviews objectAtIndex:x] respondsToSelector:@selector(reshape)])
[[subviews objectAtIndex:x] reshape];
}
}
- (void)windowWillExitFullScreen:(NSNotification *)notification
{
var_SetBool(pl_Get(VLCIntf), "fullscreen", false);
vout_thread_t *p_vout = getVoutForActiveWindow();
if (p_vout) {
var_SetBool(p_vout, "fullscreen", false);
vlc_object_release(p_vout);
}
[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;
winrect = [self frame];
[o_titlebar_view setFrame: NSMakeRect(0, winrect.size.height - f_titleBarHeight,
winrect.size.width, f_titleBarHeight)];
[[self contentView] addSubview: o_titlebar_view];
winrect.size.height = winrect.size.height + f_titleBarHeight;
[self setFrame: winrect display:NO animate:NO];
winrect = [o_video_view frame];
winrect.size.height -= f_titleBarHeight;
[o_video_view setFrame: winrect];
}
NSRect videoViewFrame = [o_video_view frame];
videoViewFrame.origin.y = [[o_controls_bar bottomBarView] frame].size.height;
videoViewFrame.size.height -= [[o_controls_bar bottomBarView] frame].size.height;
[o_video_view setFrame: videoViewFrame];
[[o_controls_bar bottomBarView] setHidden: NO];
[self setMovableByWindowBackground: YES];
}
#pragma mark -
#pragma mark Fullscreen Logic
......
......@@ -1266,8 +1266,13 @@ static VLCMain *_o_sharedMainInstance = nil;
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];
(!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
}
if (b_fullscreen)
[NSApp setPresentationOptions:(NSApplicationPresentationFullScreen | NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
......
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