⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vout.m

📁 uclinux 下的vlc播放器源代码
💻 M
📖 第 1 页 / 共 3 页
字号:
- (void)mouseMoved:(NSEvent *)o_event{    i_time_mouse_last_moved = mdate();    [super mouseMoved: o_event];}- (void)hideMouse:(BOOL)b_hide{    BOOL b_inside;    NSPoint ml;    NSView *o_contents = [o_window contentView];    ml = [o_window convertScreenToBase:[NSEvent mouseLocation]];    ml = [o_contents convertPoint:ml fromView:nil];    b_inside = [o_contents mouse: ml inRect: [o_contents bounds]];    if( b_hide && b_inside )    {        [NSCursor setHiddenUntilMouseMoves: YES];    }    else if( !b_hide )    {        [NSCursor setHiddenUntilMouseMoves: NO];    }}- (void)manage{    [super manage];    if( p_vout->b_fullscreen )    {        if( mdate() - i_time_mouse_last_moved > 3000000 )        {            [self hideMouse: YES];        }    }    else    {        [self hideMouse: NO];    }}@end/***************************************************************************** * VLCEmbeddedVoutView implementation *****************************************************************************/@implementation VLCEmbeddedVoutView- (id)initWithFrame: (NSRect)frameRect{    [super initWithFrame: frameRect];    b_used = NO;    [[[VLCMain sharedInstance] getEmbeddedList] addEmbeddedVout: self];    return self;}- (BOOL)setVout: (vout_thread_t *) p_arg_vout subView: (NSView *) view                     frame: (NSRect *) s_arg_frame{    BOOL b_return;    b_return = [super setVout: p_arg_vout subView: view frame: s_arg_frame];    if( b_return )    {        o_window = [self window];        [o_window makeKeyAndOrderFront: self];        [o_window setAcceptsMouseMovedEvents: TRUE];        if( var_GetBool( p_real_vout, "video-on-top" ) )        {            [o_window setLevel: NSStatusWindowLevel];        }        [view setFrameSize: [self frame].size];    }    return b_return;}- (void)setUsed: (BOOL)b_new_used{    b_used = b_new_used;}- (BOOL)isUsed{    return b_used;}- (void)closeVout{    [super closeVout];    [o_window setAcceptsMouseMovedEvents: NO];    [[[VLCMain sharedInstance] getEmbeddedList] releaseEmbeddedVout: self];}@end@implementation VLCDetachedEmbeddedVoutView- (BOOL)setVout: (vout_thread_t *) p_arg_vout subView: (NSView *) view                     frame: (NSRect *) s_arg_frame{    BOOL b_return = [super setVout: p_arg_vout subView: view frame: s_arg_frame];    if( b_return )    {        [o_window setAlphaValue: var_GetFloat( p_vout, "macosx-opaqueness" )];        [self updateTitle];        [self scaleWindowWithFactor: 1.0 animate: NO];        [o_window makeKeyAndOrderFront: self];    }    return b_return;}- (void)closeVout{    [o_window orderOut: self];    [super closeVout];}@end/***************************************************************************** * VLCWindow implementation *****************************************************************************/@implementation VLCWindow- (id) initWithVout: (vout_thread_t *) vout view: (VLCVoutView *) view                     frame: (NSRect *) frame{    p_vout  = vout;    o_view  = view;    s_frame = frame;    [self performSelectorOnMainThread: @selector(initReal:)        withObject: NULL waitUntilDone: YES];    if( !b_init_ok )    {        return NULL;    }    return self;}- (id)initReal: (id) sender{    NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];    NSArray *o_screens = [NSScreen screens];    NSScreen *o_screen;    vlc_bool_t b_menubar_screen = VLC_FALSE;    int i_device;    b_init_ok = VLC_FALSE;    p_real_vout = [VLCVoutView getRealVout: p_vout];    i_device = var_GetInteger( p_real_vout->p_vlc, "video-device" );    b_black = var_GetBool( p_vout, "macosx-black" );    b_embedded = var_GetBool( p_vout, "macosx-embedded" );    /* Find out on which screen to open the window */    if( i_device <= 0 || i_device > (int)[o_screens count] )    {         /* No preference specified. Use the main screen */        o_screen = [NSScreen mainScreen];        i_device = [o_screens indexOfObject: o_screen];        if( o_screen == [o_screens objectAtIndex: 0] )            b_menubar_screen = VLC_TRUE;    }    else    {        i_device--;        o_screen = [o_screens objectAtIndex: i_device];        b_menubar_screen = ( i_device == 0 );    }    if( p_vout->b_fullscreen )    {        CGDisplayFadeReservationToken token;        NSRect screen_rect = [o_screen frame];        screen_rect.origin.x = screen_rect.origin.y = 0;        /* move the FSPanel to front in case that it is currently shown         * this won't and is not supposed to work when it's fading right now */        if( [[[[VLCMain sharedInstance] getControls] getFSPanel] isDisplayed] )            [[[[VLCMain sharedInstance] getControls] getFSPanel] setActive: nil];        /* tell the fspanel to move itself to front next time it's triggered */        [[[[VLCMain sharedInstance] getControls] getFSPanel] setVoutWasUpdated: i_device];        /* Creates a window with size: screen_rect on o_screen */        [self initWithContentRect: screen_rect              styleMask: NSBorderlessWindowMask              backing: NSBackingStoreBuffered              defer: YES screen: o_screen];        if( b_black == VLC_TRUE )        {            CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &token);            CGDisplayFade( token, 0.5, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0, 0, 0, true );            CGReleaseDisplayFadeReservation( token );            unsigned int i;            for( i = 0 ; i < [o_screens count]; i++)            {                struct                {                    CGDirectDisplayID displayID;                    CGGammaValue redMin, redMax, redGamma,                                 greenMin, greenMax, greenGamma,                                 blueMin, blueMax, blueGamma;                } dispSettings;                CGDisplayCount dspyCnt;                CGPoint gPoint;                if( i == (unsigned int)i_device ) continue;                screen_rect = [[o_screens objectAtIndex: i] frame];                gPoint.x = screen_rect.origin.x;                gPoint.y = screen_rect.origin.y;                CGGetDisplaysWithPoint( gPoint, 1, &(dispSettings.displayID), &dspyCnt);                CGGetDisplayTransferByFormula(                    dispSettings.displayID,                    &dispSettings.redMin, &dispSettings.redMax, &dispSettings.redGamma,                    &dispSettings.greenMin, &dispSettings.greenMax, &dispSettings.greenGamma,                    &dispSettings.blueMin, &dispSettings.blueMax, &dispSettings.blueGamma );                CGSetDisplayTransferByFormula(                    dispSettings.displayID,                    dispSettings.redMin,   0, dispSettings.redGamma,                    dispSettings.greenMin, 0, dispSettings.greenGamma,                    dispSettings.blueMin,  0, dispSettings.blueGamma );            }        }        if( b_menubar_screen )        {            SetSystemUIMode( kUIModeAllHidden, kUIOptionAutoShowMenuBar);        }        if( b_black == VLC_TRUE )        {            CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &token);            CGDisplayFade( token, 2 , kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, false );            CGReleaseDisplayFadeReservation( token);        }    }    else if( var_GetBool( p_vout, "macosx-background" ) )    {        NSRect screen_rect = [o_screen frame];        screen_rect.origin.x = screen_rect.origin.y = 0;        /* Creates a window with size: screen_rect on o_screen */        [self initWithContentRect: screen_rect              styleMask: NSBorderlessWindowMask              backing: NSBackingStoreBuffered              defer: YES screen: o_screen];        [self setLevel: CGWindowLevelForKey(kCGDesktopWindowLevelKey)];    }    else    {        unsigned int i_stylemask = NSTitledWindowMask |                                   NSMiniaturizableWindowMask |                                   NSClosableWindowMask |                                   NSResizableWindowMask;        NSRect s_rect;        if( !s_frame )        {            s_rect.size.width  = p_vout->i_window_width;            s_rect.size.height = p_vout->i_window_height;        }        else        {            s_rect = *s_frame;        }        [self initWithContentRect: s_rect              styleMask: i_stylemask              backing: NSBackingStoreBuffered              defer: YES screen: o_screen];        [self setAlphaValue: var_GetFloat( p_vout, "macosx-opaqueness" )];        if( !s_frame )        {            [self center];        }    }    [self makeKeyAndOrderFront: nil];    [self setReleasedWhenClosed: YES];    /* We'll catch mouse events */    [self makeFirstResponder: o_view];    /* Add the view. It's automatically resized to fit the window */    [self setContentView: o_view];    [o_pool release];    b_init_ok = VLC_TRUE;    return self;}- (void)close{    [o_view closeVout];}- (void) closeWindow{    /* XXX waitUntilDone = NO to avoid a possible deadlock when hitting       Command-Q */    [self setContentView: NULL];    [self performSelectorOnMainThread: @selector(closeReal:)        withObject: NULL waitUntilDone: NO];}- (id)closeReal: (id)sender{    if( b_black == VLC_TRUE )    {        CGDisplayFadeReservationToken token;        CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &token);        CGDisplayFade( token, 2, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, false );        CGReleaseDisplayFadeReservation( token);        CGDisplayRestoreColorSyncSettings();    }    SetSystemUIMode( kUIModeNormal, 0);    [super close];    /* this does only work in embedded mode */    if( b_embedded == VLC_TRUE )        [[[[VLCMain sharedInstance] getControls] getFSPanel] orderOut: self];        return NULL;}- (id)getVoutView{    return o_view;}- (BOOL)canBecomeKeyWindow{    return YES;}/* Sometimes crashes VLC....- (BOOL)performKeyEquivalent:(NSEvent *)o_event{        return [[VLCMain sharedInstance] hasDefinedShortcutKey:o_event];}*//* This is actually the same as VLCControls::stop. */- (BOOL)windowShouldClose:(id)sender{    playlist_t * p_playlist = vlc_object_find( p_vout, VLC_OBJECT_PLAYLIST,                                                       FIND_ANYWHERE );    if( p_playlist == NULL )    {        return NO;    }    playlist_Stop( p_playlist );    vlc_object_release( p_playlist );    /* The window will be closed by the intf later. */    return NO;}@end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -