Skip to content

Commit

Permalink
Enable haptic feedback when widget hover starts
Browse files Browse the repository at this point in the history
Signed-off-by: Songlin Jiang <sjiang@igalia.com>
  • Loading branch information
HollowMan6 committed Oct 18, 2023
1 parent ae5efb0 commit 77aa073
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Expand Up @@ -1096,14 +1096,14 @@ void handleMotionEvent(final int aHandle, final int aDevice, final boolean aFocu
final float y = aY / scale;

if (widget == null) {
MotionEventGenerator.dispatch(mRootWidget, aDevice, aFocused, aPressed, x, y);
MotionEventGenerator.dispatch(this, mRootWidget, aDevice, aFocused, aPressed, x, y);

} else if (widget.getBorderWidth() > 0) {
final int border = widget.getBorderWidth();
MotionEventGenerator.dispatch(widget, aDevice, aFocused, aPressed, x - border, y - border);
MotionEventGenerator.dispatch(this, widget, aDevice, aFocused, aPressed, x - border, y - border);

} else {
MotionEventGenerator.dispatch(widget, aDevice, aFocused, aPressed, x, y);
MotionEventGenerator.dispatch(this, widget, aDevice, aFocused, aPressed, x, y);
}
});
}
Expand Down
Expand Up @@ -12,6 +12,7 @@
import android.view.MotionEvent;

import com.igalia.wolvic.ui.widgets.Widget;
import com.igalia.wolvic.ui.widgets.WidgetManagerDelegate;
import com.igalia.wolvic.utils.SystemUtils;

import java.util.Arrays;
Expand Down Expand Up @@ -86,7 +87,7 @@ private static void generateEvent(Widget aWidget, Device aDevice, boolean aFocus
event.recycle();
}

public static void dispatch(Widget aWidget, int aDevice, boolean aFocused, boolean aPressed, float aX, float aY) {
public static void dispatch(WidgetManagerDelegate widgetManager, Widget aWidget, int aDevice, boolean aFocused, boolean aPressed, float aX, float aY) {
Device device = devices.get(aDevice);
if (device == null) {
device = new Device(aDevice);
Expand Down Expand Up @@ -119,6 +120,7 @@ public static void dispatch(Widget aWidget, int aDevice, boolean aFocused, boole
}
if (aWidget != device.mPreviousWidget && !aPressed) {
generateEvent(aWidget, device, aFocused, MotionEvent.ACTION_HOVER_ENTER, true);
widgetManager.triggerHapticFeedback();
device.mHoverStartWidget = aWidget;
}
if (aPressed && !device.mWasPressed) {
Expand All @@ -140,6 +142,7 @@ public static void dispatch(Widget aWidget, int aDevice, boolean aFocused, boole
if (!isOtherDeviceDown(device.mDevice)) {
generateEvent(device.mTouchStartWidget, device, aFocused, MotionEvent.ACTION_UP, false);
generateEvent(aWidget, device, aFocused, MotionEvent.ACTION_HOVER_ENTER, true);
widgetManager.triggerHapticFeedback();
device.mHoverStartWidget = aWidget;
}
device.mTouchStartWidget = null;
Expand Down

0 comments on commit 77aa073

Please sign in to comment.