]> git.sesse.net Git - vlc/blobdiff - modules/gui/minimal_macosx/VLCOpenGLVoutView.m
Removes trailing spaces. Removes tabs.
[vlc] / modules / gui / minimal_macosx / VLCOpenGLVoutView.m
index aa7fe067586617c77213718e1eeaee7c01ad5e87..7da994f7c92f7822e027d96be02bb88d7e091b67 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * VLCOpenGLVoutView.m: MacOS X OpenGL provider
  *****************************************************************************
- * Copyright (C) 2001-2004 the VideoLAN team
+ * Copyright (C) 2001-2007 the VideoLAN team
  * $Id$
  *
  * Authors: Colin Delacroix <colin@zoy.org>
@@ -11,7 +11,7 @@
  *          Eric Petit <titer@m0k.org>
  *          Benjamin Pracht <bigben at videolan dot org>
  *          Damien Fouilleul <damienf at videolan dot org>
- *          Pierr d'Herbemont <pdherbemont at videolan dot org>
+ *          Pierre d'Herbemont <pdherbemont at videolan dot org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -52,16 +52,16 @@ int cocoaglvoutviewInit( vout_thread_t * p_vout )
     var_Create( p_vout, "drawable", VLC_VAR_DOINHERIT );
     var_Get( p_vout, "drawable", &value_drawable );
 
+    p_vout->p_sys->o_pool = [[NSAutoreleasePool alloc] init];
+
     o_cocoaglview_container = (id) value_drawable.i_int;
     if (!o_cocoaglview_container)
     {
         msg_Warn( p_vout, "No drawable!, spawing a window" );
-        o_cocoaglview_container = [[VLCMinimalVoutWindow alloc] initWithContentRect: NSMakeRect( 0, 0, 200, 200 )];
     }
 
     p_vout->p_sys->b_embedded = VLC_FALSE;
 
-    p_vout->p_sys->o_pool = [[NSAutoreleasePool alloc] init];
 
     /* Create the GL view */
     struct args { vout_thread_t * p_vout; id <VLCOpenGLVoutEmbedding> container; } args = { p_vout, o_cocoaglview_container };
@@ -95,8 +95,10 @@ void cocoaglvoutviewEnd( vout_thread_t * p_vout )
     if( [(id)o_cocoaglview_container respondsToSelector:@selector(removeVoutSubview:)] )
         [o_cocoaglview_container removeVoutSubview: p_vout->p_sys->o_glview];
 
+    [p_vout->p_sys->o_glview release];
+
     [p_vout->p_sys->o_pool release];
-    
 }
 
 /*****************************************************************************
@@ -195,20 +197,27 @@ void cocoaglvoutviewUnlock( vout_thread_t * p_vout )
  * vout_thread_t. Must be called from main thread. */
 + (void) autoinitOpenGLVoutViewIntVoutWithContainer: (NSData *) argsAsData
 {
+    NSAutoreleasePool   *pool = [[NSAutoreleasePool alloc] init];
     struct args { vout_thread_t * p_vout; id <VLCOpenGLVoutEmbedding> container; } *
         args = (struct args *)[argsAsData bytes];
     VLCOpenGLVoutView * oglview;
 
+    if( !args->container )
+    {
+        args->container = [[VLCMinimalVoutWindow alloc] initWithContentRect: NSMakeRect( 0, 0, args->p_vout->i_window_width, args->p_vout->i_window_height )];
+        [(VLCMinimalVoutWindow *)args->container makeKeyAndOrderFront: nil];
+    }
     oglview = [[VLCOpenGLVoutView alloc] initWithVout: args->p_vout container: args->container];
 
-    args->p_vout->p_sys->o_glview = [oglview autorelease];
-
+    args->p_vout->p_sys->o_glview = oglview;
     [args->container addVoutSubview: oglview];
+
+    [pool release];
 }
 
 - (void)dealloc
 {
-    [objectLock dealloc]; 
+    [objectLock dealloc];
     [super dealloc];
 }
 
@@ -365,5 +374,9 @@ void cocoaglvoutviewUnlock( vout_thread_t * p_vout )
     CGLUnlockContext([[p_vout->p_sys->o_glview openGLContext] CGLContextObj]);
 }
 
+- (BOOL)mouseDownCanMoveWindow
+{
+    return YES;
+}
 @end