changeset 35077:c9d302e5e4be

Fix translation of mouse coordinates when panscan is used.
author reimar
date Wed, 12 Sep 2012 21:03:45 +0000
parents 77a90f0b02b1
children d698d80bb438
files command.c
diffstat 1 files changed, 17 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/command.c	Wed Sep 12 20:48:08 2012 +0000
+++ b/command.c	Wed Sep 12 21:03:45 2012 +0000
@@ -38,6 +38,7 @@
 #include "libmpcodecs/vf.h"
 #include "libmpcodecs/vd.h"
 #include "libvo/video_out.h"
+#include "libvo/aspect.h"
 #include "sub/font_load.h"
 #include "playtree.h"
 #include "libao2/audio_out.h"
@@ -75,20 +76,23 @@
 static void rescale_input_coordinates(int ix, int iy, double *dx, double *dy)
 {
     //remove the borders, if any, and rescale to the range [0,1],[0,1]
-    if (vo_fs) {                //we are in full-screen mode
-        if (vo_screenwidth > vo_dwidth) //there are borders along the x axis
-            ix -= (vo_screenwidth - vo_dwidth) / 2;
-        if (vo_screenheight > vo_dheight)       //there are borders along the y axis (usual way)
-            iy -= (vo_screenheight - vo_dheight) / 2;
-
-        if (ix < 0 || ix > vo_dwidth || iy < 0 || iy > vo_dheight) {
-            *dx = *dy = -1.0;
-            return;
-        }                       //we are on one of the borders
+    int w = vo_dwidth, h = vo_dheight;
+    if (aspect_scaling()) {
+        aspect(&w, &h, A_WINZOOM);
+        panscan_calc_windowed();
+        w += vo_panscan_x;
+        h += vo_panscan_y;
+        ix -= (vo_dwidth  - w) / 2;
+        iy -= (vo_dheight - h) / 2;
     }
-
-    *dx = (double) ix / (double) vo_dwidth;
-    *dy = (double) iy / (double) vo_dheight;
+    if (ix < 0 || ix > w || iy < 0 || iy > h) {
+        // ignore movements outside movie area
+        *dx = *dy = -1.0;
+        return;
+    }
+
+    *dx = (double) ix / (double) w;
+    *dy = (double) iy / (double) h;
 
     mp_msg(MSGT_CPLAYER, MSGL_V,
            "\r\nrescaled coordinates: %.3f, %.3f, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",