]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/vout.m
OS X intf work
[vlc] / modules / gui / macosx / vout.m
index e48acd7aa2513373d46eb4b3124b19413cc13855..484f8cb63a0b328e60a6c6432e9aea98656aa084 100644 (file)
     [self setReleasedWhenClosed: YES];
 
     p_vout = _p_vout;
+
+    /* p_real_vout: the vout we have to use to check for video-on-top
+       and a few other things. If we are the QuickTime output, it's us.
+       It we are the OpenGL provider, it is our parent. */
+    if( p_vout->i_object_type == VLC_OBJECT_OPENGL )
+    {
+        p_real_vout = (vout_thread_t *) p_vout->p_parent;
+    }
+    else
+    {
+        p_real_vout = p_vout;
+    }
+
     p_fullscreen_state = NULL;
     i_time_mouse_last_moved = mdate();
 
     NSScreen * o_screen;
     vlc_bool_t b_main_screen;
 
+    var_Create( p_vout, "macosx-vdev", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
+    var_Create( p_vout, "macosx-fill", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
+    var_Create( p_vout, "macosx-stretch", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
+    var_Create( p_vout, "macosx-opaqueness", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );
+
+    /* Setup the menuitem for the multiple displays. Read the vlc preference (macosx-vdev) for the primary display */
+    NSArray * o_screens = [NSScreen screens];
+    if( [o_screens count] > 0 && var_Type( p_real_vout, "video-device" ) == 0 )
+    {
+        int i = 1;
+        vlc_value_t val, val2, text;
+        NSScreen * o_screen;
+
+        var_Get( p_real_vout, "macosx-vdev", &val );
+
+        var_Create( p_real_vout, "video-device", VLC_VAR_INTEGER |
+                                            VLC_VAR_HASCHOICE );
+        text.psz_string = _("Video device");
+        var_Change( p_real_vout, "video-device", VLC_VAR_SETTEXT, &text, NULL );
+
+        NSEnumerator * o_enumerator = [o_screens objectEnumerator];
+
+        while( (o_screen = [o_enumerator nextObject]) != NULL )
+        {
+            char psz_temp[255];
+            NSRect s_rect = [o_screen frame];
+
+            snprintf( psz_temp, sizeof(psz_temp)/sizeof(psz_temp[0])-1,
+                      "%s %d (%dx%d)", _("Screen"), i,
+                      (int)s_rect.size.width, (int)s_rect.size.height );
+
+            text.psz_string = psz_temp;
+            val2.i_int = i;
+            var_Change( p_real_vout, "video-device",
+                        VLC_VAR_ADDCHOICE, &val2, &text );
+
+            if( ( i - 1 ) == val.i_int )
+            {
+                var_Set( p_real_vout, "video-device", val2 );
+            }
+            i++;
+        }
+
+        var_AddCallback( p_real_vout, "video-device", vout_VarCallback,
+                         NULL );
+
+        val2.b_bool = VLC_TRUE;
+        var_Set( p_real_vout, "intf-change", val2 );
+    }
+
     /* Find out on which screen to open the window */
-    int i_device = var_GetInteger( p_vout, "video-device" );
+    int i_device = var_GetInteger( p_real_vout, "video-device" );
     if( i_device < 0 )
     {
          /* No preference specified. Use the main screen */
         {
             i_device--;
             o_screen = [o_screens objectAtIndex: i_device];
-            var_SetInteger( p_vout, "macosx-vdev", i_device );
+            var_SetInteger( p_real_vout, "macosx-vdev", i_device );
             b_main_screen = ( i_device == 0 );
         }
     }
         [self initWithContentRect: screen_rect
               styleMask: NSBorderlessWindowMask
               backing: NSBackingStoreBuffered
-              defer: NO screen: o_screen];
+              defer: YES screen: o_screen];
 
         if( b_main_screen )
         {
         [self initWithContentRect: s_rect
               styleMask: i_stylemask
               backing: NSBackingStoreBuffered
-              defer: NO screen: o_screen];
+              defer: YES screen: o_screen];
 
         [self setAlphaValue: var_GetFloat( p_vout, "macosx-opaqueness" )];
 
-        if( var_GetBool( p_vout, "video-on-top" ) )
+        if( var_GetBool( p_real_vout, "video-on-top" ) )
         {
             [self setLevel: NSStatusWindowLevel];
         }
     [super close];
 }
 
-- (void)setOnTop:(bool)b_on_top
+- (void)setOnTop:(BOOL)b_on_top
 {
     if( b_on_top )
     {
     }
 }
 
-- (void)hideMouse:(bool)b_hide
+- (void)hideMouse:(BOOL)b_hide
 {
     BOOL b_inside;
     NSPoint ml;
 - (void)toggleFullscreen
 {
     vlc_value_t val;
-    val.b_bool = !p_vout->b_fullscreen;
-    var_Set( p_vout, "fullscreen", val );
+    val.b_bool = !p_real_vout->b_fullscreen;
+    var_Set( p_real_vout, "fullscreen", val );
 }
 
 - (BOOL)isFullscreen
     return( p_vout->b_fullscreen );
 }
 
+- (void)snapshot
+{
+    vout_Control( p_vout, VOUT_SNAPSHOT );
+}
+
 - (BOOL)canBecomeKeyWindow
 {
     return YES;
 
     vlc_mutex_lock( &p_playlist->object_lock );
     o_title = [NSMutableString stringWithUTF8String: 
-        p_playlist->pp_items[p_playlist->i_index]->input.psz_uri]; 
+        p_playlist->status.p_item->input.psz_uri]; 
     vlc_mutex_unlock( &p_playlist->object_lock );
-
     vlc_object_release( p_playlist );
 
     if( o_title != nil )