Get latest upstream changes from internal project

This commit is contained in:
2026-10-19 12:21:40 +11:00
parent eb4e1c4d20
commit 7147ad52a2
10 changed files with 5428 additions and 3826 deletions
+66 -23
View File
@@ -7,12 +7,37 @@
#include "dn_os_windows.h"
#endif
typedef enum DN_OSW32DllLoadFunctionsResult
{
DN_OSW32DllLoadFunctionsResult_Ok,
DN_OSW32DllLoadFunctionsResult_LoadLibraryFailed,
DN_OSW32DllLoadFunctionsResult_FunctionMissing,
}
DN_OSW32DllLoadFunctionsResult;
typedef struct DN_OSW32DllFunction DN_OSW32DllLoadFunction;
struct DN_OSW32DllFunction
{
DN_Str8 name;
void *func_ptr;
};
typedef struct DN_OSW32DllCore DN_OSW32DllCore;
struct DN_OSW32DllCore
{
void* handle;
DN_OSW32DllFunction* functions;
DN_USize functions_count;
};
typedef struct DN_OSW32Error DN_OSW32Error;
struct DN_OSW32Error
{
unsigned long code;
DN_Str8 msg;
};
typedef struct DN_OSW32FolderIteratorW DN_OSW32FolderIteratorW;
struct DN_OSW32FolderIteratorW
{
void *handle;
@@ -20,6 +45,7 @@ struct DN_OSW32FolderIteratorW
wchar_t file_name_buf[512];
};
typedef struct DN_OSW32Window DN_OSW32Window;
struct DN_OSW32Window
{
HWND hwnd;
@@ -32,14 +58,16 @@ struct DN_OSW32Window
DN_OSW32Window *next;
};
enum DN_OSW32SyncPrimitiveType
typedef enum DN_OSW32SyncPrimitiveType
{
DN_OSW32SyncPrimitiveType_Semaphore,
DN_OSW32SyncPrimitiveType_Mutex,
DN_OSW32SyncPrimitiveType_ConditionVariable,
DN_OSW32SyncPrimitiveType_Barrier,
};
}
DN_OSW32SyncPrimitiveType;
typedef struct DN_OSW32SyncPrimitive DN_OSW32SyncPrimitive;
struct DN_OSW32SyncPrimitive
{
union
@@ -60,6 +88,7 @@ typedef HRESULT DN_OSW32GetDpiForMonitorFunc (HMONITOR hmonitor, MON
typedef int DN_OSW32GetSystemMetricsForDpiFunc (int nIndex, UINT dpi);
#define DN_OSW32DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((void*)-4)
typedef struct DN_OSW32Core DN_OSW32Core;
struct DN_OSW32Core
{
// NOTE: These functions are dynamically loaded because they might not be present on the user's
@@ -80,30 +109,44 @@ struct DN_OSW32Core
WNDPROC fallback_wnd_proc;
};
DN_API void DN_OS_W32Init (DN_OSW32Core *w32);
DN_API DN_OSW32Core* DN_OS_W32GetCore ();
DN_API void DN_OS_W32ThreadSetName (DN_Str8 name);
DN_API DN_OSW32Window* DN_OS_W32WindowFromHwndMaybeAlloc(DN_OSW32Core *w32, HWND hwnd, DN_Arena *arena);
DN_API LRESULT __stdcall DN_OS_W32WindowProcCustomTitlebar(HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_param);
////////////////////////////////////////////////////////////////////////////////////////////////////
// NOTE: DN Win32 book-keeping
DN_API void DN_OS_W32Init (DN_OSW32Core *w32);
DN_API DN_OSW32Core* DN_OS_W32GetCore ();
DN_API DN_OSW32Window* DN_OS_W32WindowFromHwndMaybeAlloc(DN_OSW32Core *w32, HWND hwnd, DN_Arena *arena);
DN_API DN_Str16 DN_OS_W32ErrorCodeToMsg16Alloc(DN_U32 error_code);
DN_API DN_OSW32Error DN_OS_W32ErrorCodeToMsg (DN_Arena *arena, DN_U32 error_code);
DN_API DN_OSW32Error DN_OS_W32ErrorCodeToMsgAlloc (DN_U32 error_code);
DN_API DN_OSW32Error DN_OS_W32LastError (DN_Arena *arena);
DN_API DN_OSW32Error DN_OS_W32LastErrorAlloc ();
DN_API void DN_OS_W32MakeProcessDPIAware ();
////////////////////////////////////////////////////////////////////////////////////////////////////
// NOTE: Process management
DN_API void DN_OS_W32ThreadSetName (DN_Str8 name);
DN_API LRESULT __stdcall DN_OS_W32WindowProcCustomTitlebar(HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_param);
DN_API void DN_OS_W32MakeProcessDPIAware ();
////////////////////////////////////////////////////////////////////////////////////////////////////
// NOTE: DLL
DN_API void DN_OS_W32DllUnload (DN_OSW32DllCore *dll);
DN_API DN_OSW32DllLoadFunctionsResult DN_OS_W32DllLoadFunctions (DN_OSW32DllCore *dll, DN_Str8 dll_path);
////////////////////////////////////////////////////////////////////////////////////////////////////
// NOTE: Errors
DN_API DN_Str16 DN_OS_W32ErrorCodeToMsg16Alloc (DN_U32 error_code);
DN_API DN_OSW32Error DN_OS_W32ErrorCodeToMsg (DN_Arena *arena, DN_U32 error_code);
DN_API DN_OSW32Error DN_OS_W32ErrorCodeToMsgAlloc (DN_U32 error_code);
DN_API DN_OSW32Error DN_OS_W32LastError (DN_Arena *arena);
DN_API DN_OSW32Error DN_OS_W32LastErrorAlloc ();
////////////////////////////////////////////////////////////////////////////////////////////////////
// NOTE: Windows Str8 <-> Str16
DN_API DN_Str16 DN_OS_W32Str8ToStr16 (DN_Arena *arena, DN_Str8 src);
DN_API int DN_OS_W32Str8ToStr16Buffer (DN_Str16 src, char *dest, int dest_size);
DN_API DN_Str8 DN_OS_W32Str16ToStr8 (DN_Arena *arena, DN_Str16 src);
DN_API int DN_OS_W32Str16ToStr8Buffer (DN_Str16 src, char *dest, int dest_size);
DN_API DN_Str8 DN_OS_W32Str16ToStr8FromHeap (DN_Str16 src);
DN_API DN_Str16 DN_OS_W32Str8ToStr16 (DN_Arena *arena, DN_Str8 src);
DN_API int DN_OS_W32Str8ToStr16Buffer (DN_Str16 src, char *dest, int dest_size);
DN_API DN_Str8 DN_OS_W32Str16ToStr8 (DN_Arena *arena, DN_Str16 src);
DN_API int DN_OS_W32Str16ToStr8Buffer (DN_Str16 src, char *dest, int dest_size);
DN_API DN_Str8 DN_OS_W32Str16ToStr8FromHeap (DN_Str16 src);
////////////////////////////////////////////////////////////////////////////////////////////////////
// NOTE: Path navigation
DN_API DN_Str16 DN_OS_W32EXEPathW (DN_Arena *arena);
DN_API DN_Str16 DN_OS_W32EXEDirW (DN_Arena *arena);
DN_API DN_Str8 DN_OS_W32WorkingDir (DN_Arena *arena, DN_Str8 suffix);
DN_API DN_Str16 DN_OS_W32WorkingDirW (DN_Arena *arena, DN_Str16 suffix);
DN_API bool DN_OS_W32DirWIterate (DN_Str16 path, DN_OSW32FolderIteratorW *it);
DN_API DN_Str16 DN_OS_W32ExePathW (DN_Arena *arena);
DN_API DN_Str16 DN_OS_W32ExeDirW (DN_Arena *arena);
DN_API DN_Str8 DN_OS_W32WorkingDir (DN_Arena *arena, DN_Str8 suffix);
DN_API DN_Str16 DN_OS_W32WorkingDirW (DN_Arena *arena, DN_Str16 suffix);
DN_API bool DN_OS_W32DirWIterate (DN_Str16 path, DN_OSW32FolderIteratorW *it);
#endif // !defined(DN_OS_W32_H)