Commit 354dcd7d authored by David Fuhrmann's avatar David Fuhrmann

macosx: simplify vout window instantiation

This removes unused pointering. Furthermore, for nonembedded windows
the video size is set directly to avoid strange resizing after window
creation.
parent 689613d3
......@@ -35,7 +35,7 @@
NSMutableDictionary *o_vout_dict;
}
- (VLCVoutView *)setupVout:(vout_window_t *)p_wnd;
- (VLCVoutView *)setupVoutForWindow:(vout_window_t *)p_wnd withProposedVideoViewPosition:(NSRect)videoViewPosition;
- (void)removeVoutforDisplay:(NSValue *)o_key;
- (void)updateWindowsControlsBarWithSelector:(SEL)aSel;
......
......@@ -47,7 +47,7 @@
}
- (VLCVoutView *)setupVout:(vout_window_t *)p_wnd
- (VLCVoutView *)setupVoutForWindow:(vout_window_t *)p_wnd withProposedVideoViewPosition:(NSRect)videoViewPosition
{
BOOL b_nonembedded = NO;
BOOL b_nativeFullscreenMode = [[VLCMain sharedInstance] nativeFullscreenMode];
......@@ -57,6 +57,7 @@
VLCVoutView *o_vout_view;
VLCVideoWindowCommon *o_new_video_window;
// TODO: make lion fullscreen compatible with video-wallpaper and !embedded-video
if ((b_video_wallpaper || !b_video_deco) && !b_nativeFullscreenMode) {
// b_video_wallpaper is priorized over !b_video_deco
......@@ -126,6 +127,15 @@
}
if (!b_video_wallpaper) {
// set window size
NSSize videoViewSize = NSMakeSize(videoViewPosition.size.width, videoViewPosition.size.height);
if (b_nonembedded) {
NSRect window_rect = [o_new_video_window getWindowRectForProposedVideoViewSize:videoViewSize];
[o_new_video_window setFrame:window_rect display:YES];
}
[o_new_video_window setNativeVideoSize:videoViewSize];
[o_new_video_window makeKeyAndOrderFront: self];
vout_thread_t *p_vout = getVout();
......@@ -137,6 +147,7 @@
vlc_object_release(p_vout);
}
}
[o_new_video_window setAlphaValue: config_GetFloat(VLCIntf, "macosx-opaqueness")];
if (!b_multiple_vout_windows)
......
......@@ -104,6 +104,8 @@ static const float f_min_video_height = 70.0;
- (void)resizeWindow;
- (void)setNativeVideoSize:(NSSize)size;
- (NSRect)getWindowRectForProposedVideoViewSize:(NSSize)size;
- (void)setTitle:(NSString *)title;
......
......@@ -422,19 +422,16 @@
#pragma mark -
#pragma mark Video window resizing logic
- (void)resizeWindow
- (NSRect)getWindowRectForProposedVideoViewSize:(NSSize)size
{
if ([[VLCMainWindow sharedInstance] fullscreen])
return;
NSSize windowMinSize = [self minSize];
NSRect screenFrame = [[self screen] visibleFrame];
NSPoint topleftbase = NSMakePoint(0, [self frame].size.height);
NSPoint topleftscreen = [self convertBaseToScreen: topleftbase];
unsigned int i_width = nativeVideoSize.width;
unsigned int i_height = nativeVideoSize.height;
unsigned int i_width = size.width;
unsigned int i_height = size.height;
if (i_width < windowMinSize.width)
i_width = windowMinSize.width;
if (i_height < f_min_video_height)
......@@ -464,7 +461,16 @@
if (right_window_point > right_screen_point)
new_frame.origin.x -= (right_window_point - right_screen_point);
[[self animator] setFrame:new_frame display:YES];
return new_frame;
}
- (void)resizeWindow
{
if ([[VLCMainWindow sharedInstance] fullscreen])
return;
NSRect window_rect = [self getWindowRectForProposedVideoViewSize:nativeVideoSize];
[[self animator] setFrame:window_rect display:YES];
}
- (void)setNativeVideoSize:(NSSize)size
......
......@@ -166,7 +166,6 @@ struct intf_sys_t
- (id)playlist;
- (id)info;
- (id)wizard;
- (id)getVideoViewAtPositionX: (int *)pi_x Y: (int *)pi_y withWidth: (unsigned int*)pi_width andHeight: (unsigned int*)pi_height forWindow:(vout_window_t *)p_wnd;
- (id)coreDialogProvider;
- (id)eyeTVController;
- (id)appleRemoteController;
......
......@@ -137,29 +137,31 @@ int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg)
return VLC_EGENERIC;
}
int i_x = cfg->x;
int i_y = cfg->y;
unsigned i_width = cfg->width;
unsigned i_height = cfg->height;
p_wnd->handle.nsobject = [[VLCMain sharedInstance] getVideoViewAtPositionX: &i_x Y: &i_y withWidth: &i_width andHeight: &i_height forWindow: p_wnd];
NSRect proposedVideoViewPosition = NSMakeRect(cfg->x, cfg->y, cfg->width, cfg->height);
if (!p_wnd->handle.nsobject) {
VLCVoutWindowController *o_vout_controller = [[VLCMain sharedInstance] voutController];
SEL sel = @selector(setupVoutForWindow:withProposedVideoViewPosition:);
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[o_vout_controller methodSignatureForSelector:sel]];
[inv setTarget:o_vout_controller];
[inv setSelector:sel];
[inv setArgument:&p_wnd atIndex:2]; // starting at 2!
[inv setArgument:&proposedVideoViewPosition atIndex:3];
[inv performSelectorOnMainThread:@selector(invoke) withObject:nil
waitUntilDone:YES];
VLCVoutView *videoView = nil;
[inv getReturnValue:&videoView];
if (!videoView) {
msg_Err(p_wnd, "got no video view from the interface");
[o_pool release];
return VLC_EGENERIC;
}
// TODO: this seems to be strange. Why not just allocating in the right size?
// This could avoid strange resize-animations...
NSSize newSize = NSMakeSize(cfg->width, cfg->height);
SEL sel = @selector(setNativeVideoSize:forWindow:);
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[[[VLCMain sharedInstance] voutController] methodSignatureForSelector:sel]];
[inv setTarget:[[VLCMain sharedInstance] voutController]];
[inv setSelector:sel];
[inv setArgument:&newSize atIndex:2]; // starting at 2!
[inv setArgument:&p_wnd atIndex:3];
[inv performSelectorOnMainThread:@selector(invoke) withObject:nil
waitUntilDone:NO];
msg_Dbg(VLCIntf, "returning videoview with proposed position x=%i, y=%i, width=%i, height=%i", cfg->x, cfg->y, cfg->width, cfg->height);
p_wnd->handle.nsobject = videoView;
// TODO: find a cleaner way for "start in fullscreen"
if (var_GetBool(pl_Get(VLCIntf), "fullscreen")) {
......@@ -177,7 +179,7 @@ int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg)
[[VLCMain sharedInstance] setActiveVideoPlayback: YES];
p_wnd->control = WindowControl;
p_wnd->sys = (vout_window_sys_t *)VLCIntf;
[o_pool release];
return VLC_SUCCESS;
}
......@@ -225,8 +227,6 @@ static int WindowControl(vout_window_t *p_wnd, int i_query, va_list args)
[inv performSelectorOnMainThread:@selector(invoke) withObject:nil
waitUntilDone:NO];
//[[VLCMain sharedInstance] performSelectorOnMainThread:@selector(fullscreenChanged:) withObject:[NSValue valueWithPointer:p_wnd] waitUntilDone:NO];
[o_pool release];
return VLC_SUCCESS;
}
......@@ -1550,33 +1550,6 @@ static VLCMain *_o_sharedMainInstance = nil;
return o_wizard;
}
- (id)getVideoViewAtPositionX: (int *)pi_x Y: (int *)pi_y withWidth: (unsigned int*)pi_width andHeight: (unsigned int*)pi_height forWindow:(vout_window_t *)p_wnd
{
SEL sel = @selector(setupVout:);
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[o_vout_controller methodSignatureForSelector:sel]];
[inv setTarget:o_vout_controller];
[inv setSelector:sel];
[inv setArgument:&p_wnd atIndex:2]; // starting at 2!
[inv performSelectorOnMainThread:@selector(invoke) withObject:nil
waitUntilDone:YES];
VLCVoutView *videoView;
[inv getReturnValue:&videoView];
NSRect videoRect = [videoView frame];
int i_x = (int)videoRect.origin.x;
int i_y = (int)videoRect.origin.y;
unsigned int i_width = (int)videoRect.size.width;
unsigned int i_height = (int)videoRect.size.height;
pi_x = &i_x;
pi_y = &i_y;
pi_width = &i_width;
pi_height = &i_height;
msg_Dbg(VLCIntf, "returning videoview with x=%i, y=%i, width=%i, height=%i", i_x, i_y, i_width, i_height);
return videoView;
}
- (id)coreDialogProvider
{
if (o_coredialogs)
......
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