]> git.sesse.net Git - vlc/commitdiff
Limit mouse-x and mouse-y in sdl video_output module.\nSame than [24031] but for sdl
authorRémi Duraffort <ivoire@videolan.org>
Wed, 2 Jan 2008 13:30:44 +0000 (13:30 +0000)
committerRémi Duraffort <ivoire@videolan.org>
Wed, 2 Jan 2008 13:30:44 +0000 (13:30 +0000)
modules/video_output/sdl.c

index 86a9144ed5036883fc93c63b5436b84eece33baf..ff61d1d6443d4d725d74e4aee91422e921566e07 100644 (file)
@@ -376,11 +376,30 @@ static int Manage( vout_thread_t *p_vout )
                                p_vout->p_sys->i_height,
                                &i_x, &i_y, &i_width, &i_height );
 
-            val.i_int = ( event.motion.x - i_x )
-                         * p_vout->render.i_width / i_width;
+            /* Compute the x coordinate and check if the value is
+               in [0,p_vout->fmt_in.i_visible_width] */
+            val.i_int = ( event.motion.x - i_x ) *
+                        p_vout->fmt_in.i_visible_width / i_width +
+                        p_vout->fmt_in.i_x_offset;
+
+            if( (int)(event.motion.x - i_x) < 0 )
+                val.i_int = 0;
+            else if( (unsigned int)val.i_int > p_vout->fmt_in.i_visible_width )
+                val.i_int = p_vout->fmt_in.i_visible_width;
+
             var_Set( p_vout, "mouse-x", val );
-            val.i_int = ( event.motion.y - i_y )
-                         * p_vout->render.i_height / i_height;
+
+            /* compute the y coordinate and check if the value is
+               in [0,p_vout->fmt_in.i_visible_height] */
+            val.i_int = ( event.motion.y - i_y ) *
+                        p_vout->fmt_in.i_visible_height / i_height +
+                        p_vout->fmt_in.i_y_offset;
+
+            if( (int)(event.motion.y - i_y) < 0 )
+                val.i_int = 0;
+            else if( (unsigned int)val.i_int > p_vout->fmt_in.i_visible_height )
+                val.i_int = p_vout->fmt_in.i_visible_height;
+
             var_Set( p_vout, "mouse-y", val );
 
             val.b_bool = VLC_TRUE;