WebKit:
[WebKit-https.git] / WebKit / mac / Plugins / WebNetscapePluginEventHandlerCocoa.mm
index 1ac01bf..f952f6b 100644 (file)
@@ -88,9 +88,16 @@ bool WebNetscapePluginEventHandlerCocoa::sendMouseEvent(NSEvent *nsEvent, NPCoco
     
     NSPoint point = [m_pluginView convertPoint:[nsEvent locationInWindow] fromView:nil];
     
+    int clickCount;
+    if (type == NPCocoaEventMouseEntered || type == NPCocoaEventMouseExited || type == NPCocoaEventScrollWheel)
+        clickCount = 0;
+    else
+        clickCount = [nsEvent clickCount];
+    
     event.type = type;
     event.event.mouse.modifierFlags = [nsEvent modifierFlags];
     event.event.mouse.buttonNumber = [nsEvent buttonNumber];
+    event.event.mouse.clickCount = clickCount;
     event.event.mouse.pluginX = point.x;
     event.event.mouse.pluginY = point.y;
     event.event.mouse.deltaX = [nsEvent deltaX];
@@ -102,7 +109,11 @@ bool WebNetscapePluginEventHandlerCocoa::sendMouseEvent(NSEvent *nsEvent, NPCoco
 
 void WebNetscapePluginEventHandlerCocoa::keyDown(NSEvent *event)
 {
-    sendKeyEvent(event, NPCocoaEventKeyDown);
+    bool retval = sendKeyEvent(event, NPCocoaEventKeyDown);
+    
+    // If the plug-in did not handle the event, pass it on to the Input Manager.
+    if (!retval)
+        [m_pluginView interpretKeyEvents:[NSArray arrayWithObject:event]];
 }
 
 void WebNetscapePluginEventHandlerCocoa::keyUp(NSEvent *event)
@@ -113,13 +124,9 @@ void WebNetscapePluginEventHandlerCocoa::keyUp(NSEvent *event)
 void WebNetscapePluginEventHandlerCocoa::flagsChanged(NSEvent *nsEvent)
 {
     NPCocoaEvent event;
-    
-    NSPoint point = [m_pluginView convertPoint:[nsEvent locationInWindow] fromView:nil];
-    
+        
     event.type = NPCocoaEventFlagsChanged;
     event.event.key.modifierFlags = [nsEvent modifierFlags];
-    event.event.key.pluginX = point.x;
-    event.event.key.pluginY = point.y;
     event.event.key.keyCode = [nsEvent keyCode];
     event.event.key.isARepeat = false;
     event.event.key.characters = 0;
@@ -128,22 +135,18 @@ void WebNetscapePluginEventHandlerCocoa::flagsChanged(NSEvent *nsEvent)
     sendEvent(&event);
 }
 
-void WebNetscapePluginEventHandlerCocoa::sendKeyEvent(NSEvent* nsEvent, NPCocoaEventType type)
+bool WebNetscapePluginEventHandlerCocoa::sendKeyEvent(NSEvent* nsEvent, NPCocoaEventType type)
 {
     NPCocoaEvent event;
-    
-    NSPoint point = [m_pluginView convertPoint:[nsEvent locationInWindow] fromView:nil];
-    
+        
     event.type = type;
     event.event.key.modifierFlags = [nsEvent modifierFlags];
-    event.event.key.pluginX = point.x;
-    event.event.key.pluginY = point.y;
     event.event.key.keyCode = [nsEvent keyCode];
     event.event.key.isARepeat = [nsEvent isARepeat];
     event.event.key.characters = (NPNSString *)[nsEvent characters];
     event.event.key.charactersIgnoringModifiers = (NPNSString *)[nsEvent charactersIgnoringModifiers];
      
-    sendEvent(&event);
+    return sendEvent(&event);
 }
 
 void WebNetscapePluginEventHandlerCocoa::windowFocusChanged(bool hasFocus)