[Android] LibVLC: Awindow: don't send same events more than one time

Thomas Guillem git at videolan.org
Mon Nov 28 16:39:09 CET 2016


vlc-android | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Nov 23 11:49:59 2016 +0100| [659994489675b2118e693770cf4c41940cc7aa5e] | committer: Thomas Guillem

LibVLC: Awindow: don't send same events more than one time

> https://code.videolan.org/videolan/vlc-android/commit/659994489675b2118e693770cf4c41940cc7aa5e
---

 libvlc/src/org/videolan/libvlc/AWindow.java | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/libvlc/src/org/videolan/libvlc/AWindow.java b/libvlc/src/org/videolan/libvlc/AWindow.java
index 9d1b263..dbd665f 100644
--- a/libvlc/src/org/videolan/libvlc/AWindow.java
+++ b/libvlc/src/org/videolan/libvlc/AWindow.java
@@ -381,26 +381,23 @@ public class AWindow implements IVLCVout {
     @Override
     public void sendMouseEvent(int action, int button, int x, int y) {
         synchronized (mNativeLock) {
-            if (mCallbackNativeHandle != 0)
+            if (mCallbackNativeHandle != 0 && (mMouseAction != action || mMouseButton != button
+                    || mMouseX != x || mMouseY != y))
                 mAWindowNativeHandler.nativeOnMouseEvent(mCallbackNativeHandle, action, button, x, y);
-            else {
-                mMouseAction = action;
-                mMouseButton = button;
-                mMouseX = x;
-                mMouseY = y;
-            }
+            mMouseAction = action;
+            mMouseButton = button;
+            mMouseX = x;
+            mMouseY = y;
         }
     }
 
     @Override
     public void setWindowSize(int width, int height) {
         synchronized (mNativeLock) {
-            if (mCallbackNativeHandle != 0)
+            if (mCallbackNativeHandle != 0 && (mWindowWidth != width || mWindowHeight != height))
                 mAWindowNativeHandler.nativeOnWindowSize(mCallbackNativeHandle, width, height);
-            else {
-                mWindowWidth = width;
-                mWindowHeight = height;
-            }
+            mWindowWidth = width;
+            mWindowHeight = height;
         }
     }
 
@@ -467,8 +464,6 @@ public class AWindow implements IVLCVout {
                     if (mWindowWidth != -1 && mWindowHeight != -1)
                         nativeOnWindowSize(mCallbackNativeHandle, mWindowWidth, mWindowHeight);
                 }
-                mMouseAction = mMouseButton = mMouseX = mMouseY = -1;
-                mWindowWidth = mWindowHeight = -1;
             }
             return true;
         }



More information about the Android mailing list