[Swfdec] 5 commits - libswfdec/swfdec_as_context.c libswfdec/swfdec_keys.h libswfdec/swfdec_movie.c libswfdec/swfdec_movie.h libswfdec/swfdec_sprite_movie_as.c player/swfdebug.c player/swfdec_debug_movies.c player/swfdec_debug_movies.h test/trace
Benjamin Otte
company at kemper.freedesktop.org
Tue Aug 7 14:20:48 PDT 2007
libswfdec/swfdec_as_context.c | 14 +-
libswfdec/swfdec_keys.h | 2
libswfdec/swfdec_movie.c | 70 ++++++++++-
libswfdec/swfdec_movie.h | 2
libswfdec/swfdec_sprite_movie_as.c | 12 --
player/swfdebug.c | 6 -
player/swfdec_debug_movies.c | 221 +++++++++++++++++++------------------
player/swfdec_debug_movies.h | 5
test/trace/swfdec_interaction.c | 22 ++-
test/trace/swfdec_interaction.h | 5
10 files changed, 222 insertions(+), 137 deletions(-)
New commits:
diff-tree efc9ce9124f28dfad6858a83fc2fdc749ab4ee2c (from 55ac6dbcb2e4f23ed2be981e19ab4a4b9cd99069)
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Aug 7 23:19:52 2007 +0200
reenable movie list
diff --git a/player/swfdebug.c b/player/swfdebug.c
index fbae7ac..2f52401 100644
--- a/player/swfdebug.c
+++ b/player/swfdebug.c
@@ -228,9 +228,9 @@ create_movieview (SwfdecPlayer *player)
gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
- renderer = gtk_cell_renderer_toggle_new ();
- column = gtk_tree_view_column_new_with_attributes ("V", renderer,
- "active", SWFDEC_DEBUG_MOVIES_COLUMN_VISIBLE, NULL);
+ renderer = gtk_cell_renderer_text_new ();
+ column = gtk_tree_view_column_new_with_attributes ("Depth", renderer,
+ "text", SWFDEC_DEBUG_MOVIES_COLUMN_DEPTH, NULL);
gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
diff --git a/player/swfdec_debug_movies.c b/player/swfdec_debug_movies.c
index 252277c..331b4c9 100644
--- a/player/swfdec_debug_movies.c
+++ b/player/swfdec_debug_movies.c
@@ -57,8 +57,8 @@ swfdec_debug_movies_get_column_type (Gtk
return G_TYPE_POINTER;
case SWFDEC_DEBUG_MOVIES_COLUMN_NAME:
return G_TYPE_STRING;
- case SWFDEC_DEBUG_MOVIES_COLUMN_VISIBLE:
- return G_TYPE_BOOLEAN;
+ case SWFDEC_DEBUG_MOVIES_COLUMN_DEPTH:
+ return G_TYPE_INT;
case SWFDEC_DEBUG_MOVIES_COLUMN_TYPE:
return G_TYPE_STRING;
default:
@@ -72,63 +72,35 @@ static gboolean
swfdec_debug_movies_get_iter (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreePath *path)
{
SwfdecDebugMovies *movies = SWFDEC_DEBUG_MOVIES (tree_model);
- guint depth;
+ GNode *node;
+ guint i, depth;
int *indices;
- GList *walk;
- SwfdecMovie *movie;
REPORT;
depth = gtk_tree_path_get_depth (path);
indices = gtk_tree_path_get_indices (path);
if (indices == NULL)
return FALSE;
- walk = g_list_nth (movies->player->roots, *indices);
- if (!walk)
- return FALSE;
- movie = walk->data;
- indices++;
- depth--;
- for (; depth > 0; depth--) {
- walk = g_list_nth (movie->list, *indices);
- if (!walk)
+ node = movies->root;
+ for (i = 0; i < depth; i++) {
+ node = g_node_nth_child (node, indices[i]);
+ if (node == NULL)
return FALSE;
- movie = walk->data;
- indices++;
}
- iter->user_data = movie;
+ iter->user_data = node;
+ iter->stamp = movies->stamp;
return TRUE;
}
-static gint
-my_g_list_is_nth (GList *list, gpointer data)
-{
- gint count;
-
- count = 0;
- for (; list; list = list->next) {
- if (list->data == data)
- return count;
- count++;
- }
- return -1;
-}
-
static GtkTreePath *
-swfdec_debug_movies_movie_to_path (SwfdecMovie *movie)
+swfdec_debug_movies_node_to_path (GNode *node)
{
GtkTreePath *path;
- gint i;
- if (movie->parent) {
- i = my_g_list_is_nth (movie->parent->list, movie);
- g_assert (i >= 0);
- path = swfdec_debug_movies_movie_to_path (movie->parent);
- gtk_tree_path_append_index (path, i);
- } else {
- i = my_g_list_is_nth (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context)->roots, movie);
- g_assert (i >= 0);
- path = gtk_tree_path_new ();
- gtk_tree_path_append_index (path, i);
+ path = gtk_tree_path_new ();
+ while (node->parent != NULL) {
+ gtk_tree_path_prepend_index (path, g_node_child_position (node->parent, node));
+ node = node->parent;
}
return path;
}
@@ -137,14 +109,14 @@ static GtkTreePath *
swfdec_debug_movies_get_path (GtkTreeModel *tree_model, GtkTreeIter *iter)
{
REPORT;
- return swfdec_debug_movies_movie_to_path (iter->user_data);
+ return swfdec_debug_movies_node_to_path (iter->user_data);
}
static void
swfdec_debug_movies_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter,
gint column, GValue *value)
{
- SwfdecMovie *movie = iter->user_data;
+ SwfdecMovie *movie = ((GNode *) iter->user_data)->data;
REPORT;
switch (column) {
@@ -154,11 +126,14 @@ swfdec_debug_movies_get_value (GtkTreeMo
return;
case SWFDEC_DEBUG_MOVIES_COLUMN_NAME:
g_value_init (value, G_TYPE_STRING);
- g_value_set_string (value, movie->name);
+ if (movie->name[0])
+ g_value_set_string (value, movie->name);
+ else
+ g_value_set_string (value, movie->original_name);
return;
- case SWFDEC_DEBUG_MOVIES_COLUMN_VISIBLE:
- g_value_init (value, G_TYPE_BOOLEAN);
- g_value_set_boolean (value, movie->visible);
+ case SWFDEC_DEBUG_MOVIES_COLUMN_DEPTH:
+ g_value_init (value, G_TYPE_INT);
+ g_value_set_int (value, movie->depth);
return;
case SWFDEC_DEBUG_MOVIES_COLUMN_TYPE:
g_value_init (value, G_TYPE_STRING);
@@ -174,40 +149,31 @@ swfdec_debug_movies_get_value (GtkTreeMo
static gboolean
swfdec_debug_movies_iter_next (GtkTreeModel *tree_model, GtkTreeIter *iter)
{
- GList *list;
- SwfdecMovie *movie = iter->user_data;
+ GNode *node;
REPORT;
- if (movie->parent) {
- list = movie->parent->list;
- } else {
- list = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context)->roots;
- }
- list = g_list_find (list, movie);
- g_assert (list);
- list = list->next;
- if (list == NULL)
+ node = iter->user_data;
+ node = node->next;
+ if (node == NULL)
return FALSE;
- iter->user_data = list->data;
+ iter->user_data = node;
return TRUE;
}
static gboolean
swfdec_debug_movies_iter_children (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent)
{
- GList *list;
+ GNode *node;
REPORT;
if (parent) {
- SwfdecMovie *movie = parent->user_data;
- list = movie->list;
+ node = parent->user_data;
} else {
- SwfdecPlayer *player = SWFDEC_DEBUG_MOVIES (tree_model)->player;
- list = player->roots;
+ node = SWFDEC_DEBUG_MOVIES (tree_model)->root;
}
- if (list == NULL)
+ if (node->children == NULL)
return FALSE;
- iter->user_data = list->data;
+ iter->user_data = node->children;
return TRUE;
}
@@ -223,49 +189,47 @@ swfdec_debug_movies_iter_has_child (GtkT
static gint
swfdec_debug_movies_iter_n_children (GtkTreeModel *tree_model, GtkTreeIter *iter)
{
- GList *list;
+ GNode *node;
REPORT;
if (iter) {
- SwfdecMovie *movie = iter->user_data;
- list = movie->list;
+ node = iter->user_data;
} else {
- SwfdecPlayer *player = SWFDEC_DEBUG_MOVIES (tree_model)->player;
- list = player->roots;
+ node = SWFDEC_DEBUG_MOVIES (tree_model)->root;
}
- return g_list_length (list);
+ return g_node_n_children (node);
}
static gboolean
swfdec_debug_movies_iter_nth_child (GtkTreeModel *tree_model, GtkTreeIter *iter,
GtkTreeIter *parent, gint n)
{
- GList *list;
+ GNode *node;
REPORT;
if (parent) {
- SwfdecMovie *movie = parent->user_data;
- list = movie->list;
+ node = parent->user_data;
} else {
- SwfdecPlayer *player = SWFDEC_DEBUG_MOVIES (tree_model)->player;
- list = player->roots;
+ node = SWFDEC_DEBUG_MOVIES (tree_model)->root;
}
- list = g_list_nth (list, n);
- if (list == NULL)
+ node = g_node_nth_child (node, n);
+ if (node == NULL)
return FALSE;
- iter->user_data = list->data;
+ iter->user_data = node;
return TRUE;
}
static gboolean
swfdec_debug_movies_iter_parent (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *child)
{
- SwfdecMovie *movie = SWFDEC_MOVIE (child->user_data);
+ GNode *node;
REPORT;
- if (movie->parent == NULL)
+ node = child->user_data;
+ node = node->parent;
+ if (node->parent == NULL)
return FALSE;
- iter->user_data = movie->parent;
+ iter->user_data = node;
return TRUE;
}
@@ -291,37 +255,81 @@ swfdec_debug_movies_tree_model_init (Gtk
G_DEFINE_TYPE_WITH_CODE (SwfdecDebugMovies, swfdec_debug_movies, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, swfdec_debug_movies_tree_model_init))
+static int
+swfdec_debug_movies_get_index (GNode *parent, GNode *new)
+{
+ GNode *walk;
+ int i = 0;
+
+ for (walk = parent->children; walk; walk = walk->next) {
+ if (walk == new)
+ continue;
+ if (swfdec_movie_compare_depths (walk->data, new->data) < 0) {
+ i++;
+ continue;
+ }
+ break;
+ }
+ return i;
+}
+
static void
swfdec_debug_movies_added (SwfdecPlayer *player, SwfdecMovie *movie, SwfdecDebugMovies *movies)
{
- GtkTreePath *path = swfdec_debug_movies_movie_to_path (movie);
+ GtkTreePath *path;
GtkTreeIter iter;
+ GNode *node, *new;
+ int pos;
- iter.user_data = movie;
+ if (movie->parent) {
+ node = g_hash_table_lookup (movies->nodes, movie->parent);
+ g_assert (node);
+ } else {
+ node = movies->root;
+ }
+ new = g_node_new (movie);
+ g_hash_table_insert (movies->nodes, movie, new);
+ pos = swfdec_debug_movies_get_index (node, new);
+ g_node_insert (node, pos, new);
+ movies->stamp++;
+ iter.stamp = movies->stamp;
+ iter.user_data = new;
+ path = swfdec_debug_movies_node_to_path (new);
gtk_tree_model_row_inserted (GTK_TREE_MODEL (movies), path, &iter);
gtk_tree_path_free (path);
}
static void
+swfdec_debug_movies_movie_notify (SwfdecMovie *movie, GParamSpec *pspec, SwfdecDebugMovies *movies)
+{
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ GNode *node;
+
+ node = g_hash_table_lookup (movies->nodes, movie);
+ if (g_str_equal (pspec->name, "depth")) {
+ /* reorder when depth changes */
+ g_printerr ("FIXME: implement depth changes\n");
+ }
+ iter.stamp = movies->stamp;
+ iter.user_data = node;
+ path = swfdec_debug_movies_node_to_path (node);
+ gtk_tree_model_row_changed (GTK_TREE_MODEL (movies), path, &iter);
+ gtk_tree_path_free (path);
+}
+
+static void
swfdec_debug_movies_removed (SwfdecPlayer *player, SwfdecMovie *movie, SwfdecDebugMovies *movies)
{
- GList *list;
+ GNode *node;
GtkTreePath *path;
- int i = 0;
- if (movie->parent) {
- path = swfdec_debug_movies_movie_to_path (movie->parent);
- list = movie->parent->list;
- } else {
- path = gtk_tree_path_new ();
- list = player->roots;
- }
- for (;list; list = list->next) {
- if (swfdec_movie_compare_depths (list->data, movie) >= 0)
- break;
- i++;
- }
- gtk_tree_path_append_index (path, i);
+ node = g_hash_table_lookup (movies->nodes, movie);
+ g_hash_table_remove (movies->nodes, movie);
+ g_signal_handlers_disconnect_by_func (movie, swfdec_debug_movies_movie_notify, movies);
+ path = swfdec_debug_movies_node_to_path (node);
+ g_assert (g_node_n_children (node) == 0);
+ g_node_destroy (node);
gtk_tree_model_row_deleted (GTK_TREE_MODEL (movies), path);
gtk_tree_path_free (path);
}
@@ -334,6 +342,9 @@ swfdec_debug_movies_dispose (GObject *ob
g_signal_handlers_disconnect_by_func (movies->player, swfdec_debug_movies_removed, movies);
g_signal_handlers_disconnect_by_func (movies->player, swfdec_debug_movies_added, movies);
g_object_unref (movies->player);
+ g_assert (g_node_n_children (movies->root) == 0);
+ g_node_destroy (movies->root);
+ g_hash_table_destroy (movies->nodes);
G_OBJECT_CLASS (swfdec_debug_movies_parent_class)->dispose (object);
}
@@ -347,8 +358,10 @@ swfdec_debug_movies_class_init (SwfdecDe
}
static void
-swfdec_debug_movies_init (SwfdecDebugMovies *token)
+swfdec_debug_movies_init (SwfdecDebugMovies *movies)
{
+ movies->root = g_node_new (NULL);
+ movies->nodes = g_hash_table_new (g_direct_hash, g_direct_equal);
}
SwfdecDebugMovies *
@@ -359,7 +372,7 @@ swfdec_debug_movies_new (SwfdecPlayer *p
movies = g_object_new (SWFDEC_TYPE_DEBUG_MOVIES, NULL);
movies->player = player;
g_object_ref (player);
- if (SWFDEC_IS_DEBUGGER (player) && FALSE) {
+ if (SWFDEC_IS_DEBUGGER (player)) {
g_signal_connect (player, "movie-added", G_CALLBACK (swfdec_debug_movies_added), movies);
g_signal_connect (player, "movie-removed", G_CALLBACK (swfdec_debug_movies_removed), movies);
}
diff --git a/player/swfdec_debug_movies.h b/player/swfdec_debug_movies.h
index 66d10eb..35e92da 100644
--- a/player/swfdec_debug_movies.h
+++ b/player/swfdec_debug_movies.h
@@ -27,7 +27,7 @@ G_BEGIN_DECLS
enum {
SWFDEC_DEBUG_MOVIES_COLUMN_MOVIE,
SWFDEC_DEBUG_MOVIES_COLUMN_NAME,
- SWFDEC_DEBUG_MOVIES_COLUMN_VISIBLE,
+ SWFDEC_DEBUG_MOVIES_COLUMN_DEPTH,
SWFDEC_DEBUG_MOVIES_COLUMN_TYPE,
/* add more */
SWFDEC_DEBUG_MOVIES_N_COLUMNS
@@ -47,6 +47,9 @@ struct _SwfdecDebugMovies
GObject object;
SwfdecPlayer * player; /* the video we play */
+ GNode * root; /* the root node containing all the movies */
+ int stamp; /* to validate tree iters */
+ GHashTable * nodes; /* movies => node fast lookup table */
};
struct _SwfdecDebugMoviesClass
diff-tree 55ac6dbcb2e4f23ed2be981e19ab4a4b9cd99069 (from 3b8f78e8ef27636331d6c80f6cb0fcdbbb3fd3e2)
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Aug 7 15:06:04 2007 +0200
make depth a movie property
This way we can use it inside our debugger
diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c
index a696967..42444b7 100644
--- a/libswfdec/swfdec_movie.c
+++ b/libswfdec/swfdec_movie.c
@@ -43,6 +43,11 @@
/*** MOVIE ***/
+enum {
+ PROP_0,
+ PROP_DEPTH
+};
+
G_DEFINE_ABSTRACT_TYPE (SwfdecMovie, swfdec_movie, SWFDEC_TYPE_AS_OBJECT)
static void
@@ -256,9 +261,7 @@ swfdec_movie_do_remove (SwfdecMovie *mov
if (player->mouse_drag == movie)
player->mouse_drag = NULL;
swfdec_movie_invalidate (movie);
- movie->depth = -16385 - movie->depth; /* don't ask me why... */
- if (movie->parent)
- movie->parent->list = g_list_sort (movie->parent->list, swfdec_movie_compare_depths);
+ swfdec_movie_set_depth (movie, -16385 - movie->depth); /* don't ask me why... */
if (SWFDEC_IS_SPRITE_MOVIE (movie))
return !swfdec_movie_queue_script (movie, SWFDEC_EVENT_UNLOAD);
@@ -739,6 +742,38 @@ swfdec_movie_render (SwfdecMovie *movie,
}
static void
+swfdec_movie_get_property (GObject *object, guint param_id, GValue *value,
+ GParamSpec * pspec)
+{
+ SwfdecMovie *movie = SWFDEC_MOVIE (object);
+
+ switch (param_id) {
+ case PROP_DEPTH:
+ g_value_set_int (value, movie->depth);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+swfdec_movie_set_property (GObject *object, guint param_id, const GValue *value,
+ GParamSpec * pspec)
+{
+ SwfdecMovie *movie = SWFDEC_MOVIE (object);
+
+ switch (param_id) {
+ case PROP_DEPTH:
+ movie->depth = g_value_get_int (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
swfdec_movie_dispose (GObject *object)
{
SwfdecMovie * movie = SWFDEC_MOVIE (object);
@@ -873,12 +908,18 @@ swfdec_movie_class_init (SwfdecMovieClas
SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (movie_class);
object_class->dispose = swfdec_movie_dispose;
+ object_class->get_property = swfdec_movie_get_property;
+ object_class->set_property = swfdec_movie_set_property;
asobject_class->mark = swfdec_movie_mark;
asobject_class->get = swfdec_movie_get_variable;
asobject_class->set = swfdec_movie_set_variable;
asobject_class->debug = swfdec_movie_get_debug;
+ g_object_class_install_property (object_class, PROP_DEPTH,
+ g_param_spec_int ("depth", "depth", "z order inside the parent",
+ G_MININT, G_MAXINT, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
movie_class->iterate_end = swfdec_movie_iterate_end;
}
@@ -894,6 +935,25 @@ swfdec_movie_initialize (SwfdecMovie *mo
klass->init_movie (movie);
}
+void
+swfdec_movie_set_depth (SwfdecMovie *movie, int depth)
+{
+ g_return_if_fail (SWFDEC_IS_MOVIE (movie));
+
+ if (movie->depth == depth)
+ return;
+
+ swfdec_movie_invalidate (movie);
+ movie->depth = depth;
+ if (movie->parent) {
+ movie->parent->list = g_list_sort (movie->parent->list, swfdec_movie_compare_depths);
+ } else {
+ SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
+ player->roots = g_list_sort (player->roots, swfdec_movie_compare_depths);
+ }
+ g_object_notify (G_OBJECT (movie), "depth");
+}
+
/**
* swfdec_movie_new:
* @player: a #SwfdecPlayer
@@ -925,13 +985,14 @@ swfdec_movie_new (SwfdecPlayer *player,
/* create the right movie */
if (graphic == NULL) {
- movie = g_object_new (SWFDEC_TYPE_SPRITE_MOVIE, NULL);
+ movie = g_object_new (SWFDEC_TYPE_SPRITE_MOVIE, "depth", depth, NULL);
size = sizeof (SwfdecSpriteMovie);
} else {
SwfdecGraphicClass *klass = SWFDEC_GRAPHIC_GET_CLASS (graphic);
g_return_val_if_fail (klass->create_movie != NULL, NULL);
movie = klass->create_movie (graphic, &size);
movie->graphic = g_object_ref (graphic);
+ movie->depth = depth;
}
/* register it to the VM */
/* FIXME: It'd be nice if we'd not overuse memory here when calling this function from a script */
@@ -941,7 +1002,6 @@ swfdec_movie_new (SwfdecPlayer *player,
g_object_ref (movie);
swfdec_as_object_add (SWFDEC_AS_OBJECT (movie), SWFDEC_AS_CONTEXT (player), size);
/* set essential properties */
- movie->depth = depth;
movie->parent = parent;
if (parent) {
movie->swf = g_object_ref (parent->swf);
diff --git a/libswfdec/swfdec_movie.h b/libswfdec/swfdec_movie.h
index 47d46ab..1e83f6b 100644
--- a/libswfdec/swfdec_movie.h
+++ b/libswfdec/swfdec_movie.h
@@ -192,6 +192,8 @@ void swfdec_movie_local_to_global (Swfd
void swfdec_movie_global_to_local (SwfdecMovie * movie,
double * x,
double * y);
+void swfdec_movie_set_depth (SwfdecMovie * movie,
+ int depth);
void swfdec_movie_get_mouse (SwfdecMovie * movie,
double * x,
double * y);
diff --git a/libswfdec/swfdec_sprite_movie_as.c b/libswfdec/swfdec_sprite_movie_as.c
index bef0690..f18597c 100644
--- a/libswfdec/swfdec_sprite_movie_as.c
+++ b/libswfdec/swfdec_sprite_movie_as.c
@@ -257,20 +257,14 @@ swfdec_sprite_movie_swapDepths (SwfdecAs
if (!SWFDEC_IS_MOVIE (other) ||
other->parent != movie->parent)
return;
- swfdec_movie_invalidate (other);
depth = other->depth;
- other->depth = movie->depth;
} else {
depth = swfdec_as_value_to_integer (cx, &argv[0]);
other = swfdec_movie_find (movie->parent, depth);
- if (other) {
- swfdec_movie_invalidate (other);
- other->depth = movie->depth;
- }
}
- swfdec_movie_invalidate (movie);
- movie->depth = depth;
- movie->parent->list = g_list_sort (movie->parent->list, swfdec_movie_compare_depths);
+ if (other)
+ swfdec_movie_set_depth (other, movie->depth);
+ swfdec_movie_set_depth (movie, depth);
}
static void
diff-tree 3b8f78e8ef27636331d6c80f6cb0fcdbbb3fd3e2 (from c8374ee8fedbcdd2134d1c711bd1f57bd16a59c1)
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Aug 7 13:37:14 2007 +0200
update to new key press API
diff --git a/test/trace/swfdec_interaction.c b/test/trace/swfdec_interaction.c
index 914f8ff..e9e97bd 100644
--- a/test/trace/swfdec_interaction.c
+++ b/test/trace/swfdec_interaction.c
@@ -81,12 +81,13 @@ swfdec_command_append_mouse (SwfdecInter
}
static void
-swfdec_command_append_key (SwfdecInteraction *inter, guint key, SwfdecCommandType type)
+swfdec_command_append_key (SwfdecInteraction *inter, SwfdecKey code, guint ascii, SwfdecCommandType type)
{
SwfdecCommand command;
command.command = type;
- command.args.key = key;
+ command.args.key.code = code;
+ command.args.key.ascii = ascii;
g_array_append_val (inter->commands, command);
}
@@ -159,20 +160,25 @@ swfdec_interaction_new (const char *data
swfdec_command_append_mouse (inter, inter->mouse_x, inter->mouse_y, 0);
break;
case SWFDEC_COMMAND_PRESS:
+ case SWFDEC_COMMAND_RELEASE:
+ j = token;
token = g_scanner_get_next_token (scanner);
if (token != G_TOKEN_INT) {
g_scanner_unexp_token (scanner, G_TOKEN_INT, NULL, NULL, NULL, NULL, TRUE);
goto error;
}
- swfdec_command_append_key (inter, scanner->value.v_int, SWFDEC_COMMAND_PRESS);
- break;
- case SWFDEC_COMMAND_RELEASE:
+ i = scanner->value.v_int;
+ if (i >= 256) {
+ g_scanner_unexp_token (scanner, G_TOKEN_INT, NULL, NULL, NULL, NULL, TRUE);
+ goto error;
+ }
+ /* FIXME: allow string here and convert first char */
token = g_scanner_get_next_token (scanner);
if (token != G_TOKEN_INT) {
g_scanner_unexp_token (scanner, G_TOKEN_INT, NULL, NULL, NULL, NULL, TRUE);
goto error;
}
- swfdec_command_append_key (inter, scanner->value.v_int, SWFDEC_COMMAND_RELEASE);
+ swfdec_command_append_key (inter, i, scanner->value.v_int, j);
break;
default:
g_scanner_unexp_token (scanner, SWFDEC_COMMAND_WAIT, NULL, NULL, NULL, NULL, TRUE);
@@ -244,10 +250,10 @@ swfdec_interaction_advance (SwfdecIntera
command->args.mouse.y, command->args.mouse.button);
break;
case SWFDEC_COMMAND_PRESS:
- swfdec_player_key_press (player, command->args.key);
+ swfdec_player_key_press (player, command->args.key.code, command->args.key.ascii);
break;
case SWFDEC_COMMAND_RELEASE:
- swfdec_player_key_release (player, command->args.key);
+ swfdec_player_key_release (player, command->args.key.code, command->args.key.ascii);
break;
case SWFDEC_COMMAND_UP:
case SWFDEC_COMMAND_DOWN:
diff --git a/test/trace/swfdec_interaction.h b/test/trace/swfdec_interaction.h
index 0258474..5b627de 100644
--- a/test/trace/swfdec_interaction.h
+++ b/test/trace/swfdec_interaction.h
@@ -49,7 +49,10 @@ struct _SwfdecCommand {
int button;
} mouse;
guint time;
- guint key;
+ struct {
+ SwfdecKey code;
+ guint ascii;
+ } key;
} args;
};
diff-tree c8374ee8fedbcdd2134d1c711bd1f57bd16a59c1 (from 58e0cd34b696f7a0b12bf25ef265d9aa51c9e35f)
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Aug 7 13:37:03 2007 +0200
this should have been an enum
diff --git a/libswfdec/swfdec_keys.h b/libswfdec/swfdec_keys.h
index 2a8b3e4..a97d5d0 100644
--- a/libswfdec/swfdec_keys.h
+++ b/libswfdec/swfdec_keys.h
@@ -20,7 +20,7 @@
#ifndef _SWFDEC_KEYS_H_
#define _SWFDEC_KEYS_H_
-enum {
+typedef enum {
SWFDEC_KEY_BACKSPACE = 8,
SWFDEC_KEY_TAB = 9,
SWFDEC_KEY_CLEAR = 12,
diff-tree 58e0cd34b696f7a0b12bf25ef265d9aa51c9e35f (from 7e10a396ba62a265cbc1bfb094e8d7146a796f5e)
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Aug 7 13:28:54 2007 +0200
return the target and not this when using getVariable ""
Also do something if not called from inside a frame
diff --git a/libswfdec/swfdec_as_context.c b/libswfdec/swfdec_as_context.c
index 0d4d513..49ec05e 100644
--- a/libswfdec/swfdec_as_context.c
+++ b/libswfdec/swfdec_as_context.c
@@ -879,7 +879,8 @@ swfdec_as_context_eval_get_property (Swf
return;
}
} else {
- SWFDEC_ERROR ("no frame in eval?");
+ SWFDEC_WARNING ("eval called without a frame");
+ swfdec_as_object_get_variable (cx->global, name, ret);
}
SWFDEC_AS_VALUE_SET_UNDEFINED (ret);
}
@@ -939,11 +940,14 @@ swfdec_as_context_eval_internal (SwfdecA
goto finish;
}
}
- if (obj == NULL && cx->frame) {
- swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (cx->frame), SWFDEC_AS_STR_this, &cur);
- } else {
- SWFDEC_AS_VALUE_SET_OBJECT (&cur, obj);
+ if (obj == NULL) {
+ if (cx->frame)
+ obj = cx->frame->target;
+ else
+ obj = cx->global;
}
+ g_assert (obj != NULL);
+ SWFDEC_AS_VALUE_SET_OBJECT (&cur, obj);
finish:
g_strfreev (varlist);
More information about the Swfdec
mailing list