]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/vout.m
* switched the middle arrow buttons from faster/slower to backward/forward to reflect...
[vlc] / modules / gui / macosx / vout.m
index 9822cf27d10ca974b818d7c65bc2b4409c0e9942..3e7e873d05cd4d5ebde0a816ce68fb713a1426af 100644 (file)
@@ -40,6 +40,7 @@
 #include <vlc_keys.h>
 
 #include "intf.h"
+#include "fspanel.h"
 #include "vout.h"
 #import "controls.h"
 
@@ -53,8 +54,8 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
 
     msg_Dbg( p_vout, "set %d", new_val.i_int );
-    var_Create( p_vout->p_vlc, "video-device", VLC_VAR_INTEGER );
-    var_Set( p_vout->p_vlc, "video-device", new_val );
+    var_Create( p_vout->p_libvlc, "video-device", VLC_VAR_INTEGER );
+    var_Set( p_vout->p_libvlc, "video-device", new_val );
 
     val.b_bool = VLC_TRUE;
     var_Set( p_vout, "intf-change", val );
@@ -173,13 +174,13 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
     p_real_vout = [VLCVoutView getRealVout: p_vout];
 
     /* Get the pref value when this is the first time, otherwise retrieve the device from the top level video-device var */
-    if( var_Type( p_real_vout->p_vlc, "video-device" ) == 0 )
+    if( var_Type( p_real_vout->p_libvlc, "video-device" ) == 0 )
     {
         i_device = var_GetInteger( p_vout, "macosx-vdev" );
     }
     else
     {
-        i_device = var_GetInteger( p_real_vout->p_vlc, "video-device" );
+        i_device = var_GetInteger( p_real_vout->p_libvlc, "video-device" );
     }
 
     /* Setup the menuitem for the multiple displays. */
@@ -245,12 +246,14 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 
 - (void)closeVout
 {
+    [[[[VLCMain sharedInstance] getControls] getFSPanel] fadeOut];
+
     [o_view removeFromSuperview];
     o_view = nil;
     p_vout = NULL;
     s_frame = nil;
     o_window = nil;
-    p_real_vout = NULL;
+    p_real_vout = NULL;            
 }
 
 - (void)updateTitle
@@ -270,17 +273,19 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
         return;
     }
 
-    if( p_input->input.p_item->psz_name != NULL )
+    if( input_GetItem(p_input)->psz_name != NULL )
         o_title = [NSMutableString stringWithUTF8String:
-            p_input->input.p_item->psz_name];
-    if( p_input->input.p_item->psz_uri != NULL )
+            input_GetItem(p_input)->psz_name];
+    if( input_GetItem(p_input)->psz_uri != NULL )
         o_mrl = [NSMutableString stringWithUTF8String:
-            p_input->input.p_item->psz_uri];
+            input_GetItem(p_input)->psz_uri];
     if( o_title == nil )
         o_title = o_mrl;
 
     if( o_mrl != nil )
     {
+        /* FIXME once psz_access is exported, since that syntax is no longer valid */
+#if 0
         if( p_input->input.p_access && !strcmp( p_input->input.p_access->p_module->psz_shortname, "File" ) )
         {
             NSRange prefix_range = [o_mrl rangeOfString: @"file:"];
@@ -288,6 +293,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
                 [o_mrl deleteCharactersInRange: prefix_range];
             [o_window setRepresentedFilename: o_mrl];
         }
+#endif
         [o_window setTitle: o_title];
     }
     else
@@ -349,7 +355,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
         new_frame.origin.x = topleftscreen.x;
         new_frame.origin.y = topleftscreen.y - new_frame.size.height;
 
-        [o_window setFrame: new_frame display: YES];
+        [o_window setFrame: new_frame display: NO];
 
         p_vout->i_changes |= VOUT_SIZE_CHANGE;
     }
@@ -378,6 +384,10 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
     var_Get( p_real_vout, "fullscreen", &val );
     val.b_bool = !val.b_bool;
     var_Set( p_real_vout, "fullscreen", val );
