]> git.sesse.net Git - vlc/blob - modules/video_output/macosx.m
Revert "macosx vout: show complete window if we would resize beyond screen bounds"
[vlc] / modules / video_output / macosx.m
1 /*****************************************************************************
2  * macosx.m: MacOS X OpenGL provider
3  *****************************************************************************
4  * Copyright (C) 2001-2012 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Colin Delacroix <colin@zoy.org>
8  *          Florian G. Pflug <fgp@phlo.org>
9  *          Jon Lech Johansen <jon-vl@nanocrew.net>
10  *          Derk-Jan Hartman <hartman at videolan dot org>
11  *          Eric Petit <titer@m0k.org>
12  *          Benjamin Pracht <bigben at videolan dot org>
13  *          Damien Fouilleul <damienf at videolan dot org>
14  *          Pierre d'Herbemont <pdherbemont at videolan dot org>
15  *          Felix Paul Kühne <fkuehne at videolan dot org>
16  *
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation; either version 2 of the License, or
20  * (at your option) any later version.
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program; if not, write to the Free Software
29  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
30  *****************************************************************************/
31
32 /*****************************************************************************
33  * Preamble
34  *****************************************************************************/
35
36 #import <Cocoa/Cocoa.h>
37 #import <OpenGL/OpenGL.h>
38
39 #ifdef HAVE_CONFIG_H
40 # include "config.h"
41 #endif
42
43 #include <vlc_common.h>
44 #include <vlc_plugin.h>
45 #include <vlc_vout_display.h>
46 #include <vlc_opengl.h>
47 #include <vlc_dialog.h>
48 #include "opengl.h"
49
50 @interface NSWindow (VLCCustomCode)
51 - (BOOL)isFullscreen;
52 @end
53
54 /**
55  * Forward declarations
56  */
57 static int Open(vlc_object_t *);
58 static void Close(vlc_object_t *);
59
60 static picture_pool_t *Pool(vout_display_t *vd, unsigned requested_count);
61 static void PictureRender(vout_display_t *vd, picture_t *pic, subpicture_t *subpicture);
62 static void PictureDisplay(vout_display_t *vd, picture_t *pic, subpicture_t *subpicture);
63 static int Control (vout_display_t *vd, int query, va_list ap);
64
65 static int OpenglLock(vlc_gl_t *gl);
66 static void OpenglUnlock(vlc_gl_t *gl);
67 static void OpenglSwap(vlc_gl_t *gl);
68
69 /**
70  * Module declaration
71  */
72 vlc_module_begin ()
73     /* Will be loaded even without interface module. see voutgl.m */
74     set_shortname("Mac OS X")
75     set_description( N_("Mac OS X OpenGL video output (requires drawable-nsobject)"))
76     set_category(CAT_VIDEO)
77     set_subcategory(SUBCAT_VIDEO_VOUT )
78     set_capability("vout display", 300)
79     set_callbacks(Open, Close)
80
81     add_shortcut("macosx", "vout_macosx")
82 vlc_module_end ()
83
84 /**
85  * Obj-C protocol declaration that drawable-nsobject should follow
86  */
87 @protocol VLCOpenGLVideoViewEmbedding <NSObject>
88 - (void)addVoutSubview:(NSView *)view;
89 - (void)removeVoutSubview:(NSView *)view;
90 @end
91
92 @interface VLCOpenGLVideoView : NSOpenGLView
93 {
94     vout_display_t *vd;
95     BOOL _hasPendingReshape;
96 }
97 - (void)setVoutDisplay:(vout_display_t *)vd;
98 - (vout_display_t *)voutDisplay;
99 - (void)setVoutFlushing:(BOOL)flushing;
100 @end
101
102
103 struct vout_display_sys_t
104 {
105     VLCOpenGLVideoView *glView;
106     id<VLCOpenGLVideoViewEmbedding> container;
107
108     vout_window_t *embed;
109     vlc_gl_t gl;
110     vout_display_opengl_t *vgl;
111
112     picture_pool_t *pool;
113     picture_t *current;
114     bool has_first_frame;
115 };
116
117 static int Open(vlc_object_t *this)
118 {
119     vout_display_t *vd = (vout_display_t *)this;
120     vout_display_sys_t *sys = calloc(1, sizeof(*sys));
121     NSAutoreleasePool *nsPool = nil;
122
123     if (!sys)
124         return VLC_ENOMEM;
125
126     if( !CGDisplayUsesOpenGLAcceleration( kCGDirectMainDisplay ) )
127     {
128         msg_Err( this, "no OpenGL hardware acceleration found, video output will fail" );
129         dialog_Fatal( this, _("Video output is not supported"), _("Your Mac lacks Quartz Extreme acceleration, which is required for video output.") );
130         return VLC_EGENERIC;
131     }
132     else
133         msg_Dbg( this, "Quartz Extreme acceleration is active" );
134
135     vd->sys = sys;
136     sys->pool = NULL;
137     sys->gl.sys = NULL;
138     sys->embed = NULL;
139
140     /* Get the drawable object */
141     id container = var_CreateGetAddress(vd, "drawable-nsobject");
142     if (container)
143     {
144         vout_display_DeleteWindow(vd, NULL);
145     }
146     else
147     {
148         vout_window_cfg_t wnd_cfg;
149
150         memset (&wnd_cfg, 0, sizeof (wnd_cfg));
151         wnd_cfg.type = VOUT_WINDOW_TYPE_NSOBJECT;
152         wnd_cfg.x = var_InheritInteger (vd, "video-x");
153         wnd_cfg.y = var_InheritInteger (vd, "video-y");
154         wnd_cfg.width  = vd->cfg->display.width;
155         wnd_cfg.height = vd->cfg->display.height;
156
157         sys->embed = vout_display_NewWindow (vd, &wnd_cfg);
158         if (sys->embed)
159             container = sys->embed->handle.nsobject;
160
161         if (!container)
162         {
163             msg_Dbg(vd, "No drawable-nsobject nor vout_window_t found, passing over.");
164             goto error;
165         }
166     }
167
168     /* This will be released in Close(), on
169      * main thread, after we are done using it. */
170     sys->container = [container retain];
171
172     /* Get our main view*/
173     nsPool = [[NSAutoreleasePool alloc] init];
174
175     [VLCOpenGLVideoView performSelectorOnMainThread:@selector(getNewView:) withObject:[NSValue valueWithPointer:&sys->glView] waitUntilDone:YES];
176     if (!sys->glView)
177         goto error;
178
179     [sys->glView setVoutDisplay:vd];
180
181     /* We don't wait, that means that we'll have to be careful about releasing
182      * container.
183      * That's why we'll release on main thread in Close(). */
184     if ([(id)container respondsToSelector:@selector(addVoutSubview:)])
185         [(id)container performSelectorOnMainThread:@selector(addVoutSubview:) withObject:sys->glView waitUntilDone:NO];
186     else if ([container isKindOfClass:[NSView class]])
187     {
188         NSView *parentView = container;
189         [parentView performSelectorOnMainThread:@selector(addSubview:) withObject:sys->glView waitUntilDone:NO];
190         [sys->glView performSelectorOnMainThread:@selector(setFrameWithValue:) withObject:[NSValue valueWithRect:[parentView bounds]] waitUntilDone:NO];
191     }
192     else
193     {
194         msg_Err(vd, "Invalid drawable-nsobject object. drawable-nsobject must either be an NSView or comply to the @protocol VLCOpenGLVideoViewEmbedding.");
195         goto error;
196     }
197
198
199     [nsPool release];
200     nsPool = nil;
201
202     /* Initialize common OpenGL video display */
203     sys->gl.lock = OpenglLock;
204     sys->gl.unlock = OpenglUnlock;
205     sys->gl.swap = OpenglSwap;
206     sys->gl.getProcAddress = NULL;
207     sys->gl.sys = sys;
208     const vlc_fourcc_t *subpicture_chromas;
209     video_format_t fmt = vd->fmt;
210
211     sys->vgl = vout_display_opengl_New(&vd->fmt, &subpicture_chromas, &sys->gl);
212     if (!sys->vgl)
213     {
214         sys->gl.sys = NULL;
215         goto error;
216     }
217
218     /* */
219     vout_display_info_t info = vd->info;
220     info.has_pictures_invalid = false;
221     info.has_event_thread = true;
222     info.subpicture_chromas = subpicture_chromas;
223
224     /* Setup vout_display_t once everything is fine */
225     vd->info = info;
226
227     vd->pool = Pool;
228     vd->prepare = PictureRender;
229     vd->display = PictureDisplay;
230     vd->control = Control;
231
232     /* */
233     vout_display_SendEventFullscreen (vd, false);
234     vout_display_SendEventDisplaySize (vd, vd->source.i_visible_width, vd->source.i_visible_height, false);
235
236     return VLC_SUCCESS;
237
238 error:
239     [nsPool release];
240     Close(this);
241     return VLC_EGENERIC;
242 }
243
244 void Close(vlc_object_t *this)
245 {
246     vout_display_t *vd = (vout_display_t *)this;
247     vout_display_sys_t *sys = vd->sys;
248
249     if ([[sys->glView window] level] != NSNormalWindowLevel)
250         [[sys->glView window] setLevel: NSNormalWindowLevel];
251
252     [sys->glView setVoutDisplay:nil];
253
254     var_Destroy(vd, "drawable-nsobject");
255     if ([(id)sys->container respondsToSelector:@selector(removeVoutSubview:)])
256     {
257         /* This will retain sys->glView */
258         [(id)sys->container performSelectorOnMainThread:@selector(removeVoutSubview:) withObject:sys->glView waitUntilDone:NO];
259     }
260     /* release on main thread as explained in Open() */
261     [(id)sys->container performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO];
262     [sys->glView performSelectorOnMainThread:@selector(removeFromSuperview) withObject:nil waitUntilDone:NO];
263
264     [sys->glView release];
265
266     if (sys->gl.sys != NULL)
267         vout_display_opengl_Delete(sys->vgl);
268
269     if (sys->embed)
270         vout_display_DeleteWindow(vd, sys->embed);
271     free (sys);
272 }
273
274 /*****************************************************************************
275  * vout display callbacks
276  *****************************************************************************/
277
278 static picture_pool_t *Pool(vout_display_t *vd, unsigned requested_count)
279 {
280     vout_display_sys_t *sys = vd->sys;
281
282     if (!sys->pool)
283         sys->pool = vout_display_opengl_GetPool (sys->vgl, requested_count);
284     assert(sys->pool);
285     return sys->pool;
286 }
287
288 static void PictureRender(vout_display_t *vd, picture_t *pic, subpicture_t *subpicture)
289 {
290
291     vout_display_sys_t *sys = vd->sys;
292
293     vout_display_opengl_Prepare( sys->vgl, pic, subpicture );
294 }
295
296 static void PictureDisplay(vout_display_t *vd, picture_t *pic, subpicture_t *subpicture)
297 {
298     vout_display_sys_t *sys = vd->sys;
299     [sys->glView setVoutFlushing:YES];
300     vout_display_opengl_Display(sys->vgl, &vd->fmt );
301     [sys->glView setVoutFlushing:NO];
302     picture_Release (pic);
303     sys->has_first_frame = true;
304
305     if (subpicture)
306         subpicture_Delete(subpicture);
307 }
308
309 static int Control (vout_display_t *vd, int query, va_list ap)
310 {
311     vout_display_sys_t *sys = vd->sys;
312
313     switch (query)
314     {
315         case VOUT_DISPLAY_CHANGE_FULLSCREEN:
316         {
317             NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
318             [[sys->glView window] performSelectorOnMainThread:@selector(fullscreen:) withObject: nil waitUntilDone:NO];
319             [o_pool release];
320             return VLC_SUCCESS;
321         }
322         case VOUT_DISPLAY_CHANGE_WINDOW_STATE:
323         {
324             NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
325             unsigned state = va_arg (ap, unsigned);
326             [sys->glView performSelectorOnMainThread:@selector(setWindowLevel:) withObject:[NSNumber numberWithUnsignedInt:state] waitUntilDone:NO];
327             [o_pool release];
328             return VLC_SUCCESS;
329         }
330         case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED:
331         {
332             [[sys->glView window] performSelectorOnMainThread:@selector(performZoom:) withObject: nil waitUntilDone:NO];
333             return VLC_SUCCESS;
334         }
335         case VOUT_DISPLAY_CHANGE_ZOOM:
336         case VOUT_DISPLAY_CHANGE_SOURCE_ASPECT:
337         case VOUT_DISPLAY_CHANGE_SOURCE_CROP:
338             return VLC_SUCCESS;
339         case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
340         {
341             // is needed in the case we do not an actual resize
342             [sys->glView performSelectorOnMainThread:@selector(reshapeView:) withObject:nil waitUntilDone:NO];
343
344             if (!config_GetInt( vd, "macosx-video-autoresize" ))
345                 return VLC_SUCCESS;
346
347             NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
348             NSPoint topleftbase;
349             NSPoint topleftscreen;
350             NSRect new_frame;
351             const vout_display_cfg_t *cfg;
352
353             id o_window = [sys->glView window];
354             if (!o_window)
355                 return VLC_SUCCESS; // this is okay, since the event will occur again when we have a window
356             NSRect windowFrame = [o_window frame];
357             NSRect glViewFrame = [sys->glView frame];
358             NSSize screenSize = [[o_window screen] visibleFrame].size;
359             NSSize windowMinSize = [o_window minSize];
360
361             topleftbase.x = 0;
362             topleftbase.y = windowFrame.size.height;
363             topleftscreen = [o_window convertBaseToScreen: topleftbase];
364             cfg = (const vout_display_cfg_t*)va_arg (ap, const vout_display_cfg_t *);
365             int i_width = cfg->display.width;
366             int i_height = cfg->display.height;
367
368             /* Calculate the window's new size, if it is larger than our minimal size */
369             if (i_width < windowMinSize.width)
370                 i_width = windowMinSize.width;
371             if (i_height < windowMinSize.height)
372                 i_height = windowMinSize.height;
373
374             /* make sure the window doesn't exceed the screen size the window is on */
375             if (i_width > screenSize.width)
376                 i_width = screenSize.width;
377             if (i_height > screenSize.height)
378                 i_height = screenSize.height;
379
380             if( i_height != glViewFrame.size.height || i_width != glViewFrame.size.width )
381             {
382                 new_frame.size.width = windowFrame.size.width - glViewFrame.size.width + i_width;
383                 new_frame.size.height = windowFrame.size.height - glViewFrame.size.height + i_height;
384
385                 new_frame.origin.x = topleftscreen.x;
386                 new_frame.origin.y = topleftscreen.y - new_frame.size.height;
387
388                 [sys->glView performSelectorOnMainThread:@selector(setWindowFrameWithValue:) withObject:[NSValue valueWithRect:new_frame] waitUntilDone:NO];
389             }
390             [o_pool release];
391             return VLC_SUCCESS;
392         }
393
394         case VOUT_DISPLAY_HIDE_MOUSE:
395         {
396             [NSCursor setHiddenUntilMouseMoves: YES];
397             return VLC_SUCCESS;
398         }
399
400         case VOUT_DISPLAY_GET_OPENGL:
401         {
402             vlc_gl_t **gl = va_arg (ap, vlc_gl_t **);
403             *gl = &sys->gl;
404             return VLC_SUCCESS;
405         }
406
407         case VOUT_DISPLAY_RESET_PICTURES:
408             assert (0);
409         default:
410             msg_Err (vd, "Unknown request in Mac OS X vout display");
411             return VLC_EGENERIC;
412     }
413 }
414
415 /*****************************************************************************
416  * vout opengl callbacks
417  *****************************************************************************/
418 static int OpenglLock(vlc_gl_t *gl)
419 {
420     vout_display_sys_t *sys = (vout_display_sys_t *)gl->sys;
421     NSOpenGLContext *context = [sys->glView openGLContext];
422     CGLError err = CGLLockContext([context CGLContextObj]);
423     if (kCGLNoError == err)
424     {
425         [context makeCurrentContext];
426         return 0;
427     }
428     return 1;
429 }
430
431 static void OpenglUnlock(vlc_gl_t *gl)
432 {
433     vout_display_sys_t *sys = (vout_display_sys_t *)gl->sys;
434     CGLUnlockContext([[sys->glView openGLContext] CGLContextObj]);
435 }
436
437 static void OpenglSwap(vlc_gl_t *gl)
438 {
439     vout_display_sys_t *sys = (vout_display_sys_t *)gl->sys;
440     [[sys->glView openGLContext] flushBuffer];
441 }
442
443 /*****************************************************************************
444  * Our NSView object
445  *****************************************************************************/
446 @implementation VLCOpenGLVideoView
447
448 #define VLCAssertMainThread() assert([[NSThread currentThread] isMainThread])
449
450 + (void)getNewView:(NSValue *)value
451 {
452     id *ret = [value pointerValue];
453     *ret = [[self alloc] init];
454 }
455
456 /**
457  * Gets called by the Open() method.
458  */
459 - (id)init
460 {
461     VLCAssertMainThread();
462
463     /* Warning - this may be called on non main thread */
464
465     NSOpenGLPixelFormatAttribute attribs[] =
466     {
467         NSOpenGLPFADoubleBuffer,
468         NSOpenGLPFAAccelerated,
469         NSOpenGLPFANoRecovery,
470         NSOpenGLPFAColorSize, 24,
471         NSOpenGLPFAAlphaSize, 8,
472         NSOpenGLPFADepthSize, 24,
473         NSOpenGLPFAWindow,
474         0
475     };
476
477     NSOpenGLPixelFormat *fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];
478
479     if (!fmt)
480         return nil;
481
482     self = [super initWithFrame:NSMakeRect(0,0,10,10) pixelFormat:fmt];
483     [fmt release];
484
485     if (!self)
486         return nil;
487
488     /* Swap buffers only during the vertical retrace of the monitor.
489      http://developer.apple.com/documentation/GraphicsImaging/
490      Conceptual/OpenGL/chap5/chapter_5_section_44.html */
491     GLint params[] = { 1 };
492     CGLSetParameter([[self openGLContext] CGLContextObj], kCGLCPSwapInterval, params);
493
494     [self setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
495     return self;
496 }
497
498 /**
499  * Gets called by the Open() method.
500  */
501 - (void)setFrameWithValue:(NSValue *)value
502 {
503     [self setFrame:[value rectValue]];
504 }
505
506 /**
507  * Gets called by Control() to make sure that we're performing on the main thread
508  */
509 - (void)setWindowFrameWithValue:(NSValue *)value
510 {
511     if (![[self window] isFullscreen])
512     {
513         NSRect frame = [value rectValue];
514         if (frame.origin.x <= 0.0 && frame.origin.y <= 0.0)
515             [[self window] center];
516         [[self window] setFrame:frame display:YES animate: YES];
517     }
518 }
519
520 /**
521  * Gets called by the Close and Open methods.
522  * (Non main thread).
523  */
524 - (void)setVoutDisplay:(vout_display_t *)aVd
525 {
526     @synchronized(self) {
527         vd = aVd;
528     }
529 }
530
531 - (vout_display_t *)voutDisplay
532 {
533     return vd;
534 }
535
536 /**
537  * Gets called when the vout will aquire the lock and flush.
538  * (Non main thread).
539  */
540 - (void)setVoutFlushing:(BOOL)flushing
541 {
542     if (!flushing)
543         return;
544     @synchronized(self) {
545         _hasPendingReshape = NO;
546     }
547 }
548
549 /**
550  * Can -drawRect skip rendering?.
551  */
552 - (BOOL)canSkipRendering
553 {
554     VLCAssertMainThread();
555
556     @synchronized(self) {
557         BOOL hasFirstFrame = vd && vd->sys->has_first_frame;
558         return !_hasPendingReshape && hasFirstFrame;
559     }
560 }
561
562
563 /**
564  * Local method that locks the gl context.
565  */
566 - (BOOL)lockgl
567 {
568     VLCAssertMainThread();
569     NSOpenGLContext *context = [self openGLContext];
570     CGLError err = CGLLockContext([context CGLContextObj]);
571     if (err == kCGLNoError)
572         [context makeCurrentContext];
573     return err == kCGLNoError;
574 }
575
576 /**
577  * Local method that unlocks the gl context.
578  */
579 - (void)unlockgl
580 {
581     VLCAssertMainThread();
582     CGLUnlockContext([[self openGLContext] CGLContextObj]);
583 }
584
585 /**
586  * Local method that force a rendering of a frame.
587  * This will get called if Cocoa forces us to redraw (via -drawRect).
588  */
589 - (void)render
590 {
591     VLCAssertMainThread();
592
593     // We may have taken some times to take the opengl Lock.
594     // Check here to see if we can just skip the frame as well.
595     if ([self canSkipRendering])
596         return;
597
598     BOOL hasFirstFrame;
599     @synchronized(self) { // vd can be accessed from multiple threads
600         hasFirstFrame = vd && vd->sys->has_first_frame;
601     }
602
603     if (hasFirstFrame) {
604         // This will lock gl.
605         vout_display_opengl_Display( vd->sys->vgl, &vd->source );
606     }
607     else
608         glClear(GL_COLOR_BUFFER_BIT);
609 }
610
611 - (void)reshapeView:(id)sender
612 {
613     [self reshape];
614 }
615
616 /**
617  * Method called by Cocoa when the view is resized.
618  */
619 - (void)reshape
620 {
621     VLCAssertMainThread();
622
623     NSRect bounds = [self bounds];
624
625     CGFloat height = bounds.size.height;
626     CGFloat width = bounds.size.width;
627
628     GLint x = width, y = height;
629
630     @synchronized(self) {
631         if (vd) {
632             CGFloat videoHeight = vd->source.i_visible_height;
633             CGFloat videoWidth = vd->source.i_visible_width;
634
635             GLint sarNum = vd->source.i_sar_num;
636             GLint sarDen = vd->source.i_sar_den;
637
638             if (height * videoWidth * sarNum < width * videoHeight * sarDen)
639             {
640                 x = (height * videoWidth * sarNum) / (videoHeight * sarDen);
641                 y = height;
642             }
643             else
644             {
645                 x = width;
646                 y = (width * videoHeight * sarDen) / (videoWidth * sarNum);
647             }
648         }
649     }
650
651     if ([self lockgl]) {
652         glViewport((width - x) / 2, (height - y) / 2, x, y);
653
654         @synchronized(self) {
655             // This may be cleared before -drawRect is being called,
656             // in this case we'll skip the rendering.
657             // This will save us for rendering two frames (or more) for nothing
658             // (one by the vout, one (or more) by drawRect)
659             _hasPendingReshape = YES;
660         }
661
662         [self unlockgl];
663
664         [super reshape];
665     }
666 }
667
668 /**
669  * Method called by Cocoa when the view is resized or the location has changed.
670  * We just need to make sure we are locking here.
671  */
672 - (void)update
673 {
674     VLCAssertMainThread();
675     BOOL success = [self lockgl];
676     if (!success)
677         return;
678
679     [super update];
680
681     [self unlockgl];
682 }
683
684 /**
685  * Method called by Cocoa to force redraw.
686  */
687 - (void)drawRect:(NSRect) rect
688 {
689     VLCAssertMainThread();
690
691     if ([self canSkipRendering])
692         return;
693
694     BOOL success = [self lockgl];
695     if (!success)
696         return;
697
698     [self render];
699
700     [self unlockgl];
701 }
702
703 - (void)renewGState
704 {
705     NSWindow *window = [self window];
706
707     // Remove flashes with splitter view.
708     if ([window respondsToSelector:@selector(disableScreenUpdatesUntilFlush)])
709         [window disableScreenUpdatesUntilFlush];
710
711     [super renewGState];
712 }
713
714 - (BOOL)mouseDownCanMoveWindow
715 {
716     return YES;
717 }
718
719 - (BOOL)isOpaque
720 {
721     return YES;
722 }
723
724 - (void)setWindowLevel:(NSNumber*)state
725 {
726     if( [state unsignedIntValue] & VOUT_WINDOW_STATE_ABOVE )
727         [[self window] setLevel: NSStatusWindowLevel];
728     else
729         [[self window] setLevel: NSNormalWindowLevel];
730 }
731 @end