mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 376679 part.5 nsPluginInstanceOwner::ProcessEvent() should create WM_MOUSE*WHEEL message from WidgetWheelEvent data r=smaug+jimm
This commit is contained in:
parent
642fc63e6f
commit
7a341ba0f3
@ -69,6 +69,9 @@ static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
||||
#ifdef XP_WIN
|
||||
#include <wtypes.h>
|
||||
#include <winuser.h>
|
||||
#ifndef WM_MOUSEHWHEEL
|
||||
#define WM_MOUSEHWHEEL (0x020E)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
@ -2049,21 +2052,24 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
|
||||
// we can get synthetic events from the EventStateManager... these
|
||||
// have no pluginEvent
|
||||
NPEvent pluginEvent;
|
||||
if (anEvent.mClass == eMouseEventClass) {
|
||||
if (anEvent.mClass == eMouseEventClass ||
|
||||
anEvent.mClass == eWheelEventClass) {
|
||||
if (!pPluginEvent) {
|
||||
// XXX Should extend this list to synthesize events for more event
|
||||
// types
|
||||
pluginEvent.event = 0;
|
||||
const WidgetMouseEvent* mouseEvent = anEvent.AsMouseEvent();
|
||||
bool initWParamWithCurrentState = true;
|
||||
switch (anEvent.mMessage) {
|
||||
case eMouseMove:
|
||||
case eMouseMove: {
|
||||
pluginEvent.event = WM_MOUSEMOVE;
|
||||
break;
|
||||
}
|
||||
case eMouseDown: {
|
||||
static const int downMsgs[] =
|
||||
{ WM_LBUTTONDOWN, WM_MBUTTONDOWN, WM_RBUTTONDOWN };
|
||||
static const int dblClickMsgs[] =
|
||||
{ WM_LBUTTONDBLCLK, WM_MBUTTONDBLCLK, WM_RBUTTONDBLCLK };
|
||||
const WidgetMouseEvent* mouseEvent = anEvent.AsMouseEvent();
|
||||
if (mouseEvent->clickCount == 2) {
|
||||
pluginEvent.event = dblClickMsgs[mouseEvent->button];
|
||||
} else {
|
||||
@ -2074,16 +2080,53 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
|
||||
case eMouseUp: {
|
||||
static const int upMsgs[] =
|
||||
{ WM_LBUTTONUP, WM_MBUTTONUP, WM_RBUTTONUP };
|
||||
const WidgetMouseEvent* mouseEvent = anEvent.AsMouseEvent();
|
||||
pluginEvent.event = upMsgs[mouseEvent->button];
|
||||
break;
|
||||
}
|
||||
// For plugins which don't support high-resolution scroll, we should
|
||||
// generate legacy resolution wheel messages. I.e., the delta value
|
||||
// should be WHEEL_DELTA * n.
|
||||
case eWheel: {
|
||||
// XXX Currently assuming that users don't change system settings of
|
||||
// wheel scroll amount. This is going to be fixed in following
|
||||
// patch.
|
||||
static const int32_t kLinesPerWheelDelta = 3;
|
||||
static const int32_t kCharsPerWheelDelta = 3;
|
||||
|
||||
const WidgetWheelEvent* wheelEvent = anEvent.AsWheelEvent();
|
||||
int32_t delta = 0;
|
||||
if (wheelEvent->lineOrPageDeltaY) {
|
||||
pluginEvent.event = WM_MOUSEWHEEL;
|
||||
delta =
|
||||
-WHEEL_DELTA / kLinesPerWheelDelta * wheelEvent->lineOrPageDeltaY;
|
||||
} else if (wheelEvent->lineOrPageDeltaX) {
|
||||
pluginEvent.event = WM_MOUSEHWHEEL;
|
||||
delta =
|
||||
WHEEL_DELTA / kCharsPerWheelDelta * wheelEvent->lineOrPageDeltaX;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
initWParamWithCurrentState = false;
|
||||
int32_t modifiers =
|
||||
(wheelEvent->IsControl() ? MK_CONTROL : 0) |
|
||||
(wheelEvent->IsShift() ? MK_SHIFT : 0) |
|
||||
(wheelEvent->IsLeftButtonPressed() ? MK_LBUTTON : 0) |
|
||||
(wheelEvent->IsMiddleButtonPressed() ? MK_MBUTTON : 0) |
|
||||
(wheelEvent->IsRightButtonPressed() ? MK_RBUTTON : 0) |
|
||||
(wheelEvent->Is4thButtonPressed() ? MK_XBUTTON1 : 0) |
|
||||
(wheelEvent->Is5thButtonPressed() ? MK_XBUTTON2 : 0);
|
||||
pluginEvent.wParam = MAKEWPARAM(modifiers, delta);
|
||||
pPluginEvent = &pluginEvent;
|
||||
break;
|
||||
}
|
||||
// don't synthesize anything for eMouseDoubleClick, since that
|
||||
// is a synthetic event generated on mouse-up, and Windows WM_*DBLCLK
|
||||
// messages are sent on mouse-down
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (pluginEvent.event) {
|
||||
if (pluginEvent.event && initWParamWithCurrentState) {
|
||||
pPluginEvent = &pluginEvent;
|
||||
pluginEvent.wParam =
|
||||
(::GetKeyState(VK_CONTROL) ? MK_CONTROL : 0) |
|
||||
@ -2105,7 +2148,8 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
|
||||
anEvent.mMessage == eMouseDoubleClick ||
|
||||
anEvent.mMessage == eMouseOver ||
|
||||
anEvent.mMessage == eMouseOut ||
|
||||
anEvent.mMessage == eMouseMove,
|
||||
anEvent.mMessage == eMouseMove ||
|
||||
anEvent.mMessage == eWheel,
|
||||
"Incorrect event type for coordinate translation");
|
||||
nsPoint pt =
|
||||
nsLayoutUtils::GetEventCoordinatesRelativeTo(&anEvent, mPluginFrame) -
|
||||
|
@ -7,6 +7,9 @@
|
||||
#ifndef mozilla_dom_plugins_NPEventWindows_h
|
||||
#define mozilla_dom_plugins_NPEventWindows_h 1
|
||||
|
||||
#ifndef WM_MOUSEHWHEEL
|
||||
#define WM_MOUSEHWHEEL (0x020E)
|
||||
#endif
|
||||
|
||||
#include "npapi.h"
|
||||
namespace mozilla {
|
||||
@ -92,6 +95,9 @@ struct ParamTraits<mozilla::plugins::NPRemoteEvent>
|
||||
case WM_MBUTTONDBLCLK:
|
||||
case WM_RBUTTONDBLCLK:
|
||||
|
||||
case WM_MOUSEWHEEL:
|
||||
case WM_MOUSEHWHEEL:
|
||||
|
||||
case WM_SETFOCUS:
|
||||
case WM_KILLFOCUS:
|
||||
break;
|
||||
|
@ -137,6 +137,12 @@ public:
|
||||
// ID of the canvas HitRegion
|
||||
nsString region;
|
||||
|
||||
bool IsLeftButtonPressed() const { return !!(buttons & eLeftButtonFlag); }
|
||||
bool IsRightButtonPressed() const { return !!(buttons & eRightButtonFlag); }
|
||||
bool IsMiddleButtonPressed() const { return !!(buttons & eMiddleButtonFlag); }
|
||||
bool Is4thButtonPressed() const { return !!(buttons & e4thButtonFlag); }
|
||||
bool Is5thButtonPressed() const { return !!(buttons & e5thButtonFlag); }
|
||||
|
||||
void AssignMouseEventBaseData(const WidgetMouseEventBase& aEvent,
|
||||
bool aCopyTargets)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user