[vlc-commits] mac plugin: implement Cocoa Event handling for Mouse and Keys

Felix Paul Kühne git at videolan.org
Sun Dec 30 20:32:50 CET 2012


npapi-vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Sun Dec 30 20:30:22 2012 +0100| [4c40de1f442330ec4fe8df025feea970b60548c5] | committer: Felix Paul Kühne

mac plugin: implement Cocoa Event handling for Mouse and Keys

No drawing yet

> http://git.videolan.org/gitweb.cgi/npapi-vlc.git/?a=commit;h=4c40de1f442330ec4fe8df025feea970b60548c5
---

 npapi/vlcplugin_mac.cpp |   65 ++++++++++++++++++++---------------------------
 1 file changed, 27 insertions(+), 38 deletions(-)

diff --git a/npapi/vlcplugin_mac.cpp b/npapi/vlcplugin_mac.cpp
index 6155c4c..dff3df6 100644
--- a/npapi/vlcplugin_mac.cpp
+++ b/npapi/vlcplugin_mac.cpp
@@ -1,13 +1,14 @@
 /*****************************************************************************
  * vlcplugin_mac.cpp: a VLC plugin for Mozilla (Mac interface)
  *****************************************************************************
- * Copyright (C) 2011 the VideoLAN team
+ * Copyright (C) 2011-2012 VLC Authors and VideoLAN
  * $Id$
  *
  * Authors: Samuel Hocevar <sam at zoy.org>
  *          Damien Fouilleul <damienf at videolan.org>
  *          Jean-Paul Saman <jpsaman at videolan.org>
  *          Cheng Sun <chengsun9 at gmail.com>
+ *          Felix Paul Kühne <fkuehne # videolan # org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -105,31 +106,36 @@ bool VlcPluginMac::destroy_windows()
 
 bool VlcPluginMac::handle_event(void *event)
 {
-    // FIXME: implement Cocoa event model, by porting this legacy code:
-/*
-    static UInt32 lastMouseUp = 0;
-    EventRecord *myEvent = (EventRecord*)event;
+    NPCocoaEvent* cocoaEvent = (NPCocoaEvent*)event;
 
-    switch( myEvent->what )
-    {
-        case nullEvent:
-            return true;
-        case mouseDown:
+    if (!event)
+        return false;
+
+    NPCocoaEventType eventType = cocoaEvent->type;
+
+    switch (eventType) {
+        case NPCocoaEventMouseDown:
         {
-            if( (myEvent->when - lastMouseUp) < GetDblTime() )
-            {
-                // double click
-                p_plugin->toggle_fullscreen();
-            }
+            if (cocoaEvent->data.mouse.clickCount >= 2)
+                VlcPluginMac::toggle_fullscreen();
+
             return true;
         }
-        case mouseUp:
-            lastMouseUp = myEvent->when;
-            return true;
-        case keyUp:
-        case keyDown:
-        case autoKey:
+        case NPCocoaEventMouseUp:
+        case NPCocoaEventKeyUp:
+        case NPCocoaEventKeyDown:
+        case NPCocoaEventFocusChanged:
+        case NPCocoaEventScrollWheel:
             return true;
+
+        default:
+            break;
+    }
+/*
+    EventRecord *myEvent = (EventRecord*)event;
+
+    switch( myEvent->what )
+    {
         case updateEvt:
         {
             const NPWindow& npwindow = p_plugin->getWindow();
@@ -181,23 +187,6 @@ bool VlcPluginMac::handle_event(void *event)
             }
             return true;
         }
-        case activateEvt:
-            return false;
-        case NPEventType_GetFocusEvent:
-        case NPEventType_LoseFocusEvent:
-            return true;
-        case NPEventType_AdjustCursorEvent:
-            return false;
-        case NPEventType_MenuCommandEvent:
-            return false;
-        case NPEventType_ClippingChangedEvent:
-            return false;
-        case NPEventType_ScrollingBeginsEvent:
-            return true;
-        case NPEventType_ScrollingEndsEvent:
-            return true;
-        default:
-            ;
     }
 */
     return VlcPluginBase::handle_event(event);



More information about the vlc-commits mailing list