[Android] Fix touch offset calculation

Felix Abecassis git at videolan.org
Wed May 14 19:55:24 CEST 2014


vlc-ports/android | branch: master | Felix Abecassis <felix.abecassis at gmail.com> | Wed May 14 19:51:56 2014 +0200| [a881b6832dcfdfeace8e182df088eb05305a7934] | committer: Jean-Baptiste Kempf

Fix touch offset calculation

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=a881b6832dcfdfeace8e182df088eb05305a7934
---

 vlc-android/jni/vout.c                                       |    2 +-
 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java  |   10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/vlc-android/jni/vout.c b/vlc-android/jni/vout.c
index 06d72ae..2d7d3ce 100644
--- a/vlc-android/jni/vout.c
+++ b/vlc-android/jni/vout.c
@@ -177,7 +177,7 @@ void Java_org_videolan_libvlc_LibVLC_sendMouseEvent(JNIEnv* env, jobject thiz, j
     mouse_button = button;
 }
 
-void jni_getMouseCoordinates( int *button, int *x, int *y)
+void jni_getMouseCoordinates(int *button, int *x, int *y)
 {
     *x = mouse_x;
     *y = mouse_y;
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 6822b3d..d420193 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -1149,11 +1149,11 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
             // Seek
             mTouchX = event.getRawX();
             // Click DVD menus
-            int offsetX = (screen.widthPixels - mSurface.getWidth()) / 2;
-            int offsetY = (screen.heightPixels - mSurface.getHeight()) / 2;
-            LibVLC.sendMouseEvent( 0,
-                    ((int)mTouchX - offsetX) * mVideoWidth / mSurface.getWidth(),
-                    ((int)mTouchY - offsetY) * mVideoHeight / mSurface.getHeight());
+            int[] offset = new int[2];
+            mSurface.getLocationOnScreen(offset);
+            LibVLC.sendMouseEvent(0,
+                    Math.round((mTouchX - offset[0]) * mVideoWidth / mSurface.getWidth()),
+                    Math.round((mTouchY - offset[1]) * mVideoHeight / mSurface.getHeight()));
             break;
 
         case MotionEvent.ACTION_MOVE:



More information about the Android mailing list