Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit 9bd7b5e

Browse files
MortimerGorobluemarvin
authored andcommitted
Use out of bounds coordinates when dispatching ACTION_HOVER_EXIT (#2510)
1 parent 99abd68 commit 9bd7b5e

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

app/src/common/shared/org/mozilla/vrbrowser/input/MotionEventGenerator.java

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
import org.mozilla.vrbrowser.ui.widgets.Widget;
1515
import org.mozilla.vrbrowser.utils.SystemUtils;
1616

17+
import java.util.Arrays;
18+
import java.util.List;
19+
1720
public class MotionEventGenerator {
1821
static final String LOGTAG = SystemUtils.createLogtag(MotionEventGenerator.class);
1922
static class Device {
@@ -24,6 +27,7 @@ static class Device {
2427
long mDownTime;
2528
MotionEvent.PointerProperties mProperties[];
2629
MotionEvent.PointerCoords mCoords[];
30+
MotionEvent.PointerCoords mMouseOutCoords[];
2731

2832
Device(final int aDevice) {
2933
mDevice = aDevice;
@@ -33,24 +37,34 @@ static class Device {
3337
mProperties[0].toolType = MotionEvent.TOOL_TYPE_FINGER;
3438
mCoords = new MotionEvent.PointerCoords[1];
3539
mCoords[0] = new MotionEvent.PointerCoords();
36-
mCoords[0].toolMajor = 2;
37-
mCoords[0].toolMinor = 2;
38-
mCoords[0].touchMajor = 2;
39-
mCoords[0].touchMinor = 2;
40+
mMouseOutCoords = new MotionEvent.PointerCoords[1];
41+
for (MotionEvent.PointerCoords[] coords : Arrays.asList(mCoords, mMouseOutCoords)) {
42+
coords[0] = new MotionEvent.PointerCoords();
43+
coords[0].toolMajor = 2;
44+
coords[0].toolMinor = 2;
45+
coords[0].touchMajor = 2;
46+
coords[0].touchMinor = 2;
47+
}
48+
mMouseOutCoords[0].x = -10;
49+
mMouseOutCoords[0].y = -10;
4050
}
4151
}
4252

4353
private static SparseArray<Device> devices = new SparseArray<>();
4454

4555

4656
private static void generateEvent(Widget aWidget, Device aDevice, int aAction, boolean aGeneric) {
57+
generateEvent(aWidget, aDevice, aAction, aGeneric, aDevice.mCoords);
58+
}
59+
60+
private static void generateEvent(Widget aWidget, Device aDevice, int aAction, boolean aGeneric, MotionEvent.PointerCoords[] aCoords) {
4761
MotionEvent event = MotionEvent.obtain(
4862
/*mDownTime*/ aDevice.mDownTime,
4963
/*eventTime*/ SystemClock.uptimeMillis(),
5064
/*action*/ aAction,
5165
/*pointerCount*/ 1,
5266
/*pointerProperties*/ aDevice.mProperties,
53-
/*pointerCoords*/ aDevice.mCoords,
67+
/*pointerCoords*/ aCoords,
5468
/*metaState*/ 0,
5569
/*buttonState*/ 0,
5670
/*xPrecision*/ 0,
@@ -88,7 +102,7 @@ public static void dispatch(Widget aWidget, int aDevice, boolean aPressed, float
88102
generateEvent(device.mPreviousWidget, device, MotionEvent.ACTION_CANCEL, false);
89103
device.mWasPressed = false;
90104
}
91-
generateEvent(device.mPreviousWidget, device, MotionEvent.ACTION_HOVER_EXIT, true);
105+
generateEvent(device.mPreviousWidget, device, MotionEvent.ACTION_HOVER_EXIT, true, device.mMouseOutCoords);
92106
device.mPreviousWidget = null;
93107
}
94108
if (aWidget == null) {

0 commit comments

Comments
 (0)