2008-12-12 Anders Carlsson <andersca@apple.com>
[WebKit-https.git] / WebKitExamplePlugins / NetscapeCocoaPlugin / main.m
index 1f66ac1..19a28e8 100644 (file)
@@ -203,9 +203,8 @@ static void handleDraw(PluginObject *obj)
 
 
     [NSGraphicsContext setCurrentContext:context];
-    
+
     NSRect rect = NSMakeRect(0, 0, obj->window.width, obj->window.height);
-    
     [[NSColor lightGrayColor] set];
     [NSBezierPath fillRect:rect];
 
@@ -264,9 +263,20 @@ static void invalidatePlugin(PluginObject *obj)
 
 static void handleMouseEvent(PluginObject *obj, NPCocoaEvent *event)
 {
+    NSWindow *window = ((NP_CGContext *)obj->window.window)->window;
+    // Convert the event coordinates to screen coordinates.
+    
+    NSPoint windowCoordinates = NSMakePoint(0, 0);//obj->window.x + event->data.mouse.pluginX,
+//                                            obj->window.y + event->data.mouse.pluginY);
+
+    NSPoint screenCoordinates = [window convertBaseToScreen:windowCoordinates];
+    
+    NSLog(@"window: %@", window);
+    
     NSString *string = [NSString stringWithFormat:@"Type: %@\n"
                                                    "Modifier flags: 0x%x\n"
                                                    "Coordinates: (%g, %g)\n"
+                                                   "Screen coordinates: (%g, %g)\n"
                                                    "Button number: %d\n"
                                                    "Click count: %d\n"
                                                    "Delta: (%g, %g, %g)",
@@ -274,6 +284,7 @@ static void handleMouseEvent(PluginObject *obj, NPCocoaEvent *event)
                                                    event->data.mouse.modifierFlags,
                                                    event->data.mouse.pluginX,
                                                    event->data.mouse.pluginY,
+                                                   screenCoordinates.x, screenCoordinates.y,
                                                    event->data.mouse.buttonNumber,
                                                    event->data.mouse.clickCount,
                                                    event->data.mouse.deltaX, event->data.mouse.deltaY, event->data.mouse.deltaZ];
@@ -323,6 +334,7 @@ int16 NPP_HandleEvent(NPP instance, void* event)
     
     switch(cocoaEvent->type) {
         case NPCocoaEventFocusChanged:
+            browser->status(instance, cocoaEvent->data.focus.hasFocus ? "Got focus" : "Lost Focus");
             obj->hasFocus = cocoaEvent->data.focus.hasFocus;
             invalidatePlugin(obj);
             return 1;