+    if( [self isFullscreen] )
+        [[[[VLCMain sharedInstance] getControls] getFSPanel] orderFront: self];
+    else
+        [[[[VLCMain sharedInstance] getControls] getFSPanel] orderOut: self];
 }
 
 - (BOOL)isFullscreen
@@ -437,12 +447,12 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
         {
             vlc_value_t val;
             val.i_int = config_GetInt( p_vout, "key-play-pause" );
-            var_Set( p_vout->p_vlc, "key-pressed", val );
+            var_Set( p_vout->p_libvlc, "key-pressed", val );
         }
         else
         {
             val.i_int |= CocoaKeyToVLC( key );
-            var_Set( p_vout->p_vlc, "key-pressed", val );
+            var_Set( p_vout->p_libvlc, "key-pressed", val );
         }
     }
     else
@@ -457,151 +467,102 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 
     if( p_vout )
     {
-        switch( [o_event type] )
+        if( ( [o_event type] == NSLeftMouseDown ) &&
+          ( ! ( [o_event modifierFlags] &  NSControlKeyMask ) ) )
         {
-            case NSLeftMouseDown:
+            if( [o_event clickCount] <= 1 )
             {
-                if( [o_event clickCount] <= 1 )
-                {
-                    /* single clicking */
-                    var_Get( p_vout, "mouse-button-down", &val );
-                    val.i_int |= 1;
-                    var_Set( p_vout, "mouse-button-down", val );
-                }
-                else
-                {
-                    /* multiple clicking */
-                    [self toggleFullscreen];
-                }
+                /* single clicking */
+                var_Get( p_vout, "mouse-button-down", &val );
+                val.i_int |= 1;
+                var_Set( p_vout, "mouse-button-down", val );
             }
-            break;
-            case NSRightMouseDown:
+            else
             {
-                msg_Dbg( p_vout, "received NSRightMouseDown (generic method)" );
-                [NSMenu popUpContextMenu: [[VLCMain sharedInstance] getVoutMenu] withEvent: o_event forView: [[[VLCMain sharedInstance] getControls] getVoutView]];
+                /* multiple clicking */
+                [self toggleFullscreen];
             }
-            break;
-
-            default:
-                [super mouseDown: o_event];
-            break;
+        }
+        else if( ( [o_event type] == NSRightMouseDown ) ||
+               ( ( [o_event type] == NSLeftMouseDown ) &&
+                 ( [o_event modifierFlags] &  NSControlKeyMask ) ) )
+        {
+            msg_Dbg( p_vout, "received NSRightMouseDown (generic method) or Ctrl clic" );
+            [NSMenu popUpContextMenu: [[VLCMain sharedInstance] getVoutMenu] withEvent: o_event forView: [[[VLCMain sharedInstance] getControls] getVoutView]];
         }
     }
