diff --git a/libc3/sequence.c b/libc3/sequence.c
index 2d02a0c..a50ea21 100644
--- a/libc3/sequence.c
+++ b/libc3/sequence.c
@@ -21,16 +21,20 @@ void sequence_clean (s_sequence *seq)
s_sequence * sequence_init (s_sequence *seq, f64 duration,
const s8 *title, f_sequence load,
- f_sequence render, f_sequence unload)
+ f_sequence render, f_sequence unload,
+ void *window)
{
+ s_sequence tmp = {0};
assert(seq);
- seq->dt = 0.0;
- seq->t = 0.0;
- seq->duration = duration;
- seq->title = title;
- seq->load = load;
- seq->render = render;
- seq->unload = unload;
- tag_init_void(&seq->tag);
+ tmp.dt = 0.0;
+ tmp.t = 0.0;
+ tmp.duration = duration;
+ tag_init_void(&tmp.tag);
+ tmp.title = title;
+ tmp.load = load;
+ tmp.render = render;
+ tmp.unload = unload;
+ tmp.window = window;
+ *seq = tmp;
return seq;
}
diff --git a/libc3/sequence.h b/libc3/sequence.h
index 1adf186..a869db2 100644
--- a/libc3/sequence.h
+++ b/libc3/sequence.h
@@ -20,6 +20,7 @@
void sequence_clean (s_sequence *seq);
s_sequence * sequence_init (s_sequence *sequence, f64 duration,
const s8 *title, f_sequence load,
- f_sequence render, f_sequence unload);
+ f_sequence render, f_sequence unload,
+ void *window);
#endif /* LIBC3_SEQUENCE_H */
diff --git a/libc3/void.c b/libc3/void.c
index c5c01d1..7abd6ef 100644
--- a/libc3/void.c
+++ b/libc3/void.c
@@ -142,143 +142,86 @@ bool void_clean (const s_sym *type, void *data)
return false;
}
-bool void_init_copy (const s_sym *type, void *v, const void *src)
+void * void_init_copy (const s_sym *type, void *v, const void *src)
{
- if (type == sym_1("Array")) {
- array_init_copy;
- return true;
- }
- if (type == sym_1("Bool")) {
- bool_init_copy;
- return true;
- }
- if (type == sym_1("Call")) {
- call_init_copy;
- return true;
- }
- if (type == sym_1("Cfn")) {
- cfn_init_copy;
- return true;
- }
- if (type == sym_1("Character")) {
- character_init_copy;
- return true;
- }
- if (type == sym_1("F32")) {
- f32_init_copy;
- return true;
- }
- if (type == sym_1("F64")) {
- f64_init_copy;
- return true;
- }
- if (type == sym_1("Fact")) {
- fact_init_copy;
- return true;
- }
- if (type == sym_1("Fn")) {
- fn_init_copy;
- return true;
- }
- if (type == sym_1("Ident")) {
- ident_init_copy;
- return true;
- }
- if (type == sym_1("Integer")) {
- integer_init_copy;
- return true;
- }
- if (type == sym_1("List")) {
- list_init_copy;
- return true;
- }
- if (type == sym_1("Ptag")) {
- ptag_init_copy;
- return true;
- }
- if (type == sym_1("Ptr")) {
- ptr_init_copy;
- return true;
- }
- if (type == sym_1("PtrFree")) {
- ptr_free_init_copy;
- return true;
- }
- if (type == sym_1("Quote")) {
- quote_init_copy;
- return true;
- }
- if (type == sym_1("S8")) {
- s8_init_copy;
- return true;
- }
- if (type == sym_1("S16")) {
- s16_init_copy;
- return true;
- }
- if (type == sym_1("S32")) {
- s32_init_copy;
- return true;
- }
- if (type == sym_1("S64")) {
- s64_init_copy;
- return true;
- }
- if (type == sym_1("Str")) {
- str_init_copy;
- return true;
- }
- if (type == sym_1("Struct")) {
- struct_init_copy;
- return true;
- }
- if (type == sym_1("Sw")) {
- sw_init_copy;
- return true;
- }
- if (type == sym_1("Sym")) {
- sym_init_copy;
- return true;
- }
- if (type == sym_1("Tuple")) {
- tuple_init_copy;
- return true;
- }
- if (type == sym_1("U8")) {
- u8_init_copy;
- return true;
- }
- if (type == sym_1("U16")) {
- u16_init_copy;
- return true;
- }
- if (type == sym_1("U32")) {
- u32_init_copy;
- return true;
- }
- if (type == sym_1("U64")) {
- u64_init_copy;
- return true;
- }
- if (type == sym_1("Uw")) {
- uw_init_copy;
- return true;
- }
- if (type == sym_1("Var")) {
- *dest = NULL;
- return true;
- }
- if (type == sym_1("Void")) {
- *dest = NULL;
- return true;
- }
+ void *r;
+ if (type == sym_1("Array"))
+ return array_init_copy(v, src);
+ if (type == sym_1("Bool"))
+ return bool_init_copy(v, src);
+ if (type == sym_1("Call"))
+ return call_init_copy(v, src);
+ if (type == sym_1("Cfn"))
+ return cfn_init_copy(v, src);
+ if (type == sym_1("Character"))
+ return character_init_copy(v, src);
+ if (type == sym_1("F32"))
+ return f32_init_copy(v, src);
+ if (type == sym_1("F64"))
+ return f64_init_copy(v, src);
+ if (type == sym_1("Fact"))
+ return fact_init_copy(v, src);
+ if (type == sym_1("Fn"))
+ return fn_init_copy(v, src);
+ if (type == sym_1("Ident"))
+ return ident_init_copy(v, src);
+ if (type == sym_1("Integer"))
+ return integer_init_copy(v, src);
+ if (type == sym_1("List"))
+ return list_init_copy(v, src);
+ if (type == sym_1("Ptag"))
+ return ptag_init_copy(v, src);
+ if (type == sym_1("Ptr"))
+ return ptr_init_copy(v, src);
+ if (type == sym_1("PtrFree"))
+ return ptr_free_init_copy(v, src);
+ if (type == sym_1("Quote"))
+ return quote_init_copy(v, src);
+ if (type == sym_1("S8"))
+ return s8_init_copy(v, src);
+ if (type == sym_1("S16"))
+ return s16_init_copy(v, src);
+ if (type == sym_1("S32"))
+ return s32_init_copy(v, src);
+ if (type == sym_1("S64"))
+ return s64_init_copy(v, src);
+ if (type == sym_1("Str"))
+ return str_init_copy(v, src);
+ if (type == sym_1("Struct"))
+ return struct_init_copy(v, src);
+ if (type == sym_1("Sw"))
+ return sw_init_copy(v, src);
+ if (type == sym_1("Sym"))
+ return sym_init_copy(v, src);
+ if (type == sym_1("Tuple"))
+ return tuple_init_copy(v, src);
+ if (type == sym_1("U8"))
+ return u8_init_copy(v, src);
+ if (type == sym_1("U16"))
+ return u16_init_copy(v, src);
+ if (type == sym_1("U32"))
+ return u32_init_copy(v, src);
+ if (type == sym_1("U64"))
+ return u64_init_copy(v, src);
+ if (type == sym_1("Uw"))
+ return uw_init_copy(v, src);
+ if (type == sym_1("Var"))
+ return v;
+ if (type == sym_1("Void"))
+ return v;
if (struct_type_exists(type)) {
- struct_init_copy;
- return true;
+ s_struct s = {0};
+ s_struct t = {0};
+ struct_init_with_data(&s, type, false, v);
+ struct_init_with_data(&t, type, false, (void *) src);
+ r = struct_init_copy(&s, &t);
+ struct_type_clean(&s.type);
+ struct_type_clean(&t.type);
+ return r;
}
err_write_1("void_init_copy: unknown type: ");
err_inspect_sym(&type);
err_write_1("\n");
assert(! "void_init_copy: unknown type");
- return false;
+ return NULL;
}
diff --git a/libc3/window/cairo/demo/bg_rect.c b/libc3/window/cairo/demo/bg_rect.c
index 645d4e1..2e73815 100644
--- a/libc3/window/cairo/demo/bg_rect.c
+++ b/libc3/window/cairo/demo/bg_rect.c
@@ -15,18 +15,17 @@
#include "../types.h"
#include "bg_rect.h"
-bool bg_rect_load (s_sequence *seq, s_window_cairo *window)
+#define BG_RECT_COLOR_MAX 8
+
+bool bg_rect_load (s_sequence *seq)
{
(void) seq;
- (void) window;
return true;
}
-bool bg_rect_render (s_sequence *seq, s_window_cairo *window,
- cairo_t *cr)
+bool bg_rect_render (s_sequence *seq)
{
-#define C3_WINDOW_CAIRO_DEMO_BG_RECT_COLOR_MAX 8
- const s_rgb color[C3_WINDOW_CAIRO_DEMO_BG_RECT_COLOR_MAX] = {
+ const s_rgb color[BG_RECT_COLOR_MAX] = {
{0, 0, 0},
{1, 0, 0},
{1, 1, 0},
@@ -38,11 +37,15 @@ bool bg_rect_render (s_sequence *seq, s_window_cairo *window,
};
u8 c1;
u8 c2;
+ cairo_t *cr;
double p;
double q;
s_rgb rgb;
- c1 = (u8) trunc(seq->t) % C3_WINDOW_CAIRO_DEMO_BG_RECT_COLOR_MAX;
- c2 = (u8) trunc(seq->t + 1.0) % C3_WINDOW_CAIRO_DEMO_BG_RECT_COLOR_MAX;
+ s_window_cairo *window;
+ window = seq->window;
+ cr = window->cr;
+ c1 = (u8) trunc(seq->t) % BG_RECT_COLOR_MAX;
+ c2 = (u8) trunc(seq->t + 1.0) % BG_RECT_COLOR_MAX;
p = fmod(seq->t, 1.0);
q = 1.0 - p;
rgb.r = color[c1].r * q + color[c2].r * p;
@@ -53,3 +56,9 @@ bool bg_rect_render (s_sequence *seq, s_window_cairo *window,
cairo_fill(cr);
return true;
}
+
+bool bg_rect_unload (s_sequence *seq)
+{
+ (void) seq;
+ return true;
+}
diff --git a/libc3/window/cairo/demo/bg_rect.h b/libc3/window/cairo/demo/bg_rect.h
index cd451fa..74b604b 100644
--- a/libc3/window/cairo/demo/bg_rect.h
+++ b/libc3/window/cairo/demo/bg_rect.h
@@ -15,8 +15,8 @@
#include "../types.h"
-bool bg_rect_load (s_sequence *seq, s_window_cairo *window);
-bool bg_rect_render (s_sequence *seq, s_window_cairo *window,
- cairo_t *cr);
+bool bg_rect_load (s_sequence *seq);
+bool bg_rect_render (s_sequence *seq);
+bool bg_rect_unload (s_sequence *seq);
#endif /* BG_RECT_H */
diff --git a/libc3/window/cairo/demo/flies.c b/libc3/window/cairo/demo/flies.c
index d1ec38b..c9a74c7 100644
--- a/libc3/window/cairo/demo/flies.c
+++ b/libc3/window/cairo/demo/flies.c
@@ -51,15 +51,13 @@ static void fly_init (s_map *map)
(*in)++;
}
-bool flies_load (s_sequence *seq,
- s_window_cairo *window)
+bool flies_load (s_sequence *seq)
{
uw address[2];
s_array *board;
uw i;
uw j;
s_map *map;
- (void) window;
tag_map(&seq->tag, 4);
map = &seq->tag.data.map;
tag_init_sym_1( map->key + 0, "board");
@@ -128,8 +126,7 @@ bool flies_load (s_sequence *seq,
return true;
}
-bool flies_render (s_sequence *seq, s_window_cairo *window,
- cairo_t *cr)
+bool flies_render (s_sequence *seq)
{
s8 a[BOARD_SIZE];
uw address[2];
@@ -141,6 +138,7 @@ bool flies_render (s_sequence *seq, s_window_cairo *window,
f64 board_item_w;
f64 board_item_h;
s_buf buf;
+ cairo_t *cr;
f64 dead_fly_scale;
u8 direction;
u8 direction_prev = 4;
@@ -159,6 +157,9 @@ bool flies_render (s_sequence *seq, s_window_cairo *window,
cairo_text_extents_t te;
f64 x;
f64 y;
+ s_window_cairo *window;
+ window = seq->window;
+ cr = window->cr;
cairo_set_source_rgb(cr, 0.5, 0.5, 0.5);
cairo_rectangle(cr, 0, 0, window->w, window->h);
cairo_fill(cr);
@@ -310,3 +311,9 @@ bool flies_render (s_sequence *seq, s_window_cairo *window,
}
return true;
}
+
+bool flies_unload (s_sequence *seq)
+{
+ (void) seq;
+ return true;
+}
diff --git a/libc3/window/cairo/demo/flies.h b/libc3/window/cairo/demo/flies.h
index 9695712..ee04b5e 100644
--- a/libc3/window/cairo/demo/flies.h
+++ b/libc3/window/cairo/demo/flies.h
@@ -18,8 +18,8 @@
extern s_cairo_sprite g_sprite_dead_fly;
extern s_cairo_sprite g_sprite_fly;
-bool flies_load (s_sequence *seq, s_window_cairo *window);
-bool flies_render (s_sequence *seq, s_window_cairo *window,
- cairo_t *cr);
+bool flies_load (s_sequence *seq);
+bool flies_render (s_sequence *seq);
+bool flies_unload (s_sequence *seq);
#endif /* FLIES_H */
diff --git a/libc3/window/cairo/demo/lightspeed.c b/libc3/window/cairo/demo/lightspeed.c
index 19397dc..a535d91 100644
--- a/libc3/window/cairo/demo/lightspeed.c
+++ b/libc3/window/cairo/demo/lightspeed.c
@@ -53,10 +53,9 @@ static void star_render (s_tag *star, s_window_cairo *window,
star_init(star);
}
-bool lightspeed_load (s_sequence *seq, s_window_cairo *window)
+bool lightspeed_load (s_sequence *seq)
{
uw i;
- (void) window;
tag_tuple(&seq->tag, LIGHTSPEED_STARS);
i = 0;
while (i < LIGHTSPEED_STARS) {
@@ -66,11 +65,14 @@ bool lightspeed_load (s_sequence *seq, s_window_cairo *window)
return true;
}
-bool lightspeed_render (s_sequence *seq, s_window_cairo *window,
- cairo_t *cr)
+bool lightspeed_render (s_sequence *seq)
{
+ cairo_t *cr;
uw i;
cairo_matrix_t matrix;
+ s_window_cairo *window;
+ window = seq->window;
+ cr = window->cr;
cairo_get_matrix(cr, &matrix);
cairo_scale(cr, window->w / 2.0, window->h / 2.0);
cairo_translate(cr, 1.0, 1.0);
@@ -85,3 +87,9 @@ bool lightspeed_render (s_sequence *seq, s_window_cairo *window,
cairo_set_matrix(cr, &matrix);
return true;
}
+
+bool lightspeed_unload (s_sequence *seq)
+{
+ (void) seq;
+ return true;
+}
diff --git a/libc3/window/cairo/demo/lightspeed.h b/libc3/window/cairo/demo/lightspeed.h
index dc95059..8b89b3b 100644
--- a/libc3/window/cairo/demo/lightspeed.h
+++ b/libc3/window/cairo/demo/lightspeed.h
@@ -17,8 +17,8 @@
#define LIGHTSPEED_STARS 1000
-bool lightspeed_load (s_sequence *seq, s_window_cairo *window);
-bool lightspeed_render (s_sequence *seq, s_window_cairo *window,
- cairo_t *cr);
+bool lightspeed_load (s_sequence *seq);
+bool lightspeed_render (s_sequence *seq);
+bool lightspeed_unload (s_sequence *seq);
#endif /* LIGHTSPEED_H */
diff --git a/libc3/window/cairo/demo/toasters.c b/libc3/window/cairo/demo/toasters.c
index 13086e1..ea59aac 100644
--- a/libc3/window/cairo/demo/toasters.c
+++ b/libc3/window/cairo/demo/toasters.c
@@ -39,7 +39,6 @@ static s_tag * toast_init (s_tag *toast, f64 x, f64 y)
return toast;
}
-
static void toast_render (s_tag *toast, s_window_cairo *window,
cairo_t *cr, s_sequence *seq)
{
@@ -99,11 +98,9 @@ static void toaster_render (s_tag *toaster, s_window_cairo *window,
}
}
-bool toasters_load (s_sequence *seq,
- s_window_cairo *window)
+bool toasters_load (s_sequence *seq)
{
s_map *map;
- (void) window;
tag_map(&seq->tag, 2);
map = &seq->tag.data.map;
tag_init_sym_1( map->key + 0, "toasters");
@@ -113,11 +110,14 @@ bool toasters_load (s_sequence *seq,
return true;
}
-bool toasters_render (s_sequence *seq, s_window_cairo *window,
- cairo_t *cr)
+bool toasters_render (s_sequence *seq)
{
+ cairo_t *cr;
s_list **toasters;
s_list **toasts;
+ s_window_cairo *window;
+ window = seq->window;
+ cr = window->cr;
cairo_set_source_rgb(cr, 0.7, 0.95, 1.0);
cairo_rectangle(cr, 0, 0, window->w, window->h);
cairo_fill(cr);
@@ -234,3 +234,9 @@ bool toasters_render_toasters (s_list **toasters,
}
return true;
}
+
+bool toasters_unload (s_sequence *seq)
+{
+ (void) seq;
+ return true;
+}
diff --git a/libc3/window/cairo/demo/toasters.h b/libc3/window/cairo/demo/toasters.h
index b97b4b9..c476e48 100644
--- a/libc3/window/cairo/demo/toasters.h
+++ b/libc3/window/cairo/demo/toasters.h
@@ -18,8 +18,8 @@
extern s_cairo_sprite g_sprite_toast;
extern s_cairo_sprite g_sprite_toaster;
-bool toasters_load (s_sequence *seq, s_window_cairo *window);
-bool toasters_render (s_sequence *seq, s_window_cairo *window,
- cairo_t *cr);
+bool toasters_load (s_sequence *seq);
+bool toasters_render (s_sequence *seq);
+bool toasters_unload (s_sequence *seq);
#endif /* TOASTERS_H */
diff --git a/libc3/window/cairo/demo/window_cairo_demo.c b/libc3/window/cairo/demo/window_cairo_demo.c
index b8096b9..6c85ac0 100644
--- a/libc3/window/cairo/demo/window_cairo_demo.c
+++ b/libc3/window/cairo/demo/window_cairo_demo.c
@@ -88,30 +88,28 @@ bool window_cairo_demo_load (s_window_cairo *window)
if (! cairo_font_init(&g_font_courier_new,
"fonts/Courier New/Courier New.ttf"))
return false;
- window_cairo_sequence_init(window->sequence, 8.0,
- "01. Background rectangles",
- bg_rect_load, bg_rect_render);
- window_cairo_sequence_init(window->sequence + 1, 20.0,
- "02. Lightspeed",
- lightspeed_load, lightspeed_render);
+ sequence_init(window->sequence, 8.0, "01. Background rectangles",
+ bg_rect_load, bg_rect_render, bg_rect_unload, window);
+ sequence_init(window->sequence + 1, 20.0, "02. Lightspeed",
+ lightspeed_load, lightspeed_render, lightspeed_unload,
+ window);
if (! cairo_sprite_init(&g_sprite_toaster, "img/flaps.png",
4, 1, 4))
return false;
if (! cairo_sprite_init(&g_sprite_toast, "img/toast.png",
1, 1, 1))
return false;
- window_cairo_sequence_init(window->sequence + 2, 60.0,
- "03. Toasters",
- toasters_load, toasters_render);
+ sequence_init(window->sequence + 2, 60.0, "03. Toasters",
+ toasters_load, toasters_render, toasters_unload,
+ window);
if (! cairo_sprite_init(&g_sprite_fly, "img/fly-noto.png",
1, 1, 1))
return false;
if (! cairo_sprite_init(&g_sprite_dead_fly, "img/fly-dead.png",
1, 1, 1))
return false;
- window_cairo_sequence_init(window->sequence + 3, 60.0,
- "04. Flies",
- flies_load, flies_render);
+ sequence_init(window->sequence + 3, 60.0, "04. Flies",
+ flies_load, flies_render, flies_unload, window);
window_set_sequence_pos((s_window *) window, 0);
return true;
}
@@ -142,17 +140,18 @@ static void render_text (cairo_t *cr, double x, double y,
cairo_show_text(cr, p);
}
-bool window_cairo_demo_render (s_window_cairo *window,
- cairo_t *cr)
+bool window_cairo_demo_render (s_window_cairo *window)
{
+ cairo_t *cr;
s_sequence *seq;
cairo_text_extents_t te;
assert(window);
+ cr = window->cr;
assert(cr);
if (! window_animate((s_window *) window))
return false;
seq = window->sequence + window->sequence_pos;
- if (! seq->render(seq, window, cr))
+ if (! seq->render(seq))
return false;
/* text */
cairo_set_font_size(cr, 20);
diff --git a/libc3/window/cairo/demo/window_cairo_demo.h b/libc3/window/cairo/demo/window_cairo_demo.h
index ab2b69a..32703a6 100644
--- a/libc3/window/cairo/demo/window_cairo_demo.h
+++ b/libc3/window/cairo/demo/window_cairo_demo.h
@@ -24,7 +24,7 @@ bool window_cairo_demo_button (s_window_cairo *window, u8 button,
sw x, sw y);
bool window_cairo_demo_key (s_window_cairo *window, uw keysym);
bool window_cairo_demo_load (s_window_cairo *window);
-bool window_cairo_demo_render (s_window_cairo *window, cairo_t *cr);
+bool window_cairo_demo_render (s_window_cairo *window);
bool window_cairo_demo_resize (s_window_cairo *window, uw w, uw h);
void window_cairo_demo_unload (s_window_cairo *window);
diff --git a/libc3/window/cairo/types.h b/libc3/window/cairo/types.h
index f7647fe..7893512 100644
--- a/libc3/window/cairo/types.h
+++ b/libc3/window/cairo/types.h
@@ -47,20 +47,12 @@ typedef bool (*f_window_cairo_motion) (s_window_cairo *window, sw x,
sw y);
/* return false to break event loop */
-typedef bool (*f_window_cairo_render) (s_window_cairo *window,
- cairo_t *cr);
+typedef bool (*f_window_cairo_render) (s_window_cairo *window);
/* return false to break event loop */
typedef bool (*f_window_cairo_resize) (s_window_cairo *window,
uw w, uw h);
-typedef bool (*f_window_cairo_sequence_load) (s_sequence *seq,
- s_window_cairo *window);
-
-typedef bool (*f_window_cairo_sequence_render) (s_sequence *seq,
- s_window_cairo *window,
- cairo_t *cr);
-
typedef void (*f_window_cairo_unload) (s_window_cairo *window);
struct cairo_font {
@@ -111,6 +103,7 @@ struct window_cairo {
f_window_cairo_render render;
cairo_t *cr;
f_window_cairo_resize resize;
+ s_sequence *seq;
s_sequence *sequence;
uw sequence_count;
uw sequence_pos;
diff --git a/libc3/window/cairo/window_cairo.c b/libc3/window/cairo/window_cairo.c
index 7d4728d..da4abbd 100644
--- a/libc3/window/cairo/window_cairo.c
+++ b/libc3/window/cairo/window_cairo.c
@@ -92,9 +92,11 @@ bool window_cairo_motion_default (s_window_cairo *window, sw x, sw y)
return true;
}
-bool window_cairo_render_default (s_window_cairo *window, cairo_t *cr)
+bool window_cairo_render_default (s_window_cairo *window)
{
+ cairo_t *cr;
assert(window);
+ cr = window->cr;
assert(cr);
cairo_set_source_rgb(cr, 1, 1, 1);
cairo_rectangle(cr, 0, 0, window->w, window->h);
@@ -112,21 +114,3 @@ bool window_cairo_resize_default (s_window_cairo *window, uw w, uw h)
printf("window_cairo_resize_default: %lu x %lu\n", w, h);
return true;
}
-
-s_sequence * window_cairo_sequence_init
-(s_sequence *seq, f64 duration, const s8 *title,
- f_window_cairo_sequence_load load,
- f_window_cairo_sequence_render render)
-{
- s_sequence tmp = {0};
- assert(seq);
- tmp.dt = 0.0;
- tmp.t = 0.0;
- tmp.duration = duration;
- tmp.title = title;
- tmp.load = (f_sequence_load) load;
- tmp.render = (f_sequence_render) render;
- tag_init_void(&tmp.tag);
- *seq = tmp;
- return seq;
-}
diff --git a/libc3/window/cairo/window_cairo.h b/libc3/window/cairo/window_cairo.h
index be868c2..678b198 100644
--- a/libc3/window/cairo/window_cairo.h
+++ b/libc3/window/cairo/window_cairo.h
@@ -29,20 +29,13 @@ s_window_cairo * window_cairo_init (s_window_cairo *window,
uw sequence_count);
bool window_cairo_run (s_window_cairo *window);
-/* Stack-allocation compatible functions, call sequence_clean
- after use. */
-s_sequence * window_cairo_sequence_init
-(s_sequence *sequence, f64 duration, const s8 *title,
- f_window_cairo_sequence_load load,
- f_window_cairo_sequence_render render);
-
/* Callbacks. */
bool window_cairo_button_default (s_window_cairo *window, u8 button,
sw x, sw y);
bool window_cairo_key_default (s_window_cairo *window, uw keysym);
bool window_cairo_load_default (s_window_cairo *window);
bool window_cairo_motion_default (s_window_cairo *window, sw x, sw y);
-bool window_cairo_render_default (s_window_cairo *window, cairo_t *cr);
+bool window_cairo_render_default (s_window_cairo *window);
bool window_cairo_resize_default (s_window_cairo *window, uw w, uw h);
#endif /* LIBC3_WINDOW_CAIRO_H */
diff --git a/libc3/window/cairo/xcb/window_cairo_xcb.c b/libc3/window/cairo/xcb/window_cairo_xcb.c
index 111b940..7867305 100644
--- a/libc3/window/cairo/xcb/window_cairo_xcb.c
+++ b/libc3/window/cairo/xcb/window_cairo_xcb.c
@@ -47,7 +47,7 @@ bool window_cairo_xcb_event (s_window_cairo *window,
goto ko;
break;
case XCB_EXPOSE:
- if (! window->render(window, window->cr))
+ if (! window->render(window))
goto ko;
xcb_gcontext_t gc = xcb_generate_id(conn);
u32 gc_mask = XCB_GC_GRAPHICS_EXPOSURES;
diff --git a/libc3/window/sdl2/demo/bg_rect.c b/libc3/window/sdl2/demo/bg_rect.c
index dacfce0..a48df2f 100644
--- a/libc3/window/sdl2/demo/bg_rect.c
+++ b/libc3/window/sdl2/demo/bg_rect.c
@@ -15,18 +15,14 @@
#include "../types.h"
#include "bg_rect.h"
-bool bg_rect_load (s_sequence *seq, s_window_sdl2 *window)
+bool bg_rect_load (s_sequence *seq)
{
(void) seq;
- (void) window;
return true;
}
-bool bg_rect_render (s_sequence *seq, s_window_sdl2 *window,
- SDL_GLContext context)
+bool bg_rect_render (s_sequence *seq)
{
- (void) context;
- (void) window;
#define BG_RECT_COLOR_MAX 8
const s_rgb color[BG_RECT_COLOR_MAX] = {
{0, 0, 0},
@@ -57,3 +53,9 @@ bool bg_rect_render (s_sequence *seq, s_window_sdl2 *window,
assert(glGetError() == GL_NO_ERROR);
return true;
}
+
+bool bg_rect_unload (s_sequence *seq)
+{
+ (void) seq;
+ return true;
+}
diff --git a/libc3/window/sdl2/demo/bg_rect.h b/libc3/window/sdl2/demo/bg_rect.h
index 6bc4a8b..74b604b 100644
--- a/libc3/window/sdl2/demo/bg_rect.h
+++ b/libc3/window/sdl2/demo/bg_rect.h
@@ -15,8 +15,8 @@
#include "../types.h"
-bool bg_rect_load (s_sequence *seq, s_window_sdl2 *window);
-bool bg_rect_render (s_sequence *seq, s_window_sdl2 *window,
- SDL_GLContext context);
+bool bg_rect_load (s_sequence *seq);
+bool bg_rect_render (s_sequence *seq);
+bool bg_rect_unload (s_sequence *seq);
#endif /* BG_RECT_H */
diff --git a/libc3/window/sdl2/demo/earth.c b/libc3/window/sdl2/demo/earth.c
index 79171b4..891e4d4 100644
--- a/libc3/window/sdl2/demo/earth.c
+++ b/libc3/window/sdl2/demo/earth.c
@@ -24,13 +24,15 @@
s_gl_sprite g_sprite_earth = {0};
-bool earth_load (s_sequence *seq,
- s_window_sdl2 *window)
+bool earth_load (s_sequence *seq)
{
s_map *map;
s_gl_camera *camera;
s_gl_sphere *sphere;
- (void) window;
+ s_window_sdl2 *window;
+ assert(seq);
+ window = seq->window;
+ assert(window);
camera = gl_camera_new(window->w, window->h);
if (! camera)
return false;
@@ -50,17 +52,17 @@ bool earth_load (s_sequence *seq,
return true;
}
-bool earth_render (s_sequence *seq, s_window_sdl2 *window,
- void *context)
+bool earth_render (s_sequence *seq)
{
s_gl_camera *camera;
f64 *camera_rot_x_speed;
s_map *map;
s_gl_sphere *sphere;
f64 sphere_radius;
+ s_window_sdl2 *window;
assert(seq);
+ window = seq->window;
assert(window);
- (void) context;
if (! seq || seq->tag.type != TAG_MAP ||
seq->tag.data.map.count != 3) {
err_puts("earth_render: invalid seq->tag");
@@ -132,3 +134,9 @@ bool earth_render (s_sequence *seq, s_window_sdl2 *window,
glDisable(GL_LIGHTING);
return true;
}
+
+bool earth_unload (s_sequence *seq)
+{
+ (void) seq;
+ return true;
+}
diff --git a/libc3/window/sdl2/demo/earth.h b/libc3/window/sdl2/demo/earth.h
index 0bf6ac4..5f972e3 100644
--- a/libc3/window/sdl2/demo/earth.h
+++ b/libc3/window/sdl2/demo/earth.h
@@ -19,8 +19,8 @@
extern s_gl_sprite g_sprite_earth;
extern s_gl_sprite g_sprite_earth_night;
-bool earth_load (s_sequence *seq, s_window_sdl2 *window);
-bool earth_render (s_sequence *seq, s_window_sdl2 *window,
- void *context);
+bool earth_load (s_sequence *seq);
+bool earth_render (s_sequence *seq);
+bool earth_unload (s_sequence *seq);
#endif /* EARTH_H */
diff --git a/libc3/window/sdl2/demo/flies.c b/libc3/window/sdl2/demo/flies.c
index 8c1db4d..3176666 100644
--- a/libc3/window/sdl2/demo/flies.c
+++ b/libc3/window/sdl2/demo/flies.c
@@ -54,15 +54,13 @@ static void fly_init (s_map *map)
(*in)++;
}
-bool flies_load (s_sequence *seq,
- s_window_sdl2 *window)
+bool flies_load (s_sequence *seq)
{
uw address[2];
s_array *board;
uw i;
uw j;
s_map *map;
- (void) window;
tag_map(&seq->tag, 4);
map = &seq->tag.data.map;
tag_init_sym_1( map->key + 0, "board");
@@ -131,8 +129,7 @@ bool flies_load (s_sequence *seq,
return true;
}
-bool flies_render (s_sequence *seq, s_window_sdl2 *window,
- void *context)
+bool flies_render (s_sequence *seq)
{
s8 a[BOARD_SIZE];
uw address[2];
@@ -161,12 +158,10 @@ bool flies_render (s_sequence *seq, s_window_sdl2 *window,
uw random_bits = 0;
f64 x;
f64 y;
- (void) context;
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0, window->w, 0, window->h, -1, 1);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
+ s_window_sdl2 *window;
+ assert(seq);
+ window = seq->window;
+ assert(window);
glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
/* io_inspect(&seq->tag); */
@@ -323,3 +318,9 @@ bool flies_render (s_sequence *seq, s_window_sdl2 *window,
} glPopMatrix();
return true;
}
+
+bool flies_unload (s_sequence *seq)
+{
+ (void) seq;
+ return true;
+}
diff --git a/libc3/window/sdl2/demo/flies.h b/libc3/window/sdl2/demo/flies.h
index 1de8081..d365b14 100644
--- a/libc3/window/sdl2/demo/flies.h
+++ b/libc3/window/sdl2/demo/flies.h
@@ -20,8 +20,8 @@ extern s_gl_font g_font_flies;
extern s_gl_sprite g_sprite_dead_fly;
extern s_gl_sprite g_sprite_fly;
-bool flies_load (s_sequence *seq, s_window_sdl2 *window);
-bool flies_render (s_sequence *seq, s_window_sdl2 *window,
- void *context);
+bool flies_load (s_sequence *seq);
+bool flies_render (s_sequence *seq);
+bool flies_unload (s_sequence *seq);
#endif /* FLIES_H */
diff --git a/libc3/window/sdl2/demo/lightspeed.c b/libc3/window/sdl2/demo/lightspeed.c
index 1e9cffc..e9ad16e 100644
--- a/libc3/window/sdl2/demo/lightspeed.c
+++ b/libc3/window/sdl2/demo/lightspeed.c
@@ -61,11 +61,14 @@ static void star_render (s_tag *star, s_sequence *seq, s_gl_vertex *v)
star_init(star);
}
-bool lightspeed_load (s_sequence *seq, s_window_sdl2 *window)
+bool lightspeed_load (s_sequence *seq)
{
uw i;
uw star_count;
- (void) window;
+ s_window_sdl2 *window;
+ assert(seq);
+ window = seq->window;
+ assert(window);
tag_tuple(&seq->tag, LIGHTSPEED_STAR_MAX);
star_count = window->w * window->h * LIGHTSPEED_STAR_PROBABILITY;
if (star_count > LIGHTSPEED_STAR_MAX)
@@ -78,14 +81,15 @@ bool lightspeed_load (s_sequence *seq, s_window_sdl2 *window)
return true;
}
-bool lightspeed_render (s_sequence *seq, s_window_sdl2 *window,
- void *context)
+bool lightspeed_render (s_sequence *seq)
{
uw i;
uw star_count;
s_gl_vertex *v;
- (void) window;
- (void) context;
+ s_window_sdl2 *window;
+ assert(seq);
+ window = seq->window;
+ assert(window);
gl_matrix_4d_init_identity(&g_ortho.model_matrix);
/*
gl_matrix_4d_scale(&g_ortho.model_matrix, window->w / 2.0,
@@ -126,3 +130,9 @@ bool lightspeed_render (s_sequence *seq, s_window_sdl2 *window,
assert(glGetError() == GL_NO_ERROR);
return true;
}
+
+bool lightspeed_unload (s_sequence *seq)
+{
+ (void) seq;
+ return true;
+}
diff --git a/libc3/window/sdl2/demo/lightspeed.h b/libc3/window/sdl2/demo/lightspeed.h
index 6a889ad..c099ed2 100644
--- a/libc3/window/sdl2/demo/lightspeed.h
+++ b/libc3/window/sdl2/demo/lightspeed.h
@@ -20,8 +20,8 @@
extern s_gl_lines g_lines_stars;
-bool lightspeed_load (s_sequence *seq, s_window_sdl2 *window);
-bool lightspeed_render (s_sequence *seq, s_window_sdl2 *window,
- void *context);
+bool lightspeed_load (s_sequence *seq);
+bool lightspeed_render (s_sequence *seq);
+bool lightspeed_unload (s_sequence *seq);
#endif /* LIGHTSPEED_H */
diff --git a/libc3/window/sdl2/demo/toasters.c b/libc3/window/sdl2/demo/toasters.c
index 0491655..21057d2 100644
--- a/libc3/window/sdl2/demo/toasters.c
+++ b/libc3/window/sdl2/demo/toasters.c
@@ -101,11 +101,9 @@ static void toaster_render (s_tag *toaster, s_window_sdl2 *window,
}
}
-bool toasters_load (s_sequence *seq,
- s_window_sdl2 *window)
+bool toasters_load (s_sequence *seq)
{
s_map *map;
- (void) window;
tag_map(&seq->tag, 2);
map = &seq->tag.data.map;
tag_init_sym_1( map->key + 0, "toasters");
@@ -115,12 +113,14 @@ bool toasters_load (s_sequence *seq,
return true;
}
-bool toasters_render (s_sequence *seq, s_window_sdl2 *window,
- void *context)
+bool toasters_render (s_sequence *seq)
{
s_list **toasters;
s_list **toasts;
- (void) context;
+ s_window_sdl2 *window;
+ assert(seq);
+ window = seq->window;
+ assert(window);
glClearColor(0.7f, 0.95f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
@@ -242,3 +242,9 @@ bool toasters_render_toasters (s_list **toasters, s_window_sdl2 *window,
}
return true;
}
+
+bool toasters_unload (s_sequence *seq)
+{
+ (void) seq;
+ return true;
+}
diff --git a/libc3/window/sdl2/demo/toasters.h b/libc3/window/sdl2/demo/toasters.h
index e6c9c15..ea4e3a3 100644
--- a/libc3/window/sdl2/demo/toasters.h
+++ b/libc3/window/sdl2/demo/toasters.h
@@ -18,8 +18,8 @@
extern s_gl_sprite g_sprite_toast;
extern s_gl_sprite g_sprite_toaster;
-bool toasters_load (s_sequence *seq, s_window_sdl2 *window);
-bool toasters_render (s_sequence *seq, s_window_sdl2 *window,
- void *context);
+bool toasters_load (s_sequence *seq);
+bool toasters_render (s_sequence *seq);
+bool toasters_unload (s_sequence *seq);
#endif /* TOASTERS_H */
diff --git a/libc3/window/sdl2/demo/window_sdl2_demo.c b/libc3/window/sdl2/demo/window_sdl2_demo.c
index cd75c40..07814eb 100644
--- a/libc3/window/sdl2/demo/window_sdl2_demo.c
+++ b/libc3/window/sdl2/demo/window_sdl2_demo.c
@@ -42,8 +42,7 @@ static bool window_sdl2_demo_button (s_window_sdl2 *window, u8 button,
static bool window_sdl2_demo_key (s_window_sdl2 *window,
SDL_Keysym *keysym);
static bool window_sdl2_demo_load (s_window_sdl2 *window);
-static bool window_sdl2_demo_render (s_window_sdl2 *window,
- void *context);
+static bool window_sdl2_demo_render (s_window_sdl2 *window);
static bool window_sdl2_demo_resize (s_window_sdl2 *window,
uw w, uw h);
static void window_sdl2_demo_unload (s_window_sdl2 *window);
@@ -160,24 +159,23 @@ bool window_sdl2_demo_load (s_window_sdl2 *window)
return false;
if (! gl_text_init_1(&g_text_fps, &g_font_courier_new, "0.00"))
return false;
- window_sdl2_sequence_init(window->sequence, 8.0,
- "01. Background rectangles",
- bg_rect_load, bg_rect_render);
+ sequence_init(window->sequence, 8.0, "01. Background rectangles",
+ bg_rect_load, bg_rect_render, bg_rect_unload, window);
if (! gl_lines_init(&g_lines_stars) ||
! gl_lines_allocate(&g_lines_stars, LIGHTSPEED_STAR_MAX))
return false;
- window_sdl2_sequence_init(window->sequence + 1, 20.0,
- "02. Lightspeed",
- lightspeed_load, lightspeed_render);
+ sequence_init(window->sequence + 1, 20.0, "02. Lightspeed",
+ lightspeed_load, lightspeed_render, lightspeed_unload,
+ window);
if (! gl_sprite_init(&g_sprite_toaster, "img/flaps.256.png",
4, 1, 4))
return false;
if (! gl_sprite_init(&g_sprite_toast, "img/toast.128.png",
1, 1, 1))
return false;
- window_sdl2_sequence_init(window->sequence + 2, 60.0,
- "03. Toasters",
- toasters_load, toasters_render);
+ sequence_init(window->sequence + 2, 60.0, "03. Toasters",
+ toasters_load, toasters_render, toasters_unload,
+ window);
if (! gl_font_init(&g_font_flies,
"fonts/Courier New/Courier New.ttf"))
return false;
@@ -187,9 +185,8 @@ bool window_sdl2_demo_load (s_window_sdl2 *window)
if (! gl_sprite_init(&g_sprite_dead_fly, "img/fly-dead.png",
1, 1, 1))
return false;
- window_sdl2_sequence_init(window->sequence + 3, 60.0,
- "04. Flies",
- flies_load, flies_render);
+ sequence_init(window->sequence + 3, 60.0, "04. Flies",
+ flies_load, flies_render, flies_unload, window);
if (! gl_sprite_init(&g_sprite_earth, "img/earth.png",
1, 1, 1))
return false;
@@ -197,9 +194,8 @@ bool window_sdl2_demo_load (s_window_sdl2 *window)
assert(glGetError() == GL_NO_ERROR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
assert(glGetError() == GL_NO_ERROR);
- window_sdl2_sequence_init(window->sequence + 4, 120.0,
- "05. Earth",
- earth_load, earth_render);
+ sequence_init(window->sequence + 4, 120.0, "05. Earth",
+ earth_load, earth_render, earth_unload, window);
assert(glGetError() == GL_NO_ERROR);
window_set_sequence_pos((s_window *) window, 0);
assert(glGetError() == GL_NO_ERROR);
@@ -253,21 +249,21 @@ static void render_text (s_gl_text *text, f64 x, f64 y)
assert(glGetError() == GL_NO_ERROR);
}
-bool window_sdl2_demo_render (s_window_sdl2 *window, void *context)
+bool window_sdl2_demo_render (s_window_sdl2 *window)
{
s_sequence *seq;
assert(window);
assert(glGetError() == GL_NO_ERROR);
if (! window_animate((s_window *) window))
return false;
- seq = window->sequence + window->sequence_pos;
+ seq = window->seq;
gl_matrix_4d_init_identity(&g_ortho.model_matrix);
gl_ortho_render(&g_ortho);
glEnable(GL_BLEND);
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
assert(glGetError() == GL_NO_ERROR);
- if (! seq->render(seq, window, context))
+ if (! seq->render(seq))
return false;
assert(glGetError() == GL_NO_ERROR);
/* 2D */
diff --git a/libc3/window/sdl2/types.h b/libc3/window/sdl2/types.h
index a4e3630..0f8e9de 100644
--- a/libc3/window/sdl2/types.h
+++ b/libc3/window/sdl2/types.h
@@ -63,8 +63,7 @@ typedef bool (*f_window_sdl2_motion) (s_window_sdl2 *window, sw x,
sw y);
/* return false to break event loop */
-typedef bool (*f_window_sdl2_render) (s_window_sdl2 *window,
- void *context);
+typedef bool (*f_window_sdl2_render) (s_window_sdl2 *window);
/* return false to break event loop */
typedef bool (*f_window_sdl2_resize) (s_window_sdl2 *window,
@@ -187,6 +186,7 @@ struct window_sdl2 {
f_window_sdl2_render render;
SDL_Window *sdl_window;
f_window_sdl2_resize resize;
+ s_sequence *seq;
s_sequence *sequence;
uw sequence_count;
uw sequence_pos;
diff --git a/libc3/window/sdl2/window_sdl2.c b/libc3/window/sdl2/window_sdl2.c
index f07c390..48fa5db 100644
--- a/libc3/window/sdl2/window_sdl2.c
+++ b/libc3/window/sdl2/window_sdl2.c
@@ -68,12 +68,10 @@ bool window_sdl2_default_motion_cb (s_window_sdl2 *window, sw x, sw y)
return true;
}
-bool window_sdl2_default_render_cb (s_window_sdl2 *window,
- void *sdl_window)
+bool window_sdl2_default_render_cb (s_window_sdl2 *window)
{
- (void) window;
- (void) sdl_window;
assert(window);
+ (void) window;
printf("window_sdl2_default_render_cb\n");
return true;
}
@@ -227,14 +225,14 @@ bool window_sdl2_run (s_window_sdl2 *window)
break;
case SDL_KEYDOWN:
if (! window->key(window, &sdl_event.key.keysym)) {
- err_puts("window_sdl2_run: window->key -> false");
+ err_puts("window_sdl2_run: window->key => false");
quit = 1;
}
break;
case SDL_MOUSEBUTTONDOWN:
if (! window->button(window, sdl_event.button.button,
sdl_event.button.x, sdl_event.button.y)) {
- err_puts("window_sdl2_run: window->button -> false");
+ err_puts("window_sdl2_run: window->button => false");
quit = 1;
}
break;
@@ -243,7 +241,7 @@ bool window_sdl2_run (s_window_sdl2 *window)
//int relativeY = sdl_event.motion.yrel;
if (! window->motion(window, sdl_event.motion.x,
sdl_event.motion.y)) {
- err_puts("window_sdl2_run: window->motion -> false");
+ err_puts("window_sdl2_run: window->motion => false");
quit = 1;
}
break;
@@ -251,7 +249,7 @@ bool window_sdl2_run (s_window_sdl2 *window)
if (sdl_event.window.event == SDL_WINDOWEVENT_RESIZED) {
if (! window->resize(window, sdl_event.window.data1,
sdl_event.window.data2)) {
- err_puts("window_sdl2_run: window->resize -> false");
+ err_puts("window_sdl2_run: window->resize => false");
quit = 1;
}
assert(glGetError() == GL_NO_ERROR);
@@ -269,8 +267,8 @@ bool window_sdl2_run (s_window_sdl2 *window)
}
assert(glGetError() == GL_NO_ERROR);
//glDrawBuffer(GL_BACK);
- if (! window->render(window, NULL)) {
- err_puts("window_sdl2_run: window->render -> false");
+ if (! window->render(window)) {
+ err_puts("window_sdl2_run: window->render => false");
quit = 1;
}
SDL_GL_SwapWindow(sdl_window);
@@ -283,19 +281,3 @@ bool window_sdl2_run (s_window_sdl2 *window)
SDL_DestroyWindow(sdl_window);
return false;
}
-
-s_sequence * window_sdl2_sequence_init
-(s_sequence *seq, f64 duration, const s8 *title,
- f_window_sdl2_sequence_load load,
- f_window_sdl2_sequence_render render)
-{
- assert(seq);
- seq->t = 0.0;
- seq->duration = duration;
- seq->frame = 0;
- seq->title = title;
- seq->load = (f_sequence_load) load;
- seq->render = (f_sequence_render) render;
- tag_init_void(&seq->tag);
- return seq;
-}
diff --git a/libc3/window/sdl2/window_sdl2.h b/libc3/window/sdl2/window_sdl2.h
index b5f1503..e1041f3 100644
--- a/libc3/window/sdl2/window_sdl2.h
+++ b/libc3/window/sdl2/window_sdl2.h
@@ -26,12 +26,6 @@ s_window_sdl2 * window_sdl2_init (s_window_sdl2 *window,
/* Operators. */
bool window_sdl2_run (s_window_sdl2 *window);
-/* Sequences. */
-s_sequence * window_sdl2_sequence_init
-(s_sequence *sequence, f64 duration, const s8 *title,
- f_window_sdl2_sequence_load load,
- f_window_sdl2_sequence_render render);
-
/* Callbacks. */
bool window_sdl2_default_button_cb (s_window_sdl2 *window, u8 button,
sw x, sw y);
@@ -39,8 +33,7 @@ bool window_sdl2_default_key_cb (s_window_sdl2 *window,
SDL_Keysym *keysym);
bool window_sdl2_default_load_cb (s_window_sdl2 *window);
bool window_sdl2_default_motion_cb (s_window_sdl2 *window, sw x, sw y);
-bool window_sdl2_default_render_cb (s_window_sdl2 *window,
- void *context);
+bool window_sdl2_default_render_cb (s_window_sdl2 *window);
bool window_sdl2_default_resize_cb (s_window_sdl2 *window, uw w, uw h);
void window_sdl2_default_unload_cb (s_window_sdl2 *window);
diff --git a/libc3/window/types.h b/libc3/window/types.h
index c14b999..91c4ab3 100644
--- a/libc3/window/types.h
+++ b/libc3/window/types.h
@@ -36,8 +36,7 @@ typedef bool (*f_window_load) (s_window *window);
typedef bool (*f_window_motion) (s_window *window, sw x, sw y);
/* return false to break event loop */
-typedef bool (*f_window_render) (s_window *window,
- void *render_context);
+typedef bool (*f_window_render) (s_window *window);
/* return false to break event loop */
typedef bool (*f_window_resize) (s_window *window,
@@ -61,6 +60,7 @@ struct window {
f_window_render render;
void *context;
f_window_resize resize;
+ s_sequence *seq;
s_sequence *sequence;
uw sequence_count;
uw sequence_pos;
diff --git a/libc3/window/window.c b/libc3/window/window.c
index b4550dd..95b41cc 100644
--- a/libc3/window/window.c
+++ b/libc3/window/window.c
@@ -92,8 +92,12 @@ bool window_set_sequence_pos (s_window *window, uw sequence_pos)
return false;
}
window->sequence_pos = sequence_pos;
+ if (window->seq)
+ if (! window->seq->unload(window->seq))
+ return false;
+ window->seq = seq;
io_puts(seq->title);
- if (! seq->load(seq, window))
+ if (! seq->load(seq))
return false;
return true;
}