aboutsummaryrefslogtreecommitdiffstats
path: root/minilibx-linux/mlx_loop.c
diff options
context:
space:
mode:
Diffstat (limited to 'minilibx-linux/mlx_loop.c')
-rw-r--r--minilibx-linux/mlx_loop.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/minilibx-linux/mlx_loop.c b/minilibx-linux/mlx_loop.c
index 74af0a5..11b2a41 100644
--- a/minilibx-linux/mlx_loop.c
+++ b/minilibx-linux/mlx_loop.c
@@ -16,23 +16,27 @@ extern int (*(mlx_int_param_event[]))();
int mlx_loop(t_xvar *xvar)
{
- XEvent ev;
- t_win_list *win;
+ XEvent ev;
+ t_win_list *win;
- mlx_int_set_win_event_mask(xvar);
- xvar->do_flush = 0;
- while (42)
- {
- while (!xvar->loop_hook || XPending(xvar->display))
+ mlx_int_set_win_event_mask(xvar);
+ xvar->do_flush = 0;
+ while (42)
{
- XNextEvent(xvar->display,&ev);
- win = xvar->win_list;
- while (win && (win->window!=ev.xany.window))
- win = win->next;
- if (win && ev.type < MLX_MAX_EVENT)
- if (win->hooks[ev.type].hook)
- mlx_int_param_event[ev.type](xvar, &ev, win);
+ while (!xvar->loop_hook || XPending(xvar->display))
+ {
+ XNextEvent(xvar->display,&ev);
+ win = xvar->win_list;
+ while (win && (win->window!=ev.xany.window))
+ win = win->next;
+ if (win && ev.type < MLX_MAX_EVENT)
+ {
+ if (ev.type == ClientMessage && (Atom)ev.xclient.data.l[0] == xvar->wm_delete_window)
+ XDestroyWindow(xvar->display, win->window);
+ if (win->hooks[ev.type].hook)
+ mlx_int_param_event[ev.type](xvar, &ev, win);
+ }
+ }
+ xvar->loop_hook(xvar->loop_param);
}
- xvar->loop_hook(xvar->loop_param);
- }
}