From f906f7ae3f96762fa3257fbb79c3423231fb73e3 Mon Sep 17 00:00:00 2001 From: Kasper de Bruin Date: Fri, 19 Jan 2024 13:58:24 +0100 Subject: [PATCH] add option to remove titlebar --- include/GLFW/glfw3.h | 1492 +++++++++++---------- include/GLFW/glfw3native.h | 80 +- src/cocoa_init.m | 884 ++++++------- src/cocoa_platform.h | 1 + src/cocoa_window.m | 2508 ++++++++++++++++-------------------- src/init.c | 2 + src/internal.h | 1314 ++++++++++--------- tests/triangle-vulkan.c | 4 + 8 files changed, 3093 insertions(+), 3192 deletions(-) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 5e6fad42..22830a5d 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -85,7 +85,6 @@ extern "C" { * information, see the @ref window_guide. */ - /************************************************************************* * Compiler- and platform-specific preprocessor work *************************************************************************/ @@ -108,7 +107,7 @@ extern "C" { #include #if defined(GLFW_INCLUDE_VULKAN) - #include +#include #endif /* Vulkan header */ /* The Vulkan header may have indirectly included windows.h (because of @@ -119,98 +118,98 @@ extern "C" { * all platforms. Additionally, the Windows OpenGL header needs APIENTRY. */ #if !defined(APIENTRY) - #if defined(_WIN32) - #define APIENTRY __stdcall - #else - #define APIENTRY - #endif - #define GLFW_APIENTRY_DEFINED +#if defined(_WIN32) +#define APIENTRY __stdcall +#else +#define APIENTRY +#endif +#define GLFW_APIENTRY_DEFINED #endif /* APIENTRY */ /* Some Windows OpenGL headers need this. */ #if !defined(WINGDIAPI) && defined(_WIN32) - #define WINGDIAPI __declspec(dllimport) - #define GLFW_WINGDIAPI_DEFINED +#define WINGDIAPI __declspec(dllimport) +#define GLFW_WINGDIAPI_DEFINED #endif /* WINGDIAPI */ /* Some Windows GLU headers need this. */ #if !defined(CALLBACK) && defined(_WIN32) - #define CALLBACK __stdcall - #define GLFW_CALLBACK_DEFINED +#define CALLBACK __stdcall +#define GLFW_CALLBACK_DEFINED #endif /* CALLBACK */ /* Include the chosen OpenGL or OpenGL ES headers. */ #if defined(GLFW_INCLUDE_ES1) - #include - #if defined(GLFW_INCLUDE_GLEXT) - #include - #endif +#include +#if defined(GLFW_INCLUDE_GLEXT) +#include +#endif #elif defined(GLFW_INCLUDE_ES2) - #include - #if defined(GLFW_INCLUDE_GLEXT) - #include - #endif +#include +#if defined(GLFW_INCLUDE_GLEXT) +#include +#endif #elif defined(GLFW_INCLUDE_ES3) - #include - #if defined(GLFW_INCLUDE_GLEXT) - #include - #endif +#include +#if defined(GLFW_INCLUDE_GLEXT) +#include +#endif #elif defined(GLFW_INCLUDE_ES31) - #include - #if defined(GLFW_INCLUDE_GLEXT) - #include - #endif +#include +#if defined(GLFW_INCLUDE_GLEXT) +#include +#endif #elif defined(GLFW_INCLUDE_ES32) - #include - #if defined(GLFW_INCLUDE_GLEXT) - #include - #endif +#include +#if defined(GLFW_INCLUDE_GLEXT) +#include +#endif #elif defined(GLFW_INCLUDE_GLCOREARB) - #if defined(__APPLE__) +#if defined(__APPLE__) - #include - #if defined(GLFW_INCLUDE_GLEXT) - #include - #endif /*GLFW_INCLUDE_GLEXT*/ +#include +#if defined(GLFW_INCLUDE_GLEXT) +#include +#endif /*GLFW_INCLUDE_GLEXT*/ - #else /*__APPLE__*/ +#else /*__APPLE__*/ - #include - #if defined(GLFW_INCLUDE_GLEXT) - #include - #endif +#include +#if defined(GLFW_INCLUDE_GLEXT) +#include +#endif - #endif /*__APPLE__*/ +#endif /*__APPLE__*/ #elif defined(GLFW_INCLUDE_GLU) - #if defined(__APPLE__) +#if defined(__APPLE__) - #if defined(GLFW_INCLUDE_GLU) - #include - #endif +#if defined(GLFW_INCLUDE_GLU) +#include +#endif - #else /*__APPLE__*/ +#else /*__APPLE__*/ - #if defined(GLFW_INCLUDE_GLU) - #include - #endif +#if defined(GLFW_INCLUDE_GLU) +#include +#endif - #endif /*__APPLE__*/ +#endif /*__APPLE__*/ #elif !defined(GLFW_INCLUDE_NONE) && \ !defined(__gl_h_) && \ @@ -229,49 +228,48 @@ extern "C" { !defined(__gltypes_h_) /*non-standard*/ && \ !defined(__glee_h_) /*non-standard*/ - #if defined(__APPLE__) +#if defined(__APPLE__) - #if !defined(GLFW_INCLUDE_GLEXT) - #define GL_GLEXT_LEGACY - #endif - #include +#if !defined(GLFW_INCLUDE_GLEXT) +#define GL_GLEXT_LEGACY +#endif +#include - #else /*__APPLE__*/ +#else /*__APPLE__*/ - #include - #if defined(GLFW_INCLUDE_GLEXT) - #include - #endif +#include +#if defined(GLFW_INCLUDE_GLEXT) +#include +#endif - #endif /*__APPLE__*/ +#endif /*__APPLE__*/ #endif /* OpenGL and OpenGL ES headers */ #if defined(GLFW_DLL) && defined(_GLFW_BUILD_DLL) - /* GLFW_DLL must be defined by applications that are linking against the DLL - * version of the GLFW library. _GLFW_BUILD_DLL is defined by the GLFW - * configuration header when compiling the DLL version of the library. - */ - #error "You must not have both GLFW_DLL and _GLFW_BUILD_DLL defined" +/* GLFW_DLL must be defined by applications that are linking against the DLL + * version of the GLFW library. _GLFW_BUILD_DLL is defined by the GLFW + * configuration header when compiling the DLL version of the library. + */ +#error "You must not have both GLFW_DLL and _GLFW_BUILD_DLL defined" #endif /* GLFWAPI is used to declare public API functions for export * from the DLL / shared library / dynamic library. */ #if defined(_WIN32) && defined(_GLFW_BUILD_DLL) - /* We are building GLFW as a Win32 DLL */ - #define GLFWAPI __declspec(dllexport) +/* We are building GLFW as a Win32 DLL */ +#define GLFWAPI __declspec(dllexport) #elif defined(_WIN32) && defined(GLFW_DLL) - /* We are calling a GLFW Win32 DLL */ - #define GLFWAPI __declspec(dllimport) +/* We are calling a GLFW Win32 DLL */ +#define GLFWAPI __declspec(dllimport) #elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL) - /* We are building GLFW as a Unix shared library */ - #define GLFWAPI __attribute__((visibility("default"))) +/* We are building GLFW as a Unix shared library */ +#define GLFWAPI __attribute__((visibility("default"))) #else - #define GLFWAPI +#define GLFWAPI #endif - /************************************************************************* * GLFW API tokens *************************************************************************/ @@ -284,21 +282,21 @@ extern "C" { * API is changed in non-compatible ways. * @ingroup init */ -#define GLFW_VERSION_MAJOR 3 +#define GLFW_VERSION_MAJOR 3 /*! @brief The minor version number of the GLFW header. * * The minor version number of the GLFW header. This is incremented when * features are added to the API but it remains backward-compatible. * @ingroup init */ -#define GLFW_VERSION_MINOR 4 +#define GLFW_VERSION_MINOR 4 /*! @brief The revision number of the GLFW header. * * The revision number of the GLFW header. This is incremented when a bug fix * release is made that does not contain any API changes. * @ingroup init */ -#define GLFW_VERSION_REVISION 0 +#define GLFW_VERSION_REVISION 0 /*! @} */ /*! @brief One. @@ -309,7 +307,7 @@ extern "C" { * * @ingroup init */ -#define GLFW_TRUE 1 +#define GLFW_TRUE 1 /*! @brief Zero. * * This is only semantic sugar for the number 0. You can instead use `0` or @@ -318,7 +316,7 @@ extern "C" { * * @ingroup init */ -#define GLFW_FALSE 0 +#define GLFW_FALSE 0 /*! @name Key and button actions * @{ */ @@ -328,21 +326,21 @@ extern "C" { * * @ingroup input */ -#define GLFW_RELEASE 0 +#define GLFW_RELEASE 0 /*! @brief The key or mouse button was pressed. * * The key or mouse button was pressed. * * @ingroup input */ -#define GLFW_PRESS 1 +#define GLFW_PRESS 1 /*! @brief The key was held down until it repeated. * * The key was held down until it repeated. * * @ingroup input */ -#define GLFW_REPEAT 2 +#define GLFW_REPEAT 2 /*! @} */ /*! @defgroup hat_state Joystick hat states @@ -352,24 +350,19 @@ extern "C" { * * @ingroup input * @{ */ -#define GLFW_HAT_CENTERED 0 -#define GLFW_HAT_UP 1 -#define GLFW_HAT_RIGHT 2 -#define GLFW_HAT_DOWN 4 -#define GLFW_HAT_LEFT 8 -#define GLFW_HAT_RIGHT_UP (GLFW_HAT_RIGHT | GLFW_HAT_UP) -#define GLFW_HAT_RIGHT_DOWN (GLFW_HAT_RIGHT | GLFW_HAT_DOWN) -#define GLFW_HAT_LEFT_UP (GLFW_HAT_LEFT | GLFW_HAT_UP) -#define GLFW_HAT_LEFT_DOWN (GLFW_HAT_LEFT | GLFW_HAT_DOWN) - -/*! @ingroup input - */ -#define GLFW_KEY_UNKNOWN -1 - +#define GLFW_HAT_CENTERED 0 +#define GLFW_HAT_UP 1 +#define GLFW_HAT_RIGHT 2 +#define GLFW_HAT_DOWN 4 +#define GLFW_HAT_LEFT 8 +#define GLFW_HAT_RIGHT_UP (GLFW_HAT_RIGHT | GLFW_HAT_UP) +#define GLFW_HAT_RIGHT_DOWN (GLFW_HAT_RIGHT | GLFW_HAT_DOWN) +#define GLFW_HAT_LEFT_UP (GLFW_HAT_LEFT | GLFW_HAT_UP) +#define GLFW_HAT_LEFT_DOWN (GLFW_HAT_LEFT | GLFW_HAT_DOWN) /*! @} */ -/*! @defgroup keys Keyboard key tokens - * @brief Keyboard key tokens. +/*! @defgroup keys Keyboard keys + * @brief Keyboard key IDs. * * See [key input](@ref input_key) for how these are used. * @@ -392,131 +385,134 @@ extern "C" { * @{ */ +/* The unknown key */ +#define GLFW_KEY_UNKNOWN -1 + /* Printable keys */ -#define GLFW_KEY_SPACE 32 -#define GLFW_KEY_APOSTROPHE 39 /* ' */ -#define GLFW_KEY_COMMA 44 /* , */ -#define GLFW_KEY_MINUS 45 /* - */ -#define GLFW_KEY_PERIOD 46 /* . */ -#define GLFW_KEY_SLASH 47 /* / */ -#define GLFW_KEY_0 48 -#define GLFW_KEY_1 49 -#define GLFW_KEY_2 50 -#define GLFW_KEY_3 51 -#define GLFW_KEY_4 52 -#define GLFW_KEY_5 53 -#define GLFW_KEY_6 54 -#define GLFW_KEY_7 55 -#define GLFW_KEY_8 56 -#define GLFW_KEY_9 57 -#define GLFW_KEY_SEMICOLON 59 /* ; */ -#define GLFW_KEY_EQUAL 61 /* = */ -#define GLFW_KEY_A 65 -#define GLFW_KEY_B 66 -#define GLFW_KEY_C 67 -#define GLFW_KEY_D 68 -#define GLFW_KEY_E 69 -#define GLFW_KEY_F 70 -#define GLFW_KEY_G 71 -#define GLFW_KEY_H 72 -#define GLFW_KEY_I 73 -#define GLFW_KEY_J 74 -#define GLFW_KEY_K 75 -#define GLFW_KEY_L 76 -#define GLFW_KEY_M 77 -#define GLFW_KEY_N 78 -#define GLFW_KEY_O 79 -#define GLFW_KEY_P 80 -#define GLFW_KEY_Q 81 -#define GLFW_KEY_R 82 -#define GLFW_KEY_S 83 -#define GLFW_KEY_T 84 -#define GLFW_KEY_U 85 -#define GLFW_KEY_V 86 -#define GLFW_KEY_W 87 -#define GLFW_KEY_X 88 -#define GLFW_KEY_Y 89 -#define GLFW_KEY_Z 90 -#define GLFW_KEY_LEFT_BRACKET 91 /* [ */ -#define GLFW_KEY_BACKSLASH 92 /* \ */ -#define GLFW_KEY_RIGHT_BRACKET 93 /* ] */ -#define GLFW_KEY_GRAVE_ACCENT 96 /* ` */ -#define GLFW_KEY_WORLD_1 161 /* non-US #1 */ -#define GLFW_KEY_WORLD_2 162 /* non-US #2 */ +#define GLFW_KEY_SPACE 32 +#define GLFW_KEY_APOSTROPHE 39 /* ' */ +#define GLFW_KEY_COMMA 44 /* , */ +#define GLFW_KEY_MINUS 45 /* - */ +#define GLFW_KEY_PERIOD 46 /* . */ +#define GLFW_KEY_SLASH 47 /* / */ +#define GLFW_KEY_0 48 +#define GLFW_KEY_1 49 +#define GLFW_KEY_2 50 +#define GLFW_KEY_3 51 +#define GLFW_KEY_4 52 +#define GLFW_KEY_5 53 +#define GLFW_KEY_6 54 +#define GLFW_KEY_7 55 +#define GLFW_KEY_8 56 +#define GLFW_KEY_9 57 +#define GLFW_KEY_SEMICOLON 59 /* ; */ +#define GLFW_KEY_EQUAL 61 /* = */ +#define GLFW_KEY_A 65 +#define GLFW_KEY_B 66 +#define GLFW_KEY_C 67 +#define GLFW_KEY_D 68 +#define GLFW_KEY_E 69 +#define GLFW_KEY_F 70 +#define GLFW_KEY_G 71 +#define GLFW_KEY_H 72 +#define GLFW_KEY_I 73 +#define GLFW_KEY_J 74 +#define GLFW_KEY_K 75 +#define GLFW_KEY_L 76 +#define GLFW_KEY_M 77 +#define GLFW_KEY_N 78 +#define GLFW_KEY_O 79 +#define GLFW_KEY_P 80 +#define GLFW_KEY_Q 81 +#define GLFW_KEY_R 82 +#define GLFW_KEY_S 83 +#define GLFW_KEY_T 84 +#define GLFW_KEY_U 85 +#define GLFW_KEY_V 86 +#define GLFW_KEY_W 87 +#define GLFW_KEY_X 88 +#define GLFW_KEY_Y 89 +#define GLFW_KEY_Z 90 +#define GLFW_KEY_LEFT_BRACKET 91 /* [ */ +#define GLFW_KEY_BACKSLASH 92 /* \ */ +#define GLFW_KEY_RIGHT_BRACKET 93 /* ] */ +#define GLFW_KEY_GRAVE_ACCENT 96 /* ` */ +#define GLFW_KEY_WORLD_1 161 /* non-US #1 */ +#define GLFW_KEY_WORLD_2 162 /* non-US #2 */ /* Function keys */ -#define GLFW_KEY_ESCAPE 256 -#define GLFW_KEY_ENTER 257 -#define GLFW_KEY_TAB 258 -#define GLFW_KEY_BACKSPACE 259 -#define GLFW_KEY_INSERT 260 -#define GLFW_KEY_DELETE 261 -#define GLFW_KEY_RIGHT 262 -#define GLFW_KEY_LEFT 263 -#define GLFW_KEY_DOWN 264 -#define GLFW_KEY_UP 265 -#define GLFW_KEY_PAGE_UP 266 -#define GLFW_KEY_PAGE_DOWN 267 -#define GLFW_KEY_HOME 268 -#define GLFW_KEY_END 269 -#define GLFW_KEY_CAPS_LOCK 280 -#define GLFW_KEY_SCROLL_LOCK 281 -#define GLFW_KEY_NUM_LOCK 282 -#define GLFW_KEY_PRINT_SCREEN 283 -#define GLFW_KEY_PAUSE 284 -#define GLFW_KEY_F1 290 -#define GLFW_KEY_F2 291 -#define GLFW_KEY_F3 292 -#define GLFW_KEY_F4 293 -#define GLFW_KEY_F5 294 -#define GLFW_KEY_F6 295 -#define GLFW_KEY_F7 296 -#define GLFW_KEY_F8 297 -#define GLFW_KEY_F9 298 -#define GLFW_KEY_F10 299 -#define GLFW_KEY_F11 300 -#define GLFW_KEY_F12 301 -#define GLFW_KEY_F13 302 -#define GLFW_KEY_F14 303 -#define GLFW_KEY_F15 304 -#define GLFW_KEY_F16 305 -#define GLFW_KEY_F17 306 -#define GLFW_KEY_F18 307 -#define GLFW_KEY_F19 308 -#define GLFW_KEY_F20 309 -#define GLFW_KEY_F21 310 -#define GLFW_KEY_F22 311 -#define GLFW_KEY_F23 312 -#define GLFW_KEY_F24 313 -#define GLFW_KEY_F25 314 -#define GLFW_KEY_KP_0 320 -#define GLFW_KEY_KP_1 321 -#define GLFW_KEY_KP_2 322 -#define GLFW_KEY_KP_3 323 -#define GLFW_KEY_KP_4 324 -#define GLFW_KEY_KP_5 325 -#define GLFW_KEY_KP_6 326 -#define GLFW_KEY_KP_7 327 -#define GLFW_KEY_KP_8 328 -#define GLFW_KEY_KP_9 329 -#define GLFW_KEY_KP_DECIMAL 330 -#define GLFW_KEY_KP_DIVIDE 331 -#define GLFW_KEY_KP_MULTIPLY 332 -#define GLFW_KEY_KP_SUBTRACT 333 -#define GLFW_KEY_KP_ADD 334 -#define GLFW_KEY_KP_ENTER 335 -#define GLFW_KEY_KP_EQUAL 336 -#define GLFW_KEY_LEFT_SHIFT 340 -#define GLFW_KEY_LEFT_CONTROL 341 -#define GLFW_KEY_LEFT_ALT 342 -#define GLFW_KEY_LEFT_SUPER 343 -#define GLFW_KEY_RIGHT_SHIFT 344 -#define GLFW_KEY_RIGHT_CONTROL 345 -#define GLFW_KEY_RIGHT_ALT 346 -#define GLFW_KEY_RIGHT_SUPER 347 -#define GLFW_KEY_MENU 348 +#define GLFW_KEY_ESCAPE 256 +#define GLFW_KEY_ENTER 257 +#define GLFW_KEY_TAB 258 +#define GLFW_KEY_BACKSPACE 259 +#define GLFW_KEY_INSERT 260 +#define GLFW_KEY_DELETE 261 +#define GLFW_KEY_RIGHT 262 +#define GLFW_KEY_LEFT 263 +#define GLFW_KEY_DOWN 264 +#define GLFW_KEY_UP 265 +#define GLFW_KEY_PAGE_UP 266 +#define GLFW_KEY_PAGE_DOWN 267 +#define GLFW_KEY_HOME 268 +#define GLFW_KEY_END 269 +#define GLFW_KEY_CAPS_LOCK 280 +#define GLFW_KEY_SCROLL_LOCK 281 +#define GLFW_KEY_NUM_LOCK 282 +#define GLFW_KEY_PRINT_SCREEN 283 +#define GLFW_KEY_PAUSE 284 +#define GLFW_KEY_F1 290 +#define GLFW_KEY_F2 291 +#define GLFW_KEY_F3 292 +#define GLFW_KEY_F4 293 +#define GLFW_KEY_F5 294 +#define GLFW_KEY_F6 295 +#define GLFW_KEY_F7 296 +#define GLFW_KEY_F8 297 +#define GLFW_KEY_F9 298 +#define GLFW_KEY_F10 299 +#define GLFW_KEY_F11 300 +#define GLFW_KEY_F12 301 +#define GLFW_KEY_F13 302 +#define GLFW_KEY_F14 303 +#define GLFW_KEY_F15 304 +#define GLFW_KEY_F16 305 +#define GLFW_KEY_F17 306 +#define GLFW_KEY_F18 307 +#define GLFW_KEY_F19 308 +#define GLFW_KEY_F20 309 +#define GLFW_KEY_F21 310 +#define GLFW_KEY_F22 311 +#define GLFW_KEY_F23 312 +#define GLFW_KEY_F24 313 +#define GLFW_KEY_F25 314 +#define GLFW_KEY_KP_0 320 +#define GLFW_KEY_KP_1 321 +#define GLFW_KEY_KP_2 322 +#define GLFW_KEY_KP_3 323 +#define GLFW_KEY_KP_4 324 +#define GLFW_KEY_KP_5 325 +#define GLFW_KEY_KP_6 326 +#define GLFW_KEY_KP_7 327 +#define GLFW_KEY_KP_8 328 +#define GLFW_KEY_KP_9 329 +#define GLFW_KEY_KP_DECIMAL 330 +#define GLFW_KEY_KP_DIVIDE 331 +#define GLFW_KEY_KP_MULTIPLY 332 +#define GLFW_KEY_KP_SUBTRACT 333 +#define GLFW_KEY_KP_ADD 334 +#define GLFW_KEY_KP_ENTER 335 +#define GLFW_KEY_KP_EQUAL 336 +#define GLFW_KEY_LEFT_SHIFT 340 +#define GLFW_KEY_LEFT_CONTROL 341 +#define GLFW_KEY_LEFT_ALT 342 +#define GLFW_KEY_LEFT_SUPER 343 +#define GLFW_KEY_RIGHT_SHIFT 344 +#define GLFW_KEY_RIGHT_CONTROL 345 +#define GLFW_KEY_RIGHT_ALT 346 +#define GLFW_KEY_RIGHT_SUPER 347 +#define GLFW_KEY_MENU 348 -#define GLFW_KEY_LAST GLFW_KEY_MENU +#define GLFW_KEY_LAST GLFW_KEY_MENU /*! @} */ @@ -532,34 +528,34 @@ extern "C" { * * If this bit is set one or more Shift keys were held down. */ -#define GLFW_MOD_SHIFT 0x0001 +#define GLFW_MOD_SHIFT 0x0001 /*! @brief If this bit is set one or more Control keys were held down. * * If this bit is set one or more Control keys were held down. */ -#define GLFW_MOD_CONTROL 0x0002 +#define GLFW_MOD_CONTROL 0x0002 /*! @brief If this bit is set one or more Alt keys were held down. * * If this bit is set one or more Alt keys were held down. */ -#define GLFW_MOD_ALT 0x0004 +#define GLFW_MOD_ALT 0x0004 /*! @brief If this bit is set one or more Super keys were held down. * * If this bit is set one or more Super keys were held down. */ -#define GLFW_MOD_SUPER 0x0008 +#define GLFW_MOD_SUPER 0x0008 /*! @brief If this bit is set the Caps Lock key is enabled. * * If this bit is set the Caps Lock key is enabled and the @ref * GLFW_LOCK_KEY_MODS input mode is set. */ -#define GLFW_MOD_CAPS_LOCK 0x0010 +#define GLFW_MOD_CAPS_LOCK 0x0010 /*! @brief If this bit is set the Num Lock key is enabled. * * If this bit is set the Num Lock key is enabled and the @ref * GLFW_LOCK_KEY_MODS input mode is set. */ -#define GLFW_MOD_NUM_LOCK 0x0020 +#define GLFW_MOD_NUM_LOCK 0x0020 /*! @} */ @@ -570,18 +566,18 @@ extern "C" { * * @ingroup input * @{ */ -#define GLFW_MOUSE_BUTTON_1 0 -#define GLFW_MOUSE_BUTTON_2 1 -#define GLFW_MOUSE_BUTTON_3 2 -#define GLFW_MOUSE_BUTTON_4 3 -#define GLFW_MOUSE_BUTTON_5 4 -#define GLFW_MOUSE_BUTTON_6 5 -#define GLFW_MOUSE_BUTTON_7 6 -#define GLFW_MOUSE_BUTTON_8 7 -#define GLFW_MOUSE_BUTTON_LAST GLFW_MOUSE_BUTTON_8 -#define GLFW_MOUSE_BUTTON_LEFT GLFW_MOUSE_BUTTON_1 -#define GLFW_MOUSE_BUTTON_RIGHT GLFW_MOUSE_BUTTON_2 -#define GLFW_MOUSE_BUTTON_MIDDLE GLFW_MOUSE_BUTTON_3 +#define GLFW_MOUSE_BUTTON_1 0 +#define GLFW_MOUSE_BUTTON_2 1 +#define GLFW_MOUSE_BUTTON_3 2 +#define GLFW_MOUSE_BUTTON_4 3 +#define GLFW_MOUSE_BUTTON_5 4 +#define GLFW_MOUSE_BUTTON_6 5 +#define GLFW_MOUSE_BUTTON_7 6 +#define GLFW_MOUSE_BUTTON_8 7 +#define GLFW_MOUSE_BUTTON_LAST GLFW_MOUSE_BUTTON_8 +#define GLFW_MOUSE_BUTTON_LEFT GLFW_MOUSE_BUTTON_1 +#define GLFW_MOUSE_BUTTON_RIGHT GLFW_MOUSE_BUTTON_2 +#define GLFW_MOUSE_BUTTON_MIDDLE GLFW_MOUSE_BUTTON_3 /*! @} */ /*! @defgroup joysticks Joysticks @@ -591,23 +587,23 @@ extern "C" { * * @ingroup input * @{ */ -#define GLFW_JOYSTICK_1 0 -#define GLFW_JOYSTICK_2 1 -#define GLFW_JOYSTICK_3 2 -#define GLFW_JOYSTICK_4 3 -#define GLFW_JOYSTICK_5 4 -#define GLFW_JOYSTICK_6 5 -#define GLFW_JOYSTICK_7 6 -#define GLFW_JOYSTICK_8 7 -#define GLFW_JOYSTICK_9 8 -#define GLFW_JOYSTICK_10 9 -#define GLFW_JOYSTICK_11 10 -#define GLFW_JOYSTICK_12 11 -#define GLFW_JOYSTICK_13 12 -#define GLFW_JOYSTICK_14 13 -#define GLFW_JOYSTICK_15 14 -#define GLFW_JOYSTICK_16 15 -#define GLFW_JOYSTICK_LAST GLFW_JOYSTICK_16 +#define GLFW_JOYSTICK_1 0 +#define GLFW_JOYSTICK_2 1 +#define GLFW_JOYSTICK_3 2 +#define GLFW_JOYSTICK_4 3 +#define GLFW_JOYSTICK_5 4 +#define GLFW_JOYSTICK_6 5 +#define GLFW_JOYSTICK_7 6 +#define GLFW_JOYSTICK_8 7 +#define GLFW_JOYSTICK_9 8 +#define GLFW_JOYSTICK_10 9 +#define GLFW_JOYSTICK_11 10 +#define GLFW_JOYSTICK_12 11 +#define GLFW_JOYSTICK_13 12 +#define GLFW_JOYSTICK_14 13 +#define GLFW_JOYSTICK_15 14 +#define GLFW_JOYSTICK_16 15 +#define GLFW_JOYSTICK_LAST GLFW_JOYSTICK_16 /*! @} */ /*! @defgroup gamepad_buttons Gamepad buttons @@ -617,27 +613,27 @@ extern "C" { * * @ingroup input * @{ */ -#define GLFW_GAMEPAD_BUTTON_A 0 -#define GLFW_GAMEPAD_BUTTON_B 1 -#define GLFW_GAMEPAD_BUTTON_X 2 -#define GLFW_GAMEPAD_BUTTON_Y 3 -#define GLFW_GAMEPAD_BUTTON_LEFT_BUMPER 4 -#define GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER 5 -#define GLFW_GAMEPAD_BUTTON_BACK 6 -#define GLFW_GAMEPAD_BUTTON_START 7 -#define GLFW_GAMEPAD_BUTTON_GUIDE 8 -#define GLFW_GAMEPAD_BUTTON_LEFT_THUMB 9 -#define GLFW_GAMEPAD_BUTTON_RIGHT_THUMB 10 -#define GLFW_GAMEPAD_BUTTON_DPAD_UP 11 -#define GLFW_GAMEPAD_BUTTON_DPAD_RIGHT 12 -#define GLFW_GAMEPAD_BUTTON_DPAD_DOWN 13 -#define GLFW_GAMEPAD_BUTTON_DPAD_LEFT 14 -#define GLFW_GAMEPAD_BUTTON_LAST GLFW_GAMEPAD_BUTTON_DPAD_LEFT +#define GLFW_GAMEPAD_BUTTON_A 0 +#define GLFW_GAMEPAD_BUTTON_B 1 +#define GLFW_GAMEPAD_BUTTON_X 2 +#define GLFW_GAMEPAD_BUTTON_Y 3 +#define GLFW_GAMEPAD_BUTTON_LEFT_BUMPER 4 +#define GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER 5 +#define GLFW_GAMEPAD_BUTTON_BACK 6 +#define GLFW_GAMEPAD_BUTTON_START 7 +#define GLFW_GAMEPAD_BUTTON_GUIDE 8 +#define GLFW_GAMEPAD_BUTTON_LEFT_THUMB 9 +#define GLFW_GAMEPAD_BUTTON_RIGHT_THUMB 10 +#define GLFW_GAMEPAD_BUTTON_DPAD_UP 11 +#define GLFW_GAMEPAD_BUTTON_DPAD_RIGHT 12 +#define GLFW_GAMEPAD_BUTTON_DPAD_DOWN 13 +#define GLFW_GAMEPAD_BUTTON_DPAD_LEFT 14 +#define GLFW_GAMEPAD_BUTTON_LAST GLFW_GAMEPAD_BUTTON_DPAD_LEFT -#define GLFW_GAMEPAD_BUTTON_CROSS GLFW_GAMEPAD_BUTTON_A -#define GLFW_GAMEPAD_BUTTON_CIRCLE GLFW_GAMEPAD_BUTTON_B -#define GLFW_GAMEPAD_BUTTON_SQUARE GLFW_GAMEPAD_BUTTON_X -#define GLFW_GAMEPAD_BUTTON_TRIANGLE GLFW_GAMEPAD_BUTTON_Y +#define GLFW_GAMEPAD_BUTTON_CROSS GLFW_GAMEPAD_BUTTON_A +#define GLFW_GAMEPAD_BUTTON_CIRCLE GLFW_GAMEPAD_BUTTON_B +#define GLFW_GAMEPAD_BUTTON_SQUARE GLFW_GAMEPAD_BUTTON_X +#define GLFW_GAMEPAD_BUTTON_TRIANGLE GLFW_GAMEPAD_BUTTON_Y /*! @} */ /*! @defgroup gamepad_axes Gamepad axes @@ -647,13 +643,13 @@ extern "C" { * * @ingroup input * @{ */ -#define GLFW_GAMEPAD_AXIS_LEFT_X 0 -#define GLFW_GAMEPAD_AXIS_LEFT_Y 1 -#define GLFW_GAMEPAD_AXIS_RIGHT_X 2 -#define GLFW_GAMEPAD_AXIS_RIGHT_Y 3 -#define GLFW_GAMEPAD_AXIS_LEFT_TRIGGER 4 +#define GLFW_GAMEPAD_AXIS_LEFT_X 0 +#define GLFW_GAMEPAD_AXIS_LEFT_Y 1 +#define GLFW_GAMEPAD_AXIS_RIGHT_X 2 +#define GLFW_GAMEPAD_AXIS_RIGHT_Y 3 +#define GLFW_GAMEPAD_AXIS_LEFT_TRIGGER 4 #define GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER 5 -#define GLFW_GAMEPAD_AXIS_LAST GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER +#define GLFW_GAMEPAD_AXIS_LAST GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER /*! @} */ /*! @defgroup errors Error codes @@ -669,7 +665,7 @@ extern "C" { * * @analysis Yay. */ -#define GLFW_NO_ERROR 0 +#define GLFW_NO_ERROR 0 /*! @brief GLFW has not been initialized. * * This occurs if a GLFW function was called that must not be called unless the @@ -678,7 +674,7 @@ extern "C" { * @analysis Application programmer error. Initialize GLFW before calling any * function that requires initialization. */ -#define GLFW_NOT_INITIALIZED 0x00010001 +#define GLFW_NOT_INITIALIZED 0x00010001 /*! @brief No context is current for this thread. * * This occurs if a GLFW function was called that needs and operates on the @@ -688,7 +684,7 @@ extern "C" { * @analysis Application programmer error. Ensure a context is current before * calling functions that require a current context. */ -#define GLFW_NO_CURRENT_CONTEXT 0x00010002 +#define GLFW_NO_CURRENT_CONTEXT 0x00010002 /*! @brief One of the arguments to the function was an invalid enum value. * * One of the arguments to the function was an invalid enum value, for example @@ -696,7 +692,7 @@ extern "C" { * * @analysis Application programmer error. Fix the offending call. */ -#define GLFW_INVALID_ENUM 0x00010003 +#define GLFW_INVALID_ENUM 0x00010003 /*! @brief One of the arguments to the function was an invalid value. * * One of the arguments to the function was an invalid value, for example @@ -707,7 +703,7 @@ extern "C" { * * @analysis Application programmer error. Fix the offending call. */ -#define GLFW_INVALID_VALUE 0x00010004 +#define GLFW_INVALID_VALUE 0x00010004 /*! @brief A memory allocation failed. * * A memory allocation failed. @@ -715,7 +711,7 @@ extern "C" { * @analysis A bug in GLFW or the underlying operating system. Report the bug * to our [issue tracker](https://github.com/glfw/glfw/issues). */ -#define GLFW_OUT_OF_MEMORY 0x00010005 +#define GLFW_OUT_OF_MEMORY 0x00010005 /*! @brief GLFW could not find support for the requested API on the system. * * GLFW could not find support for the requested API on the system. @@ -731,7 +727,7 @@ extern "C" { * EGL, OpenGL and OpenGL ES libraries do not interface with the Nvidia binary * driver. Older graphics drivers do not support Vulkan. */ -#define GLFW_API_UNAVAILABLE 0x00010006 +#define GLFW_API_UNAVAILABLE 0x00010006 /*! @brief The requested OpenGL or OpenGL ES version is not available. * * The requested OpenGL or OpenGL ES version (including any requested context @@ -748,7 +744,7 @@ extern "C" { * not @ref GLFW_INVALID_VALUE, because GLFW cannot know what future versions * will exist. */ -#define GLFW_VERSION_UNAVAILABLE 0x00010007 +#define GLFW_VERSION_UNAVAILABLE 0x00010007 /*! @brief A platform-specific error occurred that does not match any of the * more specific categories. * @@ -759,7 +755,7 @@ extern "C" { * system or its drivers, or a lack of required resources. Report the issue to * our [issue tracker](https://github.com/glfw/glfw/issues). */ -#define GLFW_PLATFORM_ERROR 0x00010008 +#define GLFW_PLATFORM_ERROR 0x00010008 /*! @brief The requested format is not supported or available. * * If emitted during window creation, the requested pixel format is not @@ -778,7 +774,7 @@ extern "C" { * If emitted when querying the clipboard, ignore the error or report it to * the user, as appropriate. */ -#define GLFW_FORMAT_UNAVAILABLE 0x00010009 +#define GLFW_FORMAT_UNAVAILABLE 0x00010009 /*! @brief The specified window does not have an OpenGL or OpenGL ES context. * * A window that does not have an OpenGL or OpenGL ES context was passed to @@ -786,7 +782,7 @@ extern "C" { * * @analysis Application programmer error. Fix the offending call. */ -#define GLFW_NO_WINDOW_CONTEXT 0x0001000A +#define GLFW_NO_WINDOW_CONTEXT 0x0001000A /*! @brief The specified cursor shape is not available. * * The specified standard cursor shape is not available, either because the @@ -797,7 +793,7 @@ extern "C" { * [standard cursor shape](@ref shapes) or create a * [custom cursor](@ref cursor_custom). */ -#define GLFW_CURSOR_UNAVAILABLE 0x0001000B +#define GLFW_CURSOR_UNAVAILABLE 0x0001000B /*! @brief The requested feature is not provided by the platform. * * The requested feature is not provided by the platform, so GLFW is unable to @@ -811,10 +807,11 @@ extern "C" { * A function call that emits this error has no effect other than the error and * updating any existing out parameters. */ -#define GLFW_FEATURE_UNAVAILABLE 0x0001000C +#define GLFW_FEATURE_UNAVAILABLE 0x0001000C /*! @brief The requested feature is not implemented for the platform. * - * The requested feature has not yet been implemented in GLFW for this platform. + * The requested feature has not yet been implemented in GLFW for this + * platform. * * @analysis An incomplete implementation of GLFW for this platform, hopefully * fixed in a future release. The error can be ignored unless the feature is @@ -824,29 +821,30 @@ extern "C" { * A function call that emits this error has no effect other than the error and * updating any existing out parameters. */ -#define GLFW_FEATURE_UNIMPLEMENTED 0x0001000D +#define GLFW_FEATURE_UNIMPLEMENTED 0x0001000D /*! @brief Platform unavailable or no matching platform was found. * - * If emitted during initialization, no matching platform was found. If the @ref - * GLFW_PLATFORM init hint was set to `GLFW_ANY_PLATFORM`, GLFW could not detect any of - * the platforms supported by this library binary, except for the Null platform. If the - * init hint was set to a specific platform, it is either not supported by this library - * binary or GLFW was not able to detect it. + * If emitted during initialization, no matching platform was found. If @ref + * GLFW_PLATFORM is set to `GLFW_ANY_PLATFORM`, GLFW could not detect any of + * the platforms supported by this library binary, except for the Null platform. + * If set to a specific platform, it is either not supported by this library + * binary or GLFW was not able to detect it. * - * If emitted by a native access function, GLFW was initialized for a different platform - * than the function is for. + * If emitted by a native access function, GLFW was initialized for a different + * platform than the function is for. * - * @analysis Failure to detect any platform usually only happens on non-macOS Unix - * systems, either when no window system is running or the program was run from - * a terminal that does not have the necessary environment variables. Fall back to - * a different platform if possible or notify the user that no usable platform was - * detected. + * @analysis Failure to detect any platform usually only happens on non-macOS + * Unix systems, either when no window system is running or the program was run + * from a terminal that does not have the necessary environment variables. Fall + * back to a different platform if possible or notify the user that no usable + * platform was detected. * - * Failure to detect a specific platform may have the same cause as above or be because - * support for that platform was not compiled in. Call @ref glfwPlatformSupported to - * check whether a specific platform is supported by a library binary. + * Failure to detect a specific platform may have the same cause as above or be + * because support for that platform was not compiled in. Call @ref + * glfwPlatformSupported to check whether a specific platform is supported by a + * library binary. */ -#define GLFW_PLATFORM_UNAVAILABLE 0x0001000E +#define GLFW_PLATFORM_UNAVAILABLE 0x0001000E /*! @} */ /*! @addtogroup window @@ -856,53 +854,53 @@ extern "C" { * Input focus [window hint](@ref GLFW_FOCUSED_hint) or * [window attribute](@ref GLFW_FOCUSED_attrib). */ -#define GLFW_FOCUSED 0x00020001 +#define GLFW_FOCUSED 0x00020001 /*! @brief Window iconification window attribute * * Window iconification [window attribute](@ref GLFW_ICONIFIED_attrib). */ -#define GLFW_ICONIFIED 0x00020002 +#define GLFW_ICONIFIED 0x00020002 /*! @brief Window resize-ability window hint and attribute * * Window resize-ability [window hint](@ref GLFW_RESIZABLE_hint) and * [window attribute](@ref GLFW_RESIZABLE_attrib). */ -#define GLFW_RESIZABLE 0x00020003 +#define GLFW_RESIZABLE 0x00020003 /*! @brief Window visibility window hint and attribute * * Window visibility [window hint](@ref GLFW_VISIBLE_hint) and * [window attribute](@ref GLFW_VISIBLE_attrib). */ -#define GLFW_VISIBLE 0x00020004 +#define GLFW_VISIBLE 0x00020004 /*! @brief Window decoration window hint and attribute * * Window decoration [window hint](@ref GLFW_DECORATED_hint) and * [window attribute](@ref GLFW_DECORATED_attrib). */ -#define GLFW_DECORATED 0x00020005 +#define GLFW_DECORATED 0x00020005 /*! @brief Window auto-iconification window hint and attribute * * Window auto-iconification [window hint](@ref GLFW_AUTO_ICONIFY_hint) and * [window attribute](@ref GLFW_AUTO_ICONIFY_attrib). */ -#define GLFW_AUTO_ICONIFY 0x00020006 +#define GLFW_AUTO_ICONIFY 0x00020006 /*! @brief Window decoration window hint and attribute * * Window decoration [window hint](@ref GLFW_FLOATING_hint) and * [window attribute](@ref GLFW_FLOATING_attrib). */ -#define GLFW_FLOATING 0x00020007 +#define GLFW_FLOATING 0x00020007 /*! @brief Window maximization window hint and attribute * * Window maximization [window hint](@ref GLFW_MAXIMIZED_hint) and * [window attribute](@ref GLFW_MAXIMIZED_attrib). */ -#define GLFW_MAXIMIZED 0x00020008 +#define GLFW_MAXIMIZED 0x00020008 /*! @brief Cursor centering window hint * * Cursor centering [window hint](@ref GLFW_CENTER_CURSOR_hint). */ -#define GLFW_CENTER_CURSOR 0x00020009 +#define GLFW_CENTER_CURSOR 0x00020009 /*! @brief Window framebuffer transparency hint and attribute * * Window framebuffer transparency @@ -914,168 +912,177 @@ extern "C" { * * Mouse cursor hover [window attribute](@ref GLFW_HOVERED_attrib). */ -#define GLFW_HOVERED 0x0002000B +#define GLFW_HOVERED 0x0002000B /*! @brief Input focus on calling show window hint and attribute * * Input focus [window hint](@ref GLFW_FOCUS_ON_SHOW_hint) or * [window attribute](@ref GLFW_FOCUS_ON_SHOW_attrib). */ -#define GLFW_FOCUS_ON_SHOW 0x0002000C - +#define GLFW_FOCUS_ON_SHOW 0x0002000C +/*! @brief Window has titlebar window hint and attribute + * + * Window has titlebar [window hint](@ref GLFW_TITLEBAR_hint) and + * [window attribute](@ref GLFW_TITLEBAR_attrib). + * + * NOTE: Added by Hazel + */ +#define GLFW_TITLEBAR 0x00C2000D /*! @brief Mouse input transparency window hint and attribute * * Mouse input transparency [window hint](@ref GLFW_MOUSE_PASSTHROUGH_hint) or * [window attribute](@ref GLFW_MOUSE_PASSTHROUGH_attrib). */ -#define GLFW_MOUSE_PASSTHROUGH 0x0002000D +#define GLFW_MOUSE_PASSTHROUGH 0x0002000D /*! @brief Initial position x-coordinate window hint. * * Initial position x-coordinate [window hint](@ref GLFW_POSITION_X). */ -#define GLFW_POSITION_X 0x0002000E +#define GLFW_POSITION_X 0x0002000E /*! @brief Initial position y-coordinate window hint. * * Initial position y-coordinate [window hint](@ref GLFW_POSITION_Y). */ -#define GLFW_POSITION_Y 0x0002000F +#define GLFW_POSITION_Y 0x0002000F /*! @brief Framebuffer bit depth hint. * * Framebuffer bit depth [hint](@ref GLFW_RED_BITS). */ -#define GLFW_RED_BITS 0x00021001 +#define GLFW_RED_BITS 0x00021001 /*! @brief Framebuffer bit depth hint. * * Framebuffer bit depth [hint](@ref GLFW_GREEN_BITS). */ -#define GLFW_GREEN_BITS 0x00021002 +#define GLFW_GREEN_BITS 0x00021002 /*! @brief Framebuffer bit depth hint. * * Framebuffer bit depth [hint](@ref GLFW_BLUE_BITS). */ -#define GLFW_BLUE_BITS 0x00021003 +#define GLFW_BLUE_BITS 0x00021003 /*! @brief Framebuffer bit depth hint. * * Framebuffer bit depth [hint](@ref GLFW_ALPHA_BITS). */ -#define GLFW_ALPHA_BITS 0x00021004 +#define GLFW_ALPHA_BITS 0x00021004 /*! @brief Framebuffer bit depth hint. * * Framebuffer bit depth [hint](@ref GLFW_DEPTH_BITS). */ -#define GLFW_DEPTH_BITS 0x00021005 +#define GLFW_DEPTH_BITS 0x00021005 /*! @brief Framebuffer bit depth hint. * * Framebuffer bit depth [hint](@ref GLFW_STENCIL_BITS). */ -#define GLFW_STENCIL_BITS 0x00021006 +#define GLFW_STENCIL_BITS 0x00021006 /*! @brief Framebuffer bit depth hint. * * Framebuffer bit depth [hint](@ref GLFW_ACCUM_RED_BITS). */ -#define GLFW_ACCUM_RED_BITS 0x00021007 +#define GLFW_ACCUM_RED_BITS 0x00021007 /*! @brief Framebuffer bit depth hint. * * Framebuffer bit depth [hint](@ref GLFW_ACCUM_GREEN_BITS). */ -#define GLFW_ACCUM_GREEN_BITS 0x00021008 +#define GLFW_ACCUM_GREEN_BITS 0x00021008 /*! @brief Framebuffer bit depth hint. * * Framebuffer bit depth [hint](@ref GLFW_ACCUM_BLUE_BITS). */ -#define GLFW_ACCUM_BLUE_BITS 0x00021009 +#define GLFW_ACCUM_BLUE_BITS 0x00021009 /*! @brief Framebuffer bit depth hint. * * Framebuffer bit depth [hint](@ref GLFW_ACCUM_ALPHA_BITS). */ -#define GLFW_ACCUM_ALPHA_BITS 0x0002100A +#define GLFW_ACCUM_ALPHA_BITS 0x0002100A /*! @brief Framebuffer auxiliary buffer hint. * * Framebuffer auxiliary buffer [hint](@ref GLFW_AUX_BUFFERS). */ -#define GLFW_AUX_BUFFERS 0x0002100B +#define GLFW_AUX_BUFFERS 0x0002100B /*! @brief OpenGL stereoscopic rendering hint. * * OpenGL stereoscopic rendering [hint](@ref GLFW_STEREO). */ -#define GLFW_STEREO 0x0002100C +#define GLFW_STEREO 0x0002100C /*! @brief Framebuffer MSAA samples hint. * * Framebuffer MSAA samples [hint](@ref GLFW_SAMPLES). */ -#define GLFW_SAMPLES 0x0002100D +#define GLFW_SAMPLES 0x0002100D /*! @brief Framebuffer sRGB hint. * * Framebuffer sRGB [hint](@ref GLFW_SRGB_CAPABLE). */ -#define GLFW_SRGB_CAPABLE 0x0002100E +#define GLFW_SRGB_CAPABLE 0x0002100E /*! @brief Monitor refresh rate hint. * * Monitor refresh rate [hint](@ref GLFW_REFRESH_RATE). */ -#define GLFW_REFRESH_RATE 0x0002100F +#define GLFW_REFRESH_RATE 0x0002100F /*! @brief Framebuffer double buffering hint and attribute. * * Framebuffer double buffering [hint](@ref GLFW_DOUBLEBUFFER_hint) and * [attribute](@ref GLFW_DOUBLEBUFFER_attrib). */ -#define GLFW_DOUBLEBUFFER 0x00021010 +#define GLFW_DOUBLEBUFFER 0x00021010 /*! @brief Context client API hint and attribute. * * Context client API [hint](@ref GLFW_CLIENT_API_hint) and * [attribute](@ref GLFW_CLIENT_API_attrib). */ -#define GLFW_CLIENT_API 0x00022001 +#define GLFW_CLIENT_API 0x00022001 /*! @brief Context client API major version hint and attribute. * - * Context client API major version [hint](@ref GLFW_CONTEXT_VERSION_MAJOR_hint) - * and [attribute](@ref GLFW_CONTEXT_VERSION_MAJOR_attrib). + * Context client API major version [hint](@ref + * GLFW_CONTEXT_VERSION_MAJOR_hint) and [attribute](@ref + * GLFW_CONTEXT_VERSION_MAJOR_attrib). */ -#define GLFW_CONTEXT_VERSION_MAJOR 0x00022002 +#define GLFW_CONTEXT_VERSION_MAJOR 0x00022002 /*! @brief Context client API minor version hint and attribute. * - * Context client API minor version [hint](@ref GLFW_CONTEXT_VERSION_MINOR_hint) - * and [attribute](@ref GLFW_CONTEXT_VERSION_MINOR_attrib). + * Context client API minor version [hint](@ref + * GLFW_CONTEXT_VERSION_MINOR_hint) and [attribute](@ref + * GLFW_CONTEXT_VERSION_MINOR_attrib). */ -#define GLFW_CONTEXT_VERSION_MINOR 0x00022003 +#define GLFW_CONTEXT_VERSION_MINOR 0x00022003 /*! @brief Context client API revision number attribute. * * Context client API revision number * [attribute](@ref GLFW_CONTEXT_REVISION_attrib). */ -#define GLFW_CONTEXT_REVISION 0x00022004 +#define GLFW_CONTEXT_REVISION 0x00022004 /*! @brief Context robustness hint and attribute. * * Context client API revision number [hint](@ref GLFW_CONTEXT_ROBUSTNESS_hint) * and [attribute](@ref GLFW_CONTEXT_ROBUSTNESS_attrib). */ -#define GLFW_CONTEXT_ROBUSTNESS 0x00022005 +#define GLFW_CONTEXT_ROBUSTNESS 0x00022005 /*! @brief OpenGL forward-compatibility hint and attribute. * * OpenGL forward-compatibility [hint](@ref GLFW_OPENGL_FORWARD_COMPAT_hint) * and [attribute](@ref GLFW_OPENGL_FORWARD_COMPAT_attrib). */ -#define GLFW_OPENGL_FORWARD_COMPAT 0x00022006 +#define GLFW_OPENGL_FORWARD_COMPAT 0x00022006 /*! @brief Debug mode context hint and attribute. * * Debug mode context [hint](@ref GLFW_CONTEXT_DEBUG_hint) and * [attribute](@ref GLFW_CONTEXT_DEBUG_attrib). */ -#define GLFW_CONTEXT_DEBUG 0x00022007 +#define GLFW_CONTEXT_DEBUG 0x00022007 /*! @brief Legacy name for compatibility. * * This is an alias for compatibility with earlier versions. */ -#define GLFW_OPENGL_DEBUG_CONTEXT GLFW_CONTEXT_DEBUG +#define GLFW_OPENGL_DEBUG_CONTEXT GLFW_CONTEXT_DEBUG /*! @brief OpenGL profile hint and attribute. * * OpenGL profile [hint](@ref GLFW_OPENGL_PROFILE_hint) and * [attribute](@ref GLFW_OPENGL_PROFILE_attrib). */ -#define GLFW_OPENGL_PROFILE 0x00022008 +#define GLFW_OPENGL_PROFILE 0x00022008 /*! @brief Context flush-on-release hint and attribute. * * Context flush-on-release [hint](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_hint) and @@ -1087,17 +1094,17 @@ extern "C" { * Context error suppression [hint](@ref GLFW_CONTEXT_NO_ERROR_hint) and * [attribute](@ref GLFW_CONTEXT_NO_ERROR_attrib). */ -#define GLFW_CONTEXT_NO_ERROR 0x0002200A +#define GLFW_CONTEXT_NO_ERROR 0x0002200A /*! @brief Context creation API hint and attribute. * * Context creation API [hint](@ref GLFW_CONTEXT_CREATION_API_hint) and * [attribute](@ref GLFW_CONTEXT_CREATION_API_attrib). */ -#define GLFW_CONTEXT_CREATION_API 0x0002200B +#define GLFW_CONTEXT_CREATION_API 0x0002200B /*! @brief Window content area scaling window * [window hint](@ref GLFW_SCALE_TO_MONITOR). */ -#define GLFW_SCALE_TO_MONITOR 0x0002200C +#define GLFW_SCALE_TO_MONITOR 0x0002200C /*! @brief macOS specific * [window hint](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint). */ @@ -1105,7 +1112,7 @@ extern "C" { /*! @brief macOS specific * [window hint](@ref GLFW_COCOA_FRAME_NAME_hint). */ -#define GLFW_COCOA_FRAME_NAME 0x00023002 +#define GLFW_COCOA_FRAME_NAME 0x00023002 /*! @brief macOS specific * [window hint](@ref GLFW_COCOA_GRAPHICS_SWITCHING_hint). */ @@ -1113,63 +1120,63 @@ extern "C" { /*! @brief X11 specific * [window hint](@ref GLFW_X11_CLASS_NAME_hint). */ -#define GLFW_X11_CLASS_NAME 0x00024001 +#define GLFW_X11_CLASS_NAME 0x00024001 /*! @brief X11 specific * [window hint](@ref GLFW_X11_CLASS_NAME_hint). */ -#define GLFW_X11_INSTANCE_NAME 0x00024002 -#define GLFW_WIN32_KEYBOARD_MENU 0x00025001 +#define GLFW_X11_INSTANCE_NAME 0x00024002 +#define GLFW_WIN32_KEYBOARD_MENU 0x00025001 /*! @brief Wayland specific * [window hint](@ref GLFW_WAYLAND_APP_ID_hint). - * + * * Allows specification of the Wayland app_id. */ -#define GLFW_WAYLAND_APP_ID 0x00026001 +#define GLFW_WAYLAND_APP_ID 0x00026001 /*! @} */ -#define GLFW_NO_API 0 -#define GLFW_OPENGL_API 0x00030001 -#define GLFW_OPENGL_ES_API 0x00030002 +#define GLFW_NO_API 0 +#define GLFW_OPENGL_API 0x00030001 +#define GLFW_OPENGL_ES_API 0x00030002 -#define GLFW_NO_ROBUSTNESS 0 -#define GLFW_NO_RESET_NOTIFICATION 0x00031001 -#define GLFW_LOSE_CONTEXT_ON_RESET 0x00031002 +#define GLFW_NO_ROBUSTNESS 0 +#define GLFW_NO_RESET_NOTIFICATION 0x00031001 +#define GLFW_LOSE_CONTEXT_ON_RESET 0x00031002 -#define GLFW_OPENGL_ANY_PROFILE 0 -#define GLFW_OPENGL_CORE_PROFILE 0x00032001 -#define GLFW_OPENGL_COMPAT_PROFILE 0x00032002 +#define GLFW_OPENGL_ANY_PROFILE 0 +#define GLFW_OPENGL_CORE_PROFILE 0x00032001 +#define GLFW_OPENGL_COMPAT_PROFILE 0x00032002 -#define GLFW_CURSOR 0x00033001 -#define GLFW_STICKY_KEYS 0x00033002 -#define GLFW_STICKY_MOUSE_BUTTONS 0x00033003 -#define GLFW_LOCK_KEY_MODS 0x00033004 -#define GLFW_RAW_MOUSE_MOTION 0x00033005 +#define GLFW_CURSOR 0x00033001 +#define GLFW_STICKY_KEYS 0x00033002 +#define GLFW_STICKY_MOUSE_BUTTONS 0x00033003 +#define GLFW_LOCK_KEY_MODS 0x00033004 +#define GLFW_RAW_MOUSE_MOTION 0x00033005 -#define GLFW_CURSOR_NORMAL 0x00034001 -#define GLFW_CURSOR_HIDDEN 0x00034002 -#define GLFW_CURSOR_DISABLED 0x00034003 -#define GLFW_CURSOR_CAPTURED 0x00034004 +#define GLFW_CURSOR_NORMAL 0x00034001 +#define GLFW_CURSOR_HIDDEN 0x00034002 +#define GLFW_CURSOR_DISABLED 0x00034003 +#define GLFW_CURSOR_CAPTURED 0x00034004 -#define GLFW_ANY_RELEASE_BEHAVIOR 0 +#define GLFW_ANY_RELEASE_BEHAVIOR 0 #define GLFW_RELEASE_BEHAVIOR_FLUSH 0x00035001 -#define GLFW_RELEASE_BEHAVIOR_NONE 0x00035002 +#define GLFW_RELEASE_BEHAVIOR_NONE 0x00035002 -#define GLFW_NATIVE_CONTEXT_API 0x00036001 -#define GLFW_EGL_CONTEXT_API 0x00036002 -#define GLFW_OSMESA_CONTEXT_API 0x00036003 +#define GLFW_NATIVE_CONTEXT_API 0x00036001 +#define GLFW_EGL_CONTEXT_API 0x00036002 +#define GLFW_OSMESA_CONTEXT_API 0x00036003 -#define GLFW_ANGLE_PLATFORM_TYPE_NONE 0x00037001 -#define GLFW_ANGLE_PLATFORM_TYPE_OPENGL 0x00037002 +#define GLFW_ANGLE_PLATFORM_TYPE_NONE 0x00037001 +#define GLFW_ANGLE_PLATFORM_TYPE_OPENGL 0x00037002 #define GLFW_ANGLE_PLATFORM_TYPE_OPENGLES 0x00037003 -#define GLFW_ANGLE_PLATFORM_TYPE_D3D9 0x00037004 -#define GLFW_ANGLE_PLATFORM_TYPE_D3D11 0x00037005 -#define GLFW_ANGLE_PLATFORM_TYPE_VULKAN 0x00037007 -#define GLFW_ANGLE_PLATFORM_TYPE_METAL 0x00037008 +#define GLFW_ANGLE_PLATFORM_TYPE_D3D9 0x00037004 +#define GLFW_ANGLE_PLATFORM_TYPE_D3D11 0x00037005 +#define GLFW_ANGLE_PLATFORM_TYPE_VULKAN 0x00037007 +#define GLFW_ANGLE_PLATFORM_TYPE_METAL 0x00037008 -#define GLFW_WAYLAND_PREFER_LIBDECOR 0x00038001 -#define GLFW_WAYLAND_DISABLE_LIBDECOR 0x00038002 +#define GLFW_WAYLAND_PREFER_LIBDECOR 0x00038001 +#define GLFW_WAYLAND_DISABLE_LIBDECOR 0x00038002 -#define GLFW_ANY_POSITION 0x80000000 +#define GLFW_ANY_POSITION 0x80000000 /*! @defgroup shapes Standard cursor shapes * @brief Standard system cursor shapes. @@ -1184,34 +1191,34 @@ extern "C" { * * The regular arrow cursor shape. */ -#define GLFW_ARROW_CURSOR 0x00036001 +#define GLFW_ARROW_CURSOR 0x00036001 /*! @brief The text input I-beam cursor shape. * * The text input I-beam cursor shape. */ -#define GLFW_IBEAM_CURSOR 0x00036002 +#define GLFW_IBEAM_CURSOR 0x00036002 /*! @brief The crosshair cursor shape. * * The crosshair cursor shape. */ -#define GLFW_CROSSHAIR_CURSOR 0x00036003 +#define GLFW_CROSSHAIR_CURSOR 0x00036003 /*! @brief The pointing hand cursor shape. * * The pointing hand cursor shape. */ -#define GLFW_POINTING_HAND_CURSOR 0x00036004 +#define GLFW_POINTING_HAND_CURSOR 0x00036004 /*! @brief The horizontal resize/move arrow shape. * * The horizontal resize/move arrow shape. This is usually a horizontal * double-headed arrow. */ -#define GLFW_RESIZE_EW_CURSOR 0x00036005 +#define GLFW_RESIZE_EW_CURSOR 0x00036005 /*! @brief The vertical resize/move arrow shape. * * The vertical resize/move shape. This is usually a vertical double-headed * arrow. */ -#define GLFW_RESIZE_NS_CURSOR 0x00036006 +#define GLFW_RESIZE_NS_CURSOR 0x00036006 /*! @brief The top-left to bottom-right diagonal resize/move arrow shape. * * The top-left to bottom-right diagonal resize/move shape. This is usually @@ -1226,7 +1233,7 @@ extern "C" { * @note @wayland This shape is provided by a newer standard not supported by * all cursor themes. */ -#define GLFW_RESIZE_NWSE_CURSOR 0x00036007 +#define GLFW_RESIZE_NWSE_CURSOR 0x00036007 /*! @brief The top-right to bottom-left diagonal resize/move arrow shape. * * The top-right to bottom-left diagonal resize/move shape. This is usually @@ -1241,13 +1248,13 @@ extern "C" { * @note @wayland This shape is provided by a newer standard not supported by * all cursor themes. */ -#define GLFW_RESIZE_NESW_CURSOR 0x00036008 +#define GLFW_RESIZE_NESW_CURSOR 0x00036008 /*! @brief The omni-directional resize/move cursor shape. * * The omni-directional resize cursor/move shape. This is usually either * a combined horizontal and vertical double-headed arrow or a grabbing hand. */ -#define GLFW_RESIZE_ALL_CURSOR 0x00036009 +#define GLFW_RESIZE_ALL_CURSOR 0x00036009 /*! @brief The operation-not-allowed shape. * * The operation-not-allowed shape. This is usually a circle with a diagonal @@ -1259,26 +1266,26 @@ extern "C" { * @note @wayland This shape is provided by a newer standard not supported by * all cursor themes. */ -#define GLFW_NOT_ALLOWED_CURSOR 0x0003600A +#define GLFW_NOT_ALLOWED_CURSOR 0x0003600A /*! @brief Legacy name for compatibility. * * This is an alias for compatibility with earlier versions. */ -#define GLFW_HRESIZE_CURSOR GLFW_RESIZE_EW_CURSOR +#define GLFW_HRESIZE_CURSOR GLFW_RESIZE_EW_CURSOR /*! @brief Legacy name for compatibility. * * This is an alias for compatibility with earlier versions. */ -#define GLFW_VRESIZE_CURSOR GLFW_RESIZE_NS_CURSOR +#define GLFW_VRESIZE_CURSOR GLFW_RESIZE_NS_CURSOR /*! @brief Legacy name for compatibility. * * This is an alias for compatibility with earlier versions. */ -#define GLFW_HAND_CURSOR GLFW_POINTING_HAND_CURSOR +#define GLFW_HAND_CURSOR GLFW_POINTING_HAND_CURSOR /*! @} */ -#define GLFW_CONNECTED 0x00040001 -#define GLFW_DISCONNECTED 0x00040002 +#define GLFW_CONNECTED 0x00040001 +#define GLFW_DISCONNECTED 0x00040002 /*! @addtogroup init * @{ */ @@ -1286,27 +1293,27 @@ extern "C" { * * Joystick hat buttons [init hint](@ref GLFW_JOYSTICK_HAT_BUTTONS). */ -#define GLFW_JOYSTICK_HAT_BUTTONS 0x00050001 +#define GLFW_JOYSTICK_HAT_BUTTONS 0x00050001 /*! @brief ANGLE rendering backend init hint. * * ANGLE rendering backend [init hint](@ref GLFW_ANGLE_PLATFORM_TYPE_hint). */ -#define GLFW_ANGLE_PLATFORM_TYPE 0x00050002 +#define GLFW_ANGLE_PLATFORM_TYPE 0x00050002 /*! @brief Platform selection init hint. * * Platform selection [init hint](@ref GLFW_PLATFORM). */ -#define GLFW_PLATFORM 0x00050003 +#define GLFW_PLATFORM 0x00050003 /*! @brief macOS specific init hint. * * macOS specific [init hint](@ref GLFW_COCOA_CHDIR_RESOURCES_hint). */ -#define GLFW_COCOA_CHDIR_RESOURCES 0x00051001 +#define GLFW_COCOA_CHDIR_RESOURCES 0x00051001 /*! @brief macOS specific init hint. * * macOS specific [init hint](@ref GLFW_COCOA_MENUBAR_hint). */ -#define GLFW_COCOA_MENUBAR 0x00051002 +#define GLFW_COCOA_MENUBAR 0x00051002 /*! @brief X11 specific init hint. * * X11 specific [init hint](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint). @@ -1316,7 +1323,7 @@ extern "C" { * * Wayland specific [init hint](@ref GLFW_WAYLAND_LIBDECOR_hint). */ -#define GLFW_WAYLAND_LIBDECOR 0x00053001 +#define GLFW_WAYLAND_LIBDECOR 0x00053001 /*! @} */ /*! @addtogroup init @@ -1325,16 +1332,15 @@ extern "C" { * * Hint value for @ref GLFW_PLATFORM that enables automatic platform selection. */ -#define GLFW_ANY_PLATFORM 0x00060000 -#define GLFW_PLATFORM_WIN32 0x00060001 -#define GLFW_PLATFORM_COCOA 0x00060002 -#define GLFW_PLATFORM_WAYLAND 0x00060003 -#define GLFW_PLATFORM_X11 0x00060004 -#define GLFW_PLATFORM_NULL 0x00060005 +#define GLFW_ANY_PLATFORM 0x00060000 +#define GLFW_PLATFORM_WIN32 0x00060001 +#define GLFW_PLATFORM_COCOA 0x00060002 +#define GLFW_PLATFORM_WAYLAND 0x00060003 +#define GLFW_PLATFORM_X11 0x00060004 +#define GLFW_PLATFORM_NULL 0x00060005 /*! @} */ -#define GLFW_DONT_CARE -1 - +#define GLFW_DONT_CARE -1 /************************************************************************* * GLFW API types @@ -1413,8 +1419,8 @@ typedef struct GLFWcursor GLFWcursor; * @endcode * * This function must return either a memory block at least `size` bytes long, - * or `NULL` if allocation failed. Note that not all parts of GLFW handle allocation - * failures gracefully yet. + * or `NULL` if allocation failed. Note that not all parts of GLFW handle + * allocation failures gracefully yet. * * This function may be called during @ref glfwInit but before the library is * flagged as initialized, as well as during @ref glfwTerminate after the @@ -1423,8 +1429,8 @@ typedef struct GLFWcursor GLFWcursor; * Any memory allocated by this function will be deallocated during library * termination or earlier. * - * The size will always be greater than zero. Allocations of size zero are filtered out - * before reaching the custom allocator. + * The size will always be greater than zero. Allocations of size zero are + * filtered out before reaching the custom allocator. * * @param[in] size The minimum size, in bytes, of the memory block. * @param[in] user The user-defined pointer from the allocator. @@ -1436,7 +1442,8 @@ typedef struct GLFWcursor GLFWcursor; * * @reentrancy This function should not call any GLFW function. * - * @thread_safety This function may be called from any thread that calls GLFW functions. + * @thread_safety This function may be called from any thread that calls GLFW + * functions. * * @sa @ref init_allocator * @sa @ref GLFWallocator @@ -1445,7 +1452,7 @@ typedef struct GLFWcursor GLFWcursor; * * @ingroup init */ -typedef void* (* GLFWallocatefun)(size_t size, void* user); +typedef void *(*GLFWallocatefun)(size_t size, void *user); /*! @brief The function pointer type for memory reallocation callbacks. * @@ -1456,8 +1463,8 @@ typedef void* (* GLFWallocatefun)(size_t size, void* user); * @endcode * * This function must return a memory block at least `size` bytes long, or - * `NULL` if allocation failed. Note that not all parts of GLFW handle allocation - * failures gracefully yet. + * `NULL` if allocation failed. Note that not all parts of GLFW handle + * allocation failures gracefully yet. * * This function may be called during @ref glfwInit but before the library is * flagged as initialized, as well as during @ref glfwTerminate after the @@ -1466,9 +1473,10 @@ typedef void* (* GLFWallocatefun)(size_t size, void* user); * Any memory allocated by this function will be deallocated during library * termination or earlier. * - * The block address will never be `NULL` and the size will always be greater than zero. - * Reallocations of a block to size zero are converted into deallocations. Reallocations - * of `NULL` to a non-zero size are converted into regular allocations. + * The block address will never be `NULL` and the size will always be greater + * than zero. Reallocations of a block to size zero are converted into + * deallocations. Reallocations of `NULL` to a non-zero size are converted into + * regular allocations. * * @param[in] block The address of the memory block to reallocate. * @param[in] size The new minimum size, in bytes, of the memory block. @@ -1481,7 +1489,8 @@ typedef void* (* GLFWallocatefun)(size_t size, void* user); * * @reentrancy This function should not call any GLFW function. * - * @thread_safety This function may be called from any thread that calls GLFW functions. + * @thread_safety This function may be called from any thread that calls GLFW + * functions. * * @sa @ref init_allocator * @sa @ref GLFWallocator @@ -1490,7 +1499,7 @@ typedef void* (* GLFWallocatefun)(size_t size, void* user); * * @ingroup init */ -typedef void* (* GLFWreallocatefun)(void* block, size_t size, void* user); +typedef void *(*GLFWreallocatefun)(void *block, size_t size, void *user); /*! @brief The function pointer type for memory deallocation callbacks. * @@ -1507,8 +1516,8 @@ typedef void* (* GLFWreallocatefun)(void* block, size_t size, void* user); * flagged as initialized, as well as during @ref glfwTerminate after the * library is no longer flagged as initialized. * - * The block address will never be `NULL`. Deallocations of `NULL` are filtered out - * before reaching the custom allocator. + * The block address will never be `NULL`. Deallocations of `NULL` are + * filtered out before reaching the custom allocator. * * @param[in] block The address of the memory block to deallocate. * @param[in] user The user-defined pointer from the allocator. @@ -1518,7 +1527,8 @@ typedef void* (* GLFWreallocatefun)(void* block, size_t size, void* user); * * @reentrancy This function should not call any GLFW function. * - * @thread_safety This function may be called from any thread that calls GLFW functions. + * @thread_safety This function may be called from any thread that calls GLFW + * functions. * * @sa @ref init_allocator * @sa @ref GLFWallocator @@ -1527,7 +1537,7 @@ typedef void* (* GLFWreallocatefun)(void* block, size_t size, void* user); * * @ingroup init */ -typedef void (* GLFWdeallocatefun)(void* block, void* user); +typedef void (*GLFWdeallocatefun)(void *block, void *user); /*! @brief The function pointer type for error callbacks. * @@ -1551,7 +1561,7 @@ typedef void (* GLFWdeallocatefun)(void* block, void* user); * * @ingroup init */ -typedef void (* GLFWerrorfun)(int error_code, const char* description); +typedef void (*GLFWerrorfun)(int error_code, const char *description); /*! @brief The function pointer type for window position callbacks. * @@ -1574,7 +1584,27 @@ typedef void (* GLFWerrorfun)(int error_code, const char* description); * * @ingroup window */ -typedef void (* GLFWwindowposfun)(GLFWwindow* window, int xpos, int ypos); +typedef void (*GLFWwindowposfun)(GLFWwindow *window, int xpos, int ypos); + +/*! @brief The function pointer type for window titlebar hittest callbacks. + * + * This is the function pointer type for window titelebar hittest callbacks. + * A window titlebar hittest callback function has the following signature: + * @code + * void callback_name(GLFWwindow* window, int xpos, int ypos, int* hit) + * @endcode + * + * @param[in] window The window that was moved. + * @param[in] xpos The x-coordinate of mouse, in screen coordinates. + * @param[in] ypos The y-coordinate of mouse, in screen coordinates. + * @param[out] hit 'true' or '1' if mouse hovering titlebar. + * + * @sa @ref window_pos + * @sa @ref glfwSetTitlebarHitTestCallback + * + * @ingroup window + */ +typedef void (*GLFWtitlebarhittestfun)(GLFWwindow *, int, int, int *); /*! @brief The function pointer type for window size callbacks. * @@ -1596,7 +1626,7 @@ typedef void (* GLFWwindowposfun)(GLFWwindow* window, int xpos, int ypos); * * @ingroup window */ -typedef void (* GLFWwindowsizefun)(GLFWwindow* window, int width, int height); +typedef void (*GLFWwindowsizefun)(GLFWwindow *window, int width, int height); /*! @brief The function pointer type for window close callbacks. * @@ -1616,7 +1646,7 @@ typedef void (* GLFWwindowsizefun)(GLFWwindow* window, int width, int height); * * @ingroup window */ -typedef void (* GLFWwindowclosefun)(GLFWwindow* window); +typedef void (*GLFWwindowclosefun)(GLFWwindow *window); /*! @brief The function pointer type for window content refresh callbacks. * @@ -1636,7 +1666,7 @@ typedef void (* GLFWwindowclosefun)(GLFWwindow* window); * * @ingroup window */ -typedef void (* GLFWwindowrefreshfun)(GLFWwindow* window); +typedef void (*GLFWwindowrefreshfun)(GLFWwindow *window); /*! @brief The function pointer type for window focus callbacks. * @@ -1657,7 +1687,7 @@ typedef void (* GLFWwindowrefreshfun)(GLFWwindow* window); * * @ingroup window */ -typedef void (* GLFWwindowfocusfun)(GLFWwindow* window, int focused); +typedef void (*GLFWwindowfocusfun)(GLFWwindow *window, int focused); /*! @brief The function pointer type for window iconify callbacks. * @@ -1678,7 +1708,7 @@ typedef void (* GLFWwindowfocusfun)(GLFWwindow* window, int focused); * * @ingroup window */ -typedef void (* GLFWwindowiconifyfun)(GLFWwindow* window, int iconified); +typedef void (*GLFWwindowiconifyfun)(GLFWwindow *window, int iconified); /*! @brief The function pointer type for window maximize callbacks. * @@ -1699,7 +1729,7 @@ typedef void (* GLFWwindowiconifyfun)(GLFWwindow* window, int iconified); * * @ingroup window */ -typedef void (* GLFWwindowmaximizefun)(GLFWwindow* window, int maximized); +typedef void (*GLFWwindowmaximizefun)(GLFWwindow *window, int maximized); /*! @brief The function pointer type for framebuffer size callbacks. * @@ -1720,7 +1750,8 @@ typedef void (* GLFWwindowmaximizefun)(GLFWwindow* window, int maximized); * * @ingroup window */ -typedef void (* GLFWframebuffersizefun)(GLFWwindow* window, int width, int height); +typedef void (*GLFWframebuffersizefun)(GLFWwindow *window, int width, + int height); /*! @brief The function pointer type for window content scale callbacks. * @@ -1741,7 +1772,8 @@ typedef void (* GLFWframebuffersizefun)(GLFWwindow* window, int width, int heigh * * @ingroup window */ -typedef void (* GLFWwindowcontentscalefun)(GLFWwindow* window, float xscale, float yscale); +typedef void (*GLFWwindowcontentscalefun)(GLFWwindow *window, float xscale, + float yscale); /*! @brief The function pointer type for mouse button callbacks. * @@ -1767,7 +1799,8 @@ typedef void (* GLFWwindowcontentscalefun)(GLFWwindow* window, float xscale, flo * * @ingroup input */ -typedef void (* GLFWmousebuttonfun)(GLFWwindow* window, int button, int action, int mods); +typedef void (*GLFWmousebuttonfun)(GLFWwindow *window, int button, int action, + int mods); /*! @brief The function pointer type for cursor position callbacks. * @@ -1790,7 +1823,7 @@ typedef void (* GLFWmousebuttonfun)(GLFWwindow* window, int button, int action, * * @ingroup input */ -typedef void (* GLFWcursorposfun)(GLFWwindow* window, double xpos, double ypos); +typedef void (*GLFWcursorposfun)(GLFWwindow *window, double xpos, double ypos); /*! @brief The function pointer type for cursor enter/leave callbacks. * @@ -1811,7 +1844,7 @@ typedef void (* GLFWcursorposfun)(GLFWwindow* window, double xpos, double ypos); * * @ingroup input */ -typedef void (* GLFWcursorenterfun)(GLFWwindow* window, int entered); +typedef void (*GLFWcursorenterfun)(GLFWwindow *window, int entered); /*! @brief The function pointer type for scroll callbacks. * @@ -1832,14 +1865,16 @@ typedef void (* GLFWcursorenterfun)(GLFWwindow* window, int entered); * * @ingroup input */ -typedef void (* GLFWscrollfun)(GLFWwindow* window, double xoffset, double yoffset); +typedef void (*GLFWscrollfun)(GLFWwindow *window, double xoffset, + double yoffset); /*! @brief The function pointer type for keyboard key callbacks. * * This is the function pointer type for keyboard key callbacks. A keyboard * key callback function has the following signature: * @code - * void function_name(GLFWwindow* window, int key, int scancode, int action, int mods) + * void function_name(GLFWwindow* window, int key, int scancode, int action, + * int mods) * @endcode * * @param[in] window The window that received the event. @@ -1858,7 +1893,8 @@ typedef void (* GLFWscrollfun)(GLFWwindow* window, double xoffset, double yoffse * * @ingroup input */ -typedef void (* GLFWkeyfun)(GLFWwindow* window, int key, int scancode, int action, int mods); +typedef void (*GLFWkeyfun)(GLFWwindow *window, int key, int scancode, + int action, int mods); /*! @brief The function pointer type for Unicode character callbacks. * @@ -1879,7 +1915,7 @@ typedef void (* GLFWkeyfun)(GLFWwindow* window, int key, int scancode, int actio * * @ingroup input */ -typedef void (* GLFWcharfun)(GLFWwindow* window, unsigned int codepoint); +typedef void (*GLFWcharfun)(GLFWwindow *window, unsigned int codepoint); /*! @brief The function pointer type for Unicode character with modifiers * callbacks. @@ -1906,7 +1942,8 @@ typedef void (* GLFWcharfun)(GLFWwindow* window, unsigned int codepoint); * * @ingroup input */ -typedef void (* GLFWcharmodsfun)(GLFWwindow* window, unsigned int codepoint, int mods); +typedef void (*GLFWcharmodsfun)(GLFWwindow *window, unsigned int codepoint, + int mods); /*! @brief The function pointer type for path drop callbacks. * @@ -1930,7 +1967,8 @@ typedef void (* GLFWcharmodsfun)(GLFWwindow* window, unsigned int codepoint, int * * @ingroup input */ -typedef void (* GLFWdropfun)(GLFWwindow* window, int path_count, const char* paths[]); +typedef void (*GLFWdropfun)(GLFWwindow *window, int path_count, + const char *paths[]); /*! @brief The function pointer type for monitor configuration callbacks. * @@ -1951,7 +1989,7 @@ typedef void (* GLFWdropfun)(GLFWwindow* window, int path_count, const char* pat * * @ingroup monitor */ -typedef void (* GLFWmonitorfun)(GLFWmonitor* monitor, int event); +typedef void (*GLFWmonitorfun)(GLFWmonitor *monitor, int event); /*! @brief The function pointer type for joystick configuration callbacks. * @@ -1972,7 +2010,7 @@ typedef void (* GLFWmonitorfun)(GLFWmonitor* monitor, int event); * * @ingroup input */ -typedef void (* GLFWjoystickfun)(int jid, int event); +typedef void (*GLFWjoystickfun)(int jid, int event); /*! @brief Video mode type. * @@ -1987,8 +2025,7 @@ typedef void (* GLFWjoystickfun)(int jid, int event); * * @ingroup monitor */ -typedef struct GLFWvidmode -{ +typedef struct GLFWvidmode { /*! The width, in screen coordinates, of the video mode. */ int width; @@ -2021,17 +2058,16 @@ typedef struct GLFWvidmode * * @ingroup monitor */ -typedef struct GLFWgammaramp -{ +typedef struct GLFWgammaramp { /*! An array of value describing the response of the red channel. */ - unsigned short* red; + unsigned short *red; /*! An array of value describing the response of the green channel. */ - unsigned short* green; + unsigned short *green; /*! An array of value describing the response of the blue channel. */ - unsigned short* blue; + unsigned short *blue; /*! The number of elements in each array. */ unsigned int size; @@ -2050,8 +2086,7 @@ typedef struct GLFWgammaramp * * @ingroup window */ -typedef struct GLFWimage -{ +typedef struct GLFWimage { /*! The width, in pixels, of this image. */ int width; @@ -2060,7 +2095,7 @@ typedef struct GLFWimage int height; /*! The pixel data of this image, arranged left-to-right, top-to-bottom. */ - unsigned char* pixels; + unsigned char *pixels; } GLFWimage; /*! @brief Gamepad input state @@ -2074,8 +2109,7 @@ typedef struct GLFWimage * * @ingroup input */ -typedef struct GLFWgamepadstate -{ +typedef struct GLFWgamepadstate { /*! The states of each [gamepad button](@ref gamepad_buttons), `GLFW_PRESS` * or `GLFW_RELEASE`. */ @@ -2095,15 +2129,13 @@ typedef struct GLFWgamepadstate * * @ingroup init */ -typedef struct GLFWallocator -{ +typedef struct GLFWallocator { GLFWallocatefun allocate; GLFWreallocatefun reallocate; GLFWdeallocatefun deallocate; - void* user; + void *user; } GLFWallocator; - /************************************************************************* * GLFW API functions *************************************************************************/ @@ -2121,9 +2153,9 @@ typedef struct GLFWallocator * Additional calls to this function after successful initialization but before * termination will return `GLFW_TRUE` immediately. * - * The @ref GLFW_PLATFORM init hint controls which platforms are considered during - * initialization. This also depends on which platforms the library was compiled to - * support. + * The @ref GLFW_PLATFORM init hint controls which platforms are considered + * during initialization. This also depends on which platforms the library was + * compiled to support. * * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an * [error](@ref error_handling) occurred. @@ -2252,35 +2284,38 @@ GLFWAPI void glfwInitHint(int hint, int value); * * @ingroup init */ -GLFWAPI void glfwInitAllocator(const GLFWallocator* allocator); +GLFWAPI void glfwInitAllocator(const GLFWallocator *allocator); #if defined(VK_VERSION_1_0) /*! @brief Sets the desired Vulkan `vkGetInstanceProcAddr` function. * - * This function sets the `vkGetInstanceProcAddr` function that GLFW will use for all - * Vulkan related entry point queries. + * This function sets the `vkGetInstanceProcAddr` function that GLFW will use + * for all Vulkan related entry point queries. * - * This feature is mostly useful on macOS, if your copy of the Vulkan loader is in - * a location where GLFW cannot find it through dynamic loading, or if you are still - * using the static library version of the loader. + * This feature is mostly useful on macOS, if your copy of the Vulkan loader is + * in a location where GLFW cannot find it through dynamic loading, or if you + * are still using the static library version of the loader. * - * If set to `NULL`, GLFW will try to load the Vulkan loader dynamically by its standard - * name and get this function from there. This is the default behavior. + * If set to `NULL`, GLFW will try to load the Vulkan loader dynamically by its + * standard name and get this function from there. This is the default + * behavior. * - * The standard name of the loader is `vulkan-1.dll` on Windows, `libvulkan.so.1` on - * Linux and other Unix-like systems and `libvulkan.1.dylib` on macOS. If your code is - * also loading it via these names then you probably don't need to use this function. + * The standard name of the loader is `vulkan-1.dll` on Windows, + * `libvulkan.so.1` on Linux and other Unix-like systems and `libvulkan.1.dylib` + * on macOS. If your code is also loading it via these names then you probably + * don't need to use this function. * - * The function address you set is never reset by GLFW, but it only takes effect during - * initialization. Once GLFW has been initialized, any updates will be ignored until the - * library is terminated and initialized again. + * The function address you set is never reset by GLFW, but it only takes + * effect during initialization. Once GLFW has been initialized, any updates + * will be ignored until the library is terminated and initialized again. * * @param[in] loader The address of the function to use, or `NULL`. * * @par Loader function signature * @code - * PFN_vkVoidFunction vkGetInstanceProcAddr(VkInstance instance, const char* name) + * PFN_vkVoidFunction vkGetInstanceProcAddr(VkInstance instance, const char* + * name) * @endcode * For more information about this function, see the * [Vulkan Registry](https://www.khronos.org/registry/vulkan/). @@ -2327,22 +2362,22 @@ GLFWAPI void glfwInitVulkanLoader(PFN_vkGetInstanceProcAddr loader); * * @ingroup init */ -GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev); +GLFWAPI void glfwGetVersion(int *major, int *minor, int *rev); /*! @brief Returns a string describing the compile-time configuration. * * This function returns the compile-time generated - * [version string](@ref intro_version_string) of the GLFW library binary. It describes - * the version, platforms, compiler and any platform or operating system specific - * compile-time options. It should not be confused with the OpenGL or OpenGL ES version - * string, queried with `glGetString`. + * [version string](@ref intro_version_string) of the GLFW library binary. It + * describes the version, platforms, compiler and any platform or operating + * system specific compile-time options. It should not be confused with the + * OpenGL or OpenGL ES version string, queried with `glGetString`. * * __Do not use the version string__ to parse the GLFW library version. The * @ref glfwGetVersion function provides the version of the running library * binary in numerical format. * - * __Do not use the version string__ to parse what platforms are supported. The @ref - * glfwPlatformSupported function lets you query platform support. + * __Do not use the version string__ to parse what platforms are supported. The + * @ref glfwPlatformSupported function lets you query platform support. * * @return The ASCII encoded GLFW version string. * @@ -2361,7 +2396,7 @@ GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev); * * @ingroup init */ -GLFWAPI const char* glfwGetVersionString(void); +GLFWAPI const char *glfwGetVersionString(void); /*! @brief Returns and clears the last error for the calling thread. * @@ -2371,7 +2406,8 @@ GLFWAPI const char* glfwGetVersionString(void); * call, it returns @ref GLFW_NO_ERROR (zero) and the description pointer is * set to `NULL`. * - * @param[in] description Where to store the error description pointer, or `NULL`. + * @param[in] description Where to store the error description pointer, or + * `NULL`. * @return The last error code for the calling thread, or @ref GLFW_NO_ERROR * (zero). * @@ -2392,7 +2428,7 @@ GLFWAPI const char* glfwGetVersionString(void); * * @ingroup init */ -GLFWAPI int glfwGetError(const char** description); +GLFWAPI int glfwGetError(const char **description); /*! @brief Sets the error callback. * @@ -2442,9 +2478,10 @@ GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun callback); /*! @brief Returns the currently selected platform. * - * This function returns the platform that was selected during initialization. The - * returned value will be one of `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`, - * `GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` or `GLFW_PLATFORM_NULL`. + * This function returns the platform that was selected during initialization. + * The returned value will be one of `GLFW_PLATFORM_WIN32`, + * `GLFW_PLATFORM_COCOA`, `GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` or + * `GLFW_PLATFORM_NULL`. * * @return The currently selected platform, or zero if an error occurred. * @@ -2461,11 +2498,13 @@ GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun callback); */ GLFWAPI int glfwGetPlatform(void); -/*! @brief Returns whether the library includes support for the specified platform. +/*! @brief Returns whether the library includes support for the specified + * platform. * - * This function returns whether the library was compiled with support for the specified - * platform. The platform must be one of `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`, - * `GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` or `GLFW_PLATFORM_NULL`. + * This function returns whether the library was compiled with support for the + * specified platform. The platform must be one of `GLFW_PLATFORM_WIN32`, + * `GLFW_PLATFORM_COCOA`, `GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` or + * `GLFW_PLATFORM_NULL`. * * @param[in] platform The platform to query. * @return `GLFW_TRUE` if the platform is supported, or `GLFW_FALSE` otherwise. @@ -2512,7 +2551,7 @@ GLFWAPI int glfwPlatformSupported(int platform); * * @ingroup monitor */ -GLFWAPI GLFWmonitor** glfwGetMonitors(int* count); +GLFWAPI GLFWmonitor **glfwGetMonitors(int *count); /*! @brief Returns the primary monitor. * @@ -2536,7 +2575,7 @@ GLFWAPI GLFWmonitor** glfwGetMonitors(int* count); * * @ingroup monitor */ -GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void); +GLFWAPI GLFWmonitor *glfwGetPrimaryMonitor(void); /*! @brief Returns the position of the monitor's viewport on the virtual screen. * @@ -2561,7 +2600,7 @@ GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void); * * @ingroup monitor */ -GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos); +GLFWAPI void glfwGetMonitorPos(GLFWmonitor *monitor, int *xpos, int *ypos); /*! @brief Retrieves the work area of the monitor. * @@ -2592,7 +2631,8 @@ GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos); * * @ingroup monitor */ -GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height); +GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor *monitor, int *xpos, int *ypos, + int *width, int *height); /*! @brief Returns the physical size of the monitor. * @@ -2616,7 +2656,8 @@ GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* monitor, int* xpos, int* ypos, * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @remark @win32 On Windows 8 and earlier the physical size is calculated from - * the current resolution and system DPI instead of querying the monitor EDID data. + * the current resolution and system DPI instead of querying the monitor EDID + * data. * * @thread_safety This function must only be called from the main thread. * @@ -2626,7 +2667,8 @@ GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* monitor, int* xpos, int* ypos, * * @ingroup monitor */ -GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* widthMM, int* heightMM); +GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor *monitor, int *widthMM, + int *heightMM); /*! @brief Retrieves the content scale for the specified monitor. * @@ -2658,7 +2700,8 @@ GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* widthMM, int* * * @ingroup monitor */ -GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* monitor, float* xscale, float* yscale); +GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor *monitor, float *xscale, + float *yscale); /*! @brief Returns the name of the specified monitor. * @@ -2684,7 +2727,7 @@ GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* monitor, float* xscale, flo * * @ingroup monitor */ -GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor); +GLFWAPI const char *glfwGetMonitorName(GLFWmonitor *monitor); /*! @brief Sets the user pointer of the specified monitor. * @@ -2710,7 +2753,7 @@ GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor); * * @ingroup monitor */ -GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor* monitor, void* pointer); +GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor *monitor, void *pointer); /*! @brief Returns the user pointer of the specified monitor. * @@ -2734,7 +2777,7 @@ GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor* monitor, void* pointer); * * @ingroup monitor */ -GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* monitor); +GLFWAPI void *glfwGetMonitorUserPointer(GLFWmonitor *monitor); /*! @brief Sets the monitor configuration callback. * @@ -2798,7 +2841,7 @@ GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun callback); * * @ingroup monitor */ -GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count); +GLFWAPI const GLFWvidmode *glfwGetVideoModes(GLFWmonitor *monitor, int *count); /*! @brief Returns the current mode of the specified monitor. * @@ -2826,7 +2869,7 @@ GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count); * * @ingroup monitor */ -GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor); +GLFWAPI const GLFWvidmode *glfwGetVideoMode(GLFWmonitor *monitor); /*! @brief Generates a gamma ramp and sets it for the specified monitor. * @@ -2845,7 +2888,8 @@ GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor); * @param[in] monitor The monitor whose gamma ramp to set. * @param[in] gamma The desired exponent. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_INVALID_VALUE, + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_INVALID_VALUE, * @ref GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * * @remark @wayland Gamma handling is a privileged protocol, this function @@ -2859,7 +2903,7 @@ GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor); * * @ingroup monitor */ -GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma); +GLFWAPI void glfwSetGamma(GLFWmonitor *monitor, float gamma); /*! @brief Returns the current gamma ramp for the specified monitor. * @@ -2869,8 +2913,8 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma); * @return The current gamma ramp, or `NULL` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_PLATFORM_ERROR - * and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * * @remark @wayland Gamma handling is a privileged protocol, this function * will thus never be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE while @@ -2889,7 +2933,7 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma); * * @ingroup monitor */ -GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor); +GLFWAPI const GLFWgammaramp *glfwGetGammaRamp(GLFWmonitor *monitor); /*! @brief Sets the current gamma ramp for the specified monitor. * @@ -2908,8 +2952,8 @@ GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor); * @param[in] monitor The monitor whose gamma ramp to set. * @param[in] ramp The gamma ramp to use. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_PLATFORM_ERROR - * and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * * @remark The size of the specified gamma ramp should match the size of the * current ramp for that monitor. @@ -2930,7 +2974,7 @@ GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor); * * @ingroup monitor */ -GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp); +GLFWAPI void glfwSetGammaRamp(GLFWmonitor *monitor, const GLFWgammaramp *ramp); /*! @brief Resets all window hints to their default values. * @@ -3022,7 +3066,7 @@ GLFWAPI void glfwWindowHint(int hint, int value); * * @ingroup window */ -GLFWAPI void glfwWindowHintString(int hint, const char* value); +GLFWAPI void glfwWindowHintString(int hint, const char *value); /*! @brief Creates a window and its associated context. * @@ -3089,8 +3133,8 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value); * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_API_UNAVAILABLE, @ref - * GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE, @ref - * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR. + * GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE and @ref + * GLFW_PLATFORM_ERROR. * * @remark @win32 Window creation will fail if the Microsoft GDI software * OpenGL implementation is the only one available. @@ -3112,7 +3156,8 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value); * @remark @macos The GLFW window has no icon, as it is not a document * window, but the dock icon will be the same as the application bundle's icon. * For more information on bundles, see the - * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/) + * [Bundle Programming + * Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/) * in the Mac Developer Library. * * @remark @macos On OS X 10.10 and later the window frame will not be rendered @@ -3120,7 +3165,8 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value); * [GLFW_COCOA_RETINA_FRAMEBUFFER](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint) * hint is `GLFW_TRUE` and the `NSHighResolutionCapable` key is enabled in the * application bundle's `Info.plist`. For more information, see - * [High Resolution Guidelines for OS X](https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html) + * [High Resolution Guidelines for OS + * X](https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html) * in the Mac Developer Library. The GLFW test and example programs use * a custom `Info.plist` template for this, which can be found as * `CMake/Info.plist.in` in the source tree. @@ -3168,7 +3214,8 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value); * * @ingroup window */ -GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share); +GLFWAPI GLFWwindow *glfwCreateWindow(int width, int height, const char *title, + GLFWmonitor *monitor, GLFWwindow *share); /*! @brief Destroys the specified window and its context. * @@ -3197,7 +3244,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, G * * @ingroup window */ -GLFWAPI void glfwDestroyWindow(GLFWwindow* window); +GLFWAPI void glfwDestroyWindow(GLFWwindow *window); /*! @brief Checks the close flag of the specified window. * @@ -3217,7 +3264,7 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow* window); * * @ingroup window */ -GLFWAPI int glfwWindowShouldClose(GLFWwindow* window); +GLFWAPI int glfwWindowShouldClose(GLFWwindow *window); /*! @brief Sets the close flag of the specified window. * @@ -3239,7 +3286,7 @@ GLFWAPI int glfwWindowShouldClose(GLFWwindow* window); * * @ingroup window */ -GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value); +GLFWAPI void glfwSetWindowShouldClose(GLFWwindow *window, int value); /*! @brief Sets the title of the specified window. * @@ -3264,7 +3311,7 @@ GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value); * * @ingroup window */ -GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title); +GLFWAPI void glfwSetWindowTitle(GLFWwindow *window, const char *title); /*! @brief Sets the icon for the specified window. * @@ -3297,7 +3344,8 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title); * @remark @macos Regular windows do not have icons on macOS. This function * will emit @ref GLFW_FEATURE_UNAVAILABLE. The dock icon will be the same as * the application bundle's icon. For more information on bundles, see the - * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/) + * [Bundle Programming + * Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/) * in the Mac Developer Library. * * @remark @wayland There is no existing protocol to change an icon, the @@ -3312,7 +3360,8 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title); * * @ingroup window */ -GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* images); +GLFWAPI void glfwSetWindowIcon(GLFWwindow *window, int count, + const GLFWimage *images); /*! @brief Retrieves the position of the content area of the specified window. * @@ -3344,7 +3393,7 @@ GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* i * * @ingroup window */ -GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos); +GLFWAPI void glfwGetWindowPos(GLFWwindow *window, int *xpos, int *ypos); /*! @brief Sets the position of the content area of the specified window. * @@ -3359,8 +3408,10 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos); * cannot and should not override these limits. * * @param[in] window The window to query. - * @param[in] xpos The x-coordinate of the upper-left corner of the content area. - * @param[in] ypos The y-coordinate of the upper-left corner of the content area. + * @param[in] xpos The x-coordinate of the upper-left corner of the content + * area. + * @param[in] ypos The y-coordinate of the upper-left corner of the content + * area. * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). @@ -3379,7 +3430,7 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos); * * @ingroup window */ -GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos); +GLFWAPI void glfwSetWindowPos(GLFWwindow *window, int xpos, int ypos); /*! @brief Retrieves the size of the content area of the specified window. * @@ -3409,7 +3460,7 @@ GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos); * * @ingroup window */ -GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height); +GLFWAPI void glfwGetWindowSize(GLFWwindow *window, int *width, int *height); /*! @brief Sets the size limits of the specified window. * @@ -3452,7 +3503,9 @@ GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height); * * @ingroup window */ -GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight); +GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow *window, int minwidth, + int minheight, int maxwidth, + int maxheight); /*! @brief Sets the aspect ratio of the specified window. * @@ -3495,7 +3548,7 @@ GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* window, int minwidth, int minhe * * @ingroup window */ -GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* window, int numer, int denom); +GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow *window, int numer, int denom); /*! @brief Sets the size of the content area of the specified window. * @@ -3536,7 +3589,7 @@ GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* window, int numer, int denom); * * @ingroup window */ -GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height); +GLFWAPI void glfwSetWindowSize(GLFWwindow *window, int width, int height); /*! @brief Retrieves the size of the framebuffer of the specified window. * @@ -3565,7 +3618,8 @@ GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height); * * @ingroup window */ -GLFWAPI void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height); +GLFWAPI void glfwGetFramebufferSize(GLFWwindow *window, int *width, + int *height); /*! @brief Retrieves the size of the frame of the window. * @@ -3602,7 +3656,8 @@ GLFWAPI void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height) * * @ingroup window */ -GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* window, int* left, int* top, int* right, int* bottom); +GLFWAPI void glfwGetWindowFrameSize(GLFWwindow *window, int *left, int *top, + int *right, int *bottom); /*! @brief Retrieves the content scale for the specified window. * @@ -3635,7 +3690,8 @@ GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* window, int* left, int* top, int * * @ingroup window */ -GLFWAPI void glfwGetWindowContentScale(GLFWwindow* window, float* xscale, float* yscale); +GLFWAPI void glfwGetWindowContentScale(GLFWwindow *window, float *xscale, + float *yscale); /*! @brief Returns the opacity of the whole window. * @@ -3643,7 +3699,8 @@ GLFWAPI void glfwGetWindowContentScale(GLFWwindow* window, float* xscale, float* * * The opacity (or alpha) value is a positive finite number between zero and * one, where zero is fully transparent and one is fully opaque. If the system - * does not support whole window transparency, this function always returns one. + * does not support whole window transparency, this function always returns + * one. * * The initial opacity value for newly created windows is one. * @@ -3662,7 +3719,7 @@ GLFWAPI void glfwGetWindowContentScale(GLFWwindow* window, float* xscale, float* * * @ingroup window */ -GLFWAPI float glfwGetWindowOpacity(GLFWwindow* window); +GLFWAPI float glfwGetWindowOpacity(GLFWwindow *window); /*! @brief Sets the opacity of the whole window. * @@ -3694,7 +3751,7 @@ GLFWAPI float glfwGetWindowOpacity(GLFWwindow* window); * * @ingroup window */ -GLFWAPI void glfwSetWindowOpacity(GLFWwindow* window, float opacity); +GLFWAPI void glfwSetWindowOpacity(GLFWwindow *window, float opacity); /*! @brief Iconifies the specified window. * @@ -3726,7 +3783,7 @@ GLFWAPI void glfwSetWindowOpacity(GLFWwindow* window, float opacity); * * @ingroup window */ -GLFWAPI void glfwIconifyWindow(GLFWwindow* window); +GLFWAPI void glfwIconifyWindow(GLFWwindow *window); /*! @brief Restores the specified window. * @@ -3753,7 +3810,7 @@ GLFWAPI void glfwIconifyWindow(GLFWwindow* window); * * @ingroup window */ -GLFWAPI void glfwRestoreWindow(GLFWwindow* window); +GLFWAPI void glfwRestoreWindow(GLFWwindow *window); /*! @brief Maximizes the specified window. * @@ -3778,7 +3835,7 @@ GLFWAPI void glfwRestoreWindow(GLFWwindow* window); * * @ingroup window */ -GLFWAPI void glfwMaximizeWindow(GLFWwindow* window); +GLFWAPI void glfwMaximizeWindow(GLFWwindow *window); /*! @brief Makes the specified window visible. * @@ -3810,7 +3867,7 @@ GLFWAPI void glfwMaximizeWindow(GLFWwindow* window); * * @ingroup window */ -GLFWAPI void glfwShowWindow(GLFWwindow* window); +GLFWAPI void glfwShowWindow(GLFWwindow *window); /*! @brief Hides the specified window. * @@ -3832,7 +3889,7 @@ GLFWAPI void glfwShowWindow(GLFWwindow* window); * * @ingroup window */ -GLFWAPI void glfwHideWindow(GLFWwindow* window); +GLFWAPI void glfwHideWindow(GLFWwindow *window); /*! @brief Brings the specified window to front and sets input focus. * @@ -3871,7 +3928,7 @@ GLFWAPI void glfwHideWindow(GLFWwindow* window); * * @ingroup window */ -GLFWAPI void glfwFocusWindow(GLFWwindow* window); +GLFWAPI void glfwFocusWindow(GLFWwindow *window); /*! @brief Requests user attention to the specified window. * @@ -3898,7 +3955,7 @@ GLFWAPI void glfwFocusWindow(GLFWwindow* window); * * @ingroup window */ -GLFWAPI void glfwRequestWindowAttention(GLFWwindow* window); +GLFWAPI void glfwRequestWindowAttention(GLFWwindow *window); /*! @brief Returns the monitor that the window uses for full screen mode. * @@ -3920,7 +3977,7 @@ GLFWAPI void glfwRequestWindowAttention(GLFWwindow* window); * * @ingroup window */ -GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window); +GLFWAPI GLFWmonitor *glfwGetWindowMonitor(GLFWwindow *window); /*! @brief Sets the mode, monitor, video mode and placement of a window. * @@ -3979,7 +4036,9 @@ GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window); * * @ingroup window */ -GLFWAPI void glfwSetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate); +GLFWAPI void glfwSetWindowMonitor(GLFWwindow *window, GLFWmonitor *monitor, + int xpos, int ypos, int width, int height, + int refreshRate); /*! @brief Returns an attribute of the specified window. * @@ -4016,7 +4075,7 @@ GLFWAPI void glfwSetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int * * @ingroup window */ -GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib); +GLFWAPI int glfwGetWindowAttrib(GLFWwindow *window, int attrib); /*! @brief Sets an attribute of the specified window. * @@ -4040,8 +4099,8 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib); * @param[in] value `GLFW_TRUE` or `GLFW_FALSE`. * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_PLATFORM_ERROR and @ref - * GLFW_FEATURE_UNAVAILABLE. + * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_PLATFORM_ERROR and + * @ref GLFW_FEATURE_UNAVAILABLE. * * @remark Calling @ref glfwGetWindowAttrib will always return the latest * value, even if that value is ignored by the current mode of the window. @@ -4055,7 +4114,7 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib); * * @ingroup window */ -GLFWAPI void glfwSetWindowAttrib(GLFWwindow* window, int attrib, int value); +GLFWAPI void glfwSetWindowAttrib(GLFWwindow *window, int attrib, int value); /*! @brief Sets the user pointer of the specified window. * @@ -4078,7 +4137,7 @@ GLFWAPI void glfwSetWindowAttrib(GLFWwindow* window, int attrib, int value); * * @ingroup window */ -GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer); +GLFWAPI void glfwSetWindowUserPointer(GLFWwindow *window, void *pointer); /*! @brief Returns the user pointer of the specified window. * @@ -4099,7 +4158,7 @@ GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer); * * @ingroup window */ -GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window); +GLFWAPI void *glfwGetWindowUserPointer(GLFWwindow *window); /*! @brief Sets the position callback for the specified window. * @@ -4134,7 +4193,40 @@ GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window); * * @ingroup window */ -GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun callback); +GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow *window, + GLFWwindowposfun callback); + +/*! @brief Sets the titlebar hittest callback for the specified window. + * + * This function sets the titlebar hittest callback of the specified window, + * which is called when the mouse hoveres the window to ask client if it's + * hovering over custom titlebar area which needs to be handles as a native + * titlebar. The callback is provided with the x and y coordinates of the mouse + * cursor in screen coordinates. + * + * @param[in] window The window whose callback to set. + * @param[in] callback The new callback, or `NULL` to remove the currently set + * callback. + * @return The previously set callback, or `NULL` if no callback was set or the + * library had not been [initialized](@ref intro_init). + * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, int xpos, int ypos, int* hit) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWtitlebarhittestfun). + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_pos + * + * @ingroup window + */ +GLFWAPI GLFWtitlebarhittestfun glfwSetTitlebarHitTestCallback( + GLFWwindow *window, GLFWtitlebarhittestfun callback); /*! @brief Sets the size callback for the specified window. * @@ -4166,7 +4258,8 @@ GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindow * * @ingroup window */ -GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun callback); +GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow *window, + GLFWwindowsizefun callback); /*! @brief Sets the close callback for the specified window. * @@ -4206,7 +4299,8 @@ GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwind * * @ingroup window */ -GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun callback); +GLFWAPI GLFWwindowclosefun +glfwSetWindowCloseCallback(GLFWwindow *window, GLFWwindowclosefun callback); /*! @brief Sets the refresh callback for the specified window. * @@ -4242,7 +4336,8 @@ GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwi * * @ingroup window */ -GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun callback); +GLFWAPI GLFWwindowrefreshfun +glfwSetWindowRefreshCallback(GLFWwindow *window, GLFWwindowrefreshfun callback); /*! @brief Sets the focus callback for the specified window. * @@ -4277,7 +4372,8 @@ GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GL * * @ingroup window */ -GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun callback); +GLFWAPI GLFWwindowfocusfun +glfwSetWindowFocusCallback(GLFWwindow *window, GLFWwindowfocusfun callback); /*! @brief Sets the iconify callback for the specified window. * @@ -4307,7 +4403,8 @@ GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwi * * @ingroup window */ -GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun callback); +GLFWAPI GLFWwindowiconifyfun +glfwSetWindowIconifyCallback(GLFWwindow *window, GLFWwindowiconifyfun callback); /*! @brief Sets the maximize callback for the specified window. * @@ -4337,7 +4434,8 @@ GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GL * * @ingroup window */ -GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* window, GLFWwindowmaximizefun callback); +GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback( + GLFWwindow *window, GLFWwindowmaximizefun callback); /*! @brief Sets the framebuffer resize callback for the specified window. * @@ -4367,12 +4465,14 @@ GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* window, * * @ingroup window */ -GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun callback); +GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback( + GLFWwindow *window, GLFWframebuffersizefun callback); /*! @brief Sets the window content scale callback for the specified window. * - * This function sets the window content scale callback of the specified window, - * which is called when the content scale of the specified window changes. + * This function sets the window content scale callback of the specified + * window, which is called when the content scale of the specified window + * changes. * * @param[in] window The window whose callback to set. * @param[in] callback The new callback, or `NULL` to remove the currently set @@ -4398,7 +4498,8 @@ GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window * * @ingroup window */ -GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* window, GLFWwindowcontentscalefun callback); +GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback( + GLFWwindow *window, GLFWwindowcontentscalefun callback); /*! @brief Processes all pending events. * @@ -4575,7 +4676,7 @@ GLFWAPI void glfwPostEmptyEvent(void); * * @ingroup input */ -GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode); +GLFWAPI int glfwGetInputMode(GLFWwindow *window, int mode); /*! @brief Sets an input option for the specified window. * @@ -4640,7 +4741,7 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode); * * @ingroup input */ -GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value); +GLFWAPI void glfwSetInputMode(GLFWwindow *window, int mode, int value); /*! @brief Returns whether raw mouse motion is supported. * @@ -4720,8 +4821,8 @@ GLFWAPI int glfwRawMouseMotionSupported(void); * @param[in] scancode The scancode of the key to query. * @return The UTF-8 encoded, layout-specific name of the key, or `NULL`. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_INVALID_VALUE, @ref GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. * * @remark The contents of the returned string may change when a keyboard * layout change event is received. @@ -4737,24 +4838,21 @@ GLFWAPI int glfwRawMouseMotionSupported(void); * * @ingroup input */ -GLFWAPI const char* glfwGetKeyName(int key, int scancode); +GLFWAPI const char *glfwGetKeyName(int key, int scancode); /*! @brief Returns the platform-specific scancode of the specified key. * * This function returns the platform-specific scancode of the specified key. * - * If the specified [key token](@ref keys) corresponds to a physical key not - * supported on the current platform then this method will return `-1`. - * Calling this function with anything other than a key token will return `-1` - * and generate a @ref GLFW_INVALID_ENUM error. + * If the key is `GLFW_KEY_UNKNOWN` or does not exist on the keyboard this + * method will return `-1`. * - * @param[in] key Any [key token](@ref keys). - * @return The platform-specific scancode for the key, or `-1` if the key is - * not supported on the current platform or an [error](@ref error_handling) - * occurred. + * @param[in] key Any [named key](@ref keys). + * @return The platform-specific scancode for the key, or `-1` if an + * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_INVALID_ENUM. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR. * * @thread_safety This function may be called from any thread. * @@ -4771,7 +4869,8 @@ GLFWAPI int glfwGetKeyScancode(int key); * * This function returns the last state reported for the specified key to the * specified window. The returned state is one of `GLFW_PRESS` or - * `GLFW_RELEASE`. The action `GLFW_REPEAT` is only reported to the key callback. + * `GLFW_RELEASE`. The action `GLFW_REPEAT` is only reported to the key + * callback. * * If the @ref GLFW_STICKY_KEYS input mode is enabled, this function returns * `GLFW_PRESS` the first time you call it for a key that was pressed, even if @@ -4803,7 +4902,7 @@ GLFWAPI int glfwGetKeyScancode(int key); * * @ingroup input */ -GLFWAPI int glfwGetKey(GLFWwindow* window, int key); +GLFWAPI int glfwGetKey(GLFWwindow *window, int key); /*! @brief Returns the last reported state of a mouse button for the specified * window. @@ -4832,7 +4931,7 @@ GLFWAPI int glfwGetKey(GLFWwindow* window, int key); * * @ingroup input */ -GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button); +GLFWAPI int glfwGetMouseButton(GLFWwindow *window, int button); /*! @brief Retrieves the position of the cursor relative to the content area of * the window. @@ -4870,7 +4969,7 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button); * * @ingroup input */ -GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos); +GLFWAPI void glfwGetCursorPos(GLFWwindow *window, double *xpos, double *ypos); /*! @brief Sets the position of the cursor, relative to the content area of the * window. @@ -4899,7 +4998,8 @@ GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos); * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * * @remark @wayland This function will only work when the cursor mode is - * `GLFW_CURSOR_DISABLED`, otherwise it will emit @ref GLFW_FEATURE_UNAVAILABLE. + * `GLFW_CURSOR_DISABLED`, otherwise it will emit @ref + * GLFW_FEATURE_UNAVAILABLE. * * @thread_safety This function must only be called from the main thread. * @@ -4910,7 +5010,7 @@ GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos); * * @ingroup input */ -GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos); +GLFWAPI void glfwSetCursorPos(GLFWwindow *window, double xpos, double ypos); /*! @brief Creates a custom cursor. * @@ -4948,7 +5048,8 @@ GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos); * * @ingroup input */ -GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot); +GLFWAPI GLFWcursor *glfwCreateCursor(const GLFWimage *image, int xhot, + int yhot); /*! @brief Creates a cursor with a standard shape. * @@ -4967,10 +5068,13 @@ GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot) * @ref GLFW_POINTING_HAND_CURSOR | Yes | Yes | Yes | Yes * @ref GLFW_RESIZE_EW_CURSOR | Yes | Yes | Yes | Yes * @ref GLFW_RESIZE_NS_CURSOR | Yes | Yes | Yes | Yes - * @ref GLFW_RESIZE_NWSE_CURSOR | Yes | Yes1 | Maybe2 | Maybe2 - * @ref GLFW_RESIZE_NESW_CURSOR | Yes | Yes1 | Maybe2 | Maybe2 + * @ref GLFW_RESIZE_NWSE_CURSOR | Yes | Yes1 | + * Maybe2 | Maybe2 + * @ref GLFW_RESIZE_NESW_CURSOR | Yes | Yes1 | + * Maybe2 | Maybe2 * @ref GLFW_RESIZE_ALL_CURSOR | Yes | Yes | Yes | Yes - * @ref GLFW_NOT_ALLOWED_CURSOR | Yes | Yes | Maybe2 | Maybe2 + * @ref GLFW_NOT_ALLOWED_CURSOR | Yes | Yes | Maybe2 | + * Maybe2 * * 1) This uses a private system API and may fail in the future. * @@ -4996,7 +5100,7 @@ GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot) * * @ingroup input */ -GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape); +GLFWAPI GLFWcursor *glfwCreateStandardCursor(int shape); /*! @brief Destroys a cursor. * @@ -5023,7 +5127,7 @@ GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape); * * @ingroup input */ -GLFWAPI void glfwDestroyCursor(GLFWcursor* cursor); +GLFWAPI void glfwDestroyCursor(GLFWcursor *cursor); /*! @brief Sets the cursor for the window. * @@ -5050,7 +5154,7 @@ GLFWAPI void glfwDestroyCursor(GLFWcursor* cursor); * * @ingroup input */ -GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor); +GLFWAPI void glfwSetCursor(GLFWwindow *window, GLFWcursor *cursor); /*! @brief Sets the key callback. * @@ -5063,9 +5167,9 @@ GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor); * [character callback](@ref glfwSetCharCallback) instead. * * When a window loses input focus, it will generate synthetic key release - * events for all pressed keys with associated key tokens. You can tell these - * events from user-generated events by the fact that the synthetic ones are - * generated after the focus loss event has been processed, i.e. after the + * events for all pressed keys. You can tell these events from user-generated + * events by the fact that the synthetic ones are generated after the focus + * loss event has been processed, i.e. after the * [window focus callback](@ref glfwSetWindowFocusCallback) has been called. * * The scancode of a key is specific to that platform or sometimes even to that @@ -5084,7 +5188,8 @@ GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor); * * @callback_signature * @code - * void function_name(GLFWwindow* window, int key, int scancode, int action, int mods) + * void function_name(GLFWwindow* window, int key, int scancode, int action, + * int mods) * @endcode * For more information about the callback parameters, see the * [function pointer type](@ref GLFWkeyfun). @@ -5100,7 +5205,7 @@ GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor); * * @ingroup input */ -GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun callback); +GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow *window, GLFWkeyfun callback); /*! @brief Sets the Unicode character callback. * @@ -5116,8 +5221,8 @@ GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun callback); * * The character callback behaves as system text input normally does and will * not be called if modifier keys are held down that would prevent normal text - * input on that platform, for example a Super (Command) key on macOS or Alt key - * on Windows. + * input on that platform, for example a Super (Command) key on macOS or Alt + * key on Windows. * * @param[in] window The window whose callback to set. * @param[in] callback The new callback, or `NULL` to remove the currently set @@ -5143,7 +5248,8 @@ GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun callback); * * @ingroup input */ -GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun callback); +GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow *window, + GLFWcharfun callback); /*! @brief Sets the Unicode character with modifiers callback. * @@ -5185,7 +5291,8 @@ GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun callback * * @ingroup input */ -GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmodsfun callback); +GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow *window, + GLFWcharmodsfun callback); /*! @brief Sets the mouse button callback. * @@ -5222,7 +5329,8 @@ GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmods * * @ingroup input */ -GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun callback); +GLFWAPI GLFWmousebuttonfun +glfwSetMouseButtonCallback(GLFWwindow *window, GLFWmousebuttonfun callback); /*! @brief Sets the cursor position callback. * @@ -5254,7 +5362,8 @@ GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmo * * @ingroup input */ -GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun callback); +GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow *window, + GLFWcursorposfun callback); /*! @brief Sets the cursor enter/leave callback. * @@ -5285,7 +5394,8 @@ GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursor * * @ingroup input */ -GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun callback); +GLFWAPI GLFWcursorenterfun +glfwSetCursorEnterCallback(GLFWwindow *window, GLFWcursorenterfun callback); /*! @brief Sets the scroll callback. * @@ -5319,7 +5429,8 @@ GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcu * * @ingroup input */ -GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun callback); +GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow *window, + GLFWscrollfun callback); /*! @brief Sets the path drop callback. * @@ -5356,7 +5467,8 @@ GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun ca * * @ingroup input */ -GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* window, GLFWdropfun callback); +GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow *window, + GLFWdropfun callback); /*! @brief Returns whether the specified joystick is present. * @@ -5413,7 +5525,7 @@ GLFWAPI int glfwJoystickPresent(int jid); * * @ingroup input */ -GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count); +GLFWAPI const float *glfwGetJoystickAxes(int jid, int *count); /*! @brief Returns the state of all buttons of the specified joystick. * @@ -5454,7 +5566,7 @@ GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count); * * @ingroup input */ -GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count); +GLFWAPI const unsigned char *glfwGetJoystickButtons(int jid, int *count); /*! @brief Returns the state of all hats of the specified joystick. * @@ -5511,7 +5623,7 @@ GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count); * * @ingroup input */ -GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count); +GLFWAPI const unsigned char *glfwGetJoystickHats(int jid, int *count); /*! @brief Returns the name of the specified joystick. * @@ -5542,7 +5654,7 @@ GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count); * * @ingroup input */ -GLFWAPI const char* glfwGetJoystickName(int jid); +GLFWAPI const char *glfwGetJoystickName(int jid); /*! @brief Returns the SDL compatible GUID of the specified joystick. * @@ -5583,7 +5695,7 @@ GLFWAPI const char* glfwGetJoystickName(int jid); * * @ingroup input */ -GLFWAPI const char* glfwGetJoystickGUID(int jid); +GLFWAPI const char *glfwGetJoystickGUID(int jid); /*! @brief Sets the user pointer of the specified joystick. * @@ -5609,7 +5721,7 @@ GLFWAPI const char* glfwGetJoystickGUID(int jid); * * @ingroup input */ -GLFWAPI void glfwSetJoystickUserPointer(int jid, void* pointer); +GLFWAPI void glfwSetJoystickUserPointer(int jid, void *pointer); /*! @brief Returns the user pointer of the specified joystick. * @@ -5633,7 +5745,7 @@ GLFWAPI void glfwSetJoystickUserPointer(int jid, void* pointer); * * @ingroup input */ -GLFWAPI void* glfwGetJoystickUserPointer(int jid); +GLFWAPI void *glfwGetJoystickUserPointer(int jid); /*! @brief Returns whether the specified joystick has a gamepad mapping. * @@ -5731,7 +5843,7 @@ GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun callback); * * @ingroup input */ -GLFWAPI int glfwUpdateGamepadMappings(const char* string); +GLFWAPI int glfwUpdateGamepadMappings(const char *string); /*! @brief Returns the human-readable gamepad name for the specified joystick. * @@ -5748,7 +5860,8 @@ GLFWAPI int glfwUpdateGamepadMappings(const char* string); * joystick is not present, does not have a mapping or an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref GLFW_INVALID_ENUM. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_INVALID_ENUM. * * @pointer_lifetime The returned string is allocated and freed by GLFW. You * should not free it yourself. It is valid until the specified joystick is @@ -5763,7 +5876,7 @@ GLFWAPI int glfwUpdateGamepadMappings(const char* string); * * @ingroup input */ -GLFWAPI const char* glfwGetGamepadName(int jid); +GLFWAPI const char *glfwGetGamepadName(int jid); /*! @brief Retrieves the state of the specified joystick remapped as a gamepad. * @@ -5801,7 +5914,7 @@ GLFWAPI const char* glfwGetGamepadName(int jid); * * @ingroup input */ -GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state); +GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate *state); /*! @brief Sets the clipboard to the specified string. * @@ -5814,11 +5927,6 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_PLATFORM_ERROR. * - * @remark @win32 The clipboard on Windows has a single global lock for reading and - * writing. GLFW tries to acquire it a few times, which is almost always enough. If it - * cannot acquire the lock then this function emits @ref GLFW_PLATFORM_ERROR and returns. - * It is safe to try this multiple times. - * * @pointer_lifetime The specified string is copied before this function * returns. * @@ -5831,7 +5939,7 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state); * * @ingroup input */ -GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string); +GLFWAPI void glfwSetClipboardString(GLFWwindow *window, const char *string); /*! @brief Returns the contents of the clipboard as a string. * @@ -5847,11 +5955,6 @@ GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * GLFW_FORMAT_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR. * - * @remark @win32 The clipboard on Windows has a single global lock for reading and - * writing. GLFW tries to acquire it a few times, which is almost always enough. If it - * cannot acquire the lock then this function emits @ref GLFW_PLATFORM_ERROR and returns. - * It is safe to try this multiple times. - * * @pointer_lifetime The returned string is allocated and freed by GLFW. You * should not free it yourself. It is valid until the next call to @ref * glfwGetClipboardString or @ref glfwSetClipboardString, or until the library @@ -5866,7 +5969,7 @@ GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string); * * @ingroup input */ -GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window); +GLFWAPI const char *glfwGetClipboardString(GLFWwindow *window); /*! @brief Returns the GLFW time. * @@ -5974,15 +6077,12 @@ GLFWAPI uint64_t glfwGetTimerFrequency(void); * thread. * * This function makes the OpenGL or OpenGL ES context of the specified window - * current on the calling thread. It can also detach the current context from - * the calling thread without making a new one current by passing in `NULL`. + * current on the calling thread. A context must only be made current on + * a single thread at a time and each thread can have only a single current + * context at a time. * - * A context must only be made current on a single thread at a time and each - * thread can have only a single current context at a time. Making a context - * current detaches any previously current context on the calling thread. - * - * When moving a context between threads, you must detach it (make it - * non-current) on the old thread before making it current on the new one. + * When moving a context between threads, you must make it non-current on the + * old thread before making it current on the new one. * * By default, making a context non-current implicitly forces a pipeline flush. * On machines that support `GL_KHR_context_flush_control`, you can control @@ -5997,10 +6097,6 @@ GLFWAPI uint64_t glfwGetTimerFrequency(void); * @param[in] window The window whose context to make current, or `NULL` to * detach the current context. * - * @remarks If the previously current context was created via a different - * context creation API than the one passed to this function, GLFW will still - * detach the previous one from its API before making the new one current. - * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR. * @@ -6013,7 +6109,7 @@ GLFWAPI uint64_t glfwGetTimerFrequency(void); * * @ingroup context */ -GLFWAPI void glfwMakeContextCurrent(GLFWwindow* window); +GLFWAPI void glfwMakeContextCurrent(GLFWwindow *window); /*! @brief Returns the window whose context is current on the calling thread. * @@ -6034,7 +6130,7 @@ GLFWAPI void glfwMakeContextCurrent(GLFWwindow* window); * * @ingroup context */ -GLFWAPI GLFWwindow* glfwGetCurrentContext(void); +GLFWAPI GLFWwindow *glfwGetCurrentContext(void); /*! @brief Swaps the front and back buffers of the specified window. * @@ -6068,7 +6164,7 @@ GLFWAPI GLFWwindow* glfwGetCurrentContext(void); * * @ingroup window */ -GLFWAPI void glfwSwapBuffers(GLFWwindow* window); +GLFWAPI void glfwSwapBuffers(GLFWwindow *window); /*! @brief Sets the swap interval for the current context. * @@ -6152,7 +6248,7 @@ GLFWAPI void glfwSwapInterval(int interval); * * @ingroup context */ -GLFWAPI int glfwExtensionSupported(const char* extension); +GLFWAPI int glfwExtensionSupported(const char *extension); /*! @brief Returns the address of the specified function for the current * context. @@ -6194,18 +6290,19 @@ GLFWAPI int glfwExtensionSupported(const char* extension); * * @ingroup context */ -GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname); +GLFWAPI GLFWglproc glfwGetProcAddress(const char *procname); /*! @brief Returns whether the Vulkan loader and an ICD have been found. * * This function returns whether the Vulkan loader and any minimally functional * ICD have been found. * - * The availability of a Vulkan loader and even an ICD does not by itself guarantee that - * surface creation or even instance creation is possible. Call @ref - * glfwGetRequiredInstanceExtensions to check whether the extensions necessary for Vulkan - * surface creation are available and @ref glfwGetPhysicalDevicePresentationSupport to - * check whether a queue family of a physical device supports image presentation. + * The availability of a Vulkan loader and even an ICD does not by itself + * guarantee that surface creation or even instance creation is possible. Call + * @ref glfwGetRequiredInstanceExtensions to check whether the extensions + * necessary for Vulkan surface creation are available and @ref + * glfwGetPhysicalDevicePresentationSupport to check whether a queue family of a + * physical device supports image presentation. * * @return `GLFW_TRUE` if Vulkan is minimally available, or `GLFW_FALSE` * otherwise. @@ -6224,10 +6321,10 @@ GLFWAPI int glfwVulkanSupported(void); /*! @brief Returns the Vulkan instance extensions required by GLFW. * - * This function returns an array of names of Vulkan instance extensions required - * by GLFW for creating Vulkan surfaces for GLFW windows. If successful, the - * list will always contain `VK_KHR_surface`, so if you don't require any - * additional extensions you can pass this list directly to the + * This function returns an array of names of Vulkan instance extensions + * required by GLFW for creating Vulkan surfaces for GLFW windows. If + * successful, the list will always contain `VK_KHR_surface`, so if you don't + * require any additional extensions you can pass this list directly to the * `VkInstanceCreateInfo` struct. * * If Vulkan is not available on the machine, this function returns `NULL` and @@ -6264,7 +6361,7 @@ GLFWAPI int glfwVulkanSupported(void); * * @ingroup vulkan */ -GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count); +GLFWAPI const char **glfwGetRequiredInstanceExtensions(uint32_t *count); #if defined(VK_VERSION_1_0) @@ -6307,7 +6404,8 @@ GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count); * * @ingroup vulkan */ -GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* procname); +GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, + const char *procname); /*! @brief Returns whether the specified queue family can present images. * @@ -6344,16 +6442,18 @@ GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* p * * @ingroup vulkan */ -GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily); +GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, + VkPhysicalDevice device, + uint32_t queuefamily); /*! @brief Creates a Vulkan surface for the specified window. * * This function creates a Vulkan surface for the specified window. * - * If the Vulkan loader or at least one minimally functional ICD were not found, - * this function returns `VK_ERROR_INITIALIZATION_FAILED` and generates a @ref - * GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported to check whether - * Vulkan is at least minimally available. + * If the Vulkan loader or at least one minimally functional ICD were not + * found, this function returns `VK_ERROR_INITIALIZATION_FAILED` and generates a + * @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported to check + * whether Vulkan is at least minimally available. * * If the required window surface creation instance extensions are not * available or if the specified instance was not created with these extensions @@ -6414,11 +6514,13 @@ GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhys * * @ingroup vulkan */ -GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface); +GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, + GLFWwindow *window, + const VkAllocationCallbacks *allocator, + VkSurfaceKHR *surface); #endif /*VK_VERSION_1_0*/ - /************************************************************************* * Global definition cleanup *************************************************************************/ @@ -6426,29 +6528,27 @@ GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window /* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */ #ifdef GLFW_WINGDIAPI_DEFINED - #undef WINGDIAPI - #undef GLFW_WINGDIAPI_DEFINED +#undef WINGDIAPI +#undef GLFW_WINGDIAPI_DEFINED #endif #ifdef GLFW_CALLBACK_DEFINED - #undef CALLBACK - #undef GLFW_CALLBACK_DEFINED +#undef CALLBACK +#undef GLFW_CALLBACK_DEFINED #endif /* Some OpenGL related headers need GLAPIENTRY, but it is unconditionally * defined by some gl.h variants (OpenBSD) so define it after if needed. */ #ifndef GLAPIENTRY - #define GLAPIENTRY APIENTRY - #define GLFW_GLAPIENTRY_DEFINED +#define GLAPIENTRY APIENTRY +#define GLFW_GLAPIENTRY_DEFINED #endif /* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */ - #ifdef __cplusplus } #endif #endif /* _glfw3_h_ */ - diff --git a/include/GLFW/glfw3native.h b/include/GLFW/glfw3native.h index 46072920..171abe36 100644 --- a/include/GLFW/glfw3native.h +++ b/include/GLFW/glfw3native.h @@ -169,8 +169,7 @@ extern "C" { * of the specified monitor, or `NULL` if an [error](@ref error_handling) * occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_UNAVAILABLE. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -187,8 +186,7 @@ GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* monitor); * `\\.\DISPLAY1\Monitor0`) of the specified monitor, or `NULL` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_UNAVAILABLE. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -204,8 +202,7 @@ GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor); * @return The `HWND` of the specified window, or `NULL` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_UNAVAILABLE. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @remark The `HDC` associated with the window can be queried with the * [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc) @@ -231,8 +228,8 @@ GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window); * @return The `HGLRC` of the specified window, or `NULL` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_PLATFORM_UNAVAILABLE and @ref GLFW_NO_WINDOW_CONTEXT. + * @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref + * GLFW_NOT_INITIALIZED. * * @remark The `HDC` associated with the window can be queried with the * [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc) @@ -258,8 +255,7 @@ GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window); * @return The `CGDirectDisplayID` of the specified monitor, or * `kCGNullDirectDisplay` if an [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_UNAVAILABLE. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -275,8 +271,7 @@ GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor); * @return The `NSWindow` of the specified window, or `nil` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_UNAVAILABLE. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -294,8 +289,8 @@ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window); * @return The `NSOpenGLContext` of the specified window, or `nil` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_PLATFORM_UNAVAILABLE and @ref GLFW_NO_WINDOW_CONTEXT. + * @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref + * GLFW_NOT_INITIALIZED. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -313,8 +308,7 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* window); * @return The `Display` used by GLFW, or `NULL` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_UNAVAILABLE. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -330,8 +324,7 @@ GLFWAPI Display* glfwGetX11Display(void); * @return The `RRCrtc` of the specified monitor, or `None` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_UNAVAILABLE. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -347,8 +340,7 @@ GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor); * @return The `RROutput` of the specified monitor, or `None` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_UNAVAILABLE. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -364,8 +356,7 @@ GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* monitor); * @return The `Window` of the specified window, or `None` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_UNAVAILABLE. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -380,8 +371,8 @@ GLFWAPI Window glfwGetX11Window(GLFWwindow* window); * * @param[in] string A UTF-8 encoded string. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_PLATFORM_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. * * @pointer_lifetime The specified string is copied before this function * returns. @@ -406,8 +397,8 @@ GLFWAPI void glfwSetX11SelectionString(const char* string); * @return The contents of the selection as a UTF-8 encoded string, or `NULL` * if an [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_PLATFORM_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. * * @pointer_lifetime The returned string is allocated and freed by GLFW. You * should not free it yourself. It is valid until the next call to @ref @@ -433,8 +424,8 @@ GLFWAPI const char* glfwGetX11SelectionString(void); * @return The `GLXContext` of the specified window, or `NULL` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_UNAVAILABLE. + * @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref + * GLFW_NOT_INITIALIZED. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -450,8 +441,8 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window); * @return The `GLXWindow` of the specified window, or `None` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_UNAVAILABLE. + * @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref + * GLFW_NOT_INITIALIZED. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -469,8 +460,7 @@ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* window); * @return The `struct wl_display*` used by GLFW, or `NULL` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_UNAVAILABLE. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -486,8 +476,7 @@ GLFWAPI struct wl_display* glfwGetWaylandDisplay(void); * @return The `struct wl_output*` of the specified monitor, or `NULL` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_UNAVAILABLE. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -503,8 +492,7 @@ GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* monitor); * @return The main `struct wl_surface*` of the specified window, or `NULL` if * an [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_UNAVAILABLE. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -541,8 +529,8 @@ GLFWAPI EGLDisplay glfwGetEGLDisplay(void); * @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_NO_WINDOW_CONTEXT. + * @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref + * GLFW_NOT_INITIALIZED. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -558,8 +546,8 @@ GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window); * @return The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_NO_WINDOW_CONTEXT. + * @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref + * GLFW_NOT_INITIALIZED. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -584,8 +572,8 @@ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window); * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_NO_WINDOW_CONTEXT. + * @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref + * GLFW_NOT_INITIALIZED. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -608,8 +596,8 @@ GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* window, int* width, int* height * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_NO_WINDOW_CONTEXT. + * @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref + * GLFW_NOT_INITIALIZED. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -625,8 +613,8 @@ GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* window, int* width, int* height * @return The `OSMesaContext` of the specified window, or `NULL` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_NO_WINDOW_CONTEXT. + * @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref + * GLFW_NOT_INITIALIZED. * * @thread_safety This function may be called from any thread. Access is not * synchronized. diff --git a/src/cocoa_init.m b/src/cocoa_init.m index b3831df1..3bace925 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -55,20 +55,18 @@ static void changeToResourcesDirectory(void) return; } - CFRelease(last); - - if (!CFURLGetFileSystemRepresentation(resourcesURL, - true, - (UInt8*) resourcesPath, - MAXPATHLEN)) - { - CFRelease(resourcesURL); - return; - } + CFRelease(last); + if (!CFURLGetFileSystemRepresentation(resourcesURL, + true, + (UInt8 *)resourcesPath, MAXPATHLEN)) { CFRelease(resourcesURL); + return; + } - chdir(resourcesPath); + CFRelease(resourcesURL); + + chdir(resourcesPath); } // Set up the menu bar (manually) @@ -76,308 +74,291 @@ static void changeToResourcesDirectory(void) // could go away at any moment, lots of stuff that really should be // localize(d|able), etc. Add a nib to save us this horror. // -static void createMenuBar(void) -{ - NSString* appName = nil; - NSDictionary* bundleInfo = [[NSBundle mainBundle] infoDictionary]; - NSString* nameKeys[] = - { - @"CFBundleDisplayName", - @"CFBundleName", - @"CFBundleExecutable", - }; +static void createMenuBar(void) { + NSString *appName = nil; + NSDictionary *bundleInfo = [[NSBundle mainBundle] infoDictionary]; + NSString *nameKeys[] = { + @"CFBundleDisplayName", + @"CFBundleName", + @"CFBundleExecutable", + }; - // Try to figure out what the calling application is called + // Try to figure out what the calling application is called - for (size_t i = 0; i < sizeof(nameKeys) / sizeof(nameKeys[0]); i++) - { - id name = bundleInfo[nameKeys[i]]; - if (name && - [name isKindOfClass:[NSString class]] && - ![name isEqualToString:@""]) - { - appName = name; - break; - } + for (size_t i = 0; i < sizeof(nameKeys) / sizeof(nameKeys[0]); i++) { + id name = bundleInfo[nameKeys[i]]; + if (name && [name isKindOfClass:[NSString class]] && + ![name isEqualToString:@""]) { + appName = name; + break; } + } - if (!appName) - { - char** progname = _NSGetProgname(); - if (progname && *progname) - appName = @(*progname); - else - appName = @"GLFW Application"; - } + if (!appName) { + char **progname = _NSGetProgname(); + if (progname && *progname) + appName = @(*progname); + else + appName = @"GLFW Application"; + } - NSMenu* bar = [[NSMenu alloc] init]; - [NSApp setMainMenu:bar]; + NSMenu *bar = [[NSMenu alloc] init]; + [NSApp setMainMenu:bar]; - NSMenuItem* appMenuItem = - [bar addItemWithTitle:@"" action:NULL keyEquivalent:@""]; - NSMenu* appMenu = [[NSMenu alloc] init]; - [appMenuItem setSubmenu:appMenu]; + NSMenuItem *appMenuItem = [bar addItemWithTitle:@"" + action:NULL + keyEquivalent:@""]; + NSMenu *appMenu = [[NSMenu alloc] init]; + [appMenuItem setSubmenu:appMenu]; - [appMenu addItemWithTitle:[NSString stringWithFormat:@"About %@", appName] - action:@selector(orderFrontStandardAboutPanel:) - keyEquivalent:@""]; - [appMenu addItem:[NSMenuItem separatorItem]]; - NSMenu* servicesMenu = [[NSMenu alloc] init]; - [NSApp setServicesMenu:servicesMenu]; - [[appMenu addItemWithTitle:@"Services" - action:NULL - keyEquivalent:@""] setSubmenu:servicesMenu]; - [servicesMenu release]; - [appMenu addItem:[NSMenuItem separatorItem]]; - [appMenu addItemWithTitle:[NSString stringWithFormat:@"Hide %@", appName] - action:@selector(hide:) - keyEquivalent:@"h"]; - [[appMenu addItemWithTitle:@"Hide Others" - action:@selector(hideOtherApplications:) - keyEquivalent:@"h"] - setKeyEquivalentModifierMask:NSEventModifierFlagOption | NSEventModifierFlagCommand]; - [appMenu addItemWithTitle:@"Show All" - action:@selector(unhideAllApplications:) - keyEquivalent:@""]; - [appMenu addItem:[NSMenuItem separatorItem]]; - [appMenu addItemWithTitle:[NSString stringWithFormat:@"Quit %@", appName] - action:@selector(terminate:) - keyEquivalent:@"q"]; + [appMenu addItemWithTitle:[NSString stringWithFormat:@"About %@", appName] + action:@selector(orderFrontStandardAboutPanel:) + keyEquivalent:@""]; + [appMenu addItem:[NSMenuItem separatorItem]]; + NSMenu *servicesMenu = [[NSMenu alloc] init]; + [NSApp setServicesMenu:servicesMenu]; + [[appMenu addItemWithTitle:@"Services" action:NULL + keyEquivalent:@""] setSubmenu:servicesMenu]; + [servicesMenu release]; + [appMenu addItem:[NSMenuItem separatorItem]]; + [appMenu addItemWithTitle:[NSString stringWithFormat:@"Hide %@", appName] + action:@selector(hide:) + keyEquivalent:@"h"]; + [[appMenu addItemWithTitle:@"Hide Others" + action:@selector(hideOtherApplications:) + keyEquivalent:@"h"] + setKeyEquivalentModifierMask:NSEventModifierFlagOption | + NSEventModifierFlagCommand]; + [appMenu addItemWithTitle:@"Show All" + action:@selector(unhideAllApplications:) + keyEquivalent:@""]; + [appMenu addItem:[NSMenuItem separatorItem]]; + [appMenu addItemWithTitle:[NSString stringWithFormat:@"Quit %@", appName] + action:@selector(terminate:) + keyEquivalent:@"q"]; - NSMenuItem* windowMenuItem = - [bar addItemWithTitle:@"" action:NULL keyEquivalent:@""]; - [bar release]; - NSMenu* windowMenu = [[NSMenu alloc] initWithTitle:@"Window"]; - [NSApp setWindowsMenu:windowMenu]; - [windowMenuItem setSubmenu:windowMenu]; + NSMenuItem *windowMenuItem = [bar addItemWithTitle:@"" + action:NULL + keyEquivalent:@""]; + [bar release]; + NSMenu *windowMenu = [[NSMenu alloc] initWithTitle:@"Window"]; + [NSApp setWindowsMenu:windowMenu]; + [windowMenuItem setSubmenu:windowMenu]; - [windowMenu addItemWithTitle:@"Minimize" - action:@selector(performMiniaturize:) - keyEquivalent:@"m"]; - [windowMenu addItemWithTitle:@"Zoom" - action:@selector(performZoom:) - keyEquivalent:@""]; - [windowMenu addItem:[NSMenuItem separatorItem]]; - [windowMenu addItemWithTitle:@"Bring All to Front" - action:@selector(arrangeInFront:) - keyEquivalent:@""]; + [windowMenu addItemWithTitle:@"Minimize" + action:@selector(performMiniaturize:) + keyEquivalent:@"m"]; + [windowMenu addItemWithTitle:@"Zoom" + action:@selector(performZoom:) + keyEquivalent:@""]; + [windowMenu addItem:[NSMenuItem separatorItem]]; + [windowMenu addItemWithTitle:@"Bring All to Front" + action:@selector(arrangeInFront:) + keyEquivalent:@""]; - // TODO: Make this appear at the bottom of the menu (for consistency) - [windowMenu addItem:[NSMenuItem separatorItem]]; - [[windowMenu addItemWithTitle:@"Enter Full Screen" - action:@selector(toggleFullScreen:) - keyEquivalent:@"f"] - setKeyEquivalentModifierMask:NSEventModifierFlagControl | NSEventModifierFlagCommand]; + // TODO: Make this appear at the bottom of the menu (for consistency) + [windowMenu addItem:[NSMenuItem separatorItem]]; + [[windowMenu addItemWithTitle:@"Enter Full Screen" + action:@selector(toggleFullScreen:) + keyEquivalent:@"f"] + setKeyEquivalentModifierMask:NSEventModifierFlagControl | + NSEventModifierFlagCommand]; - // Prior to Snow Leopard, we need to use this oddly-named semi-private API - // to get the application menu working properly. - SEL setAppleMenuSelector = NSSelectorFromString(@"setAppleMenu:"); - [NSApp performSelector:setAppleMenuSelector withObject:appMenu]; + // Prior to Snow Leopard, we need to use this oddly-named semi-private API + // to get the application menu working properly. + SEL setAppleMenuSelector = NSSelectorFromString(@"setAppleMenu:"); + [NSApp performSelector:setAppleMenuSelector withObject:appMenu]; } // Create key code translation tables // -static void createKeyTables(void) -{ - memset(_glfw.ns.keycodes, -1, sizeof(_glfw.ns.keycodes)); - memset(_glfw.ns.scancodes, -1, sizeof(_glfw.ns.scancodes)); +static void createKeyTables(void) { + memset(_glfw.ns.keycodes, -1, sizeof(_glfw.ns.keycodes)); + memset(_glfw.ns.scancodes, -1, sizeof(_glfw.ns.scancodes)); - _glfw.ns.keycodes[0x1D] = GLFW_KEY_0; - _glfw.ns.keycodes[0x12] = GLFW_KEY_1; - _glfw.ns.keycodes[0x13] = GLFW_KEY_2; - _glfw.ns.keycodes[0x14] = GLFW_KEY_3; - _glfw.ns.keycodes[0x15] = GLFW_KEY_4; - _glfw.ns.keycodes[0x17] = GLFW_KEY_5; - _glfw.ns.keycodes[0x16] = GLFW_KEY_6; - _glfw.ns.keycodes[0x1A] = GLFW_KEY_7; - _glfw.ns.keycodes[0x1C] = GLFW_KEY_8; - _glfw.ns.keycodes[0x19] = GLFW_KEY_9; - _glfw.ns.keycodes[0x00] = GLFW_KEY_A; - _glfw.ns.keycodes[0x0B] = GLFW_KEY_B; - _glfw.ns.keycodes[0x08] = GLFW_KEY_C; - _glfw.ns.keycodes[0x02] = GLFW_KEY_D; - _glfw.ns.keycodes[0x0E] = GLFW_KEY_E; - _glfw.ns.keycodes[0x03] = GLFW_KEY_F; - _glfw.ns.keycodes[0x05] = GLFW_KEY_G; - _glfw.ns.keycodes[0x04] = GLFW_KEY_H; - _glfw.ns.keycodes[0x22] = GLFW_KEY_I; - _glfw.ns.keycodes[0x26] = GLFW_KEY_J; - _glfw.ns.keycodes[0x28] = GLFW_KEY_K; - _glfw.ns.keycodes[0x25] = GLFW_KEY_L; - _glfw.ns.keycodes[0x2E] = GLFW_KEY_M; - _glfw.ns.keycodes[0x2D] = GLFW_KEY_N; - _glfw.ns.keycodes[0x1F] = GLFW_KEY_O; - _glfw.ns.keycodes[0x23] = GLFW_KEY_P; - _glfw.ns.keycodes[0x0C] = GLFW_KEY_Q; - _glfw.ns.keycodes[0x0F] = GLFW_KEY_R; - _glfw.ns.keycodes[0x01] = GLFW_KEY_S; - _glfw.ns.keycodes[0x11] = GLFW_KEY_T; - _glfw.ns.keycodes[0x20] = GLFW_KEY_U; - _glfw.ns.keycodes[0x09] = GLFW_KEY_V; - _glfw.ns.keycodes[0x0D] = GLFW_KEY_W; - _glfw.ns.keycodes[0x07] = GLFW_KEY_X; - _glfw.ns.keycodes[0x10] = GLFW_KEY_Y; - _glfw.ns.keycodes[0x06] = GLFW_KEY_Z; + _glfw.ns.keycodes[0x1D] = GLFW_KEY_0; + _glfw.ns.keycodes[0x12] = GLFW_KEY_1; + _glfw.ns.keycodes[0x13] = GLFW_KEY_2; + _glfw.ns.keycodes[0x14] = GLFW_KEY_3; + _glfw.ns.keycodes[0x15] = GLFW_KEY_4; + _glfw.ns.keycodes[0x17] = GLFW_KEY_5; + _glfw.ns.keycodes[0x16] = GLFW_KEY_6; + _glfw.ns.keycodes[0x1A] = GLFW_KEY_7; + _glfw.ns.keycodes[0x1C] = GLFW_KEY_8; + _glfw.ns.keycodes[0x19] = GLFW_KEY_9; + _glfw.ns.keycodes[0x00] = GLFW_KEY_A; + _glfw.ns.keycodes[0x0B] = GLFW_KEY_B; + _glfw.ns.keycodes[0x08] = GLFW_KEY_C; + _glfw.ns.keycodes[0x02] = GLFW_KEY_D; + _glfw.ns.keycodes[0x0E] = GLFW_KEY_E; + _glfw.ns.keycodes[0x03] = GLFW_KEY_F; + _glfw.ns.keycodes[0x05] = GLFW_KEY_G; + _glfw.ns.keycodes[0x04] = GLFW_KEY_H; + _glfw.ns.keycodes[0x22] = GLFW_KEY_I; + _glfw.ns.keycodes[0x26] = GLFW_KEY_J; + _glfw.ns.keycodes[0x28] = GLFW_KEY_K; + _glfw.ns.keycodes[0x25] = GLFW_KEY_L; + _glfw.ns.keycodes[0x2E] = GLFW_KEY_M; + _glfw.ns.keycodes[0x2D] = GLFW_KEY_N; + _glfw.ns.keycodes[0x1F] = GLFW_KEY_O; + _glfw.ns.keycodes[0x23] = GLFW_KEY_P; + _glfw.ns.keycodes[0x0C] = GLFW_KEY_Q; + _glfw.ns.keycodes[0x0F] = GLFW_KEY_R; + _glfw.ns.keycodes[0x01] = GLFW_KEY_S; + _glfw.ns.keycodes[0x11] = GLFW_KEY_T; + _glfw.ns.keycodes[0x20] = GLFW_KEY_U; + _glfw.ns.keycodes[0x09] = GLFW_KEY_V; + _glfw.ns.keycodes[0x0D] = GLFW_KEY_W; + _glfw.ns.keycodes[0x07] = GLFW_KEY_X; + _glfw.ns.keycodes[0x10] = GLFW_KEY_Y; + _glfw.ns.keycodes[0x06] = GLFW_KEY_Z; - _glfw.ns.keycodes[0x27] = GLFW_KEY_APOSTROPHE; - _glfw.ns.keycodes[0x2A] = GLFW_KEY_BACKSLASH; - _glfw.ns.keycodes[0x2B] = GLFW_KEY_COMMA; - _glfw.ns.keycodes[0x18] = GLFW_KEY_EQUAL; - _glfw.ns.keycodes[0x32] = GLFW_KEY_GRAVE_ACCENT; - _glfw.ns.keycodes[0x21] = GLFW_KEY_LEFT_BRACKET; - _glfw.ns.keycodes[0x1B] = GLFW_KEY_MINUS; - _glfw.ns.keycodes[0x2F] = GLFW_KEY_PERIOD; - _glfw.ns.keycodes[0x1E] = GLFW_KEY_RIGHT_BRACKET; - _glfw.ns.keycodes[0x29] = GLFW_KEY_SEMICOLON; - _glfw.ns.keycodes[0x2C] = GLFW_KEY_SLASH; - _glfw.ns.keycodes[0x0A] = GLFW_KEY_WORLD_1; + _glfw.ns.keycodes[0x27] = GLFW_KEY_APOSTROPHE; + _glfw.ns.keycodes[0x2A] = GLFW_KEY_BACKSLASH; + _glfw.ns.keycodes[0x2B] = GLFW_KEY_COMMA; + _glfw.ns.keycodes[0x18] = GLFW_KEY_EQUAL; + _glfw.ns.keycodes[0x32] = GLFW_KEY_GRAVE_ACCENT; + _glfw.ns.keycodes[0x21] = GLFW_KEY_LEFT_BRACKET; + _glfw.ns.keycodes[0x1B] = GLFW_KEY_MINUS; + _glfw.ns.keycodes[0x2F] = GLFW_KEY_PERIOD; + _glfw.ns.keycodes[0x1E] = GLFW_KEY_RIGHT_BRACKET; + _glfw.ns.keycodes[0x29] = GLFW_KEY_SEMICOLON; + _glfw.ns.keycodes[0x2C] = GLFW_KEY_SLASH; + _glfw.ns.keycodes[0x0A] = GLFW_KEY_WORLD_1; - _glfw.ns.keycodes[0x33] = GLFW_KEY_BACKSPACE; - _glfw.ns.keycodes[0x39] = GLFW_KEY_CAPS_LOCK; - _glfw.ns.keycodes[0x75] = GLFW_KEY_DELETE; - _glfw.ns.keycodes[0x7D] = GLFW_KEY_DOWN; - _glfw.ns.keycodes[0x77] = GLFW_KEY_END; - _glfw.ns.keycodes[0x24] = GLFW_KEY_ENTER; - _glfw.ns.keycodes[0x35] = GLFW_KEY_ESCAPE; - _glfw.ns.keycodes[0x7A] = GLFW_KEY_F1; - _glfw.ns.keycodes[0x78] = GLFW_KEY_F2; - _glfw.ns.keycodes[0x63] = GLFW_KEY_F3; - _glfw.ns.keycodes[0x76] = GLFW_KEY_F4; - _glfw.ns.keycodes[0x60] = GLFW_KEY_F5; - _glfw.ns.keycodes[0x61] = GLFW_KEY_F6; - _glfw.ns.keycodes[0x62] = GLFW_KEY_F7; - _glfw.ns.keycodes[0x64] = GLFW_KEY_F8; - _glfw.ns.keycodes[0x65] = GLFW_KEY_F9; - _glfw.ns.keycodes[0x6D] = GLFW_KEY_F10; - _glfw.ns.keycodes[0x67] = GLFW_KEY_F11; - _glfw.ns.keycodes[0x6F] = GLFW_KEY_F12; - _glfw.ns.keycodes[0x69] = GLFW_KEY_PRINT_SCREEN; - _glfw.ns.keycodes[0x6B] = GLFW_KEY_F14; - _glfw.ns.keycodes[0x71] = GLFW_KEY_F15; - _glfw.ns.keycodes[0x6A] = GLFW_KEY_F16; - _glfw.ns.keycodes[0x40] = GLFW_KEY_F17; - _glfw.ns.keycodes[0x4F] = GLFW_KEY_F18; - _glfw.ns.keycodes[0x50] = GLFW_KEY_F19; - _glfw.ns.keycodes[0x5A] = GLFW_KEY_F20; - _glfw.ns.keycodes[0x73] = GLFW_KEY_HOME; - _glfw.ns.keycodes[0x72] = GLFW_KEY_INSERT; - _glfw.ns.keycodes[0x7B] = GLFW_KEY_LEFT; - _glfw.ns.keycodes[0x3A] = GLFW_KEY_LEFT_ALT; - _glfw.ns.keycodes[0x3B] = GLFW_KEY_LEFT_CONTROL; - _glfw.ns.keycodes[0x38] = GLFW_KEY_LEFT_SHIFT; - _glfw.ns.keycodes[0x37] = GLFW_KEY_LEFT_SUPER; - _glfw.ns.keycodes[0x6E] = GLFW_KEY_MENU; - _glfw.ns.keycodes[0x47] = GLFW_KEY_NUM_LOCK; - _glfw.ns.keycodes[0x79] = GLFW_KEY_PAGE_DOWN; - _glfw.ns.keycodes[0x74] = GLFW_KEY_PAGE_UP; - _glfw.ns.keycodes[0x7C] = GLFW_KEY_RIGHT; - _glfw.ns.keycodes[0x3D] = GLFW_KEY_RIGHT_ALT; - _glfw.ns.keycodes[0x3E] = GLFW_KEY_RIGHT_CONTROL; - _glfw.ns.keycodes[0x3C] = GLFW_KEY_RIGHT_SHIFT; - _glfw.ns.keycodes[0x36] = GLFW_KEY_RIGHT_SUPER; - _glfw.ns.keycodes[0x31] = GLFW_KEY_SPACE; - _glfw.ns.keycodes[0x30] = GLFW_KEY_TAB; - _glfw.ns.keycodes[0x7E] = GLFW_KEY_UP; + _glfw.ns.keycodes[0x33] = GLFW_KEY_BACKSPACE; + _glfw.ns.keycodes[0x39] = GLFW_KEY_CAPS_LOCK; + _glfw.ns.keycodes[0x75] = GLFW_KEY_DELETE; + _glfw.ns.keycodes[0x7D] = GLFW_KEY_DOWN; + _glfw.ns.keycodes[0x77] = GLFW_KEY_END; + _glfw.ns.keycodes[0x24] = GLFW_KEY_ENTER; + _glfw.ns.keycodes[0x35] = GLFW_KEY_ESCAPE; + _glfw.ns.keycodes[0x7A] = GLFW_KEY_F1; + _glfw.ns.keycodes[0x78] = GLFW_KEY_F2; + _glfw.ns.keycodes[0x63] = GLFW_KEY_F3; + _glfw.ns.keycodes[0x76] = GLFW_KEY_F4; + _glfw.ns.keycodes[0x60] = GLFW_KEY_F5; + _glfw.ns.keycodes[0x61] = GLFW_KEY_F6; + _glfw.ns.keycodes[0x62] = GLFW_KEY_F7; + _glfw.ns.keycodes[0x64] = GLFW_KEY_F8; + _glfw.ns.keycodes[0x65] = GLFW_KEY_F9; + _glfw.ns.keycodes[0x6D] = GLFW_KEY_F10; + _glfw.ns.keycodes[0x67] = GLFW_KEY_F11; + _glfw.ns.keycodes[0x6F] = GLFW_KEY_F12; + _glfw.ns.keycodes[0x69] = GLFW_KEY_PRINT_SCREEN; + _glfw.ns.keycodes[0x6B] = GLFW_KEY_F14; + _glfw.ns.keycodes[0x71] = GLFW_KEY_F15; + _glfw.ns.keycodes[0x6A] = GLFW_KEY_F16; + _glfw.ns.keycodes[0x40] = GLFW_KEY_F17; + _glfw.ns.keycodes[0x4F] = GLFW_KEY_F18; + _glfw.ns.keycodes[0x50] = GLFW_KEY_F19; + _glfw.ns.keycodes[0x5A] = GLFW_KEY_F20; + _glfw.ns.keycodes[0x73] = GLFW_KEY_HOME; + _glfw.ns.keycodes[0x72] = GLFW_KEY_INSERT; + _glfw.ns.keycodes[0x7B] = GLFW_KEY_LEFT; + _glfw.ns.keycodes[0x3A] = GLFW_KEY_LEFT_ALT; + _glfw.ns.keycodes[0x3B] = GLFW_KEY_LEFT_CONTROL; + _glfw.ns.keycodes[0x38] = GLFW_KEY_LEFT_SHIFT; + _glfw.ns.keycodes[0x37] = GLFW_KEY_LEFT_SUPER; + _glfw.ns.keycodes[0x6E] = GLFW_KEY_MENU; + _glfw.ns.keycodes[0x47] = GLFW_KEY_NUM_LOCK; + _glfw.ns.keycodes[0x79] = GLFW_KEY_PAGE_DOWN; + _glfw.ns.keycodes[0x74] = GLFW_KEY_PAGE_UP; + _glfw.ns.keycodes[0x7C] = GLFW_KEY_RIGHT; + _glfw.ns.keycodes[0x3D] = GLFW_KEY_RIGHT_ALT; + _glfw.ns.keycodes[0x3E] = GLFW_KEY_RIGHT_CONTROL; + _glfw.ns.keycodes[0x3C] = GLFW_KEY_RIGHT_SHIFT; + _glfw.ns.keycodes[0x36] = GLFW_KEY_RIGHT_SUPER; + _glfw.ns.keycodes[0x31] = GLFW_KEY_SPACE; + _glfw.ns.keycodes[0x30] = GLFW_KEY_TAB; + _glfw.ns.keycodes[0x7E] = GLFW_KEY_UP; - _glfw.ns.keycodes[0x52] = GLFW_KEY_KP_0; - _glfw.ns.keycodes[0x53] = GLFW_KEY_KP_1; - _glfw.ns.keycodes[0x54] = GLFW_KEY_KP_2; - _glfw.ns.keycodes[0x55] = GLFW_KEY_KP_3; - _glfw.ns.keycodes[0x56] = GLFW_KEY_KP_4; - _glfw.ns.keycodes[0x57] = GLFW_KEY_KP_5; - _glfw.ns.keycodes[0x58] = GLFW_KEY_KP_6; - _glfw.ns.keycodes[0x59] = GLFW_KEY_KP_7; - _glfw.ns.keycodes[0x5B] = GLFW_KEY_KP_8; - _glfw.ns.keycodes[0x5C] = GLFW_KEY_KP_9; - _glfw.ns.keycodes[0x45] = GLFW_KEY_KP_ADD; - _glfw.ns.keycodes[0x41] = GLFW_KEY_KP_DECIMAL; - _glfw.ns.keycodes[0x4B] = GLFW_KEY_KP_DIVIDE; - _glfw.ns.keycodes[0x4C] = GLFW_KEY_KP_ENTER; - _glfw.ns.keycodes[0x51] = GLFW_KEY_KP_EQUAL; - _glfw.ns.keycodes[0x43] = GLFW_KEY_KP_MULTIPLY; - _glfw.ns.keycodes[0x4E] = GLFW_KEY_KP_SUBTRACT; + _glfw.ns.keycodes[0x52] = GLFW_KEY_KP_0; + _glfw.ns.keycodes[0x53] = GLFW_KEY_KP_1; + _glfw.ns.keycodes[0x54] = GLFW_KEY_KP_2; + _glfw.ns.keycodes[0x55] = GLFW_KEY_KP_3; + _glfw.ns.keycodes[0x56] = GLFW_KEY_KP_4; + _glfw.ns.keycodes[0x57] = GLFW_KEY_KP_5; + _glfw.ns.keycodes[0x58] = GLFW_KEY_KP_6; + _glfw.ns.keycodes[0x59] = GLFW_KEY_KP_7; + _glfw.ns.keycodes[0x5B] = GLFW_KEY_KP_8; + _glfw.ns.keycodes[0x5C] = GLFW_KEY_KP_9; + _glfw.ns.keycodes[0x45] = GLFW_KEY_KP_ADD; + _glfw.ns.keycodes[0x41] = GLFW_KEY_KP_DECIMAL; + _glfw.ns.keycodes[0x4B] = GLFW_KEY_KP_DIVIDE; + _glfw.ns.keycodes[0x4C] = GLFW_KEY_KP_ENTER; + _glfw.ns.keycodes[0x51] = GLFW_KEY_KP_EQUAL; + _glfw.ns.keycodes[0x43] = GLFW_KEY_KP_MULTIPLY; + _glfw.ns.keycodes[0x4E] = GLFW_KEY_KP_SUBTRACT; - for (int scancode = 0; scancode < 256; scancode++) - { - // Store the reverse translation for faster key name lookup - if (_glfw.ns.keycodes[scancode] >= 0) - _glfw.ns.scancodes[_glfw.ns.keycodes[scancode]] = scancode; - } + for (int scancode = 0; scancode < 256; scancode++) { + // Store the reverse translation for faster key name lookup + if (_glfw.ns.keycodes[scancode] >= 0) + _glfw.ns.scancodes[_glfw.ns.keycodes[scancode]] = scancode; + } } // Retrieve Unicode data for the current keyboard layout // -static GLFWbool updateUnicodeData(void) -{ - if (_glfw.ns.inputSource) - { - CFRelease(_glfw.ns.inputSource); - _glfw.ns.inputSource = NULL; - _glfw.ns.unicodeData = nil; - } +static GLFWbool updateUnicodeData(void) { + if (_glfw.ns.inputSource) { + CFRelease(_glfw.ns.inputSource); + _glfw.ns.inputSource = NULL; + _glfw.ns.unicodeData = nil; + } - _glfw.ns.inputSource = TISCopyCurrentKeyboardLayoutInputSource(); - if (!_glfw.ns.inputSource) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Cocoa: Failed to retrieve keyboard layout input source"); - return GLFW_FALSE; - } + _glfw.ns.inputSource = TISCopyCurrentKeyboardLayoutInputSource(); + if (!_glfw.ns.inputSource) { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Cocoa: Failed to retrieve keyboard layout input source"); + return GLFW_FALSE; + } - _glfw.ns.unicodeData = - TISGetInputSourceProperty(_glfw.ns.inputSource, - kTISPropertyUnicodeKeyLayoutData); - if (!_glfw.ns.unicodeData) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Cocoa: Failed to retrieve keyboard layout Unicode data"); - return GLFW_FALSE; - } + _glfw.ns.unicodeData = TISGetInputSourceProperty( + _glfw.ns.inputSource, kTISPropertyUnicodeKeyLayoutData); + if (!_glfw.ns.unicodeData) { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Cocoa: Failed to retrieve keyboard layout Unicode data"); + return GLFW_FALSE; + } - return GLFW_TRUE; + return GLFW_TRUE; } // Load HIToolbox.framework and the TIS symbols we need from it // -static GLFWbool initializeTIS(void) -{ - // This works only because Cocoa has already loaded it properly - _glfw.ns.tis.bundle = - CFBundleGetBundleWithIdentifier(CFSTR("com.apple.HIToolbox")); - if (!_glfw.ns.tis.bundle) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Cocoa: Failed to load HIToolbox.framework"); - return GLFW_FALSE; - } +static GLFWbool initializeTIS(void) { + // This works only because Cocoa has already loaded it properly + _glfw.ns.tis.bundle = + CFBundleGetBundleWithIdentifier(CFSTR("com.apple.HIToolbox")); + if (!_glfw.ns.tis.bundle) { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Cocoa: Failed to load HIToolbox.framework"); + return GLFW_FALSE; + } - CFStringRef* kPropertyUnicodeKeyLayoutData = - CFBundleGetDataPointerForName(_glfw.ns.tis.bundle, - CFSTR("kTISPropertyUnicodeKeyLayoutData")); - _glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource = - CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle, - CFSTR("TISCopyCurrentKeyboardLayoutInputSource")); - _glfw.ns.tis.GetInputSourceProperty = - CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle, - CFSTR("TISGetInputSourceProperty")); - _glfw.ns.tis.GetKbdType = - CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle, - CFSTR("LMGetKbdType")); + CFStringRef *kPropertyUnicodeKeyLayoutData = CFBundleGetDataPointerForName( + _glfw.ns.tis.bundle, CFSTR("kTISPropertyUnicodeKeyLayoutData")); + _glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource = + CFBundleGetFunctionPointerForName( + _glfw.ns.tis.bundle, + CFSTR("TISCopyCurrentKeyboardLayoutInputSource")); + _glfw.ns.tis.GetInputSourceProperty = CFBundleGetFunctionPointerForName( + _glfw.ns.tis.bundle, CFSTR("TISGetInputSourceProperty")); + _glfw.ns.tis.GetKbdType = CFBundleGetFunctionPointerForName( + _glfw.ns.tis.bundle, CFSTR("LMGetKbdType")); - if (!kPropertyUnicodeKeyLayoutData || - !TISCopyCurrentKeyboardLayoutInputSource || - !TISGetInputSourceProperty || - !LMGetKbdType) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Cocoa: Failed to load TIS API symbols"); - return GLFW_FALSE; - } + if (!kPropertyUnicodeKeyLayoutData || + !TISCopyCurrentKeyboardLayoutInputSource || !TISGetInputSourceProperty || + !LMGetKbdType) { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Cocoa: Failed to load TIS API symbols"); + return GLFW_FALSE; + } - _glfw.ns.tis.kPropertyUnicodeKeyLayoutData = - *kPropertyUnicodeKeyLayoutData; + _glfw.ns.tis.kPropertyUnicodeKeyLayoutData = *kPropertyUnicodeKeyLayoutData; - return updateUnicodeData(); + return updateUnicodeData(); } @interface GLFWHelper : NSObject @@ -385,13 +366,11 @@ static GLFWbool initializeTIS(void) @implementation GLFWHelper -- (void)selectedKeyboardInputSourceChanged:(NSObject* )object -{ - updateUnicodeData(); +- (void)selectedKeyboardInputSourceChanged:(NSObject *)object { + updateUnicodeData(); } -- (void)doNothing:(id)object -{ +- (void)doNothing:(id)object { } @end // GLFWHelper @@ -401,173 +380,163 @@ static GLFWbool initializeTIS(void) @implementation GLFWApplicationDelegate -- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender -{ - for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next) - _glfwInputWindowCloseRequest(window); +- (NSApplicationTerminateReply)applicationShouldTerminate: + (NSApplication *)sender { + for (_GLFWwindow *window = _glfw.windowListHead; window; + window = window->next) + _glfwInputWindowCloseRequest(window); - return NSTerminateCancel; + return NSTerminateCancel; } -- (void)applicationDidChangeScreenParameters:(NSNotification *) notification -{ - for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next) - { - if (window->context.client != GLFW_NO_API) - [window->context.nsgl.object update]; - } +- (void)applicationDidChangeScreenParameters:(NSNotification *)notification { + for (_GLFWwindow *window = _glfw.windowListHead; window; + window = window->next) { + if (window->context.client != GLFW_NO_API) + [window->context.nsgl.object update]; + } - _glfwPollMonitorsCocoa(); + _glfwPollMonitorsCocoa(); } -- (void)applicationWillFinishLaunching:(NSNotification *)notification -{ - if (_glfw.hints.init.ns.menubar) - { - // Menu bar setup must go between sharedApplication and finishLaunching - // in order to properly emulate the behavior of NSApplicationMain +- (void)applicationWillFinishLaunching:(NSNotification *)notification { + if (_glfw.hints.init.ns.menubar) { + // Menu bar setup must go between sharedApplication and finishLaunching + // in order to properly emulate the behavior of NSApplicationMain - if ([[NSBundle mainBundle] pathForResource:@"MainMenu" ofType:@"nib"]) - { - [[NSBundle mainBundle] loadNibNamed:@"MainMenu" - owner:NSApp - topLevelObjects:&_glfw.ns.nibObjects]; - } - else - createMenuBar(); - } + if ([[NSBundle mainBundle] pathForResource:@"MainMenu" ofType:@"nib"]) { + [[NSBundle mainBundle] loadNibNamed:@"MainMenu" + owner:NSApp + topLevelObjects:&_glfw.ns.nibObjects]; + } else + createMenuBar(); + } } -- (void)applicationDidFinishLaunching:(NSNotification *)notification -{ - _glfwPostEmptyEventCocoa(); - [NSApp stop:nil]; +- (void)applicationDidFinishLaunching:(NSNotification *)notification { + _glfwPostEmptyEventCocoa(); + [NSApp stop:nil]; } -- (void)applicationDidHide:(NSNotification *)notification -{ - for (int i = 0; i < _glfw.monitorCount; i++) - _glfwRestoreVideoModeCocoa(_glfw.monitors[i]); +- (void)applicationDidHide:(NSNotification *)notification { + for (int i = 0; i < _glfw.monitorCount; i++) + _glfwRestoreVideoModeCocoa(_glfw.monitors[i]); } @end // GLFWApplicationDelegate - ////////////////////////////////////////////////////////////////////////// ////// GLFW internal API ////// ////////////////////////////////////////////////////////////////////////// -void* _glfwLoadLocalVulkanLoaderCocoa(void) -{ - CFBundleRef bundle = CFBundleGetMainBundle(); - if (!bundle) - return NULL; +void *_glfwLoadLocalVulkanLoaderCocoa(void) { + CFBundleRef bundle = CFBundleGetMainBundle(); + if (!bundle) + return NULL; - CFURLRef frameworksUrl = CFBundleCopyPrivateFrameworksURL(bundle); - if (!frameworksUrl) - return NULL; + CFURLRef frameworksUrl = CFBundleCopyPrivateFrameworksURL(bundle); + if (!frameworksUrl) + return NULL; - CFURLRef loaderUrl = CFURLCreateCopyAppendingPathComponent( - kCFAllocatorDefault, frameworksUrl, CFSTR("libvulkan.1.dylib"), false); - if (!loaderUrl) - { - CFRelease(frameworksUrl); - return NULL; - } - - char path[PATH_MAX]; - void* handle = NULL; - - if (CFURLGetFileSystemRepresentation(loaderUrl, true, (UInt8*) path, sizeof(path) - 1)) - handle = _glfwPlatformLoadModule(path); - - CFRelease(loaderUrl); + CFURLRef loaderUrl = CFURLCreateCopyAppendingPathComponent( + kCFAllocatorDefault, frameworksUrl, CFSTR("libvulkan.1.dylib"), false); + if (!loaderUrl) { CFRelease(frameworksUrl); - return handle; -} + return NULL; + } + char path[PATH_MAX]; + void *handle = NULL; + + if (CFURLGetFileSystemRepresentation(loaderUrl, true, (UInt8 *)path, + sizeof(path) - 1)) + handle = _glfwPlatformLoadModule(path); + + CFRelease(loaderUrl); + CFRelease(frameworksUrl); + return handle; +} ////////////////////////////////////////////////////////////////////////// ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform) -{ - const _GLFWplatform cocoa = - { - GLFW_PLATFORM_COCOA, - _glfwInitCocoa, - _glfwTerminateCocoa, - _glfwGetCursorPosCocoa, - _glfwSetCursorPosCocoa, - _glfwSetCursorModeCocoa, - _glfwSetRawMouseMotionCocoa, - _glfwRawMouseMotionSupportedCocoa, - _glfwCreateCursorCocoa, - _glfwCreateStandardCursorCocoa, - _glfwDestroyCursorCocoa, - _glfwSetCursorCocoa, - _glfwGetScancodeNameCocoa, - _glfwGetKeyScancodeCocoa, - _glfwSetClipboardStringCocoa, - _glfwGetClipboardStringCocoa, - _glfwInitJoysticksCocoa, - _glfwTerminateJoysticksCocoa, - _glfwPollJoystickCocoa, - _glfwGetMappingNameCocoa, - _glfwUpdateGamepadGUIDCocoa, - _glfwFreeMonitorCocoa, - _glfwGetMonitorPosCocoa, - _glfwGetMonitorContentScaleCocoa, - _glfwGetMonitorWorkareaCocoa, - _glfwGetVideoModesCocoa, - _glfwGetVideoModeCocoa, - _glfwGetGammaRampCocoa, - _glfwSetGammaRampCocoa, - _glfwCreateWindowCocoa, - _glfwDestroyWindowCocoa, - _glfwSetWindowTitleCocoa, - _glfwSetWindowIconCocoa, - _glfwGetWindowPosCocoa, - _glfwSetWindowPosCocoa, - _glfwGetWindowSizeCocoa, - _glfwSetWindowSizeCocoa, - _glfwSetWindowSizeLimitsCocoa, - _glfwSetWindowAspectRatioCocoa, - _glfwGetFramebufferSizeCocoa, - _glfwGetWindowFrameSizeCocoa, - _glfwGetWindowContentScaleCocoa, - _glfwIconifyWindowCocoa, - _glfwRestoreWindowCocoa, - _glfwMaximizeWindowCocoa, - _glfwShowWindowCocoa, - _glfwHideWindowCocoa, - _glfwRequestWindowAttentionCocoa, - _glfwFocusWindowCocoa, - _glfwSetWindowMonitorCocoa, - _glfwWindowFocusedCocoa, - _glfwWindowIconifiedCocoa, - _glfwWindowVisibleCocoa, - _glfwWindowMaximizedCocoa, - _glfwWindowHoveredCocoa, - _glfwFramebufferTransparentCocoa, - _glfwGetWindowOpacityCocoa, - _glfwSetWindowResizableCocoa, - _glfwSetWindowDecoratedCocoa, - _glfwSetWindowFloatingCocoa, - _glfwSetWindowOpacityCocoa, - _glfwSetWindowMousePassthroughCocoa, - _glfwPollEventsCocoa, - _glfwWaitEventsCocoa, - _glfwWaitEventsTimeoutCocoa, - _glfwPostEmptyEventCocoa, - _glfwGetEGLPlatformCocoa, - _glfwGetEGLNativeDisplayCocoa, - _glfwGetEGLNativeWindowCocoa, - _glfwGetRequiredInstanceExtensionsCocoa, - _glfwGetPhysicalDevicePresentationSupportCocoa, - _glfwCreateWindowSurfaceCocoa, - }; +GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform *platform) { + const _GLFWplatform cocoa = { + GLFW_PLATFORM_COCOA, + _glfwInitCocoa, + _glfwTerminateCocoa, + _glfwGetCursorPosCocoa, + _glfwSetCursorPosCocoa, + _glfwSetCursorModeCocoa, + _glfwSetRawMouseMotionCocoa, + _glfwRawMouseMotionSupportedCocoa, + _glfwCreateCursorCocoa, + _glfwCreateStandardCursorCocoa, + _glfwDestroyCursorCocoa, + _glfwSetCursorCocoa, + _glfwGetScancodeNameCocoa, + _glfwGetKeyScancodeCocoa, + _glfwSetClipboardStringCocoa, + _glfwGetClipboardStringCocoa, + _glfwInitJoysticksCocoa, + _glfwTerminateJoysticksCocoa, + _glfwPollJoystickCocoa, + _glfwGetMappingNameCocoa, + _glfwUpdateGamepadGUIDCocoa, + _glfwFreeMonitorCocoa, + _glfwGetMonitorPosCocoa, + _glfwGetMonitorContentScaleCocoa, + _glfwGetMonitorWorkareaCocoa, + _glfwGetVideoModesCocoa, + _glfwGetVideoModeCocoa, + _glfwGetGammaRampCocoa, + _glfwSetGammaRampCocoa, + _glfwCreateWindowCocoa, + _glfwDestroyWindowCocoa, + _glfwSetWindowTitleCocoa, + _glfwSetWindowIconCocoa, + _glfwGetWindowPosCocoa, + _glfwSetWindowPosCocoa, + _glfwGetWindowSizeCocoa, + _glfwSetWindowSizeCocoa, + _glfwSetWindowSizeLimitsCocoa, + _glfwSetWindowAspectRatioCocoa, + _glfwGetFramebufferSizeCocoa, + _glfwGetWindowFrameSizeCocoa, + _glfwGetWindowContentScaleCocoa, + _glfwIconifyWindowCocoa, + _glfwRestoreWindowCocoa, + _glfwMaximizeWindowCocoa, + _glfwShowWindowCocoa, + _glfwHideWindowCocoa, + _glfwRequestWindowAttentionCocoa, + _glfwFocusWindowCocoa, + _glfwSetWindowMonitorCocoa, + _glfwWindowFocusedCocoa, + _glfwWindowIconifiedCocoa, + _glfwWindowVisibleCocoa, + _glfwWindowMaximizedCocoa, + _glfwWindowHoveredCocoa, + _glfwFramebufferTransparentCocoa, + _glfwGetWindowOpacityCocoa, + _glfwSetWindowResizableCocoa, + _glfwSetWindowDecoratedCocoa, + _glfwSetWindowTitlebarCocoa, + _glfwSetWindowFloatingCocoa, + _glfwSetWindowOpacityCocoa, + _glfwSetWindowMousePassthroughCocoa, + _glfwPollEventsCocoa, + _glfwWaitEventsCocoa, + _glfwWaitEventsTimeoutCocoa, + _glfwPostEmptyEventCocoa, + _glfwGetEGLPlatformCocoa, + _glfwGetEGLNativeDisplayCocoa, + _glfwGetEGLNativeWindowCocoa, + _glfwGetRequiredInstanceExtensionsCocoa, + _glfwGetPhysicalDevicePresentationSupportCocoa, + _glfwCreateWindowSurfaceCocoa, + }; *platform = cocoa; return GLFW_TRUE; @@ -608,10 +577,10 @@ int _glfwInitCocoa(void) handler:block]; if (_glfw.hints.init.ns.chdir) - changeToResourcesDirectory(); + changeToResourcesDirectory(); // Press and Hold prevents some keys from emitting repeated characters - NSDictionary* defaults = @{@"ApplePressAndHoldEnabled":@NO}; + NSDictionary *defaults = @{@"ApplePressAndHoldEnabled" : @NO}; [[NSUserDefaults standardUserDefaults] registerDefaults:defaults]; [[NSNotificationCenter defaultCenter] @@ -622,67 +591,63 @@ int _glfwInitCocoa(void) createKeyTables(); - _glfw.ns.eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState); + _glfw.ns.eventSource = + CGEventSourceCreate(kCGEventSourceStateHIDSystemState); if (!_glfw.ns.eventSource) - return GLFW_FALSE; + return GLFW_FALSE; CGEventSourceSetLocalEventsSuppressionInterval(_glfw.ns.eventSource, 0.0); if (!initializeTIS()) - return GLFW_FALSE; + return GLFW_FALSE; _glfwPollMonitorsCocoa(); if (![[NSRunningApplication currentApplication] isFinishedLaunching]) - [NSApp run]; + [NSApp run]; // In case we are unbundled, make us a proper UI application if (_glfw.hints.init.ns.menubar) - [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; + [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; return GLFW_TRUE; - } // autoreleasepool + } // autoreleasepool } -void _glfwTerminateCocoa(void) -{ - @autoreleasepool { +void _glfwTerminateCocoa(void) { + @autoreleasepool { - if (_glfw.ns.inputSource) - { - CFRelease(_glfw.ns.inputSource); - _glfw.ns.inputSource = NULL; - _glfw.ns.unicodeData = nil; + if (_glfw.ns.inputSource) { + CFRelease(_glfw.ns.inputSource); + _glfw.ns.inputSource = NULL; + _glfw.ns.unicodeData = nil; } - if (_glfw.ns.eventSource) - { - CFRelease(_glfw.ns.eventSource); - _glfw.ns.eventSource = NULL; + if (_glfw.ns.eventSource) { + CFRelease(_glfw.ns.eventSource); + _glfw.ns.eventSource = NULL; } - if (_glfw.ns.delegate) - { - [NSApp setDelegate:nil]; - [_glfw.ns.delegate release]; - _glfw.ns.delegate = nil; + if (_glfw.ns.delegate) { + [NSApp setDelegate:nil]; + [_glfw.ns.delegate release]; + _glfw.ns.delegate = nil; } - if (_glfw.ns.helper) - { - [[NSNotificationCenter defaultCenter] - removeObserver:_glfw.ns.helper - name:NSTextInputContextKeyboardSelectionDidChangeNotification - object:nil]; - [[NSNotificationCenter defaultCenter] - removeObserver:_glfw.ns.helper]; - [_glfw.ns.helper release]; - _glfw.ns.helper = nil; + if (_glfw.ns.helper) { + [[NSNotificationCenter defaultCenter] + removeObserver:_glfw.ns.helper + name: + NSTextInputContextKeyboardSelectionDidChangeNotification + object:nil]; + [[NSNotificationCenter defaultCenter] removeObserver:_glfw.ns.helper]; + [_glfw.ns.helper release]; + _glfw.ns.helper = nil; } if (_glfw.ns.keyUpMonitor) - [NSEvent removeMonitor:_glfw.ns.keyUpMonitor]; + [NSEvent removeMonitor:_glfw.ns.keyUpMonitor]; _glfw_free(_glfw.ns.clipboardString); @@ -690,8 +655,7 @@ void _glfwTerminateCocoa(void) _glfwTerminateEGL(); _glfwTerminateOSMesa(); - } // autoreleasepool + } // autoreleasepool } #endif // _GLFW_COCOA - diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 9f7d191d..215411b9 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -243,6 +243,7 @@ GLFWbool _glfwWindowHoveredCocoa(_GLFWwindow* window); GLFWbool _glfwFramebufferTransparentCocoa(_GLFWwindow* window); void _glfwSetWindowResizableCocoa(_GLFWwindow* window, GLFWbool enabled); void _glfwSetWindowDecoratedCocoa(_GLFWwindow* window, GLFWbool enabled); +void _glfwSetWindowTitlebarCocoa(_GLFWwindow* window, GLFWbool enabled); void _glfwSetWindowFloatingCocoa(_GLFWwindow* window, GLFWbool enabled); float _glfwGetWindowOpacityCocoa(_GLFWwindow* window); void _glfwSetWindowOpacityCocoa(_GLFWwindow* window, float opacity); diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 9d794940..216827b4 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -39,172 +39,150 @@ // Returns whether the cursor is in the content area of the specified window // -static GLFWbool cursorInContentArea(_GLFWwindow* window) -{ - const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream]; - return [window->ns.view mouse:pos inRect:[window->ns.view frame]]; +static GLFWbool cursorInContentArea(_GLFWwindow *window) { + const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream]; + return [window->ns.view mouse:pos inRect:[window->ns.view frame]]; } // Hides the cursor if not already hidden // -static void hideCursor(_GLFWwindow* window) -{ - if (!_glfw.ns.cursorHidden) - { - [NSCursor hide]; - _glfw.ns.cursorHidden = GLFW_TRUE; - } +static void hideCursor(_GLFWwindow *window) { + if (!_glfw.ns.cursorHidden) { + [NSCursor hide]; + _glfw.ns.cursorHidden = GLFW_TRUE; + } } // Shows the cursor if not already shown // -static void showCursor(_GLFWwindow* window) -{ - if (_glfw.ns.cursorHidden) - { - [NSCursor unhide]; - _glfw.ns.cursorHidden = GLFW_FALSE; - } +static void showCursor(_GLFWwindow *window) { + if (_glfw.ns.cursorHidden) { + [NSCursor unhide]; + _glfw.ns.cursorHidden = GLFW_FALSE; + } } // Updates the cursor image according to its cursor mode // -static void updateCursorImage(_GLFWwindow* window) -{ - if (window->cursorMode == GLFW_CURSOR_NORMAL) - { - showCursor(window); +static void updateCursorImage(_GLFWwindow *window) { + if (window->cursorMode == GLFW_CURSOR_NORMAL) { + showCursor(window); - if (window->cursor) - [(NSCursor*) window->cursor->ns.object set]; - else - [[NSCursor arrowCursor] set]; - } + if (window->cursor) + [(NSCursor *) window->cursor->ns.object set]; else - hideCursor(window); + [[NSCursor arrowCursor] set]; + } else + hideCursor(window); } // Apply chosen cursor mode to a focused window // -static void updateCursorMode(_GLFWwindow* window) -{ - if (window->cursorMode == GLFW_CURSOR_DISABLED) - { - _glfw.ns.disabledCursorWindow = window; - _glfwGetCursorPosCocoa(window, - &_glfw.ns.restoreCursorPosX, - &_glfw.ns.restoreCursorPosY); - _glfwCenterCursorInContentArea(window); - CGAssociateMouseAndMouseCursorPosition(false); - } - else if (_glfw.ns.disabledCursorWindow == window) - { - _glfw.ns.disabledCursorWindow = NULL; - _glfwSetCursorPosCocoa(window, - _glfw.ns.restoreCursorPosX, - _glfw.ns.restoreCursorPosY); - // NOTE: The matching CGAssociateMouseAndMouseCursorPosition call is - // made in _glfwSetCursorPosCocoa as part of a workaround - } +static void updateCursorMode(_GLFWwindow *window) { + if (window->cursorMode == GLFW_CURSOR_DISABLED) { + _glfw.ns.disabledCursorWindow = window; + _glfwGetCursorPosCocoa(window, &_glfw.ns.restoreCursorPosX, + &_glfw.ns.restoreCursorPosY); + _glfwCenterCursorInContentArea(window); + CGAssociateMouseAndMouseCursorPosition(false); + } else if (_glfw.ns.disabledCursorWindow == window) { + _glfw.ns.disabledCursorWindow = NULL; + _glfwSetCursorPosCocoa(window, _glfw.ns.restoreCursorPosX, + _glfw.ns.restoreCursorPosY); + // NOTE: The matching CGAssociateMouseAndMouseCursorPosition call is + // made in _glfwSetCursorPosCocoa as part of a workaround + } - if (cursorInContentArea(window)) - updateCursorImage(window); + if (cursorInContentArea(window)) + updateCursorImage(window); } // Make the specified window and its video mode active on its monitor // -static void acquireMonitor(_GLFWwindow* window) -{ - _glfwSetVideoModeCocoa(window->monitor, &window->videoMode); - const CGRect bounds = CGDisplayBounds(window->monitor->ns.displayID); - const NSRect frame = NSMakeRect(bounds.origin.x, - _glfwTransformYCocoa(bounds.origin.y + bounds.size.height - 1), - bounds.size.width, - bounds.size.height); +static void acquireMonitor(_GLFWwindow *window) { + _glfwSetVideoModeCocoa(window->monitor, &window->videoMode); + const CGRect bounds = CGDisplayBounds(window->monitor->ns.displayID); + const NSRect frame = + NSMakeRect(bounds.origin.x, + _glfwTransformYCocoa(bounds.origin.y + bounds.size.height - 1), + bounds.size.width, bounds.size.height); - [window->ns.object setFrame:frame display:YES]; + [window->ns.object setFrame:frame display:YES]; - _glfwInputMonitorWindow(window->monitor, window); + _glfwInputMonitorWindow(window->monitor, window); } // Remove the window and restore the original video mode // -static void releaseMonitor(_GLFWwindow* window) -{ - if (window->monitor->window != window) - return; +static void releaseMonitor(_GLFWwindow *window) { + if (window->monitor->window != window) + return; - _glfwInputMonitorWindow(window->monitor, NULL); - _glfwRestoreVideoModeCocoa(window->monitor); + _glfwInputMonitorWindow(window->monitor, NULL); + _glfwRestoreVideoModeCocoa(window->monitor); } // Translates macOS key modifiers into GLFW ones // -static int translateFlags(NSUInteger flags) -{ - int mods = 0; +static int translateFlags(NSUInteger flags) { + int mods = 0; - if (flags & NSEventModifierFlagShift) - mods |= GLFW_MOD_SHIFT; - if (flags & NSEventModifierFlagControl) - mods |= GLFW_MOD_CONTROL; - if (flags & NSEventModifierFlagOption) - mods |= GLFW_MOD_ALT; - if (flags & NSEventModifierFlagCommand) - mods |= GLFW_MOD_SUPER; - if (flags & NSEventModifierFlagCapsLock) - mods |= GLFW_MOD_CAPS_LOCK; + if (flags & NSEventModifierFlagShift) + mods |= GLFW_MOD_SHIFT; + if (flags & NSEventModifierFlagControl) + mods |= GLFW_MOD_CONTROL; + if (flags & NSEventModifierFlagOption) + mods |= GLFW_MOD_ALT; + if (flags & NSEventModifierFlagCommand) + mods |= GLFW_MOD_SUPER; + if (flags & NSEventModifierFlagCapsLock) + mods |= GLFW_MOD_CAPS_LOCK; - return mods; + return mods; } // Translates a macOS keycode to a GLFW keycode // -static int translateKey(unsigned int key) -{ - if (key >= sizeof(_glfw.ns.keycodes) / sizeof(_glfw.ns.keycodes[0])) - return GLFW_KEY_UNKNOWN; +static int translateKey(unsigned int key) { + if (key >= sizeof(_glfw.ns.keycodes) / sizeof(_glfw.ns.keycodes[0])) + return GLFW_KEY_UNKNOWN; - return _glfw.ns.keycodes[key]; + return _glfw.ns.keycodes[key]; } // Translate a GLFW keycode to a Cocoa modifier flag // -static NSUInteger translateKeyToModifierFlag(int key) -{ - switch (key) - { - case GLFW_KEY_LEFT_SHIFT: - case GLFW_KEY_RIGHT_SHIFT: - return NSEventModifierFlagShift; - case GLFW_KEY_LEFT_CONTROL: - case GLFW_KEY_RIGHT_CONTROL: - return NSEventModifierFlagControl; - case GLFW_KEY_LEFT_ALT: - case GLFW_KEY_RIGHT_ALT: - return NSEventModifierFlagOption; - case GLFW_KEY_LEFT_SUPER: - case GLFW_KEY_RIGHT_SUPER: - return NSEventModifierFlagCommand; - case GLFW_KEY_CAPS_LOCK: - return NSEventModifierFlagCapsLock; - } +static NSUInteger translateKeyToModifierFlag(int key) { + switch (key) { + case GLFW_KEY_LEFT_SHIFT: + case GLFW_KEY_RIGHT_SHIFT: + return NSEventModifierFlagShift; + case GLFW_KEY_LEFT_CONTROL: + case GLFW_KEY_RIGHT_CONTROL: + return NSEventModifierFlagControl; + case GLFW_KEY_LEFT_ALT: + case GLFW_KEY_RIGHT_ALT: + return NSEventModifierFlagOption; + case GLFW_KEY_LEFT_SUPER: + case GLFW_KEY_RIGHT_SUPER: + return NSEventModifierFlagCommand; + case GLFW_KEY_CAPS_LOCK: + return NSEventModifierFlagCapsLock; + } - return 0; + return 0; } // Defines a constant for empty ranges in NSTextInputClient // -static const NSRange kEmptyRange = { NSNotFound, 0 }; - +static const NSRange kEmptyRange = {NSNotFound, 0}; //------------------------------------------------------------------------ // Delegate for window related notifications //------------------------------------------------------------------------ -@interface GLFWWindowDelegate : NSObject -{ - _GLFWwindow* window; +@interface GLFWWindowDelegate : NSObject { + _GLFWwindow *window; } - (instancetype)initWithGlfwWindow:(_GLFWwindow *)initWindow; @@ -213,127 +191,109 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; @implementation GLFWWindowDelegate -- (instancetype)initWithGlfwWindow:(_GLFWwindow *)initWindow -{ - self = [super init]; - if (self != nil) - window = initWindow; +- (instancetype)initWithGlfwWindow:(_GLFWwindow *)initWindow { + self = [super init]; + if (self != nil) + window = initWindow; - return self; + return self; } -- (BOOL)windowShouldClose:(id)sender -{ - _glfwInputWindowCloseRequest(window); - return NO; +- (BOOL)windowShouldClose:(id)sender { + _glfwInputWindowCloseRequest(window); + return NO; } -- (void)windowDidResize:(NSNotification *)notification -{ - if (window->context.source == GLFW_NATIVE_CONTEXT_API) - [window->context.nsgl.object update]; +- (void)windowDidResize:(NSNotification *)notification { + if (window->context.source == GLFW_NATIVE_CONTEXT_API) + [window->context.nsgl.object update]; - if (_glfw.ns.disabledCursorWindow == window) - _glfwCenterCursorInContentArea(window); + if (_glfw.ns.disabledCursorWindow == window) + _glfwCenterCursorInContentArea(window); - const int maximized = [window->ns.object isZoomed]; - if (window->ns.maximized != maximized) - { - window->ns.maximized = maximized; - _glfwInputWindowMaximize(window, maximized); - } + const int maximized = [window->ns.object isZoomed]; + if (window->ns.maximized != maximized) { + window->ns.maximized = maximized; + _glfwInputWindowMaximize(window, maximized); + } - const NSRect contentRect = [window->ns.view frame]; - const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect]; + const NSRect contentRect = [window->ns.view frame]; + const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect]; - if (fbRect.size.width != window->ns.fbWidth || - fbRect.size.height != window->ns.fbHeight) - { - window->ns.fbWidth = fbRect.size.width; - window->ns.fbHeight = fbRect.size.height; - _glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height); - } + if (fbRect.size.width != window->ns.fbWidth || + fbRect.size.height != window->ns.fbHeight) { + window->ns.fbWidth = fbRect.size.width; + window->ns.fbHeight = fbRect.size.height; + _glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height); + } - if (contentRect.size.width != window->ns.width || - contentRect.size.height != window->ns.height) - { - window->ns.width = contentRect.size.width; - window->ns.height = contentRect.size.height; - _glfwInputWindowSize(window, contentRect.size.width, contentRect.size.height); - } + if (contentRect.size.width != window->ns.width || + contentRect.size.height != window->ns.height) { + window->ns.width = contentRect.size.width; + window->ns.height = contentRect.size.height; + _glfwInputWindowSize(window, contentRect.size.width, + contentRect.size.height); + } } -- (void)windowDidMove:(NSNotification *)notification -{ - if (window->context.source == GLFW_NATIVE_CONTEXT_API) - [window->context.nsgl.object update]; +- (void)windowDidMove:(NSNotification *)notification { + if (window->context.source == GLFW_NATIVE_CONTEXT_API) + [window->context.nsgl.object update]; - if (_glfw.ns.disabledCursorWindow == window) - _glfwCenterCursorInContentArea(window); + if (_glfw.ns.disabledCursorWindow == window) + _glfwCenterCursorInContentArea(window); - int x, y; - _glfwGetWindowPosCocoa(window, &x, &y); - _glfwInputWindowPos(window, x, y); + int x, y; + _glfwGetWindowPosCocoa(window, &x, &y); + _glfwInputWindowPos(window, x, y); } -- (void)windowDidMiniaturize:(NSNotification *)notification -{ - if (window->monitor) - releaseMonitor(window); +- (void)windowDidMiniaturize:(NSNotification *)notification { + if (window->monitor) + releaseMonitor(window); - _glfwInputWindowIconify(window, GLFW_TRUE); + _glfwInputWindowIconify(window, GLFW_TRUE); } -- (void)windowDidDeminiaturize:(NSNotification *)notification -{ - if (window->monitor) - acquireMonitor(window); +- (void)windowDidDeminiaturize:(NSNotification *)notification { + if (window->monitor) + acquireMonitor(window); - _glfwInputWindowIconify(window, GLFW_FALSE); + _glfwInputWindowIconify(window, GLFW_FALSE); } -- (void)windowDidBecomeKey:(NSNotification *)notification -{ - if (_glfw.ns.disabledCursorWindow == window) - _glfwCenterCursorInContentArea(window); +- (void)windowDidBecomeKey:(NSNotification *)notification { + if (_glfw.ns.disabledCursorWindow == window) + _glfwCenterCursorInContentArea(window); - _glfwInputWindowFocus(window, GLFW_TRUE); - updateCursorMode(window); + _glfwInputWindowFocus(window, GLFW_TRUE); + updateCursorMode(window); } -- (void)windowDidResignKey:(NSNotification *)notification -{ - if (window->monitor && window->autoIconify) - _glfwIconifyWindowCocoa(window); +- (void)windowDidResignKey:(NSNotification *)notification { + if (window->monitor && window->autoIconify) + _glfwIconifyWindowCocoa(window); - _glfwInputWindowFocus(window, GLFW_FALSE); + _glfwInputWindowFocus(window, GLFW_FALSE); } -- (void)windowDidChangeOcclusionState:(NSNotification* )notification -{ -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1090 - if ([window->ns.object respondsToSelector:@selector(occlusionState)]) - { - if ([window->ns.object occlusionState] & NSWindowOcclusionStateVisible) - window->ns.occluded = GLFW_FALSE; - else - window->ns.occluded = GLFW_TRUE; - } -#endif +- (void)windowDidChangeOcclusionState:(NSNotification *)notification { + if ([window->ns.object occlusionState] & NSWindowOcclusionStateVisible) + window->ns.occluded = GLFW_FALSE; + else + window->ns.occluded = GLFW_TRUE; } @end - //------------------------------------------------------------------------ // Content view class for the GLFW window //------------------------------------------------------------------------ -@interface GLFWContentView : NSView -{ - _GLFWwindow* window; - NSTrackingArea* trackingArea; - NSMutableAttributedString* markedText; +@interface GLFWContentView : NSView { + _GLFWwindow *window; + NSTrackingArea *trackingArea; + NSMutableAttributedString *markedText; } - (instancetype)initWithGlfwWindow:(_GLFWwindow *)initWindow; @@ -342,666 +302,578 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; @implementation GLFWContentView -- (instancetype)initWithGlfwWindow:(_GLFWwindow *)initWindow -{ - self = [super init]; - if (self != nil) - { - window = initWindow; - trackingArea = nil; - markedText = [[NSMutableAttributedString alloc] init]; +- (instancetype)initWithGlfwWindow:(_GLFWwindow *)initWindow { + self = [super init]; + if (self != nil) { + window = initWindow; + trackingArea = nil; + markedText = [[NSMutableAttributedString alloc] init]; - [self updateTrackingAreas]; - [self registerForDraggedTypes:@[NSPasteboardTypeURL]]; - } + [self updateTrackingAreas]; + [self registerForDraggedTypes:@[NSPasteboardTypeURL]]; + } - return self; + return self; } -- (void)dealloc -{ - [trackingArea release]; - [markedText release]; - [super dealloc]; +- (void)dealloc { + [trackingArea release]; + [markedText release]; + [super dealloc]; } -- (BOOL)isOpaque -{ - return [window->ns.object isOpaque]; +- (BOOL)isOpaque { + return [window->ns.object isOpaque]; } -- (BOOL)canBecomeKeyView -{ - return YES; +- (BOOL)canBecomeKeyView { + return YES; } -- (BOOL)acceptsFirstResponder -{ - return YES; +- (BOOL)acceptsFirstResponder { + return YES; } -- (BOOL)wantsUpdateLayer -{ - return YES; +- (BOOL)wantsUpdateLayer { + return YES; } -- (void)updateLayer -{ - if (window->context.source == GLFW_NATIVE_CONTEXT_API) - [window->context.nsgl.object update]; +- (void)updateLayer { + if (window->context.source == GLFW_NATIVE_CONTEXT_API) + [window->context.nsgl.object update]; - _glfwInputWindowDamage(window); + _glfwInputWindowDamage(window); } -- (void)cursorUpdate:(NSEvent *)event -{ - updateCursorImage(window); +- (void)cursorUpdate:(NSEvent *)event { + updateCursorImage(window); } -- (BOOL)acceptsFirstMouse:(NSEvent *)event -{ - return YES; +- (BOOL)acceptsFirstMouse:(NSEvent *)event { + return YES; } -- (void)mouseDown:(NSEvent *)event -{ - _glfwInputMouseClick(window, - GLFW_MOUSE_BUTTON_LEFT, - GLFW_PRESS, - translateFlags([event modifierFlags])); +- (void)mouseDown:(NSEvent *)event { + _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS, + translateFlags([event modifierFlags])); } -- (void)mouseDragged:(NSEvent *)event -{ - [self mouseMoved:event]; +- (void)mouseDragged:(NSEvent *)event { + [self mouseMoved:event]; } -- (void)mouseUp:(NSEvent *)event -{ - _glfwInputMouseClick(window, - GLFW_MOUSE_BUTTON_LEFT, - GLFW_RELEASE, - translateFlags([event modifierFlags])); +- (void)mouseUp:(NSEvent *)event { + _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_RELEASE, + translateFlags([event modifierFlags])); } -- (void)mouseMoved:(NSEvent *)event -{ - if (window->cursorMode == GLFW_CURSOR_DISABLED) - { - const double dx = [event deltaX] - window->ns.cursorWarpDeltaX; - const double dy = [event deltaY] - window->ns.cursorWarpDeltaY; +- (void)mouseMoved:(NSEvent *)event { + if (window->cursorMode == GLFW_CURSOR_DISABLED) { + const double dx = [event deltaX] - window->ns.cursorWarpDeltaX; + const double dy = [event deltaY] - window->ns.cursorWarpDeltaY; - _glfwInputCursorPos(window, - window->virtualCursorPosX + dx, - window->virtualCursorPosY + dy); - } - else - { - const NSRect contentRect = [window->ns.view frame]; - // NOTE: The returned location uses base 0,1 not 0,0 - const NSPoint pos = [event locationInWindow]; - - _glfwInputCursorPos(window, pos.x, contentRect.size.height - pos.y); - } - - window->ns.cursorWarpDeltaX = 0; - window->ns.cursorWarpDeltaY = 0; -} - -- (void)rightMouseDown:(NSEvent *)event -{ - _glfwInputMouseClick(window, - GLFW_MOUSE_BUTTON_RIGHT, - GLFW_PRESS, - translateFlags([event modifierFlags])); -} - -- (void)rightMouseDragged:(NSEvent *)event -{ - [self mouseMoved:event]; -} - -- (void)rightMouseUp:(NSEvent *)event -{ - _glfwInputMouseClick(window, - GLFW_MOUSE_BUTTON_RIGHT, - GLFW_RELEASE, - translateFlags([event modifierFlags])); -} - -- (void)otherMouseDown:(NSEvent *)event -{ - _glfwInputMouseClick(window, - (int) [event buttonNumber], - GLFW_PRESS, - translateFlags([event modifierFlags])); -} - -- (void)otherMouseDragged:(NSEvent *)event -{ - [self mouseMoved:event]; -} - -- (void)otherMouseUp:(NSEvent *)event -{ - _glfwInputMouseClick(window, - (int) [event buttonNumber], - GLFW_RELEASE, - translateFlags([event modifierFlags])); -} - -- (void)mouseExited:(NSEvent *)event -{ - if (window->cursorMode == GLFW_CURSOR_HIDDEN) - showCursor(window); - - _glfwInputCursorEnter(window, GLFW_FALSE); -} - -- (void)mouseEntered:(NSEvent *)event -{ - if (window->cursorMode == GLFW_CURSOR_HIDDEN) - hideCursor(window); - - _glfwInputCursorEnter(window, GLFW_TRUE); -} - -- (void)viewDidChangeBackingProperties -{ - const NSRect contentRect = [window->ns.view frame]; - const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect]; - const float xscale = fbRect.size.width / contentRect.size.width; - const float yscale = fbRect.size.height / contentRect.size.height; - - if (xscale != window->ns.xscale || yscale != window->ns.yscale) - { - if (window->ns.retina && window->ns.layer) - [window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]]; - - window->ns.xscale = xscale; - window->ns.yscale = yscale; - _glfwInputWindowContentScale(window, xscale, yscale); - } - - if (fbRect.size.width != window->ns.fbWidth || - fbRect.size.height != window->ns.fbHeight) - { - window->ns.fbWidth = fbRect.size.width; - window->ns.fbHeight = fbRect.size.height; - _glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height); - } -} - -- (void)drawRect:(NSRect)rect -{ - _glfwInputWindowDamage(window); -} - -- (void)updateTrackingAreas -{ - if (trackingArea != nil) - { - [self removeTrackingArea:trackingArea]; - [trackingArea release]; - } - - const NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited | - NSTrackingActiveInKeyWindow | - NSTrackingEnabledDuringMouseDrag | - NSTrackingCursorUpdate | - NSTrackingInVisibleRect | - NSTrackingAssumeInside; - - trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds] - options:options - owner:self - userInfo:nil]; - - [self addTrackingArea:trackingArea]; - [super updateTrackingAreas]; -} - -- (void)keyDown:(NSEvent *)event -{ - const int key = translateKey([event keyCode]); - const int mods = translateFlags([event modifierFlags]); - - _glfwInputKey(window, key, [event keyCode], GLFW_PRESS, mods); - - [self interpretKeyEvents:@[event]]; -} - -- (void)flagsChanged:(NSEvent *)event -{ - int action; - const unsigned int modifierFlags = - [event modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask; - const int key = translateKey([event keyCode]); - const int mods = translateFlags(modifierFlags); - const NSUInteger keyFlag = translateKeyToModifierFlag(key); - - if (keyFlag & modifierFlags) - { - if (window->keys[key] == GLFW_PRESS) - action = GLFW_RELEASE; - else - action = GLFW_PRESS; - } - else - action = GLFW_RELEASE; - - _glfwInputKey(window, key, [event keyCode], action, mods); -} - -- (void)keyUp:(NSEvent *)event -{ - const int key = translateKey([event keyCode]); - const int mods = translateFlags([event modifierFlags]); - _glfwInputKey(window, key, [event keyCode], GLFW_RELEASE, mods); -} - -- (void)scrollWheel:(NSEvent *)event -{ - double deltaX = [event scrollingDeltaX]; - double deltaY = [event scrollingDeltaY]; - - if ([event hasPreciseScrollingDeltas]) - { - deltaX *= 0.1; - deltaY *= 0.1; - } - - if (fabs(deltaX) > 0.0 || fabs(deltaY) > 0.0) - _glfwInputScroll(window, deltaX, deltaY); -} - -- (NSDragOperation)draggingEntered:(id )sender -{ - // HACK: We don't know what to say here because we don't know what the - // application wants to do with the paths - return NSDragOperationGeneric; -} - -- (BOOL)performDragOperation:(id )sender -{ + _glfwInputCursorPos(window, window->virtualCursorPosX + dx, + window->virtualCursorPosY + dy); + } else { const NSRect contentRect = [window->ns.view frame]; // NOTE: The returned location uses base 0,1 not 0,0 - const NSPoint pos = [sender draggingLocation]; + const NSPoint pos = [event locationInWindow]; + _glfwInputCursorPos(window, pos.x, contentRect.size.height - pos.y); + } - NSPasteboard* pasteboard = [sender draggingPasteboard]; - NSDictionary* options = @{NSPasteboardURLReadingFileURLsOnlyKey:@YES}; - NSArray* urls = [pasteboard readObjectsForClasses:@[[NSURL class]] - options:options]; - const NSUInteger count = [urls count]; - if (count) - { - char** paths = _glfw_calloc(count, sizeof(char*)); - - for (NSUInteger i = 0; i < count; i++) - paths[i] = _glfw_strdup([urls[i] fileSystemRepresentation]); - - _glfwInputDrop(window, (int) count, (const char**) paths); - - for (NSUInteger i = 0; i < count; i++) - _glfw_free(paths[i]); - _glfw_free(paths); - } - - return YES; + window->ns.cursorWarpDeltaX = 0; + window->ns.cursorWarpDeltaY = 0; } -- (BOOL)hasMarkedText -{ - return [markedText length] > 0; +- (void)rightMouseDown:(NSEvent *)event { + _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_RIGHT, GLFW_PRESS, + translateFlags([event modifierFlags])); } -- (NSRange)markedRange -{ - if ([markedText length] > 0) - return NSMakeRange(0, [markedText length] - 1); +- (void)rightMouseDragged:(NSEvent *)event { + [self mouseMoved:event]; +} + +- (void)rightMouseUp:(NSEvent *)event { + _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_RIGHT, GLFW_RELEASE, + translateFlags([event modifierFlags])); +} + +- (void)otherMouseDown:(NSEvent *)event { + _glfwInputMouseClick(window, (int) [event buttonNumber], GLFW_PRESS, + translateFlags([event modifierFlags])); +} + +- (void)otherMouseDragged:(NSEvent *)event { + [self mouseMoved:event]; +} + +- (void)otherMouseUp:(NSEvent *)event { + _glfwInputMouseClick(window, (int) [event buttonNumber], GLFW_RELEASE, + translateFlags([event modifierFlags])); +} + +- (void)mouseExited:(NSEvent *)event { + if (window->cursorMode == GLFW_CURSOR_HIDDEN) + showCursor(window); + + _glfwInputCursorEnter(window, GLFW_FALSE); +} + +- (void)mouseEntered:(NSEvent *)event { + if (window->cursorMode == GLFW_CURSOR_HIDDEN) + hideCursor(window); + + _glfwInputCursorEnter(window, GLFW_TRUE); +} + +- (void)viewDidChangeBackingProperties { + const NSRect contentRect = [window->ns.view frame]; + const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect]; + const float xscale = fbRect.size.width / contentRect.size.width; + const float yscale = fbRect.size.height / contentRect.size.height; + + if (xscale != window->ns.xscale || yscale != window->ns.yscale) { + if (window->ns.retina && window->ns.layer) + [window->ns.layer + setContentsScale:[window->ns.object backingScaleFactor]]; + + window->ns.xscale = xscale; + window->ns.yscale = yscale; + _glfwInputWindowContentScale(window, xscale, yscale); + } + + if (fbRect.size.width != window->ns.fbWidth || + fbRect.size.height != window->ns.fbHeight) { + window->ns.fbWidth = fbRect.size.width; + window->ns.fbHeight = fbRect.size.height; + _glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height); + } +} + +- (void)drawRect:(NSRect)rect { + _glfwInputWindowDamage(window); +} + +- (void)updateTrackingAreas { + if (trackingArea != nil) { + [self removeTrackingArea:trackingArea]; + [trackingArea release]; + } + + const NSTrackingAreaOptions options = + NSTrackingMouseEnteredAndExited | NSTrackingActiveInKeyWindow | + NSTrackingEnabledDuringMouseDrag | NSTrackingCursorUpdate | + NSTrackingInVisibleRect | NSTrackingAssumeInside; + + trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds] + options:options + owner:self + userInfo:nil]; + + [self addTrackingArea:trackingArea]; + [super updateTrackingAreas]; +} + +- (void)keyDown:(NSEvent *)event { + const int key = translateKey([event keyCode]); + const int mods = translateFlags([event modifierFlags]); + + _glfwInputKey(window, key, [event keyCode], GLFW_PRESS, mods); + + [self interpretKeyEvents:@[event]]; +} + +- (void)flagsChanged:(NSEvent *)event { + int action; + const unsigned int modifierFlags = + [event modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask; + const int key = translateKey([event keyCode]); + const int mods = translateFlags(modifierFlags); + const NSUInteger keyFlag = translateKeyToModifierFlag(key); + + if (keyFlag & modifierFlags) { + if (window->keys[key] == GLFW_PRESS) + action = GLFW_RELEASE; else - return kEmptyRange; + action = GLFW_PRESS; + } else + action = GLFW_RELEASE; + + _glfwInputKey(window, key, [event keyCode], action, mods); } -- (NSRange)selectedRange -{ +- (void)keyUp:(NSEvent *)event { + const int key = translateKey([event keyCode]); + const int mods = translateFlags([event modifierFlags]); + _glfwInputKey(window, key, [event keyCode], GLFW_RELEASE, mods); +} + +- (void)scrollWheel:(NSEvent *)event { + double deltaX = [event scrollingDeltaX]; + double deltaY = [event scrollingDeltaY]; + + if ([event hasPreciseScrollingDeltas]) { + deltaX *= 0.1; + deltaY *= 0.1; + } + + if (fabs(deltaX) > 0.0 || fabs(deltaY) > 0.0) + _glfwInputScroll(window, deltaX, deltaY); +} + +- (NSDragOperation)draggingEntered:(id)sender { + // HACK: We don't know what to say here because we don't know what the + // application wants to do with the paths + return NSDragOperationGeneric; +} + +- (BOOL)performDragOperation:(id)sender { + const NSRect contentRect = [window->ns.view frame]; + // NOTE: The returned location uses base 0,1 not 0,0 + const NSPoint pos = [sender draggingLocation]; + _glfwInputCursorPos(window, pos.x, contentRect.size.height - pos.y); + + NSPasteboard *pasteboard = [sender draggingPasteboard]; + NSDictionary *options = @{NSPasteboardURLReadingFileURLsOnlyKey: @YES}; + NSArray *urls = [pasteboard readObjectsForClasses:@[[NSURL class]] + options:options]; + const NSUInteger count = [urls count]; + if (count) { + char **paths = _glfw_calloc(count, sizeof(char *)); + + for (NSUInteger i = 0; i < count; i++) + paths[i] = _glfw_strdup([urls[i] fileSystemRepresentation]); + + _glfwInputDrop(window, (int) count, (const char **) paths); + + for (NSUInteger i = 0; i < count; i++) + _glfw_free(paths[i]); + _glfw_free(paths); + } + + return YES; +} + +- (BOOL)hasMarkedText { + return [markedText length] > 0; +} + +- (NSRange)markedRange { + if ([markedText length] > 0) + return NSMakeRange(0, [markedText length] - 1); + else return kEmptyRange; } +- (NSRange)selectedRange { + return kEmptyRange; +} + - (void)setMarkedText:(id)string - selectedRange:(NSRange)selectedRange - replacementRange:(NSRange)replacementRange -{ - [markedText release]; - if ([string isKindOfClass:[NSAttributedString class]]) - markedText = [[NSMutableAttributedString alloc] initWithAttributedString:string]; - else - markedText = [[NSMutableAttributedString alloc] initWithString:string]; + selectedRange:(NSRange)selectedRange + replacementRange:(NSRange)replacementRange { + [markedText release]; + if ([string isKindOfClass:[NSAttributedString class]]) + markedText = + [[NSMutableAttributedString alloc] initWithAttributedString:string]; + else + markedText = [[NSMutableAttributedString alloc] initWithString:string]; } -- (void)unmarkText -{ - [[markedText mutableString] setString:@""]; +- (void)unmarkText { + [[markedText mutableString] setString:@""]; } -- (NSArray*)validAttributesForMarkedText -{ - return [NSArray array]; +- (NSArray *)validAttributesForMarkedText { + return [NSArray array]; } -- (NSAttributedString*)attributedSubstringForProposedRange:(NSRange)range - actualRange:(NSRangePointer)actualRange -{ - return nil; +- (NSAttributedString *)attributedSubstringForProposedRange:(NSRange)range + actualRange:(NSRangePointer) + actualRange { + return nil; } -- (NSUInteger)characterIndexForPoint:(NSPoint)point -{ - return 0; +- (NSUInteger)characterIndexForPoint:(NSPoint)point { + return 0; } - (NSRect)firstRectForCharacterRange:(NSRange)range - actualRange:(NSRangePointer)actualRange -{ - const NSRect frame = [window->ns.view frame]; - return NSMakeRect(frame.origin.x, frame.origin.y, 0.0, 0.0); + actualRange:(NSRangePointer)actualRange { + const NSRect frame = [window->ns.view frame]; + return NSMakeRect(frame.origin.x, frame.origin.y, 0.0, 0.0); } -- (void)insertText:(id)string replacementRange:(NSRange)replacementRange -{ - NSString* characters; - NSEvent* event = [NSApp currentEvent]; - const int mods = translateFlags([event modifierFlags]); - const int plain = !(mods & GLFW_MOD_SUPER); +- (void)insertText:(id)string replacementRange:(NSRange)replacementRange { + NSString *characters; + NSEvent *event = [NSApp currentEvent]; + const int mods = translateFlags([event modifierFlags]); + const int plain = !(mods & GLFW_MOD_SUPER); - if ([string isKindOfClass:[NSAttributedString class]]) - characters = [string string]; - else - characters = (NSString*) string; + if ([string isKindOfClass:[NSAttributedString class]]) + characters = [string string]; + else + characters = (NSString *) string; - NSRange range = NSMakeRange(0, [characters length]); - while (range.length) - { - uint32_t codepoint = 0; + NSRange range = NSMakeRange(0, [characters length]); + while (range.length) { + uint32_t codepoint = 0; - if ([characters getBytes:&codepoint - maxLength:sizeof(codepoint) - usedLength:NULL - encoding:NSUTF32StringEncoding - options:0 - range:range - remainingRange:&range]) - { - if (codepoint >= 0xf700 && codepoint <= 0xf7ff) - continue; + if ([characters getBytes:&codepoint + maxLength:sizeof(codepoint) + usedLength:NULL + encoding:NSUTF32StringEncoding + options:0 + range:range + remainingRange:&range]) { + if (codepoint >= 0xf700 && codepoint <= 0xf7ff) + continue; - _glfwInputChar(window, codepoint, mods, plain); - } + _glfwInputChar(window, codepoint, mods, plain); } + } } -- (void)doCommandBySelector:(SEL)selector -{ +- (void)doCommandBySelector:(SEL)selector { } @end - //------------------------------------------------------------------------ // GLFW window class //------------------------------------------------------------------------ -@interface GLFWWindow : NSWindow {} +@interface GLFWWindow : NSWindow { +} @end @implementation GLFWWindow -- (BOOL)canBecomeKeyWindow -{ - // Required for NSWindowStyleMaskBorderless windows - return YES; +- (BOOL)canBecomeKeyWindow { + // Required for NSWindowStyleMaskBorderless windows + return YES; } -- (BOOL)canBecomeMainWindow -{ - return YES; +- (BOOL)canBecomeMainWindow { + return YES; } @end - // Create the Cocoa window // -static GLFWbool createNativeWindow(_GLFWwindow* window, - const _GLFWwndconfig* wndconfig, - const _GLFWfbconfig* fbconfig) -{ - window->ns.delegate = [[GLFWWindowDelegate alloc] initWithGlfwWindow:window]; - if (window->ns.delegate == nil) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Cocoa: Failed to create window delegate"); - return GLFW_FALSE; +static GLFWbool createNativeWindow(_GLFWwindow *window, + const _GLFWwndconfig *wndconfig, + const _GLFWfbconfig *fbconfig) { + window->ns.delegate = [[GLFWWindowDelegate alloc] initWithGlfwWindow:window]; + + if (window->ns.delegate == nil) { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Cocoa: Failed to create window delegate"); + return GLFW_FALSE; + } + + NSRect contentRect; + + if (window->monitor) { + GLFWvidmode mode; + int xpos, ypos; + + _glfwGetVideoModeCocoa(window->monitor, &mode); + _glfwGetMonitorPosCocoa(window->monitor, &xpos, &ypos); + + contentRect = NSMakeRect(xpos, ypos, mode.width, mode.height); + } else { + if (wndconfig->xpos == GLFW_ANY_POSITION || + wndconfig->ypos == GLFW_ANY_POSITION) { + contentRect = NSMakeRect(0, 0, wndconfig->width, wndconfig->height); + } else { + const int xpos = wndconfig->xpos; + const int ypos = + _glfwTransformYCocoa(wndconfig->ypos + wndconfig->height - 1); + contentRect = NSMakeRect(xpos, ypos, wndconfig->width, wndconfig->height); + } + } + + NSUInteger styleMask = NSWindowStyleMaskMiniaturizable; + + if (window->monitor || !window->decorated) + styleMask |= NSWindowStyleMaskBorderless; + else { + styleMask |= (NSWindowStyleMaskTitled | NSWindowStyleMaskClosable); + + if (window->resizable) + styleMask |= NSWindowStyleMaskResizable; + } + + window->ns.object = + [[GLFWWindow alloc] initWithContentRect:contentRect + styleMask:styleMask + backing:NSBackingStoreBuffered + defer:NO]; + + if (window->ns.object == nil) { + _glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to create window"); + return GLFW_FALSE; + } + + + // Set the window's style to allow for a full-size contentView + if (window->monitor) + [window->ns.object setLevel:NSMainMenuWindowLevel + 1]; + else { + if (wndconfig->xpos == GLFW_ANY_POSITION || + wndconfig->ypos == GLFW_ANY_POSITION) { + [(NSWindow *) window->ns.object center]; + _glfw.ns.cascadePoint = NSPointToCGPoint([window->ns.object + cascadeTopLeftFromPoint:NSPointFromCGPoint(_glfw.ns.cascadePoint)]); } - NSRect contentRect; - - if (window->monitor) - { - GLFWvidmode mode; - int xpos, ypos; - - _glfwGetVideoModeCocoa(window->monitor, &mode); - _glfwGetMonitorPosCocoa(window->monitor, &xpos, &ypos); - - contentRect = NSMakeRect(xpos, ypos, mode.width, mode.height); - } - else - { - if (wndconfig->xpos == GLFW_ANY_POSITION || - wndconfig->ypos == GLFW_ANY_POSITION) - { - contentRect = NSMakeRect(0, 0, wndconfig->width, wndconfig->height); - } - else - { - const int xpos = wndconfig->xpos; - const int ypos = _glfwTransformYCocoa(wndconfig->ypos + wndconfig->height - 1); - contentRect = NSMakeRect(xpos, ypos, wndconfig->width, wndconfig->height); - } + if (wndconfig->resizable) { + const NSWindowCollectionBehavior behavior = + NSWindowCollectionBehaviorFullScreenPrimary | + NSWindowCollectionBehaviorManaged; + [window->ns.object setCollectionBehavior:behavior]; + } else { + const NSWindowCollectionBehavior behavior = + NSWindowCollectionBehaviorFullScreenNone; + [window->ns.object setCollectionBehavior:behavior]; } - NSUInteger styleMask = NSWindowStyleMaskMiniaturizable; + if (wndconfig->floating) + [window->ns.object setLevel:NSFloatingWindowLevel]; - if (window->monitor || !window->decorated) - styleMask |= NSWindowStyleMaskBorderless; - else - { - styleMask |= (NSWindowStyleMaskTitled | NSWindowStyleMaskClosable); + if (wndconfig->maximized) + [window->ns.object zoom:nil]; + } - if (window->resizable) - styleMask |= NSWindowStyleMaskResizable; - } + if (strlen(wndconfig->ns.frameName)) + [window->ns.object setFrameAutosaveName:@(wndconfig->ns.frameName)]; - window->ns.object = [[GLFWWindow alloc] - initWithContentRect:contentRect - styleMask:styleMask - backing:NSBackingStoreBuffered - defer:NO]; + window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window]; + window->ns.retina = wndconfig->ns.retina; - if (window->ns.object == nil) - { - _glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to create window"); - return GLFW_FALSE; - } + if (fbconfig->transparent) { + [window->ns.object setOpaque:NO]; + [window->ns.object setHasShadow:NO]; + [window->ns.object setBackgroundColor:[NSColor clearColor]]; + } - if (window->monitor) - [window->ns.object setLevel:NSMainMenuWindowLevel + 1]; - else - { - if (wndconfig->xpos == GLFW_ANY_POSITION || - wndconfig->ypos == GLFW_ANY_POSITION) - { - [(NSWindow*) window->ns.object center]; - _glfw.ns.cascadePoint = - NSPointToCGPoint([window->ns.object cascadeTopLeftFromPoint: - NSPointFromCGPoint(_glfw.ns.cascadePoint)]); - } - - if (wndconfig->resizable) - { - const NSWindowCollectionBehavior behavior = - NSWindowCollectionBehaviorFullScreenPrimary | - NSWindowCollectionBehaviorManaged; - [window->ns.object setCollectionBehavior:behavior]; - } - else - { - const NSWindowCollectionBehavior behavior = - NSWindowCollectionBehaviorFullScreenNone; - [window->ns.object setCollectionBehavior:behavior]; - } - - if (wndconfig->floating) - [window->ns.object setLevel:NSFloatingWindowLevel]; - - if (wndconfig->maximized) - [window->ns.object zoom:nil]; - } - - if (strlen(wndconfig->ns.frameName)) - [window->ns.object setFrameAutosaveName:@(wndconfig->ns.frameName)]; - - window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window]; - window->ns.retina = wndconfig->ns.retina; - - if (fbconfig->transparent) - { - [window->ns.object setOpaque:NO]; - [window->ns.object setHasShadow:NO]; - [window->ns.object setBackgroundColor:[NSColor clearColor]]; - } - - [window->ns.object setContentView:window->ns.view]; - [window->ns.object makeFirstResponder:window->ns.view]; - [window->ns.object setTitle:@(wndconfig->title)]; - [window->ns.object setDelegate:window->ns.delegate]; - [window->ns.object setAcceptsMouseMovedEvents:YES]; - [window->ns.object setRestorable:NO]; + [window->ns.object setContentView:window->ns.view]; + [window->ns.object makeFirstResponder:window->ns.view]; + [window->ns.object setTitle:@(wndconfig->title)]; + [window->ns.object setDelegate:window->ns.delegate]; + [window->ns.object setAcceptsMouseMovedEvents:YES]; + [window->ns.object setRestorable:NO]; #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200 - if ([window->ns.object respondsToSelector:@selector(setTabbingMode:)]) - [window->ns.object setTabbingMode:NSWindowTabbingModeDisallowed]; + if ([window->ns.object respondsToSelector:@selector(setTabbingMode:)]) + [window->ns.object setTabbingMode:NSWindowTabbingModeDisallowed]; #endif - _glfwGetWindowSizeCocoa(window, &window->ns.width, &window->ns.height); - _glfwGetFramebufferSizeCocoa(window, &window->ns.fbWidth, &window->ns.fbHeight); + _glfwGetWindowSizeCocoa(window, &window->ns.width, &window->ns.height); + _glfwGetFramebufferSizeCocoa(window, &window->ns.fbWidth, + &window->ns.fbHeight); - return GLFW_TRUE; + + return GLFW_TRUE; } - ////////////////////////////////////////////////////////////////////////// ////// GLFW internal API ////// ////////////////////////////////////////////////////////////////////////// // Transforms a y-coordinate between the CG display and NS screen spaces // -float _glfwTransformYCocoa(float y) -{ - return CGDisplayBounds(CGMainDisplayID()).size.height - y - 1; +float _glfwTransformYCocoa(float y) { + return CGDisplayBounds(CGMainDisplayID()).size.height - y - 1; } - ////////////////////////////////////////////////////////////////////////// ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -GLFWbool _glfwCreateWindowCocoa(_GLFWwindow* window, - const _GLFWwndconfig* wndconfig, - const _GLFWctxconfig* ctxconfig, - const _GLFWfbconfig* fbconfig) -{ - @autoreleasepool { +GLFWbool _glfwCreateWindowCocoa(_GLFWwindow *window, + const _GLFWwndconfig *wndconfig, + const _GLFWctxconfig *ctxconfig, + const _GLFWfbconfig *fbconfig) { + @autoreleasepool { if (!createNativeWindow(window, wndconfig, fbconfig)) + return GLFW_FALSE; + + if (ctxconfig->client != GLFW_NO_API) { + if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API) { + if (!_glfwInitNSGL()) + return GLFW_FALSE; + if (!_glfwCreateContextNSGL(window, ctxconfig, fbconfig)) + return GLFW_FALSE; + } else if (ctxconfig->source == GLFW_EGL_CONTEXT_API) { + // EGL implementation on macOS use CALayer* EGLNativeWindowType so we + // need to get the layer for EGL window surface creation. + [window->ns.view setWantsLayer:YES]; + window->ns.layer = [window->ns.view layer]; + + if (!_glfwInitEGL()) + return GLFW_FALSE; + if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig)) + return GLFW_FALSE; + } else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API) { + if (!_glfwInitOSMesa()) + return GLFW_FALSE; + if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig)) + return GLFW_FALSE; + } + + if (!_glfwRefreshContextAttribs(window, ctxconfig)) return GLFW_FALSE; - - if (ctxconfig->client != GLFW_NO_API) - { - if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API) - { - if (!_glfwInitNSGL()) - return GLFW_FALSE; - if (!_glfwCreateContextNSGL(window, ctxconfig, fbconfig)) - return GLFW_FALSE; - } - else if (ctxconfig->source == GLFW_EGL_CONTEXT_API) - { - // EGL implementation on macOS use CALayer* EGLNativeWindowType so we - // need to get the layer for EGL window surface creation. - [window->ns.view setWantsLayer:YES]; - window->ns.layer = [window->ns.view layer]; - - if (!_glfwInitEGL()) - return GLFW_FALSE; - if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig)) - return GLFW_FALSE; - } - else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API) - { - if (!_glfwInitOSMesa()) - return GLFW_FALSE; - if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig)) - return GLFW_FALSE; - } - - if (!_glfwRefreshContextAttribs(window, ctxconfig)) - return GLFW_FALSE; } if (wndconfig->mousePassthrough) - _glfwSetWindowMousePassthroughCocoa(window, GLFW_TRUE); + _glfwSetWindowMousePassthroughCocoa(window, GLFW_TRUE); - if (window->monitor) - { + if (window->monitor) { + _glfwShowWindowCocoa(window); + _glfwFocusWindowCocoa(window); + acquireMonitor(window); + + if (wndconfig->centerCursor) + _glfwCenterCursorInContentArea(window); + } else { + if (wndconfig->visible) { _glfwShowWindowCocoa(window); - _glfwFocusWindowCocoa(window); - acquireMonitor(window); - - if (wndconfig->centerCursor) - _glfwCenterCursorInContentArea(window); - } - else - { - if (wndconfig->visible) - { - _glfwShowWindowCocoa(window); - if (wndconfig->focused) - _glfwFocusWindowCocoa(window); - } + if (wndconfig->focused) + _glfwFocusWindowCocoa(window); + } } return GLFW_TRUE; - } // autoreleasepool + }// autoreleasepool +} +void _glfwSetWindowTitleCocoa(_GLFWwindow *window, const char *title) { + @autoreleasepool { + + NSString *string = @(title); + [window->ns.object setTitle:string]; + } } -void _glfwDestroyWindowCocoa(_GLFWwindow* window) -{ - @autoreleasepool { +void _glfwDestroyWindowCocoa(_GLFWwindow *window) { + @autoreleasepool { if (_glfw.ns.disabledCursorWindow == window) - _glfw.ns.disabledCursorWindow = NULL; + _glfw.ns.disabledCursorWindow = NULL; [window->ns.object orderOut:nil]; if (window->monitor) - releaseMonitor(window); + releaseMonitor(window); if (window->context.destroy) - window->context.destroy(window); + window->context.destroy(window); [window->ns.object setDelegate:nil]; [window->ns.delegate release]; @@ -1016,263 +888,239 @@ void _glfwDestroyWindowCocoa(_GLFWwindow* window) // HACK: Allow Cocoa to catch up before returning _glfwPollEventsCocoa(); - } // autoreleasepool + }// autoreleasepool } -void _glfwSetWindowTitleCocoa(_GLFWwindow* window, const char* title) -{ - @autoreleasepool { - NSString* string = @(title); - [window->ns.object setTitle:string]; - // HACK: Set the miniwindow title explicitly as setTitle: doesn't update it - // if the window lacks NSWindowStyleMaskTitled - [window->ns.object setMiniwindowTitle:string]; - } // autoreleasepool +void _glfwPlatformSetWindowFloating(_GLFWwindow *window, GLFWbool enabled) { + @autoreleasepool { + // NSString *string = @(title); + // [window->ns.object setTitle:string]; + // // HACK: Set the miniwindow title explicitly as setTitle: doesn't update it + // // if the window lacks NSWindowStyleMaskTitled + // [window->ns.object setMiniwindowTitle:string]; + }// autoreleasepool } -void _glfwSetWindowIconCocoa(_GLFWwindow* window, - int count, const GLFWimage* images) -{ - _glfwInputError(GLFW_FEATURE_UNAVAILABLE, - "Cocoa: Regular windows do not have icons on macOS"); +void _glfwSetWindowIconCocoa(_GLFWwindow *window, int count, + const GLFWimage *images) { + // _glfwInputError(GLFW_FEATURE_UNAVAILABLE, + // "Cocoa: Regular windows do not have icons on macOS"); } -void _glfwGetWindowPosCocoa(_GLFWwindow* window, int* xpos, int* ypos) -{ - @autoreleasepool { +void _glfwGetWindowPosCocoa(_GLFWwindow *window, int *xpos, int *ypos) { + @autoreleasepool { const NSRect contentRect = - [window->ns.object contentRectForFrameRect:[window->ns.object frame]]; + [window->ns.object contentRectForFrameRect:[window->ns.object frame]]; if (xpos) - *xpos = contentRect.origin.x; + *xpos = contentRect.origin.x; if (ypos) - *ypos = _glfwTransformYCocoa(contentRect.origin.y + contentRect.size.height - 1); + *ypos = _glfwTransformYCocoa(contentRect.origin.y + + contentRect.size.height - 1); - } // autoreleasepool + }// autoreleasepool } -void _glfwSetWindowPosCocoa(_GLFWwindow* window, int x, int y) -{ - @autoreleasepool { +void _glfwSetWindowPosCocoa(_GLFWwindow *window, int x, int y) { + @autoreleasepool { const NSRect contentRect = [window->ns.view frame]; - const NSRect dummyRect = NSMakeRect(x, _glfwTransformYCocoa(y + contentRect.size.height - 1), 0, 0); - const NSRect frameRect = [window->ns.object frameRectForContentRect:dummyRect]; + const NSRect dummyRect = NSMakeRect( + x, _glfwTransformYCocoa(y + contentRect.size.height - 1), 0, 0); + const NSRect frameRect = + [window->ns.object frameRectForContentRect:dummyRect]; [window->ns.object setFrameOrigin:frameRect.origin]; - } // autoreleasepool + }// autoreleasepool } -void _glfwGetWindowSizeCocoa(_GLFWwindow* window, int* width, int* height) -{ - @autoreleasepool { +void _glfwGetWindowSizeCocoa(_GLFWwindow *window, int *width, int *height) { + @autoreleasepool { const NSRect contentRect = [window->ns.view frame]; if (width) - *width = contentRect.size.width; + *width = contentRect.size.width; if (height) - *height = contentRect.size.height; + *height = contentRect.size.height; - } // autoreleasepool + }// autoreleasepool } -void _glfwSetWindowSizeCocoa(_GLFWwindow* window, int width, int height) -{ - @autoreleasepool { +void _glfwSetWindowSizeCocoa(_GLFWwindow *window, int width, int height) { + @autoreleasepool { - if (window->monitor) - { - if (window->monitor->window == window) - acquireMonitor(window); - } - else - { - NSRect contentRect = - [window->ns.object contentRectForFrameRect:[window->ns.object frame]]; - contentRect.origin.y += contentRect.size.height - height; - contentRect.size = NSMakeSize(width, height); - [window->ns.object setFrame:[window->ns.object frameRectForContentRect:contentRect] - display:YES]; + if (window->monitor) { + if (window->monitor->window == window) + acquireMonitor(window); + } else { + NSRect contentRect = + [window->ns.object contentRectForFrameRect:[window->ns.object frame]]; + contentRect.origin.y += contentRect.size.height - height; + contentRect.size = NSMakeSize(width, height); + [window->ns.object + setFrame:[window->ns.object frameRectForContentRect:contentRect] + display:YES]; } - } // autoreleasepool + }// autoreleasepool } -void _glfwSetWindowSizeLimitsCocoa(_GLFWwindow* window, - int minwidth, int minheight, - int maxwidth, int maxheight) -{ - @autoreleasepool { +void _glfwSetWindowSizeLimitsCocoa(_GLFWwindow *window, int minwidth, + int minheight, int maxwidth, int maxheight) { + @autoreleasepool { if (minwidth == GLFW_DONT_CARE || minheight == GLFW_DONT_CARE) - [window->ns.object setContentMinSize:NSMakeSize(0, 0)]; + [window->ns.object setContentMinSize:NSMakeSize(0, 0)]; else - [window->ns.object setContentMinSize:NSMakeSize(minwidth, minheight)]; + [window->ns.object setContentMinSize:NSMakeSize(minwidth, minheight)]; if (maxwidth == GLFW_DONT_CARE || maxheight == GLFW_DONT_CARE) - [window->ns.object setContentMaxSize:NSMakeSize(DBL_MAX, DBL_MAX)]; + [window->ns.object setContentMaxSize:NSMakeSize(DBL_MAX, DBL_MAX)]; else - [window->ns.object setContentMaxSize:NSMakeSize(maxwidth, maxheight)]; + [window->ns.object setContentMaxSize:NSMakeSize(maxwidth, maxheight)]; - } // autoreleasepool + }// autoreleasepool } -void _glfwSetWindowAspectRatioCocoa(_GLFWwindow* window, int numer, int denom) -{ - @autoreleasepool { +void _glfwSetWindowAspectRatioCocoa(_GLFWwindow *window, int numer, int denom) { + @autoreleasepool { if (numer == GLFW_DONT_CARE || denom == GLFW_DONT_CARE) - [window->ns.object setResizeIncrements:NSMakeSize(1.0, 1.0)]; + [window->ns.object setResizeIncrements:NSMakeSize(1.0, 1.0)]; else - [window->ns.object setContentAspectRatio:NSMakeSize(numer, denom)]; - } // autoreleasepool + [window->ns.object setContentAspectRatio:NSMakeSize(numer, denom)]; + }// autoreleasepool } -void _glfwGetFramebufferSizeCocoa(_GLFWwindow* window, int* width, int* height) -{ - @autoreleasepool { +void _glfwGetFramebufferSizeCocoa(_GLFWwindow *window, int *width, + int *height) { + @autoreleasepool { const NSRect contentRect = [window->ns.view frame]; const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect]; if (width) - *width = (int) fbRect.size.width; + *width = (int) fbRect.size.width; if (height) - *height = (int) fbRect.size.height; + *height = (int) fbRect.size.height; - } // autoreleasepool + }// autoreleasepool } -void _glfwGetWindowFrameSizeCocoa(_GLFWwindow* window, - int* left, int* top, - int* right, int* bottom) -{ - @autoreleasepool { +void _glfwGetWindowFrameSizeCocoa(_GLFWwindow *window, int *left, int *top, + int *right, int *bottom) { + @autoreleasepool { const NSRect contentRect = [window->ns.view frame]; - const NSRect frameRect = [window->ns.object frameRectForContentRect:contentRect]; + const NSRect frameRect = + [window->ns.object frameRectForContentRect:contentRect]; if (left) - *left = contentRect.origin.x - frameRect.origin.x; + *left = contentRect.origin.x - frameRect.origin.x; if (top) - *top = frameRect.origin.y + frameRect.size.height - - contentRect.origin.y - contentRect.size.height; + *top = frameRect.origin.y + frameRect.size.height - contentRect.origin.y - + contentRect.size.height; if (right) - *right = frameRect.origin.x + frameRect.size.width - - contentRect.origin.x - contentRect.size.width; + *right = frameRect.origin.x + frameRect.size.width - + contentRect.origin.x - contentRect.size.width; if (bottom) - *bottom = contentRect.origin.y - frameRect.origin.y; + *bottom = contentRect.origin.y - frameRect.origin.y; - } // autoreleasepool + }// autoreleasepool } -void _glfwGetWindowContentScaleCocoa(_GLFWwindow* window, - float* xscale, float* yscale) -{ - @autoreleasepool { +void _glfwGetWindowContentScaleCocoa(_GLFWwindow *window, float *xscale, + float *yscale) { + @autoreleasepool { const NSRect points = [window->ns.view frame]; const NSRect pixels = [window->ns.view convertRectToBacking:points]; if (xscale) - *xscale = (float) (pixels.size.width / points.size.width); + *xscale = (float) (pixels.size.width / points.size.width); if (yscale) - *yscale = (float) (pixels.size.height / points.size.height); + *yscale = (float) (pixels.size.height / points.size.height); - } // autoreleasepool + }// autoreleasepool } -void _glfwIconifyWindowCocoa(_GLFWwindow* window) -{ - @autoreleasepool { +void _glfwIconifyWindowCocoa(_GLFWwindow *window) { + @autoreleasepool { [window->ns.object miniaturize:nil]; - } // autoreleasepool + }// autoreleasepool } -void _glfwRestoreWindowCocoa(_GLFWwindow* window) -{ - @autoreleasepool { +void _glfwRestoreWindowCocoa(_GLFWwindow *window) { + @autoreleasepool { if ([window->ns.object isMiniaturized]) - [window->ns.object deminiaturize:nil]; + [window->ns.object deminiaturize:nil]; else if ([window->ns.object isZoomed]) - [window->ns.object zoom:nil]; - } // autoreleasepool + [window->ns.object zoom:nil]; + }// autoreleasepool } -void _glfwMaximizeWindowCocoa(_GLFWwindow* window) -{ - @autoreleasepool { +void _glfwMaximizeWindowCocoa(_GLFWwindow *window) { + @autoreleasepool { if (![window->ns.object isZoomed]) - [window->ns.object zoom:nil]; - } // autoreleasepool + [window->ns.object zoom:nil]; + }// autoreleasepool } -void _glfwShowWindowCocoa(_GLFWwindow* window) -{ - @autoreleasepool { +void _glfwShowWindowCocoa(_GLFWwindow *window) { + @autoreleasepool { [window->ns.object orderFront:nil]; - } // autoreleasepool + }// autoreleasepool } -void _glfwHideWindowCocoa(_GLFWwindow* window) -{ - @autoreleasepool { +void _glfwHideWindowCocoa(_GLFWwindow *window) { + @autoreleasepool { [window->ns.object orderOut:nil]; - } // autoreleasepool + }// autoreleasepool } -void _glfwRequestWindowAttentionCocoa(_GLFWwindow* window) -{ - @autoreleasepool { +void _glfwRequestWindowAttentionCocoa(_GLFWwindow *window) { + @autoreleasepool { [NSApp requestUserAttention:NSInformationalRequest]; - } // autoreleasepool + }// autoreleasepool } -void _glfwFocusWindowCocoa(_GLFWwindow* window) -{ - @autoreleasepool { +void _glfwFocusWindowCocoa(_GLFWwindow *window) { + @autoreleasepool { // Make us the active application // HACK: This is here to prevent applications using only hidden windows from // being activated, but should probably not be done every time any // window is shown [NSApp activateIgnoringOtherApps:YES]; [window->ns.object makeKeyAndOrderFront:nil]; - } // autoreleasepool + }// autoreleasepool } -void _glfwSetWindowMonitorCocoa(_GLFWwindow* window, - _GLFWmonitor* monitor, - int xpos, int ypos, - int width, int height, - int refreshRate) -{ - @autoreleasepool { +void _glfwSetWindowMonitorCocoa(_GLFWwindow *window, _GLFWmonitor *monitor, + int xpos, int ypos, int width, int height, + int refreshRate) { + @autoreleasepool { - if (window->monitor == monitor) - { - if (monitor) - { - if (monitor->window == window) - acquireMonitor(window); - } - else - { - const NSRect contentRect = - NSMakeRect(xpos, _glfwTransformYCocoa(ypos + height - 1), width, height); - const NSUInteger styleMask = [window->ns.object styleMask]; - const NSRect frameRect = + if (window->monitor == monitor) { + if (monitor) { + if (monitor->window == window) + acquireMonitor(window); + } else { + const NSRect contentRect = NSMakeRect( + xpos, _glfwTransformYCocoa(ypos + height - 1), width, height); + const NSUInteger styleMask = [window->ns.object styleMask]; + const NSRect frameRect = [window->ns.object frameRectForContentRect:contentRect styleMask:styleMask]; - [window->ns.object setFrame:frameRect display:YES]; - } + [window->ns.object setFrame:frameRect display:YES]; + } - return; + return; } if (window->monitor) - releaseMonitor(window); + releaseMonitor(window); _glfwInputWindowMonitor(window, monitor); @@ -1282,261 +1130,248 @@ void _glfwSetWindowMonitorCocoa(_GLFWwindow* window, NSUInteger styleMask = [window->ns.object styleMask]; - if (window->monitor) - { - styleMask &= ~(NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable); - styleMask |= NSWindowStyleMaskBorderless; - } - else - { - if (window->decorated) - { - styleMask &= ~NSWindowStyleMaskBorderless; - styleMask |= (NSWindowStyleMaskTitled | NSWindowStyleMaskClosable); - } + if (window->monitor) { + styleMask &= ~(NSWindowStyleMaskTitled | NSWindowStyleMaskClosable); + styleMask |= NSWindowStyleMaskBorderless; + } else { + if (window->decorated) { + styleMask &= ~NSWindowStyleMaskBorderless; + styleMask |= (NSWindowStyleMaskTitled | NSWindowStyleMaskClosable); + } - if (window->resizable) - styleMask |= NSWindowStyleMaskResizable; - else - styleMask &= ~NSWindowStyleMaskResizable; + if (window->resizable) + styleMask |= NSWindowStyleMaskResizable; + else + styleMask &= ~NSWindowStyleMaskResizable; } [window->ns.object setStyleMask:styleMask]; // HACK: Changing the style mask can cause the first responder to be cleared [window->ns.object makeFirstResponder:window->ns.view]; - if (window->monitor) - { - [window->ns.object setLevel:NSMainMenuWindowLevel + 1]; - [window->ns.object setHasShadow:NO]; + if (window->monitor) { + [window->ns.object setLevel:NSMainMenuWindowLevel + 1]; + [window->ns.object setHasShadow:NO]; - acquireMonitor(window); - } - else - { - NSRect contentRect = NSMakeRect(xpos, _glfwTransformYCocoa(ypos + height - 1), - width, height); - NSRect frameRect = [window->ns.object frameRectForContentRect:contentRect - styleMask:styleMask]; - [window->ns.object setFrame:frameRect display:YES]; + acquireMonitor(window); + } else { + NSRect contentRect = NSMakeRect( + xpos, _glfwTransformYCocoa(ypos + height - 1), width, height); + NSRect frameRect = [window->ns.object frameRectForContentRect:contentRect + styleMask:styleMask]; + [window->ns.object setFrame:frameRect display:YES]; - if (window->numer != GLFW_DONT_CARE && - window->denom != GLFW_DONT_CARE) - { - [window->ns.object setContentAspectRatio:NSMakeSize(window->numer, - window->denom)]; - } + if (window->numer != GLFW_DONT_CARE && window->denom != GLFW_DONT_CARE) { + [window->ns.object + setContentAspectRatio:NSMakeSize(window->numer, window->denom)]; + } - if (window->minwidth != GLFW_DONT_CARE && - window->minheight != GLFW_DONT_CARE) - { - [window->ns.object setContentMinSize:NSMakeSize(window->minwidth, - window->minheight)]; - } + if (window->minwidth != GLFW_DONT_CARE && + window->minheight != GLFW_DONT_CARE) { + [window->ns.object + setContentMinSize:NSMakeSize(window->minwidth, window->minheight)]; + } - if (window->maxwidth != GLFW_DONT_CARE && - window->maxheight != GLFW_DONT_CARE) - { - [window->ns.object setContentMaxSize:NSMakeSize(window->maxwidth, - window->maxheight)]; - } + if (window->maxwidth != GLFW_DONT_CARE && + window->maxheight != GLFW_DONT_CARE) { + [window->ns.object + setContentMaxSize:NSMakeSize(window->maxwidth, window->maxheight)]; + } - if (window->floating) - [window->ns.object setLevel:NSFloatingWindowLevel]; - else - [window->ns.object setLevel:NSNormalWindowLevel]; + if (window->floating) + [window->ns.object setLevel:NSFloatingWindowLevel]; + else + [window->ns.object setLevel:NSNormalWindowLevel]; - if (window->resizable) - { - const NSWindowCollectionBehavior behavior = + if (window->resizable) { + const NSWindowCollectionBehavior behavior = NSWindowCollectionBehaviorFullScreenPrimary | NSWindowCollectionBehaviorManaged; - [window->ns.object setCollectionBehavior:behavior]; - } - else - { - const NSWindowCollectionBehavior behavior = + [window->ns.object setCollectionBehavior:behavior]; + } else { + const NSWindowCollectionBehavior behavior = NSWindowCollectionBehaviorFullScreenNone; - [window->ns.object setCollectionBehavior:behavior]; - } + [window->ns.object setCollectionBehavior:behavior]; + } - [window->ns.object setHasShadow:YES]; - // HACK: Clearing NSWindowStyleMaskTitled resets and disables the window - // title property but the miniwindow title property is unaffected - [window->ns.object setTitle:[window->ns.object miniwindowTitle]]; + [window->ns.object setHasShadow:YES]; + // HACK: Clearing NSWindowStyleMaskTitled resets and disables the window + // title property but the miniwindow title property is unaffected + [window->ns.object setTitle:[window->ns.object miniwindowTitle]]; } - } // autoreleasepool + }// autoreleasepool } -GLFWbool _glfwWindowFocusedCocoa(_GLFWwindow* window) -{ - @autoreleasepool { +GLFWbool _glfwWindowFocusedCocoa(_GLFWwindow *window) { + @autoreleasepool { return [window->ns.object isKeyWindow]; - } // autoreleasepool + }// autoreleasepool } -GLFWbool _glfwWindowIconifiedCocoa(_GLFWwindow* window) -{ - @autoreleasepool { +GLFWbool _glfwWindowIconifiedCocoa(_GLFWwindow *window) { + @autoreleasepool { return [window->ns.object isMiniaturized]; - } // autoreleasepool + }// autoreleasepool } -GLFWbool _glfwWindowVisibleCocoa(_GLFWwindow* window) -{ - @autoreleasepool { +GLFWbool _glfwWindowVisibleCocoa(_GLFWwindow *window) { + @autoreleasepool { return [window->ns.object isVisible]; - } // autoreleasepool + }// autoreleasepool } -GLFWbool _glfwWindowMaximizedCocoa(_GLFWwindow* window) -{ - @autoreleasepool { +GLFWbool _glfwWindowMaximizedCocoa(_GLFWwindow *window) { + @autoreleasepool { if (window->resizable) - return [window->ns.object isZoomed]; + return [window->ns.object isZoomed]; else - return GLFW_FALSE; + return GLFW_FALSE; - } // autoreleasepool + }// autoreleasepool } -GLFWbool _glfwWindowHoveredCocoa(_GLFWwindow* window) -{ - @autoreleasepool { +GLFWbool _glfwWindowHoveredCocoa(_GLFWwindow *window) { + @autoreleasepool { const NSPoint point = [NSEvent mouseLocation]; if ([NSWindow windowNumberAtPoint:point belowWindowWithWindowNumber:0] != - [window->ns.object windowNumber]) - { - return GLFW_FALSE; + [window->ns.object windowNumber]) { + return GLFW_FALSE; } - return NSMouseInRect(point, - [window->ns.object convertRectToScreen:[window->ns.view frame]], NO); + return NSMouseInRect( + point, [window->ns.object convertRectToScreen:[window->ns.view frame]], + NO); - } // autoreleasepool + }// autoreleasepool } -GLFWbool _glfwFramebufferTransparentCocoa(_GLFWwindow* window) -{ - @autoreleasepool { +GLFWbool _glfwFramebufferTransparentCocoa(_GLFWwindow *window) { + @autoreleasepool { return ![window->ns.object isOpaque] && ![window->ns.view isOpaque]; - } // autoreleasepool + }// autoreleasepool } -void _glfwSetWindowResizableCocoa(_GLFWwindow* window, GLFWbool enabled) -{ - @autoreleasepool { +void _glfwSetWindowResizableCocoa(_GLFWwindow *window, GLFWbool enabled) { + @autoreleasepool { const NSUInteger styleMask = [window->ns.object styleMask]; - if (enabled) - { - [window->ns.object setStyleMask:(styleMask | NSWindowStyleMaskResizable)]; - const NSWindowCollectionBehavior behavior = - NSWindowCollectionBehaviorFullScreenPrimary | - NSWindowCollectionBehaviorManaged; - [window->ns.object setCollectionBehavior:behavior]; - } - else - { - [window->ns.object setStyleMask:(styleMask & ~NSWindowStyleMaskResizable)]; - const NSWindowCollectionBehavior behavior = - NSWindowCollectionBehaviorFullScreenNone; - [window->ns.object setCollectionBehavior:behavior]; + if (enabled) { + [window->ns.object setStyleMask:(styleMask | NSWindowStyleMaskResizable)]; + const NSWindowCollectionBehavior behavior = + NSWindowCollectionBehaviorFullScreenPrimary | + NSWindowCollectionBehaviorManaged; + [window->ns.object setCollectionBehavior:behavior]; + } else { + [window->ns.object + setStyleMask:(styleMask & ~NSWindowStyleMaskResizable)]; + const NSWindowCollectionBehavior behavior = + NSWindowCollectionBehaviorFullScreenNone; + [window->ns.object setCollectionBehavior:behavior]; } - } // autoreleasepool + }// autoreleasepool } -void _glfwSetWindowDecoratedCocoa(_GLFWwindow* window, GLFWbool enabled) -{ - @autoreleasepool { +void _glfwSetWindowDecoratedCocoa(_GLFWwindow *window, GLFWbool enabled) { + @autoreleasepool { - NSUInteger styleMask = [window->ns.object styleMask]; - if (enabled) - { - styleMask |= (NSWindowStyleMaskTitled | NSWindowStyleMaskClosable); - styleMask &= ~NSWindowStyleMaskBorderless; - } - else - { - styleMask |= NSWindowStyleMaskBorderless; - styleMask &= ~(NSWindowStyleMaskTitled | NSWindowStyleMaskClosable); - } - - [window->ns.object setStyleMask:styleMask]; - [window->ns.object makeFirstResponder:window->ns.view]; - - } // autoreleasepool + NSUInteger styleMask = [window->ns.object styleMask]; + if (enabled) { + styleMask |= (NSWindowStyleMaskTitled | NSWindowStyleMaskClosable); + styleMask &= ~NSWindowStyleMaskBorderless; + } else { + styleMask |= NSWindowStyleMaskBorderless; + styleMask &= ~(NSWindowStyleMaskTitled | NSWindowStyleMaskClosable); + } + [window->ns.object setStyleMask:styleMask]; + [window->ns.object makeFirstResponder:window->ns.view]; + } } -void _glfwSetWindowFloatingCocoa(_GLFWwindow* window, GLFWbool enabled) -{ - @autoreleasepool { +void _glfwSetWindowTitlebarCocoa(_GLFWwindow *window, GLFWbool enabled) { + @autoreleasepool { + if (!enabled) { + NSWindow *m_nsWindow = window->ns.object; + m_nsWindow.opaque = false; + m_nsWindow.hasShadow = false; + m_nsWindow.backgroundColor = [NSColor clearColor]; + + m_nsWindow.titleVisibility = NSWindowTitleVisible; + m_nsWindow.titlebarAppearsTransparent = true; + m_nsWindow.styleMask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable | NSWindowStyleMaskFullSizeContentView; + m_nsWindow.titleVisibility = NSWindowTitleHidden; + } else { + NSWindow *m_nsWindow = window->ns.object; + + m_nsWindow.opaque = true; + m_nsWindow.hasShadow = true; + m_nsWindow.backgroundColor = [NSColor windowBackgroundColor]; + + m_nsWindow.titleVisibility = NSWindowTitleVisible; + m_nsWindow.titlebarAppearsTransparent = false; + m_nsWindow.styleMask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable | NSWindowStyleMaskFullSizeContentView; + m_nsWindow.titleVisibility = NSWindowTitleVisible; + } + }// autoreleasepool +} +// +void _glfwSetWindowFloatingCocoa(_GLFWwindow *window, GLFWbool enabled) { + @autoreleasepool { if (enabled) - [window->ns.object setLevel:NSFloatingWindowLevel]; + [window->ns.object setLevel:NSFloatingWindowLevel]; else - [window->ns.object setLevel:NSNormalWindowLevel]; - } // autoreleasepool + [window->ns.object setLevel:NSNormalWindowLevel]; + }// autoreleasepool } -void _glfwSetWindowMousePassthroughCocoa(_GLFWwindow* window, GLFWbool enabled) -{ - @autoreleasepool { +void _glfwSetWindowMousePassthroughCocoa(_GLFWwindow *window, + GLFWbool enabled) { + @autoreleasepool { [window->ns.object setIgnoresMouseEvents:enabled]; - } + } } -float _glfwGetWindowOpacityCocoa(_GLFWwindow* window) -{ - @autoreleasepool { +float _glfwGetWindowOpacityCocoa(_GLFWwindow *window) { + @autoreleasepool { return (float) [window->ns.object alphaValue]; - } // autoreleasepool + }// autoreleasepool } -void _glfwSetWindowOpacityCocoa(_GLFWwindow* window, float opacity) -{ - @autoreleasepool { +void _glfwSetWindowOpacityCocoa(_GLFWwindow *window, float opacity) { + @autoreleasepool { [window->ns.object setAlphaValue:opacity]; - } // autoreleasepool + }// autoreleasepool } -void _glfwSetRawMouseMotionCocoa(_GLFWwindow *window, GLFWbool enabled) -{ - _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED, - "Cocoa: Raw mouse motion not yet implemented"); +void _glfwSetRawMouseMotionCocoa(_GLFWwindow *window, GLFWbool enabled) { + _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED, + "Cocoa: Raw mouse motion not yet implemented"); } -GLFWbool _glfwRawMouseMotionSupportedCocoa(void) -{ - return GLFW_FALSE; -} +GLFWbool _glfwRawMouseMotionSupportedCocoa(void) { return GLFW_FALSE; } -void _glfwPollEventsCocoa(void) -{ - @autoreleasepool { +void _glfwPollEventsCocoa(void) { + @autoreleasepool { + for (;;) { + NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny + untilDate:[NSDate distantPast] + inMode:NSDefaultRunLoopMode + dequeue:YES]; + if (event == nil) + break; - for (;;) - { - NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny - untilDate:[NSDate distantPast] - inMode:NSDefaultRunLoopMode - dequeue:YES]; - if (event == nil) - break; - - [NSApp sendEvent:event]; + [NSApp sendEvent:event]; } - } // autoreleasepool + }// autoreleasepool } -void _glfwWaitEventsCocoa(void) -{ - @autoreleasepool { +void _glfwWaitEventsCocoa(void) { + @autoreleasepool { // I wanted to pass NO to dequeue:, and rely on PollEvents to // dequeue and send. For reasons not at all clear to me, passing @@ -1549,31 +1384,29 @@ void _glfwWaitEventsCocoa(void) _glfwPollEventsCocoa(); - } // autoreleasepool + }// autoreleasepool } -void _glfwWaitEventsTimeoutCocoa(double timeout) -{ - @autoreleasepool { +void _glfwWaitEventsTimeoutCocoa(double timeout) { + @autoreleasepool { - NSDate* date = [NSDate dateWithTimeIntervalSinceNow:timeout]; - NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny + NSDate *date = [NSDate dateWithTimeIntervalSinceNow:timeout]; + NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:date inMode:NSDefaultRunLoopMode dequeue:YES]; if (event) - [NSApp sendEvent:event]; + [NSApp sendEvent:event]; _glfwPollEventsCocoa(); - } // autoreleasepool + }// autoreleasepool } -void _glfwPostEmptyEventCocoa(void) -{ - @autoreleasepool { +void _glfwPostEmptyEventCocoa(void) { + @autoreleasepool { - NSEvent* event = [NSEvent otherEventWithType:NSEventTypeApplicationDefined + NSEvent *event = [NSEvent otherEventWithType:NSEventTypeApplicationDefined location:NSMakePoint(0, 0) modifierFlags:0 timestamp:0 @@ -1584,28 +1417,26 @@ void _glfwPostEmptyEventCocoa(void) data2:0]; [NSApp postEvent:event atStart:YES]; - } // autoreleasepool + }// autoreleasepool } -void _glfwGetCursorPosCocoa(_GLFWwindow* window, double* xpos, double* ypos) -{ - @autoreleasepool { +void _glfwGetCursorPosCocoa(_GLFWwindow *window, double *xpos, double *ypos) { + @autoreleasepool { const NSRect contentRect = [window->ns.view frame]; // NOTE: The returned location uses base 0,1 not 0,0 const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream]; if (xpos) - *xpos = pos.x; + *xpos = pos.x; if (ypos) - *ypos = contentRect.size.height - pos.y; + *ypos = contentRect.size.height - pos.y; - } // autoreleasepool + }// autoreleasepool } -void _glfwSetCursorPosCocoa(_GLFWwindow* window, double x, double y) -{ - @autoreleasepool { +void _glfwSetCursorPosCocoa(_GLFWwindow *window, double x, double y) { + @autoreleasepool { updateCursorImage(window); @@ -1616,54 +1447,49 @@ void _glfwSetCursorPosCocoa(_GLFWwindow* window, double x, double y) window->ns.cursorWarpDeltaX += x - pos.x; window->ns.cursorWarpDeltaY += y - contentRect.size.height + pos.y; - if (window->monitor) - { - CGDisplayMoveCursorToPoint(window->monitor->ns.displayID, - CGPointMake(x, y)); - } - else - { - const NSRect localRect = NSMakeRect(x, contentRect.size.height - y - 1, 0, 0); - const NSRect globalRect = [window->ns.object convertRectToScreen:localRect]; - const NSPoint globalPoint = globalRect.origin; + if (window->monitor) { + CGDisplayMoveCursorToPoint(window->monitor->ns.displayID, + CGPointMake(x, y)); + } else { + const NSRect localRect = + NSMakeRect(x, contentRect.size.height - y - 1, 0, 0); + const NSRect globalRect = + [window->ns.object convertRectToScreen:localRect]; + const NSPoint globalPoint = globalRect.origin; - CGWarpMouseCursorPosition(CGPointMake(globalPoint.x, - _glfwTransformYCocoa(globalPoint.y))); + CGWarpMouseCursorPosition( + CGPointMake(globalPoint.x, _glfwTransformYCocoa(globalPoint.y))); } // HACK: Calling this right after setting the cursor position prevents macOS // from freezing the cursor for a fraction of a second afterwards if (window->cursorMode != GLFW_CURSOR_DISABLED) - CGAssociateMouseAndMouseCursorPosition(true); + CGAssociateMouseAndMouseCursorPosition(true); - } // autoreleasepool + }// autoreleasepool } -void _glfwSetCursorModeCocoa(_GLFWwindow* window, int mode) -{ - @autoreleasepool { +void _glfwSetCursorModeCocoa(_GLFWwindow *window, int mode) { + @autoreleasepool { - if (mode == GLFW_CURSOR_CAPTURED) - { - _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED, - "Cocoa: Captured cursor mode not yet implemented"); + if (mode == GLFW_CURSOR_CAPTURED) { + _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED, + "Cocoa: Captured cursor mode not yet implemented"); } if (_glfwWindowFocusedCocoa(window)) - updateCursorMode(window); + updateCursorMode(window); - } // autoreleasepool + }// autoreleasepool } -const char* _glfwGetScancodeNameCocoa(int scancode) -{ - @autoreleasepool { +const char *_glfwGetScancodeNameCocoa(int scancode) { + @autoreleasepool { if (scancode < 0 || scancode > 0xff || - _glfw.ns.keycodes[scancode] == GLFW_KEY_UNKNOWN) - { - _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode); - return NULL; + _glfw.ns.keycodes[scancode] == GLFW_KEY_UNKNOWN) { + _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode); + return NULL; } const int key = _glfw.ns.keycodes[scancode]; @@ -1672,205 +1498,183 @@ const char* _glfwGetScancodeNameCocoa(int scancode) UniChar characters[4]; UniCharCount characterCount = 0; - if (UCKeyTranslate([(NSData*) _glfw.ns.unicodeData bytes], - scancode, - kUCKeyActionDisplay, - 0, - LMGetKbdType(), - kUCKeyTranslateNoDeadKeysBit, - &deadKeyState, + if (UCKeyTranslate([(NSData *) _glfw.ns.unicodeData bytes], scancode, + kUCKeyActionDisplay, 0, LMGetKbdType(), + kUCKeyTranslateNoDeadKeysBit, &deadKeyState, sizeof(characters) / sizeof(characters[0]), - &characterCount, - characters) != noErr) - { - return NULL; + &characterCount, characters) != noErr) { + return NULL; } if (!characterCount) - return NULL; + return NULL; - CFStringRef string = CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, - characters, - characterCount, - kCFAllocatorNull); - CFStringGetCString(string, - _glfw.ns.keynames[key], - sizeof(_glfw.ns.keynames[key]), - kCFStringEncodingUTF8); + CFStringRef string = CFStringCreateWithCharactersNoCopy( + kCFAllocatorDefault, characters, characterCount, kCFAllocatorNull); + CFStringGetCString(string, _glfw.ns.keynames[key], + sizeof(_glfw.ns.keynames[key]), kCFStringEncodingUTF8); CFRelease(string); return _glfw.ns.keynames[key]; - } // autoreleasepool + }// autoreleasepool } -int _glfwGetKeyScancodeCocoa(int key) -{ - return _glfw.ns.scancodes[key]; -} +int _glfwGetKeyScancodeCocoa(int key) { return _glfw.ns.scancodes[key]; } -GLFWbool _glfwCreateCursorCocoa(_GLFWcursor* cursor, - const GLFWimage* image, - int xhot, int yhot) -{ - @autoreleasepool { +GLFWbool _glfwCreateCursorCocoa(_GLFWcursor *cursor, const GLFWimage *image, + int xhot, int yhot) { + @autoreleasepool { - NSImage* native; - NSBitmapImageRep* rep; + NSImage *native; + NSBitmapImageRep *rep; rep = [[NSBitmapImageRep alloc] - initWithBitmapDataPlanes:NULL - pixelsWide:image->width - pixelsHigh:image->height - bitsPerSample:8 - samplesPerPixel:4 - hasAlpha:YES - isPlanar:NO - colorSpaceName:NSCalibratedRGBColorSpace - bitmapFormat:NSBitmapFormatAlphaNonpremultiplied - bytesPerRow:image->width * 4 - bitsPerPixel:32]; + initWithBitmapDataPlanes:NULL + pixelsWide:image->width + pixelsHigh:image->height + bitsPerSample:8 + samplesPerPixel:4 + hasAlpha:YES + isPlanar:NO + colorSpaceName:NSCalibratedRGBColorSpace + bitmapFormat:NSBitmapFormatAlphaNonpremultiplied + bytesPerRow:image->width * 4 + bitsPerPixel:32]; if (rep == nil) - return GLFW_FALSE; + return GLFW_FALSE; - memcpy([rep bitmapData], image->pixels, image->width * image->height * 4); + memcpy([rep bitmapData], image -> pixels, + image -> width * image -> height * 4); - native = [[NSImage alloc] initWithSize:NSMakeSize(image->width, image->height)]; + native = + [[NSImage alloc] initWithSize:NSMakeSize(image->width, image->height)]; [native addRepresentation:rep]; - cursor->ns.object = [[NSCursor alloc] initWithImage:native - hotSpot:NSMakePoint(xhot, yhot)]; + cursor->ns.object = + [[NSCursor alloc] initWithImage:native + hotSpot:NSMakePoint(xhot, yhot)]; [native release]; [rep release]; if (cursor->ns.object == nil) - return GLFW_FALSE; + return GLFW_FALSE; return GLFW_TRUE; - } // autoreleasepool + }// autoreleasepool } -GLFWbool _glfwCreateStandardCursorCocoa(_GLFWcursor* cursor, int shape) -{ - @autoreleasepool { +GLFWbool _glfwCreateStandardCursorCocoa(_GLFWcursor *cursor, int shape) { + @autoreleasepool { SEL cursorSelector = NULL; // HACK: Try to use a private message - switch (shape) - { + switch (shape) { + case GLFW_RESIZE_EW_CURSOR: + cursorSelector = NSSelectorFromString(@"_windowResizeEastWestCursor"); + break; + case GLFW_RESIZE_NS_CURSOR: + cursorSelector = NSSelectorFromString(@"_windowResizeNorthSouthCursor"); + break; + case GLFW_RESIZE_NWSE_CURSOR: + cursorSelector = + NSSelectorFromString(@"_windowResizeNorthWestSouthEastCursor"); + break; + case GLFW_RESIZE_NESW_CURSOR: + cursorSelector = + NSSelectorFromString(@"_windowResizeNorthEastSouthWestCursor"); + break; + } + + if (cursorSelector && [NSCursor respondsToSelector:cursorSelector]) { + id object = [NSCursor performSelector:cursorSelector]; + if ([object isKindOfClass:[NSCursor class]]) + cursor->ns.object = object; + } + + if (!cursor->ns.object) { + switch (shape) { + case GLFW_ARROW_CURSOR: + cursor->ns.object = [NSCursor arrowCursor]; + break; + case GLFW_IBEAM_CURSOR: + cursor->ns.object = [NSCursor IBeamCursor]; + break; + case GLFW_CROSSHAIR_CURSOR: + cursor->ns.object = [NSCursor crosshairCursor]; + break; + case GLFW_POINTING_HAND_CURSOR: + cursor->ns.object = [NSCursor pointingHandCursor]; + break; case GLFW_RESIZE_EW_CURSOR: - cursorSelector = NSSelectorFromString(@"_windowResizeEastWestCursor"); - break; + cursor->ns.object = [NSCursor resizeLeftRightCursor]; + break; case GLFW_RESIZE_NS_CURSOR: - cursorSelector = NSSelectorFromString(@"_windowResizeNorthSouthCursor"); - break; - case GLFW_RESIZE_NWSE_CURSOR: - cursorSelector = NSSelectorFromString(@"_windowResizeNorthWestSouthEastCursor"); - break; - case GLFW_RESIZE_NESW_CURSOR: - cursorSelector = NSSelectorFromString(@"_windowResizeNorthEastSouthWestCursor"); - break; + cursor->ns.object = [NSCursor resizeUpDownCursor]; + break; + case GLFW_RESIZE_ALL_CURSOR: + cursor->ns.object = [NSCursor closedHandCursor]; + break; + case GLFW_NOT_ALLOWED_CURSOR: + cursor->ns.object = [NSCursor operationNotAllowedCursor]; + break; + } } - if (cursorSelector && [NSCursor respondsToSelector:cursorSelector]) - { - id object = [NSCursor performSelector:cursorSelector]; - if ([object isKindOfClass:[NSCursor class]]) - cursor->ns.object = object; - } - - if (!cursor->ns.object) - { - switch (shape) - { - case GLFW_ARROW_CURSOR: - cursor->ns.object = [NSCursor arrowCursor]; - break; - case GLFW_IBEAM_CURSOR: - cursor->ns.object = [NSCursor IBeamCursor]; - break; - case GLFW_CROSSHAIR_CURSOR: - cursor->ns.object = [NSCursor crosshairCursor]; - break; - case GLFW_POINTING_HAND_CURSOR: - cursor->ns.object = [NSCursor pointingHandCursor]; - break; - case GLFW_RESIZE_EW_CURSOR: - cursor->ns.object = [NSCursor resizeLeftRightCursor]; - break; - case GLFW_RESIZE_NS_CURSOR: - cursor->ns.object = [NSCursor resizeUpDownCursor]; - break; - case GLFW_RESIZE_ALL_CURSOR: - cursor->ns.object = [NSCursor closedHandCursor]; - break; - case GLFW_NOT_ALLOWED_CURSOR: - cursor->ns.object = [NSCursor operationNotAllowedCursor]; - break; - } - } - - if (!cursor->ns.object) - { - _glfwInputError(GLFW_CURSOR_UNAVAILABLE, - "Cocoa: Standard cursor shape unavailable"); - return GLFW_FALSE; + if (!cursor->ns.object) { + _glfwInputError(GLFW_CURSOR_UNAVAILABLE, + "Cocoa: Standard cursor shape unavailable"); + return GLFW_FALSE; } [cursor->ns.object retain]; return GLFW_TRUE; - } // autoreleasepool + }// autoreleasepool } -void _glfwDestroyCursorCocoa(_GLFWcursor* cursor) -{ - @autoreleasepool { +void _glfwDestroyCursorCocoa(_GLFWcursor *cursor) { + @autoreleasepool { if (cursor->ns.object) - [(NSCursor*) cursor->ns.object release]; - } // autoreleasepool + [(NSCursor *) cursor->ns.object release]; + }// autoreleasepool } -void _glfwSetCursorCocoa(_GLFWwindow* window, _GLFWcursor* cursor) -{ - @autoreleasepool { +void _glfwSetCursorCocoa(_GLFWwindow *window, _GLFWcursor *cursor) { + @autoreleasepool { if (cursorInContentArea(window)) - updateCursorImage(window); - } // autoreleasepool + updateCursorImage(window); + }// autoreleasepool } -void _glfwSetClipboardStringCocoa(const char* string) -{ - @autoreleasepool { - NSPasteboard* pasteboard = [NSPasteboard generalPasteboard]; +void _glfwSetClipboardStringCocoa(const char *string) { + @autoreleasepool { + NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; [pasteboard declareTypes:@[NSPasteboardTypeString] owner:nil]; [pasteboard setString:@(string) forType:NSPasteboardTypeString]; - } // autoreleasepool + }// autoreleasepool } -const char* _glfwGetClipboardStringCocoa(void) -{ - @autoreleasepool { +const char *_glfwGetClipboardStringCocoa(void) { + @autoreleasepool { - NSPasteboard* pasteboard = [NSPasteboard generalPasteboard]; + NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; - if (![[pasteboard types] containsObject:NSPasteboardTypeString]) - { - _glfwInputError(GLFW_FORMAT_UNAVAILABLE, - "Cocoa: Failed to retrieve string from pasteboard"); - return NULL; + if (![[pasteboard types] containsObject:NSPasteboardTypeString]) { + _glfwInputError(GLFW_FORMAT_UNAVAILABLE, + "Cocoa: Failed to retrieve string from pasteboard"); + return NULL; } - NSString* object = [pasteboard stringForType:NSPasteboardTypeString]; - if (!object) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Cocoa: Failed to retrieve object from pasteboard"); - return NULL; + NSString *object = [pasteboard stringForType:NSPasteboardTypeString]; + if (!object) { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Cocoa: Failed to retrieve object from pasteboard"); + return NULL; } _glfw_free(_glfw.ns.clipboardString); @@ -1878,152 +1682,136 @@ const char* _glfwGetClipboardStringCocoa(void) return _glfw.ns.clipboardString; - } // autoreleasepool + }// autoreleasepool } -EGLenum _glfwGetEGLPlatformCocoa(EGLint** attribs) -{ - if (_glfw.egl.ANGLE_platform_angle) - { - int type = 0; +EGLenum _glfwGetEGLPlatformCocoa(EGLint **attribs) { + if (_glfw.egl.ANGLE_platform_angle) { + int type = 0; - if (_glfw.egl.ANGLE_platform_angle_opengl) - { - if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_OPENGL) - type = EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE; - } - - if (_glfw.egl.ANGLE_platform_angle_metal) - { - if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_METAL) - type = EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE; - } - - if (type) - { - *attribs = _glfw_calloc(3, sizeof(EGLint)); - (*attribs)[0] = EGL_PLATFORM_ANGLE_TYPE_ANGLE; - (*attribs)[1] = type; - (*attribs)[2] = EGL_NONE; - return EGL_PLATFORM_ANGLE_ANGLE; - } + if (_glfw.egl.ANGLE_platform_angle_opengl) { + if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_OPENGL) + type = EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE; } - return 0; -} - -EGLNativeDisplayType _glfwGetEGLNativeDisplayCocoa(void) -{ - return EGL_DEFAULT_DISPLAY; -} - -EGLNativeWindowType _glfwGetEGLNativeWindowCocoa(_GLFWwindow* window) -{ - return window->ns.layer; -} - -void _glfwGetRequiredInstanceExtensionsCocoa(char** extensions) -{ - if (_glfw.vk.KHR_surface && _glfw.vk.EXT_metal_surface) - { - extensions[0] = "VK_KHR_surface"; - extensions[1] = "VK_EXT_metal_surface"; + if (_glfw.egl.ANGLE_platform_angle_metal) { + if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_METAL) + type = EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE; } - else if (_glfw.vk.KHR_surface && _glfw.vk.MVK_macos_surface) - { - extensions[0] = "VK_KHR_surface"; - extensions[1] = "VK_MVK_macos_surface"; + + if (type) { + *attribs = _glfw_calloc(3, sizeof(EGLint)); + (*attribs)[0] = EGL_PLATFORM_ANGLE_TYPE_ANGLE; + (*attribs)[1] = type; + (*attribs)[2] = EGL_NONE; + return EGL_PLATFORM_ANGLE_ANGLE; } + } + + return 0; +} + +EGLNativeDisplayType _glfwGetEGLNativeDisplayCocoa(void) { + return EGL_DEFAULT_DISPLAY; +} + +EGLNativeWindowType _glfwGetEGLNativeWindowCocoa(_GLFWwindow *window) { + return window->ns.layer; +} + +void _glfwGetRequiredInstanceExtensionsCocoa(char **extensions) { + if (_glfw.vk.KHR_surface && _glfw.vk.EXT_metal_surface) { + extensions[0] = "VK_KHR_surface"; + extensions[1] = "VK_EXT_metal_surface"; + } else if (_glfw.vk.KHR_surface && _glfw.vk.MVK_macos_surface) { + extensions[0] = "VK_KHR_surface"; + extensions[1] = "VK_MVK_macos_surface"; + } } GLFWbool _glfwGetPhysicalDevicePresentationSupportCocoa(VkInstance instance, VkPhysicalDevice device, - uint32_t queuefamily) -{ - return GLFW_TRUE; + uint32_t queuefamily) { + return GLFW_TRUE; } -VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance, - _GLFWwindow* window, - const VkAllocationCallbacks* allocator, - VkSurfaceKHR* surface) -{ - @autoreleasepool { +VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance, _GLFWwindow *window, + const VkAllocationCallbacks *allocator, + VkSurfaceKHR *surface) { + @autoreleasepool { #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101100 // HACK: Dynamically load Core Animation to avoid adding an extra // dependency for the majority who don't use MoltenVK - NSBundle* bundle = [NSBundle bundleWithPath:@"/System/Library/Frameworks/QuartzCore.framework"]; - if (!bundle) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Cocoa: Failed to find QuartzCore.framework"); - return VK_ERROR_EXTENSION_NOT_PRESENT; + NSBundle *bundle = [NSBundle + bundleWithPath:@"/System/Library/Frameworks/QuartzCore.framework"]; + if (!bundle) { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Cocoa: Failed to find QuartzCore.framework"); + return VK_ERROR_EXTENSION_NOT_PRESENT; } // NOTE: Create the layer here as makeBackingLayer should not return nil window->ns.layer = [[bundle classNamed:@"CAMetalLayer"] layer]; - if (!window->ns.layer) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Cocoa: Failed to create layer for view"); - return VK_ERROR_EXTENSION_NOT_PRESENT; + if (!window->ns.layer) { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Cocoa: Failed to create layer for view"); + return VK_ERROR_EXTENSION_NOT_PRESENT; } if (window->ns.retina) - [window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]]; + [window->ns.layer + setContentsScale:[window->ns.object backingScaleFactor]]; [window->ns.view setLayer:window->ns.layer]; [window->ns.view setWantsLayer:YES]; VkResult err; - if (_glfw.vk.EXT_metal_surface) - { - VkMetalSurfaceCreateInfoEXT sci; + if (_glfw.vk.EXT_metal_surface) { + VkMetalSurfaceCreateInfoEXT sci; - PFN_vkCreateMetalSurfaceEXT vkCreateMetalSurfaceEXT; - vkCreateMetalSurfaceEXT = (PFN_vkCreateMetalSurfaceEXT) - vkGetInstanceProcAddr(instance, "vkCreateMetalSurfaceEXT"); - if (!vkCreateMetalSurfaceEXT) - { - _glfwInputError(GLFW_API_UNAVAILABLE, - "Cocoa: Vulkan instance missing VK_EXT_metal_surface extension"); - return VK_ERROR_EXTENSION_NOT_PRESENT; - } + PFN_vkCreateMetalSurfaceEXT vkCreateMetalSurfaceEXT; + vkCreateMetalSurfaceEXT = + (PFN_vkCreateMetalSurfaceEXT) vkGetInstanceProcAddr( + instance, "vkCreateMetalSurfaceEXT"); + if (!vkCreateMetalSurfaceEXT) { + _glfwInputError( + GLFW_API_UNAVAILABLE, + "Cocoa: Vulkan instance missing VK_EXT_metal_surface extension"); + return VK_ERROR_EXTENSION_NOT_PRESENT; + } - memset(&sci, 0, sizeof(sci)); - sci.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT; - sci.pLayer = window->ns.layer; + memset(&sci, 0, sizeof(sci)); + sci.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT; + sci.pLayer = window->ns.layer; - err = vkCreateMetalSurfaceEXT(instance, &sci, allocator, surface); - } - else - { - VkMacOSSurfaceCreateInfoMVK sci; + err = vkCreateMetalSurfaceEXT(instance, &sci, allocator, surface); + } else { + VkMacOSSurfaceCreateInfoMVK sci; - PFN_vkCreateMacOSSurfaceMVK vkCreateMacOSSurfaceMVK; - vkCreateMacOSSurfaceMVK = (PFN_vkCreateMacOSSurfaceMVK) - vkGetInstanceProcAddr(instance, "vkCreateMacOSSurfaceMVK"); - if (!vkCreateMacOSSurfaceMVK) - { - _glfwInputError(GLFW_API_UNAVAILABLE, - "Cocoa: Vulkan instance missing VK_MVK_macos_surface extension"); - return VK_ERROR_EXTENSION_NOT_PRESENT; - } + PFN_vkCreateMacOSSurfaceMVK vkCreateMacOSSurfaceMVK; + vkCreateMacOSSurfaceMVK = + (PFN_vkCreateMacOSSurfaceMVK) vkGetInstanceProcAddr( + instance, "vkCreateMacOSSurfaceMVK"); + if (!vkCreateMacOSSurfaceMVK) { + _glfwInputError( + GLFW_API_UNAVAILABLE, + "Cocoa: Vulkan instance missing VK_MVK_macos_surface extension"); + return VK_ERROR_EXTENSION_NOT_PRESENT; + } - memset(&sci, 0, sizeof(sci)); - sci.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK; - sci.pView = window->ns.view; + memset(&sci, 0, sizeof(sci)); + sci.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK; + sci.pView = window->ns.view; - err = vkCreateMacOSSurfaceMVK(instance, &sci, allocator, surface); + err = vkCreateMacOSSurfaceMVK(instance, &sci, allocator, surface); } - if (err) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Cocoa: Failed to create Vulkan surface: %s", - _glfwGetVulkanResultString(err)); + if (err) { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Cocoa: Failed to create Vulkan surface: %s", + _glfwGetVulkanResultString(err)); } return err; @@ -2031,28 +1819,24 @@ VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance, return VK_ERROR_EXTENSION_NOT_PRESENT; #endif - } // autoreleasepool + }// autoreleasepool } - ////////////////////////////////////////////////////////////////////////// ////// GLFW native API ////// ////////////////////////////////////////////////////////////////////////// -GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle) -{ - _GLFWwindow* window = (_GLFWwindow*) handle; - _GLFW_REQUIRE_INIT_OR_RETURN(nil); +GLFWAPI id glfwGetCocoaWindow(GLFWwindow *handle) { + _GLFWwindow *window = (_GLFWwindow *) handle; + _GLFW_REQUIRE_INIT_OR_RETURN(nil); - if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA) - { - _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, - "Cocoa: Platform not initialized"); - return NULL; - } + if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA) { + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, + "Cocoa: Platform not initialized"); + return NULL; + } - return window->ns.object; + return window->ns.object; } -#endif // _GLFW_COCOA - +#endif// _GLFW_COCOA diff --git a/src/init.c b/src/init.c index 2db542f7..06dbb3f2 100644 --- a/src/init.c +++ b/src/init.c @@ -24,6 +24,8 @@ // distribution. // //======================================================================== +// Please use C89 style variable declarations in this file because VS 2010 +//======================================================================== #include "internal.h" diff --git a/src/internal.h b/src/internal.h index fe0369aa..badf0697 100644 --- a/src/internal.h +++ b/src/internal.h @@ -28,55 +28,50 @@ #pragma once #if defined(_GLFW_USE_CONFIG_H) - #include "glfw_config.h" +#include "glfw_config.h" #endif -#if defined(GLFW_INCLUDE_GLCOREARB) || \ - defined(GLFW_INCLUDE_ES1) || \ - defined(GLFW_INCLUDE_ES2) || \ - defined(GLFW_INCLUDE_ES3) || \ - defined(GLFW_INCLUDE_ES31) || \ - defined(GLFW_INCLUDE_ES32) || \ - defined(GLFW_INCLUDE_NONE) || \ - defined(GLFW_INCLUDE_GLEXT) || \ - defined(GLFW_INCLUDE_GLU) || \ - defined(GLFW_INCLUDE_VULKAN) || \ +#if defined(GLFW_INCLUDE_GLCOREARB) || defined(GLFW_INCLUDE_ES1) || \ + defined(GLFW_INCLUDE_ES2) || defined(GLFW_INCLUDE_ES3) || \ + defined(GLFW_INCLUDE_ES31) || defined(GLFW_INCLUDE_ES32) || \ + defined(GLFW_INCLUDE_NONE) || defined(GLFW_INCLUDE_GLEXT) || \ + defined(GLFW_INCLUDE_GLU) || defined(GLFW_INCLUDE_VULKAN) || \ defined(GLFW_DLL) - #error "You must not define any header option macros when compiling GLFW" +#error "You must not define any header option macros when compiling GLFW" #endif #define GLFW_INCLUDE_NONE #include "../include/GLFW/glfw3.h" -#define _GLFW_INSERT_FIRST 0 -#define _GLFW_INSERT_LAST 1 +#define _GLFW_INSERT_FIRST 0 +#define _GLFW_INSERT_LAST 1 -#define _GLFW_POLL_PRESENCE 0 -#define _GLFW_POLL_AXES 1 -#define _GLFW_POLL_BUTTONS 2 -#define _GLFW_POLL_ALL (_GLFW_POLL_AXES | _GLFW_POLL_BUTTONS) +#define _GLFW_POLL_PRESENCE 0 +#define _GLFW_POLL_AXES 1 +#define _GLFW_POLL_BUTTONS 2 +#define _GLFW_POLL_ALL (_GLFW_POLL_AXES | _GLFW_POLL_BUTTONS) -#define _GLFW_MESSAGE_SIZE 1024 +#define _GLFW_MESSAGE_SIZE 1024 typedef int GLFWbool; typedef void (*GLFWproc)(void); -typedef struct _GLFWerror _GLFWerror; -typedef struct _GLFWinitconfig _GLFWinitconfig; -typedef struct _GLFWwndconfig _GLFWwndconfig; -typedef struct _GLFWctxconfig _GLFWctxconfig; -typedef struct _GLFWfbconfig _GLFWfbconfig; -typedef struct _GLFWcontext _GLFWcontext; -typedef struct _GLFWwindow _GLFWwindow; -typedef struct _GLFWplatform _GLFWplatform; -typedef struct _GLFWlibrary _GLFWlibrary; -typedef struct _GLFWmonitor _GLFWmonitor; -typedef struct _GLFWcursor _GLFWcursor; -typedef struct _GLFWmapelement _GLFWmapelement; -typedef struct _GLFWmapping _GLFWmapping; -typedef struct _GLFWjoystick _GLFWjoystick; -typedef struct _GLFWtls _GLFWtls; -typedef struct _GLFWmutex _GLFWmutex; +typedef struct _GLFWerror _GLFWerror; +typedef struct _GLFWinitconfig _GLFWinitconfig; +typedef struct _GLFWwndconfig _GLFWwndconfig; +typedef struct _GLFWctxconfig _GLFWctxconfig; +typedef struct _GLFWfbconfig _GLFWfbconfig; +typedef struct _GLFWcontext _GLFWcontext; +typedef struct _GLFWwindow _GLFWwindow; +typedef struct _GLFWplatform _GLFWplatform; +typedef struct _GLFWlibrary _GLFWlibrary; +typedef struct _GLFWmonitor _GLFWmonitor; +typedef struct _GLFWcursor _GLFWcursor; +typedef struct _GLFWmapelement _GLFWmapelement; +typedef struct _GLFWmapping _GLFWmapping; +typedef struct _GLFWjoystick _GLFWjoystick; +typedef struct _GLFWtls _GLFWtls; +typedef struct _GLFWmutex _GLFWmutex; #define GL_VERSION 0x1f02 #define GL_NONE 0 @@ -103,15 +98,15 @@ typedef unsigned int GLenum; typedef unsigned int GLbitfield; typedef unsigned char GLubyte; -typedef void (APIENTRY * PFNGLCLEARPROC)(GLbitfield); -typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGPROC)(GLenum); -typedef void (APIENTRY * PFNGLGETINTEGERVPROC)(GLenum,GLint*); -typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint); +typedef void(APIENTRY *PFNGLCLEARPROC)(GLbitfield); +typedef const GLubyte *(APIENTRY *PFNGLGETSTRINGPROC)(GLenum); +typedef void(APIENTRY *PFNGLGETINTEGERVPROC)(GLenum, GLint *); +typedef const GLubyte *(APIENTRY *PFNGLGETSTRINGIPROC)(GLenum, GLuint); #if defined(_GLFW_WIN32) - #define EGLAPIENTRY __stdcall +#define EGLAPIENTRY __stdcall #else - #define EGLAPIENTRY +#define EGLAPIENTRY #endif #define EGL_SUCCESS 0x3000 @@ -152,10 +147,10 @@ typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint); #define EGL_EXTENSIONS 0x3055 #define EGL_CONTEXT_CLIENT_VERSION 0x3098 #define EGL_NATIVE_VISUAL_ID 0x302e -#define EGL_NO_SURFACE ((EGLSurface) 0) -#define EGL_NO_DISPLAY ((EGLDisplay) 0) -#define EGL_NO_CONTEXT ((EGLContext) 0) -#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType) 0) +#define EGL_NO_SURFACE ((EGLSurface)0) +#define EGL_NO_DISPLAY ((EGLDisplay)0) +#define EGL_NO_CONTEXT ((EGLContext)0) +#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0) #define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 #define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 @@ -191,31 +186,40 @@ typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint); typedef int EGLint; typedef unsigned int EGLBoolean; typedef unsigned int EGLenum; -typedef void* EGLConfig; -typedef void* EGLContext; -typedef void* EGLDisplay; -typedef void* EGLSurface; +typedef void *EGLConfig; +typedef void *EGLContext; +typedef void *EGLDisplay; +typedef void *EGLSurface; -typedef void* EGLNativeDisplayType; -typedef void* EGLNativeWindowType; +typedef void *EGLNativeDisplayType; +typedef void *EGLNativeWindowType; // EGL function pointer typedefs -typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*); -typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*); -typedef EGLDisplay (EGLAPIENTRY * PFN_eglGetDisplay)(EGLNativeDisplayType); -typedef EGLint (EGLAPIENTRY * PFN_eglGetError)(void); -typedef EGLBoolean (EGLAPIENTRY * PFN_eglInitialize)(EGLDisplay,EGLint*,EGLint*); -typedef EGLBoolean (EGLAPIENTRY * PFN_eglTerminate)(EGLDisplay); -typedef EGLBoolean (EGLAPIENTRY * PFN_eglBindAPI)(EGLenum); -typedef EGLContext (EGLAPIENTRY * PFN_eglCreateContext)(EGLDisplay,EGLConfig,EGLContext,const EGLint*); -typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroySurface)(EGLDisplay,EGLSurface); -typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroyContext)(EGLDisplay,EGLContext); -typedef EGLSurface (EGLAPIENTRY * PFN_eglCreateWindowSurface)(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*); -typedef EGLBoolean (EGLAPIENTRY * PFN_eglMakeCurrent)(EGLDisplay,EGLSurface,EGLSurface,EGLContext); -typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface); -typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint); -typedef const char* (EGLAPIENTRY * PFN_eglQueryString)(EGLDisplay,EGLint); -typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*); +typedef EGLBoolean(EGLAPIENTRY *PFN_eglGetConfigAttrib)(EGLDisplay, EGLConfig, + EGLint, EGLint *); +typedef EGLBoolean(EGLAPIENTRY *PFN_eglGetConfigs)(EGLDisplay, EGLConfig *, + EGLint, EGLint *); +typedef EGLDisplay(EGLAPIENTRY *PFN_eglGetDisplay)(EGLNativeDisplayType); +typedef EGLint(EGLAPIENTRY *PFN_eglGetError)(void); +typedef EGLBoolean(EGLAPIENTRY *PFN_eglInitialize)(EGLDisplay, EGLint *, + EGLint *); +typedef EGLBoolean(EGLAPIENTRY *PFN_eglTerminate)(EGLDisplay); +typedef EGLBoolean(EGLAPIENTRY *PFN_eglBindAPI)(EGLenum); +typedef EGLContext(EGLAPIENTRY *PFN_eglCreateContext)(EGLDisplay, EGLConfig, + EGLContext, + const EGLint *); +typedef EGLBoolean(EGLAPIENTRY *PFN_eglDestroySurface)(EGLDisplay, EGLSurface); +typedef EGLBoolean(EGLAPIENTRY *PFN_eglDestroyContext)(EGLDisplay, EGLContext); +typedef EGLSurface(EGLAPIENTRY *PFN_eglCreateWindowSurface)(EGLDisplay, + EGLConfig, + EGLNativeWindowType, + const EGLint *); +typedef EGLBoolean(EGLAPIENTRY *PFN_eglMakeCurrent)(EGLDisplay, EGLSurface, + EGLSurface, EGLContext); +typedef EGLBoolean(EGLAPIENTRY *PFN_eglSwapBuffers)(EGLDisplay, EGLSurface); +typedef EGLBoolean(EGLAPIENTRY *PFN_eglSwapInterval)(EGLDisplay, EGLint); +typedef const char *(EGLAPIENTRY *PFN_eglQueryString)(EGLDisplay, EGLint); +typedef GLFWglproc(EGLAPIENTRY *PFN_eglGetProcAddress)(const char *); #define eglGetConfigAttrib _glfw.egl.GetConfigAttrib #define eglGetConfigs _glfw.egl.GetConfigs #define eglGetDisplay _glfw.egl.GetDisplay @@ -233,10 +237,13 @@ typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*); #define eglQueryString _glfw.egl.QueryString #define eglGetProcAddress _glfw.egl.GetProcAddress -typedef EGLDisplay (EGLAPIENTRY * PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum,void*,const EGLint*); -typedef EGLSurface (EGLAPIENTRY * PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(EGLDisplay,EGLConfig,void*,const EGLint*); +typedef EGLDisplay(EGLAPIENTRY *PFNEGLGETPLATFORMDISPLAYEXTPROC)( + EGLenum, void *, const EGLint *); +typedef EGLSurface(EGLAPIENTRY *PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)( + EGLDisplay, EGLConfig, void *, const EGLint *); #define eglGetPlatformDisplayEXT _glfw.egl.GetPlatformDisplayEXT -#define eglCreatePlatformWindowSurfaceEXT _glfw.egl.CreatePlatformWindowSurfaceEXT +#define eglCreatePlatformWindowSurfaceEXT \ + _glfw.egl.CreatePlatformWindowSurfaceEXT #define OSMESA_RGBA 0x1908 #define OSMESA_FORMAT 0x22 @@ -249,16 +256,22 @@ typedef EGLSurface (EGLAPIENTRY * PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(EGLD #define OSMESA_CONTEXT_MAJOR_VERSION 0x36 #define OSMESA_CONTEXT_MINOR_VERSION 0x37 -typedef void* OSMesaContext; +typedef void *OSMesaContext; typedef void (*OSMESAproc)(void); -typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextExt)(GLenum,GLint,GLint,GLint,OSMesaContext); -typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextAttribs)(const int*,OSMesaContext); -typedef void (GLAPIENTRY * PFN_OSMesaDestroyContext)(OSMesaContext); -typedef int (GLAPIENTRY * PFN_OSMesaMakeCurrent)(OSMesaContext,void*,int,int,int); -typedef int (GLAPIENTRY * PFN_OSMesaGetColorBuffer)(OSMesaContext,int*,int*,int*,void**); -typedef int (GLAPIENTRY * PFN_OSMesaGetDepthBuffer)(OSMesaContext,int*,int*,int*,void**); -typedef GLFWglproc (GLAPIENTRY * PFN_OSMesaGetProcAddress)(const char*); +typedef OSMesaContext(GLAPIENTRY *PFN_OSMesaCreateContextExt)(GLenum, GLint, + GLint, GLint, + OSMesaContext); +typedef OSMesaContext(GLAPIENTRY *PFN_OSMesaCreateContextAttribs)( + const int *, OSMesaContext); +typedef void(GLAPIENTRY *PFN_OSMesaDestroyContext)(OSMesaContext); +typedef int(GLAPIENTRY *PFN_OSMesaMakeCurrent)(OSMesaContext, void *, int, int, + int); +typedef int(GLAPIENTRY *PFN_OSMesaGetColorBuffer)(OSMesaContext, int *, int *, + int *, void **); +typedef int(GLAPIENTRY *PFN_OSMesaGetDepthBuffer)(OSMesaContext, int *, int *, + int *, void **); +typedef GLFWglproc(GLAPIENTRY *PFN_OSMesaGetProcAddress)(const char *); #define OSMesaCreateContextExt _glfw.osmesa.CreateContextExt #define OSMesaCreateContextAttribs _glfw.osmesa.CreateContextAttribs #define OSMesaDestroyContext _glfw.osmesa.DestroyContext @@ -269,119 +282,114 @@ typedef GLFWglproc (GLAPIENTRY * PFN_OSMesaGetProcAddress)(const char*); #define VK_NULL_HANDLE 0 -typedef void* VkInstance; -typedef void* VkPhysicalDevice; +typedef void *VkInstance; +typedef void *VkPhysicalDevice; typedef uint64_t VkSurfaceKHR; typedef uint32_t VkFlags; typedef uint32_t VkBool32; -typedef enum VkStructureType -{ - VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR = 1000004000, - VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR = 1000005000, - VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR = 1000006000, - VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR = 1000009000, - VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK = 1000123000, - VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT = 1000217000, - VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF +typedef enum VkStructureType { + VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR = 1000004000, + VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR = 1000005000, + VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR = 1000006000, + VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR = 1000009000, + VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK = 1000123000, + VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT = 1000217000, + VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF } VkStructureType; -typedef enum VkResult -{ - VK_SUCCESS = 0, - VK_NOT_READY = 1, - VK_TIMEOUT = 2, - VK_EVENT_SET = 3, - VK_EVENT_RESET = 4, - VK_INCOMPLETE = 5, - VK_ERROR_OUT_OF_HOST_MEMORY = -1, - VK_ERROR_OUT_OF_DEVICE_MEMORY = -2, - VK_ERROR_INITIALIZATION_FAILED = -3, - VK_ERROR_DEVICE_LOST = -4, - VK_ERROR_MEMORY_MAP_FAILED = -5, - VK_ERROR_LAYER_NOT_PRESENT = -6, - VK_ERROR_EXTENSION_NOT_PRESENT = -7, - VK_ERROR_FEATURE_NOT_PRESENT = -8, - VK_ERROR_INCOMPATIBLE_DRIVER = -9, - VK_ERROR_TOO_MANY_OBJECTS = -10, - VK_ERROR_FORMAT_NOT_SUPPORTED = -11, - VK_ERROR_SURFACE_LOST_KHR = -1000000000, - VK_SUBOPTIMAL_KHR = 1000001003, - VK_ERROR_OUT_OF_DATE_KHR = -1000001004, - VK_ERROR_INCOMPATIBLE_DISPLAY_KHR = -1000003001, - VK_ERROR_NATIVE_WINDOW_IN_USE_KHR = -1000000001, - VK_ERROR_VALIDATION_FAILED_EXT = -1000011001, - VK_RESULT_MAX_ENUM = 0x7FFFFFFF +typedef enum VkResult { + VK_SUCCESS = 0, + VK_NOT_READY = 1, + VK_TIMEOUT = 2, + VK_EVENT_SET = 3, + VK_EVENT_RESET = 4, + VK_INCOMPLETE = 5, + VK_ERROR_OUT_OF_HOST_MEMORY = -1, + VK_ERROR_OUT_OF_DEVICE_MEMORY = -2, + VK_ERROR_INITIALIZATION_FAILED = -3, + VK_ERROR_DEVICE_LOST = -4, + VK_ERROR_MEMORY_MAP_FAILED = -5, + VK_ERROR_LAYER_NOT_PRESENT = -6, + VK_ERROR_EXTENSION_NOT_PRESENT = -7, + VK_ERROR_FEATURE_NOT_PRESENT = -8, + VK_ERROR_INCOMPATIBLE_DRIVER = -9, + VK_ERROR_TOO_MANY_OBJECTS = -10, + VK_ERROR_FORMAT_NOT_SUPPORTED = -11, + VK_ERROR_SURFACE_LOST_KHR = -1000000000, + VK_SUBOPTIMAL_KHR = 1000001003, + VK_ERROR_OUT_OF_DATE_KHR = -1000001004, + VK_ERROR_INCOMPATIBLE_DISPLAY_KHR = -1000003001, + VK_ERROR_NATIVE_WINDOW_IN_USE_KHR = -1000000001, + VK_ERROR_VALIDATION_FAILED_EXT = -1000011001, + VK_RESULT_MAX_ENUM = 0x7FFFFFFF } VkResult; typedef struct VkAllocationCallbacks VkAllocationCallbacks; -typedef struct VkExtensionProperties -{ - char extensionName[256]; - uint32_t specVersion; +typedef struct VkExtensionProperties { + char extensionName[256]; + uint32_t specVersion; } VkExtensionProperties; -typedef void (APIENTRY * PFN_vkVoidFunction)(void); +typedef void(APIENTRY *PFN_vkVoidFunction)(void); -typedef PFN_vkVoidFunction (APIENTRY * PFN_vkGetInstanceProcAddr)(VkInstance,const char*); -typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const char*,uint32_t*,VkExtensionProperties*); +typedef PFN_vkVoidFunction(APIENTRY *PFN_vkGetInstanceProcAddr)(VkInstance, + const char *); +typedef VkResult(APIENTRY *PFN_vkEnumerateInstanceExtensionProperties)( + const char *, uint32_t *, VkExtensionProperties *); #define vkGetInstanceProcAddr _glfw.vk.GetInstanceProcAddr #include "platform.h" // Checks for whether the library has been initialized -#define _GLFW_REQUIRE_INIT() \ - if (!_glfw.initialized) \ - { \ - _glfwInputError(GLFW_NOT_INITIALIZED, NULL); \ - return; \ - } -#define _GLFW_REQUIRE_INIT_OR_RETURN(x) \ - if (!_glfw.initialized) \ - { \ - _glfwInputError(GLFW_NOT_INITIALIZED, NULL); \ - return x; \ - } +#define _GLFW_REQUIRE_INIT() \ + if (!_glfw.initialized) { \ + _glfwInputError(GLFW_NOT_INITIALIZED, NULL); \ + return; \ + } +#define _GLFW_REQUIRE_INIT_OR_RETURN(x) \ + if (!_glfw.initialized) { \ + _glfwInputError(GLFW_NOT_INITIALIZED, NULL); \ + return x; \ + } // Swaps the provided pointers -#define _GLFW_SWAP(type, x, y) \ - { \ - type t; \ - t = x; \ - x = y; \ - y = t; \ - } +#define _GLFW_SWAP(type, x, y) \ + { \ + type t; \ + t = x; \ + x = y; \ + y = t; \ + } // Per-thread error structure // -struct _GLFWerror -{ - _GLFWerror* next; - int code; - char description[_GLFW_MESSAGE_SIZE]; +struct _GLFWerror { + _GLFWerror *next; + int code; + char description[_GLFW_MESSAGE_SIZE]; }; // Initialization configuration // // Parameters relating to the initialization of the library // -struct _GLFWinitconfig -{ - GLFWbool hatButtons; - int angleType; - int platformID; - PFN_vkGetInstanceProcAddr vulkanLoader; - struct { - GLFWbool menubar; - GLFWbool chdir; - } ns; - struct { - GLFWbool xcbVulkanSurface; - } x11; - struct { - int libdecorMode; - } wl; +struct _GLFWinitconfig { + GLFWbool hatButtons; + int angleType; + int platformID; + PFN_vkGetInstanceProcAddr vulkanLoader; + struct { + GLFWbool menubar; + GLFWbool chdir; + } ns; + struct { + GLFWbool xcbVulkanSurface; + } x11; + struct { + int libdecorMode; + } wl; }; // Window configuration @@ -390,38 +398,38 @@ struct _GLFWinitconfig // to the framebuffer. This is used to pass window creation parameters from // shared code to the platform API. // -struct _GLFWwndconfig -{ - int xpos; - int ypos; - int width; - int height; - const char* title; - GLFWbool resizable; - GLFWbool visible; - GLFWbool decorated; - GLFWbool focused; - GLFWbool autoIconify; - GLFWbool floating; - GLFWbool maximized; - GLFWbool centerCursor; - GLFWbool focusOnShow; - GLFWbool mousePassthrough; - GLFWbool scaleToMonitor; - struct { - GLFWbool retina; - char frameName[256]; - } ns; - struct { - char className[256]; - char instanceName[256]; - } x11; - struct { - GLFWbool keymenu; - } win32; - struct { - char appId[256]; - } wl; +struct _GLFWwndconfig { + int xpos; + int ypos; + int width; + int height; + const char *title; + GLFWbool resizable; + GLFWbool visible; + GLFWbool decorated; + GLFWbool titlebar; + GLFWbool focused; + GLFWbool autoIconify; + GLFWbool floating; + GLFWbool maximized; + GLFWbool centerCursor; + GLFWbool focusOnShow; + GLFWbool mousePassthrough; + GLFWbool scaleToMonitor; + struct { + GLFWbool retina; + char frameName[256]; + } ns; + struct { + char className[256]; + char instanceName[256]; + } x11; + struct { + GLFWbool keymenu; + } win32; + struct { + char appId[256]; + } wl; }; // Context configuration @@ -430,22 +438,21 @@ struct _GLFWwndconfig // to the framebuffer. This is used to pass context creation parameters from // shared code to the platform API. // -struct _GLFWctxconfig -{ - int client; - int source; - int major; - int minor; - GLFWbool forward; - GLFWbool debug; - GLFWbool noerror; - int profile; - int robustness; - int release; - _GLFWwindow* share; - struct { - GLFWbool offline; - } nsgl; +struct _GLFWctxconfig { + int client; + int source; + int major; + int minor; + GLFWbool forward; + GLFWbool debug; + GLFWbool noerror; + int profile; + int robustness; + int release; + _GLFWwindow *share; + struct { + GLFWbool offline; + } nsgl; }; // Framebuffer configuration @@ -456,429 +463,423 @@ struct _GLFWctxconfig // It is used to pass framebuffer parameters from shared code to the platform // API and also to enumerate and select available framebuffer configs. // -struct _GLFWfbconfig -{ - int redBits; - int greenBits; - int blueBits; - int alphaBits; - int depthBits; - int stencilBits; - int accumRedBits; - int accumGreenBits; - int accumBlueBits; - int accumAlphaBits; - int auxBuffers; - GLFWbool stereo; - int samples; - GLFWbool sRGB; - GLFWbool doublebuffer; - GLFWbool transparent; - uintptr_t handle; +struct _GLFWfbconfig { + int redBits; + int greenBits; + int blueBits; + int alphaBits; + int depthBits; + int stencilBits; + int accumRedBits; + int accumGreenBits; + int accumBlueBits; + int accumAlphaBits; + int auxBuffers; + GLFWbool stereo; + int samples; + GLFWbool sRGB; + GLFWbool doublebuffer; + GLFWbool transparent; + uintptr_t handle; }; // Context structure // -struct _GLFWcontext -{ - int client; - int source; - int major, minor, revision; - GLFWbool forward, debug, noerror; - int profile; - int robustness; - int release; +struct _GLFWcontext { + int client; + int source; + int major, minor, revision; + GLFWbool forward, debug, noerror; + int profile; + int robustness; + int release; - PFNGLGETSTRINGIPROC GetStringi; - PFNGLGETINTEGERVPROC GetIntegerv; - PFNGLGETSTRINGPROC GetString; + PFNGLGETSTRINGIPROC GetStringi; + PFNGLGETINTEGERVPROC GetIntegerv; + PFNGLGETSTRINGPROC GetString; - void (*makeCurrent)(_GLFWwindow*); - void (*swapBuffers)(_GLFWwindow*); - void (*swapInterval)(int); - int (*extensionSupported)(const char*); - GLFWglproc (*getProcAddress)(const char*); - void (*destroy)(_GLFWwindow*); + void (*makeCurrent)(_GLFWwindow *); + void (*swapBuffers)(_GLFWwindow *); + void (*swapInterval)(int); + int (*extensionSupported)(const char *); + GLFWglproc (*getProcAddress)(const char *); + void (*destroy)(_GLFWwindow *); - struct { - EGLConfig config; - EGLContext handle; - EGLSurface surface; - void* client; - } egl; + struct { + EGLConfig config; + EGLContext handle; + EGLSurface surface; + void *client; + } egl; - struct { - OSMesaContext handle; - int width; - int height; - void* buffer; - } osmesa; + struct { + OSMesaContext handle; + int width; + int height; + void *buffer; + } osmesa; - // This is defined in platform.h - GLFW_PLATFORM_CONTEXT_STATE + // This is defined in platform.h + GLFW_PLATFORM_CONTEXT_STATE }; // Window and context structure // -struct _GLFWwindow -{ - struct _GLFWwindow* next; +struct _GLFWwindow { + struct _GLFWwindow *next; - // Window settings and state - GLFWbool resizable; - GLFWbool decorated; - GLFWbool autoIconify; - GLFWbool floating; - GLFWbool focusOnShow; - GLFWbool mousePassthrough; - GLFWbool shouldClose; - void* userPointer; - GLFWbool doublebuffer; - GLFWvidmode videoMode; - _GLFWmonitor* monitor; - _GLFWcursor* cursor; + // Window settings and state + GLFWbool resizable; + GLFWbool decorated; + GLFWbool autoIconify; + GLFWbool floating; + GLFWbool focusOnShow; + GLFWbool mousePassthrough; + GLFWbool shouldClose; + void *userPointer; + GLFWbool doublebuffer; + GLFWvidmode videoMode; + _GLFWmonitor *monitor; + _GLFWcursor *cursor; - int minwidth, minheight; - int maxwidth, maxheight; - int numer, denom; + int minwidth, minheight; + int maxwidth, maxheight; + int numer, denom; - GLFWbool stickyKeys; - GLFWbool stickyMouseButtons; - GLFWbool lockKeyMods; - int cursorMode; - char mouseButtons[GLFW_MOUSE_BUTTON_LAST + 1]; - char keys[GLFW_KEY_LAST + 1]; - // Virtual cursor position when cursor is disabled - double virtualCursorPosX, virtualCursorPosY; - GLFWbool rawMouseMotion; + GLFWbool stickyKeys; + GLFWbool stickyMouseButtons; + GLFWbool lockKeyMods; + int cursorMode; + char mouseButtons[GLFW_MOUSE_BUTTON_LAST + 1]; + char keys[GLFW_KEY_LAST + 1]; + // Virtual cursor position when cursor is disabled + double virtualCursorPosX, virtualCursorPosY; + GLFWbool rawMouseMotion; - _GLFWcontext context; + _GLFWcontext context; - struct { - GLFWwindowposfun pos; - GLFWwindowsizefun size; - GLFWwindowclosefun close; - GLFWwindowrefreshfun refresh; - GLFWwindowfocusfun focus; - GLFWwindowiconifyfun iconify; - GLFWwindowmaximizefun maximize; - GLFWframebuffersizefun fbsize; - GLFWwindowcontentscalefun scale; - GLFWmousebuttonfun mouseButton; - GLFWcursorposfun cursorPos; - GLFWcursorenterfun cursorEnter; - GLFWscrollfun scroll; - GLFWkeyfun key; - GLFWcharfun character; - GLFWcharmodsfun charmods; - GLFWdropfun drop; - } callbacks; + struct { + GLFWwindowposfun pos; + GLFWtitlebarhittestfun tbhittest; + GLFWwindowsizefun size; + GLFWwindowclosefun close; + GLFWwindowrefreshfun refresh; + GLFWwindowfocusfun focus; + GLFWwindowiconifyfun iconify; + GLFWwindowmaximizefun maximize; + GLFWframebuffersizefun fbsize; + GLFWwindowcontentscalefun scale; + GLFWmousebuttonfun mouseButton; + GLFWcursorposfun cursorPos; + GLFWcursorenterfun cursorEnter; + GLFWscrollfun scroll; + GLFWkeyfun key; + GLFWcharfun character; + GLFWcharmodsfun charmods; + GLFWdropfun drop; + } callbacks; - // This is defined in platform.h - GLFW_PLATFORM_WINDOW_STATE + // This is defined in platform.h + GLFW_PLATFORM_WINDOW_STATE }; // Monitor structure // -struct _GLFWmonitor -{ - char name[128]; - void* userPointer; +struct _GLFWmonitor { + char name[128]; + void *userPointer; - // Physical dimensions in millimeters. - int widthMM, heightMM; + // Physical dimensions in millimeters. + int widthMM, heightMM; - // The window whose video mode is current on this monitor - _GLFWwindow* window; + // The window whose video mode is current on this monitor + _GLFWwindow *window; - GLFWvidmode* modes; - int modeCount; - GLFWvidmode currentMode; + GLFWvidmode *modes; + int modeCount; + GLFWvidmode currentMode; - GLFWgammaramp originalRamp; - GLFWgammaramp currentRamp; + GLFWgammaramp originalRamp; + GLFWgammaramp currentRamp; - // This is defined in platform.h - GLFW_PLATFORM_MONITOR_STATE + // This is defined in platform.h + GLFW_PLATFORM_MONITOR_STATE }; // Cursor structure // -struct _GLFWcursor -{ - _GLFWcursor* next; - // This is defined in platform.h - GLFW_PLATFORM_CURSOR_STATE +struct _GLFWcursor { + _GLFWcursor *next; + // This is defined in platform.h + GLFW_PLATFORM_CURSOR_STATE }; // Gamepad mapping element structure // -struct _GLFWmapelement -{ - uint8_t type; - uint8_t index; - int8_t axisScale; - int8_t axisOffset; +struct _GLFWmapelement { + uint8_t type; + uint8_t index; + int8_t axisScale; + int8_t axisOffset; }; // Gamepad mapping structure // -struct _GLFWmapping -{ - char name[128]; - char guid[33]; - _GLFWmapelement buttons[15]; - _GLFWmapelement axes[6]; +struct _GLFWmapping { + char name[128]; + char guid[33]; + _GLFWmapelement buttons[15]; + _GLFWmapelement axes[6]; }; // Joystick structure // -struct _GLFWjoystick -{ - GLFWbool allocated; - GLFWbool connected; - float* axes; - int axisCount; - unsigned char* buttons; - int buttonCount; - unsigned char* hats; - int hatCount; - char name[128]; - void* userPointer; - char guid[33]; - _GLFWmapping* mapping; +struct _GLFWjoystick { + GLFWbool allocated; + GLFWbool connected; + float *axes; + int axisCount; + unsigned char *buttons; + int buttonCount; + unsigned char *hats; + int hatCount; + char name[128]; + void *userPointer; + char guid[33]; + _GLFWmapping *mapping; - // This is defined in platform.h - GLFW_PLATFORM_JOYSTICK_STATE + // This is defined in platform.h + GLFW_PLATFORM_JOYSTICK_STATE }; // Thread local storage structure // -struct _GLFWtls -{ - // This is defined in platform.h - GLFW_PLATFORM_TLS_STATE +struct _GLFWtls { + // This is defined in platform.h + GLFW_PLATFORM_TLS_STATE }; // Mutex structure // -struct _GLFWmutex -{ - // This is defined in platform.h - GLFW_PLATFORM_MUTEX_STATE +struct _GLFWmutex { + // This is defined in platform.h + GLFW_PLATFORM_MUTEX_STATE }; // Platform API structure // -struct _GLFWplatform -{ - int platformID; - // init - GLFWbool (*init)(void); - void (*terminate)(void); - // input - void (*getCursorPos)(_GLFWwindow*,double*,double*); - void (*setCursorPos)(_GLFWwindow*,double,double); - void (*setCursorMode)(_GLFWwindow*,int); - void (*setRawMouseMotion)(_GLFWwindow*,GLFWbool); - GLFWbool (*rawMouseMotionSupported)(void); - GLFWbool (*createCursor)(_GLFWcursor*,const GLFWimage*,int,int); - GLFWbool (*createStandardCursor)(_GLFWcursor*,int); - void (*destroyCursor)(_GLFWcursor*); - void (*setCursor)(_GLFWwindow*,_GLFWcursor*); - const char* (*getScancodeName)(int); - int (*getKeyScancode)(int); - void (*setClipboardString)(const char*); - const char* (*getClipboardString)(void); - GLFWbool (*initJoysticks)(void); - void (*terminateJoysticks)(void); - GLFWbool (*pollJoystick)(_GLFWjoystick*,int); - const char* (*getMappingName)(void); - void (*updateGamepadGUID)(char*); - // monitor - void (*freeMonitor)(_GLFWmonitor*); - void (*getMonitorPos)(_GLFWmonitor*,int*,int*); - void (*getMonitorContentScale)(_GLFWmonitor*,float*,float*); - void (*getMonitorWorkarea)(_GLFWmonitor*,int*,int*,int*,int*); - GLFWvidmode* (*getVideoModes)(_GLFWmonitor*,int*); - void (*getVideoMode)(_GLFWmonitor*,GLFWvidmode*); - GLFWbool (*getGammaRamp)(_GLFWmonitor*,GLFWgammaramp*); - void (*setGammaRamp)(_GLFWmonitor*,const GLFWgammaramp*); - // window - GLFWbool (*createWindow)(_GLFWwindow*,const _GLFWwndconfig*,const _GLFWctxconfig*,const _GLFWfbconfig*); - void (*destroyWindow)(_GLFWwindow*); - void (*setWindowTitle)(_GLFWwindow*,const char*); - void (*setWindowIcon)(_GLFWwindow*,int,const GLFWimage*); - void (*getWindowPos)(_GLFWwindow*,int*,int*); - void (*setWindowPos)(_GLFWwindow*,int,int); - void (*getWindowSize)(_GLFWwindow*,int*,int*); - void (*setWindowSize)(_GLFWwindow*,int,int); - void (*setWindowSizeLimits)(_GLFWwindow*,int,int,int,int); - void (*setWindowAspectRatio)(_GLFWwindow*,int,int); - void (*getFramebufferSize)(_GLFWwindow*,int*,int*); - void (*getWindowFrameSize)(_GLFWwindow*,int*,int*,int*,int*); - void (*getWindowContentScale)(_GLFWwindow*,float*,float*); - void (*iconifyWindow)(_GLFWwindow*); - void (*restoreWindow)(_GLFWwindow*); - void (*maximizeWindow)(_GLFWwindow*); - void (*showWindow)(_GLFWwindow*); - void (*hideWindow)(_GLFWwindow*); - void (*requestWindowAttention)(_GLFWwindow*); - void (*focusWindow)(_GLFWwindow*); - void (*setWindowMonitor)(_GLFWwindow*,_GLFWmonitor*,int,int,int,int,int); - GLFWbool (*windowFocused)(_GLFWwindow*); - GLFWbool (*windowIconified)(_GLFWwindow*); - GLFWbool (*windowVisible)(_GLFWwindow*); - GLFWbool (*windowMaximized)(_GLFWwindow*); - GLFWbool (*windowHovered)(_GLFWwindow*); - GLFWbool (*framebufferTransparent)(_GLFWwindow*); - float (*getWindowOpacity)(_GLFWwindow*); - void (*setWindowResizable)(_GLFWwindow*,GLFWbool); - void (*setWindowDecorated)(_GLFWwindow*,GLFWbool); - void (*setWindowFloating)(_GLFWwindow*,GLFWbool); - void (*setWindowOpacity)(_GLFWwindow*,float); - void (*setWindowMousePassthrough)(_GLFWwindow*,GLFWbool); - void (*pollEvents)(void); - void (*waitEvents)(void); - void (*waitEventsTimeout)(double); - void (*postEmptyEvent)(void); - // EGL - EGLenum (*getEGLPlatform)(EGLint**); - EGLNativeDisplayType (*getEGLNativeDisplay)(void); - EGLNativeWindowType (*getEGLNativeWindow)(_GLFWwindow*); - // vulkan - void (*getRequiredInstanceExtensions)(char**); - GLFWbool (*getPhysicalDevicePresentationSupport)(VkInstance,VkPhysicalDevice,uint32_t); - VkResult (*createWindowSurface)(VkInstance,_GLFWwindow*,const VkAllocationCallbacks*,VkSurfaceKHR*); +struct _GLFWplatform { + int platformID; + // init + GLFWbool (*init)(void); + void (*terminate)(void); + // input + void (*getCursorPos)(_GLFWwindow *, double *, double *); + void (*setCursorPos)(_GLFWwindow *, double, double); + void (*setCursorMode)(_GLFWwindow *, int); + void (*setRawMouseMotion)(_GLFWwindow *, GLFWbool); + GLFWbool (*rawMouseMotionSupported)(void); + GLFWbool (*createCursor)(_GLFWcursor *, const GLFWimage *, int, int); + GLFWbool (*createStandardCursor)(_GLFWcursor *, int); + void (*destroyCursor)(_GLFWcursor *); + void (*setCursor)(_GLFWwindow *, _GLFWcursor *); + const char *(*getScancodeName)(int); + int (*getKeyScancode)(int); + void (*setClipboardString)(const char *); + const char *(*getClipboardString)(void); + GLFWbool (*initJoysticks)(void); + void (*terminateJoysticks)(void); + GLFWbool (*pollJoystick)(_GLFWjoystick *, int); + const char *(*getMappingName)(void); + void (*updateGamepadGUID)(char *); + // monitor + void (*freeMonitor)(_GLFWmonitor *); + void (*getMonitorPos)(_GLFWmonitor *, int *, int *); + void (*getMonitorContentScale)(_GLFWmonitor *, float *, float *); + void (*getMonitorWorkarea)(_GLFWmonitor *, int *, int *, int *, int *); + GLFWvidmode *(*getVideoModes)(_GLFWmonitor *, int *); + void (*getVideoMode)(_GLFWmonitor *, GLFWvidmode *); + GLFWbool (*getGammaRamp)(_GLFWmonitor *, GLFWgammaramp *); + void (*setGammaRamp)(_GLFWmonitor *, const GLFWgammaramp *); + // window + GLFWbool (*createWindow)(_GLFWwindow *, const _GLFWwndconfig *, + const _GLFWctxconfig *, const _GLFWfbconfig *); + void (*destroyWindow)(_GLFWwindow *); + void (*setWindowTitle)(_GLFWwindow *, const char *); + void (*setWindowIcon)(_GLFWwindow *, int, const GLFWimage *); + void (*getWindowPos)(_GLFWwindow *, int *, int *); + void (*setWindowPos)(_GLFWwindow *, int, int); + void (*getWindowSize)(_GLFWwindow *, int *, int *); + void (*setWindowSize)(_GLFWwindow *, int, int); + void (*setWindowSizeLimits)(_GLFWwindow *, int, int, int, int); + void (*setWindowAspectRatio)(_GLFWwindow *, int, int); + void (*getFramebufferSize)(_GLFWwindow *, int *, int *); + void (*getWindowFrameSize)(_GLFWwindow *, int *, int *, int *, int *); + void (*getWindowContentScale)(_GLFWwindow *, float *, float *); + void (*iconifyWindow)(_GLFWwindow *); + void (*restoreWindow)(_GLFWwindow *); + void (*maximizeWindow)(_GLFWwindow *); + void (*showWindow)(_GLFWwindow *); + void (*hideWindow)(_GLFWwindow *); + void (*requestWindowAttention)(_GLFWwindow *); + void (*focusWindow)(_GLFWwindow *); + void (*setWindowMonitor)(_GLFWwindow *, _GLFWmonitor *, int, int, int, int, + int); + GLFWbool (*windowFocused)(_GLFWwindow *); + GLFWbool (*windowIconified)(_GLFWwindow *); + GLFWbool (*windowVisible)(_GLFWwindow *); + GLFWbool (*windowMaximized)(_GLFWwindow *); + GLFWbool (*windowHovered)(_GLFWwindow *); + GLFWbool (*framebufferTransparent)(_GLFWwindow *); + float (*getWindowOpacity)(_GLFWwindow *); + void (*setWindowResizable)(_GLFWwindow *, GLFWbool); + void (*setWindowDecorated)(_GLFWwindow *, GLFWbool); + void (*setWindowTitlebar)(_GLFWwindow *, GLFWbool); + void (*setWindowFloating)(_GLFWwindow *, GLFWbool); + void (*setWindowOpacity)(_GLFWwindow *, float); + void (*setWindowMousePassthrough)(_GLFWwindow *, GLFWbool); + void (*pollEvents)(void); + void (*waitEvents)(void); + void (*waitEventsTimeout)(double); + void (*postEmptyEvent)(void); + // EGL + EGLenum (*getEGLPlatform)(EGLint **); + EGLNativeDisplayType (*getEGLNativeDisplay)(void); + EGLNativeWindowType (*getEGLNativeWindow)(_GLFWwindow *); + // vulkan + void (*getRequiredInstanceExtensions)(char **); + GLFWbool (*getPhysicalDevicePresentationSupport)(VkInstance, VkPhysicalDevice, + uint32_t); + VkResult (*createWindowSurface)(VkInstance, _GLFWwindow *, + const VkAllocationCallbacks *, + VkSurfaceKHR *); }; // Library global data // -struct _GLFWlibrary -{ - GLFWbool initialized; - GLFWallocator allocator; +struct _GLFWlibrary { + GLFWbool initialized; + GLFWallocator allocator; - _GLFWplatform platform; + _GLFWplatform platform; - struct { - _GLFWinitconfig init; - _GLFWfbconfig framebuffer; - _GLFWwndconfig window; - _GLFWctxconfig context; - int refreshRate; - } hints; + struct { + _GLFWinitconfig init; + _GLFWfbconfig framebuffer; + _GLFWwndconfig window; + _GLFWctxconfig context; + int refreshRate; + } hints; - _GLFWerror* errorListHead; - _GLFWcursor* cursorListHead; - _GLFWwindow* windowListHead; + _GLFWerror *errorListHead; + _GLFWcursor *cursorListHead; + _GLFWwindow *windowListHead; - _GLFWmonitor** monitors; - int monitorCount; + _GLFWmonitor **monitors; + int monitorCount; - GLFWbool joysticksInitialized; - _GLFWjoystick joysticks[GLFW_JOYSTICK_LAST + 1]; - _GLFWmapping* mappings; - int mappingCount; + GLFWbool joysticksInitialized; + _GLFWjoystick joysticks[GLFW_JOYSTICK_LAST + 1]; + _GLFWmapping *mappings; + int mappingCount; - _GLFWtls errorSlot; - _GLFWtls contextSlot; - _GLFWmutex errorLock; + _GLFWtls errorSlot; + _GLFWtls contextSlot; + _GLFWmutex errorLock; - struct { - uint64_t offset; - // This is defined in platform.h - GLFW_PLATFORM_LIBRARY_TIMER_STATE - } timer; + struct { + uint64_t offset; + // This is defined in platform.h + GLFW_PLATFORM_LIBRARY_TIMER_STATE + } timer; - struct { - EGLenum platform; - EGLDisplay display; - EGLint major, minor; - GLFWbool prefix; + struct { + EGLenum platform; + EGLDisplay display; + EGLint major, minor; + GLFWbool prefix; - GLFWbool KHR_create_context; - GLFWbool KHR_create_context_no_error; - GLFWbool KHR_gl_colorspace; - GLFWbool KHR_get_all_proc_addresses; - GLFWbool KHR_context_flush_control; - GLFWbool EXT_client_extensions; - GLFWbool EXT_platform_base; - GLFWbool EXT_platform_x11; - GLFWbool EXT_platform_wayland; - GLFWbool EXT_present_opaque; - GLFWbool ANGLE_platform_angle; - GLFWbool ANGLE_platform_angle_opengl; - GLFWbool ANGLE_platform_angle_d3d; - GLFWbool ANGLE_platform_angle_vulkan; - GLFWbool ANGLE_platform_angle_metal; + GLFWbool KHR_create_context; + GLFWbool KHR_create_context_no_error; + GLFWbool KHR_gl_colorspace; + GLFWbool KHR_get_all_proc_addresses; + GLFWbool KHR_context_flush_control; + GLFWbool EXT_client_extensions; + GLFWbool EXT_platform_base; + GLFWbool EXT_platform_x11; + GLFWbool EXT_platform_wayland; + GLFWbool EXT_present_opaque; + GLFWbool ANGLE_platform_angle; + GLFWbool ANGLE_platform_angle_opengl; + GLFWbool ANGLE_platform_angle_d3d; + GLFWbool ANGLE_platform_angle_vulkan; + GLFWbool ANGLE_platform_angle_metal; - void* handle; + void *handle; - PFN_eglGetConfigAttrib GetConfigAttrib; - PFN_eglGetConfigs GetConfigs; - PFN_eglGetDisplay GetDisplay; - PFN_eglGetError GetError; - PFN_eglInitialize Initialize; - PFN_eglTerminate Terminate; - PFN_eglBindAPI BindAPI; - PFN_eglCreateContext CreateContext; - PFN_eglDestroySurface DestroySurface; - PFN_eglDestroyContext DestroyContext; - PFN_eglCreateWindowSurface CreateWindowSurface; - PFN_eglMakeCurrent MakeCurrent; - PFN_eglSwapBuffers SwapBuffers; - PFN_eglSwapInterval SwapInterval; - PFN_eglQueryString QueryString; - PFN_eglGetProcAddress GetProcAddress; + PFN_eglGetConfigAttrib GetConfigAttrib; + PFN_eglGetConfigs GetConfigs; + PFN_eglGetDisplay GetDisplay; + PFN_eglGetError GetError; + PFN_eglInitialize Initialize; + PFN_eglTerminate Terminate; + PFN_eglBindAPI BindAPI; + PFN_eglCreateContext CreateContext; + PFN_eglDestroySurface DestroySurface; + PFN_eglDestroyContext DestroyContext; + PFN_eglCreateWindowSurface CreateWindowSurface; + PFN_eglMakeCurrent MakeCurrent; + PFN_eglSwapBuffers SwapBuffers; + PFN_eglSwapInterval SwapInterval; + PFN_eglQueryString QueryString; + PFN_eglGetProcAddress GetProcAddress; - PFNEGLGETPLATFORMDISPLAYEXTPROC GetPlatformDisplayEXT; - PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC CreatePlatformWindowSurfaceEXT; - } egl; + PFNEGLGETPLATFORMDISPLAYEXTPROC GetPlatformDisplayEXT; + PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC CreatePlatformWindowSurfaceEXT; + } egl; - struct { - void* handle; + struct { + void *handle; - PFN_OSMesaCreateContextExt CreateContextExt; - PFN_OSMesaCreateContextAttribs CreateContextAttribs; - PFN_OSMesaDestroyContext DestroyContext; - PFN_OSMesaMakeCurrent MakeCurrent; - PFN_OSMesaGetColorBuffer GetColorBuffer; - PFN_OSMesaGetDepthBuffer GetDepthBuffer; - PFN_OSMesaGetProcAddress GetProcAddress; + PFN_OSMesaCreateContextExt CreateContextExt; + PFN_OSMesaCreateContextAttribs CreateContextAttribs; + PFN_OSMesaDestroyContext DestroyContext; + PFN_OSMesaMakeCurrent MakeCurrent; + PFN_OSMesaGetColorBuffer GetColorBuffer; + PFN_OSMesaGetDepthBuffer GetDepthBuffer; + PFN_OSMesaGetProcAddress GetProcAddress; - } osmesa; + } osmesa; - struct { - GLFWbool available; - void* handle; - char* extensions[2]; - PFN_vkGetInstanceProcAddr GetInstanceProcAddr; - GLFWbool KHR_surface; - GLFWbool KHR_win32_surface; - GLFWbool MVK_macos_surface; - GLFWbool EXT_metal_surface; - GLFWbool KHR_xlib_surface; - GLFWbool KHR_xcb_surface; - GLFWbool KHR_wayland_surface; - } vk; + struct { + GLFWbool available; + void *handle; + char *extensions[2]; + PFN_vkGetInstanceProcAddr GetInstanceProcAddr; + GLFWbool KHR_surface; + GLFWbool KHR_win32_surface; + GLFWbool MVK_macos_surface; + GLFWbool EXT_metal_surface; + GLFWbool KHR_xlib_surface; + GLFWbool KHR_xcb_surface; + GLFWbool KHR_wayland_surface; + } vk; - struct { - GLFWmonitorfun monitor; - GLFWjoystickfun joystick; - } callbacks; + struct { + GLFWmonitorfun monitor; + GLFWjoystickfun joystick; + } callbacks; - // These are defined in platform.h - GLFW_PLATFORM_LIBRARY_WINDOW_STATE - GLFW_PLATFORM_LIBRARY_CONTEXT_STATE - GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE + // These are defined in platform.h + GLFW_PLATFORM_LIBRARY_WINDOW_STATE + GLFW_PLATFORM_LIBRARY_CONTEXT_STATE + GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE }; // Global state shared between compilation units of GLFW // extern _GLFWlibrary _glfw; - ////////////////////////////////////////////////////////////////////////// ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// @@ -887,126 +888,183 @@ void _glfwPlatformInitTimer(void); uint64_t _glfwPlatformGetTimerValue(void); uint64_t _glfwPlatformGetTimerFrequency(void); -GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls); -void _glfwPlatformDestroyTls(_GLFWtls* tls); -void* _glfwPlatformGetTls(_GLFWtls* tls); -void _glfwPlatformSetTls(_GLFWtls* tls, void* value); +int _glfwPlatformCreateWindow(_GLFWwindow *window, + const _GLFWwndconfig *wndconfig, + const _GLFWctxconfig *ctxconfig, + const _GLFWfbconfig *fbconfig); +void _glfwPlatformDestroyWindow(_GLFWwindow *window); +void _glfwPlatformSetWindowTitle(_GLFWwindow *window, const char *title); +void _glfwPlatformSetWindowIcon(_GLFWwindow *window, int count, + const GLFWimage *images); +void _glfwPlatformGetWindowPos(_GLFWwindow *window, int *xpos, int *ypos); +void _glfwPlatformSetWindowPos(_GLFWwindow *window, int xpos, int ypos); +void _glfwPlatformGetWindowSize(_GLFWwindow *window, int *width, int *height); +void _glfwPlatformSetWindowSize(_GLFWwindow *window, int width, int height); +void _glfwPlatformSetWindowSizeLimits(_GLFWwindow *window, int minwidth, + int minheight, int maxwidth, + int maxheight); +void _glfwPlatformSetWindowAspectRatio(_GLFWwindow *window, int numer, + int denom); +void _glfwPlatformGetFramebufferSize(_GLFWwindow *window, int *width, + int *height); +void _glfwPlatformGetWindowFrameSize(_GLFWwindow *window, int *left, int *top, + int *right, int *bottom); +void _glfwPlatformGetWindowContentScale(_GLFWwindow *window, float *xscale, + float *yscale); +void _glfwPlatformIconifyWindow(_GLFWwindow *window); +void _glfwPlatformRestoreWindow(_GLFWwindow *window); +void _glfwPlatformMaximizeWindow(_GLFWwindow *window); +void _glfwPlatformShowWindow(_GLFWwindow *window); +void _glfwPlatformHideWindow(_GLFWwindow *window); +void _glfwPlatformRequestWindowAttention(_GLFWwindow *window); +void _glfwPlatformFocusWindow(_GLFWwindow *window); +void _glfwPlatformSetWindowMonitor(_GLFWwindow *window, _GLFWmonitor *monitor, + int xpos, int ypos, int width, int height, + int refreshRate); +int _glfwPlatformWindowFocused(_GLFWwindow *window); +int _glfwPlatformWindowIconified(_GLFWwindow *window); +int _glfwPlatformWindowVisible(_GLFWwindow *window); +int _glfwPlatformWindowMaximized(_GLFWwindow *window); +int _glfwPlatformWindowHovered(_GLFWwindow *window); +int _glfwPlatformFramebufferTransparent(_GLFWwindow *window); +float _glfwPlatformGetWindowOpacity(_GLFWwindow *window); +void _glfwPlatformSetWindowResizable(_GLFWwindow *window, GLFWbool enabled); +void _glfwPlatformSetWindowDecorated(_GLFWwindow *window, GLFWbool enabled); +void _glfwPlatformSetWindowTitlebar(_GLFWwindow *window, GLFWbool enabled); +void _glfwPlatformSetWindowFloating(_GLFWwindow *window, GLFWbool enabled); +void _glfwPlatformSetWindowOpacity(_GLFWwindow *window, float opacity); -GLFWbool _glfwPlatformCreateMutex(_GLFWmutex* mutex); -void _glfwPlatformDestroyMutex(_GLFWmutex* mutex); -void _glfwPlatformLockMutex(_GLFWmutex* mutex); -void _glfwPlatformUnlockMutex(_GLFWmutex* mutex); +void _glfwPlatformPollEvents(void); +void _glfwPlatformWaitEvents(void); +void _glfwPlatformWaitEventsTimeout(double timeout); +void _glfwPlatformPostEmptyEvent(void); -void* _glfwPlatformLoadModule(const char* path); -void _glfwPlatformFreeModule(void* module); -GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name); +void _glfwPlatformGetRequiredInstanceExtensions(char **extensions); +int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, + VkPhysicalDevice device, + uint32_t queuefamily); +VkResult +_glfwPlatformCreateWindowSurface(VkInstance instance, _GLFWwindow *window, + const VkAllocationCallbacks *allocator, + VkSurfaceKHR *surface); +GLFWbool _glfwPlatformCreateTls(_GLFWtls *tls); +void _glfwPlatformDestroyTls(_GLFWtls *tls); +void *_glfwPlatformGetTls(_GLFWtls *tls); +void _glfwPlatformSetTls(_GLFWtls *tls, void *value); +GLFWbool _glfwPlatformCreateMutex(_GLFWmutex *mutex); +void _glfwPlatformDestroyMutex(_GLFWmutex *mutex); +void _glfwPlatformLockMutex(_GLFWmutex *mutex); +void _glfwPlatformUnlockMutex(_GLFWmutex *mutex); + +void *_glfwPlatformLoadModule(const char *path); +void _glfwPlatformFreeModule(void *module); +GLFWproc _glfwPlatformGetModuleSymbol(void *module, const char *name); ////////////////////////////////////////////////////////////////////////// ////// GLFW event API ////// ////////////////////////////////////////////////////////////////////////// -void _glfwInputWindowFocus(_GLFWwindow* window, GLFWbool focused); -void _glfwInputWindowPos(_GLFWwindow* window, int xpos, int ypos); -void _glfwInputWindowSize(_GLFWwindow* window, int width, int height); -void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height); -void _glfwInputWindowContentScale(_GLFWwindow* window, - float xscale, float yscale); -void _glfwInputWindowIconify(_GLFWwindow* window, GLFWbool iconified); -void _glfwInputWindowMaximize(_GLFWwindow* window, GLFWbool maximized); -void _glfwInputWindowDamage(_GLFWwindow* window); -void _glfwInputWindowCloseRequest(_GLFWwindow* window); -void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor); +void _glfwInputWindowFocus(_GLFWwindow *window, GLFWbool focused); +void _glfwInputWindowPos(_GLFWwindow *window, int xpos, int ypos); +void _glfwInputWindowSize(_GLFWwindow *window, int width, int height); +void _glfwInputTitleBarHitTest(_GLFWwindow *window, int posX, int posY, + int *hit); +void _glfwInputFramebufferSize(_GLFWwindow *window, int width, int height); +void _glfwInputWindowContentScale(_GLFWwindow *window, float xscale, + float yscale); +void _glfwInputWindowIconify(_GLFWwindow *window, GLFWbool iconified); +void _glfwInputWindowMaximize(_GLFWwindow *window, GLFWbool maximized); +void _glfwInputWindowDamage(_GLFWwindow *window); +void _glfwInputWindowCloseRequest(_GLFWwindow *window); +void _glfwInputWindowMonitor(_GLFWwindow *window, _GLFWmonitor *monitor); -void _glfwInputKey(_GLFWwindow* window, - int key, int scancode, int action, int mods); -void _glfwInputChar(_GLFWwindow* window, - uint32_t codepoint, int mods, GLFWbool plain); -void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset); -void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods); -void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos); -void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered); -void _glfwInputDrop(_GLFWwindow* window, int count, const char** names); -void _glfwInputJoystick(_GLFWjoystick* js, int event); -void _glfwInputJoystickAxis(_GLFWjoystick* js, int axis, float value); -void _glfwInputJoystickButton(_GLFWjoystick* js, int button, char value); -void _glfwInputJoystickHat(_GLFWjoystick* js, int hat, char value); +void _glfwInputKey(_GLFWwindow *window, int key, int scancode, int action, + int mods); +void _glfwInputChar(_GLFWwindow *window, uint32_t codepoint, int mods, + GLFWbool plain); +void _glfwInputScroll(_GLFWwindow *window, double xoffset, double yoffset); +void _glfwInputMouseClick(_GLFWwindow *window, int button, int action, + int mods); +void _glfwInputCursorPos(_GLFWwindow *window, double xpos, double ypos); +void _glfwInputCursorEnter(_GLFWwindow *window, GLFWbool entered); +void _glfwInputDrop(_GLFWwindow *window, int count, const char **names); +void _glfwInputJoystick(_GLFWjoystick *js, int event); +void _glfwInputJoystickAxis(_GLFWjoystick *js, int axis, float value); +void _glfwInputJoystickButton(_GLFWjoystick *js, int button, char value); +void _glfwInputJoystickHat(_GLFWjoystick *js, int hat, char value); -void _glfwInputMonitor(_GLFWmonitor* monitor, int action, int placement); -void _glfwInputMonitorWindow(_GLFWmonitor* monitor, _GLFWwindow* window); +void _glfwInputMonitor(_GLFWmonitor *monitor, int action, int placement); +void _glfwInputMonitorWindow(_GLFWmonitor *monitor, _GLFWwindow *window); #if defined(__GNUC__) -void _glfwInputError(int code, const char* format, ...) +void _glfwInputError(int code, const char *format, ...) __attribute__((format(printf, 2, 3))); #else -void _glfwInputError(int code, const char* format, ...); +void _glfwInputError(int code, const char *format, ...); #endif - ////////////////////////////////////////////////////////////////////////// ////// GLFW internal API ////// ////////////////////////////////////////////////////////////////////////// -GLFWbool _glfwSelectPlatform(int platformID, _GLFWplatform* platform); +GLFWbool _glfwSelectPlatform(int platformID, _GLFWplatform *platform); -GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions); -const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired, - const _GLFWfbconfig* alternatives, +GLFWbool _glfwStringInExtensionString(const char *string, + const char *extensions); +const _GLFWfbconfig *_glfwChooseFBConfig(const _GLFWfbconfig *desired, + const _GLFWfbconfig *alternatives, unsigned int count); -GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window, - const _GLFWctxconfig* ctxconfig); -GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig); +GLFWbool _glfwRefreshContextAttribs(_GLFWwindow *window, + const _GLFWctxconfig *ctxconfig); +GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig *ctxconfig); -const GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor, - const GLFWvidmode* desired); -int _glfwCompareVideoModes(const GLFWvidmode* first, const GLFWvidmode* second); -_GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM); -void _glfwFreeMonitor(_GLFWmonitor* monitor); -void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size); -void _glfwFreeGammaArrays(GLFWgammaramp* ramp); -void _glfwSplitBPP(int bpp, int* red, int* green, int* blue); +const GLFWvidmode *_glfwChooseVideoMode(_GLFWmonitor *monitor, + const GLFWvidmode *desired); +int _glfwCompareVideoModes(const GLFWvidmode *first, const GLFWvidmode *second); +_GLFWmonitor *_glfwAllocMonitor(const char *name, int widthMM, int heightMM); +void _glfwFreeMonitor(_GLFWmonitor *monitor); +void _glfwAllocGammaArrays(GLFWgammaramp *ramp, unsigned int size); +void _glfwFreeGammaArrays(GLFWgammaramp *ramp); +void _glfwSplitBPP(int bpp, int *red, int *green, int *blue); void _glfwInitGamepadMappings(void); -_GLFWjoystick* _glfwAllocJoystick(const char* name, - const char* guid, - int axisCount, - int buttonCount, - int hatCount); -void _glfwFreeJoystick(_GLFWjoystick* js); -void _glfwCenterCursorInContentArea(_GLFWwindow* window); +_GLFWjoystick *_glfwAllocJoystick(const char *name, const char *guid, + int axisCount, int buttonCount, int hatCount); +void _glfwFreeJoystick(_GLFWjoystick *js); +void _glfwCenterCursorInContentArea(_GLFWwindow *window); GLFWbool _glfwInitEGL(void); void _glfwTerminateEGL(void); -GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, - const _GLFWctxconfig* ctxconfig, - const _GLFWfbconfig* fbconfig); +GLFWbool _glfwCreateContextEGL(_GLFWwindow *window, + const _GLFWctxconfig *ctxconfig, + const _GLFWfbconfig *fbconfig); #if defined(_GLFW_X11) -GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig, - const _GLFWctxconfig* ctxconfig, - const _GLFWfbconfig* fbconfig, - Visual** visual, int* depth); +GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig *wndconfig, + const _GLFWctxconfig *ctxconfig, + const _GLFWfbconfig *fbconfig, Visual **visual, + int *depth); #endif /*_GLFW_X11*/ GLFWbool _glfwInitOSMesa(void); void _glfwTerminateOSMesa(void); -GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window, - const _GLFWctxconfig* ctxconfig, - const _GLFWfbconfig* fbconfig); +GLFWbool _glfwCreateContextOSMesa(_GLFWwindow *window, + const _GLFWctxconfig *ctxconfig, + const _GLFWfbconfig *fbconfig); GLFWbool _glfwInitVulkan(int mode); void _glfwTerminateVulkan(void); -const char* _glfwGetVulkanResultString(VkResult result); +const char *_glfwGetVulkanResultString(VkResult result); -size_t _glfwEncodeUTF8(char* s, uint32_t codepoint); -char** _glfwParseUriList(char* text, int* count); +size_t _glfwEncodeUTF8(char *s, uint32_t codepoint); +char **_glfwParseUriList(char *text, int *count); -char* _glfw_strdup(const char* source); +char *_glfw_strdup(const char *source); int _glfw_min(int a, int b); int _glfw_max(int a, int b); float _glfw_fminf(float a, float b); float _glfw_fmaxf(float a, float b); -void* _glfw_calloc(size_t count, size_t size); -void* _glfw_realloc(void* pointer, size_t size); -void _glfw_free(void* pointer); - +void *_glfw_calloc(size_t count, size_t size); +void *_glfw_realloc(void *pointer, size_t size); +void _glfw_free(void *pointer); diff --git a/tests/triangle-vulkan.c b/tests/triangle-vulkan.c index b38ee139..a6d9fce8 100644 --- a/tests/triangle-vulkan.c +++ b/tests/triangle-vulkan.c @@ -2130,6 +2130,10 @@ int main(const int argc, const char *argv[]) { demo_create_window(&demo); demo_init_vk_swapchain(&demo); + glfwSetWindowAttrib(demo.window, GLFW_RESIZABLE, GLFW_TRUE); + glfwSetWindowAttrib(demo.window, GLFW_TITLEBAR, GLFW_FALSE); + + demo_prepare(&demo); demo_run(&demo);