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

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


npapi-vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Sun Dec 30 20:30:22 2012 +0100| [2fec8b2e34fb85953a7fab07a3e532911fb1084a] | 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=2fec8b2e34fb85953a7fab07a3e532911fb1084a
---

 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..6ea41f3 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