changeset 485:3ff1fe64d0cd

core: window -> mlk_window
author David Demelier <markand@malikania.fr>
date Tue, 28 Feb 2023 08:40:35 +0100
parents f14b8290b3ce
children d6757c30658e
files examples/example-animation/example-animation.c examples/example-audio/example-audio.c examples/example-battle/example-battle.c examples/example-cursor/example-cursor.c examples/example-debug/example-debug.c examples/example-drawable/example-drawable.c examples/example-font/example-font.c examples/example-gridmenu/example-gridmenu.c examples/example-label/example-label.c examples/example-message/example-message.c examples/example-notify/example-notify.c examples/example-sprite/example-sprite.c examples/example-trace/example-trace.c examples/example-ui/example-ui.c libmlk-core/mlk/core/game.c libmlk-core/mlk/core/image.c libmlk-core/mlk/core/painter.c libmlk-core/mlk/core/texture.c libmlk-core/mlk/core/window.c libmlk-core/mlk/core/window.h libmlk-core/mlk/core/window_p.h libmlk-example/mlk/example/example.c libmlk-rpg/mlk/rpg/battle-bar-default.c libmlk-rpg/mlk/rpg/battle-message.c libmlk-rpg/mlk/rpg/battle-state-closing.c libmlk-rpg/mlk/rpg/battle-state-lost.c libmlk-rpg/mlk/rpg/battle-state-opening.c libmlk-rpg/mlk/rpg/battle-state-victory.c libmlk-rpg/mlk/rpg/battle.c libmlk-rpg/mlk/rpg/map.c libmlk-ui/mlk/ui/notify.c tests/test-map.c tests/test-tileset.c
diffstat 33 files changed, 120 insertions(+), 120 deletions(-) [+]
line wrap: on
line diff
--- a/examples/example-animation/example-animation.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/examples/example-animation/example-animation.c	Tue Feb 28 08:40:35 2023 +0100
@@ -56,7 +56,7 @@
 {
 	if (mlk_core_init("fr.malikania", "example-animation") < 0 || ui_init() < 0)
 		mlk_panic();
-	if (window_open("Example - Animation", W, H) < 0)
+	if (mlk_window_open("Example - Animation", W, H) < 0)
 		mlk_panic();
 	if (mlk_image_openmem(&numbers, assets_sprites_numbers, sizeof (assets_sprites_numbers)) < 0)
 		mlk_panic();
@@ -105,7 +105,7 @@
 	label_draw(&label);
 
 	if (!completed)
-		mlk_animation_draw(&animation, (window.w - sprite.cellw) / 2, (window.h - sprite.cellh) / 2);
+		mlk_animation_draw(&animation, (mlk_window.w - sprite.cellw) / 2, (mlk_window.h - sprite.cellh) / 2);
 
 	mlk_painter_present();
 }
@@ -130,7 +130,7 @@
 static void
 quit(void)
 {
-	window_finish();
+	mlk_window_finish();
 	ui_finish();
 	mlk_core_finish();
 }
