macosx: Rename and invert isNotEmbedded
[vlc.git] / modules / gui / macosx / VLCVoutWindowController.m
1 /*****************************************************************************
2  * VLCVoutWindowController.m: MacOS X interface module
3  *****************************************************************************
4  * Copyright (C) 2012-2014 VLC authors and VideoLAN
5  * $Id$
6  *
7  * Authors: Felix Paul K├╝hne <fkuehne -at- videolan -dot- org>
8  *          David Fuhrmann <david dot fuhrmann at googlemail dot com>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #include <vlc_vout_display.h>
26
27 #import "CompatibilityFixes.h"
28 #import "VLCVoutWindowController.h"
29 #import "VLCMain.h"
30 #import "VLCMainWindow.h"
31 #import "VLCVoutView.h"
32
33 #import "VLCVideoEffectsWindowController.h"
34 #import "VLCAudioEffectsWindowController.h"
35 #import "VLCPlaylistInfo.h"
36 #import "VLCBookmarksWindowController.h"
37 #import "VLCTrackSynchronizationWindowController.h"
38 #import "VLCResumeDialogController.h"
39 #import "VLCPlaylist.h"
40 #import "NSScreen+VLCAdditions.h"
41
42 static atomic_bool b_intf_starting = ATOMIC_VAR_INIT(false);
43
44 static int WindowControl(vout_window_t *, int i_query, va_list);
45
46 int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg)
47 {
48     @autoreleasepool {
49         if (cfg->type != VOUT_WINDOW_TYPE_INVALID
50             && cfg->type != VOUT_WINDOW_TYPE_NSOBJECT)
51             return VLC_EGENERIC;
52
53         msg_Dbg(p_wnd, "Opening video window");
54
55         if (!atomic_load(&b_intf_starting)) {
56             msg_Err(p_wnd, "Cannot create vout as Mac OS X interface was not found");
57             return VLC_EGENERIC;
58         }
59
60         NSRect proposedVideoViewPosition = NSMakeRect(cfg->x, cfg->y, cfg->width, cfg->height);
61
62         VLCVoutWindowController *voutController = [[VLCMain sharedInstance] voutController];
63         if (!voutController) {
64             return VLC_EGENERIC;
65         }
66         [voutController.lock lock];
67
68         SEL sel = @selector(setupVoutForWindow:withProposedVideoViewPosition:);
69         NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[voutController methodSignatureForSelector:sel]];
70         [inv setTarget:voutController];
71         [inv setSelector:sel];
72         [inv setArgument:&p_wnd atIndex:2]; // starting at 2!
73         [inv setArgument:&proposedVideoViewPosition atIndex:3];
74
75         [inv performSelectorOnMainThread:@selector(invoke) withObject:nil
76                            waitUntilDone:YES];
77
78         VLCVoutView *videoView = nil;
79         [inv getReturnValue:&videoView];
80
81         // this method is not supposed to fail
82         assert(videoView != nil);
83
84         msg_Dbg(getIntf(), "returning videoview with proposed position x=%i, y=%i, width=%i, height=%i", cfg->x, cfg->y, cfg->width, cfg->height);
85         p_wnd->handle.nsobject = (void *)CFBridgingRetain(videoView);
86
87         [voutController.lock unlock];
88
89         p_wnd->type = VOUT_WINDOW_TYPE_NSOBJECT;
90         p_wnd->control = WindowControl;
91     }
92     vout_window_SetFullScreen(p_wnd, cfg->is_fullscreen);
93     return VLC_SUCCESS;
94 }
95
96 static int WindowControl(vout_window_t *p_wnd, int i_query, va_list args)
97 {
98     @autoreleasepool {
99         VLCVoutWindowController *voutController = [[VLCMain sharedInstance] voutController];
100         if (!voutController) {
101             return VLC_EGENERIC;
102         }
103         [voutController.lock lock];
104
105         switch(i_query) {
106             case VOUT_WINDOW_SET_STATE:
107             {
108                 unsigned i_state = va_arg(args, unsigned);
109
110                 if (i_state & VOUT_WINDOW_STATE_BELOW)
111                 {
112                     msg_Dbg(p_wnd, "Ignore change to VOUT_WINDOW_STATE_BELOW");
113                     goto out;
114                 }
115
116                 NSInteger i_cooca_level = NSNormalWindowLevel;
117                 if (i_state & VOUT_WINDOW_STATE_ABOVE)
118                     i_cooca_level = NSStatusWindowLevel;
119
120                 SEL sel = @selector(setWindowLevel:forWindow:);
121                 NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[voutController methodSignatureForSelector:sel]];
122                 [inv setTarget:voutController];
123                 [inv setSelector:sel];
124                 [inv setArgument:&i_cooca_level atIndex:2]; // starting at 2!
125                 [inv setArgument:&p_wnd atIndex:3];
126                 [inv performSelectorOnMainThread:@selector(invoke) withObject:nil
127                                    waitUntilDone:NO];
128
129                 break;
130             }
131             case VOUT_WINDOW_SET_SIZE:
132             {
133                 unsigned int i_width  = va_arg(args, unsigned int);
134                 unsigned int i_height = va_arg(args, unsigned int);
135
136                 NSSize newSize = NSMakeSize(i_width, i_height);
137                 SEL sel = @selector(setNativeVideoSize:forWindow:);
138                 NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[voutController methodSignatureForSelector:sel]];
139                 [inv setTarget:voutController];
140                 [inv setSelector:sel];
141                 [inv setArgument:&newSize atIndex:2]; // starting at 2!
142                 [inv setArgument:&p_wnd atIndex:3];
143                 [inv performSelectorOnMainThread:@selector(invoke) withObject:nil
144                                    waitUntilDone:NO];
145
146                 break;
147             }
148             case VOUT_WINDOW_SET_FULLSCREEN:
149             {
150                 if (var_InheritBool(getIntf(), "video-wallpaper")) {
151                     msg_Dbg(p_wnd, "Ignore fullscreen event as video-wallpaper is on");
152                     goto out;
153                 }
154
155                 int i_full = va_arg(args, int);
156                 BOOL b_animation = YES;
157
158                 SEL sel = @selector(setFullscreen:forWindow:withAnimation:);
159                 NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[voutController methodSignatureForSelector:sel]];
160                 [inv setTarget:voutController];
161                 [inv setSelector:sel];
162                 [inv setArgument:&i_full atIndex:2]; // starting at 2!
163                 [inv setArgument:&p_wnd atIndex:3];
164                 [inv setArgument:&b_animation atIndex:4];
165                 [inv performSelectorOnMainThread:@selector(invoke) withObject:nil
166                                    waitUntilDone:NO];
167
168                 break;
169             }
170             default:
171             {
172                 msg_Warn(p_wnd, "unsupported control query: %i", i_query );
173                 [voutController.lock unlock];
174                 return VLC_EGENERIC;
175             }
176         }
177
178         out:
179         [voutController.lock unlock];
180         return VLC_SUCCESS;
181     }
182 }
183
184 void WindowClose(vout_window_t *p_wnd)
185 {
186     @autoreleasepool {
187         VLCVoutWindowController *voutController = [[VLCMain sharedInstance] voutController];
188         if (!voutController) {
189             return;
190         }
191
192         [voutController.lock lock];
193         [voutController performSelectorOnMainThread:@selector(removeVoutforDisplay:) withObject:[NSValue valueWithPointer:p_wnd] waitUntilDone:NO];
194         [voutController.lock unlock];
195     }
196 }
197
198 @interface VLCVoutWindowController ()
199 {
200     NSMutableDictionary *voutWindows;
201     VLCKeyboardBacklightControl *keyboardBacklight;
202
203     NSPoint topLeftPoint;
204
205     // save the status level if at least one video window is on status level
206     NSUInteger statusLevelWindowCounter;
207     NSInteger currentWindowLevel;
208
209     BOOL mainWindowHasVideo;
210 }
211 @end
212
213 @implementation VLCVoutWindowController
214
215 - (id)init
216 {
217     self = [super init];
218     if (self) {
219         atomic_store(&b_intf_starting, true);
220         voutWindows = [[NSMutableDictionary alloc] init];
221         keyboardBacklight = [[VLCKeyboardBacklightControl alloc] init];
222         currentWindowLevel = NSNormalWindowLevel;
223         _currentStatusWindowLevel = NSFloatingWindowLevel;
224     }
225     return self;
226 }
227
228 - (void)dealloc
229 {
230     NSArray *keys = [voutWindows allKeys];
231     for (NSValue *key in keys)
232         [self removeVoutforDisplay:key];
233
234     if (var_InheritBool(getIntf(), "macosx-dim-keyboard")) {
235         [keyboardBacklight switchLightsInstantly:YES];
236     }
237 }
238
239 #pragma mark -
240 #pragma mark Methods for vout provider
241
242 - (VLCVoutView *)setupVoutForWindow:(vout_window_t *)p_wnd withProposedVideoViewPosition:(NSRect)videoViewPosition
243 {
244     BOOL isEmbedded = YES;
245     BOOL isNativeFullscreen = [[VLCMain sharedInstance] nativeFullscreenMode];
246     BOOL windowDecorations = var_InheritBool(getIntf(), "video-deco");
247     BOOL videoWallpaper = var_InheritBool(getIntf(), "video-wallpaper");
248     BOOL multipleVoutWindows = [voutWindows count] > 0;
249     VLCVoutView *voutView;
250     VLCVideoWindowCommon *newVideoWindow;
251
252     // should be called before any window resizing occurs
253     if (!multipleVoutWindows)
254         [[[VLCMain sharedInstance] mainWindow] videoplayWillBeStarted];
255
256     if (multipleVoutWindows && videoWallpaper)
257         videoWallpaper = false;
258
259     // TODO: make lion fullscreen compatible with video-wallpaper
260     if ((videoWallpaper || !windowDecorations) && !isNativeFullscreen) {
261         // videoWallpaper is priorized over !windowDecorations
262
263         msg_Dbg(getIntf(), "Creating background / blank window");
264         NSScreen *screen = [NSScreen screenWithDisplayID:(CGDirectDisplayID)var_InheritInteger(getIntf(), "macosx-vdev")];
265         if (!screen)
266             screen = [[[VLCMain sharedInstance] mainWindow] screen];
267
268         NSRect window_rect;
269         if (videoWallpaper)
270             window_rect = [screen frame];
271         else
272             window_rect = [[[VLCMain sharedInstance] mainWindow] frame];
273
274         NSUInteger mask = NSBorderlessWindowMask;
275         if (!windowDecorations)
276             mask |= NSResizableWindowMask;
277
278         newVideoWindow = [[VLCVideoWindowCommon alloc] initWithContentRect:window_rect styleMask:mask backing:NSBackingStoreBuffered defer:YES];
279         [newVideoWindow setDelegate:newVideoWindow];
280         [newVideoWindow setReleasedWhenClosed: NO];
281
282         if (videoWallpaper)
283             [newVideoWindow setLevel:CGWindowLevelForKey(kCGDesktopWindowLevelKey) + 1];
284
285         [newVideoWindow setBackgroundColor: [NSColor blackColor]];
286         [newVideoWindow setCanBecomeKeyWindow: !videoWallpaper];
287         [newVideoWindow setCanBecomeMainWindow: !videoWallpaper];
288         [newVideoWindow setAcceptsMouseMovedEvents: !videoWallpaper];
289         [newVideoWindow setMovableByWindowBackground: !videoWallpaper];
290         [newVideoWindow useOptimizedDrawing: YES];
291
292         voutView = [[VLCVoutView alloc] initWithFrame:[[newVideoWindow contentView] bounds]];
293         [voutView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
294         [[newVideoWindow contentView] addSubview:voutView positioned:NSWindowAbove relativeTo:nil];
295         [newVideoWindow setVideoView:voutView];
296
297
298         if (videoWallpaper)
299             [newVideoWindow orderBack:nil];
300         else {
301             // no frame autosave for additional vout windows
302             if (!multipleVoutWindows) {
303                 // initial window position
304                 [newVideoWindow center];
305                 [newVideoWindow setFrameAutosaveName:@"extra-videowindow"];
306             }
307
308             [newVideoWindow setContentMinSize: NSMakeSize(f_min_video_height, f_min_video_height)];
309         }
310
311         isEmbedded = NO;
312     } else {
313         if ((var_InheritBool(getIntf(), "embedded-video") && !mainWindowHasVideo)) {
314             // setup embedded video
315             newVideoWindow = [[VLCMain sharedInstance] mainWindow] ;
316             voutView = [newVideoWindow videoView];
317             mainWindowHasVideo = YES;
318             isEmbedded = YES;
319         } else {
320             // setup detached window with controls
321             NSWindowController *o_controller = [[NSWindowController alloc] initWithWindowNibName:@"DetachedVideoWindow"];
322             [o_controller loadWindow];
323             newVideoWindow = (VLCDetachedVideoWindow *)[o_controller window];
324
325             // no frame autosave for additional vout windows
326             if (multipleVoutWindows)
327                 [newVideoWindow setFrameAutosaveName:@""];
328
329             [newVideoWindow setDelegate: newVideoWindow];
330             [newVideoWindow setLevel:NSNormalWindowLevel];
331             [newVideoWindow useOptimizedDrawing: YES];
332             voutView = [newVideoWindow videoView];
333             isEmbedded = NO;
334         }
335     }
336
337     NSSize videoViewSize = NSMakeSize(videoViewPosition.size.width, videoViewPosition.size.height);
338
339     // Avoid flashes if video will directly start in fullscreen
340     NSDisableScreenUpdates();
341
342     if (!videoWallpaper) {
343         // set (only!) window origin if specified
344         if (!isEmbedded) {
345             NSRect window_rect = [newVideoWindow frame];
346             if (videoViewPosition.origin.x > 0.)
347                 window_rect.origin.x = videoViewPosition.origin.x;
348             if (videoViewPosition.origin.y > 0.)
349                 window_rect.origin.y = videoViewPosition.origin.y;
350
351             [newVideoWindow setFrame:window_rect display:YES];
352         }
353
354         // cascade windows if we have more than one vout
355         if (multipleVoutWindows) {
356             if ([voutWindows count] == 1) {
357                 NSWindow * firstWindow = [voutWindows objectForKey: [[voutWindows allKeys] firstObject]];
358
359                 NSRect topleftBaseRect = NSMakeRect(0, [firstWindow frame].size.height, 0, 0);
360                 topLeftPoint = [firstWindow convertRectToScreen: topleftBaseRect].origin;
361             }
362
363             topLeftPoint = [newVideoWindow cascadeTopLeftFromPoint: topLeftPoint];
364             [newVideoWindow setFrameTopLeftPoint: topLeftPoint];
365         }
366
367         // resize window
368         [newVideoWindow setNativeVideoSize:videoViewSize];
369
370         [newVideoWindow makeKeyAndOrderFront: self];
371     }
372
373     [newVideoWindow setAlphaValue: config_GetFloat(getIntf(), "macosx-opaqueness")];
374
375     [voutView setVoutThread:(vout_thread_t *)p_wnd->obj.parent];
376     [newVideoWindow setHasActiveVideo: YES];
377     [voutWindows setObject:newVideoWindow forKey:[NSValue valueWithPointer:p_wnd]];
378
379     [[VLCMain sharedInstance] setActiveVideoPlayback: YES];
380     [[[VLCMain sharedInstance] mainWindow] setNonembedded:!mainWindowHasVideo];
381
382     // beware of order, setActiveVideoPlayback:, setHasActiveVideo: and setNonembedded: must be called before
383     if ([newVideoWindow class] == [VLCMainWindow class])
384         [[[VLCMain sharedInstance] mainWindow] changePlaylistState: psVideoStartedOrStoppedEvent];
385
386     if (!isEmbedded) {
387         // events might be posted before window is created, so call them again
388         [[[VLCMain sharedInstance] mainWindow] updateName];
389         [[[VLCMain sharedInstance] mainWindow] updateWindow]; // update controls bar
390     }
391
392     // TODO: find a cleaner way for "start in fullscreen"
393     // Start in fs, because either prefs settings, or fullscreen button was pressed before
394     char *psz_splitter = var_GetString(pl_Get(getIntf()), "video-splitter");
395     BOOL b_have_splitter = psz_splitter != NULL && *psz_splitter != '\0';
396     free(psz_splitter);
397
398     if (!videoWallpaper && !b_have_splitter && (var_InheritBool(getIntf(), "fullscreen") || var_GetBool(pl_Get(getIntf()), "fullscreen"))) {
399
400         // this is not set when we start in fullscreen because of
401         // fullscreen settings in video prefs the second time
402         var_SetBool(p_wnd->obj.parent, "fullscreen", 1);
403
404         [self setFullscreen:1 forWindow:p_wnd withAnimation:NO];
405     }
406
407     NSEnableScreenUpdates();
408
409     return voutView;
410 }
411
412 - (void)removeVoutforDisplay:(NSValue *)o_key
413 {
414     VLCVideoWindowCommon *o_window = [voutWindows objectForKey:o_key];
415     if (!o_window) {
416         msg_Err(getIntf(), "Cannot close nonexisting window");
417         return;
418     }
419
420     [[o_window videoView] releaseVoutThread];
421
422     // set active video to no BEFORE closing the window and exiting fullscreen
423     // (avoid stopping playback due to NSWindowWillCloseNotification, preserving fullscreen state)
424     [o_window setHasActiveVideo: NO];
425
426     // prevent visible extra window if in fullscreen
427     NSDisableScreenUpdates();
428     BOOL b_native = [[[VLCMain sharedInstance] mainWindow] nativeFullscreenMode];
429
430     // close fullscreen, without changing fullscreen vars
431     if (!b_native && ([o_window fullscreen] || [o_window inFullscreenTransition]))
432         [o_window leaveFullscreenWithAnimation:NO];
433
434     // native fullscreen window will not be closed if
435     // fullscreen was triggered without video
436     if ((b_native && [o_window class] == [VLCMainWindow class] && [o_window fullscreen] && [o_window windowShouldExitFullscreenWhenFinished])) {
437         [o_window toggleFullScreen:self];
438     }
439
440     if ([o_window class] != [VLCMainWindow class]) {
441         [o_window close];
442     }
443     NSEnableScreenUpdates();
444
445     [voutWindows removeObjectForKey:o_key];
446     if ([voutWindows count] == 0) {
447         [[VLCMain sharedInstance] setActiveVideoPlayback:NO];
448         statusLevelWindowCounter = 0;
449     }
450
451     if ([o_window class] == [VLCMainWindow class]) {
452         mainWindowHasVideo = NO;
453
454         // video in main window might get stopped while another vout is open
455         if ([voutWindows count] > 0)
456             [[[VLCMain sharedInstance] mainWindow] setNonembedded:YES];
457
458         // beware of order, setActiveVideoPlayback:, setHasActiveVideo: and setNonembedded: must be called before
459         [[[VLCMain sharedInstance] mainWindow] changePlaylistState: psVideoStartedOrStoppedEvent];
460     }
461 }
462
463
464 - (void)setNativeVideoSize:(NSSize)size forWindow:(vout_window_t *)p_wnd
465 {
466     VLCVideoWindowCommon *o_window = [voutWindows objectForKey:[NSValue valueWithPointer:p_wnd]];
467     if (!o_window) {
468         msg_Err(getIntf(), "Cannot set size for nonexisting window");
469         return;
470     }
471
472     [o_window setNativeVideoSize:size];
473 }
474
475 - (void)setWindowLevel:(NSInteger)i_level forWindow:(vout_window_t *)p_wnd
476 {
477     VLCVideoWindowCommon *o_window = [voutWindows objectForKey:[NSValue valueWithPointer:p_wnd]];
478     if (!o_window) {
479         msg_Err(getIntf(), "Cannot set level for nonexisting window");
480         return;
481     }
482
483     // only set level for helper windows to normal if no status vout window exist anymore
484     if(i_level == NSStatusWindowLevel) {
485         statusLevelWindowCounter++;
486         // window level need to stay on normal in fullscreen mode
487         if (![o_window fullscreen] && ![o_window inFullscreenTransition])
488             [self updateWindowLevelForHelperWindows:i_level];
489     } else {
490         if (statusLevelWindowCounter > 0)
491             statusLevelWindowCounter--;
492
493         if (statusLevelWindowCounter == 0) {
494             [self updateWindowLevelForHelperWindows:i_level];
495         }
496     }
497
498     [o_window setWindowLevel:i_level];
499 }
500
501 - (void)setFullscreen:(int)i_full forWindow:(vout_window_t *)p_wnd withAnimation:(BOOL)b_animation
502 {
503     intf_thread_t *p_intf = getIntf();
504     BOOL b_nativeFullscreenMode = [[VLCMain sharedInstance] nativeFullscreenMode];
505
506     if (!p_intf || (!b_nativeFullscreenMode && !p_wnd))
507         return;
508     playlist_t *p_playlist = pl_Get(p_intf);
509     BOOL b_fullscreen = i_full != 0;
510
511     if (!var_GetBool(p_playlist, "fullscreen") != !b_fullscreen)
512         var_SetBool(p_playlist, "fullscreen", b_fullscreen);
513
514     VLCVideoWindowCommon *o_current_window = nil;
515     if(p_wnd)
516         o_current_window = [voutWindows objectForKey:[NSValue valueWithPointer:p_wnd]];
517
518     if (var_InheritBool(p_intf, "macosx-dim-keyboard")) {
519         [keyboardBacklight switchLightsAsync:!b_fullscreen];
520     }
521
522     if (b_nativeFullscreenMode) {
523         if(!o_current_window)
524             o_current_window = [[VLCMain sharedInstance] mainWindow] ;
525         assert(o_current_window);
526
527         // fullscreen might be triggered twice (vout event)
528         // so ignore duplicate events here
529         if((b_fullscreen && !([o_current_window fullscreen] || [o_current_window inFullscreenTransition])) ||
530            (!b_fullscreen && [o_current_window fullscreen])) {
531
532             [o_current_window toggleFullScreen:self];
533         }
534     } else {
535         assert(o_current_window);
536
537         if (b_fullscreen) {
538             input_thread_t * p_input = pl_CurrentInput(p_intf);
539             if (p_input != NULL && [[VLCMain sharedInstance] activeVideoPlayback]) {
540                 // activate app, as method can also be triggered from outside the app (prevents nasty window layout)
541                 [NSApp activateIgnoringOtherApps:YES];
542                 [o_current_window enterFullscreenWithAnimation:b_animation];
543
544             }
545             if (p_input)
546                 vlc_object_release(p_input);
547         } else {
548             // leaving fullscreen is always allowed
549             [o_current_window leaveFullscreenWithAnimation:YES];
550         }
551     }
552 }
553
554 #pragma mark -
555 #pragma mark Misc methods
556
557 - (void)updateControlsBarsUsingBlock:(void (^)(VLCControlsBarCommon *controlsBar))block
558 {
559     [voutWindows enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
560
561         if ([obj respondsToSelector:@selector(controlsBar)]) {
562             VLCControlsBarCommon *o_controlsBar = [obj controlsBar];
563             if (o_controlsBar && block)
564                 block(o_controlsBar);
565         }
566     }];
567 }
568
569 - (void)updateWindowsUsingBlock:(void (^)(VLCVideoWindowCommon *o_window))windowUpdater
570 {
571     [voutWindows enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
572         if ([obj isKindOfClass: [NSWindow class]])
573             windowUpdater(obj);
574     }];
575 }
576
577 - (void)updateWindowLevelForHelperWindows:(NSInteger)i_level
578 {
579     if (var_InheritBool(getIntf(), "video-wallpaper"))
580         return;
581
582     currentWindowLevel = i_level;
583     if (i_level == NSNormalWindowLevel) {
584         _currentStatusWindowLevel = NSFloatingWindowLevel;
585     } else {
586         _currentStatusWindowLevel = i_level + 1;
587     }
588
589     NSInteger currentStatusWindowLevel = self.currentStatusWindowLevel;
590
591     VLCMain *main = [VLCMain sharedInstance];
592     [[[VLCMain sharedInstance] mainWindow] setWindowLevel:i_level];
593     [[main videoEffectsPanel] updateCocoaWindowLevel:currentStatusWindowLevel];
594     [[main audioEffectsPanel] updateCocoaWindowLevel:currentStatusWindowLevel];
595     [[main currentMediaInfoPanel] updateCocoaWindowLevel:currentStatusWindowLevel];
596     [[main bookmarks] updateCocoaWindowLevel:currentStatusWindowLevel];
597     [[main trackSyncPanel] updateCocoaWindowLevel:currentStatusWindowLevel];
598     [[main resumeDialog] updateCocoaWindowLevel:currentStatusWindowLevel];
599 }
600
601 @end