~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-02-18 01:29:48 UTC
  • mfrom: (1.1.45) (3.5.32 sid)
  • Revision ID: package-import@ubuntu.com-20120218012948-tvq9nhnfi98kra44
Tags: 2.0.0-1
* New upstream release (Closes: #499381, #573064, #624027, LP: #455825,
  #573775, #695882, #705151, #708448, #738381, #743581, #747757, #817924,
  #931083).
* Remove dropped mozilla-plugin-vlc, vlc-plugin-ggi, and vlc-plugin-svgalib.
  The Mozilla browser plug-in is now provided by a separate source tarball.
* Add new plugins to and remove dropped plugins from vlc-nox.
* Add new and remove dropped build dependencies:
  + libbluray-dev (for Blu-ray support)
  + libresid-builder-dev
  + libsamplerate0-dev
  + libsidplay2-dev
  + lbspeexdsp-dev
  + libxcb-composite0-dev
  - libgtk2.0-dev
  - xulrunner-dev
* vlc-plugin-fluidsynth depends on fluid-soundfont-gm or
  musescore-soundfont-gm for having a sound font for playing MIDI files.
* Drop all patches (they were either backported or accepted by upstream).
* Update symbols for libvlc5.
* Install plugins.dat instead of running vlc-cache-gen in postinst.
* Update minimum version of build dependencies.
* Change Build-Dependency from libupnp3-dev to unversioned libupnp-dev.
  (Closes: #656831)

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: 05a19338a7b393fe7576886678204b173de3cab9 $
 
5
 * $Id: 5d42e6a897d02e9ebecbe865a924bde7dc770660 $
6
6
 *
7
7
 * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
8
8
 *          Jon Lech Johansen <jon-vl@nanocrew.net>
149
149
    [o_dropzone_lbl setStringValue: _NS("Drop media here")];
150
150
 
151
151
    if (!b_dark_interface) {
152
 
        [o_bottombar_view setImage: [NSImage imageNamed:@"bottom-background"]];
 
152
        [o_bottombar_view setImagesLeft: [NSImage imageNamed:@"bottom-background"] middle: [NSImage imageNamed:@"bottom-background"] right: [NSImage imageNamed:@"bottom-background"]];
153
153
        [o_bwd_btn setImage: [NSImage imageNamed:@"back"]];
154
154
        [o_bwd_btn setAlternateImage: [NSImage imageNamed:@"back-pressed"]];
155
155
        o_play_img = [[NSImage imageNamed:@"play"] retain];
192
192
    }
193
193
    else
194
194
    {
195
 
        [o_bottombar_view setImage: [NSImage imageNamed:@"bottom-background_dark"]];
 
195
        [o_bottombar_view setImagesLeft: [NSImage imageNamed:@"bottomdark-left"] middle: [NSImage imageNamed:@"bottom-background_dark"] right: [NSImage imageNamed:@"bottomdark-right"]];
196
196
        [o_bwd_btn setImage: [NSImage imageNamed:@"back_dark"]];
197
197
        [o_bwd_btn setAlternateImage: [NSImage imageNamed:@"back-pressed_dark"]];
198
198
        o_play_img = [[NSImage imageNamed:@"play_dark"] retain];
253
253
    else
254
254
        [self setContentMinSize:NSMakeSize(604., 288.)];
255
255
    [self setTitle: _NS("VLC media player")];
256
 
    [o_playlist_btn setEnabled:NO];
 
256
    [o_time_fld setAlignment: NSCenterTextAlignment];
 
257
    [o_time_fld setNeedsDisplay:YES];
 
258
    b_dropzone_active = YES;
257
259
    o_temp_view = [[NSView alloc] init];
258
260
    [o_temp_view setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable];
259
261
    [o_dropzone_view setFrame: [o_playlist_table frame]];
260
262
    [o_left_split_view setFrame: [o_sidebar_view frame]];
261
263
    if (OSX_LION && b_nativeFullscreenMode)
262
264
    {
 
265
        NSRect frame;
263
266
        [self setCollectionBehavior: NSWindowCollectionBehaviorFullScreenPrimary];
264
 
        NSRect frame;
265
267
        float f_width = [o_fullscreen_btn frame].size.width;
266
268
 
267
269
        #define moveItem( item ) \
419
421
 
420
422
        [self setBackgroundColor: [NSColor clearColor]];
421
423
        [self setOpaque: NO];
 
424
        [self display];
 
425
        [self setHasShadow:NO];
422
426
        [self setHasShadow:YES];
423
427
 
424
428
        NSRect winrect = [self frame];
560
564
 
561
565
- (IBAction)togglePlaylist:(id)sender
562
566
{
 
567
    if (b_dropzone_active && ![[VLCMain sharedInstance] activeVideoPlayback])
 
568
    {
 
569
        b_dropzone_active = NO;
 
570
        [self hideDropZone];
 
571
    }
 
572
 
563
573
    if (!b_nonembedded)
564
574
    {
565
 
        if ([o_video_view isHidden] && [o_playlist_btn isEnabled]) {
 
575
        if ([o_video_view isHidden] && [[VLCMain sharedInstance] activeVideoPlayback]) {
566
576
            [o_split_view setHidden: YES];
567
577
            [o_video_view setHidden: NO];
568
578
            [self makeFirstResponder: o_video_view];
933
943
#pragma mark Update interface and respond to foreign events
934
944
- (void)showDropZone
935
945
{
 
946
    b_dropzone_active = YES;
936
947
    [o_right_split_view addSubview: o_dropzone_view];
937
948
    [o_dropzone_view setFrame: [o_playlist_table frame]];
938
949
    [[o_playlist_table animator] setHidden:YES];
1042
1053
 
1043
1054
        [self setTitle: aString];
1044
1055
        [o_fspanel setStreamTitle: aString];
 
1056
        vlc_object_release( p_input );
1045
1057
    }
1046
1058
    else
1047
1059
    {
1086
1098
        /* chapters & titles */
1087
1099
        //FIXME! b_chapters = p_input->stream.i_area_nb > 1;
1088
1100
 
1089
 
        if (cachedInputState == PLAYING_S || b_buffering == YES)
 
1101
        if (( cachedInputState == PLAYING_S || b_buffering == YES ) && [[VLCMain sharedInstance] activeVideoPlayback] )
1090
1102
            [[o_video_view window] makeKeyAndOrderFront: nil];
1091
1103
 
1092
1104
        vlc_object_release( p_input );
1214
1226
{
1215
1227
    BOOL b_videoPlayback = [[VLCMain sharedInstance] activeVideoPlayback];
1216
1228
 
1217
 
    if (!b_nonembedded)
1218
 
        [o_playlist_btn setEnabled: b_videoPlayback];
1219
 
    else
1220
 
    {
1221
 
        [o_playlist_btn setEnabled: NO];
1222
 
        if (!b_videoPlayback)
1223
 
            [o_nonembedded_window orderOut: nil];
1224
 
    }
 
1229
    if (!b_videoPlayback)
 
1230
        [o_nonembedded_window orderOut: nil];
1225
1231
    if( OSX_LION && b_nativeFullscreenMode )
1226
1232
    {
1227
1233
        if( [NSApp presentationOptions] & NSApplicationPresentationFullScreen )
1242
1248
 
1243
1249
- (void)resizeWindow
1244
1250
{
1245
 
    if ( !b_fullscreen && !(OSX_LION && [NSApp presentationOptions] == NSApplicationPresentationFullScreen && b_nativeFullscreenMode) )
1246
 
    {
1247
 
        NSPoint topleftbase;
1248
 
        NSPoint topleftscreen;
1249
 
        NSRect new_frame;
1250
 
        topleftbase.x = 0;
1251
 
        topleftbase.y = [self frame].size.height;
1252
 
        topleftscreen = [self convertBaseToScreen: topleftbase];
1253
 
 
1254
 
        /* Calculate the window's new size */
1255
 
        new_frame.size.width = [self frame].size.width - [o_video_view frame].size.width + nativeVideoSize.width;
1256
 
        if (b_dark_interface)
1257
 
            new_frame.size.height = [self frame].size.height - [o_video_view frame].size.height + nativeVideoSize.height + [o_titlebar_view frame].size.height;
1258
 
        else
1259
 
            new_frame.size.height = [self frame].size.height - [o_video_view frame].size.height + nativeVideoSize.height;
1260
 
 
1261
 
        new_frame.origin.x = topleftscreen.x;
1262
 
        new_frame.origin.y = topleftscreen.y - new_frame.size.height;
1263
 
 
1264
 
        [[self animator] setFrame:new_frame display:YES];
1265
 
    }
 
1251
    if ( b_fullscreen || (OSX_LION && [NSApp presentationOptions] == NSApplicationPresentationFullScreen && b_nativeFullscreenMode) )
 
1252
        return;
 
1253
 
 
1254
    NSPoint topleftbase = NSMakePoint(0, [self frame].size.height);
 
1255
    NSPoint topleftscreen = [self convertBaseToScreen: topleftbase];
 
1256
 
 
1257
    /* Calculate the window's new size */
 
1258
    float w = [self frame].size.width  - [o_video_view frame].size.width
 
1259
        + nativeVideoSize.width;
 
1260
    float h = [self frame].size.height - [o_video_view frame].size.height
 
1261
        + nativeVideoSize.height;
 
1262
 
 
1263
    if (b_dark_interface)
 
1264
        h += [o_titlebar_view frame].size.height;
 
1265
 
 
1266
    NSRect new_frame = NSMakeRect(topleftscreen.x, topleftscreen.y - h, w, h);
 
1267
 
 
1268
    [[self animator] setFrame:new_frame display:YES];
1266
1269
}
1267
1270
 
1268
1271
- (void)setNativeVideoSize:(NSSize)size
1335
1338
    NSRect rect;
1336
1339
    vout_thread_t *p_vout = getVout();
1337
1340
    BOOL blackout_other_displays = config_GetInt( VLCIntf, "macosx-black" );
 
1341
    id o_videoWindow = b_nonembedded ? o_nonembedded_window : self;
1338
1342
 
1339
1343
    if( p_vout )
1340
1344
        screen = [NSScreen screenWithDisplayID:(CGDirectDisplayID)config_GetInt( VLCIntf, "macosx-vdev" )];
1344
1348
    if (!screen)
1345
1349
    {
1346
1350
        msg_Dbg( VLCIntf, "chosen screen isn't present, using current screen for fullscreen mode" );
1347
 
        screen = [self screen];
 
1351
        screen = [o_videoWindow screen];
1348
1352
    }
1349
1353
    if (!screen)
1350
1354
    {
1365
1369
        [screen blackoutOtherScreens];
1366
1370
 
1367
1371
    /* Make sure we don't see the window flashes in float-on-top mode */
1368
 
    i_originalLevel = [self level];
1369
 
    [self setLevel:NSNormalWindowLevel];
 
1372
    i_originalLevel = [o_videoWindow level];
 
1373
    [o_videoWindow setLevel:NSNormalWindowLevel];
1370
1374
 
1371
1375
    /* Only create the o_fullscreen_window if we are not in the middle of the zooming animation */
1372
1376
    if (!o_fullscreen_window)
1374
1378
        /* We can't change the styleMask of an already created NSWindow, so we create another window, and do eye catching stuff */
1375
1379
 
1376
1380
        rect = [[o_video_view superview] convertRect: [o_video_view frame] toView: nil]; /* Convert to Window base coord */
1377
 
        rect.origin.x += [[o_video_view window] frame].origin.x;
1378
 
        rect.origin.y += [[o_video_view window] frame].origin.y;
 
1381
        rect.origin.x += [o_videoWindow frame].origin.x;
 
1382
        rect.origin.y += [o_videoWindow frame].origin.y;
1379
1383
        o_fullscreen_window = [[VLCWindow alloc] initWithContentRect:rect styleMask: NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
 
1384
        [o_fullscreen_window setFullscreen: YES];
1380
1385
        [o_fullscreen_window setBackgroundColor: [NSColor blackColor]];
1381
1386
        [o_fullscreen_window setCanBecomeKeyWindow: YES];
1382
1387
 
1383
 
        if (![self isVisible] || [self alphaValue] == 0.0)
 
1388
        if (![o_videoWindow isVisible] || [o_videoWindow alphaValue] == 0.0)
1384
1389
        {
1385
1390
            /* We don't animate if we are not visible, instead we
1386
1391
             * simply fade the display */
1435
1440
    if (b_fullscreen)
1436
1441
    {
1437
1442
        /* Make sure we are hidden */
1438
 
        [super orderOut: self];
 
1443
        if( b_nonembedded )
 
1444
            [o_nonembedded_window orderOut: self];
 
1445
        else
 
1446
            [super orderOut: self];
 
1447
        
1439
1448
        [self unlockFullscreenAnimation];
1440
1449
        return;
1441
1450
    }
1462
1471
    dict1 = [[NSMutableDictionary alloc] initWithCapacity:2];
1463
1472
    dict2 = [[NSMutableDictionary alloc] initWithCapacity:3];
1464
1473
 
1465
 
    [dict1 setObject:self forKey:NSViewAnimationTargetKey];
 
1474
    [dict1 setObject:o_videoWindow forKey:NSViewAnimationTargetKey];
1466
1475
    [dict1 setObject:NSViewAnimationFadeOutEffect forKey:NSViewAnimationEffectKey];
1467
1476
 
1468
1477
    [dict2 setObject:o_fullscreen_window forKey:NSViewAnimationTargetKey];
1504
1513
    [o_fspanel setVoutWasUpdated: (int)[[o_fullscreen_window screen] displayID]];
1505
1514
    [o_fspanel setActive: nil];
1506
1515
 
1507
 
    if([self isVisible])
 
1516
    if( !b_nonembedded && [self isVisible] )
1508
1517
        [super orderOut: self];
1509
1518
 
 
1519
    if( b_nonembedded && [o_nonembedded_window isVisible] )
 
1520
        [o_nonembedded_window orderOut: self];
 
1521
 
1510
1522
    [o_fspanel setActive: nil];
1511
1523
 
1512
1524
    b_fullscreen = YES;
1584
1596
        return;
1585
1597
    }
1586
1598
 
1587
 
    [self setAlphaValue: 0.0];
1588
 
    [self orderFront: self];
 
1599
    id o_videoWindow = b_nonembedded ? o_nonembedded_window : self;
 
1600
 
 
1601
    [o_videoWindow setAlphaValue: 0.0];
 
1602
    [o_videoWindow orderFront: self];
1589
1603
    [[o_video_view window] orderFront: self];
1590
1604
 
1591
1605
    [o_fspanel setNonActive: nil];
1606
1620
    }
1607
1621
 
1608
1622
    frame = [[o_temp_view superview] convertRect: [o_temp_view frame] toView: nil]; /* Convert to Window base coord */
1609
 
    id targetWindow = b_nonembedded ? o_nonembedded_window : self;
1610
 
    frame.origin.x += [targetWindow frame].origin.x;
1611
 
    frame.origin.y += [targetWindow frame].origin.y;
 
1623
    frame.origin.x += [o_videoWindow frame].origin.x;
 
1624
    frame.origin.y += [o_videoWindow frame].origin.y;
1612
1625
 
1613
1626
    dict2 = [[NSMutableDictionary alloc] initWithCapacity:2];
1614
 
    [dict2 setObject:self forKey:NSViewAnimationTargetKey];
 
1627
    [dict2 setObject:o_videoWindow forKey:NSViewAnimationTargetKey];
1615
1628
    [dict2 setObject:NSViewAnimationFadeInEffect forKey:NSViewAnimationEffectKey];
1616
1629
 
1617
1630
    o_fullscreen_anim2 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects:dict2, nil]];
1654
1667
    [[o_temp_view superview] replaceSubview:o_temp_view with:o_video_view];
1655
1668
    [o_video_view release];
1656
1669
    [o_video_view setFrame:[o_temp_view frame]];
1657
 
    [self makeFirstResponder: o_video_view];
1658
 
    if ([self isVisible])
1659
 
        [super makeKeyAndOrderFront:self]; /* our version contains a workaround */
 
1670
    [[o_video_view window] makeFirstResponder: o_video_view];
 
1671
    if( [[o_video_view window] isVisible] )
 
1672
    {
 
1673
        if( !b_nonembedded )
 
1674
            [super makeKeyAndOrderFront:self]; /* our version contains a workaround */
 
1675
        else
 
1676
            [[o_video_view window] makeKeyAndOrderFront: self];
 
1677
    }
1660
1678
    [o_fullscreen_window orderOut: self];
1661
1679
    NSEnableScreenUpdates();
1662
1680
 
1663
1681
    [o_fullscreen_window release];
1664
1682
    o_fullscreen_window = nil;
1665
 
    [self setLevel:i_originalLevel];
 
1683
    [[o_video_view window] setLevel:i_originalLevel];
 
1684
 
 
1685
    // if we quit fullscreen because there is no video anymore, make sure non-embedded window is not visible
 
1686
    if( ![[VLCMain sharedInstance] activeVideoPlayback] && b_nonembedded )
 
1687
        [o_nonembedded_window orderOut: self];
1666
1688
 
1667
1689
    [self unlockFullscreenAnimation];
1668
1690
}