mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 01:48:08 +01:00
Added libft and mlx
This commit is contained in:
parent
8448ae3a23
commit
82d06d234a
122 changed files with 10400 additions and 0 deletions
63
mlx/mlx_loop.c
Normal file
63
mlx/mlx_loop.c
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
** mlx_loop.c for MiniLibX in
|
||||
**
|
||||
** Made by Charlie Root
|
||||
** Login <ol@epitech.net>
|
||||
**
|
||||
** Started on Wed Aug 2 18:58:11 2000 Charlie Root
|
||||
** Last update Fri Sep 30 14:47:41 2005 Olivier Crouzet
|
||||
*/
|
||||
|
||||
|
||||
#include "mlx_int.h"
|
||||
|
||||
extern int (*(mlx_int_param_event[]))();
|
||||
|
||||
static int win_count(t_xvar *xvar)
|
||||
{
|
||||
int i;
|
||||
t_win_list *win;
|
||||
|
||||
i = 0;
|
||||
win = xvar->win_list;
|
||||
while (win)
|
||||
{
|
||||
win = win->next;
|
||||
++i;
|
||||
}
|
||||
return (i);
|
||||
}
|
||||
|
||||
int mlx_loop_end(t_xvar *xvar)
|
||||
{
|
||||
xvar->end_loop = 1;
|
||||
return (1);
|
||||
}
|
||||
|
||||
int mlx_loop(t_xvar *xvar)
|
||||
{
|
||||
XEvent ev;
|
||||
t_win_list *win;
|
||||
|
||||
mlx_int_set_win_event_mask(xvar);
|
||||
xvar->do_flush = 0;
|
||||
while (win_count(xvar) && !xvar->end_loop)
|
||||
{
|
||||
while (!xvar->end_loop && (!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 == ClientMessage && ev.xclient.message_type == xvar->wm_protocols && ev.xclient.data.l[0] == xvar->wm_delete_window && win->hooks[DestroyNotify].hook)
|
||||
win->hooks[DestroyNotify].hook(win->hooks[DestroyNotify].param);
|
||||
if (win && ev.type < MLX_MAX_EVENT && win->hooks[ev.type].hook)
|
||||
mlx_int_param_event[ev.type](xvar, &ev, win);
|
||||
}
|
||||
XSync(xvar->display, False);
|
||||
if (xvar->loop_hook)
|
||||
xvar->loop_hook(xvar->loop_param);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue