/* By: ljiriste <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/27 14:29:26 by ljiriste #+# #+# */
-/* Updated: 2023/10/27 14:31:02 by ljiriste ### ########.fr */
+/* Updated: 2023/11/11 17:31:25 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
#include "color.h"
#include "vect2.h"
+int close_win(t_session *s)
+{
+ mlx_destroy_window(s->mlx, s->win);
+ return (0);
+}
+
void ft_putpx_img(t_img *img, int x, int y, t_color c)
{
char *px_addr;
int handle_key_press(int keycode, t_session *s)
{
if (keycode == XK_Escape)
- mlx_destroy_window(s->mlx, s->win);
+ close_win(s);
return (0);
}
s.img.addr = mlx_get_data_addr(s.img.img, &s.img.bpp, &s.img.bpl, &s.img.endian);
mlx_hook(s.win, KeyPress, KeyPressMask, handle_key_press, &s);
mlx_hook(s.win, ButtonPress, ButtonPressMask, handle_mouse_press, &s);
+ mlx_hook(s.win, DestroyNotify, NoEventMask, close_win, &s);
mlx_loop_hook(s.mlx, no_event_handle, &s);
draw_fractal(&s);
mlx_loop(s.mlx);