]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/voutgl.m
vougl.m: cosmetics
[vlc] / modules / gui / macosx / voutgl.m
index 58817becf6029fbc791068fa260586fd17ba35dc..0704953281073fb07461192b4e5db53618b0bc5c 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * voutgl.m: MacOS X OpenGL provider
  *****************************************************************************
- * Copyright (C) 2001-2004, 2007 the VideoLAN team
+ * Copyright (C) 2001-2004, 2007-2009 the VideoLAN team
  * $Id$
  *
  * Authors: Colin Delacroix <colin@zoy.org>
@@ -52,7 +52,7 @@
     vout_thread_t * p_vout;
 }
 
-+ (void)resetVout: (vout_thread_t *) p_vout;
++ (void)resetVout: (NSValue *) voutValue;
 - (id) initWithVout: (vout_thread_t *) p_vout;
 @end
 
@@ -61,18 +61,18 @@ struct vout_sys_t
     NSAutoreleasePool * o_pool;
     VLCGLView         * o_glview;
     VLCVoutView       * o_vout_view;
-    bool          b_saved_frame;
+    bool                b_saved_frame;
     NSRect              s_frame;
-    bool          b_got_frame;
+    bool                b_got_frame;
     /* Mozilla plugin-related variables */
-    bool          b_embedded;
+    bool                b_embedded;
     AGLContext          agl_ctx;
     AGLDrawable         agl_drawable;
     int                 i_offx, i_offy;
     int                 i_width, i_height;
     WindowRef           theWindow;
     WindowGroupRef      winGroup;
-    bool          b_clipped_out;
+    bool                b_clipped_out;
     Rect                clipBounds, viewBounds;
 };
 
@@ -104,17 +104,13 @@ int OpenVideoGL  ( vlc_object_t * p_this )
     if( !CGDisplayUsesOpenGLAcceleration( kCGDirectMainDisplay ) )
     {
         msg_Warn( p_vout, "no OpenGL hardware acceleration found. "
-                          "Video display will be slow" );
-        return( 1 );
+                          "Video display might be slow" );
     }
     msg_Dbg( p_vout, "display is Quartz Extreme accelerated" );
 
     p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
     if( p_vout->p_sys == NULL )
-    {
-        msg_Err( p_vout, "out of memory" );
-        return( 1 );
-    }
+        return VLC_ENOMEM;
 
     memset( p_vout->p_sys, 0, sizeof( vout_sys_t ) );
 
@@ -178,7 +174,6 @@ int OpenVideoGL  ( vlc_object_t * p_this )
         [o_pool release];
 
         /* Check to see if initVout: was successfull */
-
         if( !p_vout->p_sys->o_vout_view )
         {
             return VLC_EGENERIC;
@@ -200,11 +195,14 @@ int OpenVideoGL  ( vlc_object_t * p_this )
 void CloseVideoGL ( vlc_object_t * p_this )
 {
     vout_thread_t * p_vout = (vout_thread_t *) p_this;
+
+    msg_Dbg( p_this, "Closing" );
+
     if( p_vout->p_sys->b_embedded )
     {
         aglDestroyContext(p_vout->p_sys->agl_ctx);
     }
-    else if(VLCIntf && !VLCIntf->b_die)
+    else if(VLCIntf && vlc_object_alive (VLCIntf))
     {
         NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
 
@@ -257,7 +255,8 @@ static int Manage( vout_thread_t * p_vout )
         p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
     }
 
-    [p_vout->p_sys->o_vout_view manage];
+    if( p_vout->p_sys->o_vout_view )
+        [p_vout->p_sys->o_vout_view manage];
     return VLC_SUCCESS;
 }
 
@@ -275,10 +274,8 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args )
             [p_vout->p_sys->o_vout_view setOnTop: b_arg];
             return VLC_SUCCESS;
 
-        case VOUT_CLOSE:
-        case VOUT_REPARENT:
         default:
-            return vout_vaControlDefault( p_vout, i_query, args );
+            return VLC_EGENERIC;
     }
 }
 
@@ -316,13 +313,16 @@ static void Unlock( vout_thread_t * p_vout )
     [p_vout->p_sys->o_glview autorelease];
 
     /* Spawn the window */
-    p_vout->p_sys->o_vout_view = [VLCVoutView getVoutView: p_vout
-                        subView: p_vout->p_sys->o_glview frame: nil];
+    id old_vout = p_vout->p_sys->o_vout_view;
+    p_vout->p_sys->o_vout_view = [[VLCVoutView voutView: p_vout
+                                                subView: p_vout->p_sys->o_glview frame: nil] retain];
+    [old_vout release];
 }
 
 /* This function will reset the o_vout_view. It's useful to go fullscreen. */
-+ (void)resetVout:(vout_thread_t *) p_vout
++ (void)resetVout:(NSValue *) voutValue
 {
+    vout_thread_t * p_vout = [voutValue pointerValue];
     if( p_vout->b_fullscreen )
     {
         /* Save window size and position */
@@ -341,15 +341,18 @@ static void Unlock( vout_thread_t * p_vout )
  
     if( p_vout->p_sys->b_saved_frame )
     {
-        p_vout->p_sys->o_vout_view = [VLCVoutView getVoutView: p_vout
-                                                      subView: o_glview
-                                                        frame: &p_vout->p_sys->s_frame];
+        id old_vout = p_vout->p_sys->o_vout_view;
+        p_vout->p_sys->o_vout_view = [[VLCVoutView voutView: p_vout
+                                                    subView: o_glview
+                                                      frame: &p_vout->p_sys->s_frame] retain];
+        [old_vout release];
     }
     else
     {
-        p_vout->p_sys->o_vout_view = [VLCVoutView getVoutView: p_vout
-                                                      subView: o_glview frame: nil];
+        id old_vout = p_vout->p_sys->o_vout_view;
+        p_vout->p_sys->o_vout_view = [[VLCVoutView voutView: p_vout
+                                                    subView: o_glview frame: nil] retain];
+        [old_vout release];
     }
 #undef o_glview
 }
@@ -400,6 +403,11 @@ static void Unlock( vout_thread_t * p_vout )
     return self;
 }
 
+- (BOOL)mouseDownCanMoveWindow
+{
+    return YES;
+}
+
 - (void) reshape
 {
     int x, y;
@@ -770,19 +778,8 @@ static int aglControl( vout_thread_t *p_vout, int i_query, va_list args )
             return VLC_SUCCESS;
         }
 
-        case VOUT_REPARENT:
-        {
-            AGLDrawable drawable = (AGLDrawable)va_arg( args, int);
-            if( !p_vout->b_fullscreen && drawable != p_vout->p_sys->agl_drawable )
-            {
-                p_vout->p_sys->agl_drawable = drawable;
-                aglSetDrawable(p_vout->p_sys->agl_ctx, drawable);
-            }
-            return VLC_SUCCESS;
-        }
-
         default:
-            return vout_vaControlDefault( p_vout, i_query, args );
+            return VLC_EGENERIC;
     }
 }
 
@@ -945,8 +942,7 @@ static pascal OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, Event
                         {
                             vlc_value_t val;
 
-                            val.b_bool = true;
-                            var_Set( p_vout, "mouse-clicked", val );
+                            var_SetBool( p_vout, "mouse-clicked", true );
 
                             var_Get( p_vout, "mouse-button-down", &val );
                             val.i_int &= ~1;