]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/vout.m
Make mouse-moved and mouse-clicked coordinates, remove mouse-x and -y
[vlc] / modules / gui / macosx / vout.m
index 94548d3e40488c013a3983217762d504a015a3fc..554b90a2e99821c0511de637f3815972d4e442ba 100644 (file)
@@ -30,7 +30,6 @@
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <errno.h>                                                 /* ENOMEM */
 #include <stdlib.h>                                                /* free() */
 #include <string.h>
 
@@ -44,7 +43,6 @@
 /* SystemUIMode */
 #import <Carbon/Carbon.h>
 
-#include <vlc_keys.h>
 
 #include "intf.h"
 #include "fspanel.h"
@@ -52,6 +50,9 @@
 #import "controls.h"
 #import "embeddedwindow.h"
 
+#include <vlc_common.h>
+#include <vlc_keys.h>
+
 /*****************************************************************************
  * DeviceCallback: Callback triggered when the video-device variable is changed
  *****************************************************************************/
@@ -290,7 +291,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 
     if( !p_vout ) return;
 
-    p_input = vlc_object_find( p_vout, VLC_OBJECT_INPUT, FIND_PARENT );
+    p_input = getInput();
 
     if( !p_input ) return;
 
@@ -434,9 +435,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 {
     vlc_value_t val;
     if( !p_real_vout ) return;
-    var_Get( p_real_vout, "fullscreen", &val );
-    val.b_bool = !val.b_bool;
-    var_Set( p_real_vout, "fullscreen", val );
+    var_ToggleBool( p_real_vout, "fullscreen" );
 }
 
 - (BOOL)isFullscreen
@@ -581,7 +580,10 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 
     if( p_vout && [o_event type] == NSLeftMouseUp )
     {
-        var_SetBool( p_vout, "mouse-clicked", true );
+        int x, y;
+
+        var_GetCoords( p_vout, "mouse-moved", &x, &y );
+        var_SetCoords( p_vout, "mouse-clicked", x, y );
 
         var_Get( p_vout, "mouse-button-down", &val );
         val.i_int &= ~1;
@@ -647,31 +649,24 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 
         if( b_inside )
         {
-            vlc_value_t val;
+            int x, y;
             unsigned int i_width, i_height, i_x, i_y;
 
             vout_PlacePicture( p_vout, (unsigned int)s_rect.size.width,
                                        (unsigned int)s_rect.size.height,
                                        &i_x, &i_y, &i_width, &i_height );
 
-            val.i_int = ( ((int)ml.x) - i_x ) *
-                        p_vout->render.i_width / i_width;
-            var_Set( p_vout, "mouse-x", val );
-
+            x = (((int)ml.x) - i_x) * p_vout->render.i_width / i_width;
             if( [[o_view className] isEqualToString: @"VLCGLView"] )
             {
-                val.i_int = ( ((int)(s_rect.size.height - ml.y)) - i_y ) *
+                y = (((int)(s_rect.size.height - ml.y)) - i_y) *
                             p_vout->render.i_height / i_height;
             }
             else
             {
-                val.i_int = ( ((int)ml.y) - i_y ) *
-                            p_vout->render.i_height / i_height;
+                y = (((int)ml.y) - i_y) * p_vout->render.i_height / i_height;
             }
-            var_Set( p_vout, "mouse-y", val );
-
-            val.b_bool = true;
-            var_Set( p_vout, "mouse-moved", val );
+            var_SetCoords( p_vout, "mouse-moved", x, y );
         }
         if( [self isFullscreen] )
             [[[[VLCMain sharedInstance] controls] fspanel] fadeIn];
@@ -772,17 +767,15 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 - (void)enterFullscreen
 {
     /* Save the settings for next playing item */
-    playlist_t * p_playlist = pl_Hold( p_real_vout );
+    playlist_t * p_playlist = pl_Get( p_real_vout );
     var_SetBool( p_playlist, "fullscreen", true );
-    pl_Release( p_real_vout );
 }
 
 - (void)leaveFullscreen
 {
     /* Save the settings for next playing item */
-    playlist_t * p_playlist = pl_Hold( p_real_vout );
+    playlist_t * p_playlist = pl_Get( p_real_vout );
     var_SetBool( p_playlist, "fullscreen", false );
-    pl_Release( p_real_vout );
 }
 
 @end
@@ -969,7 +962,8 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
         if ([o_window isVisible] && (![o_window isFullscreen]))
             [o_window makeKeyAndOrderFront: self];
 
-        [self scaleWindowWithFactor: 1.0 animate: [o_window isVisible] && (![o_window isFullscreen])];
+        if ( [self window] != o_embeddedwindow )
+            [self scaleWindowWithFactor: 1.0 animate: [o_window isVisible] && (![o_window isFullscreen])];
 
         [o_embeddedwindow setVideoRatio:[self voutSizeForFactor:1.0]];