Bug 763613 - Make hover events mousemove events. r=wesj

This commit is contained in:
Eitan Isaacson 2012-06-15 15:34:22 -07:00
Родитель bf373d0850
Коммит a057c9b384
6 изменённых файлов: 37 добавлений и 6 удалений

Просмотреть файл

@ -197,7 +197,10 @@ public class GeckoEvent {
case MotionEvent.ACTION_POINTER_UP:
case MotionEvent.ACTION_POINTER_DOWN:
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_MOVE: {
case MotionEvent.ACTION_MOVE:
case MotionEvent.ACTION_HOVER_ENTER:
case MotionEvent.ACTION_HOVER_MOVE:
case MotionEvent.ACTION_HOVER_EXIT: {
mCount = m.getPointerCount();
mPoints = new Point[mCount];
mPointIndicies = new int[mCount];

Просмотреть файл

@ -90,6 +90,11 @@ public class LayerView extends SurfaceView implements SurfaceHolder.Callback {
return mTouchEventHandler.handleEvent(event);
}
@Override
public boolean onHoverEvent(MotionEvent event) {
return mTouchEventHandler.handleEvent(event);
}
public LayerController getController() { return mController; }
public TouchEventHandler getTouchEventHandler() { return mTouchEventHandler; }

Просмотреть файл

@ -150,6 +150,12 @@ public final class TouchEventHandler implements Tabs.OnTabsChangedListener {
return true;
}
// if this is a hover event just notify gecko, we don't have any interest in the java layer.
if (isHoverEvent(event)) {
mOnTouchListener.onTouch(mView, event);
return true;
}
if (isDownEvent(event)) {
// this is the start of a new block of events! whee!
mHoldInQueue = mWaitForTouchListeners;
@ -232,6 +238,11 @@ public final class TouchEventHandler implements Tabs.OnTabsChangedListener {
mOnTouchListener = onTouchListener;
}
private boolean isHoverEvent(MotionEvent event) {
int action = (event.getAction() & MotionEvent.ACTION_MASK);
return (action == MotionEvent.ACTION_HOVER_ENTER || action == MotionEvent.ACTION_HOVER_MOVE || action == MotionEvent.ACTION_HOVER_EXIT);
}
private boolean isDownEvent(MotionEvent event) {
int action = (event.getAction() & MotionEvent.ACTION_MASK);
return (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_POINTER_DOWN);

Просмотреть файл

@ -507,6 +507,9 @@ public:
ACTION_OUTSIDE = 4,
ACTION_POINTER_DOWN = 5,
ACTION_POINTER_UP = 6,
ACTION_HOVER_MOVE = 7,
ACTION_HOVER_ENTER = 9,
ACTION_HOVER_EXIT = 10,
ACTION_POINTER_ID_MASK = 0xff00,
ACTION_POINTER_ID_SHIFT = 8,
EDGE_TOP = 0x00000001,

Просмотреть файл

@ -843,10 +843,9 @@ nsWindow::OnGlobalAndroidEvent(AndroidGeckoEvent *ae)
if (!preventDefaultActions && ae->Count() == 2) {
target->OnGestureEvent(ae);
}
#ifndef MOZ_ONLY_TOUCH_EVENTS
if (!preventDefaultActions && ae->Count() < 2)
target->OnMotionEvent(ae);
#endif
target->OnMouseEvent(ae);
}
}
break;
@ -1289,10 +1288,12 @@ nsWindow::GetNativeData(PRUint32 aDataType)
}
void
nsWindow::OnMotionEvent(AndroidGeckoEvent *ae)
nsWindow::OnMouseEvent(AndroidGeckoEvent *ae)
{
PRUint32 msg;
PRInt16 buttons = nsMouseEvent::eLeftButtonFlag;
switch (ae->Action() & AndroidMotionEvent::ACTION_MASK) {
#ifndef MOZ_ONLY_TOUCH_EVENTS
case AndroidMotionEvent::ACTION_DOWN:
msg = NS_MOUSE_BUTTON_DOWN;
break;
@ -1305,6 +1306,14 @@ nsWindow::OnMotionEvent(AndroidGeckoEvent *ae)
case AndroidMotionEvent::ACTION_CANCEL:
msg = NS_MOUSE_BUTTON_UP;
break;
#endif
case AndroidMotionEvent::ACTION_HOVER_ENTER:
case AndroidMotionEvent::ACTION_HOVER_MOVE:
case AndroidMotionEvent::ACTION_HOVER_EXIT:
msg = NS_MOUSE_MOVE;
buttons = 0;
break;
default:
return;

Просмотреть файл

@ -52,7 +52,7 @@ public:
void OnDraw(mozilla::AndroidGeckoEvent *ae);
bool OnMultitouchEvent(mozilla::AndroidGeckoEvent *ae);
void OnGestureEvent(mozilla::AndroidGeckoEvent *ae);
void OnMotionEvent(mozilla::AndroidGeckoEvent *ae);
void OnMouseEvent(mozilla::AndroidGeckoEvent *ae);
void OnKeyEvent(mozilla::AndroidGeckoEvent *ae);
void OnIMEEvent(mozilla::AndroidGeckoEvent *ae);