Commit 734e6179 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: re-implemented a non-embedded video window

parent b7fbd8c6
...@@ -98,6 +98,9 @@ ...@@ -98,6 +98,9 @@
BOOL just_triggered_previous; BOOL just_triggered_previous;
NSMutableArray *o_sidebaritems; NSMutableArray *o_sidebaritems;
VLCWindow * o_nonembedded_window;
BOOL b_nonembedded;
VLCWindow * o_fullscreen_window; VLCWindow * o_fullscreen_window;
NSViewAnimation * o_fullscreen_anim1; NSViewAnimation * o_fullscreen_anim1;
NSViewAnimation * o_fullscreen_anim2; NSViewAnimation * o_fullscreen_anim2;
......
...@@ -409,6 +409,8 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -409,6 +409,8 @@ static VLCMainWindow *_o_sharedInstance = nil;
- (IBAction)togglePlaylist:(id)sender - (IBAction)togglePlaylist:(id)sender
{ {
if (!b_nonembedded)
{
if ([o_video_view isHidden] && [o_playlist_btn isEnabled]) { if ([o_video_view isHidden] && [o_playlist_btn isEnabled]) {
[o_playlist_table setHidden: YES]; [o_playlist_table setHidden: YES];
[o_video_view setHidden: NO]; [o_video_view setHidden: NO];
...@@ -418,6 +420,12 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -418,6 +420,12 @@ static VLCMainWindow *_o_sharedInstance = nil;
[o_video_view setHidden: YES]; [o_video_view setHidden: YES];
[o_playlist_table setHidden: NO]; [o_playlist_table setHidden: NO];
} }
}
else
{
[o_playlist_table setHidden: NO];
[o_video_view setHidden: NO];
}
} }
- (void)setRepeatOne - (void)setRepeatOne
...@@ -788,12 +796,60 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -788,12 +796,60 @@ static VLCMainWindow *_o_sharedInstance = nil;
- (id)videoView - (id)videoView
{ {
vout_thread_t *p_vout = getVout();
if (config_GetInt( VLCIntf, "embedded-video" ))
{
if ([o_video_view window] != self)
{
[o_video_view removeFromSuperviewWithoutNeedingDisplay];
[o_video_view setFrame: [o_split_view frame]];
[[self contentView] addSubview: o_video_view];
}
b_nonembedded = NO;
}
else
{
[o_video_view removeFromSuperviewWithoutNeedingDisplay];
if (o_nonembedded_window)
[o_nonembedded_window release];
o_nonembedded_window = [[VLCWindow alloc] initWithContentRect:[o_video_view frame] styleMask: NSBorderlessWindowMask|NSResizableWindowMask backing:NSBackingStoreBuffered defer:YES];
[o_nonembedded_window setFrame:[o_video_view frame] display:NO];
[o_nonembedded_window setBackgroundColor: [NSColor blackColor]];
[o_nonembedded_window setMovableByWindowBackground: YES];
[o_nonembedded_window setCanBecomeKeyWindow: YES];
[o_nonembedded_window setHasShadow:YES];
[o_nonembedded_window setContentView: o_video_view];
[o_nonembedded_window setLevel:NSNormalWindowLevel];
[o_nonembedded_window useOptimizedDrawing: YES];
[o_nonembedded_window center];
[o_nonembedded_window makeKeyAndOrderFront:self];
[o_nonembedded_window orderFront:self animate:YES];
[o_nonembedded_window setReleasedWhenClosed:NO];
b_nonembedded = YES;
}
if (p_vout)
{
if( var_GetBool( p_vout, "video-on-top" ) )
[[o_video_view window] setLevel: NSStatusWindowLevel];
else
[[o_video_view window] setLevel: NSNormalWindowLevel];
vlc_object_release( p_vout );
}
return o_video_view; return o_video_view;
} }
- (void)setVideoplayEnabled - (void)setVideoplayEnabled
{ {
if (!b_nonembedded)
[o_playlist_btn setEnabled: [[VLCMain sharedInstance] activeVideoPlayback]]; [o_playlist_btn setEnabled: [[VLCMain sharedInstance] activeVideoPlayback]];
else
{
[o_playlist_btn setEnabled: NO];
if (![[VLCMain sharedInstance] activeVideoPlayback])
[o_nonembedded_window orderOut: nil];
}
} }
- (void)resizeWindow - (void)resizeWindow
...@@ -1048,12 +1104,12 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -1048,12 +1104,12 @@ static VLCMainWindow *_o_sharedInstance = nil;
if (p_vout) if (p_vout)
{ {
if( var_GetBool( p_vout, "video-on-top" ) ) if( var_GetBool( p_vout, "video-on-top" ) )
[self setLevel: NSStatusWindowLevel]; [[o_video_view window] setLevel: NSStatusWindowLevel];
else else
[self setLevel: NSNormalWindowLevel]; [[o_video_view window] setLevel: NSNormalWindowLevel];
vlc_object_release( p_vout ); vlc_object_release( p_vout );
} }
[self makeKeyAndOrderFront: nil]; [[o_video_view window] makeKeyAndOrderFront: nil];
/* Don't do anything if o_fullscreen_window is already closed */ /* Don't do anything if o_fullscreen_window is already closed */
if (!o_fullscreen_window) if (!o_fullscreen_window)
...@@ -1094,7 +1150,7 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -1094,7 +1150,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
} }
[self setAlphaValue: 0.0]; [self setAlphaValue: 0.0];
[self orderFront: self]; [[o_video_view window] orderFront: self];
[o_fspanel setNonActive: nil]; [o_fspanel setNonActive: nil];
SetSystemUIMode( kUIModeNormal, kUIOptionAutoShowMenuBar); SetSystemUIMode( kUIModeNormal, kUIOptionAutoShowMenuBar);
......
...@@ -225,7 +225,7 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des ...@@ -225,7 +225,7 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des
[o_intf_style_dark_bcell setTitle: _NS("Dark")]; [o_intf_style_dark_bcell setTitle: _NS("Dark")];
[o_intf_style_bright_bcell setTitle: _NS("Bright")]; [o_intf_style_bright_bcell setTitle: _NS("Bright")];
[o_intf_art_txt setStringValue: _NS("Album art download policy")]; [o_intf_art_txt setStringValue: _NS("Album art download policy")];
[o_intf_embedded_ckb setTitle: _NS("Add controls to the video window")]; [o_intf_embedded_ckb setTitle: _NS("Show video within the main window")];
[o_intf_fspanel_ckb setTitle: _NS("Show Fullscreen Controller")]; [o_intf_fspanel_ckb setTitle: _NS("Show Fullscreen Controller")];
[o_intf_lang_txt setStringValue: _NS("Language")]; [o_intf_lang_txt setStringValue: _NS("Language")];
[o_intf_network_box setTitle: _NS("Privacy / Network Interaction")]; [o_intf_network_box setTitle: _NS("Privacy / Network Interaction")];
...@@ -436,9 +436,15 @@ static inline char * __config_GetLabel( vlc_object_t *p_this, const char *psz_na ...@@ -436,9 +436,15 @@ static inline char * __config_GetLabel( vlc_object_t *p_this, const char *psz_na
else else
[o_intf_enableGrowl_ckb setState: NSOffState]; [o_intf_enableGrowl_ckb setState: NSOffState];
if (config_GetInt( p_intf, "macosx-interfacestyle" )) if (config_GetInt( p_intf, "macosx-interfacestyle" ))
{
[o_intf_style_dark_bcell setState: YES]; [o_intf_style_dark_bcell setState: YES];
[o_intf_style_bright_bcell setState: NO];
}
else else
{
[o_intf_style_dark_bcell setState: NO]; [o_intf_style_dark_bcell setState: NO];
[o_intf_style_bright_bcell setState: YES];
}
/****************** /******************
* audio settings * * audio settings *
......
...@@ -314,7 +314,7 @@ static int Control (vout_display_t *vd, int query, va_list ap) ...@@ -314,7 +314,7 @@ static int Control (vout_display_t *vd, int query, va_list ap)
} }
case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED: case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED:
{ {
[[sys->glView window] performZoom: nil]; [[sys->glView window] performSelectorOnMainThread:@selector(performZoom:) withObject: nil waitUntilDone:NO];
return VLC_SUCCESS; return VLC_SUCCESS;
} }
case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE: case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
...@@ -328,6 +328,8 @@ static int Control (vout_display_t *vd, int query, va_list ap) ...@@ -328,6 +328,8 @@ static int Control (vout_display_t *vd, int query, va_list ap)
const vout_display_cfg_t *cfg; const vout_display_cfg_t *cfg;
id o_window = [sys->glView window]; id o_window = [sys->glView window];
if (!o_window)
return VLC_SUCCESS; // this is okay, since the event will occur again when we have a window
NSRect windowFrame = [o_window frame]; NSRect windowFrame = [o_window frame];
NSRect glViewFrame = [sys->glView frame]; NSRect glViewFrame = [sys->glView frame];
NSSize windowMinSize = [o_window minSize]; NSSize windowMinSize = [o_window minSize];
...@@ -353,7 +355,7 @@ static int Control (vout_display_t *vd, int query, va_list ap) ...@@ -353,7 +355,7 @@ static int Control (vout_display_t *vd, int query, va_list ap)
new_frame.origin.x = topleftscreen.x; new_frame.origin.x = topleftscreen.x;
new_frame.origin.y = topleftscreen.y - new_frame.size.height; new_frame.origin.y = topleftscreen.y - new_frame.size.height;
[o_window setFrame:new_frame display:YES animate:YES]; [sys->glView performSelectorOnMainThread:@selector(setWindowFrameWithValue:) withObject:[NSValue valueWithRect:new_frame] waitUntilDone:NO];
} }
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -470,6 +472,17 @@ static void OpenglSwap(vlc_gl_t *gl) ...@@ -470,6 +472,17 @@ static void OpenglSwap(vlc_gl_t *gl)
[self setFrame:[value rectValue]]; [self setFrame:[value rectValue]];
} }
/**
* Gets called by Control() to make sure that we're performing on the main thread
*/
- (void)setWindowFrameWithValue:(NSValue *)value
{
NSRect frame = [value rectValue];
if (frame.origin.x <= 0.0 && frame.origin.y <= 0.0)
[[self window] center];
[[self window] setFrame:frame display:YES animate: YES];
}
/** /**
* Gets called by the Close and Open methods. * Gets called by the Close and Open methods.
* (Non main thread). * (Non main thread).
......
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