+
+    [super mouseDown: o_event];
 }
 
 - (void)otherMouseDown:(NSEvent *)o_event
 {
     vlc_value_t val;
 
-    if( p_vout )
+    if( p_vout && [o_event type] == NSOtherMouseDown )
     {
-        switch( [o_event type] )
-        {
-            case NSOtherMouseDown:
-            {
-                var_Get( p_vout, "mouse-button-down", &val );
-                val.i_int |= 2;
-                var_Set( p_vout, "mouse-button-down", val );
-            }
-            break;
-
-            default:
-                [super mouseDown: o_event];
-            break;
-        }
+        var_Get( p_vout, "mouse-button-down", &val );
+        val.i_int |= 2;
+        var_Set( p_vout, "mouse-button-down", val );
     }
+
+    [super mouseDown: o_event];
 }
 
 - (void)rightMouseDown:(NSEvent *)o_event
 {
-    if( p_vout )
+    if( p_vout && [o_event type] == NSRightMouseDown )
     {
-        switch( [o_event type] )
-        {
-            case NSRightMouseDown:
-            {
-                msg_Dbg( p_vout, "received NSRightMouseDown (specific method)" );
-                [NSMenu popUpContextMenu: [[VLCMain sharedInstance] getVoutMenu] withEvent: o_event forView: [[[VLCMain sharedInstance] getControls] getVoutView]];
-            }
-            break;
-
-            default:
-                [super mouseDown: o_event];
-            break;
-        }
+        msg_Dbg( p_vout, "received NSRightMouseDown (specific method)" );
+        [NSMenu popUpContextMenu: [[VLCMain sharedInstance] getVoutMenu] withEvent: o_event forView: [[[VLCMain sharedInstance] getControls] getVoutView]];
     }
+
+    [super mouseDown: o_event];
 }
 
 - (void)mouseUp:(NSEvent *)o_event
 {
     vlc_value_t val;
 
-    if( p_vout )
+    if( p_vout && [o_event type] == NSLeftMouseUp )
     {
-        switch( [o_event type] )
-        {
-            case NSLeftMouseUp:
-            {
-                vlc_value_t b_val;
-                b_val.b_bool = VLC_TRUE;
-                var_Set( p_vout, "mouse-clicked", b_val );
+        vlc_value_t b_val;
+        b_val.b_bool = VLC_TRUE;
+        var_Set( p_vout, "mouse-clicked", b_val );
 
-                var_Get( p_vout, "mouse-button-down", &val );
-                val.i_int &= ~1;
-                var_Set( p_vout, "mouse-button-down", val );
-            }
-            break;
-
-            default:
-                [super mouseUp: o_event];
-            break;
-        }
+        var_Get( p_vout, "mouse-button-down", &val );
+        val.i_int &= ~1;
+        var_Set( p_vout, "mouse-button-down", val );
     }
+
+    [super mouseUp: o_event];
 }
 
 - (void)otherMouseUp:(NSEvent *)o_event
 {
     vlc_value_t val;
 
-    if( p_vout )
+    if( p_vout && [o_event type] == NSOtherMouseUp )
     {
-        switch( [o_event type] )
-        {
-            case NSOtherMouseUp:
-            {
-                var_Get( p_vout, "mouse-button-down", &val );
-                val.i_int &= ~2;
-                var_Set( p_vout, "mouse-button-down", val );
-            }
-            break;
-
-            default:
-                [super mouseUp: o_event];
-            break;
-        }
+        var_Get( p_vout, "mouse-button-down", &val );
+        val.i_int &= ~2;
+        var_Set( p_vout, "mouse-button-down", val );
     }
+
+    [super mouseUp: o_event];
 }
 
 - (void)rightMouseUp:(NSEvent *)o_event
 {
-    if( p_vout )
+    if( p_vout && [o_event type] == NSRightMouseUp )
     {
-        switch( [o_event type] )
-        {
-            case NSRightMouseUp:
-            {
-                /* FIXME: this is the appropriate place, but we can't receive
-                 * NSRightMouseDown some how */
-                msg_Dbg( p_vout, "received NSRightMouseUp" ); 
-                [NSMenu popUpContextMenu: [[VLCMain sharedInstance] getVoutMenu] withEvent: o_event forView: [[[VLCMain sharedInstance] getControls] getVoutView]];
-            }
-            break;
-
-            default:
-                [super mouseUp: o_event];
-            break;
-        }
+        /* FIXME: this isn't the appropriate place, but we can't receive
+         * NSRightMouseDown some how */
+        msg_Dbg( p_vout, "received NSRightMouseUp" ); 
+        [NSMenu popUpContextMenu: [[VLCMain sharedInstance] getVoutMenu] withEvent: o_event forView: [[[VLCMain sharedInstance] getControls] getVoutView]];
     }
+
+    [super mouseUp: o_event];
 }
 
 - (void)mouseDragged:(NSEvent *)o_event
@@ -659,7 +620,10 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
             val.b_bool = VLC_TRUE;
             var_Set( p_vout, "mouse-moved", val );
         }
