1 /*****************************************************************************
2 * MainWindow.m: MacOS X interface module
3 *****************************************************************************
4 * Copyright (C) 2002-2012 VLC authors and VideoLAN
7 * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
8 * Jon Lech Johansen <jon-vl@nanocrew.net>
9 * Christophe Massiot <massiot@via.ecp.fr>
10 * Derk-Jan Hartman <hartman at videolan.org>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 *****************************************************************************/
27 #import "CompatibilityFixes.h"
28 #import "MainWindow.h"
30 #import "CoreInteraction.h"
31 #import "AudioEffects.h"
34 #import "controls.h" // TODO: remove me
36 #import "SideBarItem.h"
38 #import <vlc_playlist.h>
39 #import <vlc_aout_intf.h>
41 #import <vlc_strings.h>
42 #import <vlc_services_discovery.h>
43 #import <vlc_aout_intf.h>
45 #import "ControlsBar.h"
49 @interface VLCMainWindow ()
50 - (void)resizePlaylistAfterCollapse;
51 - (void)makeSplitViewVisible;
52 - (void)makeSplitViewHidden;
56 @implementation VLCMainWindow
57 static const float f_min_video_height = 70.0;
59 static VLCMainWindow *_o_sharedInstance = nil;
61 + (VLCMainWindow *)sharedInstance
63 return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
67 #pragma mark Initialization
71 if (_o_sharedInstance) {
73 return _o_sharedInstance;
75 _o_sharedInstance = [super init];
77 return _o_sharedInstance;
80 - (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)styleMask
81 backing:(NSBackingStoreType)backingType defer:(BOOL)flag
83 self = [super initWithContentRect:contentRect styleMask:styleMask
84 backing:backingType defer:flag];
85 _o_sharedInstance = self;
87 [[VLCMain sharedInstance] updateTogglePlaylistState];
92 - (BOOL)isEvent:(NSEvent *)o_event forKey:(const char *)keyString
97 key = config_GetPsz(VLCIntf, keyString);
98 o_key = [NSString stringWithFormat:@"%s", key];
101 unsigned int i_keyModifiers = [[VLCStringUtility sharedInstance] VLCModifiersToCocoa:o_key];
103 NSString * characters = [o_event charactersIgnoringModifiers];
104 if ([characters length] > 0) {
105 return [[characters lowercaseString] isEqualToString: [[VLCStringUtility sharedInstance] VLCKeyToString: o_key]] &&
106 (i_keyModifiers & NSShiftKeyMask) == ([o_event modifierFlags] & NSShiftKeyMask) &&
107 (i_keyModifiers & NSControlKeyMask) == ([o_event modifierFlags] & NSControlKeyMask) &&
108 (i_keyModifiers & NSAlternateKeyMask) == ([o_event modifierFlags] & NSAlternateKeyMask) &&
109 (i_keyModifiers & NSCommandKeyMask) == ([o_event modifierFlags] & NSCommandKeyMask);
114 - (BOOL)performKeyEquivalent:(NSEvent *)o_event
117 // these are key events which should be handled by vlc core, but are attached to a main menu item
118 if (![self isEvent: o_event forKey: "key-vol-up"] &&
119 ![self isEvent: o_event forKey: "key-vol-down"] &&
120 ![self isEvent: o_event forKey: "key-vol-mute"]) {
121 /* We indeed want to prioritize some Cocoa key equivalent against libvlc,
122 so we perform the menu equivalent now. */
123 if ([[NSApp mainMenu] performKeyEquivalent:o_event])
129 return [[VLCMain sharedInstance] hasDefinedShortcutKey:o_event force:b_force] ||
130 [(VLCControls *)[[VLCMain sharedInstance] controls] keyEvent:o_event];
135 if (b_dark_interface)
136 [o_color_backdrop release];
138 [[NSNotificationCenter defaultCenter] removeObserver: self];
139 [o_sidebaritems release];
141 if (o_extra_video_window) {
142 [o_extra_video_window release];
143 o_extra_video_window = nil;
146 if (o_detached_video_window) {
147 [o_detached_video_window release];
148 o_detached_video_window = nil;
156 BOOL b_splitviewShouldBeHidden = NO;
158 /* setup the styled interface */
159 b_nativeFullscreenMode = NO;
160 #ifdef MAC_OS_X_VERSION_10_7
161 if (!OSX_SNOW_LEOPARD)
162 b_nativeFullscreenMode = var_InheritBool(VLCIntf, "macosx-nativefullscreenmode");
164 t_hide_mouse_timer = nil;
165 [self useOptimizedDrawing: YES];
167 [[o_search_fld cell] setPlaceholderString: _NS("Search")];
168 [[o_search_fld cell] accessibilitySetOverrideValue:_NS("Enter a term to search the playlist. Results will be selected in the table.") forAttribute:NSAccessibilityDescriptionAttribute];
170 [o_dropzone_btn setTitle: _NS("Open media...")];
171 [[o_dropzone_btn cell] accessibilitySetOverrideValue:_NS("Click to open an advanced dialog to select the media to play. You can also drop files here to play.") forAttribute:NSAccessibilityDescriptionAttribute];
172 [o_dropzone_lbl setStringValue: _NS("Drop media here")];
174 [o_podcast_add_btn setTitle: _NS("Subscribe")];
175 [o_podcast_remove_btn setTitle: _NS("Unsubscribe")];
176 [o_podcast_subscribe_title_lbl setStringValue: _NS("Subscribe to a podcast")];
177 [o_podcast_subscribe_subtitle_lbl setStringValue: _NS("Enter URL of the podcast to subscribe to:")];
178 [o_podcast_subscribe_cancel_btn setTitle: _NS("Cancel")];
179 [o_podcast_subscribe_ok_btn setTitle: _NS("Subscribe")];
180 [o_podcast_unsubscribe_title_lbl setStringValue: _NS("Unsubscribe from a podcast")];
181 [o_podcast_unsubscribe_subtitle_lbl setStringValue: _NS("Select the podcast you would like to unsubscribe from:")];
182 [o_podcast_unsubscribe_ok_btn setTitle: _NS("Unsubscribe")];
183 [o_podcast_unsubscribe_cancel_btn setTitle: _NS("Cancel")];
185 /* interface builder action */
186 float f_threshold_height = f_min_video_height + [[o_controls_bar bottomBarView] frame].size.height;
187 if (b_dark_interface)
188 f_threshold_height += [o_titlebar_view frame].size.height;
189 if ([[self contentView] frame].size.height < f_threshold_height)
190 b_splitviewShouldBeHidden = YES;
192 [self setDelegate: self];
193 [self setExcludedFromWindowsMenu: YES];
194 [self setAcceptsMouseMovedEvents: YES];
195 // Set that here as IB seems to be buggy
196 if (b_dark_interface) {
197 [self setContentMinSize:NSMakeSize(604., 288. + [o_titlebar_view frame].size.height)];
199 [self setContentMinSize:NSMakeSize(604., 288.)];
202 [self setTitle: _NS("VLC media player")];
204 b_dropzone_active = YES;
205 o_temp_view = [[NSView alloc] init];
206 [o_temp_view setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable];
207 [o_dropzone_view setFrame: [o_playlist_table frame]];
208 [o_left_split_view setFrame: [o_sidebar_view frame]];
210 if (b_nativeFullscreenMode) {
211 [self setCollectionBehavior: NSWindowCollectionBehaviorFullScreenPrimary];
213 [o_titlebar_view setFullscreenButtonHidden: YES];
216 if (!OSX_SNOW_LEOPARD) {
217 /* the default small size of the search field is slightly different on Lion, let's work-around that */
219 frame = [o_search_fld frame];
220 frame.origin.y = frame.origin.y + 2.0;
221 frame.size.height = frame.size.height - 1.0;
222 [o_search_fld setFrame: frame];
225 /* create the sidebar */
226 o_sidebaritems = [[NSMutableArray alloc] init];
227 SideBarItem *libraryItem = [SideBarItem itemWithTitle:_NS("LIBRARY") identifier:@"library"];
228 SideBarItem *playlistItem = [SideBarItem itemWithTitle:_NS("Playlist") identifier:@"playlist"];
229 [playlistItem setIcon: [NSImage imageNamed:@"sidebar-playlist"]];
230 SideBarItem *medialibraryItem = [SideBarItem itemWithTitle:_NS("Media Library") identifier:@"medialibrary"];
231 [medialibraryItem setIcon: [NSImage imageNamed:@"sidebar-playlist"]];
232 SideBarItem *mycompItem = [SideBarItem itemWithTitle:_NS("MY COMPUTER") identifier:@"mycomputer"];
233 SideBarItem *devicesItem = [SideBarItem itemWithTitle:_NS("DEVICES") identifier:@"devices"];
234 SideBarItem *lanItem = [SideBarItem itemWithTitle:_NS("LOCAL NETWORK") identifier:@"localnetwork"];
235 SideBarItem *internetItem = [SideBarItem itemWithTitle:_NS("INTERNET") identifier:@"internet"];
237 /* SD subnodes, inspired by the Qt4 intf */
238 char **ppsz_longnames;
240 char **ppsz_names = vlc_sd_GetNames(pl_Get(VLCIntf), &ppsz_longnames, &p_categories);
242 msg_Err(VLCIntf, "no sd item found"); //TODO
243 char **ppsz_name = ppsz_names, **ppsz_longname = ppsz_longnames;
244 int *p_category = p_categories;
245 NSMutableArray *internetItems = [[NSMutableArray alloc] init];
246 NSMutableArray *devicesItems = [[NSMutableArray alloc] init];
247 NSMutableArray *lanItems = [[NSMutableArray alloc] init];
248 NSMutableArray *mycompItems = [[NSMutableArray alloc] init];
249 NSString *o_identifier;
250 for (; *ppsz_name; ppsz_name++, ppsz_longname++, p_category++) {
251 o_identifier = [NSString stringWithCString: *ppsz_name encoding: NSUTF8StringEncoding];
252 switch (*p_category) {
253 case SD_CAT_INTERNET:
254 [internetItems addObject: [SideBarItem itemWithTitle: _NS(*ppsz_longname) identifier: o_identifier]];
255 if (!strncmp(*ppsz_name, "podcast", 7))
256 [[internetItems lastObject] setIcon: [NSImage imageNamed:@"sidebar-podcast"]];
258 [[internetItems lastObject] setIcon: [NSImage imageNamed:@"NSApplicationIcon"]];
259 [[internetItems lastObject] setSdtype: SD_CAT_INTERNET];
260 [[internetItems lastObject] setUntranslatedTitle: [NSString stringWithUTF8String: *ppsz_longname]];
263 [devicesItems addObject: [SideBarItem itemWithTitle: _NS(*ppsz_longname) identifier: o_identifier]];
264 [[devicesItems lastObject] setIcon: [NSImage imageNamed:@"NSApplicationIcon"]];
265 [[devicesItems lastObject] setSdtype: SD_CAT_DEVICES];
266 [[devicesItems lastObject] setUntranslatedTitle: [NSString stringWithUTF8String: *ppsz_longname]];
269 [lanItems addObject: [SideBarItem itemWithTitle: _NS(*ppsz_longname) identifier: o_identifier]];
270 [[lanItems lastObject] setIcon: [NSImage imageNamed:@"sidebar-local"]];
271 [[lanItems lastObject] setSdtype: SD_CAT_LAN];
272 [[lanItems lastObject] setUntranslatedTitle: [NSString stringWithUTF8String: *ppsz_longname]];
274 case SD_CAT_MYCOMPUTER:
275 [mycompItems addObject: [SideBarItem itemWithTitle: _NS(*ppsz_longname) identifier: o_identifier]];
276 if (!strncmp(*ppsz_name, "video_dir", 9))
277 [[mycompItems lastObject] setIcon: [NSImage imageNamed:@"sidebar-movie"]];
278 else if (!strncmp(*ppsz_name, "audio_dir", 9))
279 [[mycompItems lastObject] setIcon: [NSImage imageNamed:@"sidebar-music"]];
280 else if (!strncmp(*ppsz_name, "picture_dir", 11))
281 [[mycompItems lastObject] setIcon: [NSImage imageNamed:@"sidebar-pictures"]];
283 [[mycompItems lastObject] setIcon: [NSImage imageNamed:@"NSApplicationIcon"]];
284 [[mycompItems lastObject] setUntranslatedTitle: [NSString stringWithUTF8String: *ppsz_longname]];
285 [[mycompItems lastObject] setSdtype: SD_CAT_MYCOMPUTER];
288 msg_Warn(VLCIntf, "unknown SD type found, skipping (%s)", *ppsz_name);
293 free(*ppsz_longname);
295 [mycompItem setChildren: [NSArray arrayWithArray: mycompItems]];
296 [devicesItem setChildren: [NSArray arrayWithArray: devicesItems]];
297 [lanItem setChildren: [NSArray arrayWithArray: lanItems]];
298 [internetItem setChildren: [NSArray arrayWithArray: internetItems]];
299 [mycompItems release];
300 [devicesItems release];
302 [internetItems release];
304 free(ppsz_longnames);
307 [libraryItem setChildren: [NSArray arrayWithObjects: playlistItem, medialibraryItem, nil]];
308 [o_sidebaritems addObject: libraryItem];
309 if ([mycompItem hasChildren])
310 [o_sidebaritems addObject: mycompItem];
311 if ([devicesItem hasChildren])
312 [o_sidebaritems addObject: devicesItem];
313 if ([lanItem hasChildren])
314 [o_sidebaritems addObject: lanItem];
315 if ([internetItem hasChildren])
316 [o_sidebaritems addObject: internetItem];
318 [o_sidebar_view reloadData];
319 [o_sidebar_view selectRowIndexes:[NSIndexSet indexSetWithIndex:1] byExtendingSelection:NO];
320 [o_sidebar_view setDropItem:playlistItem dropChildIndex:NSOutlineViewDropOnItemIndex];
321 [o_sidebar_view registerForDraggedTypes:[NSArray arrayWithObjects: NSFilenamesPboardType, @"VLCPlaylistItemPboardType", nil]];
323 [o_sidebar_view setAutosaveName:@"mainwindow-sidebar"];
324 [(PXSourceList *)o_sidebar_view setDataSource:self];
325 [o_sidebar_view setDelegate:self];
326 [o_sidebar_view setAutosaveExpandedItems:YES];
328 [o_sidebar_view expandItem: libraryItem expandChildren: YES];
330 /* make sure we display the desired default appearance when VLC launches for the first time */
331 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
332 if (![defaults objectForKey:@"VLCFirstRun"]) {
333 [defaults setObject:[NSDate date] forKey:@"VLCFirstRun"];
335 NSUInteger i_sidebaritem_count = [o_sidebaritems count];
336 for (NSUInteger x = 0; x < i_sidebaritem_count; x++)
337 [o_sidebar_view expandItem: [o_sidebaritems objectAtIndex: x] expandChildren: YES];
340 if (b_dark_interface) {
341 [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(windowResizedOrMoved:) name: NSWindowDidResizeNotification object: nil];
342 [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(windowResizedOrMoved:) name: NSWindowDidMoveNotification object: nil];
344 [self setBackgroundColor: [NSColor clearColor]];
345 [self setOpaque: NO];
347 [self setHasShadow:NO];
348 [self setHasShadow:YES];
350 NSRect winrect = [self frame];
351 CGFloat f_titleBarHeight = [o_titlebar_view frame].size.height;
353 [o_titlebar_view setFrame: NSMakeRect(0, winrect.size.height - f_titleBarHeight,
354 winrect.size.width, f_titleBarHeight)];
355 [[self contentView] addSubview: o_titlebar_view positioned: NSWindowAbove relativeTo: o_split_view];
357 if (winrect.size.height > 100) {
358 [self setFrame: winrect display:YES animate:YES];
359 previousSavedFrame = winrect;
362 winrect = [o_split_view frame];
363 winrect.size.height = winrect.size.height - f_titleBarHeight;
364 [o_split_view setFrame: winrect];
365 [o_video_view setFrame: winrect];
367 o_color_backdrop = [[VLCColorView alloc] initWithFrame: [o_split_view frame]];
368 [[self contentView] addSubview: o_color_backdrop positioned: NSWindowBelow relativeTo: o_split_view];
369 [o_color_backdrop setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable];
372 [o_video_view setFrame: [o_split_view frame]];
373 [o_playlist_table setBorderType: NSNoBorder];
374 [o_sidebar_scrollview setBorderType: NSNoBorder];
377 [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(someWindowWillClose:) name: NSWindowWillCloseNotification object: nil];
378 [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(someWindowWillMiniaturize:) name: NSWindowWillMiniaturizeNotification object:nil];
379 [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(applicationWillTerminate:) name: NSApplicationWillTerminateNotification object: nil];
381 [o_split_view setAutosaveName:@"10thanniversary-splitview"];
382 if (b_splitviewShouldBeHidden) {
383 [self hideSplitView];
384 i_lastSplitViewHeight = 300;
387 /* sanity check for the window size */
388 NSRect frame = [self frame];
389 NSSize screenSize = [[self screen] frame].size;
390 if (screenSize.width <= frame.size.width || screenSize.height <= frame.size.height) {
391 nativeVideoSize = screenSize;
398 - (VLCMainWindowControlsBar *)controlsBar;
400 return (VLCMainWindowControlsBar *)o_controls_bar;
403 - (void)resizePlaylistAfterCollapse
406 plrect = [o_playlist_table frame];
407 plrect.size.height = i_lastSplitViewHeight - 20.0; // actual pl top bar height, which differs from its frame
408 [[o_playlist_table animator] setFrame: plrect];
410 NSRect rightSplitRect;
411 rightSplitRect = [o_right_split_view frame];
412 plrect = [o_dropzone_box frame];
413 plrect.origin.x = (rightSplitRect.size.width - plrect.size.width) / 2;
414 plrect.origin.y = (rightSplitRect.size.height - plrect.size.height) / 2;
415 [[o_dropzone_box animator] setFrame: plrect];
418 - (void)makeSplitViewVisible
420 if (b_dark_interface)
421 [self setContentMinSize: NSMakeSize(604., 288. + [o_titlebar_view frame].size.height)];
423 [self setContentMinSize: NSMakeSize(604., 288.)];
425 NSRect old_frame = [self frame];
426 float newHeight = [self minSize].height;
427 if (old_frame.size.height < newHeight) {
428 NSRect new_frame = old_frame;
429 new_frame.origin.y = old_frame.origin.y + old_frame.size.height - newHeight;
430 new_frame.size.height = newHeight;
432 [[self animator] setFrame: new_frame display: YES animate: YES];
435 [o_video_view setHidden: YES];
436 [o_split_view setHidden: NO];
437 [self makeFirstResponder: nil];
441 - (void)makeSplitViewHidden
443 if (b_dark_interface)
444 [self setContentMinSize: NSMakeSize(604., f_min_video_height + [o_titlebar_view frame].size.height)];
446 [self setContentMinSize: NSMakeSize(604., f_min_video_height)];
448 [o_split_view setHidden: YES];
449 [o_video_view setHidden: NO];
451 if ([[o_video_view subviews] count] > 0)
452 [self makeFirstResponder: [[o_video_view subviews] objectAtIndex:0]];
455 // only exception for an controls bar button action
456 - (IBAction)togglePlaylist:(id)sender
458 if (![self isVisible] && sender != nil) {
459 [self makeKeyAndOrderFront: sender];
463 BOOL b_activeVideo = [[VLCMain sharedInstance] activeVideoPlayback];
464 BOOL b_restored = NO;
466 // TODO: implement toggle playlist in this situation (triggerd via menu item).
467 // but for now we block this case, to avoid displaying only the half
468 if (b_nativeFullscreenMode && b_fullscreen && b_activeVideo && sender != nil)
471 if (b_dropzone_active && ([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask) != 0) {
476 if (!(b_nativeFullscreenMode && b_fullscreen) && !b_splitview_removed && ((([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask) != 0 && b_activeVideo)
477 || (b_nonembedded && sender != nil)
478 || (!b_activeVideo && sender != nil)
479 || b_minimized_view))
480 [self hideSplitView];
482 if (b_splitview_removed) {
483 if (!b_nonembedded || (sender != nil && b_nonembedded))
484 [self showSplitView];
487 b_minimized_view = YES;
489 b_minimized_view = NO;
495 if (!b_nonembedded) {
496 if (([o_video_view isHidden] && b_activeVideo) || b_restored || (b_activeVideo && sender == nil))
497 [self makeSplitViewHidden];
499 [self makeSplitViewVisible];
501 [o_split_view setHidden: NO];
502 [o_playlist_table setHidden: NO];
503 [o_video_view setHidden: !b_activeVideo];
504 if (b_activeVideo && [[o_video_view subviews] count] > 0)
505 [[o_video_view window] makeFirstResponder: [[o_video_view subviews] objectAtIndex:0]];
510 - (IBAction)dropzoneButtonAction:(id)sender
512 [[[VLCMain sharedInstance] open] openFileGeneric];
516 #pragma mark overwritten default functionality
518 - (void)windowResizedOrMoved:(NSNotification *)notification
520 [self saveFrameUsingName: [self frameAutosaveName]];
523 - (void)applicationWillTerminate:(NSNotification *)notification
525 [self saveFrameUsingName: [self frameAutosaveName]];
529 - (void)someWindowWillClose:(NSNotification *)notification
531 id obj = [notification object];
532 if (obj == o_detached_video_window || obj == o_extra_video_window || (obj == self && !b_nonembedded)) {
533 if ([[VLCMain sharedInstance] activeVideoPlayback])
534 [[VLCCoreInteraction sharedInstance] stop];
538 - (void)someWindowWillMiniaturize:(NSNotification *)notification
540 if (config_GetInt(VLCIntf, "macosx-pause-minimized")) {
541 id obj = [notification object];
542 if (obj == o_detached_video_window || obj == o_extra_video_window || (obj == self && !b_nonembedded)) {
543 if ([[VLCMain sharedInstance] activeVideoPlayback])
544 [[VLCCoreInteraction sharedInstance] pause];
549 - (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize
551 id videoWindow = [o_video_view window];
552 if (![[VLCMain sharedInstance] activeVideoPlayback] || nativeVideoSize.width == 0. || nativeVideoSize.height == 0. || window != videoWindow)
553 return proposedFrameSize;
555 // needed when entering lion fullscreen mode
557 return proposedFrameSize;
559 if ([[VLCCoreInteraction sharedInstance] aspectRatioIsLocked]) {
560 NSRect videoWindowFrame = [videoWindow frame];
561 NSRect viewRect = [o_video_view convertRect:[o_video_view bounds] toView: nil];
562 NSRect contentRect = [videoWindow contentRectForFrameRect:videoWindowFrame];
563 float marginy = viewRect.origin.y + videoWindowFrame.size.height - contentRect.size.height;
564 float marginx = contentRect.size.width - viewRect.size.width;
565 if (b_dark_interface)// && b_video_deco)
566 marginy += [o_titlebar_view frame].size.height;
568 proposedFrameSize.height = (proposedFrameSize.width - marginx) * nativeVideoSize.height / nativeVideoSize.width + marginy;
571 return proposedFrameSize;
575 #pragma mark Update interface and respond to foreign events
578 b_dropzone_active = YES;
579 [o_right_split_view addSubview: o_dropzone_view positioned:NSWindowAbove relativeTo:o_playlist_table];
580 [o_dropzone_view setFrame: [o_playlist_table frame]];
581 [[o_playlist_table animator] setHidden:YES];
586 b_dropzone_active = NO;
587 [o_dropzone_view removeFromSuperview];
588 [[o_playlist_table animator] setHidden: NO];
591 - (void)hideSplitView
593 NSRect winrect = [self frame];
594 i_lastSplitViewHeight = [o_split_view frame].size.height;
595 winrect.size.height = winrect.size.height - i_lastSplitViewHeight;
596 winrect.origin.y = winrect.origin.y + i_lastSplitViewHeight;
597 [self setFrame: winrect display: YES animate: YES];
598 [self performSelector:@selector(hideDropZone) withObject:nil afterDelay:0.1];
599 if (b_dark_interface) {
600 [self setContentMinSize: NSMakeSize(604., [[o_controls_bar bottomBarView] frame].size.height + [o_titlebar_view frame].size.height)];
601 [self setContentMaxSize: NSMakeSize(FLT_MAX, [[o_controls_bar bottomBarView] frame].size.height + [o_titlebar_view frame].size.height)];
603 [self setContentMinSize: NSMakeSize(604., [[o_controls_bar bottomBarView] frame].size.height)];
604 [self setContentMaxSize: NSMakeSize(FLT_MAX, [[o_controls_bar bottomBarView] frame].size.height)];
607 b_splitview_removed = YES;
610 - (void)showSplitView
613 if (b_dark_interface)
614 [self setContentMinSize:NSMakeSize(604., 288. + [o_titlebar_view frame].size.height)];
616 [self setContentMinSize:NSMakeSize(604., 288.)];
617 [self setContentMaxSize: NSMakeSize(FLT_MAX, FLT_MAX)];
620 winrect = [self frame];
621 winrect.size.height = winrect.size.height + i_lastSplitViewHeight;
622 winrect.origin.y = winrect.origin.y - i_lastSplitViewHeight;
623 [self setFrame: winrect display: YES animate: YES];
625 [self performSelector:@selector(resizePlaylistAfterCollapse) withObject: nil afterDelay:0.75];
627 b_splitview_removed = NO;
630 - (void)updateTimeSlider
632 [o_controls_bar updateTimeSlider];
633 [[self controlsBar] updatePosAndTimeInFSPanel:o_fspanel];
634 if (o_detached_video_window)
635 [[o_detached_video_window controlsBar] updateTimeSlider];
640 input_thread_t * p_input;
641 p_input = pl_CurrentInput(VLCIntf);
644 char *format = var_InheritString(VLCIntf, "input-title-format");
645 char *formated = str_format_meta(pl_Get(VLCIntf), format);
647 aString = [NSString stringWithUTF8String:formated];
650 char *uri = input_item_GetURI(input_GetItem(p_input));
652 NSURL * o_url = [NSURL URLWithString: [NSString stringWithUTF8String: uri]];
653 if ([o_url isFileURL]) {
654 [self setRepresentedURL: o_url];
655 if (o_detached_video_window)
656 [o_detached_video_window setRepresentedURL: o_url];
658 [self setRepresentedURL: nil];
659 if (o_detached_video_window)
660 [o_detached_video_window setRepresentedURL: nil];
664 if ([aString isEqualToString:@""]) {
665 if ([o_url isFileURL])
666 aString = [[NSFileManager defaultManager] displayNameAtPath: [o_url path]];
668 aString = [o_url absoluteString];
671 [self setTitle: aString];
672 if (b_nonembedded && o_detached_video_window && [[VLCMain sharedInstance] activeVideoPlayback])
673 [o_detached_video_window setTitle: aString];
675 [o_fspanel setStreamTitle: aString];
676 vlc_object_release(p_input);
678 [self setTitle: _NS("VLC media player")];
679 [self setRepresentedURL: nil];
685 [o_controls_bar updateControls];
686 if (o_detached_video_window)
687 [[o_detached_video_window controlsBar] updateControls];
689 bool b_seekable = false;
691 playlist_t * p_playlist = pl_Get(VLCIntf);
692 input_thread_t * p_input = playlist_CurrentInput(p_playlist);
694 /* seekable streams */
695 b_seekable = var_GetBool(p_input, "can-seek");
697 vlc_object_release(p_input);
700 [self updateTimeSlider];
701 if ([o_fspanel respondsToSelector:@selector(setSeekable:)])
702 [o_fspanel setSeekable: b_seekable];
705 if ([[[VLCMain sharedInstance] playlist] currentPlaylistRoot] != p_playlist->p_local_category || p_playlist->p_local_category->i_children > 0)
710 [o_sidebar_view setNeedsDisplay:YES];
715 [o_controls_bar setPause];
716 if (o_detached_video_window)
717 [[o_detached_video_window controlsBar] setPause];
718 [o_fspanel setPause];
723 [o_controls_bar setPlay];
724 if (o_detached_video_window)
725 [[o_detached_video_window controlsBar] setPlay];
729 - (void)updateVolumeSlider
731 [[self controlsBar] updateVolumeSlider];
732 [o_fspanel setVolumeLevel: [[VLCCoreInteraction sharedInstance] volume]];
736 #pragma mark Video Output handling
738 - (VLCVoutView *)setupVout:(vout_window_t *)p_wnd
740 BOOL b_video_deco = var_InheritBool(VLCIntf, "video-deco");
741 BOOL b_video_wallpaper = var_InheritBool(VLCIntf, "video-wallpaper");
742 VLCVoutView *o_vout_view;
743 VLCVideoWindowCommon *o_new_video_window;
745 // TODO: make lion fullscreen compatible with video-wallpaper and !embedded-video
746 if ((b_video_wallpaper || !b_video_deco) && !b_nativeFullscreenMode) {
747 // b_video_wallpaper is priorized over !b_video_deco
749 msg_Dbg(VLCIntf, "Creating background / blank window");
750 NSScreen *screen = [NSScreen screenWithDisplayID:(CGDirectDisplayID)var_InheritInteger(VLCIntf, "macosx-vdev")];
752 screen = [self screen];
755 if (b_video_wallpaper)
756 window_rect = [screen frame];
758 window_rect = [self frame];
760 if (o_extra_video_window)
761 [o_extra_video_window release];
763 NSUInteger mask = NSBorderlessWindowMask;
764 if (!OSX_SNOW_LEOPARD && !b_video_deco)
765 mask |= NSResizableWindowMask;
767 BOOL b_no_video_deco_only = !b_video_wallpaper;
768 o_extra_video_window = [[VLCVideoWindowCommon alloc] initWithContentRect:window_rect styleMask:mask backing:NSBackingStoreBuffered defer:YES];
769 [o_extra_video_window setDelegate:self];
771 if (b_video_wallpaper)
772 [o_extra_video_window setLevel:CGWindowLevelForKey(kCGDesktopWindowLevelKey) + 1];
774 [o_extra_video_window setBackgroundColor: [NSColor blackColor]];
775 [o_extra_video_window setCanBecomeKeyWindow: !b_video_wallpaper];
776 [o_extra_video_window setCanBecomeMainWindow: !b_video_wallpaper];
777 [o_extra_video_window setAcceptsMouseMovedEvents: !b_video_wallpaper];
778 [o_extra_video_window setMovableByWindowBackground: !b_video_wallpaper];
779 [o_extra_video_window useOptimizedDrawing: YES];
781 o_vout_view = [[VLCVoutView alloc] initWithFrame:[[o_extra_video_window contentView] bounds]];
782 [o_vout_view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
783 [[o_extra_video_window contentView] addSubview:o_vout_view positioned:NSWindowAbove relativeTo:nil];
784 [o_extra_video_window setVideoView:o_vout_view];
786 o_new_video_window = o_extra_video_window;
788 if (b_video_wallpaper)
789 [o_extra_video_window orderBack:nil];
791 [o_extra_video_window center];
792 [o_extra_video_window setFrameAutosaveName:@"extra-videowindow"];
793 [o_extra_video_window setContentMinSize: NSMakeSize(f_min_video_height, f_min_video_height)];
798 if (var_InheritBool(VLCIntf, "embedded-video") || b_nativeFullscreenMode) {
799 o_vout_view = [o_video_view retain];
800 o_new_video_window = self;
803 if (!o_detached_video_window) {
804 NSWindowController *o_controller = [[NSWindowController alloc] initWithWindowNibName:@"DetachedVideoWindow"];
805 [o_controller loadWindow];
806 o_detached_video_window = [(VLCDetachedVideoWindow *)[o_controller window] retain];
807 [o_controller release];
809 // event occurs before window is created, so call again
810 [[VLCMain sharedInstance] playbackStatusUpdated];
813 [o_detached_video_window setDelegate: self];
814 if (b_dark_interface) {
815 [o_detached_video_window setContentMinSize: NSMakeSize(363., f_min_video_height + [[[o_detached_video_window controlsBar] bottomBarView] frame].size.height + [o_titlebar_view frame].size.height)];
817 [o_detached_video_window setContentMinSize: NSMakeSize(363., f_min_video_height + [[[o_detached_video_window controlsBar] bottomBarView] frame].size.height)];
820 [o_detached_video_window setLevel:NSNormalWindowLevel];
821 [o_detached_video_window useOptimizedDrawing: YES];
823 o_vout_view = [[o_detached_video_window videoView] retain];
824 o_new_video_window = o_detached_video_window;
829 if (!b_video_wallpaper) {
830 [o_new_video_window makeKeyAndOrderFront: self];
832 vout_thread_t *p_vout = getVout();
834 if (var_GetBool(p_vout, "video-on-top"))
835 [o_new_video_window setLevel: NSStatusWindowLevel];
837 [o_new_video_window setLevel: NSNormalWindowLevel];
838 vlc_object_release(p_vout);
842 [o_new_video_window setAlphaValue: config_GetFloat(VLCIntf, "macosx-opaqueness")];
844 return [o_vout_view autorelease];
847 - (void)setVideoplayEnabled
849 BOOL b_videoPlayback = [[VLCMain sharedInstance] activeVideoPlayback];
851 if (b_videoPlayback) {
852 frameBeforePlayback = [self frame];
854 // look for 'start at fullscreen'
855 [[VLCMain sharedInstance] fullscreenChanged];
858 [[self animator] setFrame:frameBeforePlayback display:YES];
860 [self makeFirstResponder: nil];
861 if (o_detached_video_window)
862 [o_detached_video_window orderOut: nil];
863 if (o_extra_video_window)
864 [o_extra_video_window orderOut: nil];
866 if ([self level] != NSNormalWindowLevel)
867 [self setLevel: NSNormalWindowLevel];
868 if (o_detached_video_window && [o_detached_video_window level] != NSNormalWindowLevel)
869 [o_detached_video_window setLevel: NSNormalWindowLevel];
871 // restore alpha value to 1 for the case that macosx-opaqueness is set to < 1
872 [self setAlphaValue:1.0];
875 if (b_nativeFullscreenMode) {
876 if ([NSApp presentationOptions] & NSApplicationPresentationFullScreen)
877 [[o_controls_bar bottomBarView] setHidden: b_videoPlayback];
879 [[o_controls_bar bottomBarView] setHidden: NO];
880 if (b_videoPlayback && b_fullscreen)
881 [o_fspanel setActive: nil];
882 if (!b_videoPlayback)
883 [o_fspanel setNonActive: nil];
886 if (!b_videoPlayback && b_fullscreen) {
887 if (!b_nativeFullscreenMode)
888 [[VLCCoreInteraction sharedInstance] toggleFullscreen];
894 if (b_fullscreen || (b_nativeFullscreenMode && [NSApp presentationOptions] & NSApplicationPresentationFullScreen))
897 id o_videoWindow = [o_video_view window];
898 NSSize windowMinSize = [o_videoWindow minSize];
899 NSRect screenFrame = [[o_videoWindow screen] visibleFrame];
901 NSPoint topleftbase = NSMakePoint(0, [o_videoWindow frame].size.height);
902 NSPoint topleftscreen = [o_videoWindow convertBaseToScreen: topleftbase];
904 unsigned int i_width = nativeVideoSize.width;
905 unsigned int i_height = nativeVideoSize.height;
906 if (i_width < windowMinSize.width)
907 i_width = windowMinSize.width;
908 if (i_height < f_min_video_height)
909 i_height = f_min_video_height;
911 /* Calculate the window's new size */
913 new_frame.size.width = [o_videoWindow frame].size.width - [o_video_view frame].size.width + i_width;
914 new_frame.size.height = [o_videoWindow frame].size.height - [o_video_view frame].size.height + i_height;
915 new_frame.origin.x = topleftscreen.x;
916 new_frame.origin.y = topleftscreen.y - new_frame.size.height;
918 /* make sure the window doesn't exceed the screen size the window is on */
919 if (new_frame.size.width > screenFrame.size.width) {
920 new_frame.size.width = screenFrame.size.width;
921 new_frame.origin.x = screenFrame.origin.x;
923 if (new_frame.size.height > screenFrame.size.height) {
924 new_frame.size.height = screenFrame.size.height;
925 new_frame.origin.y = screenFrame.origin.y;
927 if (new_frame.origin.y < screenFrame.origin.y)
928 new_frame.origin.y = screenFrame.origin.y;
930 CGFloat right_screen_point = screenFrame.origin.x + screenFrame.size.width;
931 CGFloat right_window_point = new_frame.origin.x + new_frame.size.width;
932 if (right_window_point > right_screen_point)
933 new_frame.origin.x -= (right_window_point - right_screen_point);
935 [[o_videoWindow animator] setFrame:new_frame display:YES];
938 - (void)setNativeVideoSize:(NSSize)size
940 nativeVideoSize = size;
942 if (var_InheritBool(VLCIntf, "macosx-video-autoresize") && !b_fullscreen && !var_InheritBool(VLCIntf, "video-wallpaper"))
943 [self performSelectorOnMainThread:@selector(resizeWindow) withObject:nil waitUntilDone:NO];
946 // Called automatically if window's acceptsMouseMovedEvents property is true
947 - (void)mouseMoved:(NSEvent *)theEvent
950 [self recreateHideMouseTimer];
952 [super mouseMoved: theEvent];
955 - (void)recreateHideMouseTimer
957 if (t_hide_mouse_timer != nil) {
958 [t_hide_mouse_timer invalidate];
959 [t_hide_mouse_timer release];
962 t_hide_mouse_timer = [NSTimer scheduledTimerWithTimeInterval:2
964 selector:@selector(hideMouseCursor:)
967 [t_hide_mouse_timer retain];
970 // NSTimer selectors require this function signature as per Apple's docs
971 - (void)hideMouseCursor:(NSTimer *)timer
973 [NSCursor setHiddenUntilMouseMoves: YES];
977 #pragma mark Fullscreen support
978 - (void)showFullscreenController
980 if (b_fullscreen && [[VLCMain sharedInstance] activeVideoPlayback])
989 - (void)lockFullscreenAnimation
991 [o_animation_lock lock];
994 - (void)unlockFullscreenAnimation
996 [o_animation_lock unlock];
999 - (void)enterFullscreen
1001 NSMutableDictionary *dict1, *dict2;
1005 BOOL blackout_other_displays = var_InheritBool(VLCIntf, "macosx-black");
1006 o_current_video_window = [o_video_view window];
1008 screen = [NSScreen screenWithDisplayID:(CGDirectDisplayID)var_InheritInteger(VLCIntf, "macosx-vdev")];
1009 [self lockFullscreenAnimation];
1012 msg_Dbg(VLCIntf, "chosen screen isn't present, using current screen for fullscreen mode");
1013 screen = [o_current_video_window screen];
1016 msg_Dbg(VLCIntf, "Using deepest screen");
1017 screen = [NSScreen deepestScreen];
1020 screen_rect = [screen frame];
1022 [o_controls_bar setFullscreenState:YES];
1023 if (o_detached_video_window)
1024 [[o_detached_video_window controlsBar] setFullscreenState:YES];
1026 [self recreateHideMouseTimer];
1028 if (blackout_other_displays)
1029 [screen blackoutOtherScreens];
1031 /* Make sure we don't see the window flashes in float-on-top mode */
1032 i_originalLevel = [o_current_video_window level];
1033 [o_current_video_window setLevel:NSNormalWindowLevel];
1035 /* Only create the o_fullscreen_window if we are not in the middle of the zooming animation */
1036 if (!o_fullscreen_window) {
1037 /* We can't change the styleMask of an already created NSWindow, so we create another window, and do eye catching stuff */
1039 rect = [[o_video_view superview] convertRect: [o_video_view frame] toView: nil]; /* Convert to Window base coord */
1040 rect.origin.x += [o_current_video_window frame].origin.x;
1041 rect.origin.y += [o_current_video_window frame].origin.y;
1042 o_fullscreen_window = [[VLCWindow alloc] initWithContentRect:rect styleMask: NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
1043 [o_fullscreen_window setBackgroundColor: [NSColor blackColor]];
1044 [o_fullscreen_window setCanBecomeKeyWindow: YES];
1045 [o_fullscreen_window setCanBecomeMainWindow: YES];
1047 if (![o_current_video_window isVisible] || [o_current_video_window alphaValue] == 0.0) {
1048 /* We don't animate if we are not visible, instead we
1049 * simply fade the display */
1050 CGDisplayFadeReservationToken token;
1052 if (blackout_other_displays) {
1053 CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &token);
1054 CGDisplayFade(token, 0.5, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0, 0, 0, YES);
1057 if ([screen mainScreen])
1058 [NSApp setPresentationOptions:(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
1060 [[o_video_view superview] replaceSubview:o_video_view with:o_temp_view];
1061 [o_temp_view setFrame:[o_video_view frame]];
1062 [o_fullscreen_window setContentView:o_video_view];
1064 [o_fullscreen_window makeKeyAndOrderFront:self];
1065 [o_fullscreen_window orderFront:self animate:YES];
1067 [o_fullscreen_window setFrame:screen_rect display:YES animate:YES];
1068 [o_fullscreen_window setLevel:NSNormalWindowLevel];
1070 if (blackout_other_displays) {
1071 CGDisplayFade(token, 0.3, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, NO);
1072 CGReleaseDisplayFadeReservation(token);
1075 /* Will release the lock */
1076 [self hasBecomeFullscreen];
1081 /* Make sure we don't see the o_video_view disappearing of the screen during this operation */
1082 NSDisableScreenUpdates();
1083 [[o_video_view superview] replaceSubview:o_video_view with:o_temp_view];
1084 [o_temp_view setFrame:[o_video_view frame]];
1085 [o_fullscreen_window setContentView:o_video_view];
1086 [o_fullscreen_window makeKeyAndOrderFront:self];
1087 NSEnableScreenUpdates();
1090 /* We are in fullscreen (and no animation is running) */
1092 /* Make sure we are hidden */
1093 [o_current_video_window orderOut: self];
1095 [self unlockFullscreenAnimation];
1099 if (o_fullscreen_anim1) {
1100 [o_fullscreen_anim1 stopAnimation];
1101 [o_fullscreen_anim1 release];
1103 if (o_fullscreen_anim2) {
1104 [o_fullscreen_anim2 stopAnimation];
1105 [o_fullscreen_anim2 release];
1108 if ([screen mainScreen])
1109 [NSApp setPresentationOptions:(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
1111 dict1 = [[NSMutableDictionary alloc] initWithCapacity:2];
1112 dict2 = [[NSMutableDictionary alloc] initWithCapacity:3];
1114 [dict1 setObject:o_current_video_window forKey:NSViewAnimationTargetKey];
1115 [dict1 setObject:NSViewAnimationFadeOutEffect forKey:NSViewAnimationEffectKey];
1117 [dict2 setObject:o_fullscreen_window forKey:NSViewAnimationTargetKey];
1118 [dict2 setObject:[NSValue valueWithRect:[o_fullscreen_window frame]] forKey:NSViewAnimationStartFrameKey];
1119 [dict2 setObject:[NSValue valueWithRect:screen_rect] forKey:NSViewAnimationEndFrameKey];
1121 /* Strategy with NSAnimation allocation:
1122 - Keep at most 2 animation at a time
1123 - leaveFullscreen/enterFullscreen are the only responsible for releasing and alloc-ing
1125 o_fullscreen_anim1 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObject:dict1]];
1126 o_fullscreen_anim2 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObject:dict2]];
1131 [o_fullscreen_anim1 setAnimationBlockingMode: NSAnimationNonblocking];
1132 [o_fullscreen_anim1 setDuration: 0.3];
1133 [o_fullscreen_anim1 setFrameRate: 30];
1134 [o_fullscreen_anim2 setAnimationBlockingMode: NSAnimationNonblocking];
1135 [o_fullscreen_anim2 setDuration: 0.2];
1136 [o_fullscreen_anim2 setFrameRate: 30];
1138 [o_fullscreen_anim2 setDelegate: self];
1139 [o_fullscreen_anim2 startWhenAnimation: o_fullscreen_anim1 reachesProgress: 1.0];
1141 [o_fullscreen_anim1 startAnimation];
1142 /* fullscreenAnimation will be unlocked when animation ends */
1145 - (void)hasBecomeFullscreen
1147 if ([[o_video_view subviews] count] > 0)
1148 [o_fullscreen_window makeFirstResponder: [[o_video_view subviews] objectAtIndex:0]];
1150 [o_fullscreen_window makeKeyWindow];
1151 [o_fullscreen_window setAcceptsMouseMovedEvents: YES];
1153 /* tell the fspanel to move itself to front next time it's triggered */
1154 [o_fspanel setVoutWasUpdated: (int)[[o_fullscreen_window screen] displayID]];
1155 [o_fspanel setActive: nil];
1157 if ([o_current_video_window isVisible])
1158 [o_current_video_window orderOut: self];
1161 [self unlockFullscreenAnimation];
1164 - (void)leaveFullscreen
1166 [self leaveFullscreenAndFadeOut: NO];
1169 - (void)leaveFullscreenAndFadeOut: (BOOL)fadeout
1171 NSMutableDictionary *dict1, *dict2;
1173 BOOL blackout_other_displays = var_InheritBool(VLCIntf, "macosx-black");
1175 if (!o_current_video_window)
1178 [self lockFullscreenAnimation];
1180 [o_controls_bar setFullscreenState:NO];
1181 if (o_detached_video_window)
1182 [[o_detached_video_window controlsBar] setFullscreenState:NO];
1184 /* We always try to do so */
1185 [NSScreen unblackoutScreens];
1187 vout_thread_t *p_vout = getVout();
1189 if (var_GetBool(p_vout, "video-on-top"))
1190 [[o_video_view window] setLevel: NSStatusWindowLevel];
1192 [[o_video_view window] setLevel: NSNormalWindowLevel];
1193 vlc_object_release(p_vout);
1195 [[o_video_view window] makeKeyAndOrderFront: nil];
1197 /* Don't do anything if o_fullscreen_window is already closed */
1198 if (!o_fullscreen_window) {
1199 [self unlockFullscreenAnimation];
1204 /* We don't animate if we are not visible, instead we
1205 * simply fade the display */
1206 CGDisplayFadeReservationToken token;
1208 if (blackout_other_displays) {
1209 CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &token);
1210 CGDisplayFade(token, 0.3, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0, 0, 0, YES);
1213 [o_fspanel setNonActive: nil];
1214 [NSApp setPresentationOptions: NSApplicationPresentationDefault];
1216 /* Will release the lock */
1217 [self hasEndedFullscreen];
1219 /* Our window is hidden, and might be faded. We need to workaround that, so note it
1221 b_window_is_invisible = YES;
1223 if (blackout_other_displays) {
1224 CGDisplayFade(token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, NO);
1225 CGReleaseDisplayFadeReservation(token);
1231 [o_current_video_window setAlphaValue: 0.0];
1232 [o_current_video_window orderFront: self];
1233 [[o_video_view window] orderFront: self];
1235 [o_fspanel setNonActive: nil];
1236 [NSApp setPresentationOptions:(NSApplicationPresentationDefault)];
1238 if (o_fullscreen_anim1) {
1239 [o_fullscreen_anim1 stopAnimation];
1240 [o_fullscreen_anim1 release];
1242 if (o_fullscreen_anim2) {
1243 [o_fullscreen_anim2 stopAnimation];
1244 [o_fullscreen_anim2 release];
1247 frame = [[o_temp_view superview] convertRect: [o_temp_view frame] toView: nil]; /* Convert to Window base coord */
1248 frame.origin.x += [o_current_video_window frame].origin.x;
1249 frame.origin.y += [o_current_video_window frame].origin.y;
1251 dict2 = [[NSMutableDictionary alloc] initWithCapacity:2];
1252 [dict2 setObject:o_current_video_window forKey:NSViewAnimationTargetKey];
1253 [dict2 setObject:NSViewAnimationFadeInEffect forKey:NSViewAnimationEffectKey];
1255 o_fullscreen_anim2 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects:dict2, nil]];
1258 [o_fullscreen_anim2 setAnimationBlockingMode: NSAnimationNonblocking];
1259 [o_fullscreen_anim2 setDuration: 0.3];
1260 [o_fullscreen_anim2 setFrameRate: 30];
1262 [o_fullscreen_anim2 setDelegate: self];
1264 dict1 = [[NSMutableDictionary alloc] initWithCapacity:3];
1266 [dict1 setObject:o_fullscreen_window forKey:NSViewAnimationTargetKey];
1267 [dict1 setObject:[NSValue valueWithRect:[o_fullscreen_window frame]] forKey:NSViewAnimationStartFrameKey];
1268 [dict1 setObject:[NSValue valueWithRect:frame] forKey:NSViewAnimationEndFrameKey];
1270 o_fullscreen_anim1 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects:dict1, nil]];
1273 [o_fullscreen_anim1 setAnimationBlockingMode: NSAnimationNonblocking];
1274 [o_fullscreen_anim1 setDuration: 0.2];
1275 [o_fullscreen_anim1 setFrameRate: 30];
1276 [o_fullscreen_anim2 startWhenAnimation: o_fullscreen_anim1 reachesProgress: 1.0];
1278 /* Make sure o_fullscreen_window is the frontmost window */
1279 [o_fullscreen_window orderFront: self];
1281 [o_fullscreen_anim1 startAnimation];
1282 /* fullscreenAnimation will be unlocked when animation ends */
1285 - (void)hasEndedFullscreen
1289 /* This function is private and should be only triggered at the end of the fullscreen change animation */
1290 /* Make sure we don't see the o_video_view disappearing of the screen during this operation */
1291 NSDisableScreenUpdates();
1292 [o_video_view retain];
1293 [o_video_view removeFromSuperviewWithoutNeedingDisplay];
1294 [[o_temp_view superview] replaceSubview:o_temp_view with:o_video_view];
1295 [o_video_view release];
1296 [o_video_view setFrame:[o_temp_view frame]];
1297 if ([[o_video_view subviews] count] > 0)
1298 [[o_video_view window] makeFirstResponder: [[o_video_view subviews] objectAtIndex:0]];
1300 [super makeKeyAndOrderFront:self]; /* our version contains a workaround */
1302 [[o_video_view window] makeKeyAndOrderFront: self];
1303 [o_fullscreen_window orderOut: self];
1304 NSEnableScreenUpdates();
1306 [o_fullscreen_window release];
1307 o_fullscreen_window = nil;
1308 [[o_video_view window] setLevel:i_originalLevel];
1309 [[o_video_view window] setAlphaValue: config_GetFloat(VLCIntf, "macosx-opaqueness")];
1311 // if we quit fullscreen because there is no video anymore, make sure non-embedded window is not visible
1312 if (![[VLCMain sharedInstance] activeVideoPlayback] && b_nonembedded)
1313 [o_current_video_window orderOut: self];
1315 o_current_video_window = nil;
1316 [self unlockFullscreenAnimation];
1319 - (void)animationDidEnd:(NSAnimation*)animation
1321 NSArray *viewAnimations;
1322 if (o_makekey_anim == animation) {
1323 [o_makekey_anim release];
1326 if ([animation currentValue] < 1.0)
1329 /* Fullscreen ended or started (we are a delegate only for leaveFullscreen's/enterFullscren's anim2) */
1330 viewAnimations = [o_fullscreen_anim2 viewAnimations];
1331 if ([viewAnimations count] >=1 &&
1332 [[[viewAnimations objectAtIndex: 0] objectForKey: NSViewAnimationEffectKey] isEqualToString:NSViewAnimationFadeInEffect]) {
1333 /* Fullscreen ended */
1334 [self hasEndedFullscreen];
1336 /* Fullscreen started */
1337 [self hasBecomeFullscreen];
1340 - (void)makeKeyAndOrderFront: (id)sender
1343 * when we exit fullscreen and fade out, we may endup in
1344 * having a window that is faded. We can't have it fade in unless we
1347 if (!b_window_is_invisible) {
1348 /* Make sure we don't do it too much */
1349 [super makeKeyAndOrderFront: sender];
1353 [super setAlphaValue:0.0f];
1354 [super makeKeyAndOrderFront: sender];
1356 NSMutableDictionary * dict = [[NSMutableDictionary alloc] initWithCapacity:2];
1357 [dict setObject:self forKey:NSViewAnimationTargetKey];
1358 [dict setObject:NSViewAnimationFadeInEffect forKey:NSViewAnimationEffectKey];
1360 o_makekey_anim = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObject:dict]];
1363 [o_makekey_anim setAnimationBlockingMode: NSAnimationNonblocking];
1364 [o_makekey_anim setDuration: 0.1];
1365 [o_makekey_anim setFrameRate: 30];
1366 [o_makekey_anim setDelegate: self];
1368 [o_makekey_anim startAnimation];
1369 b_window_is_invisible = NO;
1371 /* fullscreenAnimation will be unlocked when animation ends */
1375 #pragma mark Lion native fullscreen handling
1376 - (void)windowWillEnterFullScreen:(NSNotification *)notification
1378 // workaround, see #6668
1379 [NSApp setPresentationOptions:(NSApplicationPresentationFullScreen | NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
1381 var_SetBool(pl_Get(VLCIntf), "fullscreen", true);
1383 vout_thread_t *p_vout = getVout();
1385 var_SetBool(p_vout, "fullscreen", true);
1386 vlc_object_release(p_vout);
1389 [o_video_view setFrame: [[self contentView] frame]];
1392 [self recreateHideMouseTimer];
1393 i_originalLevel = [self level];
1394 [self setLevel:NSNormalWindowLevel];
1396 if (b_dark_interface) {
1397 [o_titlebar_view removeFromSuperviewWithoutNeedingDisplay];
1400 CGFloat f_titleBarHeight = [o_titlebar_view frame].size.height;
1401 winrect = [self frame];
1403 winrect.size.height = winrect.size.height - f_titleBarHeight;
1404 [self setFrame: winrect display:NO animate:NO];
1405 winrect = [o_split_view frame];
1406 winrect.size.height = winrect.size.height + f_titleBarHeight;
1407 [o_split_view setFrame: winrect];
1410 if ([[VLCMain sharedInstance] activeVideoPlayback])
1411 [[o_controls_bar bottomBarView] setHidden: YES];
1413 [self setMovableByWindowBackground: NO];
1416 - (void)windowDidEnterFullScreen:(NSNotification *)notification
1418 // Indeed, we somehow can have an "inactive" fullscreen (but a visible window!).
1419 // But this creates some problems when leaving fs over remote intfs, so activate app here.
1420 [NSApp activateIgnoringOtherApps:YES];
1422 [o_fspanel setVoutWasUpdated: (int)[[self screen] displayID]];
1423 [o_fspanel setActive: nil];
1426 - (void)windowWillExitFullScreen:(NSNotification *)notification
1429 var_SetBool(pl_Get(VLCIntf), "fullscreen", false);
1431 vout_thread_t *p_vout = getVout();
1433 var_SetBool(p_vout, "fullscreen", false);
1434 vlc_object_release(p_vout);
1437 [o_video_view setFrame: [o_split_view frame]];
1438 [NSCursor setHiddenUntilMouseMoves: NO];
1439 [o_fspanel setNonActive: nil];
1440 [self setLevel:i_originalLevel];
1443 if (b_dark_interface) {
1445 CGFloat f_titleBarHeight = [o_titlebar_view frame].size.height;
1446 winrect = [self frame];
1448 [o_titlebar_view setFrame: NSMakeRect(0, winrect.size.height - f_titleBarHeight,
1449 winrect.size.width, f_titleBarHeight)];
1450 [[self contentView] addSubview: o_titlebar_view];
1452 winrect.size.height = winrect.size.height + f_titleBarHeight;
1453 [self setFrame: winrect display:NO animate:NO];
1454 winrect = [o_split_view frame];
1455 winrect.size.height = winrect.size.height - f_titleBarHeight;
1456 [o_split_view setFrame: winrect];
1457 [o_video_view setFrame: winrect];
1460 if ([[VLCMain sharedInstance] activeVideoPlayback])
1461 [[o_controls_bar bottomBarView] setHidden: NO];
1463 [self setMovableByWindowBackground: YES];
1467 #pragma mark split view delegate
1468 - (CGFloat)splitView:(NSSplitView *)splitView constrainMaxCoordinate:(CGFloat)proposedMax ofSubviewAt:(NSInteger)dividerIndex
1470 if (dividerIndex == 0)
1476 - (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMin ofSubviewAt:(NSInteger)dividerIndex
1478 if (dividerIndex == 0)
1484 - (BOOL)splitView:(NSSplitView *)splitView canCollapseSubview:(NSView *)subview
1486 return ([subview isEqual:o_left_split_view]);
1489 - (BOOL)splitView:(NSSplitView *)splitView shouldAdjustSizeOfSubview:(NSView *)subview
1491 if ([subview isEqual:o_left_split_view])
1497 #pragma mark Side Bar Data handling
1498 /* taken under BSD-new from the PXSourceList sample project, adapted for VLC */
1499 - (NSUInteger)sourceList:(PXSourceList*)sourceList numberOfChildrenOfItem:(id)item
1501 //Works the same way as the NSOutlineView data source: `nil` means a parent item
1503 return [o_sidebaritems count];
1505 return [[item children] count];
1509 - (id)sourceList:(PXSourceList*)aSourceList child:(NSUInteger)index ofItem:(id)item
1511 //Works the same way as the NSOutlineView data source: `nil` means a parent item
1513 return [o_sidebaritems objectAtIndex:index];
1515 return [[item children] objectAtIndex:index];
1519 - (id)sourceList:(PXSourceList*)aSourceList objectValueForItem:(id)item
1521 return [item title];
1524 - (void)sourceList:(PXSourceList*)aSourceList setObjectValue:(id)object forItem:(id)item
1526 [item setTitle:object];
1529 - (BOOL)sourceList:(PXSourceList*)aSourceList isItemExpandable:(id)item
1531 return [item hasChildren];
1535 - (BOOL)sourceList:(PXSourceList*)aSourceList itemHasBadge:(id)item
1537 if ([[item identifier] isEqualToString: @"playlist"] || [[item identifier] isEqualToString: @"medialibrary"])
1540 return [item hasBadge];
1544 - (NSInteger)sourceList:(PXSourceList*)aSourceList badgeValueForItem:(id)item
1546 playlist_t * p_playlist = pl_Get(VLCIntf);
1547 NSInteger i_playlist_size;
1549 if ([[item identifier] isEqualToString: @"playlist"]) {
1551 i_playlist_size = p_playlist->p_local_category->i_children;
1554 return i_playlist_size;
1556 if ([[item identifier] isEqualToString: @"medialibrary"]) {
1558 i_playlist_size = p_playlist->p_ml_category->i_children;
1561 return i_playlist_size;
1564 return [item badgeValue];
1568 - (BOOL)sourceList:(PXSourceList*)aSourceList itemHasIcon:(id)item
1570 return [item hasIcon];
1574 - (NSImage*)sourceList:(PXSourceList*)aSourceList iconForItem:(id)item
1579 - (NSMenu*)sourceList:(PXSourceList*)aSourceList menuForEvent:(NSEvent*)theEvent item:(id)item
1581 if ([theEvent type] == NSRightMouseDown || ([theEvent type] == NSLeftMouseDown && ([theEvent modifierFlags] & NSControlKeyMask) == NSControlKeyMask)) {
1584 if ([item sdtype] > 0)
1586 m = [[NSMenu alloc] init];
1587 playlist_t * p_playlist = pl_Get(VLCIntf);
1588 BOOL sd_loaded = playlist_IsServicesDiscoveryLoaded(p_playlist, [[item identifier] UTF8String]);
1590 [m addItemWithTitle:_NS("Enable") action:@selector(sdmenuhandler:) keyEquivalent:@""];
1592 [m addItemWithTitle:_NS("Disable") action:@selector(sdmenuhandler:) keyEquivalent:@""];
1593 [[m itemAtIndex:0] setRepresentedObject: [item identifier]];
1595 return [m autorelease];
1602 - (IBAction)sdmenuhandler:(id)sender
1604 NSString * identifier = [sender representedObject];
1605 if ([identifier length] > 0 && ![identifier isEqualToString:@"lua{sd='freebox',longname='Freebox TV'}"]) {
1606 playlist_t * p_playlist = pl_Get(VLCIntf);
1607 BOOL sd_loaded = playlist_IsServicesDiscoveryLoaded(p_playlist, [identifier UTF8String]);
1610 playlist_ServicesDiscoveryAdd(p_playlist, [identifier UTF8String]);
1612 playlist_ServicesDiscoveryRemove(p_playlist, [identifier UTF8String]);
1617 #pragma mark Side Bar Delegate Methods
1618 /* taken under BSD-new from the PXSourceList sample project, adapted for VLC */
1619 - (BOOL)sourceList:(PXSourceList*)aSourceList isGroupAlwaysExpanded:(id)group
1621 if ([[group identifier] isEqualToString:@"library"])
1627 - (void)sourceListSelectionDidChange:(NSNotification *)notification
1629 playlist_t * p_playlist = pl_Get(VLCIntf);
1631 NSIndexSet *selectedIndexes = [o_sidebar_view selectedRowIndexes];
1632 id item = [o_sidebar_view itemAtRow:[selectedIndexes firstIndex]];
1635 //Set the label text to represent the new selection
1636 if ([item sdtype] > -1 && [[item identifier] length] > 0) {
1637 BOOL sd_loaded = playlist_IsServicesDiscoveryLoaded(p_playlist, [[item identifier] UTF8String]);
1639 playlist_ServicesDiscoveryAdd(p_playlist, [[item identifier] UTF8String]);
1642 [o_chosen_category_lbl setStringValue:[item title]];
1644 if ([[item identifier] isEqualToString:@"playlist"]) {
1645 [[[VLCMain sharedInstance] playlist] setPlaylistRoot:p_playlist->p_local_category];
1646 } else if ([[item identifier] isEqualToString:@"medialibrary"]) {
1647 [[[VLCMain sharedInstance] playlist] setPlaylistRoot:p_playlist->p_ml_category];
1649 playlist_item_t * pl_item;
1651 pl_item = playlist_ChildSearchName(p_playlist->p_root, [[item untranslatedTitle] UTF8String]);
1653 [[[VLCMain sharedInstance] playlist] setPlaylistRoot: pl_item];
1657 if ([[[VLCMain sharedInstance] playlist] currentPlaylistRoot] != p_playlist->p_local_category || p_playlist->p_local_category->i_children > 0)
1658 [self hideDropZone];
1660 [self showDropZone];
1663 if ([[item identifier] isEqualToString:@"podcast{longname=\"Podcasts\"}"])
1664 [self showPodcastControls];
1666 [self hidePodcastControls];
1669 - (NSDragOperation)sourceList:(PXSourceList *)aSourceList validateDrop:(id <NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(NSInteger)index
1671 if ([[item identifier] isEqualToString:@"playlist"] || [[item identifier] isEqualToString:@"medialibrary"]) {
1672 NSPasteboard *o_pasteboard = [info draggingPasteboard];
1673 if ([[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] || [[o_pasteboard types] containsObject: NSFilenamesPboardType])
1674 return NSDragOperationGeneric;
1676 return NSDragOperationNone;
1679 - (BOOL)sourceList:(PXSourceList *)aSourceList acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(NSInteger)index
1681 NSPasteboard *o_pasteboard = [info draggingPasteboard];
1683 playlist_t * p_playlist = pl_Get(VLCIntf);
1684 playlist_item_t *p_node;
1686 if ([[item identifier] isEqualToString:@"playlist"])
1687 p_node = p_playlist->p_local_category;
1689 p_node = p_playlist->p_ml_category;
1691 if ([[o_pasteboard types] containsObject: NSFilenamesPboardType]) {
1692 NSArray *o_values = [[o_pasteboard propertyListForType: NSFilenamesPboardType] sortedArrayUsingSelector: @selector(caseInsensitiveCompare:)];
1693 NSUInteger count = [o_values count];
1694 NSMutableArray *o_array = [NSMutableArray arrayWithCapacity:count];
1696 for(NSUInteger i = 0; i < count; i++) {
1697 NSDictionary *o_dic;
1698 char *psz_uri = vlc_path2uri([[o_values objectAtIndex:i] UTF8String], NULL);
1702 o_dic = [NSDictionary dictionaryWithObject:[NSString stringWithCString:psz_uri encoding:NSUTF8StringEncoding] forKey:@"ITEM_URL"];
1706 [o_array addObject: o_dic];
1709 [[[VLCMain sharedInstance] playlist] appendNodeArray:o_array inNode: p_node atPos:-1 enqueue:YES];
1712 else if ([[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"]) {
1713 NSArray * array = [[[VLCMain sharedInstance] playlist] draggedItems];
1715 NSUInteger count = [array count];
1716 playlist_item_t * p_item = NULL;
1719 for(NSUInteger i = 0; i < count; i++) {
1720 p_item = [[array objectAtIndex:i] pointerValue];
1721 if (!p_item) continue;
1722 playlist_NodeAddCopy(p_playlist, p_item, p_node, PLAYLIST_END);
1731 - (id)sourceList:(PXSourceList *)aSourceList persistentObjectForItem:(id)item
1733 return [item identifier];
1736 - (id)sourceList:(PXSourceList *)aSourceList itemForPersistentObject:(id)object
1738 /* the following code assumes for sakes of simplicity that only the top level
1739 * items are allowed to have children */
1741 NSArray * array = [NSArray arrayWithArray: o_sidebaritems]; // read-only arrays are noticebly faster
1742 NSUInteger count = [array count];
1746 for (NSUInteger x = 0; x < count; x++) {
1747 id item = [array objectAtIndex: x]; // save one objc selector call
1748 if ([[item identifier] isEqualToString:object])
1756 #pragma mark Podcast
1758 - (IBAction)addPodcast:(id)sender
1760 [NSApp beginSheet:o_podcast_subscribe_window modalForWindow:self modalDelegate:self didEndSelector:NULL contextInfo:nil];
1763 - (IBAction)addPodcastWindowAction:(id)sender
1765 [o_podcast_subscribe_window orderOut:sender];
1766 [NSApp endSheet: o_podcast_subscribe_window];
1768 if (sender == o_podcast_subscribe_ok_btn && [[o_podcast_subscribe_url_fld stringValue] length] > 0) {
1769 NSMutableString * podcastConf = [[NSMutableString alloc] init];
1770 if (config_GetPsz(VLCIntf, "podcast-urls") != NULL)
1771 [podcastConf appendFormat:@"%s|", config_GetPsz(VLCIntf, "podcast-urls")];
1773 [podcastConf appendString: [o_podcast_subscribe_url_fld stringValue]];
1774 config_PutPsz(VLCIntf, "podcast-urls", [podcastConf UTF8String]);
1776 vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name(VLCIntf->p_libvlc, "podcast");
1778 var_SetString(p_obj, "podcast-urls", [podcastConf UTF8String]);
1779 vlc_object_release(p_obj);
1781 [podcastConf release];
1785 - (IBAction)removePodcast:(id)sender
1787 if (config_GetPsz(VLCIntf, "podcast-urls") != NULL) {
1788 [o_podcast_unsubscribe_pop removeAllItems];
1789 [o_podcast_unsubscribe_pop addItemsWithTitles:[[NSString stringWithUTF8String:config_GetPsz(VLCIntf, "podcast-urls")] componentsSeparatedByString:@"|"]];
1790 [NSApp beginSheet:o_podcast_unsubscribe_window modalForWindow:self modalDelegate:self didEndSelector:NULL contextInfo:nil];
1794 - (IBAction)removePodcastWindowAction:(id)sender
1796 [o_podcast_unsubscribe_window orderOut:sender];
1797 [NSApp endSheet: o_podcast_unsubscribe_window];
1799 if (sender == o_podcast_unsubscribe_ok_btn) {
1800 NSMutableArray * urls = [[NSMutableArray alloc] initWithArray:[[NSString stringWithUTF8String:config_GetPsz(VLCIntf, "podcast-urls")] componentsSeparatedByString:@"|"]];
1801 [urls removeObjectAtIndex: [o_podcast_unsubscribe_pop indexOfSelectedItem]];
1802 config_PutPsz(VLCIntf, "podcast-urls", [[urls componentsJoinedByString:@"|"] UTF8String]);
1805 vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name(VLCIntf->p_libvlc, "podcast");
1807 var_SetString(p_obj, "podcast-urls", config_GetPsz(VLCIntf, "podcast-urls"));
1808 vlc_object_release(p_obj);
1811 /* reload the podcast module, since it won't update its list when removing podcasts */
1812 playlist_t * p_playlist = pl_Get(VLCIntf);
1813 if (playlist_IsServicesDiscoveryLoaded(p_playlist, "podcast{longname=\"Podcasts\"}")) {
1814 playlist_ServicesDiscoveryRemove(p_playlist, "podcast{longname=\"Podcasts\"}");
1815 playlist_ServicesDiscoveryAdd(p_playlist, "podcast{longname=\"Podcasts\"}");
1816 [o_playlist_table reloadData];
1822 - (void)showPodcastControls
1824 NSRect podcastViewDimensions = [o_podcast_view frame];
1825 NSRect rightSplitRect = [o_right_split_view frame];
1826 NSRect playlistTableRect = [o_playlist_table frame];
1828 podcastViewDimensions.size.width = rightSplitRect.size.width;
1829 podcastViewDimensions.origin.x = podcastViewDimensions.origin.y = .0;
1830 [o_podcast_view setFrame:podcastViewDimensions];
1832 playlistTableRect.origin.y = playlistTableRect.origin.y + podcastViewDimensions.size.height;
1833 playlistTableRect.size.height = playlistTableRect.size.height - podcastViewDimensions.size.height;
1834 [o_playlist_table setFrame:playlistTableRect];
1835 [o_playlist_table setNeedsDisplay:YES];
1837 [o_right_split_view addSubview: o_podcast_view positioned: NSWindowAbove relativeTo: o_right_split_view];
1838 b_podcastView_displayed = YES;
1841 - (void)hidePodcastControls
1843 if (b_podcastView_displayed) {
1844 NSRect podcastViewDimensions = [o_podcast_view frame];
1845 NSRect playlistTableRect = [o_playlist_table frame];
1847 playlistTableRect.origin.y = playlistTableRect.origin.y - podcastViewDimensions.size.height;
1848 playlistTableRect.size.height = playlistTableRect.size.height + podcastViewDimensions.size.height;
1850 [o_podcast_view removeFromSuperviewWithoutNeedingDisplay];
1851 [o_playlist_table setFrame: playlistTableRect];
1852 b_podcastView_displayed = NO;
1858 @implementation VLCDetachedVideoWindow
1860 - (void)awakeFromNib
1862 [self setAcceptsMouseMovedEvents: YES];
1864 [self setBackgroundColor: [NSColor blackColor]];
1865 if (b_dark_interface) {
1866 [self setOpaque: NO];
1868 [self setHasShadow:NO];
1869 [self setHasShadow:YES];
1871 NSRect winrect = [self frame];
1872 CGFloat f_titleBarHeight = [o_titlebar_view frame].size.height;
1874 [self setTitle: _NS("VLC media player")];
1875 [o_titlebar_view setFrame: NSMakeRect(0, winrect.size.height - f_titleBarHeight, winrect.size.width, f_titleBarHeight)];
1876 [[self contentView] addSubview: o_titlebar_view positioned: NSWindowAbove relativeTo: nil];
1878 // native fs not supported with detached view yet
1879 [o_titlebar_view setFullscreenButtonHidden: YES];
1882 NSRect videoViewRect = [[self contentView] bounds];
1883 if (b_dark_interface)
1884 videoViewRect.size.height -= [o_titlebar_view frame].size.height;
1885 CGFloat f_bottomBarHeight = [[[self controlsBar] bottomBarView] frame].size.height;
1886 videoViewRect.size.height -= f_bottomBarHeight;
1887 videoViewRect.origin.y = f_bottomBarHeight;
1888 [o_video_view setFrame: videoViewRect];