зеркало из https://github.com/mozilla/pjs.git
send native events to plugins on mouse enter and exit. b=332597 r=smichaud sr=roc
This commit is contained in:
Родитель
6c097f6bba
Коммит
4cdce19d4b
|
@ -87,6 +87,11 @@
|
||||||
PRLogModuleInfo* sCocoaLog = nsnull;
|
PRLogModuleInfo* sCocoaLog = nsnull;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// npapi.h defines NPEventType_AdjustCursorEvent but we don't want to include npapi.h here.
|
||||||
|
// We need to send this in the "what" field for certain native plugin events. WebKit does
|
||||||
|
// this as well.
|
||||||
|
#define adjustCursorEvent 33
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
CG_EXTERN void CGContextResetCTM(CGContextRef);
|
CG_EXTERN void CGContextResetCTM(CGContextRef);
|
||||||
CG_EXTERN void CGContextSetCTM(CGContextRef, CGAffineTransform);
|
CG_EXTERN void CGContextSetCTM(CGContextRef, CGAffineTransform);
|
||||||
|
@ -2621,11 +2626,12 @@ class nsNonNativeContextMenuEvent : public nsRunnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static nsEventStatus SendMouseEvent(PRBool isTrusted,
|
// sends a mouse enter or exit event into gecko
|
||||||
PRUint32 msg,
|
static nsEventStatus SendGeckoMouseEnterOrExitEvent(PRBool isTrusted,
|
||||||
nsIWidget *widget,
|
PRUint32 msg,
|
||||||
nsMouseEvent::reasonType aReason,
|
nsIWidget *widget,
|
||||||
NSPoint* localEventLocation)
|
nsMouseEvent::reasonType aReason,
|
||||||
|
NSPoint* localEventLocation)
|
||||||
{
|
{
|
||||||
if (!widget || !localEventLocation)
|
if (!widget || !localEventLocation)
|
||||||
return nsEventStatus_eIgnore;
|
return nsEventStatus_eIgnore;
|
||||||
|
@ -2634,6 +2640,14 @@ static nsEventStatus SendMouseEvent(PRBool isTrusted,
|
||||||
event.refPoint.x = nscoord((PRInt32)localEventLocation->x);
|
event.refPoint.x = nscoord((PRInt32)localEventLocation->x);
|
||||||
event.refPoint.y = nscoord((PRInt32)localEventLocation->y);
|
event.refPoint.y = nscoord((PRInt32)localEventLocation->y);
|
||||||
|
|
||||||
|
EventRecord macEvent;
|
||||||
|
macEvent.what = adjustCursorEvent;
|
||||||
|
macEvent.message = 0;
|
||||||
|
macEvent.when = ::TickCount();
|
||||||
|
::GetGlobalMouse(&macEvent.where);
|
||||||
|
macEvent.modifiers = GetCurrentKeyModifiers();
|
||||||
|
event.nativeMsg = &macEvent;
|
||||||
|
|
||||||
nsEventStatus status;
|
nsEventStatus status;
|
||||||
widget->DispatchEvent(&event, status);
|
widget->DispatchEvent(&event, status);
|
||||||
return status;
|
return status;
|
||||||
|
@ -2655,7 +2669,7 @@ static nsEventStatus SendMouseEvent(PRBool isTrusted,
|
||||||
if (![NSApp isActive] && ![ChildView mouseEventIsOverRollupWidget:theEvent]) {
|
if (![NSApp isActive] && ![ChildView mouseEventIsOverRollupWidget:theEvent]) {
|
||||||
if (sLastViewEntered) {
|
if (sLastViewEntered) {
|
||||||
nsIWidget* lastViewEnteredWidget = [(NSView<mozView>*)sLastViewEntered widget];
|
nsIWidget* lastViewEnteredWidget = [(NSView<mozView>*)sLastViewEntered widget];
|
||||||
SendMouseEvent(PR_TRUE, NS_MOUSE_EXIT, lastViewEnteredWidget, nsMouseEvent::eReal, &viewEventLocation);
|
SendGeckoMouseEnterOrExitEvent(PR_TRUE, NS_MOUSE_EXIT, lastViewEnteredWidget, nsMouseEvent::eReal, &viewEventLocation);
|
||||||
sLastViewEntered = nil;
|
sLastViewEntered = nil;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -2733,7 +2747,7 @@ static nsEventStatus SendMouseEvent(PRBool isTrusted,
|
||||||
if (sLastViewEntered) {
|
if (sLastViewEntered) {
|
||||||
// NSLog(@"sending NS_MOUSE_EXIT event with point %f,%f\n", viewEventLocation.x, viewEventLocation.y);
|
// NSLog(@"sending NS_MOUSE_EXIT event with point %f,%f\n", viewEventLocation.x, viewEventLocation.y);
|
||||||
nsIWidget* lastViewEnteredWidget = [(NSView<mozView>*)sLastViewEntered widget];
|
nsIWidget* lastViewEnteredWidget = [(NSView<mozView>*)sLastViewEntered widget];
|
||||||
SendMouseEvent(PR_TRUE, NS_MOUSE_EXIT, lastViewEnteredWidget, nsMouseEvent::eReal, &viewEventLocation);
|
SendGeckoMouseEnterOrExitEvent(PR_TRUE, NS_MOUSE_EXIT, lastViewEnteredWidget, nsMouseEvent::eReal, &viewEventLocation);
|
||||||
sLastViewEntered = nil;
|
sLastViewEntered = nil;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -2748,11 +2762,11 @@ static nsEventStatus SendMouseEvent(PRBool isTrusted,
|
||||||
if (sLastViewEntered) {
|
if (sLastViewEntered) {
|
||||||
// NSLog(@"sending NS_MOUSE_EXIT event with point %f,%f\n", viewEventLocation.x, viewEventLocation.y);
|
// NSLog(@"sending NS_MOUSE_EXIT event with point %f,%f\n", viewEventLocation.x, viewEventLocation.y);
|
||||||
nsIWidget* lastViewEnteredWidget = [(NSView<mozView>*)sLastViewEntered widget];
|
nsIWidget* lastViewEnteredWidget = [(NSView<mozView>*)sLastViewEntered widget];
|
||||||
SendMouseEvent(PR_TRUE, NS_MOUSE_EXIT, lastViewEnteredWidget, nsMouseEvent::eReal, &viewEventLocation);
|
SendGeckoMouseEnterOrExitEvent(PR_TRUE, NS_MOUSE_EXIT, lastViewEnteredWidget, nsMouseEvent::eReal, &viewEventLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NSLog(@"sending NS_MOUSE_ENTER event with point %f,%f\n", viewEventLocation.x, viewEventLocation.y);
|
// NSLog(@"sending NS_MOUSE_ENTER event with point %f,%f\n", viewEventLocation.x, viewEventLocation.y);
|
||||||
SendMouseEvent(PR_TRUE, NS_MOUSE_ENTER, mGeckoChild, nsMouseEvent::eReal, &viewEventLocation);
|
SendGeckoMouseEnterOrExitEvent(PR_TRUE, NS_MOUSE_ENTER, mGeckoChild, nsMouseEvent::eReal, &viewEventLocation);
|
||||||
|
|
||||||
// mark this view as the last view entered
|
// mark this view as the last view entered
|
||||||
sLastViewEntered = (NSView*)self;
|
sLastViewEntered = (NSView*)self;
|
||||||
|
@ -2772,11 +2786,10 @@ static nsEventStatus SendMouseEvent(PRBool isTrusted,
|
||||||
|
|
||||||
// create native EventRecord for use by plugins
|
// create native EventRecord for use by plugins
|
||||||
EventRecord macEvent;
|
EventRecord macEvent;
|
||||||
macEvent.what = nullEvent;
|
macEvent.what = adjustCursorEvent;
|
||||||
macEvent.message = 0;
|
macEvent.message = 0;
|
||||||
macEvent.when = ::TickCount();
|
macEvent.when = ::TickCount();
|
||||||
::GetGlobalMouse(&macEvent.where);
|
::GetGlobalMouse(&macEvent.where);
|
||||||
|
|
||||||
macEvent.modifiers = GetCurrentKeyModifiers();
|
macEvent.modifiers = GetCurrentKeyModifiers();
|
||||||
geckoEvent.nativeMsg = &macEvent;
|
geckoEvent.nativeMsg = &macEvent;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче