[sdl] stub: handle SDL events
This commit is contained in:
parent
a31e039e09
commit
1bdb46d305
|
@ -110,6 +110,7 @@ struct window_args_list {
|
||||||
|
|
||||||
static void load_fonts(struct ax_backend* bac, struct font_list* fl);
|
static void load_fonts(struct ax_backend* bac, struct font_list* fl);
|
||||||
static void make_windows(struct ax_backend* bac, struct window_args_list* wl);
|
static void make_windows(struct ax_backend* bac, struct window_args_list* wl);
|
||||||
|
static void handle_events(void);
|
||||||
static void render_windows(struct window_list* wl);
|
static void render_windows(struct window_list* wl);
|
||||||
|
|
||||||
void ax__backend_step(struct ax_backend* bac)
|
void ax__backend_step(struct ax_backend* bac)
|
||||||
|
@ -168,11 +169,32 @@ void ax__backend_step(struct ax_backend* bac)
|
||||||
load_fonts(bac, fonts);
|
load_fonts(bac, fonts);
|
||||||
make_windows(bac, ax__reverse_list(windows));
|
make_windows(bac, ax__reverse_list(windows));
|
||||||
render_windows(bac->windows);
|
render_windows(bac->windows);
|
||||||
|
handle_events();
|
||||||
|
|
||||||
rgn_cleanup(&tmp_rgn);
|
rgn_cleanup(&tmp_rgn);
|
||||||
// printf("ping. %zu message(s)\n", nmsg);
|
// printf("ping. %zu message(s)\n", nmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* Event handling
|
||||||
|
* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
static void handle_events(void)
|
||||||
|
{
|
||||||
|
SDL_Event ev;
|
||||||
|
while (SDL_PollEvent(&ev)) {
|
||||||
|
switch (ev.type) {
|
||||||
|
case SDL_QUIT:
|
||||||
|
printf("pls quit...\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
printf("some event of type: %d\n", ev.type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Fonts
|
* Fonts
|
||||||
* -------------------------------------------------------------------------- */
|
* -------------------------------------------------------------------------- */
|
||||||
|
@ -231,7 +253,7 @@ struct window_handle {
|
||||||
SDL_Renderer* rnd;
|
SDL_Renderer* rnd;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void cleanup_window_handle(struct window_handle*);
|
static void window_handle_cleanup(struct window_handle*);
|
||||||
|
|
||||||
static int new_window_handle(
|
static int new_window_handle(
|
||||||
struct rgn* rgn,
|
struct rgn* rgn,
|
||||||
|
@ -242,7 +264,7 @@ static int new_window_handle(
|
||||||
struct window_handle* wh = ralloc_typed(rgn, struct window_handle, 1);
|
struct window_handle* wh = ralloc_typed(rgn, struct window_handle, 1);
|
||||||
wh->win = NULL;
|
wh->win = NULL;
|
||||||
wh->rnd = NULL;
|
wh->rnd = NULL;
|
||||||
rgn_pin(rgn, wh, (void*) cleanup_window_handle);
|
rgn_pin(rgn, wh, (void*) window_handle_cleanup);
|
||||||
|
|
||||||
int rv;
|
int rv;
|
||||||
if ((rv = SDL_CreateWindowAndRenderer((int) args->width,
|
if ((rv = SDL_CreateWindowAndRenderer((int) args->width,
|
||||||
|
@ -259,7 +281,7 @@ static int new_window_handle(
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cleanup_window_handle(struct window_handle* wh)
|
static void window_handle_cleanup(struct window_handle* wh)
|
||||||
{
|
{
|
||||||
SDL_DestroyRenderer(wh->rnd);
|
SDL_DestroyRenderer(wh->rnd);
|
||||||
SDL_DestroyWindow(wh->win);
|
SDL_DestroyWindow(wh->win);
|
||||||
|
|
Loading…
Reference in New Issue