]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/vout.m
* always forward the clicks to OSX's core
[vlc] / modules / gui / macosx / vout.m
index c1fdc381375ad76e63fd381661b9ce14be2e07a3..a3e460cc085327575ff0beb15e64b8d3030a3e4f 100644 (file)
@@ -10,6 +10,7 @@
  *          Derk-Jan Hartman <hartman at videolan dot org>
  *          Eric Petit <titer@m0k.org>
  *          Benjamin Pracht <bigben at videolan dot org>
+ *          Felix K\9fhne <fkuehne 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
@@ -41,7 +42,6 @@
 #include "intf.h"
 #include "vout.h"
 
-
 /*****************************************************************************
  * DeviceCallback: Callback triggered when the video-device variable is changed
  *****************************************************************************/
@@ -456,20 +456,32 @@ 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 )
             {
+                /* single clicking */
                 var_Get( p_vout, "mouse-button-down", &val );
                 val.i_int |= 1;
                 var_Set( p_vout, "mouse-button-down", val );
             }
-            break;
-
-            default:
-                [super mouseDown: o_event];
-            break;
+            else
+            {
+                /* multiple clicking */
+                [self toggleFullscreen];
+            }
+        }
+        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]];
         }
+
+        /* always forward to core as well */
+        [super mouseDown: o_event];
     }
 }
 
@@ -479,43 +491,28 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 
     if( p_vout )
     {
-        switch( [o_event type] )
+        if( [o_event type] == NSOtherMouseDown )
         {
-            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
 {
-    vlc_value_t val;
-
     if( p_vout )
     {
-        switch( [o_event type] )
+        if( [o_event type] == NSRightMouseDown )
         {
-            case NSRightMouseDown:
-            {
-                var_Get( p_vout, "mouse-button-down", &val );
-                val.i_int |= 4;
-                var_Set( p_vout, "mouse-button-down", val );
-            }
-            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];
     }
 }
 
@@ -525,24 +522,18 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 
     if( p_vout )
     {
-        switch( [o_event type] )
+        if( [o_event type] == NSLeftMouseUp )
         {
-            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];
     }
 }
 
@@ -552,43 +543,29 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 
     if( p_vout )
     {
-        switch( [o_event type] )
+        if( [o_event type] == NSOtherMouseUp )
         {
-            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
 {
-    vlc_value_t val;
-
     if( p_vout )
     {
-        switch( [o_event type] )
+        if( [o_event type] == NSRightMouseUp )
         {
-            case NSRightMouseUp:
-            {
-                var_Get( p_vout, "mouse-button-down", &val );
-                val.i_int &= ~4;
-                var_Set( p_vout, "mouse-button-down", val );
-            }
-            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];
     }
 }
 
@@ -772,6 +749,13 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
                                                     frame: s_arg_frame];
     [self updateTitle];
     [view setFrame: [self frame]];
+
+    if( var_GetBool( p_real_vout, "video-on-top" ) )
+    {
+        [o_window setLevel: NSStatusWindowLevel];
+    }
+
+
     [o_window setAcceptsMouseMovedEvents: TRUE];
     return b_return;
 }
@@ -853,6 +837,12 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
         o_window = [self window];
         [o_window makeKeyAndOrderFront: self];
         [o_window setAcceptsMouseMovedEvents: TRUE];
+
+        if( var_GetBool( p_real_vout, "video-on-top" ) )
+        {
+            [o_window setLevel: NSStatusWindowLevel];
+        }
+
         [view setFrameSize: [self frame].size];
     }
     return b_return;
@@ -936,7 +926,6 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 
     b_init_ok = VLC_FALSE;
 
-    p_fullscreen_state = NULL;
     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" );
@@ -1009,8 +998,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
         }
         if( b_menubar_screen )
         {
-            BeginFullScreen( &p_fullscreen_state, NULL, 0, 0,
-                             NULL, NULL, fullScreenAllowEvents );
+            SetSystemUIMode( kUIModeAllHidden, kUIOptionAutoShowMenuBar);
         }
         if( b_black == VLC_TRUE )
         {
@@ -1057,11 +1045,6 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 
         [self setAlphaValue: var_GetFloat( p_vout, "macosx-opaqueness" )];
 
-        if( var_GetBool( p_real_vout, "video-on-top" ) )
-        {
-            [self setLevel: NSStatusWindowLevel];
-        }
-
         if( !s_frame )
         {
             [self center];
@@ -1099,8 +1082,6 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 
 - (id) closeReal: (id) sender
 {
-    if( p_fullscreen_state )
-        EndFullScreen( p_fullscreen_state, 0 );
     if( b_black == VLC_TRUE )
     {
         CGDisplayFadeReservationToken token;
@@ -1109,6 +1090,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
         CGReleaseDisplayFadeReservation( token);
         CGDisplayRestoreColorSyncSettings();
     }
+    SetSystemUIMode( kUIModeNormal, 0);
     [super close];
     return NULL;
 }