diff options
-rw-r--r-- | minilibx-linux/Makefile.gen | 2 | ||||
-rw-r--r-- | minilibx-linux/Makefile.mk | 2 | ||||
-rw-r--r-- | minilibx-linux/README.md (renamed from minilibx-linux/=README=) | 0 | ||||
-rwxr-xr-x | minilibx-linux/configure | 1 | ||||
-rw-r--r-- | minilibx-linux/man/man1/mlx_pixel_put.1 | 13 | ||||
-rw-r--r-- | minilibx-linux/mlx.h | 4 | ||||
-rw-r--r-- | minilibx-linux/mlx_mouse.c | 26 | ||||
-rw-r--r-- | src/ft_hooks_and_loops.c | 3 |
8 files changed, 43 insertions, 8 deletions
diff --git a/minilibx-linux/Makefile.gen b/minilibx-linux/Makefile.gen index f1b7b36..629a0a4 100644 --- a/minilibx-linux/Makefile.gen +++ b/minilibx-linux/Makefile.gen @@ -28,7 +28,7 @@ SRC = mlx_init.c mlx_new_window.c mlx_pixel_put.c mlx_loop.c \ mlx_put_image_to_window.c mlx_get_color_value.c mlx_clear_window.c \ mlx_xpm.c mlx_int_str_to_wordtab.c mlx_destroy_window.c \ mlx_int_param_event.c mlx_int_set_win_event_mask.c mlx_hook.c \ - mlx_rgb.c mlx_destroy_image.c mlx_screen_size.c + mlx_rgb.c mlx_destroy_image.c mlx_mouse.c mlx_screen_size.c OBJ =$(SRC:.c=.o) CFLAGS = -O3 -I$(INC) diff --git a/minilibx-linux/Makefile.mk b/minilibx-linux/Makefile.mk index 8aec9f8..4b4deb8 100644 --- a/minilibx-linux/Makefile.mk +++ b/minilibx-linux/Makefile.mk @@ -28,7 +28,7 @@ SRC = mlx_init.c mlx_new_window.c mlx_pixel_put.c mlx_loop.c \ mlx_put_image_to_window.c mlx_get_color_value.c mlx_clear_window.c \ mlx_xpm.c mlx_int_str_to_wordtab.c mlx_destroy_window.c \ mlx_int_param_event.c mlx_int_set_win_event_mask.c mlx_hook.c \ - mlx_rgb.c mlx_destroy_image.c mlx_screen_size.c + mlx_rgb.c mlx_destroy_image.c mlx_mouse.c mlx_screen_size.c OBJ =$(SRC:.c=.o) CFLAGS = -O3 -I$(INC) diff --git a/minilibx-linux/=README= b/minilibx-linux/README.md index 65d5429..65d5429 100644 --- a/minilibx-linux/=README= +++ b/minilibx-linux/README.md diff --git a/minilibx-linux/configure b/minilibx-linux/configure index 2f9b0be..04fcdc4 100755 --- a/minilibx-linux/configure +++ b/minilibx-linux/configure @@ -15,6 +15,7 @@ for inc in \ /usr/X11R5/include \ /usr/X11R4/include \ \ + /usr/include \ /usr/include/X11 \ /usr/include/X11R6 \ /usr/include/X11R5 \ diff --git a/minilibx-linux/man/man1/mlx_pixel_put.1 b/minilibx-linux/man/man1/mlx_pixel_put.1 index f4d131e..258df58 100644 --- a/minilibx-linux/man/man1/mlx_pixel_put.1 +++ b/minilibx-linux/man/man1/mlx_pixel_put.1 @@ -63,11 +63,14 @@ to create the original color. Theses three values must be set inside the integer to display the right color. The three least significant bytes of this integer are filled as shown in the picture below: -.nf - | 0 | R | G | B | color integer - +---+---+---+---+ -.fi - +.TS +allbox; +c s s s s +r c c c c. +Color Integer +Interpretation \[*a] R G B +Bit numbers 31..24 23..16 15..8 7..0 +.TE While filling the integer, make sure you avoid endian problems. Remember that the "blue" byte should always be the least significant one. diff --git a/minilibx-linux/mlx.h b/minilibx-linux/mlx.h index af6af12..951871c 100644 --- a/minilibx-linux/mlx.h +++ b/minilibx-linux/mlx.h @@ -126,6 +126,10 @@ int mlx_do_key_autorepeatoff(void *mlx_ptr); int mlx_do_key_autorepeaton(void *mlx_ptr); int mlx_do_sync(void *mlx_ptr); +int mlx_mouse_move(void *mlx_ptr, void *win_ptr, int x, int y); +int mlx_mouse_hide(void *mlx_ptr, void *win_ptr); +int mlx_mouse_show(void *mlx_ptr, void *win_ptr); + int mlx_get_screen_size(void *mlx_ptr, int *sizex, int *sizey); #endif /* MLX_H */ diff --git a/minilibx-linux/mlx_mouse.c b/minilibx-linux/mlx_mouse.c new file mode 100644 index 0000000..0ada4e4 --- /dev/null +++ b/minilibx-linux/mlx_mouse.c @@ -0,0 +1,26 @@ +#include "mlx_int.h" + +int mlx_mouse_move(t_xvar *xvar, t_win_list *win, int x, int y) +{ + XWarpPointer(xvar->display, None, win->window, 0, 0, 0, 0, x, y); + return (0); +} + +int mlx_mouse_hide(t_xvar *xvar, t_win_list *win) +{ + static char data[1] = {0}; + Cursor cursor; + Pixmap blank; + XColor dummy; + + blank = XCreateBitmapFromData(xvar->display, win->window, data, 1, 1); + cursor = XCreatePixmapCursor(xvar->display, blank, blank, &dummy, &dummy, 0, 0); + XDefineCursor(xvar->display, win->window, cursor); + XFreePixmap(xvar->display, blank); + XFreeCursor(xvar->display, cursor); +} + +int mlx_mouse_show(t_xvar *xvar, t_win_list *win) +{ + XUndefineCursor(xvar->display, win->window); +} diff --git a/src/ft_hooks_and_loops.c b/src/ft_hooks_and_loops.c index b8bdd36..c1ab352 100644 --- a/src/ft_hooks_and_loops.c +++ b/src/ft_hooks_and_loops.c @@ -13,13 +13,14 @@ #include <libft.h> #include <cub3d.h> #include <mlx.h> +#include <X11/Xlib.h> void ft_hooks_and_loops(t_win *wl, t_cub *cl) { mlx_hook(wl->winptr, 2, (1L << 0), ft_key_event, cl); mlx_hook(wl->winptr, 3, (1L << 1), ft_key_release, cl); + mlx_hook(wl->winptr, DestroyNotify, StructureNotifyMask, ft_click_close, cl); mlx_loop_hook(wl->wlx, ft_key_loop, cl); - mlx_hook(wl->winptr, 17, 0L, ft_click_close, cl); mlx_loop(wl->wlx); } |