From bdb258f6b2e239ccc3bfb7f44a5921831c1e5d16 Mon Sep 17 00:00:00 2001 From: mcolonna Date: Tue, 9 Apr 2024 14:18:49 +0200 Subject: [PATCH] fix: key autorepeat on at program end * --- dev/TODO.md | 1 - src/main/error.c | 4 +++- src/main/main.c | 5 ++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dev/TODO.md b/dev/TODO.md index 685e16d..9c27915 100644 --- a/dev/TODO.md +++ b/dev/TODO.md @@ -7,4 +7,3 @@ - walls all around - a possible way to exit - Program takes the map file -- Re-enable repeating keys at end of program diff --git a/src/main/error.c b/src/main/error.c index 598a3eb..555f7e8 100644 --- a/src/main/error.c +++ b/src/main/error.c @@ -6,7 +6,7 @@ /* By: mcolonna +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/26 16:05:21 by mcolonna #+# #+# */ -/* Updated: 2024/04/02 17:56:31 by mcolonna ### ########.fr */ +/* Updated: 2024/04/09 14:16:15 by mcolonna ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,6 +14,8 @@ static void end(int no) { + if (g_env.mlx) + mlx_do_key_autorepeaton(g_env.mlx); display_destroyall(); mem_freeall(g_env.mc); exit(no); diff --git a/src/main/main.c b/src/main/main.c index be07826..5deaa49 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -6,7 +6,7 @@ /* By: mcolonna +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/26 15:28:34 by mcolonna #+# #+# */ -/* Updated: 2024/04/08 17:18:03 by mcolonna ### ########.fr */ +/* Updated: 2024/04/09 14:16:56 by mcolonna ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,7 +20,6 @@ int expose_hook(void) int close_hook(void) { - mlx_do_key_autorepeaton(g_env.mlx); success(); return (0); } @@ -44,10 +43,10 @@ int main(void) { g_env.max_ketchup = 0; g_env.moves = 0; - g_env.mc = mem_newclass(error_err); g_env.mlx = mlx_init(); if (!g_env.mlx) error_err("mlx_init() failed"); + g_env.mc = mem_newclass(error_err); display_init(); g_env.win = mlx_new_window(g_env.mlx, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_TITLE);