From 23ab9727247534dc2a27505a0da8efff5384f5ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 28 Mar 2023 17:29:33 +0200 Subject: [PATCH 01/50] Fix unquoted CMake variable references The previous version did not handle paths containing whitespace correctly. Related to #2256 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd256a0f..8b51ae96 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ endif() set_property(GLOBAL PROPERTY USE_FOLDERS ON) -string(COMPARE EQUAL ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR} GLFW_STANDALONE) +string(COMPARE EQUAL "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}" GLFW_STANDALONE) option(BUILD_SHARED_LIBS "Build shared libraries" OFF) option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ${GLFW_STANDALONE}) From 9cce2896eeaa8e74a902b11caaeb64ae666efaf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 22 May 2022 16:50:15 +0200 Subject: [PATCH 02/50] Null: Add (fictional) scancodes This replaces the previous scheme where scancodes were equal to keycodes (an implausible and potentially misleading situation) with a set of scancodes invented purely for the null platform. --- src/null_init.c | 133 ++++++++++++++++++++++++++++++++++++++++++++ src/null_platform.h | 124 +++++++++++++++++++++++++++++++++++++++++ src/null_window.c | 132 +++++++++++++++++++++---------------------- 3 files changed, 323 insertions(+), 66 deletions(-) diff --git a/src/null_init.c b/src/null_init.c index de4b28f3..7236c98c 100644 --- a/src/null_init.c +++ b/src/null_init.c @@ -30,6 +30,7 @@ #include "internal.h" #include +#include ////////////////////////////////////////////////////////////////////////// @@ -120,6 +121,138 @@ GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform) int _glfwInitNull(void) { + int scancode; + + memset(_glfw.null.keycodes, -1, sizeof(_glfw.null.keycodes)); + memset(_glfw.null.scancodes, -1, sizeof(_glfw.null.scancodes)); + + _glfw.null.keycodes[GLFW_NULL_SC_SPACE] = GLFW_KEY_SPACE; + _glfw.null.keycodes[GLFW_NULL_SC_APOSTROPHE] = GLFW_KEY_APOSTROPHE; + _glfw.null.keycodes[GLFW_NULL_SC_COMMA] = GLFW_KEY_COMMA; + _glfw.null.keycodes[GLFW_NULL_SC_MINUS] = GLFW_KEY_MINUS; + _glfw.null.keycodes[GLFW_NULL_SC_PERIOD] = GLFW_KEY_PERIOD; + _glfw.null.keycodes[GLFW_NULL_SC_SLASH] = GLFW_KEY_SLASH; + _glfw.null.keycodes[GLFW_NULL_SC_0] = GLFW_KEY_0; + _glfw.null.keycodes[GLFW_NULL_SC_1] = GLFW_KEY_1; + _glfw.null.keycodes[GLFW_NULL_SC_2] = GLFW_KEY_2; + _glfw.null.keycodes[GLFW_NULL_SC_3] = GLFW_KEY_3; + _glfw.null.keycodes[GLFW_NULL_SC_4] = GLFW_KEY_4; + _glfw.null.keycodes[GLFW_NULL_SC_5] = GLFW_KEY_5; + _glfw.null.keycodes[GLFW_NULL_SC_6] = GLFW_KEY_6; + _glfw.null.keycodes[GLFW_NULL_SC_7] = GLFW_KEY_7; + _glfw.null.keycodes[GLFW_NULL_SC_8] = GLFW_KEY_8; + _glfw.null.keycodes[GLFW_NULL_SC_9] = GLFW_KEY_9; + _glfw.null.keycodes[GLFW_NULL_SC_SEMICOLON] = GLFW_KEY_SEMICOLON; + _glfw.null.keycodes[GLFW_NULL_SC_EQUAL] = GLFW_KEY_EQUAL; + _glfw.null.keycodes[GLFW_NULL_SC_A] = GLFW_KEY_A; + _glfw.null.keycodes[GLFW_NULL_SC_B] = GLFW_KEY_B; + _glfw.null.keycodes[GLFW_NULL_SC_C] = GLFW_KEY_C; + _glfw.null.keycodes[GLFW_NULL_SC_D] = GLFW_KEY_D; + _glfw.null.keycodes[GLFW_NULL_SC_E] = GLFW_KEY_E; + _glfw.null.keycodes[GLFW_NULL_SC_F] = GLFW_KEY_F; + _glfw.null.keycodes[GLFW_NULL_SC_G] = GLFW_KEY_G; + _glfw.null.keycodes[GLFW_NULL_SC_H] = GLFW_KEY_H; + _glfw.null.keycodes[GLFW_NULL_SC_I] = GLFW_KEY_I; + _glfw.null.keycodes[GLFW_NULL_SC_J] = GLFW_KEY_J; + _glfw.null.keycodes[GLFW_NULL_SC_K] = GLFW_KEY_K; + _glfw.null.keycodes[GLFW_NULL_SC_L] = GLFW_KEY_L; + _glfw.null.keycodes[GLFW_NULL_SC_M] = GLFW_KEY_M; + _glfw.null.keycodes[GLFW_NULL_SC_N] = GLFW_KEY_N; + _glfw.null.keycodes[GLFW_NULL_SC_O] = GLFW_KEY_O; + _glfw.null.keycodes[GLFW_NULL_SC_P] = GLFW_KEY_P; + _glfw.null.keycodes[GLFW_NULL_SC_Q] = GLFW_KEY_Q; + _glfw.null.keycodes[GLFW_NULL_SC_R] = GLFW_KEY_R; + _glfw.null.keycodes[GLFW_NULL_SC_S] = GLFW_KEY_S; + _glfw.null.keycodes[GLFW_NULL_SC_T] = GLFW_KEY_T; + _glfw.null.keycodes[GLFW_NULL_SC_U] = GLFW_KEY_U; + _glfw.null.keycodes[GLFW_NULL_SC_V] = GLFW_KEY_V; + _glfw.null.keycodes[GLFW_NULL_SC_W] = GLFW_KEY_W; + _glfw.null.keycodes[GLFW_NULL_SC_X] = GLFW_KEY_X; + _glfw.null.keycodes[GLFW_NULL_SC_Y] = GLFW_KEY_Y; + _glfw.null.keycodes[GLFW_NULL_SC_Z] = GLFW_KEY_Z; + _glfw.null.keycodes[GLFW_NULL_SC_LEFT_BRACKET] = GLFW_KEY_LEFT_BRACKET; + _glfw.null.keycodes[GLFW_NULL_SC_BACKSLASH] = GLFW_KEY_BACKSLASH; + _glfw.null.keycodes[GLFW_NULL_SC_RIGHT_BRACKET] = GLFW_KEY_RIGHT_BRACKET; + _glfw.null.keycodes[GLFW_NULL_SC_GRAVE_ACCENT] = GLFW_KEY_GRAVE_ACCENT; + _glfw.null.keycodes[GLFW_NULL_SC_WORLD_1] = GLFW_KEY_WORLD_1; + _glfw.null.keycodes[GLFW_NULL_SC_WORLD_2] = GLFW_KEY_WORLD_2; + _glfw.null.keycodes[GLFW_NULL_SC_ESCAPE] = GLFW_KEY_ESCAPE; + _glfw.null.keycodes[GLFW_NULL_SC_ENTER] = GLFW_KEY_ENTER; + _glfw.null.keycodes[GLFW_NULL_SC_TAB] = GLFW_KEY_TAB; + _glfw.null.keycodes[GLFW_NULL_SC_BACKSPACE] = GLFW_KEY_BACKSPACE; + _glfw.null.keycodes[GLFW_NULL_SC_INSERT] = GLFW_KEY_INSERT; + _glfw.null.keycodes[GLFW_NULL_SC_DELETE] = GLFW_KEY_DELETE; + _glfw.null.keycodes[GLFW_NULL_SC_RIGHT] = GLFW_KEY_RIGHT; + _glfw.null.keycodes[GLFW_NULL_SC_LEFT] = GLFW_KEY_LEFT; + _glfw.null.keycodes[GLFW_NULL_SC_DOWN] = GLFW_KEY_DOWN; + _glfw.null.keycodes[GLFW_NULL_SC_UP] = GLFW_KEY_UP; + _glfw.null.keycodes[GLFW_NULL_SC_PAGE_UP] = GLFW_KEY_PAGE_UP; + _glfw.null.keycodes[GLFW_NULL_SC_PAGE_DOWN] = GLFW_KEY_PAGE_DOWN; + _glfw.null.keycodes[GLFW_NULL_SC_HOME] = GLFW_KEY_HOME; + _glfw.null.keycodes[GLFW_NULL_SC_END] = GLFW_KEY_END; + _glfw.null.keycodes[GLFW_NULL_SC_CAPS_LOCK] = GLFW_KEY_CAPS_LOCK; + _glfw.null.keycodes[GLFW_NULL_SC_SCROLL_LOCK] = GLFW_KEY_SCROLL_LOCK; + _glfw.null.keycodes[GLFW_NULL_SC_NUM_LOCK] = GLFW_KEY_NUM_LOCK; + _glfw.null.keycodes[GLFW_NULL_SC_PRINT_SCREEN] = GLFW_KEY_PRINT_SCREEN; + _glfw.null.keycodes[GLFW_NULL_SC_PAUSE] = GLFW_KEY_PAUSE; + _glfw.null.keycodes[GLFW_NULL_SC_F1] = GLFW_KEY_F1; + _glfw.null.keycodes[GLFW_NULL_SC_F2] = GLFW_KEY_F2; + _glfw.null.keycodes[GLFW_NULL_SC_F3] = GLFW_KEY_F3; + _glfw.null.keycodes[GLFW_NULL_SC_F4] = GLFW_KEY_F4; + _glfw.null.keycodes[GLFW_NULL_SC_F5] = GLFW_KEY_F5; + _glfw.null.keycodes[GLFW_NULL_SC_F6] = GLFW_KEY_F6; + _glfw.null.keycodes[GLFW_NULL_SC_F7] = GLFW_KEY_F7; + _glfw.null.keycodes[GLFW_NULL_SC_F8] = GLFW_KEY_F8; + _glfw.null.keycodes[GLFW_NULL_SC_F9] = GLFW_KEY_F9; + _glfw.null.keycodes[GLFW_NULL_SC_F10] = GLFW_KEY_F10; + _glfw.null.keycodes[GLFW_NULL_SC_F11] = GLFW_KEY_F11; + _glfw.null.keycodes[GLFW_NULL_SC_F12] = GLFW_KEY_F12; + _glfw.null.keycodes[GLFW_NULL_SC_F13] = GLFW_KEY_F13; + _glfw.null.keycodes[GLFW_NULL_SC_F14] = GLFW_KEY_F14; + _glfw.null.keycodes[GLFW_NULL_SC_F15] = GLFW_KEY_F15; + _glfw.null.keycodes[GLFW_NULL_SC_F16] = GLFW_KEY_F16; + _glfw.null.keycodes[GLFW_NULL_SC_F17] = GLFW_KEY_F17; + _glfw.null.keycodes[GLFW_NULL_SC_F18] = GLFW_KEY_F18; + _glfw.null.keycodes[GLFW_NULL_SC_F19] = GLFW_KEY_F19; + _glfw.null.keycodes[GLFW_NULL_SC_F20] = GLFW_KEY_F20; + _glfw.null.keycodes[GLFW_NULL_SC_F21] = GLFW_KEY_F21; + _glfw.null.keycodes[GLFW_NULL_SC_F22] = GLFW_KEY_F22; + _glfw.null.keycodes[GLFW_NULL_SC_F23] = GLFW_KEY_F23; + _glfw.null.keycodes[GLFW_NULL_SC_F24] = GLFW_KEY_F24; + _glfw.null.keycodes[GLFW_NULL_SC_F25] = GLFW_KEY_F25; + _glfw.null.keycodes[GLFW_NULL_SC_KP_0] = GLFW_KEY_KP_0; + _glfw.null.keycodes[GLFW_NULL_SC_KP_1] = GLFW_KEY_KP_1; + _glfw.null.keycodes[GLFW_NULL_SC_KP_2] = GLFW_KEY_KP_2; + _glfw.null.keycodes[GLFW_NULL_SC_KP_3] = GLFW_KEY_KP_3; + _glfw.null.keycodes[GLFW_NULL_SC_KP_4] = GLFW_KEY_KP_4; + _glfw.null.keycodes[GLFW_NULL_SC_KP_5] = GLFW_KEY_KP_5; + _glfw.null.keycodes[GLFW_NULL_SC_KP_6] = GLFW_KEY_KP_6; + _glfw.null.keycodes[GLFW_NULL_SC_KP_7] = GLFW_KEY_KP_7; + _glfw.null.keycodes[GLFW_NULL_SC_KP_8] = GLFW_KEY_KP_8; + _glfw.null.keycodes[GLFW_NULL_SC_KP_9] = GLFW_KEY_KP_9; + _glfw.null.keycodes[GLFW_NULL_SC_KP_DECIMAL] = GLFW_KEY_KP_DECIMAL; + _glfw.null.keycodes[GLFW_NULL_SC_KP_DIVIDE] = GLFW_KEY_KP_DIVIDE; + _glfw.null.keycodes[GLFW_NULL_SC_KP_MULTIPLY] = GLFW_KEY_KP_MULTIPLY; + _glfw.null.keycodes[GLFW_NULL_SC_KP_SUBTRACT] = GLFW_KEY_KP_SUBTRACT; + _glfw.null.keycodes[GLFW_NULL_SC_KP_ADD] = GLFW_KEY_KP_ADD; + _glfw.null.keycodes[GLFW_NULL_SC_KP_ENTER] = GLFW_KEY_KP_ENTER; + _glfw.null.keycodes[GLFW_NULL_SC_KP_EQUAL] = GLFW_KEY_KP_EQUAL; + _glfw.null.keycodes[GLFW_NULL_SC_LEFT_SHIFT] = GLFW_KEY_LEFT_SHIFT; + _glfw.null.keycodes[GLFW_NULL_SC_LEFT_CONTROL] = GLFW_KEY_LEFT_CONTROL; + _glfw.null.keycodes[GLFW_NULL_SC_LEFT_ALT] = GLFW_KEY_LEFT_ALT; + _glfw.null.keycodes[GLFW_NULL_SC_LEFT_SUPER] = GLFW_KEY_LEFT_SUPER; + _glfw.null.keycodes[GLFW_NULL_SC_RIGHT_SHIFT] = GLFW_KEY_RIGHT_SHIFT; + _glfw.null.keycodes[GLFW_NULL_SC_RIGHT_CONTROL] = GLFW_KEY_RIGHT_CONTROL; + _glfw.null.keycodes[GLFW_NULL_SC_RIGHT_ALT] = GLFW_KEY_RIGHT_ALT; + _glfw.null.keycodes[GLFW_NULL_SC_RIGHT_SUPER] = GLFW_KEY_RIGHT_SUPER; + _glfw.null.keycodes[GLFW_NULL_SC_MENU] = GLFW_KEY_MENU; + + for (scancode = GLFW_NULL_SC_FIRST; scancode < GLFW_NULL_SC_LAST; scancode++) + { + if (_glfw.null.keycodes[scancode] > 0) + _glfw.null.scancodes[_glfw.null.keycodes[scancode]] = scancode; + } + _glfwPollMonitorsNull(); return GLFW_TRUE; } diff --git a/src/null_platform.h b/src/null_platform.h index b646acb3..6d900111 100644 --- a/src/null_platform.h +++ b/src/null_platform.h @@ -33,6 +33,128 @@ #define GLFW_NULL_CURSOR_STATE #define GLFW_NULL_LIBRARY_CONTEXT_STATE +#define GLFW_NULL_SC_FIRST GLFW_NULL_SC_SPACE +#define GLFW_NULL_SC_SPACE 1 +#define GLFW_NULL_SC_APOSTROPHE 2 +#define GLFW_NULL_SC_COMMA 3 +#define GLFW_NULL_SC_MINUS 4 +#define GLFW_NULL_SC_PERIOD 5 +#define GLFW_NULL_SC_SLASH 6 +#define GLFW_NULL_SC_0 7 +#define GLFW_NULL_SC_1 8 +#define GLFW_NULL_SC_2 9 +#define GLFW_NULL_SC_3 10 +#define GLFW_NULL_SC_4 11 +#define GLFW_NULL_SC_5 12 +#define GLFW_NULL_SC_6 13 +#define GLFW_NULL_SC_7 14 +#define GLFW_NULL_SC_8 15 +#define GLFW_NULL_SC_9 16 +#define GLFW_NULL_SC_SEMICOLON 17 +#define GLFW_NULL_SC_EQUAL 18 +#define GLFW_NULL_SC_LEFT_BRACKET 19 +#define GLFW_NULL_SC_BACKSLASH 20 +#define GLFW_NULL_SC_RIGHT_BRACKET 21 +#define GLFW_NULL_SC_GRAVE_ACCENT 22 +#define GLFW_NULL_SC_WORLD_1 23 +#define GLFW_NULL_SC_WORLD_2 24 +#define GLFW_NULL_SC_ESCAPE 25 +#define GLFW_NULL_SC_ENTER 26 +#define GLFW_NULL_SC_TAB 27 +#define GLFW_NULL_SC_BACKSPACE 28 +#define GLFW_NULL_SC_INSERT 29 +#define GLFW_NULL_SC_DELETE 30 +#define GLFW_NULL_SC_RIGHT 31 +#define GLFW_NULL_SC_LEFT 32 +#define GLFW_NULL_SC_DOWN 33 +#define GLFW_NULL_SC_UP 34 +#define GLFW_NULL_SC_PAGE_UP 35 +#define GLFW_NULL_SC_PAGE_DOWN 36 +#define GLFW_NULL_SC_HOME 37 +#define GLFW_NULL_SC_END 38 +#define GLFW_NULL_SC_CAPS_LOCK 39 +#define GLFW_NULL_SC_SCROLL_LOCK 40 +#define GLFW_NULL_SC_NUM_LOCK 41 +#define GLFW_NULL_SC_PRINT_SCREEN 42 +#define GLFW_NULL_SC_PAUSE 43 +#define GLFW_NULL_SC_A 44 +#define GLFW_NULL_SC_B 45 +#define GLFW_NULL_SC_C 46 +#define GLFW_NULL_SC_D 47 +#define GLFW_NULL_SC_E 48 +#define GLFW_NULL_SC_F 49 +#define GLFW_NULL_SC_G 50 +#define GLFW_NULL_SC_H 51 +#define GLFW_NULL_SC_I 52 +#define GLFW_NULL_SC_J 53 +#define GLFW_NULL_SC_K 54 +#define GLFW_NULL_SC_L 55 +#define GLFW_NULL_SC_M 56 +#define GLFW_NULL_SC_N 57 +#define GLFW_NULL_SC_O 58 +#define GLFW_NULL_SC_P 59 +#define GLFW_NULL_SC_Q 60 +#define GLFW_NULL_SC_R 61 +#define GLFW_NULL_SC_S 62 +#define GLFW_NULL_SC_T 63 +#define GLFW_NULL_SC_U 64 +#define GLFW_NULL_SC_V 65 +#define GLFW_NULL_SC_W 66 +#define GLFW_NULL_SC_X 67 +#define GLFW_NULL_SC_Y 68 +#define GLFW_NULL_SC_Z 69 +#define GLFW_NULL_SC_F1 70 +#define GLFW_NULL_SC_F2 71 +#define GLFW_NULL_SC_F3 72 +#define GLFW_NULL_SC_F4 73 +#define GLFW_NULL_SC_F5 74 +#define GLFW_NULL_SC_F6 75 +#define GLFW_NULL_SC_F7 76 +#define GLFW_NULL_SC_F8 77 +#define GLFW_NULL_SC_F9 78 +#define GLFW_NULL_SC_F10 79 +#define GLFW_NULL_SC_F11 80 +#define GLFW_NULL_SC_F12 81 +#define GLFW_NULL_SC_F13 82 +#define GLFW_NULL_SC_F14 83 +#define GLFW_NULL_SC_F15 84 +#define GLFW_NULL_SC_F16 85 +#define GLFW_NULL_SC_F17 86 +#define GLFW_NULL_SC_F18 87 +#define GLFW_NULL_SC_F19 88 +#define GLFW_NULL_SC_F20 89 +#define GLFW_NULL_SC_F21 90 +#define GLFW_NULL_SC_F22 91 +#define GLFW_NULL_SC_F23 92 +#define GLFW_NULL_SC_F24 93 +#define GLFW_NULL_SC_F25 94 +#define GLFW_NULL_SC_KP_0 95 +#define GLFW_NULL_SC_KP_1 96 +#define GLFW_NULL_SC_KP_2 97 +#define GLFW_NULL_SC_KP_3 98 +#define GLFW_NULL_SC_KP_4 99 +#define GLFW_NULL_SC_KP_5 100 +#define GLFW_NULL_SC_KP_6 101 +#define GLFW_NULL_SC_KP_7 102 +#define GLFW_NULL_SC_KP_8 103 +#define GLFW_NULL_SC_KP_9 104 +#define GLFW_NULL_SC_KP_DECIMAL 105 +#define GLFW_NULL_SC_KP_DIVIDE 106 +#define GLFW_NULL_SC_KP_MULTIPLY 107 +#define GLFW_NULL_SC_KP_SUBTRACT 108 +#define GLFW_NULL_SC_KP_ADD 109 +#define GLFW_NULL_SC_KP_ENTER 110 +#define GLFW_NULL_SC_KP_EQUAL 111 +#define GLFW_NULL_SC_LEFT_SHIFT 112 +#define GLFW_NULL_SC_LEFT_CONTROL 113 +#define GLFW_NULL_SC_LEFT_ALT 114 +#define GLFW_NULL_SC_LEFT_SUPER 115 +#define GLFW_NULL_SC_RIGHT_SHIFT 116 +#define GLFW_NULL_SC_RIGHT_CONTROL 117 +#define GLFW_NULL_SC_RIGHT_ALT 118 +#define GLFW_NULL_SC_RIGHT_SUPER 119 +#define GLFW_NULL_SC_MENU 120 +#define GLFW_NULL_SC_LAST GLFW_NULL_SC_MENU // Null-specific per-window data // @@ -68,6 +190,8 @@ typedef struct _GLFWlibraryNull int ycursor; char* clipboardString; _GLFWwindow* focusedWindow; + uint16_t keycodes[GLFW_NULL_SC_LAST + 1]; + uint8_t scancodes[GLFW_KEY_LAST + 1]; } _GLFWlibraryNull; void _glfwPollMonitorsNull(void); diff --git a/src/null_window.c b/src/null_window.c index 5cdf3e23..e0bbb3b6 100644 --- a/src/null_window.c +++ b/src/null_window.c @@ -568,7 +568,7 @@ EGLNativeWindowType _glfwGetEGLNativeWindowNull(_GLFWwindow* window) const char* _glfwGetScancodeNameNull(int scancode) { - if (scancode < GLFW_KEY_SPACE || scancode > GLFW_KEY_LAST) + if (scancode < GLFW_NULL_SC_FIRST || scancode > GLFW_NULL_SC_LAST) { _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode); return NULL; @@ -576,117 +576,117 @@ const char* _glfwGetScancodeNameNull(int scancode) switch (scancode) { - case GLFW_KEY_APOSTROPHE: + case GLFW_NULL_SC_APOSTROPHE: return "'"; - case GLFW_KEY_COMMA: + case GLFW_NULL_SC_COMMA: return ","; - case GLFW_KEY_MINUS: - case GLFW_KEY_KP_SUBTRACT: + case GLFW_NULL_SC_MINUS: + case GLFW_NULL_SC_KP_SUBTRACT: return "-"; - case GLFW_KEY_PERIOD: - case GLFW_KEY_KP_DECIMAL: + case GLFW_NULL_SC_PERIOD: + case GLFW_NULL_SC_KP_DECIMAL: return "."; - case GLFW_KEY_SLASH: - case GLFW_KEY_KP_DIVIDE: + case GLFW_NULL_SC_SLASH: + case GLFW_NULL_SC_KP_DIVIDE: return "/"; - case GLFW_KEY_SEMICOLON: + case GLFW_NULL_SC_SEMICOLON: return ";"; - case GLFW_KEY_EQUAL: - case GLFW_KEY_KP_EQUAL: + case GLFW_NULL_SC_EQUAL: + case GLFW_NULL_SC_KP_EQUAL: return "="; - case GLFW_KEY_LEFT_BRACKET: + case GLFW_NULL_SC_LEFT_BRACKET: return "["; - case GLFW_KEY_RIGHT_BRACKET: + case GLFW_NULL_SC_RIGHT_BRACKET: return "]"; - case GLFW_KEY_KP_MULTIPLY: + case GLFW_NULL_SC_KP_MULTIPLY: return "*"; - case GLFW_KEY_KP_ADD: + case GLFW_NULL_SC_KP_ADD: return "+"; - case GLFW_KEY_BACKSLASH: - case GLFW_KEY_WORLD_1: - case GLFW_KEY_WORLD_2: + case GLFW_NULL_SC_BACKSLASH: + case GLFW_NULL_SC_WORLD_1: + case GLFW_NULL_SC_WORLD_2: return "\\"; - case GLFW_KEY_0: - case GLFW_KEY_KP_0: + case GLFW_NULL_SC_0: + case GLFW_NULL_SC_KP_0: return "0"; - case GLFW_KEY_1: - case GLFW_KEY_KP_1: + case GLFW_NULL_SC_1: + case GLFW_NULL_SC_KP_1: return "1"; - case GLFW_KEY_2: - case GLFW_KEY_KP_2: + case GLFW_NULL_SC_2: + case GLFW_NULL_SC_KP_2: return "2"; - case GLFW_KEY_3: - case GLFW_KEY_KP_3: + case GLFW_NULL_SC_3: + case GLFW_NULL_SC_KP_3: return "3"; - case GLFW_KEY_4: - case GLFW_KEY_KP_4: + case GLFW_NULL_SC_4: + case GLFW_NULL_SC_KP_4: return "4"; - case GLFW_KEY_5: - case GLFW_KEY_KP_5: + case GLFW_NULL_SC_5: + case GLFW_NULL_SC_KP_5: return "5"; - case GLFW_KEY_6: - case GLFW_KEY_KP_6: + case GLFW_NULL_SC_6: + case GLFW_NULL_SC_KP_6: return "6"; - case GLFW_KEY_7: - case GLFW_KEY_KP_7: + case GLFW_NULL_SC_7: + case GLFW_NULL_SC_KP_7: return "7"; - case GLFW_KEY_8: - case GLFW_KEY_KP_8: + case GLFW_NULL_SC_8: + case GLFW_NULL_SC_KP_8: return "8"; - case GLFW_KEY_9: - case GLFW_KEY_KP_9: + case GLFW_NULL_SC_9: + case GLFW_NULL_SC_KP_9: return "9"; - case GLFW_KEY_A: + case GLFW_NULL_SC_A: return "a"; - case GLFW_KEY_B: + case GLFW_NULL_SC_B: return "b"; - case GLFW_KEY_C: + case GLFW_NULL_SC_C: return "c"; - case GLFW_KEY_D: + case GLFW_NULL_SC_D: return "d"; - case GLFW_KEY_E: + case GLFW_NULL_SC_E: return "e"; - case GLFW_KEY_F: + case GLFW_NULL_SC_F: return "f"; - case GLFW_KEY_G: + case GLFW_NULL_SC_G: return "g"; - case GLFW_KEY_H: + case GLFW_NULL_SC_H: return "h"; - case GLFW_KEY_I: + case GLFW_NULL_SC_I: return "i"; - case GLFW_KEY_J: + case GLFW_NULL_SC_J: return "j"; - case GLFW_KEY_K: + case GLFW_NULL_SC_K: return "k"; - case GLFW_KEY_L: + case GLFW_NULL_SC_L: return "l"; - case GLFW_KEY_M: + case GLFW_NULL_SC_M: return "m"; - case GLFW_KEY_N: + case GLFW_NULL_SC_N: return "n"; - case GLFW_KEY_O: + case GLFW_NULL_SC_O: return "o"; - case GLFW_KEY_P: + case GLFW_NULL_SC_P: return "p"; - case GLFW_KEY_Q: + case GLFW_NULL_SC_Q: return "q"; - case GLFW_KEY_R: + case GLFW_NULL_SC_R: return "r"; - case GLFW_KEY_S: + case GLFW_NULL_SC_S: return "s"; - case GLFW_KEY_T: + case GLFW_NULL_SC_T: return "t"; - case GLFW_KEY_U: + case GLFW_NULL_SC_U: return "u"; - case GLFW_KEY_V: + case GLFW_NULL_SC_V: return "v"; - case GLFW_KEY_W: + case GLFW_NULL_SC_W: return "w"; - case GLFW_KEY_X: + case GLFW_NULL_SC_X: return "x"; - case GLFW_KEY_Y: + case GLFW_NULL_SC_Y: return "y"; - case GLFW_KEY_Z: + case GLFW_NULL_SC_Z: return "z"; } @@ -695,7 +695,7 @@ const char* _glfwGetScancodeNameNull(int scancode) int _glfwGetKeyScancodeNull(int key) { - return key; + return _glfw.null.scancodes[key]; } void _glfwGetRequiredInstanceExtensionsNull(char** extensions) From 6f2d7064be3bcc57c46a319898dc618ee121c2fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 20 Jan 2023 06:50:52 +0100 Subject: [PATCH 03/50] Make glfwinfo try Vulkan even if GL/GLES fails --- tests/glfwinfo.c | 349 +++++++++++++++++++++++------------------------ 1 file changed, 173 insertions(+), 176 deletions(-) diff --git a/tests/glfwinfo.c b/tests/glfwinfo.c index eda2f821..ea3302e0 100644 --- a/tests/glfwinfo.c +++ b/tests/glfwinfo.c @@ -710,190 +710,187 @@ int main(int argc, char** argv) glfwWindowHint(GLFW_COCOA_GRAPHICS_SWITCHING, cocoa_graphics_switching); GLFWwindow* window = glfwCreateWindow(200, 200, "Version", NULL, NULL); - if (!window) + if (window) { - glfwTerminate(); - exit(EXIT_FAILURE); - } + glfwMakeContextCurrent(window); + gladLoadGL(glfwGetProcAddress); - glfwMakeContextCurrent(window); - gladLoadGL(glfwGetProcAddress); + const GLenum error = glGetError(); + if (error != GL_NO_ERROR) + printf("*** OpenGL error after make current: 0x%08x ***\n", error); - const GLenum error = glGetError(); - if (error != GL_NO_ERROR) - printf("*** OpenGL error after make current: 0x%08x ***\n", error); + // Report client API version - // Report client API version + const int client = glfwGetWindowAttrib(window, GLFW_CLIENT_API); + const int major = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MAJOR); + const int minor = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MINOR); + const int revision = glfwGetWindowAttrib(window, GLFW_CONTEXT_REVISION); + const int profile = glfwGetWindowAttrib(window, GLFW_OPENGL_PROFILE); - const int client = glfwGetWindowAttrib(window, GLFW_CLIENT_API); - const int major = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MAJOR); - const int minor = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MINOR); - const int revision = glfwGetWindowAttrib(window, GLFW_CONTEXT_REVISION); - const int profile = glfwGetWindowAttrib(window, GLFW_OPENGL_PROFILE); - - printf("%s context version string: \"%s\"\n", - get_api_name(client), - glGetString(GL_VERSION)); - - printf("%s context version parsed by GLFW: %u.%u.%u\n", - get_api_name(client), - major, minor, revision); - - // Report client API context properties - - if (client == GLFW_OPENGL_API) - { - if (major >= 3) - { - GLint flags; - - glGetIntegerv(GL_CONTEXT_FLAGS, &flags); - printf("%s context flags (0x%08x):", get_api_name(client), flags); - - if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT) - printf(" forward-compatible"); - if (flags & 2/*GL_CONTEXT_FLAG_DEBUG_BIT*/) - printf(" debug"); - if (flags & GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB) - printf(" robustness"); - if (flags & 8/*GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR*/) - printf(" no-error"); - putchar('\n'); - - printf("%s context flags parsed by GLFW:", get_api_name(client)); - - if (glfwGetWindowAttrib(window, GLFW_OPENGL_FORWARD_COMPAT)) - printf(" forward-compatible"); - if (glfwGetWindowAttrib(window, GLFW_CONTEXT_DEBUG)) - printf(" debug"); - if (glfwGetWindowAttrib(window, GLFW_CONTEXT_ROBUSTNESS) == GLFW_LOSE_CONTEXT_ON_RESET) - printf(" robustness"); - if (glfwGetWindowAttrib(window, GLFW_CONTEXT_NO_ERROR)) - printf(" no-error"); - putchar('\n'); - } - - if (major >= 4 || (major == 3 && minor >= 2)) - { - GLint mask; - glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask); - - printf("%s profile mask (0x%08x): %s\n", - get_api_name(client), - mask, - get_profile_name_gl(mask)); - - printf("%s profile mask parsed by GLFW: %s\n", - get_api_name(client), - get_profile_name_glfw(profile)); - } - - if (GLAD_GL_ARB_robustness) - { - const int robustness = glfwGetWindowAttrib(window, GLFW_CONTEXT_ROBUSTNESS); - GLint strategy; - glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy); - - printf("%s robustness strategy (0x%08x): %s\n", - get_api_name(client), - strategy, - get_strategy_name_gl(strategy)); - - printf("%s robustness strategy parsed by GLFW: %s\n", - get_api_name(client), - get_strategy_name_glfw(robustness)); - } - } - - printf("%s context renderer string: \"%s\"\n", - get_api_name(client), - glGetString(GL_RENDERER)); - printf("%s context vendor string: \"%s\"\n", - get_api_name(client), - glGetString(GL_VENDOR)); - - if (major >= 2) - { - printf("%s context shading language version: \"%s\"\n", + printf("%s context version string: \"%s\"\n", get_api_name(client), - glGetString(GL_SHADING_LANGUAGE_VERSION)); + glGetString(GL_VERSION)); + + printf("%s context version parsed by GLFW: %u.%u.%u\n", + get_api_name(client), + major, minor, revision); + + // Report client API context properties + + if (client == GLFW_OPENGL_API) + { + if (major >= 3) + { + GLint flags; + + glGetIntegerv(GL_CONTEXT_FLAGS, &flags); + printf("%s context flags (0x%08x):", get_api_name(client), flags); + + if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT) + printf(" forward-compatible"); + if (flags & 2/*GL_CONTEXT_FLAG_DEBUG_BIT*/) + printf(" debug"); + if (flags & GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB) + printf(" robustness"); + if (flags & 8/*GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR*/) + printf(" no-error"); + putchar('\n'); + + printf("%s context flags parsed by GLFW:", get_api_name(client)); + + if (glfwGetWindowAttrib(window, GLFW_OPENGL_FORWARD_COMPAT)) + printf(" forward-compatible"); + if (glfwGetWindowAttrib(window, GLFW_CONTEXT_DEBUG)) + printf(" debug"); + if (glfwGetWindowAttrib(window, GLFW_CONTEXT_ROBUSTNESS) == GLFW_LOSE_CONTEXT_ON_RESET) + printf(" robustness"); + if (glfwGetWindowAttrib(window, GLFW_CONTEXT_NO_ERROR)) + printf(" no-error"); + putchar('\n'); + } + + if (major >= 4 || (major == 3 && minor >= 2)) + { + GLint mask; + glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask); + + printf("%s profile mask (0x%08x): %s\n", + get_api_name(client), + mask, + get_profile_name_gl(mask)); + + printf("%s profile mask parsed by GLFW: %s\n", + get_api_name(client), + get_profile_name_glfw(profile)); + } + + if (GLAD_GL_ARB_robustness) + { + const int robustness = glfwGetWindowAttrib(window, GLFW_CONTEXT_ROBUSTNESS); + GLint strategy; + glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy); + + printf("%s robustness strategy (0x%08x): %s\n", + get_api_name(client), + strategy, + get_strategy_name_gl(strategy)); + + printf("%s robustness strategy parsed by GLFW: %s\n", + get_api_name(client), + get_strategy_name_glfw(robustness)); + } + } + + printf("%s context renderer string: \"%s\"\n", + get_api_name(client), + glGetString(GL_RENDERER)); + printf("%s context vendor string: \"%s\"\n", + get_api_name(client), + glGetString(GL_VENDOR)); + + if (major >= 2) + { + printf("%s context shading language version: \"%s\"\n", + get_api_name(client), + glGetString(GL_SHADING_LANGUAGE_VERSION)); + } + + printf("%s framebuffer:\n", get_api_name(client)); + + GLint redbits, greenbits, bluebits, alphabits, depthbits, stencilbits; + + if (client == GLFW_OPENGL_API && profile == GLFW_OPENGL_CORE_PROFILE) + { + glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, + GL_BACK_LEFT, + GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE, + &redbits); + glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, + GL_BACK_LEFT, + GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE, + &greenbits); + glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, + GL_BACK_LEFT, + GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE, + &bluebits); + glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, + GL_BACK_LEFT, + GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE, + &alphabits); + glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, + GL_DEPTH, + GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, + &depthbits); + glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, + GL_STENCIL, + GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE, + &stencilbits); + } + else + { + glGetIntegerv(GL_RED_BITS, &redbits); + glGetIntegerv(GL_GREEN_BITS, &greenbits); + glGetIntegerv(GL_BLUE_BITS, &bluebits); + glGetIntegerv(GL_ALPHA_BITS, &alphabits); + glGetIntegerv(GL_DEPTH_BITS, &depthbits); + glGetIntegerv(GL_STENCIL_BITS, &stencilbits); + } + + printf(" red: %u green: %u blue: %u alpha: %u depth: %u stencil: %u\n", + redbits, greenbits, bluebits, alphabits, depthbits, stencilbits); + + if (client == GLFW_OPENGL_ES_API || + GLAD_GL_ARB_multisample || + major > 1 || minor >= 3) + { + GLint samples, samplebuffers; + glGetIntegerv(GL_SAMPLES, &samples); + glGetIntegerv(GL_SAMPLE_BUFFERS, &samplebuffers); + + printf(" samples: %u sample buffers: %u\n", samples, samplebuffers); + } + + if (client == GLFW_OPENGL_API && profile != GLFW_OPENGL_CORE_PROFILE) + { + GLint accumredbits, accumgreenbits, accumbluebits, accumalphabits; + GLint auxbuffers; + + glGetIntegerv(GL_ACCUM_RED_BITS, &accumredbits); + glGetIntegerv(GL_ACCUM_GREEN_BITS, &accumgreenbits); + glGetIntegerv(GL_ACCUM_BLUE_BITS, &accumbluebits); + glGetIntegerv(GL_ACCUM_ALPHA_BITS, &accumalphabits); + glGetIntegerv(GL_AUX_BUFFERS, &auxbuffers); + + printf(" accum red: %u accum green: %u accum blue: %u accum alpha: %u aux buffers: %u\n", + accumredbits, accumgreenbits, accumbluebits, accumalphabits, auxbuffers); + } + + if (list_extensions) + list_context_extensions(client, major, minor); + + glfwDestroyWindow(window); } - printf("%s framebuffer:\n", get_api_name(client)); - - GLint redbits, greenbits, bluebits, alphabits, depthbits, stencilbits; - - if (client == GLFW_OPENGL_API && profile == GLFW_OPENGL_CORE_PROFILE) - { - glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, - GL_BACK_LEFT, - GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE, - &redbits); - glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, - GL_BACK_LEFT, - GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE, - &greenbits); - glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, - GL_BACK_LEFT, - GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE, - &bluebits); - glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, - GL_BACK_LEFT, - GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE, - &alphabits); - glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, - GL_DEPTH, - GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, - &depthbits); - glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, - GL_STENCIL, - GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE, - &stencilbits); - } - else - { - glGetIntegerv(GL_RED_BITS, &redbits); - glGetIntegerv(GL_GREEN_BITS, &greenbits); - glGetIntegerv(GL_BLUE_BITS, &bluebits); - glGetIntegerv(GL_ALPHA_BITS, &alphabits); - glGetIntegerv(GL_DEPTH_BITS, &depthbits); - glGetIntegerv(GL_STENCIL_BITS, &stencilbits); - } - - printf(" red: %u green: %u blue: %u alpha: %u depth: %u stencil: %u\n", - redbits, greenbits, bluebits, alphabits, depthbits, stencilbits); - - if (client == GLFW_OPENGL_ES_API || - GLAD_GL_ARB_multisample || - major > 1 || minor >= 3) - { - GLint samples, samplebuffers; - glGetIntegerv(GL_SAMPLES, &samples); - glGetIntegerv(GL_SAMPLE_BUFFERS, &samplebuffers); - - printf(" samples: %u sample buffers: %u\n", samples, samplebuffers); - } - - if (client == GLFW_OPENGL_API && profile != GLFW_OPENGL_CORE_PROFILE) - { - GLint accumredbits, accumgreenbits, accumbluebits, accumalphabits; - GLint auxbuffers; - - glGetIntegerv(GL_ACCUM_RED_BITS, &accumredbits); - glGetIntegerv(GL_ACCUM_GREEN_BITS, &accumgreenbits); - glGetIntegerv(GL_ACCUM_BLUE_BITS, &accumbluebits); - glGetIntegerv(GL_ACCUM_ALPHA_BITS, &accumalphabits); - glGetIntegerv(GL_AUX_BUFFERS, &auxbuffers); - - printf(" accum red: %u accum green: %u accum blue: %u accum alpha: %u aux buffers: %u\n", - accumredbits, accumgreenbits, accumbluebits, accumalphabits, auxbuffers); - } - - if (list_extensions) - list_context_extensions(client, major, minor); - - glfwDestroyWindow(window); - glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); window = glfwCreateWindow(200, 200, "Version", NULL, NULL); From f27daa34ada52c67bf2f258e1135254dc4fa5b34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 26 Jan 2023 18:18:14 +0100 Subject: [PATCH 04/50] Fix glfwinfo output of Vulkan layer spec version --- tests/glfwinfo.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/glfwinfo.c b/tests/glfwinfo.c index ea3302e0..12acbccc 100644 --- a/tests/glfwinfo.c +++ b/tests/glfwinfo.c @@ -266,9 +266,10 @@ static void list_vulkan_instance_layers(void) for (uint32_t i = 0; i < lp_count; i++) { - printf(" %s (spec version %u) \"%s\"\n", + printf(" %s (spec version %u.%u) \"%s\"\n", lp[i].layerName, - lp[i].specVersion >> 22, + VK_VERSION_MAJOR(lp[i].specVersion), + VK_VERSION_MINOR(lp[i].specVersion), lp[i].description); } @@ -286,9 +287,10 @@ static void list_vulkan_device_layers(VkInstance instance, VkPhysicalDevice devi for (uint32_t i = 0; i < lp_count; i++) { - printf(" %s (spec version %u) \"%s\"\n", + printf(" %s (spec version %u.%u) \"%s\"\n", lp[i].layerName, - lp[i].specVersion >> 22, + VK_VERSION_MAJOR(lp[i].specVersion), + VK_VERSION_MINOR(lp[i].specVersion), lp[i].description); } From 0b94e1b29b5be16fc0979de8ac107e93ae440419 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Fri, 7 Oct 2022 21:26:21 -0400 Subject: [PATCH 05/50] Wayland: Fix detection of joysticks after init Closes #2198 --- src/wl_window.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wl_window.c b/src/wl_window.c index 5a35c001..52d3b9eb 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1095,6 +1095,11 @@ static void inputText(_GLFWwindow* window, uint32_t scancode) static void handleEvents(double* timeout) { +#if defined(GLFW_BUILD_LINUX_JOYSTICK) + if (_glfw.joysticksInitialized) + _glfwDetectJoystickConnectionLinux(); +#endif + GLFWbool event = GLFW_FALSE; struct pollfd fds[4] = { From 3fa2360720eeba1964df3c0ecf4b5df8648a8e52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 31 Mar 2023 15:30:20 +0200 Subject: [PATCH 06/50] Update changelog Related to #2198 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 08a3ba5b..7815c72a 100644 --- a/README.md +++ b/README.md @@ -383,6 +383,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: `GLFW_DECORATED` was ignored when showing a window with XDG decorations - [Wayland] Bugfix: Connecting a mouse after `glfwInit` would segfault (#1450) + - [Wayland] Bugfix: Joysticks connected after `glfwInit` were not detected (#2198) - [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [Linux] Bugfix: Joysticks without buttons were ignored (#2042,#2043) From 00a663dafd3bc214181a2987af1f5dac81e3b053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 25 Apr 2023 22:47:18 +0200 Subject: [PATCH 07/50] Wayland: Fix fallback decorations emitting errors A GLFW_CURSOR_UNAVAILABLE error would be emitted each time the cursor moved over the fallback decorations if the standard cursor shape appropriate for that part was missing on the system. These errors served no useful purpose and have been removed. --- README.md | 1 + src/wl_window.c | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7815c72a..e3d18ec8 100644 --- a/README.md +++ b/README.md @@ -384,6 +384,7 @@ information on what to include when reporting a bug. decorations - [Wayland] Bugfix: Connecting a mouse after `glfwInit` would segfault (#1450) - [Wayland] Bugfix: Joysticks connected after `glfwInit` were not detected (#2198) + - [Wayland] Bugfix: Fallback decorations emitted `GLFW_CURSOR_UNAVAILABLE` errors - [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [Linux] Bugfix: Joysticks without buttons were ignored (#2042,#2043) diff --git a/src/wl_window.c b/src/wl_window.c index 52d3b9eb..43090112 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1327,11 +1327,8 @@ static void setCursor(_GLFWwindow* window, const char* name) cursor = wl_cursor_theme_get_cursor(theme, name); if (!cursor) - { - _glfwInputError(GLFW_CURSOR_UNAVAILABLE, - "Wayland: Standard cursor shape unavailable"); return; - } + // TODO: handle animated cursors too. image = cursor->images[0]; From 6b48f2be97057cf436c6eb3059bbbfdcb5f66d7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 25 Apr 2023 22:53:17 +0200 Subject: [PATCH 08/50] Wayland: Merge function called once This brings together the two halves of the cursor setting logic for the fallback decorations. --- src/wl_window.c | 85 ++++++++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 43 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index 43090112..fe0a2b79 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1308,48 +1308,6 @@ static void pointerHandleLeave(void* userData, _glfwInputCursorEnter(window, GLFW_FALSE); } -static void setCursor(_GLFWwindow* window, const char* name) -{ - struct wl_buffer* buffer; - struct wl_cursor* cursor; - struct wl_cursor_image* image; - struct wl_surface* surface = _glfw.wl.cursorSurface; - struct wl_cursor_theme* theme = _glfw.wl.cursorTheme; - int scale = 1; - - if (window->wl.contentScale > 1 && _glfw.wl.cursorThemeHiDPI) - { - // We only support up to scale=2 for now, since libwayland-cursor - // requires us to load a different theme for each size. - scale = 2; - theme = _glfw.wl.cursorThemeHiDPI; - } - - cursor = wl_cursor_theme_get_cursor(theme, name); - if (!cursor) - return; - - // TODO: handle animated cursors too. - image = cursor->images[0]; - - if (!image) - return; - - buffer = wl_cursor_image_get_buffer(image); - if (!buffer) - return; - wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial, - surface, - image->hotspot_x / scale, - image->hotspot_y / scale); - wl_surface_set_buffer_scale(surface, scale); - wl_surface_attach(surface, buffer, 0, 0); - wl_surface_damage(surface, 0, 0, - image->width, image->height); - wl_surface_commit(surface); - _glfw.wl.cursorPreviousName = name; -} - static void pointerHandleMotion(void* userData, struct wl_pointer* pointer, uint32_t time, @@ -1405,8 +1363,49 @@ static void pointerHandleMotion(void* userData, default: assert(0); } + if (_glfw.wl.cursorPreviousName != cursorName) - setCursor(window, cursorName); + { + struct wl_buffer* buffer; + struct wl_cursor* cursor; + struct wl_cursor_image* image; + struct wl_surface* surface = _glfw.wl.cursorSurface; + struct wl_cursor_theme* theme = _glfw.wl.cursorTheme; + int scale = 1; + + if (window->wl.contentScale > 1 && _glfw.wl.cursorThemeHiDPI) + { + // We only support up to scale=2 for now, since libwayland-cursor + // requires us to load a different theme for each size. + scale = 2; + theme = _glfw.wl.cursorThemeHiDPI; + } + + cursor = wl_cursor_theme_get_cursor(theme, name); + if (!cursor) + return; + + // TODO: handle animated cursors too. + image = cursor->images[0]; + + if (!image) + return; + + buffer = wl_cursor_image_get_buffer(image); + if (!buffer) + return; + + wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial, + surface, + image->hotspot_x / scale, + image->hotspot_y / scale); + wl_surface_set_buffer_scale(surface, scale); + wl_surface_attach(surface, buffer, 0, 0); + wl_surface_damage(surface, 0, 0, + image->width, image->height); + wl_surface_commit(surface); + _glfw.wl.cursorPreviousName = name; + } } static void pointerHandleButton(void* userData, From 3eaf1255b29fdf5c2895856c7be7d7185ef2b241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 25 Apr 2023 22:59:25 +0200 Subject: [PATCH 09/50] Wayland: Cleanup Update naming and declarations to current standard. --- src/wl_window.c | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index fe0a2b79..7b9e3d0d 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1315,47 +1315,47 @@ static void pointerHandleMotion(void* userData, wl_fixed_t sy) { _GLFWwindow* window = _glfw.wl.pointerFocus; - const char* cursorName = NULL; - double x, y; - if (!window) return; if (window->cursorMode == GLFW_CURSOR_DISABLED) return; - x = wl_fixed_to_double(sx); - y = wl_fixed_to_double(sy); - window->wl.cursorPosX = x; - window->wl.cursorPosY = y; + + const double xpos = wl_fixed_to_double(sx); + const double ypos = wl_fixed_to_double(sy); + window->wl.cursorPosX = xpos; + window->wl.cursorPosY = ypos; + + const char* cursorName = NULL; switch (window->wl.decorations.focus) { case GLFW_MAIN_WINDOW: _glfw.wl.cursorPreviousName = NULL; - _glfwInputCursorPos(window, x, y); + _glfwInputCursorPos(window, xpos, ypos); return; case GLFW_TOP_DECORATION: - if (y < GLFW_BORDER_SIZE) + if (ypos < GLFW_BORDER_SIZE) cursorName = "n-resize"; else cursorName = "left_ptr"; break; case GLFW_LEFT_DECORATION: - if (y < GLFW_BORDER_SIZE) + if (ypos < GLFW_BORDER_SIZE) cursorName = "nw-resize"; else cursorName = "w-resize"; break; case GLFW_RIGHT_DECORATION: - if (y < GLFW_BORDER_SIZE) + if (ypos < GLFW_BORDER_SIZE) cursorName = "ne-resize"; else cursorName = "e-resize"; break; case GLFW_BOTTOM_DECORATION: - if (x < GLFW_BORDER_SIZE) + if (xpos < GLFW_BORDER_SIZE) cursorName = "sw-resize"; - else if (x > window->wl.width + GLFW_BORDER_SIZE) + else if (xpos > window->wl.width + GLFW_BORDER_SIZE) cursorName = "se-resize"; else cursorName = "s-resize"; @@ -1366,9 +1366,6 @@ static void pointerHandleMotion(void* userData, if (_glfw.wl.cursorPreviousName != cursorName) { - struct wl_buffer* buffer; - struct wl_cursor* cursor; - struct wl_cursor_image* image; struct wl_surface* surface = _glfw.wl.cursorSurface; struct wl_cursor_theme* theme = _glfw.wl.cursorTheme; int scale = 1; @@ -1381,17 +1378,16 @@ static void pointerHandleMotion(void* userData, theme = _glfw.wl.cursorThemeHiDPI; } - cursor = wl_cursor_theme_get_cursor(theme, name); + struct wl_cursor* cursor = wl_cursor_theme_get_cursor(theme, cursorName); if (!cursor) return; // TODO: handle animated cursors too. - image = cursor->images[0]; - + struct wl_cursor_image* image = cursor->images[0]; if (!image) return; - buffer = wl_cursor_image_get_buffer(image); + struct wl_buffer* buffer = wl_cursor_image_get_buffer(image); if (!buffer) return; @@ -1401,10 +1397,10 @@ static void pointerHandleMotion(void* userData, image->hotspot_y / scale); wl_surface_set_buffer_scale(surface, scale); wl_surface_attach(surface, buffer, 0, 0); - wl_surface_damage(surface, 0, 0, - image->width, image->height); + wl_surface_damage(surface, 0, 0, image->width, image->height); wl_surface_commit(surface); - _glfw.wl.cursorPreviousName = name; + + _glfw.wl.cursorPreviousName = cursorName; } } From 93a3ba808067134b5a964b1a1c44701450386fe4 Mon Sep 17 00:00:00 2001 From: moritz-h <7849248+moritz-h@users.noreply.github.com> Date: Wed, 15 Nov 2023 16:37:46 +0100 Subject: [PATCH 10/50] Win32: Add library name suffix to pkg-config file Closes #2386 --- CMake/glfw3.pc.in | 2 +- src/CMakeLists.txt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CMake/glfw3.pc.in b/CMake/glfw3.pc.in index 37f4efd9..36ee218e 100644 --- a/CMake/glfw3.pc.in +++ b/CMake/glfw3.pc.in @@ -8,6 +8,6 @@ Description: A multi-platform library for OpenGL, window and input Version: @GLFW_VERSION@ URL: https://www.glfw.org/ Requires.private: @GLFW_PKG_CONFIG_REQUIRES_PRIVATE@ -Libs: -L${libdir} -l@GLFW_LIB_NAME@ +Libs: -L${libdir} -l@GLFW_LIB_NAME@@GLFW_LIB_NAME_SUFFIX@ Libs.private: @GLFW_PKG_CONFIG_LIBS_PRIVATE@ Cflags: -I${includedir} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 01f191c9..5acac0d0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -126,6 +126,7 @@ if (UNIX AND GLFW_BUILD_SHARED_LIBRARY) else() set(GLFW_LIB_NAME glfw3) endif() +set(GLFW_LIB_NAME_SUFFIX "") set_target_properties(glfw PROPERTIES OUTPUT_NAME ${GLFW_LIB_NAME} @@ -337,6 +338,7 @@ if (GLFW_BUILD_SHARED_LIBRARY) # Add a suffix to the import library to avoid naming conflicts set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.lib") endif() + set (GLFW_LIB_NAME_SUFFIX "dll") target_compile_definitions(glfw INTERFACE GLFW_DLL) endif() From 46c2e35c554d96fdb8a94c3f19c88e34a613532a Mon Sep 17 00:00:00 2001 From: Doug Binks Date: Wed, 15 Nov 2023 16:44:24 +0100 Subject: [PATCH 11/50] Updated changelog --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e3d18ec8..5f86a9eb 100644 --- a/README.md +++ b/README.md @@ -183,6 +183,7 @@ information on what to include when reporting a bug. - Bugfix: `glfwMakeContextCurrent` would access TLS slot before initialization - Bugfix: `glfwSetGammaRamp` could emit `GLFW_INVALID_VALUE` before initialization - Bugfix: `glfwGetJoystickUserPointer` returned `NULL` during disconnection (#2092) + - [Win32] Fix pkg-config for dynamic library on Windows (#2386, #2420) - [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access to the window menu - [Win32] Added a version info resource to the GLFW DLL From 9a80225ddfdaf9457c80c97ce4c12aed3377dd24 Mon Sep 17 00:00:00 2001 From: Doug Binks Date: Wed, 15 Nov 2023 16:48:19 +0100 Subject: [PATCH 12/50] Add credits Related to #2386 and #2420 --- CONTRIBUTORS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 020bb26e..908b8169 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -150,6 +150,7 @@ video tutorials. - Alexander Monakov - Pierre Morel - Jon Morton + - moritz-h - Pierre Moulon - Martins Mozeiko - Pascal Muetschard @@ -247,6 +248,7 @@ video tutorials. - Corentin Wallez - Torsten Walluhn - Patrick Walton + - Jim Wang - Xo Wang - Andre Weissflog - Jay Weisskopf From 3ed6e9d89aa518b44ab30e598e5b813879eda71c Mon Sep 17 00:00:00 2001 From: Doug Binks Date: Wed, 15 Nov 2023 17:48:30 +0100 Subject: [PATCH 13/50] Updated credit --- CONTRIBUTORS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 908b8169..cba9ac73 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -83,6 +83,7 @@ video tutorials. - Stephen Gutekanst - Jonathan Hale - hdf89shfdfs + - Moritz Heinemann - Sylvain Hellegouarch - Björn Hempel - Matthew Henry @@ -150,7 +151,6 @@ video tutorials. - Alexander Monakov - Pierre Morel - Jon Morton - - moritz-h - Pierre Moulon - Martins Mozeiko - Pascal Muetschard From 938a3c29b2e1b93a681cfde82876dfce97635658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 19 Jul 2023 17:40:22 +0200 Subject: [PATCH 14/50] Update Doxyfile template for Doxygen 1.9.7 --- docs/Doxyfile.in | 180 +++++++++++++++++++++++++++++------------------ 1 file changed, 113 insertions(+), 67 deletions(-) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index 6505aa33..067619c7 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -1,4 +1,4 @@ -# Doxyfile 1.9.5 +# Doxyfile 1.9.7 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. @@ -86,7 +86,7 @@ CREATE_SUBDIRS = NO # level increment doubles the number of directories, resulting in 4096 # directories at level 8 which is the default and also the maximum value. The # sub-directories are organized in 2 levels, the first level always has a fixed -# numer of 16 directories. +# number of 16 directories. # Minimum value: 0, maximum value: 8, default value: 8. # This tag requires that the tag CREATE_SUBDIRS is set to YES. @@ -364,6 +364,17 @@ MARKDOWN_SUPPORT = YES TOC_INCLUDE_HEADINGS = 5 +# The MARKDOWN_ID_STYLE tag can be used to specify the algorithm used to +# generate identifiers for the Markdown headings. Note: Every identifier is +# unique. +# Possible values are: DOXYGEN Use a fixed 'autotoc_md' string followed by a +# sequence number starting at 0. and GITHUB Use the lower case version of title +# with any whitespace replaced by '-' and punctations characters removed.. +# The default value is: DOXYGEN. +# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. + +MARKDOWN_ID_STYLE = DOXYGEN + # When enabled doxygen tries to link words that correspond to documented # classes, or namespaces to their corresponding documentation. Such a link can # be prevented in individual cases by putting a % sign in front of the word or @@ -404,7 +415,7 @@ SIP_SUPPORT = NO # should set this option to NO. # The default value is: YES. -IDL_PROPERTY_SUPPORT = NO +IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES then doxygen will reuse the documentation of the first @@ -488,6 +499,14 @@ LOOKUP_CACHE_SIZE = 0 NUM_PROC_THREADS = 1 +# If the TIMESTAMP tag is set different from NO then each generated page will +# contain the date or date and time when the page was generated. Setting this to +# NO can help when comparing the output of multiple runs. +# Possible values are: YES, NO, DATETIME and DATE. +# The default value is: NO. + +TIMESTAMP = NO + #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- @@ -569,7 +588,8 @@ HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. If set # to NO, these classes will be included in the various overviews. This option -# has no effect if EXTRACT_ALL is enabled. +# will also hide undocumented C++ concepts if enabled. This option has no effect +# if EXTRACT_ALL is enabled. # The default value is: NO. HIDE_UNDOC_CLASSES = NO @@ -860,11 +880,26 @@ WARN_IF_INCOMPLETE_DOC = YES WARN_NO_PARAMDOC = YES +# If WARN_IF_UNDOC_ENUM_VAL option is set to YES, doxygen will warn about +# undocumented enumeration values. If set to NO, doxygen will accept +# undocumented enumeration values. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: NO. + +WARN_IF_UNDOC_ENUM_VAL = NO + # If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when # a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS # then doxygen will continue running as if WARN_AS_ERROR tag is set to NO, but # at the end of the doxygen process doxygen will return with a non-zero status. -# Possible values are: NO, YES and FAIL_ON_WARNINGS. +# If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS_PRINT then doxygen behaves +# like FAIL_ON_WARNINGS but in case no WARN_LOGFILE is defined doxygen will not +# write the warning messages in between other messages but write them at the end +# of a run, in case a WARN_LOGFILE is defined the warning messages will be +# besides being in the defined file also be shown at the end of a run, unless +# the WARN_LOGFILE is defined as - i.e. standard output (stdout) in that case +# the behavior will remain as with the setting FAIL_ON_WARNINGS. +# Possible values are: NO, YES, FAIL_ON_WARNINGS and FAIL_ON_WARNINGS_PRINT. # The default value is: NO. WARN_AS_ERROR = NO @@ -987,9 +1022,6 @@ EXCLUDE_PATTERNS = # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # ANamespace::AClass, ANamespace::*Test -# -# Note that the wildcards are matched against the file with absolute path, so to -# exclude all test directories use the pattern */test/* EXCLUDE_SYMBOLS = APIENTRY GLFWAPI @@ -1186,10 +1218,11 @@ VERBATIM_HEADERS = YES ALPHABETICAL_INDEX = YES -# In case all classes in a project start with a common prefix, all classes will -# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag -# can be used to specify a prefix (or a list of prefixes) that should be ignored -# while generating the index headers. +# The IGNORE_PREFIX tag can be used to specify a prefix (or a list of prefixes) +# that should be ignored while generating the index headers. The IGNORE_PREFIX +# tag works for classes, function and member names. The entity will be placed in +# the alphabetical list under the first letter of the entity name that remains +# after removing the prefix. # This tag requires that the tag ALPHABETICAL_INDEX is set to YES. IGNORE_PREFIX = glfw GLFW_ @@ -1268,7 +1301,12 @@ HTML_STYLESHEET = # Doxygen will copy the style sheet files to the output directory. # Note: The order of the extra style sheet files is of importance (e.g. the last # style sheet in the list overrules the setting of the previous ones in the -# list). For an example see the documentation. +# list). +# Note: Since the styling of scrollbars can currently not be overruled in +# Webkit/Chromium, the styling will be left out of the default doxygen.css if +# one or more extra stylesheets have been specified. So if scrollbar +# customization is desired it has to be added explicitly. For an example see the +# documentation. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_EXTRA_STYLESHEET = "@GLFW_SOURCE_DIR@/docs/extra.css" @@ -1284,17 +1322,13 @@ HTML_EXTRA_STYLESHEET = "@GLFW_SOURCE_DIR@/docs/extra.css" HTML_EXTRA_FILES = "@GLFW_SOURCE_DIR@/docs/spaces.svg" # The HTML_COLORSTYLE tag can be used to specify if the generated HTML output -# should be rendered with a dark or light theme. Default setting AUTO_LIGHT -# enables light output unless the user preference is dark output. Other options -# are DARK to always use dark mode, LIGHT to always use light mode, AUTO_DARK to -# default to dark mode unless the user prefers light mode, and TOGGLE to let the -# user toggle between dark and light mode via a button. -# Possible values are: LIGHT Always generate light output., DARK Always generate -# dark output., AUTO_LIGHT Automatically set the mode according to the user -# preference, use light mode if no preference is set (the default)., AUTO_DARK -# Automatically set the mode according to the user preference, use dark mode if -# no preference is set. and TOGGLE Allow to user to switch between light and -# dark mode via a button.. +# should be rendered with a dark or light theme. +# Possible values are: LIGHT always generate light mode output, DARK always +# generate dark mode output, AUTO_LIGHT automatically set the mode according to +# the user preference, use light mode if no preference is set (the default), +# AUTO_DARK automatically set the mode according to the user preference, use +# dark mode if no preference is set and TOGGLE allow to user to switch between +# light and dark mode via a button. # The default value is: AUTO_LIGHT. # This tag requires that the tag GENERATE_HTML is set to YES. @@ -1330,15 +1364,6 @@ HTML_COLORSTYLE_SAT = 100 HTML_COLORSTYLE_GAMMA = 80 -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting this -# to YES can help to show when doxygen was last run and thus if the -# documentation is up to date. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_TIMESTAMP = YES - # If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML # documentation will contain a main index with vertical navigation menus that # are dynamically created via JavaScript. If disabled, the navigation index will @@ -1488,6 +1513,16 @@ BINARY_TOC = NO TOC_EXPAND = NO +# The SITEMAP_URL tag is used to specify the full URL of the place where the +# generated documentation will be placed on the server by the user during the +# deployment of the documentation. The generated sitemap is called sitemap.xml +# and placed on the directory specified by HTML_OUTPUT. In case no SITEMAP_URL +# is specified no sitemap is generated. For information about the sitemap +# protocol see https://www.sitemaps.org +# This tag requires that the tag GENERATE_HTML is set to YES. + +SITEMAP_URL = + # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that # can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help @@ -1627,7 +1662,7 @@ ENUM_VALUES_PER_LINE = 4 # Minimum value: 0, maximum value: 1500, default value: 250. # This tag requires that the tag GENERATE_HTML is set to YES. -TREEVIEW_WIDTH = 300 +TREEVIEW_WIDTH = 250 # If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to # external symbols imported via tag files in a separate window. @@ -1976,9 +2011,16 @@ PDF_HYPERLINKS = YES USE_PDFLATEX = YES -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode -# command to the generated LaTeX files. This will instruct LaTeX to keep running -# if errors occur, instead of asking the user for help. +# The LATEX_BATCHMODE tag ignals the behavior of LaTeX in case of an error. +# Possible values are: NO same as ERROR_STOP, YES same as BATCH, BATCH In batch +# mode nothing is printed on the terminal, errors are scrolled as if is +# hit at every error; missing files that TeX tries to input or request from +# keyboard input (\read on a not open input stream) cause the job to abort, +# NON_STOP In nonstop mode the diagnostic message will appear on the terminal, +# but there is no possibility of user interaction just like in batch mode, +# SCROLL In scroll mode, TeX will stop only for missing files to input or if +# keyboard input is necessary and ERROR_STOP In errorstop mode, TeX will stop at +# each error, asking for user intervention. # The default value is: NO. # This tag requires that the tag GENERATE_LATEX is set to YES. @@ -1999,14 +2041,6 @@ LATEX_HIDE_INDICES = NO LATEX_BIB_STYLE = plain -# If the LATEX_TIMESTAMP tag is set to YES then the footer of each generated -# page will contain the date and time when the page was generated. Setting this -# to NO can help when comparing the output of multiple runs. -# The default value is: NO. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -LATEX_TIMESTAMP = NO - # The LATEX_EMOJI_DIRECTORY tag is used to specify the (relative or absolute) # path from which the emoji images will be read. If a relative path is entered, # it will be relative to the LATEX_OUTPUT directory. If left blank the @@ -2172,7 +2206,7 @@ DOCBOOK_OUTPUT = docbook #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an -# AutoGen Definitions (see http://autogen.sourceforge.net/) file that captures +# AutoGen Definitions (see https://autogen.sourceforge.net/) file that captures # the structure of the code including all documentation. Note that this feature # is still experimental and incomplete at the moment. # The default value is: NO. @@ -2353,16 +2387,9 @@ EXTERNAL_GROUPS = YES EXTERNAL_PAGES = YES #--------------------------------------------------------------------------- -# Configuration options related to the dot tool +# Configuration options related to diagram generator tools #--------------------------------------------------------------------------- -# You can include diagrams made with dia in doxygen documentation. Doxygen will -# then run dia to produce the diagram and insert it in the documentation. The -# DIA_PATH tag allows you to specify the directory where the dia binary resides. -# If left empty dia is assumed to be found in the default search path. - -DIA_PATH = - # If set to YES the inheritance and collaboration graphs will hide inheritance # and usage relations if the target is undocumented or is not a class. # The default value is: YES. @@ -2371,7 +2398,7 @@ HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz (see: -# http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent +# https://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent # Bell Labs. The other options in this section have no effect if this option is # set to NO # The default value is: NO. @@ -2424,13 +2451,15 @@ DOT_NODE_ATTR = "shape=box,height=0.2,width=0.4" DOT_FONTPATH = -# If the CLASS_GRAPH tag is set to YES (or GRAPH) then doxygen will generate a -# graph for each documented class showing the direct and indirect inheritance -# relations. In case HAVE_DOT is set as well dot will be used to draw the graph, -# otherwise the built-in generator will be used. If the CLASS_GRAPH tag is set -# to TEXT the direct and indirect inheritance relations will be shown as texts / -# links. -# Possible values are: NO, YES, TEXT and GRAPH. +# If the CLASS_GRAPH tag is set to YES or GRAPH or BUILTIN then doxygen will +# generate a graph for each documented class showing the direct and indirect +# inheritance relations. In case the CLASS_GRAPH tag is set to YES or GRAPH and +# HAVE_DOT is enabled as well, then dot will be used to draw the graph. In case +# the CLASS_GRAPH tag is set to YES and HAVE_DOT is disabled or if the +# CLASS_GRAPH tag is set to BUILTIN, then the built-in generator will be used. +# If the CLASS_GRAPH tag is set to TEXT the direct and indirect inheritance +# relations will be shown as texts / links. +# Possible values are: NO, YES, TEXT, GRAPH and BUILTIN. # The default value is: YES. CLASS_GRAPH = YES @@ -2571,7 +2600,7 @@ DIR_GRAPH_MAX_DEPTH = 1 # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. For an explanation of the image formats see the section # output formats in the documentation of the dot tool (Graphviz (see: -# http://www.graphviz.org/)). +# https://www.graphviz.org/)). # Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order # to make the SVG files visible in IE 9+ (other browsers do not have this # requirement). @@ -2608,11 +2637,12 @@ DOT_PATH = DOTFILE_DIRS = -# The MSCFILE_DIRS tag can be used to specify one or more directories that -# contain msc files that are included in the documentation (see the \mscfile -# command). +# You can include diagrams made with dia in doxygen documentation. Doxygen will +# then run dia to produce the diagram and insert it in the documentation. The +# DIA_PATH tag allows you to specify the directory where the dia binary resides. +# If left empty dia is assumed to be found in the default search path. -MSCFILE_DIRS = +DIA_PATH = # The DIAFILE_DIRS tag can be used to specify one or more directories that # contain dia files that are included in the documentation (see the \diafile @@ -2689,3 +2719,19 @@ GENERATE_LEGEND = YES # The default value is: YES. DOT_CLEANUP = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. If the MSCGEN_TOOL tag is left empty (the default), then doxygen will +# use a built-in version of mscgen tool to produce the charts. Alternatively, +# the MSCGEN_TOOL tag can also specify the name an external tool. For instance, +# specifying prog as the value, doxygen will call the tool as prog -T +# -o . The external tool should support +# output file formats "png", "eps", "svg", and "ismap". + +MSCGEN_TOOL = + +# The MSCFILE_DIRS tag can be used to specify one or more directories that +# contain msc files that are included in the documentation (see the \mscfile +# command). + +MSCFILE_DIRS = From 01d7c331fddd5d027f7d85c651c6473b18d0ea37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 3 Aug 2023 18:10:24 +0200 Subject: [PATCH 15/50] Wayland: Fix zero being used in place of NULL --- src/wl_window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wl_window.c b/src/wl_window.c index 7b9e3d0d..fc4a671a 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -2478,7 +2478,7 @@ void _glfwSetWindowMousePassthroughWayland(_GLFWwindow* window, GLFWbool enabled wl_region_destroy(region); } else - wl_surface_set_input_region(window->wl.surface, 0); + wl_surface_set_input_region(window->wl.surface, NULL); } float _glfwGetWindowOpacityWayland(_GLFWwindow* window) From 509f4131bec5303b04e30617a123e7ce18a95798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 15 Nov 2023 17:55:07 +0100 Subject: [PATCH 16/50] Win32: Fix glfwWaitEventsTimeout ignoring messages The bitmask passed to MsgWaitForMultipleObjects was missing QS_SENDMESSAGE, causing glfwWaitEventsTimeout not to return when the thread received messages sent from other threads. Fixes #2408 --- CONTRIBUTORS.md | 1 + README.md | 1 + src/win32_window.c | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index cba9ac73..99aab7b1 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -142,6 +142,7 @@ video tutorials. - Marcel Metz - Liam Middlebrook - Ave Milia + - Icyllis Milica - Jonathan Miller - Kenneth Miller - Bruce Mitchener diff --git a/README.md b/README.md index 5f86a9eb..2ced3ffb 100644 --- a/README.md +++ b/README.md @@ -230,6 +230,7 @@ information on what to include when reporting a bug. - [Win32] Bugfix: Instance-local operations used executable instance (#469,#1296,#1395) - [Win32] Bugfix: The OSMesa library was not unloaded on termination - [Win32] Bugfix: Right shift emitted `GLFW_KEY_UNKNOWN` when using a CJK IME (#2050) + - [Win32] Bugfix: `glfwWaitEventsTimeout` did not return for some sent messages (#2408) - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - [Cocoa] Moved main menu creation to GLFW initialization time (#1649) diff --git a/src/win32_window.c b/src/win32_window.c index 676640bf..a4a18171 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -2121,7 +2121,7 @@ void _glfwWaitEventsWin32(void) void _glfwWaitEventsTimeoutWin32(double timeout) { - MsgWaitForMultipleObjects(0, NULL, FALSE, (DWORD) (timeout * 1e3), QS_ALLEVENTS); + MsgWaitForMultipleObjects(0, NULL, FALSE, (DWORD) (timeout * 1e3), QS_ALLINPUT); _glfwPollEventsWin32(); } From 0bd3e879e1fd8c5ed4562929fb0365a5a7089833 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 16 Nov 2023 17:28:17 +0100 Subject: [PATCH 17/50] Fix unneccessary use of "must" Passing a context-less window to a function that requires a context only emits a harmless GLFW_NO_WINDOW_CONTEXT error. --- docs/context.dox | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/context.dox b/docs/context.dox index c64a0709..21672ad7 100644 --- a/docs/context.dox +++ b/docs/context.dox @@ -88,9 +88,10 @@ window, even if none of them are visible. @subsection context_less Windows without contexts You can disable context creation by setting the -[GLFW_CLIENT_API](@ref GLFW_CLIENT_API_hint) hint to `GLFW_NO_API`. Windows -without contexts must not be passed to @ref glfwMakeContextCurrent or @ref -glfwSwapBuffers. +[GLFW_CLIENT_API](@ref GLFW_CLIENT_API_hint) hint to `GLFW_NO_API`. + +Windows without contexts should not be passed to @ref glfwMakeContextCurrent or +@ref glfwSwapBuffers. Doing this generates a @ref GLFW_NO_WINDOW_CONTEXT error. @section context_current Current context From c992226a9c63f80e157d6bd9bf2372acd2a1c795 Mon Sep 17 00:00:00 2001 From: Michael Skec Date: Thu, 9 Nov 2023 15:04:19 +1100 Subject: [PATCH 18/50] Linux: Fix memory leak when inotify init failed This introduces regex_compiled boolean to track whether the regex is compiled successfully. Closes #2229 --- src/linux_joystick.c | 8 ++++++-- src/linux_joystick.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/linux_joystick.c b/src/linux_joystick.c index 26db853e..5b2c3b34 100644 --- a/src/linux_joystick.c +++ b/src/linux_joystick.c @@ -326,7 +326,9 @@ GLFWbool _glfwInitJoysticksLinux(void) // Continue without device connection notifications if inotify fails - if (regcomp(&_glfw.linjs.regex, "^event[0-9]\\+$", 0) != 0) + _glfw.linjs.regex_compiled = regcomp(&_glfw.linjs.regex, + "^event[0-9]\\+$", 0) == 0; + if (!_glfw.linjs.regex_compiled) { _glfwInputError(GLFW_PLATFORM_ERROR, "Linux: Failed to compile regex"); return GLFW_FALSE; @@ -378,8 +380,10 @@ void _glfwTerminateJoysticksLinux(void) inotify_rm_watch(_glfw.linjs.inotify, _glfw.linjs.watch); close(_glfw.linjs.inotify); - regfree(&_glfw.linjs.regex); } + + if (_glfw.linjs.regex_compiled) + regfree(&_glfw.linjs.regex); } GLFWbool _glfwPollJoystickLinux(_GLFWjoystick* js, int mode) diff --git a/src/linux_joystick.h b/src/linux_joystick.h index df605e72..3e1fe8c8 100644 --- a/src/linux_joystick.h +++ b/src/linux_joystick.h @@ -50,6 +50,7 @@ typedef struct _GLFWlibraryLinux int inotify; int watch; regex_t regex; + GLFWbool regex_compiled; GLFWbool dropped; } _GLFWlibraryLinux; From 2a4dd9c28f663c1ef410d6430aaa3fe90085bf6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 16 Nov 2023 23:08:30 +0100 Subject: [PATCH 19/50] Cleanup --- src/linux_joystick.c | 7 +++---- src/linux_joystick.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/linux_joystick.c b/src/linux_joystick.c index 5b2c3b34..78d867eb 100644 --- a/src/linux_joystick.c +++ b/src/linux_joystick.c @@ -326,9 +326,8 @@ GLFWbool _glfwInitJoysticksLinux(void) // Continue without device connection notifications if inotify fails - _glfw.linjs.regex_compiled = regcomp(&_glfw.linjs.regex, - "^event[0-9]\\+$", 0) == 0; - if (!_glfw.linjs.regex_compiled) + _glfw.linjs.regexCompiled = (regcomp(&_glfw.linjs.regex, "^event[0-9]\\+$", 0) == 0); + if (!_glfw.linjs.regexCompiled) { _glfwInputError(GLFW_PLATFORM_ERROR, "Linux: Failed to compile regex"); return GLFW_FALSE; @@ -382,7 +381,7 @@ void _glfwTerminateJoysticksLinux(void) close(_glfw.linjs.inotify); } - if (_glfw.linjs.regex_compiled) + if (_glfw.linjs.regexCompiled) regfree(&_glfw.linjs.regex); } diff --git a/src/linux_joystick.h b/src/linux_joystick.h index 3e1fe8c8..64462b04 100644 --- a/src/linux_joystick.h +++ b/src/linux_joystick.h @@ -50,7 +50,7 @@ typedef struct _GLFWlibraryLinux int inotify; int watch; regex_t regex; - GLFWbool regex_compiled; + GLFWbool regexCompiled; GLFWbool dropped; } _GLFWlibraryLinux; From a87acd8c1fac78011013bebb537926e18fe49f46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 16 Nov 2023 20:47:27 +0100 Subject: [PATCH 20/50] Update changelog and add credit Related to #2229 --- CONTRIBUTORS.md | 1 + README.md | 1 + 2 files changed, 2 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 99aab7b1..3ad802f2 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -215,6 +215,7 @@ video tutorials. - Dmitri Shuralyov - Joao da Silva - Daniel Sieger + - Michael Skec - Daniel Skorupski - Slemmie - Anthony Smith diff --git a/README.md b/README.md index 2ced3ffb..eb19011b 100644 --- a/README.md +++ b/README.md @@ -390,6 +390,7 @@ information on what to include when reporting a bug. - [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [Linux] Bugfix: Joysticks without buttons were ignored (#2042,#2043) + - [Linux] Bugfix: A small amount of memory could leak if initialization failed (#2229) - [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072) - [NSGL] Removed enforcement of forward-compatible flag for core contexts - [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer From d9709904fec956524d4e9032a7fa8d0550d5d49b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 21 Nov 2023 17:36:34 +0100 Subject: [PATCH 21/50] Linux: Fix POSIX version not set for Null build When compiling GLFW on Linux with only the Null platform enabled, the CMake files did not set the required POSIX version macro. Fixes #2402 --- CONTRIBUTORS.md | 1 + src/CMakeLists.txt | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 3ad802f2..b39ee2ab 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -215,6 +215,7 @@ video tutorials. - Dmitri Shuralyov - Joao da Silva - Daniel Sieger + - Daljit Singh - Michael Skec - Daniel Skorupski - Slemmie diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5acac0d0..7b84ecf2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -316,10 +316,8 @@ if (MSVC90) endif() # Workaround for -std=c99 on Linux disabling _DEFAULT_SOURCE (POSIX 2008 and more) -if (GLFW_BUILD_X11 OR GLFW_BUILD_WAYLAND) - if (CMAKE_SYSTEM_NAME STREQUAL "Linux") - target_compile_definitions(glfw PRIVATE _DEFAULT_SOURCE) - endif() +if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + target_compile_definitions(glfw PRIVATE _DEFAULT_SOURCE) endif() if (GLFW_BUILD_SHARED_LIBRARY) From 97820bc329c603074ecdefdfdef339be776bd9f8 Mon Sep 17 00:00:00 2001 From: Scr3amer Date: Tue, 21 Nov 2023 14:28:39 -0500 Subject: [PATCH 22/50] Null: Remove duplicated function declaration The declaration of _glfwRequestWindowAttentionNull was duplicated. Closes #2403 --- src/null_platform.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/null_platform.h b/src/null_platform.h index 6d900111..fb9374b4 100644 --- a/src/null_platform.h +++ b/src/null_platform.h @@ -239,7 +239,6 @@ void _glfwSetRawMouseMotionNull(_GLFWwindow *window, GLFWbool enabled); GLFWbool _glfwRawMouseMotionSupportedNull(void); void _glfwShowWindowNull(_GLFWwindow* window); void _glfwRequestWindowAttentionNull(_GLFWwindow* window); -void _glfwRequestWindowAttentionNull(_GLFWwindow* window); void _glfwHideWindowNull(_GLFWwindow* window); void _glfwFocusWindowNull(_GLFWwindow* window); GLFWbool _glfwWindowFocusedNull(_GLFWwindow* window); From afd22ebcf34f2fa84d5b9f28103f014505ae8d47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 21 Nov 2023 21:26:45 +0100 Subject: [PATCH 23/50] Add credit Related to #2403 --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index b39ee2ab..18db7c02 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -206,6 +206,7 @@ video tutorials. - Yoshinori Sano - Brandon Schaefer - Sebastian Schuberth + - Scr3amer - Christian Sdunek - Matt Sealey - Steve Sexton From dbe810e4036fa6640fbe5d509e1a551c8a77f371 Mon Sep 17 00:00:00 2001 From: Grzesiek11 Date: Fri, 24 Nov 2023 18:04:13 +0100 Subject: [PATCH 24/50] Documentation: only named keys generate synthetic key releases The current wording states that all keys have synthetic key release events generated after focus is lost, but keys that aren't named don't have any state held, so no such events are generated for them. The new wording clarifies that only named keys have the events generated for them. --- CONTRIBUTORS.md | 1 + include/GLFW/glfw3.h | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 18db7c02..9e0fb922 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -269,6 +269,7 @@ video tutorials. - Jonas Ådahl - Lasse Öörni - Leonard König + - Grzesiek11 - All the unmentioned and anonymous contributors in the GLFW community, for bug reports, patches, feedback, testing and encouragement diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 58b395cd..f8b0ae00 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -5058,9 +5058,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. 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 named 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 From 659d161446ad6e3f3e67cdc1baabcf61abd70aef Mon Sep 17 00:00:00 2001 From: Doug Binks Date: Fri, 24 Nov 2023 17:06:18 +0000 Subject: [PATCH 25/50] Reorder credit --- CONTRIBUTORS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 9e0fb922..1b9a277a 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -78,6 +78,7 @@ video tutorials. - Kovid Goyal - Kevin Grandemange - Eloi Marín Gratacós + - Grzesiek11 - Stefan Gustavson - Andrew Gutekanst - Stephen Gutekanst @@ -269,7 +270,6 @@ video tutorials. - Jonas Ådahl - Lasse Öörni - Leonard König - - Grzesiek11 - All the unmentioned and anonymous contributors in the GLFW community, for bug reports, patches, feedback, testing and encouragement From 23ea072c4157f2a7760d26f4d6e375833646bd88 Mon Sep 17 00:00:00 2001 From: Doug Binks Date: Mon, 27 Nov 2023 16:56:58 +0000 Subject: [PATCH 26/50] Reorder changelog entry --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eb19011b..d0a40c34 100644 --- a/README.md +++ b/README.md @@ -183,7 +183,6 @@ information on what to include when reporting a bug. - Bugfix: `glfwMakeContextCurrent` would access TLS slot before initialization - Bugfix: `glfwSetGammaRamp` could emit `GLFW_INVALID_VALUE` before initialization - Bugfix: `glfwGetJoystickUserPointer` returned `NULL` during disconnection (#2092) - - [Win32] Fix pkg-config for dynamic library on Windows (#2386, #2420) - [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access to the window menu - [Win32] Added a version info resource to the GLFW DLL @@ -231,6 +230,7 @@ information on what to include when reporting a bug. - [Win32] Bugfix: The OSMesa library was not unloaded on termination - [Win32] Bugfix: Right shift emitted `GLFW_KEY_UNKNOWN` when using a CJK IME (#2050) - [Win32] Bugfix: `glfwWaitEventsTimeout` did not return for some sent messages (#2408) + - [Win32] Bugfix: Fix pkg-config for dynamic library on Windows (#2386, #2420) - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - [Cocoa] Moved main menu creation to GLFW initialization time (#1649) From 9fdc425931888ea70bc095e53cc006fca8ccb703 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 30 Nov 2023 02:43:48 +0100 Subject: [PATCH 27/50] Wayland: Use Wayland to wait for libdecor to init Much of libdecor is initialized only after certain events have been received from the compositor and some parts of libdecor 0.1 are unsafe to use until this delayed initialization has completed. Since libdecor does not provide an API to query if or be notified when this has happened, GLFW processed events until its newly created libdecor frame had created its XDG shell objects. This commit switches to using a generic Wayland sync point created just after libdecor (and presumably its plugin) has set up its delayed initialization, instead of relying on the more specific implementation detail mentioned above. It also makes this wait mandatory before the first libdecor frame is created instead of a pre-condition for certain libdecor frame calls, hopefully removing even more dependence on implementation details. --- src/wl_init.c | 32 +++++++++++++++++++++++++++++--- src/wl_platform.h | 2 ++ src/wl_window.c | 10 ++++------ 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index 66d77dca..0ec65900 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -40,6 +40,7 @@ #include #include #include +#include #include "wayland-client-protocol.h" #include "wayland-xdg-shell-client-protocol.h" @@ -216,6 +217,22 @@ static const struct libdecor_interface libdecorInterface = libdecorHandleError }; +static void libdecorReadyCallback(void* userData, + struct wl_callback* callback, + uint32_t time) +{ + _glfw.wl.libdecor.ready = GLFW_TRUE; + + assert(_glfw.wl.libdecor.callback == callback); + wl_callback_destroy(_glfw.wl.libdecor.callback); + _glfw.wl.libdecor.callback = NULL; +} + +static const struct wl_callback_listener libdecorReadyListener = +{ + libdecorReadyCallback +}; + // Create key code translation tables // static void createKeyTables(void) @@ -775,10 +792,17 @@ int _glfwInitWayland(void) if (_glfw.wl.libdecor.handle) { _glfw.wl.libdecor.context = libdecor_new(_glfw.wl.display, &libdecorInterface); - - // Allow libdecor to receive its globals before proceeding if (_glfw.wl.libdecor.context) - libdecor_dispatch(_glfw.wl.libdecor.context, 1); + { + // Perform an initial dispatch and flush to get the init started + libdecor_dispatch(_glfw.wl.libdecor.context, 0); + + // Create sync point to "know" when libdecor is ready for use + _glfw.wl.libdecor.callback = wl_display_sync(_glfw.wl.display); + wl_callback_add_listener(_glfw.wl.libdecor.callback, + &libdecorReadyListener, + NULL); + } } #ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION @@ -822,6 +846,8 @@ void _glfwTerminateWayland(void) _glfwTerminateEGL(); _glfwTerminateOSMesa(); + if (_glfw.wl.libdecor.callback) + wl_callback_destroy(_glfw.wl.libdecor.callback); if (_glfw.wl.libdecor.context) libdecor_unref(_glfw.wl.libdecor.context); diff --git a/src/wl_platform.h b/src/wl_platform.h index e9dd0b4a..d00e28fe 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -550,6 +550,8 @@ typedef struct _GLFWlibraryWayland struct { void* handle; struct libdecor* context; + struct wl_callback* callback; + GLFWbool ready; PFN_libdecor_new libdecor_new_; PFN_libdecor_unref libdecor_unref_; PFN_libdecor_get_fd libdecor_get_fd_; diff --git a/src/wl_window.c b/src/wl_window.c index fc4a671a..c7dd62b0 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -735,6 +735,10 @@ static const struct libdecor_frame_interface libdecorFrameInterface = static GLFWbool createLibdecorFrame(_GLFWwindow* window) { + // Allow libdecor to finish initialization of itself and its plugin + while (!_glfw.wl.libdecor.ready) + _glfwWaitEventsWayland(); + window->wl.libdecor.frame = libdecor_decorate(_glfw.wl.libdecor.context, window->wl.surface, &libdecorFrameInterface, @@ -776,12 +780,6 @@ static GLFWbool createLibdecorFrame(_GLFWwindow* window) if (window->monitor) { - // HACK: Allow libdecor to finish initialization of itself and its - // plugin so it will create the xdg_toplevel for the frame - // This needs to exist when setting the frame to fullscreen - while (!libdecor_frame_get_xdg_toplevel(window->wl.libdecor.frame)) - _glfwWaitEventsWayland(); - libdecor_frame_set_fullscreen(window->wl.libdecor.frame, window->monitor->wl.output); setIdleInhibitor(window, GLFW_TRUE); From 23e40548b15db9a53a755d152d1fd2072c39610e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 29 Nov 2023 16:25:29 +0100 Subject: [PATCH 28/50] Wayland: Fix protocol error on undecorated window When setting the visibility of a libdecor frame on a compositor that supports XDG decorations, libdecor 0.1 will update the geometry of the XDG surface. GLFW attempted to set the visibility before having told libdecor what size the content area is. This caused a Wayland protocol error when libdecor attempted to set the window size to 0x0. This commit adds setting the content area size for the libdecor frame directly after creation, allowing libdecor to know what it's doing. --- README.md | 1 + src/wl_window.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index d0a40c34..52081c1c 100644 --- a/README.md +++ b/README.md @@ -387,6 +387,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Connecting a mouse after `glfwInit` would segfault (#1450) - [Wayland] Bugfix: Joysticks connected after `glfwInit` were not detected (#2198) - [Wayland] Bugfix: Fallback decorations emitted `GLFW_CURSOR_UNAVAILABLE` errors + - [Wayland] Bugfix: Showing an undecorated window would cause a protocol error - [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [Linux] Bugfix: Joysticks without buttons were ignored (#2042,#2043) diff --git a/src/wl_window.c b/src/wl_window.c index c7dd62b0..8292dcd6 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -750,6 +750,11 @@ static GLFWbool createLibdecorFrame(_GLFWwindow* window) return GLFW_FALSE; } + struct libdecor_state* frameState = + libdecor_state_new(window->wl.width, window->wl.height); + libdecor_frame_commit(window->wl.libdecor.frame, frameState, NULL); + libdecor_state_free(frameState); + if (strlen(window->wl.appId)) libdecor_frame_set_app_id(window->wl.libdecor.frame, window->wl.appId); From d097e35743ee49d38811a89ea29c7f2525dc8d6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 30 Nov 2023 16:47:35 +0100 Subject: [PATCH 29/50] Wayland: Fix heuristics for what counts as events The Wayland implementation of glfwWaitEvents* keeps waiting until it sees evidence that a significant event has been processed. However, this included updating an animated cursor (not a significant event) but did not include previously buffered Wayland events or libdecor events (definitely significant events). This commit corrects these cases. --- src/wl_window.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index 8292dcd6..7c509896 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1118,7 +1118,10 @@ static void handleEvents(double* timeout) while (!event) { while (wl_display_prepare_read(_glfw.wl.display) != 0) - wl_display_dispatch_pending(_glfw.wl.display); + { + if (wl_display_dispatch_pending(_glfw.wl.display) > 0) + return; + } // If an error other than EAGAIN happens, we have likely been disconnected // from the Wayland session; try to handle that the best we can. @@ -1176,14 +1179,14 @@ static void handleEvents(double* timeout) uint64_t repeats; if (read(_glfw.wl.cursorTimerfd, &repeats, sizeof(repeats)) == 8) - { incrementCursorImage(_glfw.wl.pointerFocus); - event = GLFW_TRUE; - } } if (fds[3].revents & POLLIN) - libdecor_dispatch(_glfw.wl.libdecor.context, 0); + { + if (libdecor_dispatch(_glfw.wl.libdecor.context, 0) > 0) + event = GLFW_TRUE; + } } } From fb94e4268b222448a55b151f3c115f57f1e6540f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 1 Dec 2023 12:38:57 +0100 Subject: [PATCH 30/50] Remove changelog entry This bug was introduced since the last release and should not be listed. --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 52081c1c..d0a40c34 100644 --- a/README.md +++ b/README.md @@ -387,7 +387,6 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Connecting a mouse after `glfwInit` would segfault (#1450) - [Wayland] Bugfix: Joysticks connected after `glfwInit` were not detected (#2198) - [Wayland] Bugfix: Fallback decorations emitted `GLFW_CURSOR_UNAVAILABLE` errors - - [Wayland] Bugfix: Showing an undecorated window would cause a protocol error - [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [Linux] Bugfix: Joysticks without buttons were ignored (#2042,#2043) From 8c5471d6cdc6d87935e494b8c379f659e998bcf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 1 Dec 2023 13:22:11 +0100 Subject: [PATCH 31/50] Fix return value on error for glfwGetKeyScancode The documentation says it should be -1, not zero. --- README.md | 1 + src/input.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d0a40c34..797ffd17 100644 --- a/README.md +++ b/README.md @@ -183,6 +183,7 @@ information on what to include when reporting a bug. - Bugfix: `glfwMakeContextCurrent` would access TLS slot before initialization - Bugfix: `glfwSetGammaRamp` could emit `GLFW_INVALID_VALUE` before initialization - Bugfix: `glfwGetJoystickUserPointer` returned `NULL` during disconnection (#2092) + - Bugfix: `glfwGetKeyScancode` returned `0` on error when initialized instead of `-1` - [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access to the window menu - [Win32] Added a version info resource to the GLFW DLL diff --git a/src/input.c b/src/input.c index 36128e10..8c1bb7ef 100644 --- a/src/input.c +++ b/src/input.c @@ -721,7 +721,7 @@ GLFWAPI int glfwGetKeyScancode(int key) if (key < GLFW_KEY_SPACE || key > GLFW_KEY_LAST) { _glfwInputError(GLFW_INVALID_ENUM, "Invalid key %i", key); - return GLFW_RELEASE; + return -1; } return _glfw.platform.getKeyScancode(key); From fa0ea5c41f53119c68748a0e8570ef120b7fa703 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 3 Dec 2023 16:06:31 +0100 Subject: [PATCH 32/50] Fix potential violation of invariant The shared function for reading back context attributes, _glfwRefreshContextAttribs, did not check whether the newly created context had been successfully made current. This violated the invariant that the context TLS slot always points to a valid window and that its context is current whenever _glfw.platform.getProcAddress is called. Related to #2327 --- src/context.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/context.c b/src/context.c index 33b399c9..f8610e1e 100644 --- a/src/context.c +++ b/src/context.c @@ -363,6 +363,8 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window, previous = _glfwPlatformGetTls(&_glfw.contextSlot); glfwMakeContextCurrent((GLFWwindow*) window); + if (_glfwPlatformGetTls(&_glfw.contextSlot) != window) + return GLFW_FALSE; window->context.GetIntegerv = (PFNGLGETINTEGERVPROC) window->context.getProcAddress("glGetIntegerv"); From 93d70cb6a8c9571b5b493936596633a1a8538cea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 3 Dec 2023 17:07:25 +0100 Subject: [PATCH 33/50] Add assertions for context function invariants Related to #2327 --- src/egl_context.c | 1 + src/glx_context.c | 1 + src/nsgl_context.m | 9 ++++----- src/wgl_context.c | 1 + 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/egl_context.c b/src/egl_context.c index 64dcdd6f..4f76d351 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -311,6 +311,7 @@ static int extensionSupportedEGL(const char* extension) static GLFWglproc getProcAddressEGL(const char* procname) { _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot); + assert(window != NULL); if (window->context.egl.client) { diff --git a/src/glx_context.c b/src/glx_context.c index 4406dfd3..f3f4b3ec 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -192,6 +192,7 @@ static void swapBuffersGLX(_GLFWwindow* window) static void swapIntervalGLX(int interval) { _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot); + assert(window != NULL); if (_glfw.glx.EXT_swap_control) { diff --git a/src/nsgl_context.m b/src/nsgl_context.m index 878f32ed..de89e421 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -83,11 +83,10 @@ static void swapIntervalNSGL(int interval) @autoreleasepool { _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot); - if (window) - { - [window->context.nsgl.object setValues:&interval - forParameter:NSOpenGLContextParameterSwapInterval]; - } + assert(window != NULL); + + [window->context.nsgl.object setValues:&interval + forParameter:NSOpenGLContextParameterSwapInterval]; } // autoreleasepool } diff --git a/src/wgl_context.c b/src/wgl_context.c index cfe24b27..08c499ff 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -332,6 +332,7 @@ static void swapBuffersWGL(_GLFWwindow* window) static void swapIntervalWGL(int interval) { _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot); + assert(window != NULL); window->context.wgl.interval = interval; From 1b2605dbcd674608ba3ef57ff40880c2bf899029 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 3 Dec 2023 17:23:37 +0100 Subject: [PATCH 34/50] Fix missing new constant in release notes --- docs/news.dox | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/news.dox b/docs/news.dox index e16267b2..28c500d9 100644 --- a/docs/news.dox +++ b/docs/news.dox @@ -277,6 +277,7 @@ then GLFW will fail to initialize. - @ref GLFW_POSITION_X - @ref GLFW_POSITION_Y - @ref GLFW_ANY_POSITION + - @ref GLFW_WAYLAND_APP_ID - @ref GLFW_WAYLAND_LIBDECOR - @ref GLFW_WAYLAND_PREFER_LIBDECOR - @ref GLFW_WAYLAND_DISABLE_LIBDECOR From 3f31519de81b943d17231b3d59108923d0d2e302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 3 Dec 2023 17:40:42 +0100 Subject: [PATCH 35/50] Clarify documentation for glfwMakeContextCurrent --- include/GLFW/glfw3.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index f8b0ae00..0b05aa7f 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -5959,12 +5959,15 @@ GLFWAPI uint64_t glfwGetTimerFrequency(void); * thread. * * This function makes the OpenGL or OpenGL ES context of the specified window - * 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. + * 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`. * - * When moving a context between threads, you must make it non-current on the - * old thread before making it current on the new one. + * 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. * * By default, making a context non-current implicitly forces a pipeline flush. * On machines that support `GL_KHR_context_flush_control`, you can control @@ -5979,6 +5982,10 @@ 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. * From b1517e5b3ee6f060f2e7ebd47c9de0c10e6ad411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 4 Dec 2023 18:48:24 +0100 Subject: [PATCH 36/50] Fix glfwGetKeyName not checking key token is valid --- src/input.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/input.c b/src/input.c index 8c1bb7ef..8ab141fb 100644 --- a/src/input.c +++ b/src/input.c @@ -701,6 +701,12 @@ GLFWAPI const char* glfwGetKeyName(int key, int scancode) if (key != GLFW_KEY_UNKNOWN) { + if (key < GLFW_KEY_SPACE || key > GLFW_KEY_LAST) + { + _glfwInputError(GLFW_INVALID_ENUM, "Invalid key %i", key); + return NULL; + } + if (key != GLFW_KEY_KP_EQUAL && (key < GLFW_KEY_KP_0 || key > GLFW_KEY_KP_ADD) && (key < GLFW_KEY_APOSTROPHE || key > GLFW_KEY_WORLD_2)) From 557a633b2d926431090367e9536cd5ba661a276d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 5 Dec 2023 15:53:42 +0100 Subject: [PATCH 37/50] Fix list of possible errors for glfwGetKeyName --- include/GLFW/glfw3.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 0b05aa7f..8116784d 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -4718,8 +4718,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 and @ref - * GLFW_PLATFORM_ERROR. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_INVALID_VALUE, @ref GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR. * * @remark The contents of the returned string may change when a keyboard * layout change event is received. From 9959dc69cadd1f7790060846ffbc44e7da56fc56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 4 Dec 2023 20:06:10 +0100 Subject: [PATCH 38/50] Improve documentation relating to key tokens Shifted the documentation away from the term 'named keys' as something different than keys that glfwGetKeyName will return a name for. The already existing term 'key token' should now be used to refer to the GLFW_KEY_* constants. The associated term 'named mouse button' was also replaced with 'supported mouse button'. The parts explaining which key tokens will return a valid scancode from glfwGetKeyScancode have hopefully been clarified. This issue was reported in #2055. The GLFW_KEY_UNKNOWN constant has been moved out of the list of key tokens to simplify and hopefully clarify the related documentation. Various other keyboard key related edits were made, hopefully resulting in improvements. Related to #2055 --- docs/input.dox | 30 ++++++++++++++++++------------ include/GLFW/glfw3.h | 35 ++++++++++++++++++++--------------- 2 files changed, 38 insertions(+), 27 deletions(-) diff --git a/docs/input.dox b/docs/input.dox index d3904f46..f57520bb 100644 --- a/docs/input.dox +++ b/docs/input.dox @@ -95,7 +95,7 @@ new size before everything returns back out of the @ref glfwSetWindowSize call. GLFW divides keyboard input into two categories; key events and character events. Key events relate to actual physical keyboard keys, whereas character -events relate to the Unicode code points generated by pressing some of them. +events relate to the text that is generated by pressing some of them. Keys and characters do not map 1:1. A single key press may produce several characters, and a single character may require several keys to produce. This @@ -127,6 +127,10 @@ The action is one of `GLFW_PRESS`, `GLFW_REPEAT` or `GLFW_RELEASE`. Events with `GLFW_PRESS` and `GLFW_RELEASE` actions are emitted for every key press. Most keys will also emit events with `GLFW_REPEAT` actions while a key is held down. +Note that many keyboards have a limit on how many keys being simultaneous held +down that they can detect. This limit is called +[key rollover](https://en.wikipedia.org/wiki/Key_rollover). + Key events with `GLFW_REPEAT` actions are intended for text input. They are emitted at the rate set in the user's keyboard settings. At most one key is repeated even if several keys are held down. `GLFW_REPEAT` actions should not @@ -142,16 +146,16 @@ keys. The scancode is unique for every key, regardless of whether it has a key token. Scancodes are platform-specific but consistent over time, so keys will have different scancodes depending on the platform but they are safe to save to disk. -You can query the scancode for any [named key](@ref keys) on the current -platform with @ref glfwGetKeyScancode. +You can query the scancode for any [key token](@ref keys) supported on the +current platform with @ref glfwGetKeyScancode. @code const int scancode = glfwGetKeyScancode(GLFW_KEY_X); set_key_mapping(scancode, swap_weapons); @endcode -The last reported state for every [named key](@ref keys) is also saved in -per-window state arrays that can be polled with @ref glfwGetKey. +The last reported state for every physical key with a [key token](@ref keys) is +also saved in per-window state arrays that can be polled with @ref glfwGetKey. @code int state = glfwGetKey(window, GLFW_KEY_E); @@ -164,7 +168,8 @@ if (state == GLFW_PRESS) The returned state is one of `GLFW_PRESS` or `GLFW_RELEASE`. This function only returns cached key event state. It does not poll the -system for the current physical state of the key. +system for the current state of the physical key. It also does not provide any +key repeat information. @anchor GLFW_STICKY_KEYS Whenever you poll state, you risk missing the state change you are looking for. @@ -195,15 +200,15 @@ Lock was on when the event occurred and the @ref GLFW_MOD_NUM_LOCK bit set if Num Lock was on. The `GLFW_KEY_LAST` constant holds the highest value of any -[named key](@ref keys). +[key token](@ref keys). @subsection input_char Text input GLFW supports text input in the form of a stream of [Unicode code points](https://en.wikipedia.org/wiki/Unicode), as produced by the -operating system text input system. Unlike key input, text input obeys keyboard -layouts and modifier keys and supports composing characters using +operating system text input system. Unlike key input, text input is affected by +keyboard layouts and modifier keys and supports composing characters using [dead keys](https://en.wikipedia.org/wiki/Dead_key). Once received, you can encode the code points into UTF-8 or any other encoding you prefer. @@ -502,8 +507,9 @@ void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) The action is one of `GLFW_PRESS` or `GLFW_RELEASE`. -Mouse button states for [named buttons](@ref buttons) are also saved in -per-window state arrays that can be polled with @ref glfwGetMouseButton. +The last reported state for every [supported mouse button](@ref buttons) is also +saved in per-window state arrays that can be polled with @ref +glfwGetMouseButton. @code int state = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT); @@ -536,7 +542,7 @@ had been processed in the meantime, the state will reset to `GLFW_RELEASE`, otherwise it will remain `GLFW_PRESS`. The `GLFW_MOUSE_BUTTON_LAST` constant holds the highest value of any -[named button](@ref buttons). +[supported mouse button](@ref buttons). @subsection scrolling Scroll input diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 8116784d..eb98dafd 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -361,10 +361,15 @@ extern "C" { #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 + /*! @} */ -/*! @defgroup keys Keyboard keys - * @brief Keyboard key IDs. +/*! @defgroup keys Keyboard key tokens + * @brief Keyboard key tokens. * * See [key input](@ref input_key) for how these are used. * @@ -387,9 +392,6 @@ extern "C" { * @{ */ -/* The unknown key */ -#define GLFW_KEY_UNKNOWN -1 - /* Printable keys */ #define GLFW_KEY_SPACE 32 #define GLFW_KEY_APOSTROPHE 39 /* ' */ @@ -4741,15 +4743,18 @@ GLFWAPI const char* glfwGetKeyName(int key, int scancode); * * This function returns the platform-specific scancode of the specified key. * - * If the key is `GLFW_KEY_UNKNOWN` or does not exist on the keyboard this - * method will return `-1`. + * 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. * - * @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. + * @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. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_INVALID_ENUM. * * @thread_safety This function may be called from any thread. * @@ -5058,9 +5063,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 named 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 + * 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 * [window focus callback](@ref glfwSetWindowFocusCallback) has been called. * * The scancode of a key is specific to that platform or sometimes even to that From 52405a9d599412545efd3bc3ace8342ae571ccd0 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Tue, 7 Mar 2023 23:03:06 -0800 Subject: [PATCH 39/50] Win32: Fix invalid hat bit mask being accepted It is reportedly possible to get opposing directions of an XInput DPad bit mask set simultaneously with some controllers. This commit ensures that those values are not passed on to other parts of GLFW. This commit is based on the PR #2291 by @ PeterJohnson but with the following changes: - moved XInput-specific special case to XInput implementation - attempt to preserve data by only masking out the invalid axis - admin (credit, changelog, commit message) Closes #2291 --- CONTRIBUTORS.md | 1 + README.md | 1 + src/win32_joystick.c | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 1b9a277a..afd91a01 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -102,6 +102,7 @@ video tutorials. - JannikGM - Erik S. V. Jansson - jjYBdx4IL + - Peter Johnson - Toni Jovanoski - Arseny Kapoulkine - Cem Karan diff --git a/README.md b/README.md index 797ffd17..7045e75c 100644 --- a/README.md +++ b/README.md @@ -232,6 +232,7 @@ information on what to include when reporting a bug. - [Win32] Bugfix: Right shift emitted `GLFW_KEY_UNKNOWN` when using a CJK IME (#2050) - [Win32] Bugfix: `glfwWaitEventsTimeout` did not return for some sent messages (#2408) - [Win32] Bugfix: Fix pkg-config for dynamic library on Windows (#2386, #2420) + - [Win32] Bugfix: XInput could reportedly provide invalid DPad bit masks (#2291) - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - [Cocoa] Moved main menu creation to GLFW initialization time (#1649) diff --git a/src/win32_joystick.c b/src/win32_joystick.c index 4e83577a..eae44edf 100644 --- a/src/win32_joystick.c +++ b/src/win32_joystick.c @@ -736,6 +736,13 @@ GLFWbool _glfwPollJoystickWin32(_GLFWjoystick* js, int mode) if (xis.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT) dpad |= GLFW_HAT_LEFT; + // Treat invalid combinations as neither being pressed + // while preserving what data can be preserved + if ((dpad & GLFW_HAT_RIGHT) && (dpad & GLFW_HAT_LEFT)) + dpad &= ~(GLFW_HAT_RIGHT | GLFW_HAT_LEFT); + if ((dpad & GLFW_HAT_UP) && (dpad & GLFW_HAT_DOWN)) + dpad &= ~(GLFW_HAT_UP | GLFW_HAT_DOWN); + _glfwInputJoystickHat(js, 0, dpad); } From 0ede5f58c6f7c167499c0c78ce445828f44c15ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 5 Dec 2023 22:14:53 +0100 Subject: [PATCH 40/50] Simplify joystick hat value assertions --- src/input.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/input.c b/src/input.c index 8ab141fb..8b7ef29c 100644 --- a/src/input.c +++ b/src/input.c @@ -462,10 +462,11 @@ void _glfwInputJoystickHat(_GLFWjoystick* js, int hat, char value) assert(hat >= 0); assert(hat < js->hatCount); - // Valid hat values only use the least significant nibble and have at most two bits - // set, which can be considered adjacent plus an arbitrary rotation within the nibble + // Valid hat values only use the least significant nibble assert((value & 0xf0) == 0); - assert((value & ((value << 2) | (value >> 2))) == 0); + // Valid hat values do not have both bits of an axis set + assert((value & GLFW_HAT_LEFT) == 0 || (value & GLFW_HAT_RIGHT) == 0); + assert((value & GLFW_HAT_UP) == 0 || (value & GLFW_HAT_DOWN) == 0); base = js->buttonCount + hat * 4; From 5e4496cb420df4d93b4a31805b9fef443433f73b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 5 Dec 2023 20:59:42 +0100 Subject: [PATCH 41/50] Cocoa: Fix compilation error on OS X 10.8 The occlusion state parts of NSWindow are OS X 10.9+ only but we still (technically) support building for only 10.8. Fixes #2161 --- README.md | 2 ++ src/cocoa_window.m | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7045e75c..fc8f89ce 100644 --- a/README.md +++ b/README.md @@ -273,6 +273,8 @@ information on what to include when reporting a bug. application (#2110) - [Cocoa] Bugfix: The Vulkan loader was not loaded from the `Frameworks` bundle subdirectory (#2113,#2120) + - [Cocoa] Bugfix: Compilation failed on OS X 10.8 due to unconditional use of 10.9+ + symbols (#2161) - [X11] Bugfix: The CMake files did not check for the XInput headers (#1480) - [X11] Bugfix: Key names were not updated when the keyboard layout changed (#1462,#1528) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 6f8aa978..c030c2d5 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -311,10 +311,15 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; - (void)windowDidChangeOcclusionState:(NSNotification* )notification { - if ([window->ns.object occlusionState] & NSWindowOcclusionStateVisible) - window->ns.occluded = GLFW_FALSE; - else - window->ns.occluded = GLFW_TRUE; +#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 } @end From ddd92a4fa8dea2729ad2ea09172a8cfd541e53e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 6 Dec 2023 17:02:24 +0100 Subject: [PATCH 42/50] Update changelog and add credit Related to #2327 --- CONTRIBUTORS.md | 1 + README.md | 1 + 2 files changed, 2 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index afd91a01..741bce3a 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -213,6 +213,7 @@ video tutorials. - Matt Sealey - Steve Sexton - Arkady Shapkin + - Mingjie Shen - Ali Sherief - Yoshiki Shibukawa - Dmitri Shuralyov diff --git a/README.md b/README.md index fc8f89ce..d7810cd5 100644 --- a/README.md +++ b/README.md @@ -184,6 +184,7 @@ information on what to include when reporting a bug. - Bugfix: `glfwSetGammaRamp` could emit `GLFW_INVALID_VALUE` before initialization - Bugfix: `glfwGetJoystickUserPointer` returned `NULL` during disconnection (#2092) - Bugfix: `glfwGetKeyScancode` returned `0` on error when initialized instead of `-1` + - Bugfix: Failure to make a newly created context current could cause segfault (#2327) - [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access to the window menu - [Win32] Added a version info resource to the GLFW DLL From 68edc66aa4e0bcd2772e60711331629e9e369916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 7 Dec 2023 16:01:47 +0100 Subject: [PATCH 43/50] Add credit Fixes #2397 --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 741bce3a..40569702 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -66,6 +66,7 @@ video tutorials. - Nikita Fediuchin - Felipe Ferreira - Michael Fogleman + - forworldm - Jason Francis - Gerald Franz - Mário Freitas From 46cebb5081820418f2a20f3e90b07f9b1bd44b42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 7 Dec 2023 16:51:13 +0100 Subject: [PATCH 44/50] EGL: Only use EGL_EXT_present_opaque on Wayland The EGL_EXT_present_opaque extension is primarily a workaround meant for Wayland, even if the language in it doesn't mention this. GLFW previously always enabled this extension where supported. This caused issues on X11 when running the Nvidia binary blob. This commit ensures the extension is only enabled on Wayland. Fixes #2365 --- CONTRIBUTORS.md | 1 + src/egl_context.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 40569702..a78fd5ce 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -252,6 +252,7 @@ video tutorials. - Jari Vetoniemi - Ricardo Vieira - Nicholas Vitovitch + - Vladimír Vondruš - Simon Voordouw - Corentin Wallez - Torsten Walluhn diff --git a/src/egl_context.c b/src/egl_context.c index 4f76d351..a18590b9 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -704,8 +704,11 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, if (!fbconfig->doublebuffer) SET_ATTRIB(EGL_RENDER_BUFFER, EGL_SINGLE_BUFFER); - if (_glfw.egl.EXT_present_opaque) - SET_ATTRIB(EGL_PRESENT_OPAQUE_EXT, !fbconfig->transparent); + if (_glfw.platform.platformID == GLFW_PLATFORM_WAYLAND) + { + if (_glfw.egl.EXT_present_opaque) + SET_ATTRIB(EGL_PRESENT_OPAQUE_EXT, !fbconfig->transparent); + } SET_ATTRIB(EGL_NONE, EGL_NONE); From 8e9a5d29a8258d2e82250102db9ae713794be321 Mon Sep 17 00:00:00 2001 From: FuzzyQuills Date: Tue, 12 Dec 2023 06:25:44 +1000 Subject: [PATCH 45/50] Cocoa: No NSWindowStyleMaskResizable in fullscreen On macOS 10.15 Catalina and earlier, not having the resizable bit cleared in NSWindowStyleMask in fullscreen leads to windows minimising when clicked anywhere in the content area. On all tested macOS versions it also causes the fullscreen window to be resizable by the user. Regression introduced by 0d599026d04ddcc2695ae938fc1864523dab7a34. Fixes #2377 Closes #2405 --- src/cocoa_window.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index c030c2d5..9d794940 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1284,7 +1284,7 @@ void _glfwSetWindowMonitorCocoa(_GLFWwindow* window, if (window->monitor) { - styleMask &= ~(NSWindowStyleMaskTitled | NSWindowStyleMaskClosable); + styleMask &= ~(NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable); styleMask |= NSWindowStyleMaskBorderless; } else From 7b152019dab027dfd276e37cacaacd439075f6c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 11 Dec 2023 17:07:47 +0100 Subject: [PATCH 46/50] Add credit Related to #2377 Related to #2405 --- CONTRIBUTORS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index a78fd5ce..7ee3c514 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -72,6 +72,7 @@ video tutorials. - Mário Freitas - GeO4d - Marcus Geelnard + - Gegy - ghuser404 - Charles Giessen - Ryan C. Gordon @@ -131,6 +132,7 @@ video tutorials. - Luflosi - lukect - Tristam MacDonald + - Jean-Luc Mackail - Hans Mackowiak - Ramiro Magno - Дмитри Малышев From 378e5fc814ec7d6071d7b3423aac5182b0336f1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 12 Dec 2023 13:46:48 +0100 Subject: [PATCH 47/50] Fix Markdown formatting for changelog entry --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d7810cd5..95ee0baf 100644 --- a/README.md +++ b/README.md @@ -407,7 +407,7 @@ information on what to include when reporting a bug. (#442) - [EGL] Added ANGLE backend selection via `EGL_ANGLE_platform_angle` extension (#1380) - [EGL] Added loading of glvnd `libOpenGL.so.0` where available for OpenGL + - [EGL] Added loading of glvnd `libOpenGL.so.0` where available for OpenGL - [EGL] Bugfix: The `GLFW_DOUBLEBUFFER` context attribute was ignored (#1843) - [GLX] Added loading of glvnd `libGLX.so.0` where available - [GLX] Bugfix: Context creation failed if GLX 1.4 was not exported by GLX library From eeeb56eb23c9a23866e8042fb23d7b0b4d96d106 Mon Sep 17 00:00:00 2001 From: lo-v-ol Date: Mon, 5 Jun 2023 08:56:15 +0100 Subject: [PATCH 48/50] EGL: Fix GLFW_CONTEXT_NO_ERROR on Mesa Mesa EGL requires the context version to be set to 2.0 or greater before EGL_CONTEXT_OPENGL_NO_ERROR_KHR in the attribute list. Without this, context creation via Mesa EGL with EGL_CONTEXT_OPENGL_NO_ERROR_KHR set fails with EGL_BAD_ATTRIBUTE. Fixes #2348 --- src/egl_context.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/egl_context.c b/src/egl_context.c index a18590b9..6e997b11 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -641,18 +641,18 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR; } - if (ctxconfig->noerror) - { - if (_glfw.egl.KHR_create_context_no_error) - SET_ATTRIB(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, GLFW_TRUE); - } - if (ctxconfig->major != 1 || ctxconfig->minor != 0) { SET_ATTRIB(EGL_CONTEXT_MAJOR_VERSION_KHR, ctxconfig->major); SET_ATTRIB(EGL_CONTEXT_MINOR_VERSION_KHR, ctxconfig->minor); } + if (ctxconfig->noerror) + { + if (_glfw.egl.KHR_create_context_no_error) + SET_ATTRIB(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, GLFW_TRUE); + } + if (mask) SET_ATTRIB(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, mask); From ea3ea627086f06f207928dceb61a8ea5d0fb3fb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 12 Dec 2023 13:39:54 +0100 Subject: [PATCH 49/50] Update changelog and add credit Related to #2348 --- CONTRIBUTORS.md | 1 + README.md | 1 + 2 files changed, 2 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 7ee3c514..0b66f2ef 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -127,6 +127,7 @@ video tutorials. - Anders Lindqvist - Leon Linhart - Marco Lizza + - lo-v-ol - Eyal Lotem - Aaron Loucks - Luflosi diff --git a/README.md b/README.md index 95ee0baf..831bdba6 100644 --- a/README.md +++ b/README.md @@ -409,6 +409,7 @@ information on what to include when reporting a bug. (#1380) - [EGL] Added loading of glvnd `libOpenGL.so.0` where available for OpenGL - [EGL] Bugfix: The `GLFW_DOUBLEBUFFER` context attribute was ignored (#1843) + - [EGL] Bugfix: Setting `GLFW_CONTEXT_DEBUG` caused creation to fail (#2348) - [GLX] Added loading of glvnd `libGLX.so.0` where available - [GLX] Bugfix: Context creation failed if GLX 1.4 was not exported by GLX library From 2c1d31009fdc527d5a44ff887659a25ecbf1f7f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 12 Dec 2023 17:38:52 +0100 Subject: [PATCH 50/50] Cocoa: Fix segfault querying joystick elements It is reportedly possible for IOHIDDeviceCopyMatchingElements to return NULL on macOS 13 if the application lacks input monitoring permissions. This commit only prevents the segfault. More work will be needed to correctly handle this situation, including Game Controller support. Related to #2320 Closes #2321 --- CONTRIBUTORS.md | 1 + README.md | 2 ++ src/cocoa_joystick.m | 11 ++++++++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 0b66f2ef..75533ec3 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -85,6 +85,7 @@ video tutorials. - Andrew Gutekanst - Stephen Gutekanst - Jonathan Hale + - Daniel Hauser - hdf89shfdfs - Moritz Heinemann - Sylvain Hellegouarch diff --git a/README.md b/README.md index 831bdba6..cebe62bc 100644 --- a/README.md +++ b/README.md @@ -276,6 +276,8 @@ information on what to include when reporting a bug. subdirectory (#2113,#2120) - [Cocoa] Bugfix: Compilation failed on OS X 10.8 due to unconditional use of 10.9+ symbols (#2161) + - [Cocoa] Bugfix: Querying joystick elements could reportedly segfault on macOS + 13 Ventura (#2320) - [X11] Bugfix: The CMake files did not check for the XInput headers (#1480) - [X11] Bugfix: Key names were not updated when the keyboard layout changed (#1462,#1528) diff --git a/src/cocoa_joystick.m b/src/cocoa_joystick.m index 865adac7..caeb4725 100644 --- a/src/cocoa_joystick.m +++ b/src/cocoa_joystick.m @@ -136,6 +136,14 @@ static void matchCallback(void* context, return; } + CFArrayRef elements = + IOHIDDeviceCopyMatchingElements(device, NULL, kIOHIDOptionsTypeNone); + + // It is reportedly possible for this to fail on macOS 13 Ventura + // if the application does not have input monitoring permissions + if (!elements) + return; + axes = CFArrayCreateMutable(NULL, 0, NULL); buttons = CFArrayCreateMutable(NULL, 0, NULL); hats = CFArrayCreateMutable(NULL, 0, NULL); @@ -179,9 +187,6 @@ static void matchCallback(void* context, name[8], name[9], name[10]); } - CFArrayRef elements = - IOHIDDeviceCopyMatchingElements(device, NULL, kIOHIDOptionsTypeNone); - for (CFIndex i = 0; i < CFArrayGetCount(elements); i++) { IOHIDElementRef native = (IOHIDElementRef)