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 @@
BOOL just_triggered_previous;
NSMutableArray *o_sidebaritems;
VLCWindow * o_nonembedded_window;
BOOL b_nonembedded;
VLCWindow * o_fullscreen_window;
NSViewAnimation * o_fullscreen_anim1;
NSViewAnimation * o_fullscreen_anim2;
......
......@@ -409,14 +409,22 @@ static VLCMainWindow *_o_sharedInstance = nil;
- (IBAction)togglePlaylist:(id)sender
{
if ([o_video_view isHidden] && [o_playlist_btn isEnabled]) {
[o_playlist_table setHidden: YES];
[o_video_view setHidden: NO];
if (!b_nonembedded)
{
if ([o_video_view isHidden] && [o_playlist_btn isEnabled]) {
[o_playlist_table setHidden: YES];
[o_video_view setHidden: NO];
}
else
{
[o_video_view setHidden: YES];
[o_playlist_table setHidden: NO];
}
}
else
{
[o_video_view setHidden: YES];
[o_playlist_table setHidden: NO];
[o_video_view setHidden: NO];
}
}
......@@ -788,12 +796,60 @@ static VLCMainWindow *_o_sharedInstance = nil;
- (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;
}
- (void)setVideoplayEnabled
{
[o_playlist_btn setEnabled: [[VLCMain sharedInstance] activeVideoPlayback]];
if (!b_nonembedded)
[o_playlist_btn setEnabled: [[VLCMain sharedInstance] activeVideoPlayback]];
else
{
[o_playlist_btn setEnabled: NO];
if (![[VLCMain sharedInstance] activeVideoPlayback])
[o_nonembedded_window orderOut: nil];
}
}
- (void)resizeWindow
......@@ -1048,12 +1104,12 @@ static VLCMainWindow *_o_sharedInstance = nil;
if (p_vout)
{
if( var_GetBool( p_vout, "video-on-top" ) )
[self setLevel: NSStatusWindowLevel];
[[o_video_view window] setLevel: NSStatusWindowLevel];
else
[self setLevel: NSNormalWindowLevel];
[[o_video_view window] setLevel: NSNormalWindowLevel];
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 */
if (!o_fullscreen_window)
......@@ -1094,7 +1150,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
}
[self setAlphaValue: 0.0];
[self orderFront: self];
[[o_video_view window] orderFront: self];
[o_fspanel setNonActive: nil];
SetSystemUIMode( kUIModeNormal, kUIOptionAutoShowMenuBar);
......
......@@ -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_bright_bcell setTitle: _NS("Bright")];
[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_lang_txt setStringValue: _NS("Language")];
[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
else
[o_intf_enableGrowl_ckb setState: NSOffState];
if (config_GetInt( p_intf, "macosx-interfacestyle" ))
{
[o_intf_style_dark_bcell setState: YES];
[o_intf_style_bright_bcell setState: NO];
}
else
{
[o_intf_style_dark_bcell setState: NO];
[o_intf_style_bright_bcell setState: YES];
}
/******************
* audio settings *
......
......@@ -34,4 +34,4 @@
id o_window;
}
@end
\ No newline at end of file
@end
......@@ -314,7 +314,7 @@ static int Control (vout_display_t *vd, int query, va_list ap)
}
case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED:
{
[[sys->glView window] performZoom: nil];
[[sys->glView window] performSelectorOnMainThread:@selector(performZoom:) withObject: nil waitUntilDone:NO];
return VLC_SUCCESS;
}
case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
......@@ -328,6 +328,8 @@ static int Control (vout_display_t *vd, int query, va_list ap)
const vout_display_cfg_t *cfg;
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 glViewFrame = [sys->glView frame];
NSSize windowMinSize = [o_window minSize];
......@@ -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.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;
}
......@@ -470,6 +472,17 @@ static void OpenglSwap(vlc_gl_t *gl)
[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.
* (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