From 4471e886f5769b5ae63a02c72140c0afd9e6c1e3 Mon Sep 17 00:00:00 2001 From: Tommi Komulainen Date: Sun, 29 Jun 2008 10:31:31 +0000 Subject: [PATCH] OSX: don't depend on ClutterGLWindow * clutter/osx/clutter-osx.h (_clutter_event_osx_put) * clutter/osx/clutter-event-osx.c (clutter_event_osx_translate, NSEvent:clutterStage:) * clutter/osx/clutter-stage-osx.c (EVENT_HANDLER): Since events are delivered to ClutterGLView, pass the associated ClutterStage directly to event translation. Avoids relying on being embedded in ClutterGLWindow, which makes it easier to implement clutter-gtk. --- ChangeLog | 10 ++++++++++ clutter/osx/clutter-event-osx.c | 18 ++++-------------- clutter/osx/clutter-osx.h | 2 +- clutter/osx/clutter-stage-osx.c | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 773423f70..f43b40810 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-06-29 Tommi Komulainen + + * clutter/osx/clutter-osx.h (_clutter_event_osx_put) + * clutter/osx/clutter-event-osx.c (clutter_event_osx_translate, + NSEvent:clutterStage:) + * clutter/osx/clutter-stage-osx.c (EVENT_HANDLER): Since events are + delivered to ClutterGLView, pass the associated ClutterStage directly + to event translation. Avoids relying on being embedded in + ClutterGLWindow, which makes it easier to implement clutter-gtk. + 2008-06-29 Tommi Komulainen * clutter/osx/clutter-event.osx.c (NSEvent:clutterKeyVal:): Add diff --git a/clutter/osx/clutter-event-osx.c b/clutter/osx/clutter-event-osx.c index d4afa8230..e2df62178 100644 --- a/clutter/osx/clutter-event-osx.c +++ b/clutter/osx/clutter-event-osx.c @@ -38,7 +38,6 @@ static GPollFunc old_poll_func = NULL; /*************************************************************************/ @interface NSEvent (Clutter) -- (ClutterStage*)clutterStage; - (gint)clutterTime; - (gint)clutterButton; - (void)clutterX:(gint*)ptrX y:(gint*)ptrY; @@ -47,16 +46,6 @@ static GPollFunc old_poll_func = NULL; @end @implementation NSEvent (Clutter) -- (ClutterStage*)clutterStage -{ - ClutterGLWindow *w = (ClutterGLWindow*)[self window]; - if (![w isKindOfClass:[ClutterGLWindow class]]) - return NULL; - - ClutterStageOSX *stage_osx = w->stage_osx; - return stage_osx->wrapper; -} - - (gint)clutterTime { return [self timestamp] * 1000; @@ -177,7 +166,6 @@ static GPollFunc old_poll_func = NULL; static gboolean clutter_event_osx_translate (NSEvent *nsevent, ClutterEvent *event) { - event->any.stage = [nsevent clutterStage]; event->any.time = [nsevent clutterTime]; switch ([nsevent type]) @@ -248,10 +236,12 @@ clutter_event_osx_translate (NSEvent *nsevent, ClutterEvent *event) } void -_clutter_event_osx_put (NSEvent *nsevent) +_clutter_event_osx_put (NSEvent *nsevent, ClutterStage *wrapper) { ClutterEvent event = { 0, }; - + + event.any.stage = wrapper; + if (clutter_event_osx_translate (nsevent, &event)) { g_assert (event.type != CLUTTER_NOTHING); diff --git a/clutter/osx/clutter-osx.h b/clutter/osx/clutter-osx.h index d7271387f..3c4fc9cac 100644 --- a/clutter/osx/clutter-osx.h +++ b/clutter/osx/clutter-osx.h @@ -34,7 +34,7 @@ G_BEGIN_DECLS void _clutter_events_osx_init (void); void _clutter_events_osx_uninit (void); -void _clutter_event_osx_put (NSEvent *nsevent); +void _clutter_event_osx_put (NSEvent *nsevent, ClutterStage *wrapper); G_END_DECLS diff --git a/clutter/osx/clutter-stage-osx.c b/clutter/osx/clutter-stage-osx.c index a118c176a..cb60b3676 100644 --- a/clutter/osx/clutter-stage-osx.c +++ b/clutter/osx/clutter-stage-osx.c @@ -159,7 +159,7 @@ clutter_stage_osx_state_update (ClutterStageOSX *self, /* Simply forward all events that reach our view to clutter. */ #define EVENT_HANDLER(event) -(void)event:(NSEvent *)theEvent { \ - _clutter_event_osx_put (theEvent); \ + _clutter_event_osx_put (theEvent, self->stage_osx->wrapper); \ } EVENT_HANDLER(mouseDown) EVENT_HANDLER(mouseDragged)