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

Commit a79c84d

Browse files
authored
Exit other devices hover when clicking with another device (#3001)
1 parent 2b534a4 commit a79c84d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

+11
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ static class Device {
2222
int mDevice;
2323
Widget mPreviousWidget = null;
2424
Widget mTouchStartWidget = null;
25+
Widget mHoverStartWidget = null;
2526
boolean mWasPressed;
2627
long mDownTime;
2728
MotionEvent.PointerProperties mProperties[];
@@ -108,27 +109,37 @@ public static void dispatch(Widget aWidget, int aDevice, boolean aFocused, boole
108109
}
109110
generateEvent(device.mPreviousWidget, device, aFocused, MotionEvent.ACTION_HOVER_EXIT, true, device.mMouseOutCoords);
110111
device.mPreviousWidget = null;
112+
device.mHoverStartWidget = null;
111113
}
112114
if (aWidget == null) {
113115
device.mPreviousWidget = null;
116+
device.mHoverStartWidget = null;
114117
return;
115118
}
116119
if (aWidget != device.mPreviousWidget && !aPressed) {
117120
generateEvent(aWidget, device, aFocused, MotionEvent.ACTION_HOVER_ENTER, true);
121+
device.mHoverStartWidget = aWidget;
118122
}
119123
if (aPressed && !device.mWasPressed) {
120124
device.mDownTime = SystemClock.uptimeMillis();
121125
device.mWasPressed = true;
122126
if (!isOtherDeviceDown(device.mDevice)) {
123127
generateEvent(aWidget, device, aFocused, MotionEvent.ACTION_HOVER_EXIT, true);
124128
generateEvent(aWidget, device, aFocused, MotionEvent.ACTION_DOWN, false);
129+
device.mHoverStartWidget = null;
130+
}
131+
for (int i=0; i<devices.size(); i++) {
132+
if (devices.get(i) != device && devices.get(i).mHoverStartWidget != null) {
133+
generateEvent(devices.get(i).mHoverStartWidget, devices.get(i), aFocused, MotionEvent.ACTION_HOVER_EXIT, true);
134+
}
125135
}
126136
device.mTouchStartWidget = aWidget;
127137
} else if (!aPressed && device.mWasPressed) {
128138
device.mWasPressed = false;
129139
if (!isOtherDeviceDown(device.mDevice)) {
130140
generateEvent(device.mTouchStartWidget, device, aFocused, MotionEvent.ACTION_UP, false);
131141
generateEvent(aWidget, device, aFocused, MotionEvent.ACTION_HOVER_ENTER, true);
142+
device.mHoverStartWidget = aWidget;
132143
}
133144
device.mTouchStartWidget = null;
134145
} else if (moving && aPressed) {

0 commit comments

Comments
 (0)