зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1107782 - Only accept certain mouse, gamepad events as user-active. r=smaug
Based on a patch by gfritsche, this filters out mouse events not indicative of user activity (like hit tests), and brings in gamepad events that might be indicative of user activity.
This commit is contained in:
Родитель
8aa11a9056
Коммит
61f8d55777
|
@ -482,6 +482,30 @@ EventStateManager::TryToFlushPendingNotificationsToIME()
|
|||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
IsMessageMouseUserActivity(EventMessage aMessage)
|
||||
{
|
||||
return aMessage == eMouseMove ||
|
||||
aMessage == eMouseUp ||
|
||||
aMessage == eMouseDown ||
|
||||
aMessage == eMouseDoubleClick ||
|
||||
aMessage == eMouseClick ||
|
||||
aMessage == eMouseActivate ||
|
||||
aMessage == eMouseLongTap;
|
||||
}
|
||||
|
||||
static bool
|
||||
IsMessageGamepadUserActivity(EventMessage aMessage)
|
||||
{
|
||||
#ifndef MOZ_GAMEPAD
|
||||
return false;
|
||||
#else
|
||||
return aMessage == eGamepadButtonDown ||
|
||||
aMessage == eGamepadButtonUp ||
|
||||
aMessage == eGamepadAxisMove;
|
||||
#endif
|
||||
}
|
||||
|
||||
nsresult
|
||||
EventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
||||
WidgetEvent* aEvent,
|
||||
|
@ -510,12 +534,12 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
|||
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
|
||||
if (aEvent->mFlags.mIsTrusted &&
|
||||
((mouseEvent && mouseEvent->IsReal() &&
|
||||
mouseEvent->mMessage != eMouseEnterIntoWidget &&
|
||||
mouseEvent->mMessage != eMouseExitFromWidget) ||
|
||||
IsMessageMouseUserActivity(mouseEvent->mMessage)) ||
|
||||
aEvent->mClass == eWheelEventClass ||
|
||||
aEvent->mClass == ePointerEventClass ||
|
||||
aEvent->mClass == eTouchEventClass ||
|
||||
aEvent->mClass == eKeyboardEventClass)) {
|
||||
aEvent->mClass == eKeyboardEventClass ||
|
||||
IsMessageGamepadUserActivity(aEvent->mMessage))) {
|
||||
if (gMouseOrKeyboardEventCounter == 0) {
|
||||
nsCOMPtr<nsIObserverService> obs =
|
||||
mozilla::services::GetObserverService();
|
||||
|
|
Загрузка…
Ссылка в новой задаче