From 6ac5d2296a48db38f464cd22f4e489dc7dbcf642 Mon Sep 17 00:00:00 2001 From: Mitya Selivanov Date: Fri, 25 Apr 2025 10:38:48 +0200 Subject: Add native window handle --- runtime.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'runtime.c') diff --git a/runtime.c b/runtime.c index 01877af..a00e301 100644 --- a/runtime.c +++ b/runtime.c @@ -25,9 +25,10 @@ // // STYLE CONVENTIONS // -// - Pascal_Snake_Case - Type name. -// - snake_case - Non-type name. -// - UPPER_SNAKE_CASE - Macro or constant. +// - Pascal_Snake_Case - Type name. +// - snake_case - Non-type name. +// - UPPER_SNAKE_CASE - Macro or constant. +// - UPPER_Pascal_Snake_Case - Constant. // // - g_ prefix - Global variable name. // - _ prefix - Name of a global variable that is not part of the user API. @@ -114,7 +115,10 @@ // - Windows sockets // - fetch - via libcurl on native platforms // - Lattice-based cipher suite -// - Switching canvas - Web +// - Web +// - Touch events +// - Mobile input +// - Switching canvas // - File system // - Secure random // - Process @@ -290,6 +294,14 @@ typedef unsigned char b8; typedef float f32; typedef double f64; +#if defined(__LP64__) || defined(_LP64) || defined(_WIN64) +typedef long long iptr; +typedef unsigned long long uptr; +#else +typedef signed iptr; +typedef unsigned uptr; +#endif + typedef union { struct { f64 v[ 2]; }; struct { f64 x, y; }; } vec2; typedef union { struct { f64 v[ 3]; }; struct { f64 x, y, z; }; } vec3; typedef union { struct { f64 v[ 4]; }; struct { f64 x, y, z, w; }; } vec4; @@ -655,12 +667,13 @@ typedef struct { b8 key_down [MAX_NUM_KEYS]; b8 key_pressed [MAX_NUM_KEYS]; + u64 native_window_handle; + i64 memory_buffer_size; u8 *memory_buffer; } Platform; // UTF-8 -// NOTE: We need UTF-8 because we use Xutf8LookupString on Xlib. i8 utf8_size (c32 c); UTF8_Char utf8_read (i64 len, c8 *s); i8 utf8_write(c32 c, c8 *buffer); @@ -3449,6 +3462,8 @@ void init_main_window(void) { return; } + g_platform.native_window_handle = (u64) _window; + _im = XOpenIM(_display, NULL, NULL, NULL); if (_im == NULL) { @@ -3518,7 +3533,8 @@ void init_main_window(void) { void shutdown_all_systems(void) { PROFILER_report_(); - g_platform.done = 1; + g_platform.done = 1; + g_platform.native_window_handle = 0; if (!g_platform.graceful_shutdown) return; -- cgit v1.2.3