1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2003 the VideoLAN team
7 * Authors: Cyril Deguet <asmax@via.ecp.fr>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
26 #include "macosx_loop.hpp"
27 #include "macosx_window.hpp"
28 #include "../src/generic_window.hpp"
29 #include "../events/evt_refresh.hpp"
31 static pascal OSStatus WinEventHandler( EventHandlerCallRef handler,
32 EventRef event, void *data )
34 GenericWindow *pWin = (GenericWindow*)data;
35 intf_thread_t *pIntf = pWin->getIntf();
37 //fprintf(stderr, "event\n" );
38 UInt32 evclass = GetEventClass( event );
39 UInt32 evkind = GetEventKind( event );
43 case kEventClassWindow:
44 EvtRefresh evt( pIntf, 0, 0, -1, -1);
45 pWin->processEvent( evt );
51 MacOSXLoop::MacOSXLoop( intf_thread_t *pIntf ):
52 OSLoop( pIntf ), m_exit( false )
57 MacOSXLoop::~MacOSXLoop()
62 OSLoop *MacOSXLoop::instance( intf_thread_t *pIntf )
64 if( pIntf->p_sys->p_osLoop == NULL )
66 OSLoop *pOsLoop = new MacOSXLoop( pIntf );
67 pIntf->p_sys->p_osLoop = pOsLoop;
69 return pIntf->p_sys->p_osLoop;
73 void MacOSXLoop::destroy( intf_thread_t *pIntf )
75 if( pIntf->p_sys->p_osLoop )
77 delete pIntf->p_sys->p_osLoop;
78 pIntf->p_sys->p_osLoop = NULL;
83 void MacOSXLoop::run()
93 void MacOSXLoop::exit()
99 void MacOSXLoop::registerWindow( GenericWindow &rGenWin, WindowRef win )
101 // Create the event handler
102 EventTypeSpec evList[] = {
103 { kEventClassWindow, kEventWindowUpdate },
104 { kEventClassMouse, kEventMouseMoved }
106 EventHandlerUPP handler = NewEventHandlerUPP( WinEventHandler );
107 InstallWindowEventHandler( win, handler, GetEventTypeCount( evList ),
108 evList, &rGenWin, NULL );