]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/macosx/macosx_loop.cpp
Set a non compressed format in aes3 decoder at open.
[vlc] / modules / gui / skins2 / macosx / macosx_loop.cpp
index 825cafb778b670fd62df4cf5352a1cfaf3927c25..ab46ae913c9e329127a90026ed7f4098a7620cc3 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * macosx_loop.cpp
  *****************************************************************************
- * Copyright (C) 2003 VideoLAN (Centrale Réseaux) and its contributors
+ * Copyright (C) 2003 the VideoLAN team
  * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 #ifdef MACOSX_SKINS
 
-#include <Carbon/Carbon.h>
 #include "macosx_loop.hpp"
+#include "macosx_window.hpp"
+#include "../src/generic_window.hpp"
+#include "../events/evt_refresh.hpp"
+
+static pascal OSStatus WinEventHandler( EventHandlerCallRef handler,
+                                        EventRef event, void *data )
+{
+    GenericWindow *pWin = (GenericWindow*)data;
+    intf_thread_t *pIntf = pWin->getIntf();
+
+    //fprintf(stderr, "event\n" );
+    UInt32 evclass = GetEventClass( event );
+    UInt32 evkind = GetEventKind( event );
+
+    switch( evclass )
+    {
+    case kEventClassWindow:
+        EvtRefresh evt( pIntf, 0, 0, -1, -1);
+        pWin->processEvent( evt );
+        break;
+    }
+}
 
 
 MacOSXLoop::MacOSXLoop( intf_thread_t *pIntf ):
@@ -51,11 +72,8 @@ OSLoop *MacOSXLoop::instance( intf_thread_t *pIntf )
 
 void MacOSXLoop::destroy( intf_thread_t *pIntf )
 {
-    if( pIntf->p_sys->p_osLoop )
-    {
-        delete pIntf->p_sys->p_osLoop;
-        pIntf->p_sys->p_osLoop = NULL;
-    }
+    delete pIntf->p_sys->p_osLoop;
+    pIntf->p_sys->p_osLoop = NULL;
 }
 
 
@@ -64,41 +82,7 @@ void MacOSXLoop::run()
     // Main event loop
     while( !m_exit )
     {
-        EventRef pEvent;
-        OSStatus err = ReceiveNextEvent( 0, NULL, kEventDurationForever, true,
-                                         &pEvent );
-        if( err != noErr )
-        {
-            // Get the event type
-            UInt32 evClass = GetEventClass( pEvent );
-
-            switch( evClass )
-            {
-                case kEventClassMouse:
-                {
-                    break;
-                }
-
-                case kEventClassKeyboard:
-                {
-                    break;
-                }
-
-                case kEventClassWindow:
-                {
-                    handleWindowEvent( pEvent );
-                    break;
-                }
-
-                default:
-                {
-                    EventTargetRef pTarget;
-                    pTarget = GetEventDispatcherTarget();
-                    SendEventToEventTarget( pEvent, pTarget );
-                    ReleaseEvent( pEvent );
-                }
-            }
-        }
+        sleep(1);
     }
 }
 
@@ -109,11 +93,16 @@ void MacOSXLoop::exit()
 }
 
 
-void MacOSXLoop::handleWindowEvent( EventRef pEvent )
+void MacOSXLoop::registerWindow( GenericWindow &rGenWin, WindowRef win )
 {
-    UInt32 evKind = GetEventKind( pEvent );
-
+    // Create the event handler
+    EventTypeSpec evList[] = {
+        { kEventClassWindow, kEventWindowUpdate },
+        { kEventClassMouse, kEventMouseMoved }
+    };
+    EventHandlerUPP handler = NewEventHandlerUPP( WinEventHandler );
+    InstallWindowEventHandler( win, handler, GetEventTypeCount( evList ),
+                               evList, &rGenWin, NULL );
 }
 
-
 #endif