diff --git a/ChangeLog b/ChangeLog index c3a3c4ef2..bd06927f3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2007-08-23 Emmanuele Bassi + + * clutter/clutter-private.h: + * clutter/clutter-event.c: Revert the event queue ordering + commit. + + * clutter/eglx/clutter-event-egl.c: + * clutter/glx/clutter-event-glx.c: + * clutter/sdl/clutter-event-sdl.c: Update backends. + 2007-08-22 Tomas Frydrych * clutter/clutter-behaviour-rotate.c: diff --git a/clutter/clutter-event.c b/clutter/clutter-event.c index 3b2c41814..d93c95e6a 100644 --- a/clutter/clutter-event.c +++ b/clutter/clutter-event.c @@ -364,13 +364,9 @@ clutter_event_get_type (void) ClutterEvent * clutter_event_new (ClutterEventType type) { - ClutterEventPrivate *real_event; ClutterEvent *new_event; - real_event = g_slice_new0 (ClutterEventPrivate); - real_event->flags = 0; - - new_event = (ClutterEvent *) real_event; + new_event = g_slice_new0 (ClutterEvent); new_event->type = new_event->any.type = type; return new_event; @@ -408,7 +404,7 @@ clutter_event_free (ClutterEvent *event) { if (G_LIKELY (event)) { - g_slice_free (ClutterEventPrivate, (ClutterEventPrivate *) event); + g_slice_free (ClutterEvent, event); } } @@ -434,23 +430,7 @@ clutter_event_get (void) if (g_queue_is_empty (context->events_queue)) return NULL; - /* find the first non pending item */ - item = context->events_queue->tail; - while (item) - { - ClutterEventPrivate *event = item->data; - - if (!(event->flags & CLUTTER_EVENT_PENDING)) - { - g_queue_remove (context->events_queue, event); - - return (ClutterEvent *) event; - } - - item = item->prev; - } - - return NULL; + return g_queue_pop_tail (context->events_queue); } /** @@ -467,26 +447,16 @@ ClutterEvent * clutter_event_peek (void) { ClutterMainContext *context = clutter_context_get_default (); - GList *item; - if (!context->events_queue) + g_return_val_if_fail (context != NULL, NULL); + + if (context->events_queue == NULL) return NULL; if (g_queue_is_empty (context->events_queue)) return NULL; - /* find the first non pending item */ - item = context->events_queue->tail; - while (item) - { - ClutterEventPrivate *event = item->data; - if (!(event->flags & CLUTTER_EVENT_PENDING)) - return (ClutterEvent *) event; - - item = item->prev; - } - - return NULL; + return g_queue_peek_tail (context->events_queue); } /** @@ -502,8 +472,8 @@ clutter_event_put (ClutterEvent *event) { ClutterMainContext *context = clutter_context_get_default (); - g_return_if_fail (event != NULL); - g_return_if_fail (context->events_queue != NULL); + /* FIXME: check queue is valid */ + g_return_if_fail (context != NULL); g_queue_push_head (context->events_queue, clutter_event_copy (event)); } @@ -521,28 +491,13 @@ gboolean clutter_events_pending (void) { ClutterMainContext *context = clutter_context_get_default (); - GList *item; g_return_val_if_fail (context != NULL, FALSE); if (!context->events_queue) return FALSE; - if (g_queue_is_empty (context->events_queue)) - return FALSE; - - /* find the first non pending item */ - item = context->events_queue->tail; - while (item) - { - ClutterEventPrivate *event = item->data; - if (!(event->flags & CLUTTER_EVENT_PENDING)) - return TRUE; - - item = item->prev; - } - - return FALSE; + return g_queue_is_empty (context->events_queue) == FALSE; } /* Backend helpers (private) */ @@ -585,10 +540,10 @@ _clutter_event_button_generate (ClutterBackend *backend, button_x[0] = button_x[1] = 0; button_y[0] = button_y[1] = 0; } - else if ((event->button.time < (button_click_time[0] + double_click_time)) - && (event->button.button == button_number[0]) - && (ABS (event->button.x - button_x[0]) <= double_click_distance) - && (ABS (event->button.y - button_y[0]) <= double_click_distance)) + else if ((event->button.time < (button_click_time[0] + double_click_time)) && + (event->button.button == button_number[0]) && + (ABS (event->button.x - button_x[0]) <= double_click_distance) && + (ABS (event->button.y - button_y[0]) <= double_click_distance)) { synthesize_click (backend, event, 2); diff --git a/clutter/clutter-private.h b/clutter/clutter-private.h index b97023ba9..ac42da470 100644 --- a/clutter/clutter-private.h +++ b/clutter/clutter-private.h @@ -61,25 +61,7 @@ typedef enum { CLUTTER_PICK_ALL } ClutterPickMode; -typedef enum { - /* this flag is set when an event has been put on the queue but still - * needs processing; the event queue must ignore every event with this - * flag set - */ - CLUTTER_EVENT_PENDING = 1 << 0 -} ClutterEventFlags; - -typedef struct _ClutterEventPrivate ClutterEventPrivate; -typedef struct _ClutterMainContext ClutterMainContext; - -/* Private structure, to be used for extending ClutterEvent without - * exposing new members and breaking compatibility. - */ -struct _ClutterEventPrivate -{ - ClutterEvent event; - guint flags; -}; +typedef struct _ClutterMainContext ClutterMainContext; struct _ClutterMainContext { diff --git a/clutter/eglx/clutter-event-egl.c b/clutter/eglx/clutter-event-egl.c index afc97dd4c..59843cfa4 100644 --- a/clutter/eglx/clutter-event-egl.c +++ b/clutter/eglx/clutter-event-egl.c @@ -295,30 +295,25 @@ static void events_queue (ClutterBackend *backend) { ClutterBackendEGL *backend_egl = CLUTTER_BACKEND_EGL (backend); - Display *xdisplay = backend_egl->xdpy; + ClutterEvent *event; XEvent xevent; ClutterMainContext *clutter_context; clutter_context = clutter_context_get_default (); + Display *xdisplay = backend_egl->xdpy; + while (!clutter_events_pending () && XPending (xdisplay)) { - ClutterEvent *event; - XNextEvent (xdisplay, &xevent); event = clutter_event_new (CLUTTER_NOTHING); - ((ClutterEventPrivate *) event)->flags |= CLUTTER_EVENT_PENDING; - - g_queue_push_head (clutter_context->events_queue, event); - if (clutter_event_translate (backend, event, &xevent)) { - ((ClutterEventPrivate *) event)->flags &= ~CLUTTER_EVENT_PENDING; + g_queue_push_head (clutter_context->events_queue, event); } else { - g_queue_remove (clutter_context->events_queue, event); clutter_event_free (event); } } diff --git a/clutter/glx/clutter-event-glx.c b/clutter/glx/clutter-event-glx.c index dc09342c5..86366019d 100644 --- a/clutter/glx/clutter-event-glx.c +++ b/clutter/glx/clutter-event-glx.c @@ -517,6 +517,7 @@ static void events_queue (ClutterBackend *backend) { ClutterBackendGLX *backend_glx = CLUTTER_BACKEND_GLX (backend); + ClutterEvent *event; Display *xdisplay = backend_glx->xdpy; XEvent xevent; ClutterMainContext *clutter_context; @@ -525,27 +526,17 @@ events_queue (ClutterBackend *backend) while (!clutter_events_pending () && XPending (xdisplay)) { - ClutterEvent *event; - XNextEvent (xdisplay, &xevent); event = clutter_event_new (CLUTTER_NOTHING); - /* mark the event as pending and push it so that event_translate() - * can put events on the queue without tampering with the ordering - */ - ((ClutterEventPrivate *) event)->flags |= CLUTTER_EVENT_PENDING; - g_queue_push_head (clutter_context->events_queue, event); - if (event_translate (backend, event, &xevent)) { - /* translation successful, the event is done */ - ((ClutterEventPrivate *) event)->flags &= ~CLUTTER_EVENT_PENDING; + /* push directly here to avoid copy of queue_put */ + g_queue_push_head (clutter_context->events_queue, event); } else { - /* remove the event from the queue */ - g_queue_remove (clutter_context->events_queue, event); clutter_event_free (event); } } diff --git a/clutter/sdl/clutter-event-sdl.c b/clutter/sdl/clutter-event-sdl.c index 388fa38ef..f9c05e694 100644 --- a/clutter/sdl/clutter-event-sdl.c +++ b/clutter/sdl/clutter-event-sdl.c @@ -326,17 +326,13 @@ clutter_event_dispatch (GSource *source, { event = clutter_event_new (CLUTTER_NOTHING); - ((ClutterEventPrivate *) event)->flags |= CLUTTER_EVENT_PENDING; - - g_queue_push_head (clutter_context->events_queue, event); - if (event_translate (backend, event, &sdl_event)) { - ((ClutterEventPrivate *) event)->flags &= ~CLUTTER_EVENT_PENDING; - } + /* push directly here to avoid copy of queue_put */ + g_queue_push_head (clutter_context->events_queue, event); + } else { - g_queue_remove (clutter_context->events_queue, event); clutter_event_free (event); } } @@ -346,7 +342,7 @@ clutter_event_dispatch (GSource *source, if (event) { - clutter_do_event (event); + clutter_do_event(event); clutter_event_free (event); }