~ubuntu-branches/ubuntu/utopic/vlc/utopic

« back to all changes in this revision

Viewing changes to modules/gui/macosx/MainWindow.m

  • Committer: Package Import Robot
  • Author(s): Benjamin Drung
  • Date: 2012-07-21 17:52:21 UTC
  • mfrom: (1.1.48) (3.5.44 sid)
  • Revision ID: package-import@ubuntu.com-20120721175221-53m5pclzo992kawy
Tags: 2.0.3-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * MainWindow.h: MacOS X interface module
3
3
 *****************************************************************************
4
4
 * Copyright (C) 2002-2012 VLC authors and VideoLAN
5
 
 * $Id: 3473ef086cc3a473a27e139ed837ddf96b93a497 $
 
5
 * $Id: 6e7e36f73986eac80931e803f1d899019577f3c0 $
6
6
 *
7
7
 * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
8
8
 *          Jon Lech Johansen <jon-vl@nanocrew.net>
122
122
 
123
123
- (BOOL)performKeyEquivalent:(NSEvent *)o_event
124
124
{
 
125
    BOOL b_force = NO;
125
126
    // these are key events which should be handled by vlc core, but are attached to a main menu item
126
127
    if( ![self isEvent: o_event forKey: "key-vol-up"] &&
127
128
        ![self isEvent: o_event forKey: "key-vol-down"] &&
132
133
        if([[NSApp mainMenu] performKeyEquivalent:o_event])
133
134
            return TRUE;
134
135
    }
 
136
    else
 
137
        b_force = YES;
135
138
 
136
 
    return [[VLCMain sharedInstance] hasDefinedShortcutKey:o_event] ||
 
139
    return [[VLCMain sharedInstance] hasDefinedShortcutKey:o_event force:b_force] ||
137
140
           [(VLCControls *)[[VLCMain sharedInstance] controls] keyEvent:o_event];
138
141
}
139
142
 
1663
1666
    if( new_frame.origin.y < screenFrame.origin.y )
1664
1667
        new_frame.origin.y = screenFrame.origin.y;
1665
1668
 
 
1669
    CGFloat right_screen_point = screenFrame.origin.x + screenFrame.size.width;
 
1670
    CGFloat right_window_point = new_frame.origin.x + new_frame.size.width;
 
1671
    if( right_window_point > right_screen_point )
 
1672
        new_frame.origin.x -= ( right_window_point - right_screen_point );
 
1673
 
1666
1674
    [[o_videoWindow animator] setFrame:new_frame display:YES];
1667
1675
}
1668
1676
 
1712
1720
        [o_fspanel fadeIn];
1713
1721
}
1714
1722
 
1715
 
- (void)updateFullscreen
1716
 
{
1717
 
    [[VLCMain sharedInstance] fullscreenChanged];
1718
 
}
1719
 
 
1720
1723
- (BOOL)isFullscreen
1721
1724
{
1722
1725
    return b_fullscreen;
1738
1741
    NSScreen *screen;
1739
1742
    NSRect screen_rect;
1740
1743
    NSRect rect;
1741
 
    vout_thread_t *p_vout = getVout();
1742
1744
    BOOL blackout_other_displays = config_GetInt( VLCIntf, "macosx-black" );
1743
1745
    id o_videoWindow = b_nonembedded ? o_detached_video_window : self;
1744
1746
 
1745
 
    if( p_vout )
1746
 
        screen = [NSScreen screenWithDisplayID:(CGDirectDisplayID)config_GetInt( VLCIntf, "macosx-vdev" )];
1747
 
 
 
1747
    screen = [NSScreen screenWithDisplayID:(CGDirectDisplayID)config_GetInt( VLCIntf, "macosx-vdev" )];
1748
1748
    [self lockFullscreenAnimation];
1749
1749
 
1750
1750
    if (!screen)
1758
1758
        screen = [NSScreen deepestScreen];
1759
1759
    }
1760
1760
 
1761
 
    if( p_vout )
1762
 
        vlc_object_release( p_vout );
1763
 
 
1764
1761
    screen_rect = [screen frame];
1765
1762
 
1766
1763
    [o_fullscreen_btn setState: YES];
2197
2194
 
2198
2195
- (void)windowDidEnterFullScreen:(NSNotification *)notification
2199
2196
{
 
2197
    // Indeed, we somehow can have an "inactive" fullscreen (but a visible window!).
 
2198
    // But this creates some problems when leaving fs over remote intfs, so activate app here.
 
2199
    [NSApp activateIgnoringOtherApps:YES];
 
2200
 
2200
2201
    [o_fspanel setVoutWasUpdated: (int)[[self screen] displayID]];
2201
2202
    [o_fspanel setActive: nil];
2202
2203
}
2545
2546
 
2546
2547
    return nil;
2547
2548
}
 
2549
 
 
2550
#pragma mark -
 
2551
#pragma mark Accessibility stuff
 
2552
 
 
2553
- (NSArray *)accessibilityAttributeNames
 
