diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 30 |
1 files changed, 29 insertions, 1 deletions
@@ -552,6 +552,7 @@ button_press_cb (GtkWidget *w, GdkEventButton *ev, sphinx_t *sphinx) static cairo_surface_t * _create_surface (void *closure, + cairo_content_t content, double width, double height) //csi_object_t *dictionary) { @@ -761,21 +762,44 @@ _destroy_surface (void *closure, GDK_THREADS_LEAVE (); } +static cairo_t * +_create_context (void *closure, + cairo_surface_t *surface) + //csi_object_t *dictionary) +{ + sphinx_t *sphinx = closure; + cairo_t *cr; + + cr = cairo_create (surface); + + GDK_THREADS_ENTER (); + + g_hash_table_insert (sphinx->contexts_ht, + cr, cairo_surface_reference (surface)); + + GDK_THREADS_LEAVE (); + + return cr; +} + static void _destroy_context (void *closure, void *cr) //csi_object_t *dictionary) { sphinx_t *sphinx = closure; + cairo_surface_t *surface; GDK_THREADS_ENTER (); + surface = g_hash_table_lookup (sphinx->contexts_ht, cr); if (sphinx->watch_contexts) { if (sphinx->view == NULL) sphinx->view = _create_surface_view (sphinx); - surface_view_set_surface (sphinx->view, cairo_get_target (cr)); + surface_view_set_surface (sphinx->view, surface); } + g_hash_table_remove (sphinx->contexts_ht, cr); if (sphinx->break_on_context_undef) sphinx_run_break (sphinx); @@ -900,12 +924,16 @@ sphinx_new (void) .closure = sphinx, .surface_create = _create_surface, .surface_destroy = _destroy_surface, + .context_create = _create_context, .context_destroy = _destroy_context, }; sphinx->csi = cairo_script_interpreter_create (); cairo_script_interpreter_install_hooks (sphinx->csi, &hooks); + sphinx->contexts_ht = g_hash_table_new_full (NULL, NULL, NULL, + (GDestroyNotify) cairo_surface_destroy); + sphinx->break_on_surface_undef = FALSE; sphinx->break_on_context_undef = FALSE; sphinx->watch_surfaces = FALSE; |