]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/voutgl.m
macosx: Save a reference to the view in the voutgl.
[vlc] / modules / gui / macosx / voutgl.m
index cfcdaf0393f5e6a8bc42e074e67247cde3baee97..6b9ba857f11e13e31de211476d730da801393a90 100644 (file)
@@ -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
 
@@ -200,6 +200,9 @@ 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);
@@ -257,7 +260,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;
 }
 
@@ -316,13 +320,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 getVoutView: 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 +348,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
+        id old_vout = p_vout->p_sys->o_vout_view;
+        p_vout->p_sys->o_vout_view = [[VLCVoutView getVoutView: p_vout
                                                       subView: o_glview
-                                                        frame: &p_vout->p_sys->s_frame];
+                                                        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 getVoutView: p_vout
+                                                      subView: o_glview frame: nil] retain];
+        [old_vout release];
     }
 #undef o_glview
 }
@@ -400,6 +410,11 @@ static void Unlock( vout_thread_t * p_vout )
     return self;
 }
 
+- (BOOL)mouseDownCanMoveWindow
+{
+    return YES;
+}
+
 - (void) reshape
 {
     int x, y;