--- a/examples/example-audio/example-audio.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/examples/example-audio/example-audio.c	Tue Feb 28 08:40:35 2023 +0100
@@ -61,7 +61,7 @@
 {
 	if (mlk_core_init("fr.malikania", "example-audio") < 0 || ui_init() < 0)
 		mlk_panic();
-	if (window_open("Example - Audio", W, H) < 0)
+	if (mlk_window_open("Example - Audio", W, H) < 0)
 		mlk_panic();
 	if (mlk_music_openmem(&music, assets_music_vabsounds_romance, sizeof (assets_music_vabsounds_romance)) < 0 ||
 	    mlk_sound_openmem(&sound, assets_sounds_fire, sizeof (assets_sounds_fire)) < 0)
@@ -71,7 +71,7 @@
 static void
 quit(void)
 {
-	window_finish();
+	mlk_window_finish();
 	ui_finish();
 	mlk_core_finish();
 }
--- a/examples/example-battle/example-battle.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/examples/example-battle/example-battle.c	Tue Feb 28 08:40:35 2023 +0100
@@ -132,7 +132,7 @@
 {
 	if (mlk_core_init("fr.malikania", "example-battle") < 0 || ui_init() < 0 || rpg_init() < 0)
 		mlk_panic();
-	if (window_open("Example - Battle", W, H) < 0)
+	if (mlk_window_open("Example - Battle", W, H) < 0)
 		mlk_panic();
 
 	registry_init();
@@ -328,7 +328,7 @@
 {
 	registry_finish();
 	theme_finish();
-	window_finish();
+	mlk_window_finish();
 	mlk_sys_finish();
 }
 
--- a/examples/example-cursor/example-cursor.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/examples/example-cursor/example-cursor.c	Tue Feb 28 08:40:35 2023 +0100
@@ -37,7 +37,7 @@
 
 static struct mlk_state *states[1];
 static char help_text[128];
-static enum window_cursor cursor = WINDOW_CURSOR_ARROW;
+static enum mlk_window_cursor cursor = MLK_WINDOW_CURSOR_ARROW;
 
 static struct label help = {
 	.x = 10,
@@ -51,12 +51,12 @@
 {
 	if (mlk_core_init("fr.malikania", "example-cursor") < 0 || ui_init() < 0)
 		mlk_panic();
-	if (window_open("Example - Cursor", W, H) < 0)
+	if (mlk_window_open("Example - Cursor", W, H) < 0)
 		mlk_panic();
 }
 
 static void
-change(enum window_cursor cursor)
+change(enum mlk_window_cursor cursor)
 {
 	static const char *names[] = {
 		[WINDOW_CURSOR_ARROW]           = "WINDOW_CURSOR_ARROW",
@@ -69,7 +69,7 @@
 	};
 
 	snprintf(help_text, sizeof (help_text), "Keys: <Left>/<Right> to change cursor. Current: %s", names[cursor]);
-	window_set_cursor(cursor);
+	mlk_window_set_cursor(cursor);
 }
 
 static void
@@ -85,7 +85,7 @@
 				change(--cursor);
 			break;
 		case MLK_KEY_RIGHT:
-			if (cursor + 1 < WINDOW_CURSOR_LAST)
+			if (cursor + 1 < MLK_WINDOW_CURSOR_LAST)
 				change(++cursor);
 			break;
 		default:
@@ -131,7 +131,7 @@
 static void
 quit(void)
 {
-	window_finish();
+	mlk_window_finish();
 	ui_finish();
 	mlk_core_finish();
 }
--- a/examples/example-debug/example-debug.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/examples/example-debug/example-debug.c	Tue Feb 28 08:40:35 2023 +0100
@@ -41,7 +41,7 @@
 {
 	if (mlk_core_init("fr.malikania", "example-debug") < 0 || ui_init() < 0)
 		mlk_panic();
-	if (window_open("Example - Debug", W, H) < 0)
+	if (mlk_window_open("Example - Debug", W, H) < 0)
 		mlk_panic();
 
 	debug_options.enable = 1;
@@ -95,7 +95,7 @@
 static void
 quit(void)
 {
-	window_finish();
+	mlk_window_finish();
 	ui_finish();
 	mlk_core_finish();
 }
--- a/examples/example-drawable/example-drawable.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/examples/example-drawable/example-drawable.c	Tue Feb 28 08:40:35 2023 +0100
@@ -76,7 +76,7 @@
 {
 	if (mlk_core_init("fr.malikania", "example-drawable") < 0 || ui_init() < 0)
 		mlk_panic();
-	if (window_open("Example - Drawable", W, H) < 0)
+	if (mlk_window_open("Example - Drawable", W, H) < 0)
 		mlk_panic();
 
 	/* 0: Explosion animation. */
@@ -191,7 +191,7 @@
 static void
 quit(void)
 {
-	window_finish();
+	mlk_window_finish();
 	ui_finish();
 	mlk_core_finish();
 }
--- a/examples/example-font/example-font.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/examples/example-font/example-font.c	Tue Feb 28 08:40:35 2023 +0100
@@ -55,7 +55,7 @@
 {
 	if (mlk_core_init("fr.malikania", "example-font") < 0 || ui_init() < 0)
 		mlk_panic();
-	if (window_open("Example - Font", W, H) < 0)
+	if (mlk_window_open("Example - Font", W, H) < 0)
 		mlk_panic();
 }
 
@@ -129,7 +129,7 @@
 static void
 quit(void)
 {
-	window_finish();
+	mlk_window_finish();
 	ui_finish();
 	mlk_core_finish();
 }
--- a/examples/example-gridmenu/example-gridmenu.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/examples/example-gridmenu/example-gridmenu.c	Tue Feb 28 08:40:35 2023 +0100
@@ -43,14 +43,14 @@
 {
 	if (mlk_core_init("fr.malikania", "example-gridmenu") < 0 || ui_init() < 0)
 		mlk_panic();
-	if (window_open("Example - Grid menu", W, H) < 0)
+	if (mlk_window_open("Example - Grid menu", W, H) < 0)
 		mlk_panic();
 }
 
 static void
 quit(void)
 {
-	window_finish();
+	mlk_window_finish();
 	ui_finish();
 	mlk_core_finish();
 }
--- a/examples/example-label/example-label.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/examples/example-label/example-label.c	Tue Feb 28 08:40:35 2023 +0100
@@ -108,7 +108,7 @@
 {
 	if (mlk_core_init("fr.malikania", "example-label") < 0 || ui_init() < 0)
 		mlk_panic();
-	if (window_open("Example - Label", W, H) < 0)
+	if (mlk_window_open("Example - Label", W, H) < 0)
 		mlk_panic();
 
 	for (size_t i = 0; i < MLK_UTIL_SIZE(table); ++i) {
@@ -123,7 +123,7 @@
 static void
 quit(void)
 {
-	window_finish();
+	mlk_window_finish();
 	ui_finish();
 	mlk_core_finish();
 }
--- a/examples/example-message/example-message.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/examples/example-message/example-message.c	Tue Feb 28 08:40:35 2023 +0100
@@ -50,14 +50,14 @@
 {
 	if (mlk_core_init("fr.malikania", "example-message") < 0 || ui_init() < 0 || rpg_init() < 0)
 		mlk_panic();
-	if (window_open("Example - Message", W, H) < 0)
+	if (mlk_window_open("Example - Message", W, H) < 0)
 		mlk_panic();
 }
 
 static void
 quit(void)
 {
-	window_finish();
+	mlk_window_finish();
 	rpg_finish();
 	ui_finish();
 	mlk_core_finish();
@@ -244,10 +244,10 @@
 static void
 smallbottom(void)
 {
-	const unsigned int w = window.w / 4;
+	const unsigned int w = mlk_window.w / 4;
 	const unsigned int h = MH;
-	const int x = (window.w / 2) - (w / 2);
-	const int y = (window.h - h - 10);
+	const int x = (mlk_window.w / 2) - (w / 2);
+	const int y = (mlk_window.h - h - 10);
 	const char * const text[] = {
 		"This one is small here."
 	};
--- a/examples/example-notify/example-notify.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/examples/example-notify/example-notify.c	Tue Feb 28 08:40:35 2023 +0100
@@ -53,7 +53,7 @@
 {
 	if (mlk_core_init("fr.malikania", "example-notify") < 0 || ui_init() < 0)
 		mlk_panic();
-	if (window_open("Example - Notify", W, H) < 0)
+	if (mlk_window_open("Example - Notify", W, H) < 0)
 		mlk_panic();
 	if (mlk_image_openmem(&icon, assets_images_sword, sizeof (assets_images_sword)) < 0)
 		mlk_panic();
@@ -114,7 +114,7 @@
 static void
 quit(void)
 {
-	window_finish();
+	mlk_window_finish();
 	ui_finish();
 	mlk_core_finish();
 }
--- a/examples/example-sprite/example-sprite.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/examples/example-sprite/example-sprite.c	Tue Feb 28 08:40:35 2023 +0100
@@ -67,7 +67,7 @@
 {
 	if (mlk_core_init("fr.malikania", "example-sprite") < 0 || ui_init() < 0)
 		mlk_panic();
-	if (window_open("Example - Sprite", W, H) < 0)
+	if (mlk_window_open("Example - Sprite", W, H) < 0)
 		mlk_panic();
 	if (mlk_image_openmem(&texture, assets_sprites_people, sizeof (assets_sprites_people)) < 0)
 		mlk_panic();
@@ -147,7 +147,7 @@
 quit(void)
 {
 	mlk_texture_finish(&texture);
-	window_finish();
+	mlk_window_finish();
 	ui_finish();
 	mlk_core_finish();
 }
--- a/examples/example-trace/example-trace.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/examples/example-trace/example-trace.c	Tue Feb 28 08:40:35 2023 +0100
@@ -42,7 +42,7 @@
 {
 	if (mlk_core_init("fr.malikania", "example-trace") < 0 || ui_init() < 0)
 		mlk_panic();
-	if (window_open("Example - Trace", W, H) < 0)
+	if (mlk_window_open("Example - Trace", W, H) < 0)
 		mlk_panic();
 
 	mlk_trace_handler = trace_hud_handler;
@@ -111,7 +111,7 @@
 static void
 quit(void)
 {
-	window_finish();
+	mlk_window_finish();
 	ui_finish();
 	mlk_core_finish();
 }
--- a/examples/example-ui/example-ui.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/examples/example-ui/example-ui.c	Tue Feb 28 08:40:35 2023 +0100
@@ -125,7 +125,7 @@
 {
 	if (mlk_core_init("fr.malikania", "example-ui") < 0 || ui_init() < 0)
 		mlk_panic();
-	if (window_open("Example - UI", W, H) < 0)
+	if (mlk_window_open("Example - UI", W, H) < 0)
 		mlk_panic();
 }
 
@@ -219,12 +219,12 @@
 			ui.motion.active = 1;
 			ui.motion.x = ev->click.x;
 			ui.motion.y = ev->click.y;
-			window_set_cursor(WINDOW_CURSOR_SIZE);
+			mlk_window_set_cursor(WINDOW_CURSOR_SIZE);
 		}
 		break;
 	case MLK_EVENT_CLICKUP:
 		ui.motion.active = 0;
-		window_set_cursor(WINDOW_CURSOR_ARROW);
+		mlk_window_set_cursor(WINDOW_CURSOR_ARROW);
 		break;
 	default:
 		break;
@@ -269,7 +269,7 @@
 static void
 quit(void)
 {
-	window_finish();
+	mlk_window_finish();
 	ui_finish();
 	mlk_core_finish();
 }
--- a/libmlk-core/mlk/core/game.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/libmlk-core/mlk/core/game.c	Tue Feb 28 08:40:35 2023 +0100
@@ -102,8 +102,8 @@
 	unsigned int elapsed = 0;
 	unsigned int frametime;
 
-	if (window.framerate > 0)
-		frametime = 1000 / window.framerate;
+	if (mlk_window.framerate > 0)
+		frametime = 1000 / mlk_window.framerate;
 	else
 		/* Assuming 50.0 FPS. */
 		frametime = 1000.0 / 50.0;
--- a/libmlk-core/mlk/core/image.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/libmlk-core/mlk/core/image.c	Tue Feb 28 08:40:35 2023 +0100
@@ -44,7 +44,7 @@
 	assert(tex);
 	assert(path);
 
-	if (!(tex->handle = IMG_LoadTexture(RENDERER(), path)))
+	if (!(tex->handle = IMG_LoadTexture(MLK__RENDERER(), path)))
 		return MLK_ERR_SDL;
 
 	dimensions(tex);
@@ -59,7 +59,7 @@
 
 	SDL_RWops *ops = SDL_RWFromConstMem(buffer, size);
 
-	if (!ops || !(tex->handle = IMG_LoadTexture_RW(RENDERER(), ops, 1)))
+	if (!ops || !(tex->handle = IMG_LoadTexture_RW(MLK__RENDERER(), ops, 1)))
 		return MLK_ERR_SDL;
 
 	dimensions(tex);
--- a/libmlk-core/mlk/core/painter.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/libmlk-core/mlk/core/painter.c	Tue Feb 28 08:40:35 2023 +0100
@@ -37,7 +37,7 @@
 mlk_painter_set_target(struct mlk_texture *tex)
 {
 	renderer = tex;
-	SDL_SetRenderTarget(RENDERER(), tex ? tex->handle : NULL);
+	SDL_SetRenderTarget(MLK__RENDERER(), tex ? tex->handle : NULL);
 }
 
 unsigned long
@@ -45,7 +45,7 @@
 {
 	Uint8 r = 0, g = 0, b = 0, a = 0;
 
-	SDL_GetRenderDrawColor(RENDERER(), &r, &g, &b, &a);
+	SDL_GetRenderDrawColor(MLK__RENDERER(), &r, &g, &b, &a);
 
 	return MLK_COLOR_HEX(r, g, b, a);
 }
@@ -54,7 +54,7 @@
 mlk_painter_set_color(unsigned long color)
 {
 	SDL_SetRenderDrawColor(
-		RENDERER(),
+		MLK__RENDERER(),
 		MLK_COLOR_R(color),
 		MLK_COLOR_G(color),
 		MLK_COLOR_B(color),
@@ -65,13 +65,13 @@
 void
 mlk_painter_draw_line(int x1, int y1, int x2, int y2)
 {
-	SDL_RenderDrawLine(RENDERER(), x1, y1, x2, y2);
+	SDL_RenderDrawLine(MLK__RENDERER(), x1, y1, x2, y2);
 }
 
 void
 mlk_painter_draw_point(int x1, int y1)
 {
-	SDL_RenderDrawPoint(RENDERER(), x1, y1);
+	SDL_RenderDrawPoint(MLK__RENDERER(), x1, y1);
 }
 
 void
@@ -84,7 +84,7 @@
 		.y = y
 	};
 
-	SDL_RenderFillRect(RENDERER(), &rect);
+	SDL_RenderFillRect(MLK__RENDERER(), &rect);
 }
 
 void
@@ -97,19 +97,19 @@
 	for (double dy = 1; dy <= radius; dy += 1.0) {
 		double dx = floor(sqrt((2.0 * radius * dy) - (dy * dy)));
 
-		SDL_RenderDrawLine(RENDERER(), x - dx, y + dy - radius, x + dx, y + dy - radius);
-		SDL_RenderDrawLine(RENDERER(), x - dx, y - dy + radius, x + dx, y - dy + radius);
+		SDL_RenderDrawLine(MLK__RENDERER(), x - dx, y + dy - radius, x + dx, y + dy - radius);
+		SDL_RenderDrawLine(MLK__RENDERER(), x - dx, y - dy + radius, x + dx, y - dy + radius);
 	}
 }
 
 void
 mlk_painter_clear(void)
 {
-	SDL_RenderClear(RENDERER());
+	SDL_RenderClear(MLK__RENDERER());
 }
 
 void
 mlk_painter_present(void)
 {
-	SDL_RenderPresent(RENDERER());
+	SDL_RenderPresent(MLK__RENDERER());
 }
--- a/libmlk-core/mlk/core/texture.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/libmlk-core/mlk/core/texture.c	Tue Feb 28 08:40:35 2023 +0100
@@ -34,7 +34,7 @@
 	assert(w);
 	assert(h);
 
-	tex->handle = SDL_CreateTexture(RENDERER(),
+	tex->handle = SDL_CreateTexture(MLK__RENDERER(),
 	    SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, w, h);
 
 	if (!tex->handle) {
@@ -108,7 +108,7 @@
 		.h = tex->h
 	};
 
-	if (SDL_RenderCopy(RENDERER(), tex->handle, NULL, &dst) < 0)
+	if (SDL_RenderCopy(MLK__RENDERER(), tex->handle, NULL, &dst) < 0)
 		return errorf("%s", SDL_GetError());
 
 	return 0;
@@ -139,7 +139,7 @@
 		.h = dst_h
 	};
 
-	if (SDL_RenderCopyEx(RENDERER(), tex->handle, &src, &dst, angle, NULL, SDL_FLIP_NONE) < 0)
+	if (SDL_RenderCopyEx(MLK__RENDERER(), tex->handle, &src, &dst, angle, NULL, SDL_FLIP_NONE) < 0)
 		return errorf("%s", SDL_GetError());
 
 	return 0;
@@ -164,7 +164,7 @@
 	assert(tex);
 	assert(surface);
 
-	if (!(tex->handle = SDL_CreateTextureFromSurface(RENDERER(), surface))) {
+	if (!(tex->handle = SDL_CreateTextureFromSurface(MLK__RENDERER(), surface))) {
 		tex->w = tex->h = 0;
 		return MLK_ERR_SDL;
 	}
--- a/libmlk-core/mlk/core/window.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/libmlk-core/mlk/core/window.c	Tue Feb 28 08:40:35 2023 +0100
@@ -26,27 +26,27 @@
 #include "window.h"
 #include "window_p.h"
 
-static struct window_handle handle = {
+static struct mlk__window_handle handle = {
 	.win = NULL,
 	.renderer = NULL
 };
 
-static SDL_Cursor *cursors[WINDOW_CURSOR_LAST];
+static SDL_Cursor *cursors[MLK_WINDOW_CURSOR_LAST];
 
-struct window window = {
+struct mlk_window mlk_window = {
 	.handle = &handle
 };
 
 static void
 load_cursors(void)
 {
-	cursors[WINDOW_CURSOR_ARROW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
-	cursors[WINDOW_CURSOR_EDIT] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
-	cursors[WINDOW_CURSOR_WAIT] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAIT);
-	cursors[WINDOW_CURSOR_CROSSHAIR] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_CROSSHAIR);
-	cursors[WINDOW_CURSOR_SIZE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL);
-	cursors[WINDOW_CURSOR_NO] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NO);
-	cursors[WINDOW_CURSOR_HAND] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND);
+	cursors[MLK_WINDOW_CURSOR_ARROW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
+	cursors[MLK_WINDOW_CURSOR_EDIT] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
+	cursors[MLK_WINDOW_CURSOR_WAIT] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAIT);
+	cursors[MLK_WINDOW_CURSOR_CROSSHAIR] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_CROSSHAIR);
+	cursors[MLK_WINDOW_CURSOR_SIZE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL);
+	cursors[MLK_WINDOW_CURSOR_NO] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NO);
+	cursors[MLK_WINDOW_CURSOR_HAND] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND);
 }
 
 static void
@@ -55,7 +55,7 @@
 	SDL_DisplayMode mode;
 
 	if (SDL_GetWindowDisplayMode(handle.win, &mode) == 0)
-		window.framerate = mode.refresh_rate;
+		mlk_window.framerate = mode.refresh_rate;
 }
 
 static void
@@ -79,15 +79,15 @@
 }
 
 int
-window_open(const char *title, unsigned int w, unsigned int h)
+mlk_window_open(const char *title, unsigned int w, unsigned int h)
 {
 	assert(title);
 
 	if (!load_window(title, w, h) || !load_renderer())
 		return MLK_ERR_SDL;
 
-	window.w = w;
-	window.h = h;
+	mlk_window.w = w;
+	mlk_window.h = h;
 
 	load_framerate();
 	load_cursors();
@@ -96,15 +96,15 @@
 }
 
 void
-window_set_cursor(enum window_cursor cursor)
+mlk_window_set_cursor(enum mlk_window_cursor cursor)
 {
-	assert(cursor < WINDOW_CURSOR_LAST);
+	assert(cursor < MLK_WINDOW_CURSOR_LAST);
 
 	SDL_SetCursor(cursors[cursor]);
 }
 
 void
-window_finish(void)
+mlk_window_finish(void)
 {
 	if (handle.renderer)
 		SDL_DestroyRenderer(handle.renderer);
--- a/libmlk-core/mlk/core/window.h	Mon Feb 27 19:47:09 2023 +0100
+++ b/libmlk-core/mlk/core/window.h	Tue Feb 28 08:40:35 2023 +0100
@@ -21,36 +21,36 @@
 
 #include "core.h"
 
-struct window {
+struct mlk_window {
 	unsigned int w;
 	unsigned int h;
 	unsigned int framerate;
 	void *handle;
 };
 
-enum window_cursor {
-	WINDOW_CURSOR_ARROW,
-	WINDOW_CURSOR_EDIT,
-	WINDOW_CURSOR_WAIT,
-	WINDOW_CURSOR_CROSSHAIR,
-	WINDOW_CURSOR_SIZE,
-	WINDOW_CURSOR_NO,
-	WINDOW_CURSOR_HAND,
-	WINDOW_CURSOR_LAST
+enum mlk_window_cursor {
+	MLK_WINDOW_CURSOR_ARROW,
+	MLK_WINDOW_CURSOR_EDIT,
+	MLK_WINDOW_CURSOR_WAIT,
+	MLK_WINDOW_CURSOR_CROSSHAIR,
+	MLK_WINDOW_CURSOR_SIZE,
+	MLK_WINDOW_CURSOR_NO,
+	MLK_WINDOW_CURSOR_HAND,
+	MLK_WINDOW_CURSOR_LAST
 };
 
-extern struct window window;
+extern struct mlk_window mlk_window;
 
 MLK_CORE_BEGIN_DECLS
 
 int
-window_open(const char *, unsigned int, unsigned int);
+mlk_window_open(const char *, unsigned int, unsigned int);
 
 void
-window_set_cursor(enum window_cursor);
+mlk_window_set_cursor(enum mlk_window_cursor);
 
 void
-window_finish(void);
+mlk_window_finish(void);
 
 MLK_CORE_END_DECLS
 
--- a/libmlk-core/mlk/core/window_p.h	Mon Feb 27 19:47:09 2023 +0100
+++ b/libmlk-core/mlk/core/window_p.h	Tue Feb 28 08:40:35 2023 +0100
@@ -1,5 +1,5 @@
 /*
- * window.c -- (PRIVATE) basic window management
+ * window_p.h -- (PRIVATE) basic window management
  *
  * Copyright (c) 2020-2023 David Demelier <markand@malikania.fr>
  *
@@ -21,13 +21,13 @@
 
 #include <SDL.h>
 
-struct window_handle {
+struct mlk__window_handle {
 	SDL_Window *win;
 	SDL_Renderer *renderer;
 };
 
 /* Convenient macros to access the native handle from global window object. */
-#define WINDOW()        (((struct window_handle *)window.handle)->win)
-#define RENDERER()      (((struct window_handle *)window.handle)->renderer)
+#define MLK__WINDOW()        (((struct mlk__window_handle *)mlk_window.handle)->win)
+#define MLK__RENDERER()      (((struct mlk__window_handle *)mlk_window.handle)->renderer)
 
 #endif /* !MLK_CORE_WINDOW_P_H */
--- a/libmlk-example/mlk/example/example.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/libmlk-example/mlk/example/example.c	Tue Feb 28 08:40:35 2023 +0100
@@ -42,7 +42,7 @@
 		return err;
 	if ((err = rpg_init()) < 0)
 		return err;
-	if (window_open(name, MLK_EXAMPLE_W, MLK_EXAMPLE_H) < 0)
+	if (mlk_window_open(name, MLK_EXAMPLE_W, MLK_EXAMPLE_H) < 0)
 		return err;
 
 	registry_init();
@@ -53,7 +53,7 @@
 void
 mlk_example_finish(void)
 {
-	window_finish();
+	mlk_window_finish();
 	rpg_finish();
 	ui_finish();
 	mlk_core_finish();
--- a/libmlk-rpg/mlk/rpg/battle-bar-default.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/libmlk-rpg/mlk/rpg/battle-bar-default.c	Tue Feb 28 08:40:35 2023 +0100
@@ -56,7 +56,7 @@
 	geo[0].w = bar->w * 0.2;
 	geo[0].h = bar->h;
 	geo[0].x = bar->x + (bar->w / 2) - (geo[0].w / 2);
-	geo[0].y = window.h - bar->h;
+	geo[0].y = mlk_window.h - bar->h;
 
 	/* 1 == status frame */
 	geo[1].x = geo[0].x + geo[0].w;
@@ -535,10 +535,10 @@
 
 	memset(bar, 0, sizeof (*bar));
 
-	bar->w = window.w;
-	bar->h = window.h * 0.12;
+	bar->w = mlk_window.w;
+	bar->h = mlk_window.h * 0.12;
 	bar->x = 0;
-	bar->y = window.h - bar->h;
+	bar->y = mlk_window.h - bar->h;
 
 	dimensions(geo, bar);
 
--- a/libmlk-rpg/mlk/rpg/battle-message.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/libmlk-rpg/mlk/rpg/battle-message.c	Tue Feb 28 08:40:35 2023 +0100
@@ -48,12 +48,12 @@
 	unsigned int lw = 0, lh = 0;
 
 	/* Prepare message frame. */
-	f.w = window.w / 3;
-	f.h = window.h / 15;
+	f.w = mlk_window.w / 3;
+	f.h = mlk_window.h / 15;
 	f.theme = msg->theme;
 
 	/* Center on top. */
-	align(ALIGN_TOP, &f.x, &f.y, f.w, f.h, 0, 20, window.w, window.h);
+	align(ALIGN_TOP, &f.x, &f.y, f.w, f.h, 0, 20, mlk_window.w, mlk_window.h);
 
 	/* Prepare message label box. */
 	l.text = msg->text;
--- a/libmlk-rpg/mlk/rpg/battle-state-closing.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/libmlk-rpg/mlk/rpg/battle-state-closing.c	Tue Feb 28 08:40:35 2023 +0100
@@ -65,14 +65,14 @@
 {
 	assert(cls);
 
-	if (mlk_texture_new(&cls->texture, window.w, window.h) < 0)
+	if (mlk_texture_new(&cls->texture, mlk_window.w, mlk_window.h) < 0)
 		mlk_panic();
 
 	MLK_PAINTER_BEGIN(&cls->texture);
 	mlk_texture_set_blend_mode(&cls->texture, MLK_TEXTURE_BLEND_BLEND);
 	mlk_painter_set_color(0x000000ff);
 	mlk_painter_clear();
-	mlk_painter_draw_rectangle(0, 0, window.w, window.h);
+	mlk_painter_draw_rectangle(0, 0, mlk_window.w, mlk_window.h);
 	MLK_PAINTER_END();
 
 	mlk_texture_set_alpha_mod(&cls->texture, 0);
--- a/libmlk-rpg/mlk/rpg/battle-state-lost.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/libmlk-rpg/mlk/rpg/battle-state-lost.c	Tue Feb 28 08:40:35 2023 +0100
@@ -75,9 +75,9 @@
 	message_start(&lost->msg);
 	message_query(&lost->msg, NULL, &lost->msg.h);
 
-	lost->msg.w = window.w * 0.6;
-	lost->msg.y = window.h * 0.1;
-	lost->msg.x = (window.w - lost->msg.w) / 2;
+	lost->msg.w = mlk_window.w * 0.6;
+	lost->msg.y = mlk_window.h * 0.1;
+	lost->msg.x = (mlk_window.w - lost->msg.w) / 2;
 
 	bt->status = BATTLE_STATUS_LOST;
 
--- a/libmlk-rpg/mlk/rpg/battle-state-opening.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/libmlk-rpg/mlk/rpg/battle-state-opening.c	Tue Feb 28 08:40:35 2023 +0100
@@ -82,8 +82,8 @@
 	assert(op);
 	assert(bt);
 
-	const unsigned int w = window.w;
-	const unsigned int h = window.h / 2;
+	const unsigned int w = mlk_window.w;
+	const unsigned int h = mlk_window.h / 2;
 	const unsigned int ch = op->elapsed * h / DELAY;
 
 	battle_draw_component(bt, BATTLE_COMPONENT_BACKGROUND | BATTLE_COMPONENT_ENTITIES);
--- a/libmlk-rpg/mlk/rpg/battle-state-victory.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/libmlk-rpg/mlk/rpg/battle-state-victory.c	Tue Feb 28 08:40:35 2023 +0100
@@ -76,9 +76,9 @@
 	message_start(&vic->msg);
 	message_query(&vic->msg, NULL, &vic->msg.h);
 
-	vic->msg.w = window.w * 0.6;
-	vic->msg.y = window.h * 0.1;
-	vic->msg.x = (window.w - vic->msg.w) / 2;
+	vic->msg.w = mlk_window.w * 0.6;
+	vic->msg.y = mlk_window.h * 0.1;
+	vic->msg.x = (mlk_window.w - vic->msg.w) / 2;
 
 	bt->status = BATTLE_STATUS_WON;
 
--- a/libmlk-rpg/mlk/rpg/battle.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/libmlk-rpg/mlk/rpg/battle.c	Tue Feb 28 08:40:35 2023 +0100
@@ -177,8 +177,8 @@
 	}
 
 	/* TODO: compute a correct x placement. */
-	spacing = (window.h - requirement) / (nmemb + 1);
-	x = window.w - 200;
+	spacing = (mlk_window.h - requirement) / (nmemb + 1);
+	x = mlk_window.w - 200;
 	y = spacing;
 
 	BATTLE_TEAM_FOREACH(bt, et) {
@@ -471,7 +471,7 @@
 	if ((comp & BATTLE_COMPONENT_BACKGROUND) && mlk_texture_ok(bt->background))
 		mlk_texture_scale(bt->background,
 		    0, 0, bt->background->w, bt->background->h,
-		    0, 0, window.w, window.h,
+		    0, 0, mlk_window.w, mlk_window.h,
 		    0.f);
 	if (comp & BATTLE_COMPONENT_ENTITIES) {
 		draw_entities(bt, bt->team, bt->teamsz);
--- a/libmlk-rpg/mlk/rpg/map.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/libmlk-rpg/mlk/rpg/map.c	Tue Feb 28 08:40:35 2023 +0100
@@ -164,8 +164,8 @@
 init(struct map *map)
 {
 	/* Adjust view. */
-	map->view_w = window.w;
-	map->view_h = window.h;
+	map->view_w = mlk_window.w;
+	map->view_h = mlk_window.h;
 
 	/* Adjust margin. */
 	map->margin_w = map->view_w - (MARGIN_WIDTH * 2) - map->player_sprite->cellw;
--- a/libmlk-ui/mlk/ui/notify.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/libmlk-ui/mlk/ui/notify.c	Tue Feb 28 08:40:35 2023 +0100
@@ -31,8 +31,8 @@
 #include "notify.h"
 #include "theme.h"
 
-#define WIDTH   (window.w / 3)
-#define HEIGHT  (window.h / 10)
+#define WIDTH   (mlk_window.w / 3)
+#define HEIGHT  (mlk_window.h / 10)
 
 struct geo {
 	const struct theme *theme;
@@ -66,7 +66,7 @@
 	geo->theme = system->theme ? system->theme : theme_default();
 
 	/* Determine notification position. */
-	x  = window.w - geo->theme->padding;
+	x  = mlk_window.w - geo->theme->padding;
 	x -= WIDTH;
 
 	y  = geo->theme->padding * (index + 1);;
--- a/tests/test-map.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/tests/test-map.c	Tue Feb 28 08:40:35 2023 +0100
@@ -134,7 +134,7 @@
 	 * we will skip if it fails to initialize.
 	 */
 
-	if (mlk_core_init("fr.malikania", "test") < 0 || window_open("test-map", 100, 100) < 0)
+	if (mlk_core_init("fr.malikania", "test") < 0 || mlk_window_open("test-map", 100, 100) < 0)
 		return 1;
 
 	DT_RUN(test_basics_sample);
--- a/tests/test-tileset.c	Mon Feb 27 19:47:09 2023 +0100
+++ b/tests/test-tileset.c	Tue Feb 28 08:40:35 2023 +0100
@@ -93,7 +93,7 @@
 int
 main(void)
 {
-	if (mlk_core_init("fr.malikania", "test") < 0 || window_open("test-tileset", 100, 100) < 0)
+	if (mlk_core_init("fr.malikania", "test") < 0 || mlk_window_open("test-tileset", 100, 100) < 0)
 		return 1;
 
 	DT_RUN(test_basics_sample);