+        if( [self isFullscreen] )
+            [[[[VLCMain sharedInstance] getControls] getFSPanel] fadeIn];
     }
+
     [super mouseMoved: o_event];
 }
 
@@ -704,12 +668,10 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
     vlc_value_t value_drawable;
     int i_timeout;
     id o_return = nil;
-    vout_thread_t * p_real_vout = [VLCVoutView getRealVout: p_vout];
 
-    var_Get( p_vout->p_vlc, "drawable", &value_drawable );
+    var_Get( p_vout->p_libvlc, "drawable", &value_drawable );
 
     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 );
     var_Create( p_vout, "macosx-background", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
@@ -741,7 +703,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
         else
         {
             if ( VLCIntf && !(p_vout->b_fullscreen) &&
-                        !(var_GetBool( p_real_vout, "macosx-background" )) &&
+                        !(var_GetBool( p_vout, "macosx-background" )) &&
                         var_GetBool( p_vout, "macosx-embedded") )
             {
                 o_return = [[[VLCMain sharedInstance] getEmbeddedList]
@@ -962,8 +924,9 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
     b_init_ok = VLC_FALSE;
 
     p_real_vout = [VLCVoutView getRealVout: p_vout];
-    i_device = var_GetInteger( p_real_vout->p_vlc, "video-device" );
-    b_black = var_GetBool( p_real_vout->p_vlc, "macosx-black" );
+    i_device = var_GetInteger( p_real_vout->p_libvlc, "video-device" );
+    b_black = var_GetBool( p_vout, "macosx-black" );
+    b_embedded = var_GetBool( p_vout, "macosx-embedded" );
 
     /* Find out on which screen to open the window */
     if( i_device <= 0 || i_device > (int)[o_screens count] )
@@ -987,13 +950,20 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
         NSRect screen_rect = [o_screen frame];
         screen_rect.origin.x = screen_rect.origin.y = 0;
 
+        /* move the FSPanel to front in case that it is currently shown
+         * this won't and is not supposed to work when it's fading right now */
+        if( [[[[VLCMain sharedInstance] getControls] getFSPanel] isDisplayed] )
+            [[[[VLCMain sharedInstance] getControls] getFSPanel] orderFront: self];
+        
+        /* tell the fspanel to move itself to front next time it's triggered */
+        [[[[VLCMain sharedInstance] getControls] getFSPanel] setVoutWasUpdated: i_device];
+
         /* Creates a window with size: screen_rect on o_screen */
         [self initWithContentRect: screen_rect
               styleMask: NSBorderlessWindowMask
               backing: NSBackingStoreBuffered
               defer: YES screen: o_screen];
-
-        if( var_GetBool( p_real_vout, "macosx-black" ) )
+        
         if( b_black == VLC_TRUE )
         {
             CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &token);
@@ -1042,7 +1012,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
             CGReleaseDisplayFadeReservation( token);
         }
     }
-    else if( var_GetBool( p_real_vout, "macosx-background" ) )
+    else if( var_GetBool( p_vout, "macosx-background" ) )
     {
         NSRect screen_rect = [o_screen frame];
         screen_rect.origin.x = screen_rect.origin.y = 0;
@@ -1106,7 +1076,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
     [o_view closeVout];
 }
 
-- (void) closeWindow
+- (void)closeWindow
 {
     /* XXX waitUntilDone = NO to avoid a possible deadlock when hitting
        Command-Q */
@@ -1115,7 +1085,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
         withObject: NULL waitUntilDone: NO];
 }
 
-- (id) closeReal: (id) sender
+- (id)closeReal:(id)sender
 {
     if( b_black == VLC_TRUE )
     {
@@ -1127,6 +1097,10 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
     }
     SetSystemUIMode( kUIModeNormal, 0);
     [super close];
+    /* this does only work in embedded mode */
+    if( b_embedded == VLC_TRUE )
+        [[[[VLCMain sharedInstance] getControls] getFSPanel] orderOut: self];
+
     return NULL;
 }