/*****************************************************************************
* 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 ):
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;
}
// 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);
}
}
}
-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