2006-06-05 Matthew Allum <mallum@openedhand.com>

* clutter/clutter-event.h:
        Remove send_event field. Clutter shouldn't need it.

        * clutter/clutter-main.c: (clutter_dispatch_x_event):
        Dont malloc a new clutter event for each xevent.

        * clutter/clutter-stage.h:
        * clutter/clutter-stage.c: (clutter_stage_class_init),
        (clutter_stage_get_default):
        Dont ref stage from clutter_stage_get_default.

        * examples/super-oh.c: (main):
        Remove some now uneeded debug g_prints
This commit is contained in:
Matthew Allum 2006-06-05 21:44:13 +00:00
parent f6fe9e7412
commit 7806e409fb
6 changed files with 47 additions and 39 deletions

View File

@ -1,3 +1,19 @@
2006-06-05 Matthew Allum <mallum@openedhand.com>
* clutter/clutter-event.h:
Remove send_event field. Clutter shouldn't need it.
* clutter/clutter-main.c: (clutter_dispatch_x_event):
Dont malloc a new clutter event for each xevent.
* clutter/clutter-stage.h:
* clutter/clutter-stage.c: (clutter_stage_class_init),
(clutter_stage_get_default):
Dont ref stage from clutter_stage_get_default.
* examples/super-oh.c: (main):
Remove some now uneeded debug g_prints
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:

View File

@ -67,7 +67,6 @@ typedef struct _ClutterInputDevice ClutterInputDevice;
struct _ClutterAnyEvent
{
ClutterEventType type;
guint8 send_event : 1;
};
struct _ClutterKeyEvent

View File

@ -151,13 +151,10 @@ clutter_dispatch_x_event (XEvent *xevent,
gpointer data)
{
ClutterMainContext *ctx = CLUTTER_CONTEXT ();
ClutterEvent *event;
ClutterEvent event;
ClutterStage *stage = ctx->stage;
gboolean emit_input_event = FALSE;
event = clutter_event_new (CLUTTER_NOTHING);
event->any.send_event = xevent->xany.send_event ? TRUE : FALSE;
switch (xevent->type)
{
case Expose:
@ -177,36 +174,35 @@ clutter_dispatch_x_event (XEvent *xevent,
}
break;
case KeyPress:
translate_key_event ((ClutterKeyEvent *) event, xevent);
g_signal_emit_by_name (stage, "key-press-event", event);
translate_key_event ((ClutterKeyEvent *) &event, xevent);
g_signal_emit_by_name (stage, "key-press-event", &event);
emit_input_event = TRUE;
break;
case KeyRelease:
translate_key_event ((ClutterKeyEvent *) event, xevent);
g_signal_emit_by_name (stage, "key-release-event", event);
translate_key_event ((ClutterKeyEvent *) &event, xevent);
g_signal_emit_by_name (stage, "key-release-event", &event);
emit_input_event = TRUE;
break;
case ButtonPress:
translate_button_event ((ClutterButtonEvent *) event, xevent);
g_signal_emit_by_name (stage, "button-press-event", event);
translate_button_event ((ClutterButtonEvent *) &event, xevent);
g_signal_emit_by_name (stage, "button-press-event", &event);
emit_input_event = TRUE;
break;
case ButtonRelease:
translate_button_event ((ClutterButtonEvent *) event, xevent);
g_signal_emit_by_name (stage, "button-release-event", event);
translate_button_event ((ClutterButtonEvent *) &event, xevent);
g_signal_emit_by_name (stage, "button-release-event", &event);
emit_input_event = TRUE;
break;
case MotionNotify:
translate_motion_event ((ClutterMotionEvent *) event, xevent);
g_signal_emit_by_name (stage, "motion-event", event);
translate_motion_event ((ClutterMotionEvent *) &event, xevent);
g_signal_emit_by_name (stage, "motion-event", &event);
emit_input_event = TRUE;
break;
}
if (emit_input_event)
g_signal_emit_by_name (stage, "input-event", event);
g_signal_emit_by_name (stage, "input-event", &event);
clutter_event_free (event);
}
static void
@ -481,7 +477,7 @@ clutter_gl_context_set_indirect (gboolean indirect)
}
ClutterMainContext *
ClutterMainContext*
clutter_context_get_default (void)
{
if (!ClutterCntx)

View File

@ -564,6 +564,7 @@ clutter_stage_class_init (ClutterStageClass *klass)
clutter_marshal_VOID__BOXED,
G_TYPE_NONE, 1,
CLUTTER_TYPE_EVENT);
stage_signals[BUTTON_PRESS_EVENT] =
g_signal_new ("button-press-event",
G_TYPE_FROM_CLASS (gobject_class),
@ -660,14 +661,22 @@ clutter_stage_get_default (void)
else
{
retval = CLUTTER_ELEMENT (stage_singleton);
g_object_ref (retval);
/* We dont ref for now as its assumed there will always be
* a stage and no real support for multiple stages. Non
* reffing makes API slightly simpler and allows for things
* like CLUTTER_STAGE_WIDTH() work nicely.
*
* In future if multiple stage support is added probably
* add a clutter-stage-manager class that would manage
* multiple instances.
* g_object_ref (retval);
*/
}
return retval;
}
/**
* clutter_stage_get_xwindow
* @stage: A #ClutterStage

View File

@ -42,10 +42,10 @@ G_BEGIN_DECLS
#define CLUTTER_TYPE_STAGE clutter_stage_get_type()
#define CLUTTER_STAGE_WIDTH() \
clutter_element_get_width(CLUTTER_ELEMENT(clutter_stage()))
clutter_element_get_width(CLUTTER_ELEMENT(clutter_stage_get_default()))
#define CLUTTER_STAGE_HEIGHT() \
clutter_element_get_height(CLUTTER_ELEMENT(clutter_stage()))
clutter_element_get_height(CLUTTER_ELEMENT(clutter_stage_get_default()))
#define CLUTTER_STAGE(obj) \
@ -110,19 +110,18 @@ GType clutter_stage_get_type (void);
ClutterElement *clutter_stage_get_default (void);
/* FIXME: no need for below to take stage arg ?
* convert to defines also ?
*/
Window clutter_stage_get_xwindow (ClutterStage *stage);
void clutter_stage_set_color (ClutterStage *stage,
const ClutterColor *color);
void clutter_stage_get_color (ClutterStage *stage,
ClutterColor *color);
ClutterElement *clutter_stage_get_element_at_pos (ClutterStage *stage,
gint x,
gint y);
GdkPixbuf * clutter_stage_snapshot (ClutterStage *stage,
gint x,
gint y,

View File

@ -115,20 +115,9 @@ main (int argc, char *argv[])
clutter_element_set_size (stage, WINWIDTH, WINHEIGHT);
/* and its background color */
g_print ("before clutter_stage_set_color: (%3d, %3d, %3d, %3d)\n",
stage_color.red,
stage_color.green,
stage_color.blue,
stage_color.alpha);
clutter_stage_set_color (CLUTTER_STAGE (stage),
&stage_color);
clutter_stage_get_color (CLUTTER_STAGE (stage),
&stage_color);
g_print ("after clutter_stage_get_color: (%3d, %3d, %3d, %3d)\n",
stage_color.red,
stage_color.green,
stage_color.blue,
stage_color.alpha);
oh = g_new(SuperOH, 1);