2554
{
 
2555
    if( !b_dark_interface )
 
2556
        return [super accessibilityAttributeNames];
 
2557
 
 
2558
    static NSMutableArray *attributes = nil;
 
2559
    if ( attributes == nil ) {
 
2560
        attributes = [[super accessibilityAttributeNames] mutableCopy];
 
2561
        NSArray *appendAttributes = [NSArray arrayWithObjects: NSAccessibilitySubroleAttribute,
 
2562
                                     NSAccessibilityCloseButtonAttribute,
 
2563
                                     NSAccessibilityMinimizeButtonAttribute,
 
2564
                                     NSAccessibilityZoomButtonAttribute,
 
2565
                                     nil];
 
2566
 
 
2567
        for( NSString *attribute in appendAttributes )
 
2568
        {
 
2569
            if( ![attributes containsObject:attribute] )
 
2570
                [attributes addObject:attribute];
 
2571
        }
 
2572
    }
 
2573
    return attributes;
 
2574
}
 
2575
 
 
2576
- (id)accessibilityAttributeValue: (NSString*)o_attribute_name
 
2577
{
 
2578
    if( b_dark_interface )
 
2579
    {
 
2580
        VLCMainWindowTitleView *o_tbv = o_titlebar_view;
 
2581
 
 
2582
        if( [o_attribute_name isEqualTo: NSAccessibilitySubroleAttribute] )
 
2583
            return NSAccessibilityStandardWindowSubrole;
 
2584
 
 
2585
        if( [o_attribute_name isEqualTo: NSAccessibilityCloseButtonAttribute] )
 
2586
            return [[o_tbv closeButton] cell];
 
2587
 
 
2588
        if( [o_attribute_name isEqualTo: NSAccessibilityMinimizeButtonAttribute] )
 
2589
            return [[o_tbv minimizeButton] cell];
 
2590
        
 
2591
        if( [o_attribute_name isEqualTo: NSAccessibilityZoomButtonAttribute] )
 
2592
            return [[o_tbv zoomButton] cell];
 
2593
    }
 
2594
 
 
2595
    return [super accessibilityAttributeValue: o_attribute_name];
 
2596
}
 
2597
 
 
2598
- (id)detachedTitlebarView
 
2599
{
 
2600
    return o_detached_titlebar_view;
 
2601
}
2548
2602
@end
2549
2603
 
2550
2604
@implementation VLCDetachedVideoWindow
2599
2653
    [[VLCCoreInteraction sharedInstance] toggleFullscreen];
2600
2654
}
2601
2655
 
2602
 
- (void)updateFullscreen
2603
 
{
2604
 
    [[VLCMain sharedInstance] fullscreenChanged];
2605
 
}
2606
 
 
2607
2656
- (BOOL)isFullscreen
2608
2657
{
2609
2658
    return [[VLCMainWindow sharedInstance] isFullscreen];
2755
2804
    [self setFrame: maxRect display: YES animate: YES];
2756
2805
}
2757
2806
 
 
2807
- (NSArray *)accessibilityAttributeNames
 
2808
{
 
2809
    if( !b_dark_interface )
 
2810
        return [super accessibilityAttributeNames];
 
2811
    
 
2812
    static NSMutableArray *attributes = nil;
 
2813
    if ( attributes == nil ) {
 
2814
        attributes = [[super accessibilityAttributeNames] mutableCopy];
 
2815
        NSArray *appendAttributes = [NSArray arrayWithObjects: NSAccessibilitySubroleAttribute,
 
2816
                                     NSAccessibilityCloseButtonAttribute,
 
2817
                                     NSAccessibilityMinimizeButtonAttribute,
 
2818
                                     NSAccessibilityZoomButtonAttribute,
 
2819
                                     nil];
 
2820
        
 
2821
        for( NSString *attribute in appendAttributes )
 
2822
        {
 
2823
            if( ![attributes containsObject:attribute] )
 
2824
                [attributes addObject:attribute];
 
2825
        }
 
2826
    }
 
2827
    return attributes;
 
2828
}
 
2829
 
 
2830
- (id)accessibilityAttributeValue: (NSString*)o_attribute_name
 
2831
{
 
2832
    if( b_dark_interface )
 
2833
    {
 
2834
        VLCMainWindowTitleView *o_tbv = [[VLCMainWindow sharedInstance] detachedTitlebarView];
 
2835
        
 
2836
        if( [o_attribute_name isEqualTo: NSAccessibilitySubroleAttribute] )
 
2837
            return NSAccessibilityStandardWindowSubrole;
 
2838
        
 
2839
        if( [o_attribute_name isEqualTo: NSAccessibilityCloseButtonAttribute] )
 
2840
            return [[o_tbv closeButton] cell];
 
2841
        
 
2842
        if( [o_attribute_name isEqualTo: NSAccessibilityMinimizeButtonAttribute] )
 
2843
            return [[o_tbv minimizeButton] cell];
 
2844
        
 
2845
        if( [o_attribute_name isEqualTo: NSAccessibilityZoomButtonAttribute] )
 
2846
            return [[o_tbv zoomButton] cell];
 
2847
    }
 
2848
    
 
2849
    return [super accessibilityAttributeValue: o_attribute_name];
 
2850
}
 
2851
 
2758
2852
@end