From a9343d641c0419622c388b3e8b6413c88e8dd608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 16 Apr 2019 14:47:38 +0200 Subject: [PATCH 001/167] Start 3.3.1 --- CMakeLists.txt | 2 +- README.md | 183 +------------------------------------------ include/GLFW/glfw3.h | 2 +- 3 files changed, 3 insertions(+), 184 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c0f625032..061618ee03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ endif() set(GLFW_VERSION_MAJOR "3") set(GLFW_VERSION_MINOR "3") -set(GLFW_VERSION_PATCH "0") +set(GLFW_VERSION_PATCH "1") set(GLFW_VERSION_EXTRA "") set(GLFW_VERSION "${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}") set(GLFW_VERSION_FULL "${GLFW_VERSION}.${GLFW_VERSION_PATCH}${GLFW_VERSION_EXTRA}") diff --git a/README.md b/README.md index 27a0b38722..3fce2f8c2e 100644 --- a/README.md +++ b/README.md @@ -118,188 +118,7 @@ information on what to include when reporting a bug. ## Changelog -- Added `glfwGetError` function for querying the last error code and its - description (#970) -- Added `glfwUpdateGamepadMappings` function for importing gamepad mappings in - SDL\_GameControllerDB format (#900) -- Added `glfwJoystickIsGamepad` function for querying whether a joystick has - a gamepad mapping (#900) -- Added `glfwGetJoystickGUID` function for querying the SDL compatible GUID of - a joystick (#900) -- Added `glfwGetGamepadName` function for querying the name provided by the - gamepad mapping (#900) -- Added `glfwGetGamepadState` function, `GLFW_GAMEPAD_*` and `GLFWgamepadstate` - for retrieving gamepad input state (#900) -- Added `glfwGetWindowContentScale`, `glfwGetMonitorContentScale` and - `glfwSetWindowContentScaleCallback` for DPI-aware rendering - (#235,#439,#677,#845,#898) -- Added `glfwRequestWindowAttention` function for requesting attention from the - user (#732,#988) -- Added `glfwGetMonitorWorkarea` function for retrieving the monitor work area - (#920,#989,#1322) -- Added `glfwGetKeyScancode` function that allows retrieving platform dependent - scancodes for keys (#830) -- Added `glfwSetWindowMaximizeCallback` and `GLFWwindowmaximizefun` for - receiving window maximization events (#778) -- Added `glfwSetWindowAttrib` function for changing window attributes (#537) -- Added `glfwGetJoystickHats` function for querying joystick hats - (#889,#906,#934) -- Added `glfwInitHint` for setting initialization hints -- Added `glfwWindowHintString` for setting string type window hints (#893,#1139) -- Added `glfwGetWindowOpacity` and `glfwSetWindowOpacity` for controlling whole - window transparency (#1089) -- Added `glfwSetMonitorUserPointer` and `glfwGetMonitorUserPointer` for - per-monitor user pointers -- Added `glfwSetJoystickUserPointer` and `glfwGetJoystickUserPointer` for - per-joystick user pointers -- Added `glfwGetX11SelectionString` and `glfwSetX11SelectionString` - functions for accessing X11 primary selection (#894,#1056) -- Added `glfwRawMouseMotionSupported` function for querying raw motion support - (#125,#1400,#1401) -- Added headless [OSMesa](http://mesa3d.org/osmesa.html) backend (#850) -- Added definition of `GLAPIENTRY` to public header -- Added `GLFW_TRANSPARENT_FRAMEBUFFER` window hint and attribute for controlling - per-pixel framebuffer transparency (#197,#663,#715,#723,#1078) -- Added `GLFW_HOVERED` window attribute for polling cursor hover state (#1166) -- Added `GLFW_CENTER_CURSOR` window hint for controlling cursor centering - (#749,#842) -- Added `GLFW_FOCUS_ON_SHOW` window hint and attribute to control input focus - on calling show window (#1189) -- Added `GLFW_SCALE_TO_MONITOR` window hint for automatic window resizing - (#676,#1115) -- Added `GLFW_JOYSTICK_HAT_BUTTONS` init hint (#889) -- Added `GLFW_LOCK_KEY_MODS` input mode and `GLFW_MOD_*_LOCK` mod bits (#946) -- Added `GLFW_RAW_MOUSE_MOTION` input mode for selecting raw motion input - (#125,#1400,#1401) -- Added macOS specific `GLFW_COCOA_RETINA_FRAMEBUFFER` window hint -- Added macOS specific `GLFW_COCOA_FRAME_NAME` window hint (#195) -- Added macOS specific `GLFW_COCOA_GRAPHICS_SWITCHING` window hint (#377,#935) -- Added macOS specific `GLFW_COCOA_CHDIR_RESOURCES` init hint -- Added macOS specific `GLFW_COCOA_MENUBAR` init hint -- Added X11 specific `GLFW_X11_CLASS_NAME` and `GLFW_X11_INSTANCE_NAME` window - hints (#893,#1139) -- Added `GLFW_INCLUDE_ES32` for including the OpenGL ES 3.2 header -- Added `GLFW_OSMESA_CONTEXT_API` for creating OpenGL contexts with - [OSMesa](https://www.mesa3d.org/osmesa.html) (#281) -- Added `GenerateMappings.cmake` script for updating gamepad mappings -- Made `glfwCreateWindowSurface` emit an error when the window has a context - (#1194,#1205) -- Deprecated window parameter of clipboard string functions -- Deprecated charmods callback -- Removed `GLFW_USE_RETINA` compile-time option -- Removed `GLFW_USE_CHDIR` compile-time option -- Removed `GLFW_USE_MENUBAR` compile-time option -- Removed requirement of at least one window for `glfwWaitEvents` and - `glfwPostEmptyEvent` (#1317) -- Removed all dependencies on the Vulkan SDK -- Bugfix: Calling `glfwMaximizeWindow` on a full screen window was not ignored -- Bugfix: `GLFW_INCLUDE_VULKAN` could not be combined with the corresponding - OpenGL and OpenGL ES header macros -- Bugfix: `glfwGetInstanceProcAddress` returned `NULL` for - `vkGetInstanceProcAddr` when `_GLFW_VULKAN_STATIC` was enabled -- Bugfix: Invalid library paths were used in test and example CMake files (#930) -- Bugfix: The scancode for synthetic key release events was always zero -- Bugfix: The generated Doxyfile did not handle paths with spaces (#1081) -- Bugfix: The gamma ramp generated by `glfwSetGamma` did not use the monitor - ramp size (#1387,#1388) -- [Win32] Added system error strings to relevant GLFW error descriptions (#733) -- [Win32] Removed XInput circular deadzone from joystick axis data (#1045) -- [Win32] Bugfix: Undecorated windows could not be iconified by the user (#861) -- [Win32] Bugfix: Deadzone logic could underflow with some controllers (#910) -- [Win32] Bugfix: `glfwVulkanSupported` emitted an error on systems with - a loader but no ICD (#916) -- [Win32] Bugfix: Non-iconified full sreeen windows did not prevent screen - blanking or password enabled screensavers (#851) -- [Win32] Bugfix: Mouse capture logic lost secondary release messages (#954) -- [Win32] Bugfix: Monitors with no display devices were not enumerated (#960) -- [Win32] Bugfix: Monitor events were not emitted (#784) -- [Win32] Bugfix: The DLL was installed to the wrong directory on Cygwin (#1035) -- [Win32] Bugfix: Normalization of axis data via XInput was incorrect (#1045) -- [Win32] Bugfix: `glfw3native.h` would undefine a foreign `APIENTRY` (#1062) -- [Win32] Bugfix: Disabled cursor mode prevented use of caption buttons - (#650,#1071) -- [Win32] Bugfix: Returned key names did not match other platforms (#943) -- [Win32] Bugfix: Undecorated windows did not maximize to workarea (#899) -- [Win32] Bugfix: Window was resized twice when entering full screen (#1085) -- [Win32] Bugfix: The HID device notification was not unregistered (#1170) -- [Win32] Bugfix: `glfwCreateWindow` activated window even with `GLFW_FOCUSED` - hint set to false (#1179,#1180) -- [Win32] Bugfix: The keypad equals key was reported as `GLFW_KEY_UNKNOWN` - (#1315,#1316) -- [Win32] Bugfix: A title bar would be drawn over undecorated windows in some - circumstances (#1383) -- [Win32] Bugfix: Standard cursors were not per-monitor DPI aware (#1431) -- [X11] Replaced `_GLFW_HAS_XF86VM` compile-time option with dynamic loading -- [X11] Bugfix: `glfwGetVideoMode` would segfault on Cygwin/X -- [X11] Bugfix: Dynamic X11 library loading did not use full sonames (#941) -- [X11] Bugfix: Window creation on 64-bit would read past top of stack (#951) -- [X11] Bugfix: XDND support had multiple non-conformance issues (#968) -- [X11] Bugfix: The RandR monitor path was disabled despite working RandR (#972) -- [X11] Bugfix: IM-duplicated key events would leak at low polling rates (#747) -- [X11] Bugfix: Gamma ramp setting via RandR did not validate ramp size -- [X11] Bugfix: Key name string encoding depended on current locale (#981,#983) -- [X11] Bugfix: Incremental reading of selections was not supported (#275) -- [X11] Bugfix: Selection I/O reported but did not support `COMPOUND_TEXT` -- [X11] Bugfix: Latin-1 text read from selections was not converted to UTF-8 -- [X11] Bugfix: NVidia EGL would segfault if unloaded before closing the display -- [X11] Bugfix: Checking window maximized attrib could crash some WMs (#1356) -- [X11] Bugfix: Update cursor position on enter event (#1366) -- [X11] Bugfix: `glfwSetWindowMonitor` did not update hints when resizing - non-user-resizable windows -- [X11] Bugfix: `glfwSetWindowMonitor` did not flush output buffer in some cases -- [X11] Bugfix: `glfwSetWindowMonitor` did not update the EWMH state of hidden - windows (#1358) -- [Linux] Added workaround for missing `SYN_DROPPED` in pre-2.6.39 kernel - headers (#1196) -- [Linux] Moved to evdev for joystick input (#906,#1005) -- [Linux] Bugfix: Event processing did not detect joystick disconnection (#932) -- [Linux] Bugfix: The joystick device path could be truncated (#1025) -- [Linux] Bugfix: `glfwInit` would fail if inotify creation failed (#833) -- [Linux] Bugfix: `strdup` was used without any required feature macro (#1055) -- [Cocoa] Added support for Vulkan window surface creation via - [MoltenVK](https://moltengl.com/moltenvk/) (#870) -- [Cocoa] Added support for loading a `MainMenu.nib` when available -- [Cocoa] Disabled automatic window tabbing for created windows (#1250) -- [Cocoa] Bugfix: Disabling window aspect ratio would assert (#852) -- [Cocoa] Bugfix: Window creation failed to set first responder (#876,#883) -- [Cocoa] Bugfix: Removed use of deprecated `CGDisplayIOServicePort` function - (#165,#192,#508,#511) -- [Cocoa] Bugfix: Disabled use of deprecated `CGDisplayModeCopyPixelEncoding` - function on macOS 10.12+ -- [Cocoa] Bugfix: Running in AppSandbox would emit warnings (#816,#882) -- [Cocoa] Bugfix: Windows created after the first were not cascaded (#195) -- [Cocoa] Bugfix: Leaving video mode with `glfwSetWindowMonitor` would set - incorrect position and size (#748) -- [Cocoa] Bugfix: Iconified full screen windows could not be restored (#848) -- [Cocoa] Bugfix: Value range was ignored for joystick hats and buttons (#888) -- [Cocoa] Bugfix: Full screen framebuffer was incorrectly sized for some video - modes (#682) -- [Cocoa] Bugfix: A string object for IME was updated non-idiomatically (#1050) -- [Cocoa] Bugfix: A hidden or disabled cursor would become visible when a user - notification was shown (#971,#1028) -- [Cocoa] Bugfix: Some characters did not repeat due to Press and Hold (#1010) -- [Cocoa] Bugfix: Window title was lost when full screen or undecorated (#1082) -- [Cocoa] Bugfix: Window was resized twice when entering full screen (#1085) -- [Cocoa] Bugfix: Duplicate size events were not filtered (#1085) -- [Cocoa] Bugfix: Event polling did not initialize AppKit if necessary (#1218) -- [Cocoa] Bugfix: OpenGL rendering was not visible before resize on early macOS - 10.14 (#1334,#1346) -- [Cocoa] Bugfix: Caps Lock did not generate any key events (#1368,#1373) -- [Cocoa] Bugfix: Some buttons for some joysticks were ignored (#1385) -- [Cocoa] Bugfix: Analog joystick buttons were not translated correctly (#1385) -- [Cocoa] Bugfix: OpenGL swap interval was ignored for occluded windows (#680) -- [Cocoa] Bugfix: OpenGL swap interval was ignored on early macOS 10.14 - (#1337,#1417,#1435) -- [Cocoa] Bugfix: The y-coordinate was incorrect for `glfwGetCursorPos` and - `glfwSetCursorPos` (#1461) -- [WGL] Added support for `WGL_EXT_colorspace` for OpenGL ES contexts -- [WGL] Added support for `WGL_ARB_create_context_no_error` -- [GLX] Added support for `GLX_ARB_create_context_no_error` -- [GLX] Bugfix: Context creation could segfault if no GLXFBConfigs were - available (#1040) -- [EGL] Added support for `EGL_KHR_get_all_proc_addresses` (#871) -- [EGL] Added support for `EGL_KHR_context_flush_control` -- [EGL] Bugfix: The test for `EGL_RGB_BUFFER` was invalid +User-visible changes since the last release. ## Contact diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 0521d19801..e2e3af176e 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -266,7 +266,7 @@ extern "C" { * API changes. * @ingroup init */ -#define GLFW_VERSION_REVISION 0 +#define GLFW_VERSION_REVISION 1 /*! @} */ /*! @brief One. From 76505355e11046b8f3ad57c72d4e0bf6376a88dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 17 May 2019 16:10:28 +0200 Subject: [PATCH 002/167] Update Travis CI build - Migrate to Xenial - Use whitelisted PPA instead of hardcoded deb URL - Only add X11 dependencies for X11 builds - Only set sudo on matrix entries (cherry picked from commit ff7d42a55e79bcf526dda829732a18cf8a01a70e) --- .travis.yml | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 804b8647a4..a5ee5b42cc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,31 +4,45 @@ branches: only: - ci - master -sudo: false -dist: trusty -addons: - apt: - packages: - - cmake - - libxrandr-dev - - libxinerama-dev - - libxcursor-dev - - libxi-dev matrix: include: - os: linux + dist: xenial + sudo: false + addons: + apt: + packages: + - cmake + - libxrandr-dev + - libxinerama-dev + - libxcursor-dev + - libxi-dev env: - BUILD_SHARED_LIBS=ON - CFLAGS=-Werror - os: linux + dist: xenial + sudo: false + addons: + apt: + packages: + - cmake + - libxrandr-dev + - libxinerama-dev + - libxcursor-dev + - libxi-dev env: - BUILD_SHARED_LIBS=OFF - CFLAGS=-Werror - os: linux + dist: xenial sudo: required addons: apt: + sources: + - ppa:kubuntu-ppa/backports packages: + - extra-cmake-modules - libwayland-dev - libxkbcommon-dev - libegl1-mesa-dev @@ -37,10 +51,14 @@ matrix: - BUILD_SHARED_LIBS=ON - CFLAGS=-Werror - os: linux + dist: xenial sudo: required addons: apt: + sources: + - ppa:kubuntu-ppa/backports packages: + - extra-cmake-modules - libwayland-dev - libxkbcommon-dev - libegl1-mesa-dev @@ -49,10 +67,12 @@ matrix: - BUILD_SHARED_LIBS=OFF - CFLAGS=-Werror - os: osx + sudo: false env: - BUILD_SHARED_LIBS=ON - CFLAGS=-Werror - os: osx + sudo: false env: - BUILD_SHARED_LIBS=OFF - CFLAGS=-Werror @@ -60,9 +80,7 @@ script: - if grep -Inr '\s$' src include docs tests examples CMake *.md .gitattributes .gitignore; then echo Trailing whitespace found, aborting.; exit 1; fi - mkdir build - cd build - - if test -n "${USE_WAYLAND}"; - then wget https://mirrors.kernel.org/ubuntu/pool/universe/e/extra-cmake-modules/extra-cmake-modules_5.38.0a-0ubuntu1_amd64.deb; - sudo dpkg -i extra-cmake-modules_5.38.0a-0ubuntu1_amd64.deb; + - if test -n "${USE_WAYLAND}"; then git clone git://anongit.freedesktop.org/wayland/wayland-protocols; pushd wayland-protocols; git checkout 1.15 && ./autogen.sh --prefix=/usr && make && sudo make install; From 6648b3d4bbcadfbe2b9599049e5f3630681b2f84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 28 Apr 2019 01:43:30 +0200 Subject: [PATCH 003/167] Documentation work The monitor content scale was missing from the monitor properties paragraph. (cherry picked from commit be71147ad51b91a7c5b43f75b9e20fa304fa4752) --- docs/monitor.dox | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/monitor.dox b/docs/monitor.dox index a5a7db76e5..86eb4540b0 100644 --- a/docs/monitor.dox +++ b/docs/monitor.dox @@ -94,8 +94,8 @@ for a disconnected monitor and only before the monitor callback returns. @section monitor_properties Monitor properties Each monitor has a current video mode, a list of supported video modes, -a virtual position, a human-readable name, a user pointer, an estimated physical -size and a gamma ramp. +a virtual position, a content scale, a human-readable name, a user pointer, an +estimated physical size and a gamma ramp. @subsection monitor_modes Video modes From 2e3b4cf8984e8bf983e1647a85aced8f6e6754f0 Mon Sep 17 00:00:00 2001 From: Konstantin Podsvirov Date: Thu, 18 Apr 2019 19:50:48 +0300 Subject: [PATCH 004/167] Fix use of absolute path in INSTALL_INTERFACE Closes #1470. (cherry picked from commit 15af302f77f7c83a869bdfc7ce9abdeeb6231854) --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0913579b61..050ee9e02c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -103,7 +103,7 @@ set_target_properties(glfw PROPERTIES target_compile_definitions(glfw PRIVATE _GLFW_USE_CONFIG_H) target_include_directories(glfw PUBLIC "$" - "$") + "$") target_include_directories(glfw PRIVATE "${GLFW_SOURCE_DIR}/src" "${GLFW_BINARY_DIR}/src" From e826f839a428a0a799cd856bd148e44d730acfff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 2 May 2019 21:32:14 +0200 Subject: [PATCH 005/167] Update changelog and add credit (cherry picked from commit 42a3e4434f27c2afd98ab8e51e9bec09d837843d) --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3fce2f8c2e..017cd5fcf8 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,8 @@ information on what to include when reporting a bug. ## Changelog -User-visible changes since the last release. + - Bugfix: The CMake config-file package used an absolute path and was not + relocatable (#1470) ## Contact @@ -258,6 +259,7 @@ skills. - Cyril Pichard - Keith Pitt - Stanislav Podgorskiy + - Konstantin Podsvirov - Nathan Poirier - Alexandre Pretyman - przemekmirek From 9cc83cf07f47ac8acf46ae12f0f9312fe39cfd6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 7 May 2019 17:03:55 +0200 Subject: [PATCH 006/167] X11: Fix CMake not checking for XInput2 headers Fixes #1480. (cherry picked from commit 090b16bfae282606472f876d6b2fd23fa28e1564) --- CMakeLists.txt | 8 +++++++- README.md | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 061618ee03..706f1063ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -230,10 +230,16 @@ if (_GLFW_X11) message(FATAL_ERROR "The Xcursor headers were not found") endif() + # Check for XInput (modern HID input) + if (NOT X11_Xinput_INCLUDE_PATH) + message(FATAL_ERROR "The XInput headers were not found") + endif() + list(APPEND glfw_INCLUDE_DIRS "${X11_Xrandr_INCLUDE_PATH}" "${X11_Xinerama_INCLUDE_PATH}" "${X11_Xkb_INCLUDE_PATH}" - "${X11_Xcursor_INCLUDE_PATH}") + "${X11_Xcursor_INCLUDE_PATH}" + "${X11_Xinput_INCLUDE_PATH}") endif() #-------------------------------------------------------------------- diff --git a/README.md b/README.md index 017cd5fcf8..3277985c67 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,7 @@ information on what to include when reporting a bug. - Bugfix: The CMake config-file package used an absolute path and was not relocatable (#1470) + - [X11] Bugfix: The CMake files did not check for the XInput headers (#1480) ## Contact From 37cc51b8239cdc2fbf48c79ab0b56f816e0e942e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 17 May 2019 15:19:35 +0200 Subject: [PATCH 007/167] X11: Only check for headers at build time GLFW does not require the X11 extension libraries to build or run, so only fail if the headers are unavailable. (cherry picked from commit 5c5963f1c07e10e344370dbae352683542eab044) --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 706f1063ae..02462d7c17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -211,22 +211,22 @@ if (_GLFW_X11) list(APPEND glfw_LIBRARIES "${X11_X11_LIB}" "${CMAKE_THREAD_LIBS_INIT}") # Check for XRandR (modern resolution switching and gamma control) - if (NOT X11_Xrandr_FOUND) + if (NOT X11_Xrandr_INCLUDE_PATH) message(FATAL_ERROR "The RandR headers were not found") endif() # Check for Xinerama (legacy multi-monitor support) - if (NOT X11_Xinerama_FOUND) + if (NOT X11_Xinerama_INCLUDE_PATH) message(FATAL_ERROR "The Xinerama headers were not found") endif() # Check for Xkb (X keyboard extension) - if (NOT X11_Xkb_FOUND) + if (NOT X11_Xkb_INCLUDE_PATH) message(FATAL_ERROR "The X keyboard extension headers were not found") endif() # Check for Xcursor (cursor creation from RGBA images) - if (NOT X11_Xcursor_FOUND) + if (NOT X11_Xcursor_INCLUDE_PATH) message(FATAL_ERROR "The Xcursor headers were not found") endif() From bc8b567d7cc15be15c18abd939c109637934da60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 8 May 2019 15:28:18 +0200 Subject: [PATCH 008/167] Move to the modern CMake project version option This replaces the manual ad-hoc version variables we have used since CMake 2.x (and GLFW 2.x lite). (cherry picked from commit a255e7ace6a1bbdd879df11916b0273ac207cffb) --- CMakeLists.txt | 11 ++--------- docs/Doxyfile.in | 2 +- examples/CMakeLists.txt | 2 +- src/CMakeLists.txt | 2 +- src/glfw3.pc.in | 2 +- tests/CMakeLists.txt | 2 +- 6 files changed, 7 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 02462d7c17..e959ca6e63 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.0) -project(GLFW C) +project(GLFW VERSION 3.3.1 LANGUAGES C) set(CMAKE_LEGACY_CYGWIN_WIN32 OFF) @@ -8,13 +8,6 @@ if (POLICY CMP0054) cmake_policy(SET CMP0054 NEW) endif() -set(GLFW_VERSION_MAJOR "3") -set(GLFW_VERSION_MINOR "3") -set(GLFW_VERSION_PATCH "1") -set(GLFW_VERSION_EXTRA "") -set(GLFW_VERSION "${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}") -set(GLFW_VERSION_FULL "${GLFW_VERSION}.${GLFW_VERSION_PATCH}${GLFW_VERSION_EXTRA}") - set_property(GLOBAL PROPERTY USE_FOLDERS ON) option(BUILD_SHARED_LIBS "Build shared libraries" OFF) @@ -328,7 +321,7 @@ configure_package_config_file(src/glfw3Config.cmake.in NO_CHECK_REQUIRED_COMPONENTS_MACRO) write_basic_package_version_file(src/glfw3ConfigVersion.cmake - VERSION ${GLFW_VERSION_FULL} + VERSION ${GLFW_VERSION} COMPATIBILITY SameMajorVersion) configure_file(src/glfw_config.h.in src/glfw_config.h @ONLY) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index 27ed92c4b9..7a0056dfd8 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -32,7 +32,7 @@ PROJECT_NAME = "GLFW" # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = @GLFW_VERSION_FULL@ +PROJECT_NUMBER = @GLFW_VERSION@ # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 98da2cd7bd..e0a9c2d68f 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -70,7 +70,7 @@ if (APPLE) set_target_properties(${WINDOWS_BINARIES} PROPERTIES RESOURCE glfw.icns MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION} - MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL} + MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION} MACOSX_BUNDLE_ICON_FILE glfw.icns MACOSX_BUNDLE_INFO_PLIST "${GLFW_SOURCE_DIR}/CMake/MacOSXBundleInfo.plist.in") endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 050ee9e02c..1928670e14 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -95,7 +95,7 @@ endif() add_library(glfw ${glfw_SOURCES} ${glfw_HEADERS}) set_target_properties(glfw PROPERTIES OUTPUT_NAME ${GLFW_LIB_NAME} - VERSION ${GLFW_VERSION} + VERSION ${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR} SOVERSION ${GLFW_VERSION_MAJOR} POSITION_INDEPENDENT_CODE ON FOLDER "GLFW3") diff --git a/src/glfw3.pc.in b/src/glfw3.pc.in index 87423e1a65..f74298d4b7 100644 --- a/src/glfw3.pc.in +++ b/src/glfw3.pc.in @@ -5,7 +5,7 @@ libdir=@CMAKE_INSTALL_FULL_LIBDIR@ Name: GLFW Description: A multi-platform library for OpenGL, window and input -Version: @GLFW_VERSION_FULL@ +Version: @GLFW_VERSION@ URL: https://www.glfw.org/ Requires.private: @GLFW_PKG_DEPS@ Libs: -L${libdir} -l@GLFW_LIB_NAME@ diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 97da4684c2..7e94466811 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -78,7 +78,7 @@ if (APPLE) set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION} - MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL} + MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION} MACOSX_BUNDLE_INFO_PLIST "${GLFW_SOURCE_DIR}/CMake/MacOSXBundleInfo.plist.in") endif() From b596c79014f1965b53387fa1f7e7717961df1792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 8 May 2019 18:33:28 +0200 Subject: [PATCH 009/167] Use CMakeDependentOption for dependent options This replaces the earlier manual logic for dependent CMake options with the cmake_dependent_option function from CMakeDependentOption. (cherry picked from commit cd290f767fbf572bd2a9b5b79f45e2d4f112802c) --- CMakeLists.txt | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e959ca6e63..01c75680a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,22 +18,16 @@ option(GLFW_INSTALL "Generate installation target" ON) option(GLFW_VULKAN_STATIC "Assume the Vulkan loader is linked with the application" OFF) include(GNUInstallDirs) - -if (UNIX) - option(GLFW_USE_OSMESA "Use OSMesa for offscreen context creation" OFF) -endif() - -if (WIN32) - option(GLFW_USE_HYBRID_HPG "Force use of high-performance GPU on hybrid systems" OFF) -endif() - -if (UNIX AND NOT APPLE) - option(GLFW_USE_WAYLAND "Use Wayland for window creation" OFF) -endif() - -if (MSVC) - option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON) -endif() +include(CMakeDependentOption) + +cmake_dependent_option(GLFW_USE_OSMESA "Use OSMesa for offscreen context creation" OFF + "UNIX" OFF) +cmake_dependent_option(GLFW_USE_HYBRID_HPG "Force use of high-performance GPU on hybrid systems" OFF + "WIN32" OFF) +cmake_dependent_option(GLFW_USE_WAYLAND "Use Wayland for window creation" OFF + "UNIX;NOT APPLE" OFF) +cmake_dependent_option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON + "MSVC" OFF) if (BUILD_SHARED_LIBS) set(_GLFW_BUILD_DLL 1) From d715917add8c4767be85699a35938deddc5d7f5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 17 May 2019 16:15:59 +0200 Subject: [PATCH 010/167] Add descriptive names for Travis CI jobs (cherry picked from commit c0eabc594f71fb44e0fb9d5378fc7a5304f1b868) --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index a5ee5b42cc..864869dd0b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ matrix: - os: linux dist: xenial sudo: false + name: "X11 shared library" addons: apt: packages: @@ -23,6 +24,7 @@ matrix: - os: linux dist: xenial sudo: false + name: "X11 static library" addons: apt: packages: @@ -37,6 +39,7 @@ matrix: - os: linux dist: xenial sudo: required + name: "Wayland shared library" addons: apt: sources: @@ -53,6 +56,7 @@ matrix: - os: linux dist: xenial sudo: required + name: "Wayland static library" addons: apt: sources: @@ -68,11 +72,13 @@ matrix: - CFLAGS=-Werror - os: osx sudo: false + name: "Cocoa shared library" env: - BUILD_SHARED_LIBS=ON - CFLAGS=-Werror - os: osx sudo: false + name: "Cocoa static library" env: - BUILD_SHARED_LIBS=OFF - CFLAGS=-Werror From 73a3ef86dbabf082b87159fd7c6d5ae43634e24c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 17 May 2019 16:31:42 +0200 Subject: [PATCH 011/167] Format Travis CI inline script for readability (cherry picked from commit 7dc36dd7da89abeda5181b6506f79842f813a296) --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 864869dd0b..0096210abd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -83,7 +83,10 @@ matrix: - BUILD_SHARED_LIBS=OFF - CFLAGS=-Werror script: - - if grep -Inr '\s$' src include docs tests examples CMake *.md .gitattributes .gitignore; then echo Trailing whitespace found, aborting.; exit 1; fi + - if grep -Inr '\s$' src include docs tests examples CMake *.md .gitattributes .gitignore; then + echo Trailing whitespace found, aborting; + exit 1; + fi - mkdir build - cd build - if test -n "${USE_WAYLAND}"; then From 80935c6c27611b4c02860fa3ad1955c106be785b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 17 May 2019 16:55:52 +0200 Subject: [PATCH 012/167] Remove cmake from Travis CI package list This was left over from an old workaround for Travis CI having an ancient version of CMake pre-installed. (cherry picked from commit 535491c4f39a272d26b8c53b2d4e3b6de6f53531) --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0096210abd..3033fc511b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,6 @@ matrix: addons: apt: packages: - - cmake - libxrandr-dev - libxinerama-dev - libxcursor-dev @@ -28,7 +27,6 @@ matrix: addons: apt: packages: - - cmake - libxrandr-dev - libxinerama-dev - libxcursor-dev From 645b8c3bba8ca115bf040f545a75094fb076bc66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 17 May 2019 16:58:50 +0200 Subject: [PATCH 013/167] Add stable release branch to CI (cherry picked from commit 0ccb690853e29ae38317d762f9deaa37ba101f4b) --- .appveyor.yml | 1 + .travis.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.appveyor.yml b/.appveyor.yml index 4a002500c7..f8aaf42d45 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -2,6 +2,7 @@ branches: only: - ci - master + - 3.3-stable skip_tags: true environment: CFLAGS: /WX diff --git a/.travis.yml b/.travis.yml index 3033fc511b..9b37ebfd33 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ branches: only: - ci - master + - 3.3-stable matrix: include: - os: linux From b383e70021bc875e6fb5c1a693e5aa85fbc160d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 17 May 2019 17:26:46 +0200 Subject: [PATCH 014/167] X11: Fix CMake check for XInput headers The X11_Xinput_* variables have been removed in recent CMake, leaving only the X11_Xi_* set. Related to #1480. (cherry picked from commit ceb16cb5f11b078010a669bab817d8927f8a99b7) --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 01c75680a2..e3af22e82a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -218,7 +218,7 @@ if (_GLFW_X11) endif() # Check for XInput (modern HID input) - if (NOT X11_Xinput_INCLUDE_PATH) + if (NOT X11_Xi_INCLUDE_PATH) message(FATAL_ERROR "The XInput headers were not found") endif() @@ -226,7 +226,7 @@ if (_GLFW_X11) "${X11_Xinerama_INCLUDE_PATH}" "${X11_Xkb_INCLUDE_PATH}" "${X11_Xcursor_INCLUDE_PATH}" - "${X11_Xinput_INCLUDE_PATH}") + "${X11_Xi_INCLUDE_PATH}") endif() #-------------------------------------------------------------------- From 4d99045e8749dd6a96b6f9145f7bbb1fcea543e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 17 May 2019 19:19:07 +0200 Subject: [PATCH 015/167] Add credit Related to #1480. (cherry picked from commit 57bf6b2f75e46369e83b6d727541991533b1dc2d) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3277985c67..6ac3d6b428 100644 --- a/README.md +++ b/README.md @@ -202,6 +202,7 @@ skills. - Lucas Hinderberger - Paul Holden - Warren Hu + - Charles Huber - IntellectualKitty - Aaron Jacobs - Erik S. V. Jansson From 9f5c6c6e8977bfaf33de665770692775fcdd68b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 19 May 2019 18:55:50 +0200 Subject: [PATCH 016/167] Add Vulkan 1.1 support to glfwinfo (cherry picked from commit 700d1f28d8f0f55b8f17a979288c6916267e9b9d) --- tests/glfwinfo.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/tests/glfwinfo.c b/tests/glfwinfo.c index 3bd6f23b51..618d9a27c5 100644 --- a/tests/glfwinfo.c +++ b/tests/glfwinfo.c @@ -809,6 +809,7 @@ int main(int argc, char** argv) if (glfwVulkanSupported()) { + uint32_t loader_version = VK_API_VERSION_1_0; uint32_t i, re_count, pd_count; const char** re; VkApplicationInfo ai = {0}; @@ -818,6 +819,17 @@ int main(int argc, char** argv) gladLoadVulkanUserPtr(NULL, glad_vulkan_callback, NULL); + if (vkEnumerateInstanceVersion) + { + uint32_t version; + if (vkEnumerateInstanceVersion(&version) == VK_SUCCESS) + loader_version = version; + } + + printf("Vulkan loader API version: %i.%i\n", + VK_VERSION_MAJOR(loader_version), + VK_VERSION_MINOR(loader_version)); + re = glfwGetRequiredInstanceExtensions(&re_count); printf("Vulkan required instance extensions:"); @@ -838,10 +850,14 @@ int main(int argc, char** argv) ai.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; ai.pApplicationName = "glfwinfo"; - ai.applicationVersion = GLFW_VERSION_MAJOR; - ai.pEngineName = "GLFW"; - ai.engineVersion = GLFW_VERSION_MAJOR; - ai.apiVersion = VK_API_VERSION_1_0; + ai.applicationVersion = VK_MAKE_VERSION(GLFW_VERSION_MAJOR, + GLFW_VERSION_MINOR, + GLFW_VERSION_REVISION); + + if (loader_version >= VK_API_VERSION_1_1) + ai.apiVersion = VK_API_VERSION_1_1; + else + ai.apiVersion = VK_API_VERSION_1_0; ici.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; ici.pApplicationInfo = &ai; @@ -879,9 +895,11 @@ int main(int argc, char** argv) vkGetPhysicalDeviceProperties(pd[i], &pdp); - printf("Vulkan %s device: \"%s\"\n", + printf("Vulkan %s device: \"%s\" API version %i.%i\n", get_device_type_name(pdp.deviceType), - pdp.deviceName); + pdp.deviceName, + VK_VERSION_MAJOR(pdp.apiVersion), + VK_VERSION_MINOR(pdp.apiVersion)); if (list_extensions) list_vulkan_device_extensions(instance, pd[i]); From 3afb2cc8edeb924cce5c6babd55c895632e9f1fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 19 May 2019 21:41:57 +0200 Subject: [PATCH 017/167] Documentation work Most context related hint and attribute links had copypaste errors. The GLFW_CONTEXT_RELEASE_BEHAVIOR and GLFW_CONTEXT_NO_ERROR attributes did not have guide documentation. (cherry picked from commit 3cf7645b96c593d74f089069ac2e1c67938efd7f) --- docs/window.dox | 15 +++++++++++++++ include/GLFW/glfw3.h | 40 ++++++++++++++++++++-------------------- 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/docs/window.dox b/docs/window.dox index f38e0885ec..3a9e4a2948 100644 --- a/docs/window.dox +++ b/docs/window.dox @@ -1332,6 +1332,21 @@ unknown or the context is an OpenGL ES context. Note that the returned profile may not match the profile bits of the context flags, as GLFW will try other means of detecting the profile when no bits are set. +@anchor GLFW_CONTEXT_RELEASE_BEHAVIOR_attrib +__GLFW_CONTEXT_RELEASE_BEHAVIOR__ indicates the release used by the context. +Possible values are one of `GLFW_ANY_RELEASE_BEHAVIOR`, +`GLFW_RELEASE_BEHAVIOR_FLUSH` or `GLFW_RELEASE_BEHAVIOR_NONE`. If the +behavior is `GLFW_ANY_RELEASE_BEHAVIOR`, the default behavior of the context +creation API will be used. If the behavior is `GLFW_RELEASE_BEHAVIOR_FLUSH`, +the pipeline will be flushed whenever the context is released from being the +current one. If the behavior is `GLFW_RELEASE_BEHAVIOR_NONE`, the pipeline will +not be flushed on release. + +@anchor GLFW_CONTEXT_NO_ERROR_attrib +__GLFW_CONTEXT_NO_ERROR__ indicates whether errors are generated by the context. +Possible values are `GLFW_TRUE` and `GLFW_FALSE`. If enabled, situations that +would have generated errors instead cause undefined behavior. + @anchor GLFW_CONTEXT_ROBUSTNESS_attrib __GLFW_CONTEXT_ROBUSTNESS__ indicates the robustness strategy used by the context. This is `GLFW_LOSE_CONTEXT_ON_RESET` or `GLFW_NO_RESET_NOTIFICATION` diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index e2e3af176e..a116549b6f 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -917,62 +917,62 @@ extern "C" { #define GLFW_CLIENT_API 0x00022001 /*! @brief Context client API major version hint and attribute. * - * Context client API major version [hint](@ref GLFW_CLIENT_API_hint) and - * [attribute](@ref GLFW_CLIENT_API_attrib). + * Context client API major version [hint](@ref GLFW_CONTEXT_VERSION_MAJOR_hint) + * and [attribute](@ref GLFW_CONTEXT_VERSION_MAJOR_attrib). */ #define GLFW_CONTEXT_VERSION_MAJOR 0x00022002 /*! @brief Context client API minor version hint and attribute. * - * Context client API minor version [hint](@ref GLFW_CLIENT_API_hint) and - * [attribute](@ref GLFW_CLIENT_API_attrib). + * Context client API minor version [hint](@ref GLFW_CONTEXT_VERSION_MINOR_hint) + * and [attribute](@ref GLFW_CONTEXT_VERSION_MINOR_attrib). */ #define GLFW_CONTEXT_VERSION_MINOR 0x00022003 /*! @brief Context client API revision number hint and attribute. * - * Context client API revision number [hint](@ref GLFW_CLIENT_API_hint) and - * [attribute](@ref GLFW_CLIENT_API_attrib). + * Context client API revision number + * [attribute](@ref GLFW_CONTEXT_REVISION_attrib). */ #define GLFW_CONTEXT_REVISION 0x00022004 /*! @brief Context robustness hint and attribute. * - * Context client API revision number [hint](@ref GLFW_CLIENT_API_hint) and - * [attribute](@ref GLFW_CLIENT_API_attrib). + * Context client API revision number [hint](@ref GLFW_CONTEXT_ROBUSTNESS_hint) + * and [attribute](@ref GLFW_CONTEXT_ROBUSTNESS_attrib). */ #define GLFW_CONTEXT_ROBUSTNESS 0x00022005 /*! @brief OpenGL forward-compatibility hint and attribute. * - * OpenGL forward-compatibility [hint](@ref GLFW_CLIENT_API_hint) and - * [attribute](@ref GLFW_CLIENT_API_attrib). + * OpenGL forward-compatibility [hint](@ref GLFW_OPENGL_FORWARD_COMPAT_hint) + * and [attribute](@ref GLFW_OPENGL_FORWARD_COMPAT_attrib). */ #define GLFW_OPENGL_FORWARD_COMPAT 0x00022006 /*! @brief OpenGL debug context hint and attribute. * - * OpenGL debug context [hint](@ref GLFW_CLIENT_API_hint) and - * [attribute](@ref GLFW_CLIENT_API_attrib). + * OpenGL debug context [hint](@ref GLFW_OPENGL_DEBUG_CONTEXT_hint) and + * [attribute](@ref GLFW_OPENGL_DEBUG_CONTEXT_attrib). */ #define GLFW_OPENGL_DEBUG_CONTEXT 0x00022007 /*! @brief OpenGL profile hint and attribute. * - * OpenGL profile [hint](@ref GLFW_CLIENT_API_hint) and - * [attribute](@ref GLFW_CLIENT_API_attrib). + * OpenGL profile [hint](@ref GLFW_OPENGL_PROFILE_hint) and + * [attribute](@ref GLFW_OPENGL_PROFILE_attrib). */ #define GLFW_OPENGL_PROFILE 0x00022008 /*! @brief Context flush-on-release hint and attribute. * - * Context flush-on-release [hint](@ref GLFW_CLIENT_API_hint) and - * [attribute](@ref GLFW_CLIENT_API_attrib). + * Context flush-on-release [hint](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_hint) and + * [attribute](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_attrib). */ #define GLFW_CONTEXT_RELEASE_BEHAVIOR 0x00022009 /*! @brief Context error suppression hint and attribute. * - * Context error suppression [hint](@ref GLFW_CLIENT_API_hint) and - * [attribute](@ref GLFW_CLIENT_API_attrib). + * Context error suppression [hint](@ref GLFW_CONTEXT_NO_ERROR_hint) and + * [attribute](@ref GLFW_CONTEXT_NO_ERROR_attrib). */ #define GLFW_CONTEXT_NO_ERROR 0x0002200A /*! @brief Context creation API hint and attribute. * - * Context creation API [hint](@ref GLFW_CLIENT_API_hint) and - * [attribute](@ref GLFW_CLIENT_API_attrib). + * Context creation API [hint](@ref GLFW_CONTEXT_CREATION_API_hint) and + * [attribute](@ref GLFW_CONTEXT_CREATION_API_attrib). */ #define GLFW_CONTEXT_CREATION_API 0x0002200B /*! @brief Window content area scaling window From d2634896d69319b80d4110360e53f9d1a5dd2d1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 19 May 2019 21:51:56 +0200 Subject: [PATCH 018/167] Add missing word (cherry picked from commit feaa5328861d9767d59d4bb60c5553539060cda2) --- docs/quick.dox | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/quick.dox b/docs/quick.dox index 14d03de16e..73070f4a9e 100644 --- a/docs/quick.dox +++ b/docs/quick.dox @@ -337,7 +337,7 @@ presses _Escape_ or closes the window. The program above can be found in the [source package](https://www.glfw.org/download.html) as `examples/simple.c` and is compiled along with all other examples when you build GLFW. If you -built GLFW from the source package then already have this as `simple.exe` on +built GLFW from the source package then you already have this as `simple.exe` on Windows, `simple` on Linux or `simple.app` on macOS. This tutorial used only a few of the many functions GLFW provides. There are From 04522580adb27729e57dd209962ef6f69dbbe710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 20 May 2019 15:24:14 +0200 Subject: [PATCH 019/167] Add C dialect reminders to each source file Files built for Win32 must use C89 style declarations for compatibility with VS 2010 and 2012, which are still supported by GLFW. (cherry picked from commit 56aad76b164be741af21688ea3832093c2069cef) --- src/cocoa_init.m | 2 ++ src/cocoa_joystick.m | 2 ++ src/cocoa_monitor.m | 2 ++ src/cocoa_time.c | 2 ++ src/cocoa_window.m | 2 ++ src/context.c | 2 ++ src/egl_context.c | 2 ++ src/glx_context.c | 2 ++ src/init.c | 2 ++ src/input.c | 2 ++ src/linux_joystick.c | 2 ++ src/monitor.c | 2 ++ src/nsgl_context.m | 2 ++ src/null_init.c | 2 ++ src/null_joystick.c | 2 ++ src/null_monitor.c | 2 ++ src/null_window.c | 2 ++ src/osmesa_context.c | 2 ++ src/posix_thread.c | 2 ++ src/posix_time.c | 2 ++ src/vulkan.c | 2 ++ src/wgl_context.c | 2 ++ src/win32_init.c | 2 ++ src/win32_joystick.c | 2 ++ src/win32_monitor.c | 2 ++ src/win32_thread.c | 2 ++ src/win32_time.c | 2 ++ src/win32_window.c | 2 ++ src/window.c | 2 ++ src/wl_init.c | 2 ++ src/wl_monitor.c | 2 ++ src/wl_window.c | 2 ++ src/x11_init.c | 2 ++ src/x11_monitor.c | 2 ++ src/x11_window.c | 2 ++ src/xkb_unicode.c | 2 ++ 36 files changed, 72 insertions(+) diff --git a/src/cocoa_init.m b/src/cocoa_init.m index 41329b37ea..62a3cfabc3 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -23,6 +23,8 @@ // distribution. // //======================================================================== +// It is fine to use C99 in this file because it will not be built with VS +//======================================================================== #include "internal.h" #include // For MAXPATHLEN diff --git a/src/cocoa_joystick.m b/src/cocoa_joystick.m index db4427d627..a8121e8553 100644 --- a/src/cocoa_joystick.m +++ b/src/cocoa_joystick.m @@ -24,6 +24,8 @@ // distribution. // //======================================================================== +// It is fine to use C99 in this file because it will not be built with VS +//======================================================================== #include "internal.h" diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index e327c628c6..11a31ef4a5 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -24,6 +24,8 @@ // distribution. // //======================================================================== +// It is fine to use C99 in this file because it will not be built with VS +//======================================================================== #include "internal.h" diff --git a/src/cocoa_time.c b/src/cocoa_time.c index 3b2703515c..d390cdc16d 100644 --- a/src/cocoa_time.c +++ b/src/cocoa_time.c @@ -23,6 +23,8 @@ // distribution. // //======================================================================== +// It is fine to use C99 in this file because it will not be built with VS +//======================================================================== #include "internal.h" diff --git a/src/cocoa_window.m b/src/cocoa_window.m index d64809601b..ce896d1f79 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -23,6 +23,8 @@ // distribution. // //======================================================================== +// It is fine to use C99 in this file because it will not be built with VS +//======================================================================== #include "internal.h" diff --git a/src/context.c b/src/context.c index 385085225f..867e399f23 100644 --- a/src/context.c +++ b/src/context.c @@ -24,6 +24,8 @@ // distribution. // //======================================================================== +// Please use C89 style variable declarations in this file because VS 2010 +//======================================================================== #include "internal.h" diff --git a/src/egl_context.c b/src/egl_context.c index 19525276fe..0b93e72d26 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -24,6 +24,8 @@ // distribution. // //======================================================================== +// Please use C89 style variable declarations in this file because VS 2010 +//======================================================================== #include "internal.h" diff --git a/src/glx_context.c b/src/glx_context.c index b03a048985..94aa8f9bdc 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -24,6 +24,8 @@ // distribution. // //======================================================================== +// It is fine to use C99 in this file because it will not be built with VS +//======================================================================== #include "internal.h" diff --git a/src/init.c b/src/init.c index 3d0f9cf70f..e44d0ca226 100644 --- a/src/init.c +++ b/src/init.c @@ -24,6 +24,8 @@ // distribution. // //======================================================================== +// Please use C89 style variable declarations in this file because VS 2010 +//======================================================================== #include "internal.h" #include "mappings.h" diff --git a/src/input.c b/src/input.c index a2f42efec2..337d5cf0fc 100644 --- a/src/input.c +++ b/src/input.c @@ -24,6 +24,8 @@ // distribution. // //======================================================================== +// Please use C89 style variable declarations in this file because VS 2010 +//======================================================================== #include "internal.h" diff --git a/src/linux_joystick.c b/src/linux_joystick.c index 42e457f219..7366cfa59d 100644 --- a/src/linux_joystick.c +++ b/src/linux_joystick.c @@ -24,6 +24,8 @@ // distribution. // //======================================================================== +// It is fine to use C99 in this file because it will not be built with VS +//======================================================================== #include "internal.h" diff --git a/src/monitor.c b/src/monitor.c index d390a1c6fe..db21b7a9e0 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -24,6 +24,8 @@ // distribution. // //======================================================================== +// Please use C89 style variable declarations in this file because VS 2010 +//======================================================================== #include "internal.h" diff --git a/src/nsgl_context.m b/src/nsgl_context.m index bbbbd36d9c..89571a764c 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -23,6 +23,8 @@ // distribution. // //======================================================================== +// It is fine to use C99 in this file because it will not be built with VS +//======================================================================== #include "internal.h" diff --git a/src/null_init.c b/src/null_init.c index b48477b6dc..569bc8c0aa 100644 --- a/src/null_init.c +++ b/src/null_init.c @@ -24,6 +24,8 @@ // distribution. // //======================================================================== +// It is fine to use C99 in this file because it will not be built with VS +//======================================================================== #include "internal.h" diff --git a/src/null_joystick.c b/src/null_joystick.c index 60180bcb1a..000faf2894 100644 --- a/src/null_joystick.c +++ b/src/null_joystick.c @@ -23,6 +23,8 @@ // distribution. // //======================================================================== +// It is fine to use C99 in this file because it will not be built with VS +//======================================================================== #include "internal.h" diff --git a/src/null_monitor.c b/src/null_monitor.c index f5cb092f7e..4514dae908 100644 --- a/src/null_monitor.c +++ b/src/null_monitor.c @@ -24,6 +24,8 @@ // distribution. // //======================================================================== +// It is fine to use C99 in this file because it will not be built with VS +//======================================================================== #include "internal.h" diff --git a/src/null_window.c b/src/null_window.c index 67021ab6aa..045c76a200 100644 --- a/src/null_window.c +++ b/src/null_window.c @@ -24,6 +24,8 @@ // distribution. // //======================================================================== +// It is fine to use C99 in this file because it will not be built with VS +//======================================================================== #include "internal.h" diff --git a/src/osmesa_context.c b/src/osmesa_context.c index b45bb2e156..c2fa49d4bc 100644 --- a/src/osmesa_context.c +++ b/src/osmesa_context.c @@ -24,6 +24,8 @@ // distribution. // //======================================================================== +// Please use C89 style variable declarations in this file because VS 2010 +//======================================================================== #include #include diff --git a/src/posix_thread.c b/src/posix_thread.c index ff4ea60b97..f1697dce3b 100644 --- a/src/posix_thread.c +++ b/src/posix_thread.c @@ -24,6 +24,8 @@ // distribution. // //======================================================================== +// It is fine to use C99 in this file because it will not be built with VS +//======================================================================== #include "internal.h" diff --git a/src/posix_time.c b/src/posix_time.c index 53f856cc1b..040c8f180e 100644 --- a/src/posix_time.c +++ b/src/posix_time.c @@ -24,6 +24,8 @@ // distribution. // //======================================================================== +// It is fine to use C99 in this file because it will not be built with VS +//======================================================================== #include "internal.h" diff --git a/src/vulkan.c b/src/vulkan.c index cb326732bd..7f9ed86260 100644 --- a/src/vulkan.c +++ b/src/vulkan.c @@ -24,6 +24,8 @@ // distribution. // //======================================================================== +// Please use C89 style variable declarations in this file because VS 2010 +//======================================================================== #include "internal.h" diff --git a/src/wgl_context.c b/src/wgl_context.c index 5b0d09b8e1..03ccf2bed6 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -24,6 +24,8 @@ // distribution. // //======================================================================== +// Please use C89 style variable declarations in this file because VS 2010 +//======================================================================== #include "internal.h" diff --git a/src/win32_init.c b/src/win32_init.c index e28868f4ae..216452ef7e 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -24,6 +24,8 @@ // distribution. // //======================================================================== +// Please use C89 style variable declarations in this file because VS 2010 +//======================================================================== #include "internal.h" diff --git a/src/win32_joystick.c b/src/win32_joystick.c index 5c3e87de82..4ffc9fbf40 100644 --- a/src/win32_joystick.c +++ b/src/win32_joystick.c @@ -24,6 +24,8 @@ // distribution. // //======================================================================== +// Please use C89 style variable declarations in this file because VS 2010 +//======================================================================== #include "internal.h" diff --git a/src/win32_monitor.c b/src/win32_monitor.c index e6875dbc80..3982e9ae3c 100644 --- a/src/win32_monitor.c +++ b/src/win32_monitor.c @@ -24,6 +24,8 @@ // distribution. // //======================================================================== +// Please use C89 style variable declarations in this file because VS 2010 +//======================================================================== #include "internal.h" diff --git a/src/win32_thread.c b/src/win32_thread.c index 9391fc9bb0..ce0686db84 100644 --- a/src/win32_thread.c +++ b/src/win32_thread.c @@ -24,6 +24,8 @@ // distribution. // //======================================================================== +// Please use C89 style variable declarations in this file because VS 2010 +//======================================================================== #include "internal.h" diff --git a/src/win32_time.c b/src/win32_time.c index 29670f9758..75594637cd 100644 --- a/src/win32_time.c +++ b/src/win32_time.c @@ -24,6 +24,8 @@ // distribution. // //======================================================================== +// Please use C89 style variable declarations in this file because VS 2010 +//======================================================================== #include "internal.h" diff --git a/src/win32_window.c b/src/win32_window.c index 48b3dd5d20..c46a1e6baa 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -24,6 +24,8 @@ // distribution. // //======================================================================== +// Please use C89 style variable declarations in this file because VS 2010 +//======================================================================== #include "internal.h" diff --git a/src/window.c b/src/window.c index cf403dd0a0..4b356b2167 100644 --- a/src/window.c +++ b/src/window.c @@ -25,6 +25,8 @@ // distribution. // //======================================================================== +// Please use C89 style variable declarations in this file because VS 2010 +//======================================================================== #include "internal.h" diff --git a/src/wl_init.c b/src/wl_init.c index 8a6b918ce7..292de1c382 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -23,6 +23,8 @@ // distribution. // //======================================================================== +// It is fine to use C99 in this file because it will not be built with VS +//======================================================================== #include "internal.h" diff --git a/src/wl_monitor.c b/src/wl_monitor.c index 223c3b8dc5..db49271116 100644 --- a/src/wl_monitor.c +++ b/src/wl_monitor.c @@ -23,6 +23,8 @@ // distribution. // //======================================================================== +// It is fine to use C99 in this file because it will not be built with VS +//======================================================================== #include "internal.h" diff --git a/src/wl_window.c b/src/wl_window.c index 0ae712ddf3..c6cbc7adc5 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -23,6 +23,8 @@ // distribution. // //======================================================================== +// It is fine to use C99 in this file because it will not be built with VS +//======================================================================== #define _GNU_SOURCE diff --git a/src/x11_init.c b/src/x11_init.c index dae5b98c34..a89e7495f6 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -24,6 +24,8 @@ // distribution. // //======================================================================== +// It is fine to use C99 in this file because it will not be built with VS +//======================================================================== #include "internal.h" diff --git a/src/x11_monitor.c b/src/x11_monitor.c index 1cf0c42b04..db9746e8ae 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -24,6 +24,8 @@ // distribution. // //======================================================================== +// It is fine to use C99 in this file because it will not be built with VS +//======================================================================== #include "internal.h" diff --git a/src/x11_window.c b/src/x11_window.c index f66c49b75e..716e116fe8 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -24,6 +24,8 @@ // distribution. // //======================================================================== +// It is fine to use C99 in this file because it will not be built with VS +//======================================================================== #include "internal.h" diff --git a/src/xkb_unicode.c b/src/xkb_unicode.c index ad3cc23338..f30c4cd717 100644 --- a/src/xkb_unicode.c +++ b/src/xkb_unicode.c @@ -24,6 +24,8 @@ // distribution. // //======================================================================== +// It is fine to use C99 in this file because it will not be built with VS +//======================================================================== #include "internal.h" From 97393223eeeb2707051a3b2ecaa14aeea3fb7ce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 20 May 2019 16:00:04 +0200 Subject: [PATCH 020/167] WGL: Fix misplaced block comment (cherry picked from commit 3fd4e79adb00b94442e39d3a16ccc73bc34ec8bb) --- src/wgl_context.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/wgl_context.h b/src/wgl_context.h index fa6605bcb5..26f33227b0 100644 --- a/src/wgl_context.h +++ b/src/wgl_context.h @@ -82,6 +82,7 @@ typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC)(void); typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC); typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC,HGLRC,const int*); +// opengl32.dll function pointer typedefs typedef HGLRC (WINAPI * PFN_wglCreateContext)(HDC); typedef BOOL (WINAPI * PFN_wglDeleteContext)(HGLRC); typedef PROC (WINAPI * PFN_wglGetProcAddress)(LPCSTR); @@ -89,8 +90,6 @@ typedef HDC (WINAPI * PFN_wglGetCurrentDC)(void); typedef HGLRC (WINAPI * PFN_wglGetCurrentContext)(void); typedef BOOL (WINAPI * PFN_wglMakeCurrent)(HDC,HGLRC); typedef BOOL (WINAPI * PFN_wglShareLists)(HGLRC,HGLRC); - -// opengl32.dll function pointer typedefs #define wglCreateContext _glfw.wgl.CreateContext #define wglDeleteContext _glfw.wgl.DeleteContext #define wglGetProcAddress _glfw.wgl.GetProcAddress From 051424f196b5e9791d0e9c20fc06ea59fcb173ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 20 May 2019 16:18:23 +0200 Subject: [PATCH 021/167] WGL: Add extension function macro aliases This should have been done when the WGL extension members were moved from the context struct to the library struct. (cherry picked from commit 22a6c02a4c35752a0bf9d58b6bad5151e5006eea) --- src/wgl_context.c | 21 ++++++++++----------- src/wgl_context.h | 6 ++++++ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/wgl_context.c b/src/wgl_context.c index 03ccf2bed6..fe50524325 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -77,8 +77,8 @@ static int choosePixelFormat(_GLFWwindow* window, { const int attrib = WGL_NUMBER_PIXEL_FORMATS_ARB; - if (!_glfw.wgl.GetPixelFormatAttribivARB(window->context.wgl.dc, - 1, 0, 1, &attrib, &nativeCount)) + if (!wglGetPixelFormatAttribivARB(window->context.wgl.dc, + 1, 0, 1, &attrib, &nativeCount)) { _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, "WGL: Failed to retrieve pixel format attribute"); @@ -141,10 +141,10 @@ static int choosePixelFormat(_GLFWwindow* window, { // Get pixel format attributes through "modern" extension - if (!_glfw.wgl.GetPixelFormatAttribivARB(window->context.wgl.dc, - pixelFormat, 0, - attribCount, - attribs, values)) + if (!wglGetPixelFormatAttribivARB(window->context.wgl.dc, + pixelFormat, 0, + attribCount, + attribs, values)) { _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, "WGL: Failed to retrieve pixel format attributes"); @@ -362,7 +362,7 @@ static void swapIntervalWGL(int interval) } if (_glfw.wgl.EXT_swap_control) - _glfw.wgl.SwapIntervalEXT(interval); + wglSwapIntervalEXT(interval); } static int extensionSupportedWGL(const char* extension) @@ -370,9 +370,9 @@ static int extensionSupportedWGL(const char* extension) const char* extensions = NULL; if (_glfw.wgl.GetExtensionsStringARB) - extensions = _glfw.wgl.GetExtensionsStringARB(wglGetCurrentDC()); + extensions = wglGetExtensionsStringARB(wglGetCurrentDC()); else if (_glfw.wgl.GetExtensionsStringEXT) - extensions = _glfw.wgl.GetExtensionsStringEXT(); + extensions = wglGetExtensionsStringEXT(); if (!extensions) return GLFW_FALSE; @@ -695,8 +695,7 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window, setAttrib(0, 0); window->context.wgl.handle = - _glfw.wgl.CreateContextAttribsARB(window->context.wgl.dc, - share, attribs); + wglCreateContextAttribsARB(window->context.wgl.dc, share, attribs); if (!window->context.wgl.handle) { const DWORD error = GetLastError(); diff --git a/src/wgl_context.h b/src/wgl_context.h index 26f33227b0..d982118809 100644 --- a/src/wgl_context.h +++ b/src/wgl_context.h @@ -76,11 +76,17 @@ #define ERROR_INVALID_PROFILE_ARB 0x2096 #define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 +// WGL extension pointer typedefs typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC)(int); typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC,int,int,UINT,const int*,int*); typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC)(void); typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC); typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC,HGLRC,const int*); +#define wglSwapIntervalEXT _glfw.wgl.SwapIntervalEXT +#define wglGetPixelFormatAttribivARB _glfw.wgl.GetPixelFormatAttribivARB +#define wglGetExtensionsStringEXT _glfw.wgl.GetExtensionsStringEXT +#define wglGetExtensionsStringARB _glfw.wgl.GetExtensionsStringARB +#define wglCreateContextAttribsARB _glfw.wgl.CreateContextAttribsARB // opengl32.dll function pointer typedefs typedef HGLRC (WINAPI * PFN_wglCreateContext)(HDC); From e01128f32f497fcd6084d275d6ec8e0ae66e9284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 20 May 2019 17:13:09 +0200 Subject: [PATCH 022/167] Clarify difference between time and timer in docs (cherry picked from commit bb6945a18ad4a33a2d2a0c9874da11e699978ed2) --- docs/input.dox | 21 +++++++++++---------- include/GLFW/glfw3.h | 30 ++++++++++++++++++------------ 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/docs/input.dox b/docs/input.dox index 4c07a8189a..eb0244a796 100644 --- a/docs/input.dox +++ b/docs/input.dox @@ -864,28 +864,29 @@ GLFW provides high-resolution time input, in seconds, with @ref glfwGetTime. double seconds = glfwGetTime(); @endcode -It returns the number of seconds since the timer was started when the library -was initialized with @ref glfwInit. The platform-specific time sources used -usually have micro- or nanosecond resolution. +It returns the number of seconds since the library was initialized with @ref +glfwInit. The platform-specific time sources used typically have micro- or +nanosecond resolution. -You can modify the reference time with @ref glfwSetTime. +You can modify the base time with @ref glfwSetTime. @code glfwSetTime(4.0); @endcode -This sets the timer to the specified time, in seconds. +This sets the time to the specified time, in seconds, and it continues to count +from there. -You can also access the raw timer value, measured in 1 / frequency -seconds, with @ref glfwGetTimerValue. +You can also access the raw timer used to implement the functions above, +with @ref glfwGetTimerValue. @code uint64_t value = glfwGetTimerValue(); @endcode -The frequency of the raw timer varies depending on what time sources are -available on the machine. You can query its frequency, in Hz, with @ref -glfwGetTimerFrequency. +This value is in 1 / frequency seconds. The frequency of the raw +timer varies depending on the operating system and hardware. You can query the +frequency, in Hz, with @ref glfwGetTimerFrequency. @code uint64_t freqency = glfwGetTimerFrequency(); diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index a116549b6f..4c25bf303c 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -5069,23 +5069,26 @@ GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string); */ GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window); -/*! @brief Returns the value of the GLFW timer. +/*! @brief Returns the GLFW time. * - * This function returns the value of the GLFW timer. Unless the timer has - * been set using @ref glfwSetTime, the timer measures time elapsed since GLFW - * was initialized. + * This function returns the current GLFW time, in seconds. Unless the time + * has been set using @ref glfwSetTime it measures time elapsed since GLFW was + * initialized. + * + * This function and @ref glfwSetTime are helper functions on top of @ref + * glfwGetTimerFrequency and @ref glfwGetTimerValue. * * The resolution of the timer is system dependent, but is usually on the order * of a few micro- or nanoseconds. It uses the highest-resolution monotonic * time source on each supported platform. * - * @return The current value, in seconds, or zero if an + * @return The current time, in seconds, or zero if an * [error](@ref error_handling) occurred. * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @thread_safety This function may be called from any thread. Reading and - * writing of the internal timer offset is not atomic, so it needs to be + * writing of the internal base time is not atomic, so it needs to be * externally synchronized with calls to @ref glfwSetTime. * * @sa @ref time @@ -5096,23 +5099,26 @@ GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window); */ GLFWAPI double glfwGetTime(void); -/*! @brief Sets the GLFW timer. +/*! @brief Sets the GLFW time. + * + * This function sets the current GLFW time, in seconds. The value must be + * a positive finite number less than or equal to 18446744073.0, which is + * approximately 584.5 years. * - * This function sets the value of the GLFW timer. It then continues to count - * up from that value. The value must be a positive finite number less than - * or equal to 18446744073.0, which is approximately 584.5 years. + * This function and @ref glfwGetTime are helper functions on top of @ref + * glfwGetTimerFrequency and @ref glfwGetTimerValue. * * @param[in] time The new value, in seconds. * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_INVALID_VALUE. * - * @remark The upper limit of the timer is calculated as + * @remark The upper limit of GLFW time is calculated as * floor((264 - 1) / 109) and is due to implementations * storing nanoseconds in 64 bits. The limit may be increased in the future. * * @thread_safety This function may be called from any thread. Reading and - * writing of the internal timer offset is not atomic, so it needs to be + * writing of the internal base time is not atomic, so it needs to be * externally synchronized with calls to @ref glfwGetTime. * * @sa @ref time From 15f078c6ad1a44402b022b00f5a7df581b833a5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 2 May 2019 21:13:17 +0200 Subject: [PATCH 023/167] Win32: Remove stale comment (cherry picked from commit 267e06a41e873ee86fbec6763e0932347496347c) --- src/win32_window.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/win32_window.c b/src/win32_window.c index c46a1e6baa..a470b67576 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -832,7 +832,6 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, const int x = GET_X_LPARAM(lParam); const int y = GET_Y_LPARAM(lParam); - // Disabled cursor motion input is provided by WM_INPUT if (window->cursorMode == GLFW_CURSOR_DISABLED) { const int dx = x - window->win32.lastCursorPosX; From ad3e7c7f3915508cd0197696861e50b07561eeba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 2 May 2019 21:15:35 +0200 Subject: [PATCH 024/167] Win32: Fix non-client actions for disabled cursor Disabled cursor mode interfered with some non-client actions. (cherry picked from commit d0c3fa900a378ae1accd74cee88a9b0f03c13f6b) --- src/win32_window.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/win32_window.c b/src/win32_window.c index a470b67576..b7e679e9c4 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -631,12 +631,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, // clicking a caption button if (HIWORD(lParam) == WM_LBUTTONDOWN) { - if (LOWORD(lParam) == HTCLOSE || - LOWORD(lParam) == HTMINBUTTON || - LOWORD(lParam) == HTMAXBUTTON) - { + if (LOWORD(lParam) != HTCLIENT) window->win32.frameAction = GLFW_TRUE; - } } break; @@ -943,6 +939,9 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, case WM_ENTERSIZEMOVE: case WM_ENTERMENULOOP: { + if (window->win32.frameAction) + break; + // HACK: Enable the cursor while the user is moving or // resizing the window or using the window menu if (window->cursorMode == GLFW_CURSOR_DISABLED) @@ -954,6 +953,9 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, case WM_EXITSIZEMOVE: case WM_EXITMENULOOP: { + if (window->win32.frameAction) + break; + // HACK: Disable the cursor once the user is done moving or // resizing the window or using the menu if (window->cursorMode == GLFW_CURSOR_DISABLED) From b436d8e3e6512479737f566cc89fb0dc9b03ce5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 20 May 2019 18:43:34 +0200 Subject: [PATCH 025/167] Remove pointless comments (cherry picked from commit 84ec99bb01b1d1367239d349f97781fd8abaae3a) --- src/glx_context.c | 2 -- src/nsgl_context.m | 2 -- src/wgl_context.c | 2 -- 3 files changed, 6 deletions(-) diff --git a/src/glx_context.c b/src/glx_context.c index 94aa8f9bdc..fbbb897727 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -228,8 +228,6 @@ static GLFWglproc getProcAddressGLX(const char* procname) return _glfw_dlsym(_glfw.glx.handle, procname); } -// Destroy the OpenGL context -// static void destroyContextGLX(_GLFWwindow* window) { if (window->context.glx.window) diff --git a/src/nsgl_context.m b/src/nsgl_context.m index 89571a764c..1b450b18fa 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -119,8 +119,6 @@ static GLFWglproc getProcAddressNSGL(const char* procname) return symbol; } -// Destroy the OpenGL context -// static void destroyContextNSGL(_GLFWwindow* window) { @autoreleasepool { diff --git a/src/wgl_context.c b/src/wgl_context.c index fe50524325..b7d1c4d469 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -389,8 +389,6 @@ static GLFWglproc getProcAddressWGL(const char* procname) return (GLFWglproc) GetProcAddress(_glfw.wgl.instance, procname); } -// Destroy the OpenGL context -// static void destroyContextWGL(_GLFWwindow* window) { if (window->context.wgl.handle) From 16186943b466199f5a5acc35c0582d9d10ecc326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 20 May 2019 19:02:08 +0200 Subject: [PATCH 026/167] Clarify Doxyfile INPUT value generation (cherry picked from commit e1d9e2ba73a0ee6acfbbd4442eb2b5f7720cd29b) --- docs/CMakeLists.txt | 41 ++++++++++++++++++++++------------------- docs/Doxyfile.in | 2 +- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 7a7407a1e2..df9e214720 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -1,24 +1,27 @@ -set(glfw_DOCS_SOURCES - "${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h" - "${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h" - "${GLFW_SOURCE_DIR}/docs/main.dox" - "${GLFW_SOURCE_DIR}/docs/news.dox" - "${GLFW_SOURCE_DIR}/docs/quick.dox" - "${GLFW_SOURCE_DIR}/docs/moving.dox" - "${GLFW_SOURCE_DIR}/docs/compile.dox" - "${GLFW_SOURCE_DIR}/docs/build.dox" - "${GLFW_SOURCE_DIR}/docs/intro.dox" - "${GLFW_SOURCE_DIR}/docs/context.dox" - "${GLFW_SOURCE_DIR}/docs/monitor.dox" - "${GLFW_SOURCE_DIR}/docs/window.dox" - "${GLFW_SOURCE_DIR}/docs/input.dox" - "${GLFW_SOURCE_DIR}/docs/vulkan.dox" - "${GLFW_SOURCE_DIR}/docs/compat.dox" - "${GLFW_SOURCE_DIR}/docs/internal.dox") +# NOTE: The order of this list determines the order of items in the Guides +# (i.e. Pages) list in the generated documentation +set(GLFW_DOXYGEN_SOURCES + "include/GLFW/glfw3.h" + "include/GLFW/glfw3native.h" + "docs/main.dox" + "docs/news.dox" + "docs/quick.dox" + "docs/moving.dox" + "docs/compile.dox" + "docs/build.dox" + "docs/intro.dox" + "docs/context.dox" + "docs/monitor.dox" + "docs/window.dox" + "docs/input.dox" + "docs/vulkan.dox" + "docs/compat.dox" + "docs/internal.dox") -foreach(arg ${glfw_DOCS_SOURCES}) - set(GLFW_DOCS_SOURCES "${GLFW_DOCS_SOURCES} \\\n\"${arg}\"") +# Format the source list into a Doxyfile INPUT value that Doxygen can parse +foreach(path IN LISTS GLFW_DOXYGEN_SOURCES) + set(GLFW_DOXYGEN_INPUT "${GLFW_DOXYGEN_INPUT} \\\n\"${GLFW_SOURCE_DIR}/${path}\"") endforeach() configure_file(Doxyfile.in Doxyfile @ONLY) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index 7a0056dfd8..0eff0b0f27 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -662,7 +662,7 @@ WARN_LOGFILE = "@GLFW_BINARY_DIR@/docs/warnings.txt" # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = @GLFW_DOCS_SOURCES@ +INPUT = @GLFW_DOXYGEN_INPUT@ # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is From 5416e347ad969081c78f160af4fc12d775fe696d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 23 May 2019 20:09:36 +0200 Subject: [PATCH 027/167] Enable CMake policy CMP0077 where available This will let higher-level projects override GLFW CMake options with normal variables instead of having to use cache variables. This means with CMake 3.13 and later you can now do: set(GLFW_BUILD_TESTS ON) add_subdirectory(path/to/glfw) Instead of the more verbose: set(GLFW_BUILD_TESTS ON CACHE BOOL "" FORCE) add_subdirectory(path/to/glfw) (cherry picked from commit 71e6ff386d9a3e0cc7c069be9b0ee1a9ac738647) --- CMakeLists.txt | 4 ++++ README.md | 1 + 2 files changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e3af22e82a..a07c964551 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,10 @@ if (POLICY CMP0054) cmake_policy(SET CMP0054 NEW) endif() +if (POLICY CMP0077) + cmake_policy(SET CMP0077 NEW) +endif() + set_property(GLOBAL PROPERTY USE_FOLDERS ON) option(BUILD_SHARED_LIBS "Build shared libraries" OFF) diff --git a/README.md b/README.md index 6ac3d6b428..a9e9b8e6d2 100644 --- a/README.md +++ b/README.md @@ -220,6 +220,7 @@ skills. - Robin Leffmann - Glenn Lewis - Shane Liesegang + - Anders Lindqvist - Eyal Lotem - Aaron Loucks - Tristam MacDonald From b962ef12419efbb511098e252ac766f00e238324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 24 May 2019 01:52:49 +0200 Subject: [PATCH 028/167] Improve (?) reference documentation for callbacks (cherry picked from commit 51bb76c7c3de934b2dd3affcdc297a32e4817835) --- docs/Doxyfile.in | 1 + include/GLFW/glfw3.h | 426 +++++++++++++++++++++++++++++++++---------- tests/events.c | 2 +- tests/joysticks.c | 2 +- 4 files changed, 328 insertions(+), 103 deletions(-) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index 0eff0b0f27..80ac3bd193 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -200,6 +200,7 @@ ALIASES = "thread_safety=@par Thread safety^^" \ "analysis=@par Analysis^^" \ "reentrancy=@par Reentrancy^^" \ "errors=@par Errors^^" \ + "callback_signature=@par Callback signature^^" \ "glfw3=__GLFW 3:__" \ "x11=__X11:__" \ "wayland=__Wayland:__" \ diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 4c25bf303c..c95b80db18 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1164,13 +1164,21 @@ typedef struct GLFWwindow GLFWwindow; */ typedef struct GLFWcursor GLFWcursor; -/*! @brief The function signature for error callbacks. +/*! @brief The function pointer type for error callbacks. * - * This is the function signature for error callback functions. + * This is the function pointer type for error callbacks. An error callback + * function has the following signature: + * @code + * void callback_name(int error_code, const char* description) + * @endcode * - * @param[in] error An [error code](@ref errors). + * @param[in] error_code An [error code](@ref errors). Future releases may add + * more error codes. * @param[in] description A UTF-8 encoded string describing the error. * + * @pointer_lifetime The error description string is valid until the callback + * function returns. + * * @sa @ref error_handling * @sa @ref glfwSetErrorCallback * @@ -1180,9 +1188,13 @@ typedef struct GLFWcursor GLFWcursor; */ typedef void (* GLFWerrorfun)(int,const char*); -/*! @brief The function signature for window position callbacks. +/*! @brief The function pointer type for window position callbacks. * - * This is the function signature for window position callback functions. + * This is the function pointer type for window position callbacks. A window + * position callback function has the following signature: + * @code + * void callback_name(GLFWwindow* window, int xpos, int ypos) + * @endcode * * @param[in] window The window that was moved. * @param[in] xpos The new x-coordinate, in screen coordinates, of the @@ -1199,9 +1211,13 @@ typedef void (* GLFWerrorfun)(int,const char*); */ typedef void (* GLFWwindowposfun)(GLFWwindow*,int,int); -/*! @brief The function signature for window resize callbacks. +/*! @brief The function pointer type for window size callbacks. * - * This is the function signature for window size callback functions. + * This is the function pointer type for window size callbacks. A window size + * callback function has the following signature: + * @code + * void callback_name(GLFWwindow* window, int width, int height) + * @endcode * * @param[in] window The window that was resized. * @param[in] width The new width, in screen coordinates, of the window. @@ -1217,9 +1233,13 @@ typedef void (* GLFWwindowposfun)(GLFWwindow*,int,int); */ typedef void (* GLFWwindowsizefun)(GLFWwindow*,int,int); -/*! @brief The function signature for window close callbacks. +/*! @brief The function pointer type for window close callbacks. * - * This is the function signature for window close callback functions. + * This is the function pointer type for window close callbacks. A window + * close callback function has the following signature: + * @code + * void function_name(GLFWwindow* window) + * @endcode * * @param[in] window The window that the user attempted to close. * @@ -1233,9 +1253,13 @@ typedef void (* GLFWwindowsizefun)(GLFWwindow*,int,int); */ typedef void (* GLFWwindowclosefun)(GLFWwindow*); -/*! @brief The function signature for window content refresh callbacks. +/*! @brief The function pointer type for window content refresh callbacks. * - * This is the function signature for window refresh callback functions. + * This is the function pointer type for window content refresh callbacks. + * A window content refresh callback function has the following signature: + * @code + * void function_name(GLFWwindow* window); + * @endcode * * @param[in] window The window whose content needs to be refreshed. * @@ -1249,9 +1273,13 @@ typedef void (* GLFWwindowclosefun)(GLFWwindow*); */ typedef void (* GLFWwindowrefreshfun)(GLFWwindow*); -/*! @brief The function signature for window focus/defocus callbacks. +/*! @brief The function pointer type for window focus callbacks. * - * This is the function signature for window focus callback functions. + * This is the function pointer type for window focus callbacks. A window + * focus callback function has the following signature: + * @code + * void function_name(GLFWwindow* window, int focused) + * @endcode * * @param[in] window The window that gained or lost input focus. * @param[in] focused `GLFW_TRUE` if the window was given input focus, or @@ -1266,10 +1294,13 @@ typedef void (* GLFWwindowrefreshfun)(GLFWwindow*); */ typedef void (* GLFWwindowfocusfun)(GLFWwindow*,int); -/*! @brief The function signature for window iconify/restore callbacks. +/*! @brief The function pointer type for window iconify callbacks. * - * This is the function signature for window iconify/restore callback - * functions. + * This is the function pointer type for window iconify callbacks. A window + * iconify callback function has the following signature: + * @code + * void function_name(GLFWwindow* window, int iconified) + * @endcode * * @param[in] window The window that was iconified or restored. * @param[in] iconified `GLFW_TRUE` if the window was iconified, or @@ -1284,10 +1315,13 @@ typedef void (* GLFWwindowfocusfun)(GLFWwindow*,int); */ typedef void (* GLFWwindowiconifyfun)(GLFWwindow*,int); -/*! @brief The function signature for window maximize/restore callbacks. +/*! @brief The function pointer type for window maximize callbacks. * - * This is the function signature for window maximize/restore callback - * functions. + * This is the function pointer type for window maximize callbacks. A window + * maximize callback function has the following signature: + * @code + * void function_name(GLFWwindow* window, int maximized) + * @endcode * * @param[in] window The window that was maximized or restored. * @param[in] iconified `GLFW_TRUE` if the window was maximized, or @@ -1302,10 +1336,13 @@ typedef void (* GLFWwindowiconifyfun)(GLFWwindow*,int); */ typedef void (* GLFWwindowmaximizefun)(GLFWwindow*,int); -/*! @brief The function signature for framebuffer resize callbacks. +/*! @brief The function pointer type for framebuffer size callbacks. * - * This is the function signature for framebuffer resize callback - * functions. + * This is the function pointer type for framebuffer size callbacks. + * A framebuffer size callback function has the following signature: + * @code + * void function_name(GLFWwindow* window, int width, int height) + * @endcode * * @param[in] window The window whose framebuffer was resized. * @param[in] width The new width, in pixels, of the framebuffer. @@ -1320,10 +1357,13 @@ typedef void (* GLFWwindowmaximizefun)(GLFWwindow*,int); */ typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int); -/*! @brief The function signature for window content scale callbacks. +/*! @brief The function pointer type for window content scale callbacks. * - * This is the function signature for window content scale callback - * functions. + * This is the function pointer type for window content scale callbacks. + * A window content scale callback function has the following signature: + * @code + * void function_name(GLFWwindow* window, float xscale, float yscale) + * @endcode * * @param[in] window The window whose content scale changed. * @param[in] xscale The new x-axis content scale of the window. @@ -1338,14 +1378,19 @@ typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int); */ typedef void (* GLFWwindowcontentscalefun)(GLFWwindow*,float,float); -/*! @brief The function signature for mouse button callbacks. +/*! @brief The function pointer type for mouse button callbacks. * - * This is the function signature for mouse button callback functions. + * This is the function pointer type for mouse button callback functions. + * A mouse button callback function has the following signature: + * @code + * void function_name(GLFWwindow* window, int button, int action, int mods) + * @endcode * * @param[in] window The window that received the event. * @param[in] button The [mouse button](@ref buttons) that was pressed or * released. - * @param[in] action One of `GLFW_PRESS` or `GLFW_RELEASE`. + * @param[in] action One of `GLFW_PRESS` or `GLFW_RELEASE`. Future releases + * may add more actions. * @param[in] mods Bit field describing which [modifier keys](@ref mods) were * held down. * @@ -1359,9 +1404,13 @@ typedef void (* GLFWwindowcontentscalefun)(GLFWwindow*,float,float); */ typedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int); -/*! @brief The function signature for cursor position callbacks. +/*! @brief The function pointer type for cursor position callbacks. * - * This is the function signature for cursor position callback functions. + * This is the function pointer type for cursor position callbacks. A cursor + * position callback function has the following signature: + * @code + * void function_name(GLFWwindow* window, double xpos, double ypos); + * @endcode * * @param[in] window The window that received the event. * @param[in] xpos The new cursor x-coordinate, relative to the left edge of @@ -1378,9 +1427,13 @@ typedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int); */ typedef void (* GLFWcursorposfun)(GLFWwindow*,double,double); -/*! @brief The function signature for cursor enter/leave callbacks. +/*! @brief The function pointer type for cursor enter/leave callbacks. * - * This is the function signature for cursor enter/leave callback functions. + * This is the function pointer type for cursor enter/leave callbacks. + * A cursor enter/leave callback function has the following signature: + * @code + * void function_name(GLFWwindow* window, int entered) + * @endcode * * @param[in] window The window that received the event. * @param[in] entered `GLFW_TRUE` if the cursor entered the window's content @@ -1395,9 +1448,13 @@ typedef void (* GLFWcursorposfun)(GLFWwindow*,double,double); */ typedef void (* GLFWcursorenterfun)(GLFWwindow*,int); -/*! @brief The function signature for scroll callbacks. +/*! @brief The function pointer type for scroll callbacks. * - * This is the function signature for scroll callback functions. + * This is the function pointer type for scroll callbacks. A scroll callback + * function has the following signature: + * @code + * void function_name(GLFWwindow* window, double xoffset, double yoffset) + * @endcode * * @param[in] window The window that received the event. * @param[in] xoffset The scroll offset along the x-axis. @@ -1412,14 +1469,19 @@ typedef void (* GLFWcursorenterfun)(GLFWwindow*,int); */ typedef void (* GLFWscrollfun)(GLFWwindow*,double,double); -/*! @brief The function signature for keyboard key callbacks. +/*! @brief The function pointer type for keyboard key callbacks. * - * This is the function signature for keyboard key callback functions. + * This is the function pointer type for keyboard key callbacks. A keyboard + * key callback function has the following signature: + * @code + * void function_name(GLFWwindow* window, int key, int scancode, int action, int mods) + * @endcode * * @param[in] window The window that received the event. * @param[in] key The [keyboard key](@ref keys) that was pressed or released. * @param[in] scancode The system-specific scancode of the key. - * @param[in] action `GLFW_PRESS`, `GLFW_RELEASE` or `GLFW_REPEAT`. + * @param[in] action `GLFW_PRESS`, `GLFW_RELEASE` or `GLFW_REPEAT`. Future + * releases may add more actions. * @param[in] mods Bit field describing which [modifier keys](@ref mods) were * held down. * @@ -1433,9 +1495,13 @@ typedef void (* GLFWscrollfun)(GLFWwindow*,double,double); */ typedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int,int); -/*! @brief The function signature for Unicode character callbacks. +/*! @brief The function pointer type for Unicode character callbacks. * - * This is the function signature for Unicode character callback functions. + * This is the function pointer type for Unicode character callbacks. + * A Unicode character callback function has the following signature: + * @code + * void function_name(GLFWwindow* window, unsigned int codepoint) + * @endcode * * @param[in] window The window that received the event. * @param[in] codepoint The Unicode code point of the character. @@ -1450,12 +1516,16 @@ typedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int,int); */ typedef void (* GLFWcharfun)(GLFWwindow*,unsigned int); -/*! @brief The function signature for Unicode character with modifiers +/*! @brief The function pointer type for Unicode character with modifiers * callbacks. * - * This is the function signature for Unicode character with modifiers callback - * functions. It is called for each input character, regardless of what - * modifier keys are held down. + * This is the function pointer type for Unicode character with modifiers + * callbacks. It is called for each input character, regardless of what + * modifier keys are held down. A Unicode character with modifiers callback + * function has the following signature: + * @code + * void function_name(GLFWwindow* window, unsigned int codepoint, int mods) + * @endcode * * @param[in] window The window that received the event. * @param[in] codepoint The Unicode code point of the character. @@ -1473,14 +1543,21 @@ typedef void (* GLFWcharfun)(GLFWwindow*,unsigned int); */ typedef void (* GLFWcharmodsfun)(GLFWwindow*,unsigned int,int); -/*! @brief The function signature for file drop callbacks. +/*! @brief The function pointer type for path drop callbacks. * - * This is the function signature for file drop callbacks. + * This is the function pointer type for path drop callbacks. A path drop + * callback function has the following signature: + * @code + * void function_name(GLFWwindow* window, int path_count, const char* paths[]) + * @endcode * * @param[in] window The window that received the event. - * @param[in] count The number of dropped files. + * @param[in] path_count The number of dropped paths. * @param[in] paths The UTF-8 encoded file and/or directory path names. * + * @pointer_lifetime The path array and its strings are valid until the + * callback function returns. + * * @sa @ref path_drop * @sa @ref glfwSetDropCallback * @@ -1488,15 +1565,19 @@ typedef void (* GLFWcharmodsfun)(GLFWwindow*,unsigned int,int); * * @ingroup input */ -typedef void (* GLFWdropfun)(GLFWwindow*,int,const char**); +typedef void (* GLFWdropfun)(GLFWwindow*,int,const char*[]); -/*! @brief The function signature for monitor configuration callbacks. +/*! @brief The function pointer type for monitor configuration callbacks. * - * This is the function signature for monitor configuration callback functions. + * This is the function pointer type for monitor configuration callbacks. + * A monitor callback function has the following signature: + * @code + * void function_name(GLFWmonitor* monitor, int event) + * @endcode * * @param[in] monitor The monitor that was connected or disconnected. - * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. Remaining - * values reserved for future use. + * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. Future + * releases may add more events. * * @sa @ref monitor_event * @sa @ref glfwSetMonitorCallback @@ -1507,14 +1588,17 @@ typedef void (* GLFWdropfun)(GLFWwindow*,int,const char**); */ typedef void (* GLFWmonitorfun)(GLFWmonitor*,int); -/*! @brief The function signature for joystick configuration callbacks. +/*! @brief The function pointer type for joystick configuration callbacks. * - * This is the function signature for joystick configuration callback - * functions. + * This is the function pointer type for joystick configuration callbacks. + * A joystick configuration callback function has the following signature: + * @code + * void function_name(int jid, int event) + * @endcode * * @param[in] jid The joystick that was connected or disconnected. - * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. Remaining - * values reserved for future use. + * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. Future + * releases may add more events. * * @sa @ref joystick_event * @sa @ref glfwSetJoystickCallback @@ -1849,10 +1933,17 @@ GLFWAPI int glfwGetError(const char** description); * Once set, the error callback remains set even after the library has been * terminated. * - * @param[in] cbfun The new callback, or `NULL` to remove the currently set + * @param[in] callback The new callback, or `NULL` to remove the currently set * callback. * @return The previously set callback, or `NULL` if no callback was set. * + * @callback_signature + * @code + * void callback_name(int error_code, const char* description) + * @endcode + * For more information about the callback parameters, see the + * [callback pointer type](@ref GLFWerrorfun). + * * @errors None. * * @remark This function may be called before @ref glfwInit. @@ -1866,7 +1957,7 @@ GLFWAPI int glfwGetError(const char** description); * * @ingroup init */ -GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun); +GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun callback); /*! @brief Returns the currently connected monitors. * @@ -2125,11 +2216,18 @@ GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* monitor); * currently set callback. This is called when a monitor is connected to or * disconnected from the system. * - * @param[in] cbfun The new callback, or `NULL` to remove the currently set + * @param[in] callback The new callback, or `NULL` to remove the currently set * callback. * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * + * @callback_signature + * @code + * void function_name(GLFWmonitor* monitor, int event) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWmonitorfun). + * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @thread_safety This function must only be called from the main thread. @@ -2140,7 +2238,7 @@ GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* monitor); * * @ingroup monitor */ -GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun); +GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun callback); /*! @brief Returns the available video modes for the specified monitor. * @@ -3477,11 +3575,18 @@ GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window); * area of the window. * * @param[in] window The window whose callback to set. - * @param[in] cbfun The new callback, or `NULL` to remove the currently set + * @param[in] callback The new callback, or `NULL` to remove the currently set * callback. * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, int xpos, int ypos) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWwindowposfun). + * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @remark @wayland This callback will never be called, as there is no way for @@ -3495,7 +3600,7 @@ GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window); * * @ingroup window */ -GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun cbfun); +GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun callback); /*! @brief Sets the size callback for the specified window. * @@ -3504,11 +3609,18 @@ GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindow * in screen coordinates, of the content area of the window. * * @param[in] window The window whose callback to set. - * @param[in] cbfun The new callback, or `NULL` to remove the currently set + * @param[in] callback The new callback, or `NULL` to remove the currently set * callback. * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, int width, int height) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWwindowsizefun). + * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @thread_safety This function must only be called from the main thread. @@ -3520,7 +3632,7 @@ GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindow * * @ingroup window */ -GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun cbfun); +GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun callback); /*! @brief Sets the close callback for the specified window. * @@ -3534,11 +3646,18 @@ GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwind * The close callback is not triggered by @ref glfwDestroyWindow. * * @param[in] window The window whose callback to set. - * @param[in] cbfun The new callback, or `NULL` to remove the currently set + * @param[in] callback The new callback, or `NULL` to remove the currently set * callback. * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * + * @callback_signature + * @code + * void function_name(GLFWwindow* window) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWwindowclosefun). + * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @remark @macos Selecting Quit from the application menu will trigger the @@ -3553,7 +3672,7 @@ GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwind * * @ingroup window */ -GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun cbfun); +GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun callback); /*! @brief Sets the refresh callback for the specified window. * @@ -3566,11 +3685,18 @@ GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwi * very infrequently or never at all. * * @param[in] window The window whose callback to set. - * @param[in] cbfun The new callback, or `NULL` to remove the currently set + * @param[in] callback The new callback, or `NULL` to remove the currently set * callback. * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * + * @callback_signature + * @code + * void function_name(GLFWwindow* window); + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWwindowrefreshfun). + * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @thread_safety This function must only be called from the main thread. @@ -3582,7 +3708,7 @@ GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwi * * @ingroup window */ -GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun cbfun); +GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun callback); /*! @brief Sets the focus callback for the specified window. * @@ -3595,11 +3721,18 @@ GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GL * and @ref glfwSetMouseButtonCallback. * * @param[in] window The window whose callback to set. - * @param[in] cbfun The new callback, or `NULL` to remove the currently set + * @param[in] callback The new callback, or `NULL` to remove the currently set * callback. * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, int focused) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWwindowfocusfun). + * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @thread_safety This function must only be called from the main thread. @@ -3610,7 +3743,7 @@ GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GL * * @ingroup window */ -GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun cbfun); +GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun callback); /*! @brief Sets the iconify callback for the specified window. * @@ -3618,11 +3751,18 @@ GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwi * is called when the window is iconified or restored. * * @param[in] window The window whose callback to set. - * @param[in] cbfun The new callback, or `NULL` to remove the currently set + * @param[in] callback The new callback, or `NULL` to remove the currently set * callback. * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, int iconified) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWwindowiconifyfun). + * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @remark @wayland The wl_shell protocol has no concept of iconification, @@ -3636,7 +3776,7 @@ GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwi * * @ingroup window */ -GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun cbfun); +GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun callback); /*! @brief Sets the maximize callback for the specified window. * @@ -3644,11 +3784,18 @@ GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GL * is called when the window is maximized or restored. * * @param[in] window The window whose callback to set. - * @param[in] cbfun The new callback, or `NULL` to remove the currently set + * @param[in] callback The new callback, or `NULL` to remove the currently set * callback. * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, int maximized) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWwindowmaximizefun). + * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @thread_safety This function must only be called from the main thread. @@ -3659,7 +3806,7 @@ GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GL * * @ingroup window */ -GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* window, GLFWwindowmaximizefun cbfun); +GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* window, GLFWwindowmaximizefun callback); /*! @brief Sets the framebuffer resize callback for the specified window. * @@ -3667,11 +3814,18 @@ GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* window, * which is called when the framebuffer of the specified window is resized. * * @param[in] window The window whose callback to set. - * @param[in] cbfun The new callback, or `NULL` to remove the currently set + * @param[in] callback The new callback, or `NULL` to remove the currently set * callback. * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, int width, int height) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWframebuffersizefun). + * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @thread_safety This function must only be called from the main thread. @@ -3682,7 +3836,7 @@ GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* window, * * @ingroup window */ -GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun cbfun); +GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun callback); /*! @brief Sets the window content scale callback for the specified window. * @@ -3690,11 +3844,18 @@ GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window * which is called when the content scale of the specified window changes. * * @param[in] window The window whose callback to set. - * @param[in] cbfun The new callback, or `NULL` to remove the currently set + * @param[in] callback The new callback, or `NULL` to remove the currently set * callback. * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, float xscale, float yscale) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWwindowcontentscalefun). + * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @thread_safety This function must only be called from the main thread. @@ -3706,7 +3867,7 @@ GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window * * @ingroup window */ -GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* window, GLFWwindowcontentscalefun cbfun); +GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* window, GLFWwindowcontentscalefun callback); /*! @brief Processes all pending events. * @@ -4353,11 +4514,18 @@ GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor); * scancode may be zero. * * @param[in] window The window whose callback to set. - * @param[in] cbfun The new key callback, or `NULL` to remove the currently + * @param[in] callback The new key callback, or `NULL` to remove the currently * set callback. * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, int key, int scancode, int action, int mods) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWkeyfun). + * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @thread_safety This function must only be called from the main thread. @@ -4369,7 +4537,7 @@ GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor); * * @ingroup input */ -GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun cbfun); +GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun callback); /*! @brief Sets the Unicode character callback. * @@ -4389,11 +4557,18 @@ GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun cbfun); * on Windows. * * @param[in] window The window whose callback to set. - * @param[in] cbfun The new callback, or `NULL` to remove the currently set + * @param[in] callback The new callback, or `NULL` to remove the currently set * callback. * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, unsigned int codepoint) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWcharfun). + * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @thread_safety This function must only be called from the main thread. @@ -4405,7 +4580,7 @@ GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun cbfun); * * @ingroup input */ -GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun cbfun); +GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun callback); /*! @brief Sets the Unicode character with modifiers callback. * @@ -4423,11 +4598,18 @@ GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun cbfun); * [key callback](@ref glfwSetKeyCallback) instead. * * @param[in] window The window whose callback to set. - * @param[in] cbfun The new callback, or `NULL` to remove the currently set + * @param[in] callback The new callback, or `NULL` to remove the currently set * callback. * @return The previously set callback, or `NULL` if no callback was set or an * [error](@ref error_handling) occurred. * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, unsigned int codepoint, int mods) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWcharmodsfun). + * * @deprecated Scheduled for removal in version 4.0. * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. @@ -4440,7 +4622,7 @@ GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun cbfun); * * @ingroup input */ -GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmodsfun cbfun); +GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmodsfun callback); /*! @brief Sets the mouse button callback. * @@ -4454,11 +4636,18 @@ GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmods * [window focus callback](@ref glfwSetWindowFocusCallback) has been called. * * @param[in] window The window whose callback to set. - * @param[in] cbfun The new callback, or `NULL` to remove the currently set + * @param[in] callback The new callback, or `NULL` to remove the currently set * callback. * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, int button, int action, int mods) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWmousebuttonfun). + * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @thread_safety This function must only be called from the main thread. @@ -4470,7 +4659,7 @@ GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmods * * @ingroup input */ -GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun cbfun); +GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun callback); /*! @brief Sets the cursor position callback. * @@ -4480,11 +4669,18 @@ GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmo * content area of the window. * * @param[in] window The window whose callback to set. - * @param[in] cbfun The new callback, or `NULL` to remove the currently set + * @param[in] callback The new callback, or `NULL` to remove the currently set * callback. * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, double xpos, double ypos); + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWcursorposfun). + * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @thread_safety This function must only be called from the main thread. @@ -4495,20 +4691,27 @@ GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmo * * @ingroup input */ -GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun cbfun); +GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun callback); -/*! @brief Sets the cursor enter/exit callback. +/*! @brief Sets the cursor enter/leave callback. * * This function sets the cursor boundary crossing callback of the specified * window, which is called when the cursor enters or leaves the content area of * the window. * * @param[in] window The window whose callback to set. - * @param[in] cbfun The new callback, or `NULL` to remove the currently set + * @param[in] callback The new callback, or `NULL` to remove the currently set * callback. * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, int entered) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWcursorenterfun). + * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @thread_safety This function must only be called from the main thread. @@ -4519,7 +4722,7 @@ GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursor * * @ingroup input */ -GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun cbfun); +GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun callback); /*! @brief Sets the scroll callback. * @@ -4531,11 +4734,18 @@ GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcu * wheel or a touchpad scrolling area. * * @param[in] window The window whose callback to set. - * @param[in] cbfun The new scroll callback, or `NULL` to remove the currently - * set callback. + * @param[in] callback The new scroll callback, or `NULL` to remove the + * currently set callback. * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, double xoffset, double yoffset) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWscrollfun). + * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @thread_safety This function must only be called from the main thread. @@ -4546,12 +4756,12 @@ GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcu * * @ingroup input */ -GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun cbfun); +GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun callback); -/*! @brief Sets the file drop callback. +/*! @brief Sets the path drop callback. * - * This function sets the file drop callback of the specified window, which is - * called when one or more dragged files are dropped on the window. + * This function sets the path drop callback of the specified window, which is + * called when one or more dragged paths are dropped on the window. * * Because the path array and its strings may have been generated specifically * for that event, they are not guaranteed to be valid after the callback has @@ -4559,11 +4769,18 @@ GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun cb * make a deep copy. * * @param[in] window The window whose callback to set. - * @param[in] cbfun The new file drop callback, or `NULL` to remove the + * @param[in] callback The new file drop callback, or `NULL` to remove the * currently set callback. * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, int path_count, const char* paths[]) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWdropfun). + * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @remark @wayland File drop is currently unimplemented. @@ -4576,7 +4793,7 @@ GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun cb * * @ingroup input */ -GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* window, GLFWdropfun cbfun); +GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* window, GLFWdropfun callback); /*! @brief Returns whether the specified joystick is present. * @@ -4895,11 +5112,18 @@ GLFWAPI int glfwJoystickIsGamepad(int jid); * called by joystick functions. The function will then return whatever it * returns if the joystick is not present. * - * @param[in] cbfun The new callback, or `NULL` to remove the currently set + * @param[in] callback The new callback, or `NULL` to remove the currently set * callback. * @return The previously set callback, or `NULL` if no callback was set or the * library had not been [initialized](@ref intro_init). * + * @callback_signature + * @code + * void function_name(int jid, int event) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWjoystickfun). + * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * * @thread_safety This function must only be called from the main thread. @@ -4910,7 +5134,7 @@ GLFWAPI int glfwJoystickIsGamepad(int jid); * * @ingroup input */ -GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun cbfun); +GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun callback); /*! @brief Adds the specified SDL_GameControllerDB gamepad mappings. * diff --git a/tests/events.c b/tests/events.c index c442dfdcf9..f1dde4569c 100644 --- a/tests/events.c +++ b/tests/events.c @@ -429,7 +429,7 @@ static void char_callback(GLFWwindow* window, unsigned int codepoint) get_character_string(codepoint)); } -static void drop_callback(GLFWwindow* window, int count, const char** paths) +static void drop_callback(GLFWwindow* window, int count, const char* paths[]) { int i; Slot* slot = glfwGetWindowUserPointer(window); diff --git a/tests/joysticks.c b/tests/joysticks.c index 9e88199f78..17ca760633 100644 --- a/tests/joysticks.c +++ b/tests/joysticks.c @@ -85,7 +85,7 @@ static void joystick_callback(int jid, int event) glfwRequestWindowAttention(window); } -static void drop_callback(GLFWwindow* window, int count, const char** paths) +static void drop_callback(GLFWwindow* window, int count, const char* paths[]) { int i; From f2208ab135d608ee2e4ae9c1714e3ea7bf8994e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 24 May 2019 17:17:15 +0200 Subject: [PATCH 029/167] Explicitly disable inclusion for test and examples Thank you, Travis CI, for reminding me that one cannot disable a header with inclusion guards if it doesn't exist. (cherry picked from commit 537ea4ccf1deb7b5e00c3745ab51e82a8c0696dc) --- examples/boing.c | 1 + examples/gears.c | 1 + examples/heightmap.c | 1 + examples/offscreen.c | 1 + examples/particles.c | 1 + examples/sharing.c | 1 + examples/simple.c | 1 + examples/splitview.c | 1 + examples/wave.c | 1 + tests/clipboard.c | 1 + tests/cursor.c | 1 + tests/empty.c | 1 + tests/events.c | 1 + tests/gamma.c | 1 + tests/glfwinfo.c | 1 + tests/icon.c | 1 + tests/iconify.c | 1 + tests/inputlag.c | 1 + tests/joysticks.c | 1 + tests/monitors.c | 1 + tests/msaa.c | 1 + tests/opacity.c | 1 + tests/reopen.c | 1 + tests/tearing.c | 1 + tests/threads.c | 1 + tests/timeout.c | 1 + tests/title.c | 1 + tests/windows.c | 1 + 28 files changed, 28 insertions(+) diff --git a/examples/boing.c b/examples/boing.c index 2ffddbd655..ca389086a1 100644 --- a/examples/boing.c +++ b/examples/boing.c @@ -37,6 +37,7 @@ #include #include +#define GLFW_INCLUDE_NONE #include #include diff --git a/examples/gears.c b/examples/gears.c index 4c7d9a9883..292f44b591 100644 --- a/examples/gears.c +++ b/examples/gears.c @@ -32,6 +32,7 @@ #include #include +#define GLFW_INCLUDE_NONE #include /** diff --git a/examples/heightmap.c b/examples/heightmap.c index bd38339a51..13a3c1e147 100644 --- a/examples/heightmap.c +++ b/examples/heightmap.c @@ -30,6 +30,7 @@ #include #include +#define GLFW_INCLUDE_NONE #include /* Map height updates */ diff --git a/examples/offscreen.c b/examples/offscreen.c index 4f717cb59d..eca37c4810 100644 --- a/examples/offscreen.c +++ b/examples/offscreen.c @@ -24,6 +24,7 @@ //======================================================================== #include +#define GLFW_INCLUDE_NONE #include #if USE_NATIVE_OSMESA diff --git a/examples/particles.c b/examples/particles.c index 29889149b8..248c851637 100644 --- a/examples/particles.c +++ b/examples/particles.c @@ -40,6 +40,7 @@ #include #include +#define GLFW_INCLUDE_NONE #include // Define tokens for GL_EXT_separate_specular_color if not already defined diff --git a/examples/sharing.c b/examples/sharing.c index 34936011d5..4a1a2323da 100644 --- a/examples/sharing.c +++ b/examples/sharing.c @@ -24,6 +24,7 @@ //======================================================================== #include +#define GLFW_INCLUDE_NONE #include #include diff --git a/examples/simple.c b/examples/simple.c index 9b632ea35c..95d8fe6348 100644 --- a/examples/simple.c +++ b/examples/simple.c @@ -25,6 +25,7 @@ //! [code] #include +#define GLFW_INCLUDE_NONE #include #include "linmath.h" diff --git a/examples/splitview.c b/examples/splitview.c index 1e02b77803..58eb11ef95 100644 --- a/examples/splitview.c +++ b/examples/splitview.c @@ -11,6 +11,7 @@ //======================================================================== #include +#define GLFW_INCLUDE_NONE #include #if defined(_MSC_VER) diff --git a/examples/wave.c b/examples/wave.c index 32d78c6ae1..7acb8b9290 100644 --- a/examples/wave.c +++ b/examples/wave.c @@ -18,6 +18,7 @@ #include #include +#define GLFW_INCLUDE_NONE #include #include diff --git a/tests/clipboard.c b/tests/clipboard.c index c6093ce55a..41454a3ca7 100644 --- a/tests/clipboard.c +++ b/tests/clipboard.c @@ -28,6 +28,7 @@ //======================================================================== #include +#define GLFW_INCLUDE_NONE #include #include diff --git a/tests/cursor.c b/tests/cursor.c index 3edadf025f..b6288f6ac8 100644 --- a/tests/cursor.c +++ b/tests/cursor.c @@ -31,6 +31,7 @@ //======================================================================== #include +#define GLFW_INCLUDE_NONE #include #if defined(_MSC_VER) diff --git a/tests/empty.c b/tests/empty.c index ae87f849d3..c3877a715f 100644 --- a/tests/empty.c +++ b/tests/empty.c @@ -30,6 +30,7 @@ #include "tinycthread.h" #include +#define GLFW_INCLUDE_NONE #include #include diff --git a/tests/events.c b/tests/events.c index f1dde4569c..ba7f00ab09 100644 --- a/tests/events.c +++ b/tests/events.c @@ -32,6 +32,7 @@ //======================================================================== #include +#define GLFW_INCLUDE_NONE #include #include diff --git a/tests/gamma.c b/tests/gamma.c index c625447b61..aa4c8b7833 100644 --- a/tests/gamma.c +++ b/tests/gamma.c @@ -29,6 +29,7 @@ //======================================================================== #include +#define GLFW_INCLUDE_NONE #include #define NK_IMPLEMENTATION diff --git a/tests/glfwinfo.c b/tests/glfwinfo.c index 618d9a27c5..5991652dbb 100644 --- a/tests/glfwinfo.c +++ b/tests/glfwinfo.c @@ -25,6 +25,7 @@ #include #include +#define GLFW_INCLUDE_NONE #include #include diff --git a/tests/icon.c b/tests/icon.c index 301923f70a..aa7ee18174 100644 --- a/tests/icon.c +++ b/tests/icon.c @@ -28,6 +28,7 @@ //======================================================================== #include +#define GLFW_INCLUDE_NONE #include #include diff --git a/tests/iconify.c b/tests/iconify.c index 2224a67e7e..ff446d2d8c 100644 --- a/tests/iconify.c +++ b/tests/iconify.c @@ -29,6 +29,7 @@ //======================================================================== #include +#define GLFW_INCLUDE_NONE #include #include diff --git a/tests/inputlag.c b/tests/inputlag.c index f6f5befe9d..269a0c8f97 100644 --- a/tests/inputlag.c +++ b/tests/inputlag.c @@ -29,6 +29,7 @@ //======================================================================== #include +#define GLFW_INCLUDE_NONE #include #define NK_IMPLEMENTATION diff --git a/tests/joysticks.c b/tests/joysticks.c index 17ca760633..8eae021e4b 100644 --- a/tests/joysticks.c +++ b/tests/joysticks.c @@ -29,6 +29,7 @@ //======================================================================== #include +#define GLFW_INCLUDE_NONE #include #define NK_IMPLEMENTATION diff --git a/tests/monitors.c b/tests/monitors.c index d35dfe1fac..30ce408896 100644 --- a/tests/monitors.c +++ b/tests/monitors.c @@ -29,6 +29,7 @@ //======================================================================== #include +#define GLFW_INCLUDE_NONE #include #include diff --git a/tests/msaa.c b/tests/msaa.c index 45d7df7adc..33e2ccc3ba 100644 --- a/tests/msaa.c +++ b/tests/msaa.c @@ -30,6 +30,7 @@ //======================================================================== #include +#define GLFW_INCLUDE_NONE #include #if defined(_MSC_VER) diff --git a/tests/opacity.c b/tests/opacity.c index 5c086ec720..47f28b16bc 100644 --- a/tests/opacity.c +++ b/tests/opacity.c @@ -24,6 +24,7 @@ //======================================================================== #include +#define GLFW_INCLUDE_NONE #include #define NK_IMPLEMENTATION diff --git a/tests/reopen.c b/tests/reopen.c index e077092d23..10d22b28b9 100644 --- a/tests/reopen.c +++ b/tests/reopen.c @@ -34,6 +34,7 @@ //======================================================================== #include +#define GLFW_INCLUDE_NONE #include #include diff --git a/tests/tearing.c b/tests/tearing.c index 8b28d396d8..17a3f0e406 100644 --- a/tests/tearing.c +++ b/tests/tearing.c @@ -29,6 +29,7 @@ //======================================================================== #include +#define GLFW_INCLUDE_NONE #include #include diff --git a/tests/threads.c b/tests/threads.c index 70a93aa9ab..9829493365 100644 --- a/tests/threads.c +++ b/tests/threads.c @@ -31,6 +31,7 @@ #include "tinycthread.h" #include +#define GLFW_INCLUDE_NONE #include #include diff --git a/tests/timeout.c b/tests/timeout.c index e025dfaa80..bda2560c7a 100644 --- a/tests/timeout.c +++ b/tests/timeout.c @@ -28,6 +28,7 @@ //======================================================================== #include +#define GLFW_INCLUDE_NONE #include #include diff --git a/tests/title.c b/tests/title.c index ca8dc5f9e9..a5bad34229 100644 --- a/tests/title.c +++ b/tests/title.c @@ -28,6 +28,7 @@ //======================================================================== #include +#define GLFW_INCLUDE_NONE #include #include diff --git a/tests/windows.c b/tests/windows.c index 296ee937c1..6669856f1e 100644 --- a/tests/windows.c +++ b/tests/windows.c @@ -28,6 +28,7 @@ //======================================================================== #include +#define GLFW_INCLUDE_NONE #include #include From 7b18f79ea61e3f2861ec56a93c2a6ce0ab7d4e6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 24 May 2019 17:21:48 +0200 Subject: [PATCH 030/167] Rename legacy Vulkan triangle program Fixes #1477. (cherry picked from commit d834f01ca43c0f5ddd31b00a7fc2f48abbafa3da) --- .gitignore | 2 +- tests/CMakeLists.txt | 6 +++--- tests/{vulkan.c => triangle-vulkan.c} | 0 3 files changed, 4 insertions(+), 4 deletions(-) rename tests/{vulkan.c => triangle-vulkan.c} (100%) diff --git a/.gitignore b/.gitignore index 859499268a..544117e079 100644 --- a/.gitignore +++ b/.gitignore @@ -80,6 +80,6 @@ tests/tearing tests/threads tests/timeout tests/title -tests/vulkan +tests/triangle-vulkan tests/windows diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7e94466811..fcc992433e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -39,7 +39,7 @@ add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c ${GLAD_GL}) add_executable(threads WIN32 MACOSX_BUNDLE threads.c ${TINYCTHREAD} ${GLAD_GL}) add_executable(timeout WIN32 MACOSX_BUNDLE timeout.c ${GLAD_GL}) add_executable(title WIN32 MACOSX_BUNDLE title.c ${GLAD_GL}) -add_executable(vulkan WIN32 vulkan.c ${ICON} ${GLAD_VULKAN}) +add_executable(triangle-vulkan WIN32 triangle-vulkan.c ${ICON} ${GLAD_VULKAN}) add_executable(windows WIN32 MACOSX_BUNDLE windows.c ${GETOPT} ${GLAD_GL}) target_link_libraries(empty "${CMAKE_THREAD_LIBS_INIT}") @@ -50,7 +50,7 @@ if (RT_LIBRARY) endif() set(WINDOWS_BINARIES empty gamma icon inputlag joysticks opacity tearing - threads timeout title vulkan windows) + threads timeout title triangle-vulkan windows) set(CONSOLE_BINARIES clipboard events msaa glfwinfo iconify monitors reopen cursor) @@ -73,7 +73,7 @@ if (APPLE) set_target_properties(threads PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Threads") set_target_properties(timeout PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Timeout") set_target_properties(title PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Title") - set_target_properties(windows PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Vulkan") + set_target_properties(triangle-vulkan PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Vulkan Triangle") set_target_properties(windows PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Windows") set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES diff --git a/tests/vulkan.c b/tests/triangle-vulkan.c similarity index 100% rename from tests/vulkan.c rename to tests/triangle-vulkan.c From 71a4f2d8a28eb4151a67291116ba81de5c66f707 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Fri, 7 Jun 2019 23:35:10 +0200 Subject: [PATCH 031/167] Replace some tabs with spaces I found some tabs where there should be spaces for consistency. Closes #1496. (cherry picked from commit 2db3b9688da30811c7d92fa9482fd48d8b8382b0) --- src/egl_context.h | 16 ++++++++-------- src/glx_context.h | 6 +++--- src/internal.h | 6 +++--- src/win32_platform.h | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/egl_context.h b/src/egl_context.h index 7def043afe..6d42e11c97 100644 --- a/src/egl_context.h +++ b/src/egl_context.h @@ -47,26 +47,26 @@ typedef struct wl_egl_window* EGLNativeWindowType; #error "No supported EGL platform selected" #endif -#define EGL_SUCCESS 0x3000 -#define EGL_NOT_INITIALIZED 0x3001 +#define EGL_SUCCESS 0x3000 +#define EGL_NOT_INITIALIZED 0x3001 #define EGL_BAD_ACCESS 0x3002 #define EGL_BAD_ALLOC 0x3003 #define EGL_BAD_ATTRIBUTE 0x3004 #define EGL_BAD_CONFIG 0x3005 -#define EGL_BAD_CONTEXT 0x3006 -#define EGL_BAD_CURRENT_SURFACE 0x3007 -#define EGL_BAD_DISPLAY 0x3008 +#define EGL_BAD_CONTEXT 0x3006 +#define EGL_BAD_CURRENT_SURFACE 0x3007 +#define EGL_BAD_DISPLAY 0x3008 #define EGL_BAD_MATCH 0x3009 #define EGL_BAD_NATIVE_PIXMAP 0x300a #define EGL_BAD_NATIVE_WINDOW 0x300b #define EGL_BAD_PARAMETER 0x300c -#define EGL_BAD_SURFACE 0x300d +#define EGL_BAD_SURFACE 0x300d #define EGL_CONTEXT_LOST 0x300e #define EGL_COLOR_BUFFER_TYPE 0x303f #define EGL_RGB_BUFFER 0x308e #define EGL_SURFACE_TYPE 0x3033 #define EGL_WINDOW_BIT 0x0004 -#define EGL_RENDERABLE_TYPE 0x3040 +#define EGL_RENDERABLE_TYPE 0x3040 #define EGL_OPENGL_ES_BIT 0x0001 #define EGL_OPENGL_ES2_BIT 0x0004 #define EGL_OPENGL_BIT 0x0008 @@ -76,7 +76,7 @@ typedef struct wl_egl_window* EGLNativeWindowType; #define EGL_RED_SIZE 0x3024 #define EGL_DEPTH_SIZE 0x3025 #define EGL_STENCIL_SIZE 0x3026 -#define EGL_SAMPLES 0x3031 +#define EGL_SAMPLES 0x3031 #define EGL_OPENGL_ES_API 0x30a0 #define EGL_OPENGL_API 0x30a2 #define EGL_NONE 0x3038 diff --git a/src/glx_context.h b/src/glx_context.h index e63684f347..12af20ef41 100644 --- a/src/glx_context.h +++ b/src/glx_context.h @@ -29,11 +29,11 @@ #define GLX_RGBA_BIT 0x00000001 #define GLX_WINDOW_BIT 0x00000001 #define GLX_DRAWABLE_TYPE 0x8010 -#define GLX_RENDER_TYPE 0x8011 +#define GLX_RENDER_TYPE 0x8011 #define GLX_RGBA_TYPE 0x8014 #define GLX_DOUBLEBUFFER 5 #define GLX_STEREO 6 -#define GLX_AUX_BUFFERS 7 +#define GLX_AUX_BUFFERS 7 #define GLX_RED_SIZE 8 #define GLX_GREEN_SIZE 9 #define GLX_BLUE_SIZE 10 @@ -42,7 +42,7 @@ #define GLX_STENCIL_SIZE 13 #define GLX_ACCUM_RED_SIZE 14 #define GLX_ACCUM_GREEN_SIZE 15 -#define GLX_ACCUM_BLUE_SIZE 16 +#define GLX_ACCUM_BLUE_SIZE 16 #define GLX_ACCUM_ALPHA_SIZE 17 #define GLX_SAMPLES 0x186a1 #define GLX_VISUAL_ID 0x800b diff --git a/src/internal.h b/src/internal.h index 618507c6d3..81f12dc1c9 100644 --- a/src/internal.h +++ b/src/internal.h @@ -84,8 +84,8 @@ typedef GLFWglproc (* _GLFWgetprocaddressfun)(const char*); typedef void (* _GLFWdestroycontextfun)(_GLFWwindow*); #define GL_VERSION 0x1f02 -#define GL_NONE 0 -#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_NONE 0 +#define GL_COLOR_BUFFER_BIT 0x00004000 #define GL_UNSIGNED_BYTE 0x1401 #define GL_EXTENSIONS 0x1f03 #define GL_NUM_EXTENSIONS 0x821d @@ -102,7 +102,7 @@ typedef void (* _GLFWdestroycontextfun)(_GLFWwindow*); #define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82fc #define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 -typedef int GLint; +typedef int GLint; typedef unsigned int GLuint; typedef unsigned int GLenum; typedef unsigned int GLbitfield; diff --git a/src/win32_platform.h b/src/win32_platform.h index 07e437764d..be1dc54491 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -212,7 +212,7 @@ typedef enum // HACK: Define macros that some dinput.h variants don't #ifndef DIDFT_OPTIONAL - #define DIDFT_OPTIONAL 0x80000000 + #define DIDFT_OPTIONAL 0x80000000 #endif // winmm.dll function pointer typedefs From 66e06b060901428f117143c6e243f4a03bd3b3f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 4 Jun 2019 16:51:31 +0200 Subject: [PATCH 032/167] Convert some declarations to C99 style (cherry picked from commit 0c6b5056196a409e6aac244c983244211abf13b1) --- src/cocoa_monitor.m | 77 +++++++++++++++++----------------------- src/cocoa_window.m | 11 +++--- src/linux_joystick.c | 51 +++++++++++++-------------- src/x11_init.c | 6 ++-- src/x11_monitor.c | 84 +++++++++++++++++--------------------------- src/x11_window.c | 5 ++- 6 files changed, 96 insertions(+), 138 deletions(-) diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index 11a31ef4a5..11ddf17d61 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -247,18 +247,16 @@ GLFWbool refreshMonitorScreen(_GLFWmonitor* monitor) // void _glfwPollMonitorsNS(void) { - uint32_t i, j, displayCount, disconnectedCount; - CGDirectDisplayID* displays; - _GLFWmonitor** disconnected = NULL; - + uint32_t displayCount; CGGetOnlineDisplayList(0, NULL, &displayCount); - displays = calloc(displayCount, sizeof(CGDirectDisplayID)); + CGDirectDisplayID* displays = calloc(displayCount, sizeof(CGDirectDisplayID)); CGGetOnlineDisplayList(displayCount, displays, &displayCount); - for (i = 0; i < _glfw.monitorCount; i++) + for (uint32_t i = 0; i < _glfw.monitorCount; i++) _glfw.monitors[i]->ns.screen = nil; - disconnectedCount = _glfw.monitorCount; + _GLFWmonitor** disconnected = NULL; + uint32_t disconnectedCount = _glfw.monitorCount; if (disconnectedCount) { disconnected = calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*)); @@ -267,19 +265,17 @@ void _glfwPollMonitorsNS(void) _glfw.monitorCount * sizeof(_GLFWmonitor*)); } - for (i = 0; i < displayCount; i++) + for (uint32_t i = 0; i < displayCount; i++) { - _GLFWmonitor* monitor; - const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]); - if (CGDisplayIsAsleep(displays[i])) continue; - for (j = 0; j < disconnectedCount; j++) + // HACK: Compare unit numbers instead of display IDs to work around + // display replacement on machines with automatic graphics + // switching + const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]); + for (uint32_t j = 0; j < disconnectedCount; j++) { - // HACK: Compare unit numbers instead of display IDs to work around - // display replacement on machines with automatic graphics - // switching if (disconnected[j] && disconnected[j]->ns.unitNumber == unitNumber) { disconnected[j] = NULL; @@ -292,7 +288,7 @@ void _glfwPollMonitorsNS(void) if (!name) name = _glfw_strdup("Unknown"); - monitor = _glfwAllocMonitor(name, size.width, size.height); + _GLFWmonitor* monitor = _glfwAllocMonitor(name, size.width, size.height); monitor->ns.displayID = displays[i]; monitor->ns.unitNumber = unitNumber; @@ -301,7 +297,7 @@ void _glfwPollMonitorsNS(void) _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST); } - for (i = 0; i < disconnectedCount; i++) + for (uint32_t i = 0; i < disconnectedCount; i++) { if (disconnected[i]) _glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0); @@ -315,24 +311,21 @@ void _glfwPollMonitorsNS(void) // void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired) { - CFArrayRef modes; - CFIndex count, i; - CVDisplayLinkRef link; - CGDisplayModeRef native = NULL; GLFWvidmode current; - const GLFWvidmode* best; - - best = _glfwChooseVideoMode(monitor, desired); _glfwPlatformGetVideoMode(monitor, ¤t); + + const GLFWvidmode* best = _glfwChooseVideoMode(monitor, desired); if (_glfwCompareVideoModes(¤t, best) == 0) return; + CVDisplayLinkRef link; CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link); - modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL); - count = CFArrayGetCount(modes); + CFArrayRef modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL); + const CFIndex count = CFArrayGetCount(modes); + CGDisplayModeRef native = NULL; - for (i = 0; i < count; i++) + for (CFIndex i = 0; i < count; i++) { CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i); if (!modeIsGood(dm)) @@ -445,26 +438,23 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, { @autoreleasepool { - CFArrayRef modes; - CFIndex found, i, j; - GLFWvidmode* result; - CVDisplayLinkRef link; - *count = 0; + CVDisplayLinkRef link; CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link); - modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL); - found = CFArrayGetCount(modes); - result = calloc(found, sizeof(GLFWvidmode)); + CFArrayRef modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL); + const CFIndex found = CFArrayGetCount(modes); + GLFWvidmode* result = calloc(found, sizeof(GLFWvidmode)); - for (i = 0; i < found; i++) + for (CFIndex i = 0; i < found; i++) { CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i); if (!modeIsGood(dm)) continue; const GLFWvidmode mode = vidmodeFromCGDisplayMode(dm, link); + CFIndex j; for (j = 0; j < *count; j++) { @@ -491,14 +481,12 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode) { @autoreleasepool { - CGDisplayModeRef displayMode; CVDisplayLinkRef link; - CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link); - displayMode = CGDisplayCopyDisplayMode(monitor->ns.displayID); - *mode = vidmodeFromCGDisplayMode(displayMode, link); - CGDisplayModeRelease(displayMode); + CGDisplayModeRef native = CGDisplayCopyDisplayMode(monitor->ns.displayID); + *mode = vidmodeFromCGDisplayMode(native, link); + CGDisplayModeRelease(native); CVDisplayLinkRelease(link); @@ -509,7 +497,7 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) { @autoreleasepool { - uint32_t i, size = CGDisplayGammaTableCapacity(monitor->ns.displayID); + uint32_t size = CGDisplayGammaTableCapacity(monitor->ns.displayID); CGGammaValue* values = calloc(size * 3, sizeof(CGGammaValue)); CGGetDisplayTransferByTable(monitor->ns.displayID, @@ -521,7 +509,7 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) _glfwAllocGammaArrays(ramp, size); - for (i = 0; i < size; i++) + for (uint32_t i = 0; i < size; i++) { ramp->red[i] = (unsigned short) (values[i] * 65535); ramp->green[i] = (unsigned short) (values[i + size] * 65535); @@ -538,10 +526,9 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) { @autoreleasepool { - int i; CGGammaValue* values = calloc(ramp->size * 3, sizeof(CGGammaValue)); - for (i = 0; i < ramp->size; i++) + for (int i = 0; i < ramp->size; i++) { values[i] = ramp->red[i] / 65535.f; values[i + ramp->size] = ramp->green[i] / 65535.f; diff --git a/src/cocoa_window.m b/src/cocoa_window.m index ce896d1f79..cdb544096d 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -612,10 +612,8 @@ - (void)keyUp:(NSEvent *)event - (void)scrollWheel:(NSEvent *)event { - double deltaX, deltaY; - - deltaX = [event scrollingDeltaX]; - deltaY = [event scrollingDeltaY]; + double deltaX = [event scrollingDeltaX]; + double deltaY = [event scrollingDeltaY]; if ([event hasPreciseScrollingDeltas]) { @@ -732,9 +730,8 @@ - (void)insertText:(id)string replacementRange:(NSRange)replacementRange else characters = (NSString*) string; - NSUInteger i, length = [characters length]; - - for (i = 0; i < length; i++) + const NSUInteger length = [characters length]; + for (NSUInteger i = 0; i < length; i++) { const unichar codepoint = [characters characterAtIndex:i]; if ((codepoint & 0xff00) == 0xf700) diff --git a/src/linux_joystick.c b/src/linux_joystick.c index 7366cfa59d..5a3b806c5e 100644 --- a/src/linux_joystick.c +++ b/src/linux_joystick.c @@ -106,9 +106,7 @@ static void handleAbsEvent(_GLFWjoystick* js, int code, int value) // static void pollAbsState(_GLFWjoystick* js) { - int code; - - for (code = 0; code < ABS_CNT; code++) + for (int code = 0; code < ABS_CNT; code++) { if (js->linjs.absMap[code] < 0) continue; @@ -128,18 +126,7 @@ static void pollAbsState(_GLFWjoystick* js) // static GLFWbool openJoystickDevice(const char* path) { - int jid, code; - char name[256] = ""; - char guid[33] = ""; - char evBits[(EV_CNT + 7) / 8] = {0}; - char keyBits[(KEY_CNT + 7) / 8] = {0}; - char absBits[(ABS_CNT + 7) / 8] = {0}; - int axisCount = 0, buttonCount = 0, hatCount = 0; - struct input_id id; - _GLFWjoystickLinux linjs = {0}; - _GLFWjoystick* js = NULL; - - for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++) + for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++) { if (!_glfw.joysticks[jid].present) continue; @@ -147,10 +134,16 @@ static GLFWbool openJoystickDevice(const char* path) return GLFW_FALSE; } + _GLFWjoystickLinux linjs = {0}; linjs.fd = open(path, O_RDONLY | O_NONBLOCK); if (linjs.fd == -1) return GLFW_FALSE; + char evBits[(EV_CNT + 7) / 8] = {0}; + char keyBits[(KEY_CNT + 7) / 8] = {0}; + char absBits[(ABS_CNT + 7) / 8] = {0}; + struct input_id id; + if (ioctl(linjs.fd, EVIOCGBIT(0, sizeof(evBits)), evBits) < 0 || ioctl(linjs.fd, EVIOCGBIT(EV_KEY, sizeof(keyBits)), keyBits) < 0 || ioctl(linjs.fd, EVIOCGBIT(EV_ABS, sizeof(absBits)), absBits) < 0 || @@ -170,9 +163,13 @@ static GLFWbool openJoystickDevice(const char* path) return GLFW_FALSE; } + char name[256] = ""; + if (ioctl(linjs.fd, EVIOCGNAME(sizeof(name)), name) < 0) strncpy(name, "Unknown", sizeof(name)); + char guid[33] = ""; + // Generate a joystick GUID that matches the SDL 2.0.5+ one if (id.vendor && id.product && id.version) { @@ -191,7 +188,9 @@ static GLFWbool openJoystickDevice(const char* path) name[8], name[9], name[10]); } - for (code = BTN_MISC; code < KEY_CNT; code++) + int axisCount = 0, buttonCount = 0, hatCount = 0; + + for (int code = BTN_MISC; code < KEY_CNT; code++) { if (!isBitSet(code, keyBits)) continue; @@ -200,7 +199,7 @@ static GLFWbool openJoystickDevice(const char* path) buttonCount++; } - for (code = 0; code < ABS_CNT; code++) + for (int code = 0; code < ABS_CNT; code++) { linjs.absMap[code] = -1; if (!isBitSet(code, absBits)) @@ -223,7 +222,8 @@ static GLFWbool openJoystickDevice(const char* path) } } - js = _glfwAllocJoystick(name, guid, axisCount, buttonCount, hatCount); + _GLFWjoystick* js = + _glfwAllocJoystick(name, guid, axisCount, buttonCount, hatCount); if (!js) { close(linjs.fd); @@ -268,8 +268,6 @@ static int compareJoysticks(const void* fp, const void* sp) // GLFWbool _glfwInitJoysticksLinux(void) { - DIR* dir; - int count = 0; const char* dirname = "/dev/input"; _glfw.linjs.inotify = inotify_init1(IN_NONBLOCK | IN_CLOEXEC); @@ -291,7 +289,9 @@ GLFWbool _glfwInitJoysticksLinux(void) return GLFW_FALSE; } - dir = opendir(dirname); + int count = 0; + + DIR* dir = opendir(dirname); if (dir) { struct dirent* entry; @@ -346,12 +346,11 @@ void _glfwTerminateJoysticksLinux(void) void _glfwDetectJoystickConnectionLinux(void) { - ssize_t offset = 0; - char buffer[16384]; - if (_glfw.linjs.inotify <= 0) return; + ssize_t offset = 0; + char buffer[16384]; const ssize_t size = read(_glfw.linjs.inotify, buffer, sizeof(buffer)); while (size > offset) @@ -371,9 +370,7 @@ void _glfwDetectJoystickConnectionLinux(void) openJoystickDevice(path); else if (e->mask & IN_DELETE) { - int jid; - - for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++) + for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++) { if (strcmp(_glfw.joysticks[jid].linjs.path, path) == 0) { diff --git a/src/x11_init.c b/src/x11_init.c index a89e7495f6..6d92bbd963 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -331,14 +331,13 @@ static void createKeyTables(void) // static GLFWbool hasUsableInputMethodStyle(void) { - unsigned int i; GLFWbool found = GLFW_FALSE; XIMStyles* styles = NULL; if (XGetIMValues(_glfw.x11.im, XNQueryInputStyle, &styles, NULL) != NULL) return GLFW_FALSE; - for (i = 0; i < styles->count_styles; i++) + for (unsigned int i = 0; i < styles->count_styles; i++) { if (styles->supported_styles[i] == (XIMPreeditNothing | XIMStatusNothing)) { @@ -357,10 +356,9 @@ static Atom getSupportedAtom(Atom* supportedAtoms, unsigned long atomCount, const char* atomName) { - unsigned long i; const Atom atom = XInternAtom(_glfw.x11.display, atomName, False); - for (i = 0; i < atomCount; i++) + for (unsigned int i = 0; i < atomCount; i++) { if (supportedAtoms[i] == atom) return atom; diff --git a/src/x11_monitor.c b/src/x11_monitor.c index db9746e8ae..cce05f98fd 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -56,9 +56,7 @@ static int calculateRefreshRate(const XRRModeInfo* mi) // static const XRRModeInfo* getModeInfo(const XRRScreenResources* sr, RRMode id) { - int i; - - for (i = 0; i < sr->nmode; i++) + for (int i = 0; i < sr->nmode; i++) { if (sr->modes[i].id == id) return sr->modes + i; @@ -104,7 +102,7 @@ void _glfwPollMonitorsX11(void) { if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken) { - int i, j, disconnectedCount, screenCount = 0; + int disconnectedCount, screenCount = 0; _GLFWmonitor** disconnected = NULL; XineramaScreenInfo* screens = NULL; XRRScreenResources* sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, @@ -124,14 +122,11 @@ void _glfwPollMonitorsX11(void) _glfw.monitorCount * sizeof(_GLFWmonitor*)); } - for (i = 0; i < sr->noutput; i++) + for (int i = 0; i < sr->noutput; i++) { - int type, widthMM, heightMM; - XRROutputInfo* oi; - XRRCrtcInfo* ci; - _GLFWmonitor* monitor; + int j, type, widthMM, heightMM; - oi = XRRGetOutputInfo(_glfw.x11.display, sr, sr->outputs[i]); + XRROutputInfo* oi = XRRGetOutputInfo(_glfw.x11.display, sr, sr->outputs[i]); if (oi->connection != RR_Connected || oi->crtc == None) { XRRFreeOutputInfo(oi); @@ -154,7 +149,7 @@ void _glfwPollMonitorsX11(void) continue; } - ci = XRRGetCrtcInfo(_glfw.x11.display, sr, oi->crtc); + XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, oi->crtc); if (ci->rotation == RR_Rotate_90 || ci->rotation == RR_Rotate_270) { widthMM = oi->mm_height; @@ -166,7 +161,7 @@ void _glfwPollMonitorsX11(void) heightMM = oi->mm_height; } - monitor = _glfwAllocMonitor(oi->name, widthMM, heightMM); + _GLFWmonitor* monitor = _glfwAllocMonitor(oi->name, widthMM, heightMM); monitor->x11.output = sr->outputs[i]; monitor->x11.crtc = oi->crtc; @@ -198,7 +193,7 @@ void _glfwPollMonitorsX11(void) if (screens) XFree(screens); - for (i = 0; i < disconnectedCount; i++) + for (int i = 0; i < disconnectedCount; i++) { if (disconnected[i]) _glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0); @@ -223,24 +218,20 @@ void _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired) { if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken) { - XRRScreenResources* sr; - XRRCrtcInfo* ci; - XRROutputInfo* oi; GLFWvidmode current; - const GLFWvidmode* best; RRMode native = None; - int i; - best = _glfwChooseVideoMode(monitor, desired); + const GLFWvidmode* best = _glfwChooseVideoMode(monitor, desired); _glfwPlatformGetVideoMode(monitor, ¤t); if (_glfwCompareVideoModes(¤t, best) == 0) return; - sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root); - ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc); - oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output); + XRRScreenResources* sr = + XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root); + XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc); + XRROutputInfo* oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output); - for (i = 0; i < oi->nmode; i++) + for (int i = 0; i < oi->nmode; i++) { const XRRModeInfo* mi = getModeInfo(sr, oi->modes[i]); if (!modeIsGood(mi)) @@ -281,14 +272,12 @@ void _glfwRestoreVideoModeX11(_GLFWmonitor* monitor) { if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken) { - XRRScreenResources* sr; - XRRCrtcInfo* ci; - if (monitor->x11.oldMode == None) return; - sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root); - ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc); + XRRScreenResources* sr = + XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root); + XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc); XRRSetCrtcConfig(_glfw.x11.display, sr, monitor->x11.crtc, @@ -319,11 +308,9 @@ void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) { if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken) { - XRRScreenResources* sr; - XRRCrtcInfo* ci; - - sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root); - ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc); + XRRScreenResources* sr = + XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root); + XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc); if (xpos) *xpos = ci->x; @@ -350,11 +337,9 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, int* xpos, int* ypos if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken) { - XRRScreenResources* sr; - XRRCrtcInfo* ci; - - sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root); - ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc); + XRRScreenResources* sr = + XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root); + XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc); areaX = ci->x; areaY = ci->y; @@ -446,24 +431,21 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count) if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken) { - int i, j; - XRRScreenResources* sr; - XRRCrtcInfo* ci; - XRROutputInfo* oi; - - sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root); - ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc); - oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output); + XRRScreenResources* sr = + XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root); + XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc); + XRROutputInfo* oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output); result = calloc(oi->nmode, sizeof(GLFWvidmode)); - for (i = 0; i < oi->nmode; i++) + for (int i = 0; i < oi->nmode; i++) { const XRRModeInfo* mi = getModeInfo(sr, oi->modes[i]); if (!modeIsGood(mi)) continue; const GLFWvidmode mode = vidmodeFromModeInfo(mi, ci); + int j; for (j = 0; j < *count; j++) { @@ -497,11 +479,9 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) { if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken) { - XRRScreenResources* sr; - XRRCrtcInfo* ci; - - sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root); - ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc); + XRRScreenResources* sr = + XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root); + XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc); *mode = vidmodeFromModeInfo(getModeInfo(sr, ci->mode), ci); diff --git a/src/x11_window.c b/src/x11_window.c index 716e116fe8..da39a39df2 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -962,7 +962,6 @@ static void handleSelectionRequest(XEvent* event) static const char* getSelectionString(Atom selection) { - size_t i; char** selectionString = NULL; const Atom targets[] = { _glfw.x11.UTF8_STRING, XA_STRING }; const size_t targetCount = sizeof(targets) / sizeof(targets[0]); @@ -983,7 +982,7 @@ static const char* getSelectionString(Atom selection) free(*selectionString); *selectionString = NULL; - for (i = 0; i < targetCount; i++) + for (size_t i = 0; i < targetCount; i++) { char* data; Atom actualType; @@ -1167,7 +1166,6 @@ static void releaseMonitor(_GLFWwindow* window) // static void processEvent(XEvent *event) { - _GLFWwindow* window = NULL; int keycode = 0; Bool filtered = False; @@ -1237,6 +1235,7 @@ static void processEvent(XEvent *event) return; } + _GLFWwindow* window = NULL; if (XFindContext(_glfw.x11.display, event->xany.window, _glfw.x11.context, From e276f6731eba3b1ac7a159cb5e962d931ab53682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 4 Jun 2019 16:52:40 +0200 Subject: [PATCH 033/167] X11: Clean up EWMH feature detection The EWMH feature detection atoms are now named and loaded the same way as other X11 atoms. Detection is now performed after all non-conditional atoms have been loaded. The EWMH detection now has hopefully more readable comments. (cherry picked from commit fad9896d38922222cdd28608cfc27c3761b3d90b) --- src/x11_init.c | 55 +++++++++++++++++++++++----------------------- src/x11_platform.h | 2 ++ 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/src/x11_init.c b/src/x11_init.c index 6d92bbd963..77f543cb6e 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -371,18 +371,11 @@ static Atom getSupportedAtom(Atom* supportedAtoms, // static void detectEWMH(void) { - Window* windowFromRoot = NULL; - Window* windowFromChild = NULL; - - // First we need a couple of atoms - const Atom supportingWmCheck = - XInternAtom(_glfw.x11.display, "_NET_SUPPORTING_WM_CHECK", False); - const Atom wmSupported = - XInternAtom(_glfw.x11.display, "_NET_SUPPORTED", False); + // First we read the _NET_SUPPORTING_WM_CHECK property on the root window - // Then we look for the _NET_SUPPORTING_WM_CHECK property of the root window + Window* windowFromRoot = NULL; if (!_glfwGetWindowPropertyX11(_glfw.x11.root, - supportingWmCheck, + _glfw.x11.NET_SUPPORTING_WM_CHECK, XA_WINDOW, (unsigned char**) &windowFromRoot)) { @@ -391,10 +384,12 @@ static void detectEWMH(void) _glfwGrabErrorHandlerX11(); - // It should be the ID of a child window (of the root) - // Then we look for the same property on the child window + // If it exists, it should be the XID of a top-level window + // Then we look for the same property on that window + + Window* windowFromChild = NULL; if (!_glfwGetWindowPropertyX11(*windowFromRoot, - supportingWmCheck, + _glfw.x11.NET_SUPPORTING_WM_CHECK, XA_WINDOW, (unsigned char**) &windowFromChild)) { @@ -404,7 +399,8 @@ static void detectEWMH(void) _glfwReleaseErrorHandlerX11(); - // It should be the ID of that same child window + // If the property exists, it should contain the XID of the window + if (*windowFromRoot != *windowFromChild) { XFree(windowFromRoot); @@ -415,19 +411,20 @@ static void detectEWMH(void) XFree(windowFromRoot); XFree(windowFromChild); - // We are now fairly sure that an EWMH-compliant window manager is running - - Atom* supportedAtoms; - unsigned long atomCount; + // We are now fairly sure that an EWMH-compliant WM is currently running + // We can now start querying the WM about what features it supports by + // looking in the _NET_SUPPORTED property on the root window + // It should contain a list of supported EWMH protocol and state atoms - // Now we need to check the _NET_SUPPORTED property of the root window - // It should be a list of supported WM protocol and state atoms - atomCount = _glfwGetWindowPropertyX11(_glfw.x11.root, - wmSupported, - XA_ATOM, - (unsigned char**) &supportedAtoms); + Atom* supportedAtoms = NULL; + const unsigned long atomCount = + _glfwGetWindowPropertyX11(_glfw.x11.root, + _glfw.x11.NET_SUPPORTED, + XA_ATOM, + (unsigned char**) &supportedAtoms); // See which of the atoms we support that are supported by the WM + _glfw.x11.NET_WM_STATE = getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE"); _glfw.x11.NET_WM_STATE_ABOVE = @@ -707,9 +704,6 @@ static GLFWbool initExtensions(void) // the keyboard mapping. createKeyTables(); - // Detect whether an EWMH-conformant window manager is running - detectEWMH(); - // String format atoms _glfw.x11.NULL_ = XInternAtom(_glfw.x11.display, "NULL", False); _glfw.x11.UTF8_STRING = XInternAtom(_glfw.x11.display, "UTF8_STRING", False); @@ -753,6 +747,10 @@ static GLFWbool initExtensions(void) XInternAtom(_glfw.x11.display, "WM_STATE", False); _glfw.x11.WM_DELETE_WINDOW = XInternAtom(_glfw.x11.display, "WM_DELETE_WINDOW", False); + _glfw.x11.NET_SUPPORTED = + XInternAtom(_glfw.x11.display, "_NET_SUPPORTED", False); + _glfw.x11.NET_SUPPORTING_WM_CHECK = + XInternAtom(_glfw.x11.display, "_NET_SUPPORTING_WM_CHECK", False); _glfw.x11.NET_WM_ICON = XInternAtom(_glfw.x11.display, "_NET_WM_ICON", False); _glfw.x11.NET_WM_PING = @@ -777,6 +775,9 @@ static GLFWbool initExtensions(void) _glfw.x11.NET_WM_CM_Sx = XInternAtom(_glfw.x11.display, name, False); } + // Detect whether an EWMH-conformant window manager is running + detectEWMH(); + return GLFW_TRUE; } diff --git a/src/x11_platform.h b/src/x11_platform.h index 3b2b2b22c4..9fffa78ea0 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -239,6 +239,8 @@ typedef struct _GLFWlibraryX11 _GLFWwindow* disabledCursorWindow; // Window manager atoms + Atom NET_SUPPORTED; + Atom NET_SUPPORTING_WM_CHECK; Atom WM_PROTOCOLS; Atom WM_STATE; Atom WM_DELETE_WINDOW; From 1e1265334838a59ed41a1529a9ab13f12b066a54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 4 Jun 2019 16:59:04 +0200 Subject: [PATCH 034/167] X11: Let the language initialize XEvent structs (cherry picked from commit 1f508530f0cda2db78404a82fba1b956372e67aa) --- src/x11_window.c | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/src/x11_window.c b/src/x11_window.c index da39a39df2..dc8c1e9324 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -215,10 +215,7 @@ static int translateKey(int scancode) static void sendEventToWM(_GLFWwindow* window, Atom type, long a, long b, long c, long d, long e) { - XEvent event; - memset(&event, 0, sizeof(event)); - - event.type = ClientMessage; + XEvent event = { ClientMessage }; event.xclient.window = window->x11.handle; event.xclient.format = 32; // Data is 32-bit longs event.xclient.message_type = type; @@ -946,11 +943,8 @@ static void handleSelectionRequest(XEvent* event) { const XSelectionRequestEvent* request = &event->xselectionrequest; - XEvent reply; - memset(&reply, 0, sizeof(reply)); - + XEvent reply = { SelectionNotify }; reply.xselection.property = writeTargetToProperty(request); - reply.xselection.type = SelectionNotify; reply.xselection.display = request->display; reply.xselection.requestor = request->requestor; reply.xselection.selection = request->selection; @@ -1647,10 +1641,7 @@ static void processEvent(XEvent *event) } else if (_glfw.x11.xdnd.version >= 2) { - XEvent reply; - memset(&reply, 0, sizeof(reply)); - - reply.type = ClientMessage; + XEvent reply = { ClientMessage }; reply.xclient.window = _glfw.x11.xdnd.source; reply.xclient.message_type = _glfw.x11.XdndFinished; reply.xclient.format = 32; @@ -1683,10 +1674,7 @@ static void processEvent(XEvent *event) _glfwInputCursorPos(window, xpos, ypos); - XEvent reply; - memset(&reply, 0, sizeof(reply)); - - reply.type = ClientMessage; + XEvent reply = { ClientMessage }; reply.xclient.window = _glfw.x11.xdnd.source; reply.xclient.message_type = _glfw.x11.XdndStatus; reply.xclient.format = 32; @@ -1739,10 +1727,7 @@ static void processEvent(XEvent *event) if (_glfw.x11.xdnd.version >= 2) { - XEvent reply; - memset(&reply, 0, sizeof(reply)); - - reply.type = ClientMessage; + XEvent reply = { ClientMessage }; reply.xclient.window = _glfw.x11.xdnd.source; reply.xclient.message_type = _glfw.x11.XdndFinished; reply.xclient.format = 32; @@ -2738,10 +2723,7 @@ void _glfwPlatformWaitEventsTimeout(double timeout) void _glfwPlatformPostEmptyEvent(void) { - XEvent event; - - memset(&event, 0, sizeof(event)); - event.type = ClientMessage; + XEvent event = { ClientMessage }; event.xclient.window = _glfw.x11.helperWindowHandle; event.xclient.format = 32; // Data is 32-bit longs event.xclient.message_type = _glfw.x11.NULL_; From 8542f8dd8434881644b3e2ee55864c9aad07b132 Mon Sep 17 00:00:00 2001 From: "A. Tombs" Date: Tue, 28 May 2019 01:24:18 +0100 Subject: [PATCH 035/167] Win32: Cleanup pointer test in win32_window.c MSVC 2019 complains that the code at line 1744 (`GetMonitorInfo(window->monitor->win32.handle, &mi);`) can potentially dereference a null pointer. The compiler is wrong in this case (it has not spotted that `monitor` and `window->monitor` must be equal), but I think it makes sense for our non-NULL test to be on the variable we actually use rather than the one it was set from. Related to #1491. (cherry picked from commit 1d6215726807e73fd21da9a4a09c28aab3111879) --- src/win32_window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win32_window.c b/src/win32_window.c index b7e679e9c4..1f58acb6fa 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1725,7 +1725,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, _glfwInputWindowMonitor(window, monitor); - if (monitor) + if (window->monitor) { MONITORINFO mi = { sizeof(mi) }; UINT flags = SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOCOPYBITS; From eb466a0e0bca92cd8697be54041418e6f8516485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 6 Jun 2019 16:02:41 +0200 Subject: [PATCH 036/167] Cocoa: Cleanup This makes the Cocoa _glfwPlatformSetWindowMonitor consistent with its X11 and Win32 counterparts. (cherry picked from commit 3262c29440428348e33b746c4783d783b2825228) --- 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 cdb544096d..f9383b3edd 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1221,7 +1221,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, // HACK: Changing the style mask can cause the first responder to be cleared [window->ns.object makeFirstResponder:window->ns.view]; - if (monitor) + if (window->monitor) { [window->ns.object setLevel:NSMainMenuWindowLevel + 1]; [window->ns.object setHasShadow:NO]; From 898b7f9c54aaee9f61f2d459c893afd73372ac84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 4 Jun 2019 18:50:07 +0200 Subject: [PATCH 037/167] Remove unused function in tearing test (cherry picked from commit 3a5e99e59a74aae9cb74dbd1170374aec9ecc6a2) --- tests/tearing.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/tearing.c b/tests/tearing.c index 17a3f0e406..17601219b4 100644 --- a/tests/tearing.c +++ b/tests/tearing.c @@ -69,14 +69,6 @@ static int swap_tear; static int swap_interval; static double frame_rate; -static void usage(void) -{ - printf("Usage: tearing [-f] [-h]\n"); - printf("Options:\n"); - printf(" -f use full screen\n"); - printf(" -h show this help\n"); -} - static void update_window_title(GLFWwindow* window) { char title[256]; From 633ba53f2c5202e8193d5599c5170d1ff0952406 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Sat, 8 Jun 2019 00:06:22 +0200 Subject: [PATCH 038/167] Fix typo Closes #1513. (cherry picked from commit e463e85bbab1bd1c805f9a7d733ccd9caa5fa45f) --- src/wl_monitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wl_monitor.c b/src/wl_monitor.c index db49271116..48b25b9ff6 100644 --- a/src/wl_monitor.c +++ b/src/wl_monitor.c @@ -200,7 +200,7 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) { _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Gamma ramp access it not available"); + "Wayland: Gamma ramp access is not available"); return GLFW_FALSE; } From 84fa724456cd2d66ee4356b6a349fb2fb28205f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 11 Jul 2019 00:36:34 +0200 Subject: [PATCH 039/167] X11: Fix focus events not being filtered The filter condition had ended up below the action. (cherry picked from commit c6b95e3b07b9c20d9adae2ddebf69706540180de) --- src/x11_window.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/x11_window.c b/src/x11_window.c index dc8c1e9324..2eeaf572b1 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -1746,9 +1746,6 @@ static void processEvent(XEvent *event) case FocusIn: { - if (window->cursorMode == GLFW_CURSOR_DISABLED) - disableCursor(window); - if (event->xfocus.mode == NotifyGrab || event->xfocus.mode == NotifyUngrab) { @@ -1757,6 +1754,9 @@ static void processEvent(XEvent *event) return; } + if (window->cursorMode == GLFW_CURSOR_DISABLED) + disableCursor(window); + if (window->x11.ic) XSetICFocus(window->x11.ic); @@ -1766,9 +1766,6 @@ static void processEvent(XEvent *event) case FocusOut: { - if (window->cursorMode == GLFW_CURSOR_DISABLED) - enableCursor(window); - if (event->xfocus.mode == NotifyGrab || event->xfocus.mode == NotifyUngrab) { @@ -1777,6 +1774,9 @@ static void processEvent(XEvent *event) return; } + if (window->cursorMode == GLFW_CURSOR_DISABLED) + enableCursor(window); + if (window->x11.ic) XUnsetICFocus(window->x11.ic); From b3eb6dd38b5390f3d5a5bd00b66cec1bdb56e49d Mon Sep 17 00:00:00 2001 From: Denis Bernard Date: Thu, 30 May 2019 00:37:26 +0200 Subject: [PATCH 040/167] X11: Query and keep track of Xkb group index For users with multiple keyboard layouts configured, glfwGetKeyName works fine only with the primary layout. Switching layouts results in changing the group index. This commit querries the current group index when initializing keyboard input and keeps track of any change to it. As a result the scancode -> keyname mapping may change while the program is running (needs to be documented). Fixes #1462. Closes #1528. (cherry picked from commit 36f90800d8d490b27d4dc2109c07a95a12007327) --- src/x11_init.c | 12 ++++++++++-- src/x11_platform.h | 15 ++++++++------- src/x11_window.c | 11 ++++++++++- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/x11_init.c b/src/x11_init.c index 77f543cb6e..f00080d644 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -54,7 +54,7 @@ static int translateKeyCode(int scancode) // Note: This way we always force "NumLock = ON", which is intentional // since the returned key code should correspond to a physical // location. - keySym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, 0, 1); + keySym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, _glfw.x11.xkb.group, 1); switch (keySym) { case XK_KP_0: return GLFW_KEY_KP_0; @@ -76,7 +76,7 @@ static int translateKeyCode(int scancode) // Now try primary keysym for function keys (non-printable keys) // These should not depend on the current keyboard layout - keySym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, 0, 0); + keySym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, _glfw.x11.xkb.group, 0); } else { @@ -659,6 +659,14 @@ static GLFWbool initExtensions(void) if (supported) _glfw.x11.xkb.detectable = GLFW_TRUE; } + + _glfw.x11.xkb.group = 0; + XkbStateRec state; + if (XkbGetState(_glfw.x11.display, XkbUseCoreKbd, &state) == Success) + { + XkbSelectEventDetails(_glfw.x11.display, XkbUseCoreKbd, XkbStateNotify, XkbAllStateComponentsMask, XkbGroupStateMask); + _glfw.x11.xkb.group = (unsigned int)state.group; + } } #if defined(__CYGWIN__) diff --git a/src/x11_platform.h b/src/x11_platform.h index 9fffa78ea0..5b3652419a 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -323,13 +323,14 @@ typedef struct _GLFWlibraryX11 } randr; struct { - GLFWbool available; - GLFWbool detectable; - int majorOpcode; - int eventBase; - int errorBase; - int major; - int minor; + GLFWbool available; + GLFWbool detectable; + int majorOpcode; + int eventBase; + int errorBase; + int major; + int minor; + unsigned int group; } xkb; struct { diff --git a/src/x11_window.c b/src/x11_window.c index 2eeaf572b1..47e7a40e54 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -1180,6 +1180,15 @@ static void processEvent(XEvent *event) } } + if (_glfw.x11.xkb.available && event->type == _glfw.x11.xkb.eventBase) + { + if (((XkbEvent *)event)->any.xkb_type == XkbStateNotify && + ((XkbEvent *)event)->state.changed & XkbGroupStateMask) + { + _glfw.x11.xkb.group = ((XkbEvent *)event)->state.group; + } + } + if (event->type == GenericEvent) { if (_glfw.x11.xi.available) @@ -2780,7 +2789,7 @@ const char* _glfwPlatformGetScancodeName(int scancode) if (!_glfw.x11.xkb.available) return NULL; - const KeySym keysym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, 0, 0); + const KeySym keysym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, _glfw.x11.xkb.group, 0); if (keysym == NoSymbol) return NULL; From ff2c00091dd6249178721ff0e2fbd9272b324e25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 11 Jul 2019 19:06:06 +0200 Subject: [PATCH 041/167] Cleanup Related to #1528. (cherry picked from commit d232bcfcdde2435110fcce9d6027db726e57646f) --- src/x11_window.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/x11_window.c b/src/x11_window.c index 47e7a40e54..7fd09b5474 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -1180,12 +1180,15 @@ static void processEvent(XEvent *event) } } - if (_glfw.x11.xkb.available && event->type == _glfw.x11.xkb.eventBase) + if (_glfw.x11.xkb.available) { - if (((XkbEvent *)event)->any.xkb_type == XkbStateNotify && - ((XkbEvent *)event)->state.changed & XkbGroupStateMask) + if (event->type == _glfw.x11.xkb.eventBase + XkbEventCode) { - _glfw.x11.xkb.group = ((XkbEvent *)event)->state.group; + if (((XkbEvent*) event)->any.xkb_type == XkbStateNotify && + (((XkbEvent*) event)->state.changed & XkbGroupStateMask)) + { + _glfw.x11.xkb.group = ((XkbEvent*) event)->state.group; + } } } @@ -2789,7 +2792,8 @@ const char* _glfwPlatformGetScancodeName(int scancode) if (!_glfw.x11.xkb.available) return NULL; - const KeySym keysym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, _glfw.x11.xkb.group, 0); + const KeySym keysym = XkbKeycodeToKeysym(_glfw.x11.display, + scancode, _glfw.x11.xkb.group, 0); if (keysym == NoSymbol) return NULL; From 95e7ad7e5bbefdc59a99a0b036d5751382f04cb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 11 Jul 2019 20:21:04 +0200 Subject: [PATCH 042/167] Update changelog Related to #1528. (cherry picked from commit 5bea122211a4c537e461f7f473a8d9afbc98af6f) --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a9e9b8e6d2..6e6d6f478b 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,8 @@ information on what to include when reporting a bug. - Bugfix: The CMake config-file package used an absolute path and was not relocatable (#1470) - [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) ## Contact From 248e827673e84e1ee9fe45f289b394b9ba89093b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 12 Jul 2019 14:23:12 +0200 Subject: [PATCH 043/167] Win32: Fix symbol redefinition warnings When both GLFW_INCLUDE_VULKAN and VK_USE_PLATFORM_WIN32_KHR were defined, the GLFW header would define replacement versions of APIENTRY and WINGDIAPI /before/ including the Vulkan header, which would include windows.h, which (justifiably) defines APIENTRY and WINGDIAPI blindly. Fixes #1524. (cherry picked from commit 773f4495f005004ea17fbc4a96b6b1ce758e79d6) --- README.md | 2 ++ include/GLFW/glfw3.h | 34 +++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 6e6d6f478b..b32b473ffb 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,8 @@ information on what to include when reporting a bug. - Bugfix: The CMake config-file package used an absolute path and was not relocatable (#1470) + - [Win32] Bugfix: `GLFW_INCLUDE_VULKAN` plus `VK_USE_PLATFORM_WIN32_KHR` caused + symbol redefinition (#1524) - [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/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index c95b80db18..28a38e33d5 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -96,6 +96,25 @@ extern "C" { #define _WIN32 #endif /* _WIN32 */ +/* Include because most Windows GLU headers need wchar_t and + * the macOS OpenGL header blocks the definition of ptrdiff_t by glext.h. + * Include it unconditionally to avoid surprising side-effects. + */ +#include + +/* Include because it is needed by Vulkan and related functions. + * Include it unconditionally to avoid surprising side-effects. + */ +#include + +#if defined(GLFW_INCLUDE_VULKAN) + #include +#endif /* Vulkan header */ + +/* The Vulkan header may have indirectly included windows.h (because of + * VK_USE_PLATFORM_WIN32_KHR) so we offer our replacement symbols after it. + */ + /* It is customary to use APIENTRY for OpenGL function pointer declarations on * all platforms. Additionally, the Windows OpenGL header needs APIENTRY. */ @@ -122,17 +141,6 @@ extern "C" { #define GLFW_CALLBACK_DEFINED #endif /* CALLBACK */ -/* Include because most Windows GLU headers need wchar_t and - * the macOS OpenGL header blocks the definition of ptrdiff_t by glext.h. - * Include it unconditionally to avoid surprising side-effects. - */ -#include - -/* Include because it is needed by Vulkan and related functions. - * Include it unconditionally to avoid surprising side-effects. - */ -#include - /* Include the chosen OpenGL or OpenGL ES headers. */ #if defined(GLFW_INCLUDE_ES1) @@ -211,10 +219,6 @@ extern "C" { #endif /* OpenGL and OpenGL ES headers */ -#if defined(GLFW_INCLUDE_VULKAN) - #include -#endif /* Vulkan header */ - #if defined(GLFW_DLL) && defined(_GLFW_BUILD_DLL) /* GLFW_DLL must be defined by applications that are linking against the DLL * version of the GLFW library. _GLFW_BUILD_DLL is defined by the GLFW From 75b415c5b8e2d45c54f02f6e243427fb802fcebb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 12 Jul 2019 14:33:05 +0200 Subject: [PATCH 044/167] Cleanup (cherry picked from commit 62b7fe831179428c3fa1d7939d48562772ee5647) --- 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 28a38e33d5..cbc18259d1 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -118,8 +118,8 @@ extern "C" { /* It is customary to use APIENTRY for OpenGL function pointer declarations on * all platforms. Additionally, the Windows OpenGL header needs APIENTRY. */ -#ifndef APIENTRY - #ifdef _WIN32 +#if !defined(APIENTRY) + #if defined(_WIN32) #define APIENTRY __stdcall #else #define APIENTRY From 452a648abb8b20184a5651420cbb2f6fe45dc78d Mon Sep 17 00:00:00 2001 From: Lukas Zanner Date: Fri, 14 Jun 2019 12:53:57 +0200 Subject: [PATCH 045/167] Fix typo in glfwGetRequiredInstanceExtensions docs Closes #1500. (cherry picked from commit 84b13113ed5e16aa29a0f5b4a0e95487081184a3) --- include/GLFW/glfw3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index cbc18259d1..f631eb30c6 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -5650,7 +5650,7 @@ GLFWAPI int glfwVulkanSupported(void); * * This function returns an array of names of Vulkan instance extensions required * by GLFW for creating Vulkan surfaces for GLFW windows. If successful, the - * list will always contains `VK_KHR_surface`, so if you don't require any + * list will always contain `VK_KHR_surface`, so if you don't require any * additional extensions you can pass this list directly to the * `VkInstanceCreateInfo` struct. * From ce7cd3e28882ed8292cf1274a936d4cfefd9b54e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 12 Jul 2019 16:38:06 +0200 Subject: [PATCH 046/167] Add credits (cherry picked from commit 7bd0af3089e39de0dbed11e42463ecf84e5df769) --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b32b473ffb..83bb17a251 100644 --- a/README.md +++ b/README.md @@ -227,6 +227,7 @@ skills. - Anders Lindqvist - Eyal Lotem - Aaron Loucks + - Luflosi - Tristam MacDonald - Hans Mackowiak - Дмитри Малышев @@ -318,6 +319,7 @@ skills. - Jay Weisskopf - Frank Wille - Ryogo Yoshimura + - Lukas Zanner - Andrey Zholos - Santi Zupancic - Jonas Ådahl From 9fc035a562b1bd2ce962239108c65afad32f5e74 Mon Sep 17 00:00:00 2001 From: Leon Linhart Date: Mon, 27 May 2019 22:42:12 +0200 Subject: [PATCH 047/167] Win32: Fix cursor enter/position event order This fixes the cursor enter event being emitted after the first cursor position event on Windows. Closes #1490. (cherry picked from commit 4f0b8b0ddaada126cd257f2e5b06450e932ad5f6) --- README.md | 2 ++ src/win32_window.c | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 83bb17a251..7a34d69950 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,7 @@ information on what to include when reporting a bug. relocatable (#1470) - [Win32] Bugfix: `GLFW_INCLUDE_VULKAN` plus `VK_USE_PLATFORM_WIN32_KHR` caused symbol redefinition (#1524) + - [Win32] Bugfix: Invoke cursor enter callback before cursor position callback - [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) @@ -225,6 +226,7 @@ skills. - Glenn Lewis - Shane Liesegang - Anders Lindqvist + - Leon Linhart - Eyal Lotem - Aaron Loucks - Luflosi diff --git a/src/win32_window.c b/src/win32_window.c index 1f58acb6fa..5b9671d8b5 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -828,6 +828,19 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, const int x = GET_X_LPARAM(lParam); const int y = GET_Y_LPARAM(lParam); + if (!window->win32.cursorTracked) + { + TRACKMOUSEEVENT tme; + ZeroMemory(&tme, sizeof(tme)); + tme.cbSize = sizeof(tme); + tme.dwFlags = TME_LEAVE; + tme.hwndTrack = window->win32.handle; + TrackMouseEvent(&tme); + + window->win32.cursorTracked = GLFW_TRUE; + _glfwInputCursorEnter(window, GLFW_TRUE); + } + if (window->cursorMode == GLFW_CURSOR_DISABLED) { const int dx = x - window->win32.lastCursorPosX; @@ -848,19 +861,6 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, window->win32.lastCursorPosX = x; window->win32.lastCursorPosY = y; - if (!window->win32.cursorTracked) - { - TRACKMOUSEEVENT tme; - ZeroMemory(&tme, sizeof(tme)); - tme.cbSize = sizeof(tme); - tme.dwFlags = TME_LEAVE; - tme.hwndTrack = window->win32.handle; - TrackMouseEvent(&tme); - - window->win32.cursorTracked = GLFW_TRUE; - _glfwInputCursorEnter(window, GLFW_TRUE); - } - return 0; } From 8e923e592d548d60647bbf4db43950b5a5d89305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 12 Jul 2019 19:04:16 +0200 Subject: [PATCH 048/167] Documentation work [ci skip] (cherry picked from commit a4d910b4a72f3a85d7be42ea2f91162cdfd28375) --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7a34d69950..431711cf61 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,8 @@ information on what to include when reporting a bug. relocatable (#1470) - [Win32] Bugfix: `GLFW_INCLUDE_VULKAN` plus `VK_USE_PLATFORM_WIN32_KHR` caused symbol redefinition (#1524) - - [Win32] Bugfix: Invoke cursor enter callback before cursor position callback + - [Win32] Bugfix: The cursor position event was emitted before its cursor enter + event (#1490) - [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) From cfd93597ecda7d7e7fceb27926604f454ac5a9f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 16 Jul 2019 23:12:20 +0200 Subject: [PATCH 049/167] Cocoa: Fix file-local function not declared static (cherry picked from commit 062a1c22b5e346b63fe8dfc09b63f1a57991461a) --- src/cocoa_monitor.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index 11ddf17d61..112f23b0c4 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -215,7 +215,7 @@ static void endFadeReservation(CGDisplayFadeReservationToken token) // Finds and caches the NSScreen corresponding to the specified monitor // -GLFWbool refreshMonitorScreen(_GLFWmonitor* monitor) +static GLFWbool refreshMonitorScreen(_GLFWmonitor* monitor) { if (monitor->ns.screen) return GLFW_TRUE; From 1daf9de40f926963dbdfee49e06f2a0633348beb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 16 Jul 2019 23:14:16 +0200 Subject: [PATCH 050/167] Cocoa: Fix internal symbol hiding for dylib The default symbol visibility was not set to hidden on macOS. (cherry picked from commit b430bc4935d8ca8ff459313dbd87ecc2b266aee1) --- src/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1928670e14..4ff82d7b21 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -140,7 +140,9 @@ if (BUILD_SHARED_LIBS) set_target_properties(glfw PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_LIBDIR}") - elseif (UNIX) + endif() + + if (UNIX) # Hide symbols not explicitly tagged for export from the shared library target_compile_options(glfw PRIVATE "-fvisibility=hidden") endif() From d25e19b7900077d25a04155d13ce439db641ee8d Mon Sep 17 00:00:00 2001 From: Ave Milia Date: Mon, 8 Jul 2019 14:54:08 +0200 Subject: [PATCH 051/167] CMake: remove -DGLFW_DLL on non-Windows targets When using GLFW with CMake and installed GLFW binaries, `-DGLFW_DLL` is passed on Linux, which should not happen. Closes #1530. (cherry picked from commit d7fb01750ece465cfaae0493dfe3003da1e5f500) --- src/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4ff82d7b21..80ee96913f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -134,6 +134,8 @@ if (BUILD_SHARED_LIBS) # Add a suffix to the import library to avoid naming conflicts set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.lib") endif() + + target_compile_definitions(glfw INTERFACE GLFW_DLL) elseif (APPLE) # Add -fno-common to work around a bug in Apple's GCC target_compile_options(glfw PRIVATE "-fno-common") @@ -147,7 +149,6 @@ if (BUILD_SHARED_LIBS) target_compile_options(glfw PRIVATE "-fvisibility=hidden") endif() - target_compile_definitions(glfw INTERFACE GLFW_DLL) target_link_libraries(glfw PRIVATE ${glfw_LIBRARIES}) else() target_link_libraries(glfw INTERFACE ${glfw_LIBRARIES}) From b1309dd42a72c8f7cd58a6f75329c4328679aed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 16 Jul 2019 14:35:35 +0200 Subject: [PATCH 052/167] Add credit (cherry picked from commit b0692d73ddb66461549cda0a009f867dab9de0fd) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 431711cf61..604a1be449 100644 --- a/README.md +++ b/README.md @@ -243,6 +243,7 @@ skills. - Jonathan Mercier - Marcel Metz - Liam Middlebrook + - Ave Milia - Jonathan Miller - Kenneth Miller - Bruce Mitchener From adcd306fbd7ce9def12ab84b080e2e1acdb21273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 22 Jul 2019 17:42:00 +0200 Subject: [PATCH 053/167] Fix conflict with DEBUG macro defined by Bazel The Bazel build system may define DEBUG when compiling on macOS, which caused the glfwinfo test program to fail to build. Fixes #1537. (cherry picked from commit 6abad2efd29adfe41b5ef2e73b1650e45b1725e1) --- tests/glfwinfo.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/glfwinfo.c b/tests/glfwinfo.c index 5991652dbb..074bcbd6f1 100644 --- a/tests/glfwinfo.c +++ b/tests/glfwinfo.c @@ -359,7 +359,8 @@ int main(int argc, char** argv) GLenum error; GLFWwindow* window; - enum { CLIENT, CONTEXT, BEHAVIOR, DEBUG, FORWARD, HELP, EXTENSIONS, LAYERS, + enum { CLIENT, CONTEXT, BEHAVIOR, DEBUG_CONTEXT, FORWARD, HELP, + EXTENSIONS, LAYERS, MAJOR, MINOR, PROFILE, ROBUSTNESS, VERSION, REDBITS, GREENBITS, BLUEBITS, ALPHABITS, DEPTHBITS, STENCILBITS, ACCUMREDBITS, ACCUMGREENBITS, ACCUMBLUEBITS, ACCUMALPHABITS, @@ -370,7 +371,7 @@ int main(int argc, char** argv) { "behavior", 1, NULL, BEHAVIOR }, { "client-api", 1, NULL, CLIENT }, { "context-api", 1, NULL, CONTEXT }, - { "debug", 0, NULL, DEBUG }, + { "debug", 0, NULL, DEBUG_CONTEXT }, { "forward", 0, NULL, FORWARD }, { "help", 0, NULL, HELP }, { "list-extensions", 0, NULL, EXTENSIONS }, @@ -461,7 +462,7 @@ int main(int argc, char** argv) } break; case 'd': - case DEBUG: + case DEBUG_CONTEXT: glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE); break; case 'f': From 1e8dc836a04c360079dd8500b977411c5d25c825 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 25 Jul 2019 19:09:42 +0200 Subject: [PATCH 054/167] Fix Vulkan triangle test segfault on resize The command buffer handle was not reset after being freed on window resize, leading to a segfault when the stale handle was used. (cherry picked from commit 65748fb8f316384cda39583a489c39ae80124305) --- README.md | 1 + tests/triangle-vulkan.c | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index 604a1be449..e71cbf5261 100644 --- a/README.md +++ b/README.md @@ -197,6 +197,7 @@ skills. - Mário Freitas - GeO4d - Marcus Geelnard + - Charles Giessen - Stephen Gowen - Kovid Goyal - Eloi Marín Gratacós diff --git a/tests/triangle-vulkan.c b/tests/triangle-vulkan.c index 7cdb8f78e0..8600ced7ce 100644 --- a/tests/triangle-vulkan.c +++ b/tests/triangle-vulkan.c @@ -2118,6 +2118,7 @@ static void demo_cleanup(struct demo *demo) { if (demo->setup_cmd) { vkFreeCommandBuffers(demo->device, demo->cmd_pool, 1, &demo->setup_cmd); + demo->setup_cmd = VK_NULL_HANDLE; } vkFreeCommandBuffers(demo->device, demo->cmd_pool, 1, &demo->draw_cmd); vkDestroyCommandPool(demo->device, demo->cmd_pool, NULL); From 116f4c831d7e83eb3e6b4b5267f6857218dd2965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 25 Jul 2019 20:29:30 +0200 Subject: [PATCH 055/167] Put fix in correct position This fixes a mismerge by @elmindreda in 65748fb8f316384cda39583a489c39ae80124305. (cherry picked from commit efda4afb495be4779c152a96f7b3f52c54cbff32) --- tests/triangle-vulkan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/triangle-vulkan.c b/tests/triangle-vulkan.c index 8600ced7ce..33442968c2 100644 --- a/tests/triangle-vulkan.c +++ b/tests/triangle-vulkan.c @@ -2118,7 +2118,6 @@ static void demo_cleanup(struct demo *demo) { if (demo->setup_cmd) { vkFreeCommandBuffers(demo->device, demo->cmd_pool, 1, &demo->setup_cmd); - demo->setup_cmd = VK_NULL_HANDLE; } vkFreeCommandBuffers(demo->device, demo->cmd_pool, 1, &demo->draw_cmd); vkDestroyCommandPool(demo->device, demo->cmd_pool, NULL); @@ -2178,6 +2177,7 @@ static void demo_resize(struct demo *demo) { if (demo->setup_cmd) { vkFreeCommandBuffers(demo->device, demo->cmd_pool, 1, &demo->setup_cmd); + demo->setup_cmd = VK_NULL_HANDLE; } vkFreeCommandBuffers(demo->device, demo->cmd_pool, 1, &demo->draw_cmd); vkDestroyCommandPool(demo->device, demo->cmd_pool, NULL); From 30e67357bed12b6a30df1654466654ea35b8cafb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 13 Aug 2019 15:18:02 +0200 Subject: [PATCH 056/167] Win32: Fix GLFW_MAXIMIZED not maximizing window The window rect adjustment for content scale broke the initial, correct maximization performed when creating the window with WS_MAXIMIZE. This switches to updating the restored rect instead of the current rect. Fixes #1499. Closes #1503. (cherry picked from commit 711b9694a133ef338482ae75ada724e3a9915d91) --- README.md | 2 ++ src/win32_window.c | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e71cbf5261..bbe9948026 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,8 @@ information on what to include when reporting a bug. symbol redefinition (#1524) - [Win32] Bugfix: The cursor position event was emitted before its cursor enter event (#1490) + - [Win32] Bugfix: The window hint `GLFW_MAXIMIZED` did not move or resize the + window (#1499) - [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/win32_window.c b/src/win32_window.c index 5b9671d8b5..7090c981b6 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1281,6 +1281,7 @@ static int createNativeWindow(_GLFWwindow* window, if (!window->monitor) { RECT rect = { 0, 0, wndconfig->width, wndconfig->height }; + WINDOWPLACEMENT wp = { sizeof(wp) }; if (wndconfig->scaleToMonitor) { @@ -1301,10 +1302,11 @@ static int createNativeWindow(_GLFWwindow* window, else AdjustWindowRectEx(&rect, style, FALSE, exStyle); - SetWindowPos(window->win32.handle, NULL, - rect.left, rect.top, - rect.right - rect.left, rect.bottom - rect.top, - SWP_NOACTIVATE | SWP_NOZORDER); + // Only update the restored window rect as the window may be maximized + GetWindowPlacement(window->win32.handle, &wp); + wp.rcNormalPosition = rect; + wp.showCmd = SW_HIDE; + SetWindowPlacement(window->win32.handle, &wp); } DragAcceptFiles(window->win32.handle, TRUE); From 2d3f388158131f9ac421117c831fa8ac699263b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 14 Aug 2019 19:18:29 +0200 Subject: [PATCH 057/167] Win32: Fix initial state of maximized state cache (cherry picked from commit 2c7ef5b480d7780455deed43aedc177b9fe3ac61) --- src/win32_window.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/win32_window.c b/src/win32_window.c index 7090c981b6..e7fe3a0a87 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1228,6 +1228,7 @@ static int createNativeWindow(_GLFWwindow* window, xpos = CW_USEDEFAULT; ypos = CW_USEDEFAULT; + window->win32.maximized = wndconfig->maximized; if (wndconfig->maximized) style |= WS_MAXIMIZE; From c0d1249ca26ead8af0f09a7dc74e00355ac7e6fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 15 Aug 2019 16:59:54 +0200 Subject: [PATCH 058/167] Fix license copyright year and formatting (cherry picked from commit f764836e58ec47b7e105687630c75f8161ffcaa8) --- LICENSE.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LICENSE.md b/LICENSE.md index acdac20b93..7494a3f689 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,5 +1,6 @@ Copyright (c) 2002-2006 Marcus Geelnard -Copyright (c) 2006-2016 Camilla Löwy + +Copyright (c) 2006-2019 Camilla Löwy This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages From 2032a8f0dcd6337e887e81834967969978eba305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 15 Aug 2019 17:25:36 +0200 Subject: [PATCH 059/167] Clarify comment (cherry picked from commit 4cc5d2e62304432ee395b8d09f062c140810f340) --- src/win32_window.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/win32_window.c b/src/win32_window.c index e7fe3a0a87..f7b9f24858 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1276,9 +1276,9 @@ static int createNativeWindow(_GLFWwindow* window, window->win32.scaleToMonitor = wndconfig->scaleToMonitor; - // Adjust window size to account for DPI scaling of the window frame and - // optionally DPI scaling of the content area - // This cannot be done until we know what monitor it was placed on + // Adjust window rect to account for DPI scaling of the window frame and + // (if enabled) DPI scaling of the content area + // This cannot be done until we know what monitor the window was placed on if (!window->monitor) { RECT rect = { 0, 0, wndconfig->width, wndconfig->height }; From 79f4ec6822742e587a7c295aff2bee297edc12ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 22 Aug 2019 21:31:46 +0200 Subject: [PATCH 060/167] Unify key name string handling This makes key names per-key static strings for all supported platforms. Fixes #1200. (cherry picked from commit 56ca0cb3b30ecb1310752360e9c875fc1b2bab5e) --- include/GLFW/glfw3.h | 6 ++++-- src/cocoa_platform.h | 2 +- src/cocoa_window.m | 10 ++++++---- src/x11_platform.h | 2 +- src/x11_window.c | 7 ++++--- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index f631eb30c6..343ed18847 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -4193,9 +4193,11 @@ GLFWAPI int glfwRawMouseMotionSupported(void); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_PLATFORM_ERROR. * + * @remark The contents of the returned string may change when a keyboard + * layout change event is received. + * * @pointer_lifetime The returned string is allocated and freed by GLFW. You - * should not free it yourself. It is valid until the next call to @ref - * glfwGetKeyName, or until the library is terminated. + * should not free it yourself. It is valid until the library is terminated. * * @thread_safety This function must only be called from the main thread. * diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 2847f36b53..43639a3489 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -139,7 +139,7 @@ typedef struct _GLFWlibraryNS id keyUpMonitor; id nibObjects; - char keyName[64]; + char keynames[GLFW_KEY_LAST + 1][17]; short int keycodes[256]; short int scancodes[GLFW_KEY_LAST + 1]; char* clipboardString; diff --git a/src/cocoa_window.m b/src/cocoa_window.m index f9383b3edd..5f7e0c3e1c 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1503,8 +1503,10 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) { @autoreleasepool { + const int key = _glfw.ns.keycodes[scancode]; + UInt32 deadKeyState = 0; - UniChar characters[8]; + UniChar characters[4]; UniCharCount characterCount = 0; if (UCKeyTranslate([(NSData*) _glfw.ns.unicodeData bytes], @@ -1529,12 +1531,12 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) characterCount, kCFAllocatorNull); CFStringGetCString(string, - _glfw.ns.keyName, - sizeof(_glfw.ns.keyName), + _glfw.ns.keynames[key], + sizeof(_glfw.ns.keynames[key]), kCFStringEncodingUTF8); CFRelease(string); - return _glfw.ns.keyName; + return _glfw.ns.keynames[key]; } // autoreleasepool } diff --git a/src/x11_platform.h b/src/x11_platform.h index 5b3652419a..d34bc5871b 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -228,7 +228,7 @@ typedef struct _GLFWlibraryX11 // Clipboard string (while the selection is owned) char* clipboardString; // Key name string - char keyName[5]; + char keynames[GLFW_KEY_LAST + 1][5]; // X11 keycode to GLFW key LUT short int keycodes[256]; // GLFW key to X11 keycode LUT diff --git a/src/x11_window.c b/src/x11_window.c index 7fd09b5474..0ddbc0d488 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2792,6 +2792,7 @@ const char* _glfwPlatformGetScancodeName(int scancode) if (!_glfw.x11.xkb.available) return NULL; + const int key = _glfw.x11.keycodes[scancode]; const KeySym keysym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, _glfw.x11.xkb.group, 0); if (keysym == NoSymbol) @@ -2801,12 +2802,12 @@ const char* _glfwPlatformGetScancodeName(int scancode) if (ch == -1) return NULL; - const size_t count = encodeUTF8(_glfw.x11.keyName, (unsigned int) ch); + const size_t count = encodeUTF8(_glfw.x11.keynames[key], (unsigned int) ch); if (count == 0) return NULL; - _glfw.x11.keyName[count] = '\0'; - return _glfw.x11.keyName; + _glfw.x11.keynames[key][count] = '\0'; + return _glfw.x11.keynames[key]; } int _glfwPlatformGetKeyScancode(int key) From 71cfafe2f9cbddda85c147f699e011e65e571ec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 22 Aug 2019 23:39:47 +0200 Subject: [PATCH 061/167] Win32: Fix VS static analysis false positive This way is perhaps also more readable for humans. (cherry picked from commit cbf23e56151b2054003769760004dd581dda0ae1) --- src/win32_monitor.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/win32_monitor.c b/src/win32_monitor.c index 3982e9ae3c..03496411ac 100644 --- a/src/win32_monitor.c +++ b/src/win32_monitor.c @@ -477,7 +477,7 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) { HDC dc; - WORD values[768]; + WORD values[3][256]; dc = CreateDCW(L"DISPLAY", monitor->win32.adapterName, NULL, NULL); GetDeviceGammaRamp(dc, values); @@ -485,9 +485,9 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) _glfwAllocGammaArrays(ramp, 256); - memcpy(ramp->red, values + 0, 256 * sizeof(unsigned short)); - memcpy(ramp->green, values + 256, 256 * sizeof(unsigned short)); - memcpy(ramp->blue, values + 512, 256 * sizeof(unsigned short)); + memcpy(ramp->red, values[0], sizeof(values[0])); + memcpy(ramp->green, values[1], sizeof(values[1])); + memcpy(ramp->blue, values[2], sizeof(values[2])); return GLFW_TRUE; } @@ -495,7 +495,7 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) { HDC dc; - WORD values[768]; + WORD values[3][256]; if (ramp->size != 256) { @@ -504,9 +504,9 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) return; } - memcpy(values + 0, ramp->red, 256 * sizeof(unsigned short)); - memcpy(values + 256, ramp->green, 256 * sizeof(unsigned short)); - memcpy(values + 512, ramp->blue, 256 * sizeof(unsigned short)); + memcpy(values[0], ramp->red, sizeof(values[0])); + memcpy(values[1], ramp->green, sizeof(values[1])); + memcpy(values[2], ramp->blue, sizeof(values[2])); dc = CreateDCW(L"DISPLAY", monitor->win32.adapterName, NULL, NULL); SetDeviceGammaRamp(dc, values); From b2919dca4b5135f6259b98a4f3bdcdf0fb1be129 Mon Sep 17 00:00:00 2001 From: httpdigest Date: Sat, 31 Aug 2019 02:44:04 +0200 Subject: [PATCH 062/167] Fix comparison of video modes of equal area This fixes the bug of video modes being discarded if they had a different resolution but the same area as another mode. Fixes #1555. Closes #1556. (cherry picked from commit 2777f6a754a469eb9b71b4d241ca5f3b1ce5a9b1) --- src/monitor.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/monitor.c b/src/monitor.c index db21b7a9e0..c6bcfd395a 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -56,6 +56,10 @@ static int compareVideoModes(const void* fp, const void* sp) if (farea != sarea) return farea - sarea; + // Then sort on width + if (fm->width != sm->width) + return fm->width - sm->width; + // Lastly sort on refresh rate return fm->refreshRate - sm->refreshRate; } From 934f0e9ff1c2dc49fdfc91a945e5b973ddbaff93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 1 Sep 2019 20:05:58 +0200 Subject: [PATCH 063/167] Update changelog and add credit Related to #1556. (cherry picked from commit 26aac53e1d07ad9996cde7a341c7713eaa1955b5) --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index bbe9948026..26e9c1cc2d 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,7 @@ information on what to include when reporting a bug. - Bugfix: The CMake config-file package used an absolute path and was not relocatable (#1470) + - Bugfix: Video modes with a duplicate screen area were discarded (#1555,#1556) - [Win32] Bugfix: `GLFW_INCLUDE_VULKAN` plus `VK_USE_PLATFORM_WIN32_KHR` caused symbol redefinition (#1524) - [Win32] Bugfix: The cursor position event was emitted before its cursor enter @@ -167,6 +168,7 @@ skills. - blanco - Kyle Brenneman - Rok Breulj + - Kai Burjack - Martin Capitanio - David Carlier - Arturo Castro From 649553cc783423f18772b5e0493449dddf1de32e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 6 Sep 2019 15:23:20 +0200 Subject: [PATCH 064/167] Remove deprecated tags from Doxyfile.in This fixes warnings emitted by Doxygen 1.8.16. (cherry picked from commit aa8e8ab960760fd3bbcb08f2a87be93c2f260aa1) --- docs/Doxyfile.in | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index 80ac3bd193..1c8618fd3c 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -1632,11 +1632,6 @@ ALLEXTERNALS = NO EXTERNAL_GROUPS = YES -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- @@ -1649,15 +1644,6 @@ PERL_PATH = /usr/bin/perl CLASS_DIAGRAMS = YES -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_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. From a1b65e8542fc99da7beab795e70dea14c3469331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 29 Aug 2019 22:08:29 +0200 Subject: [PATCH 065/167] Cocoa: Fix glfwSetWindowSize anchor point This makes glfwSetWindowSize use the top-left corner as anchor point instead of the bottom-left corner. Fixes #1553. (cherry picked from commit 7f02898264d6077738f0e8032f027eb7e252c90e) --- README.md | 2 ++ src/cocoa_window.m | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 26e9c1cc2d..85a1a2d7db 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,7 @@ information on what to include when reporting a bug. event (#1490) - [Win32] Bugfix: The window hint `GLFW_MAXIMIZED` did not move or resize the window (#1499) + - [Cocoa] Bugfix: `glfwSetWindowSize` used a bottom-left anchor point (#1553) - [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) @@ -226,6 +227,7 @@ skills. - Peter Knut - Christoph Kubisch - Yuri Kunde Schlesner + - Rokas Kupstys - Konstantin Käfer - Eric Larson - Robin Leffmann diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 5f7e0c3e1c..c8af3321a4 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1032,7 +1032,14 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) acquireMonitor(window); } else - [window->ns.object setContentSize:NSMakeSize(width, height)]; + { + NSRect contentRect = + [window->ns.object contentRectForFrameRect:[window->ns.object frame]]; + contentRect.origin.y += contentRect.size.height - height; + contentRect.size = NSMakeSize(width, height); + [window->ns.object setFrame:[window->ns.object frameRectForContentRect:contentRect] + display:YES]; + } } // autoreleasepool } From 13a4e4e810e2ad1174a411682b173bb0307c4f5a Mon Sep 17 00:00:00 2001 From: "luz.paz" Date: Mon, 12 Aug 2019 06:52:31 -0400 Subject: [PATCH 066/167] Fix typos Found via `codespell -q 3 -S ./deps -L fo,numer,te,uint,wille` (cherry picked from commit 7105ff2dfd004a46bd732c1d0c9f461bae6d51b3) --- docs/Doxyfile.in | 2 +- docs/input.dox | 2 +- examples/particles.c | 6 +++--- examples/splitview.c | 2 +- include/GLFW/glfw3.h | 14 +++++++------- src/win32_init.c | 4 ++-- src/wl_window.c | 2 +- tests/events.c | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index 1c8618fd3c..825356d92f 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -1714,7 +1714,7 @@ UML_LOOK = NO # the class node. If there are many fields or methods and many nodes the # graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS # threshold limits the number of items for each type to make the size more -# managable. Set this to 0 for no limit. Note that the threshold may be +# manageable. Set this to 0 for no limit. Note that the threshold may be # exceeded by 50% before the limit is enforced. UML_LIMIT_NUM_FIELDS = 10 diff --git a/docs/input.dox b/docs/input.dox index eb0244a796..dea6487749 100644 --- a/docs/input.dox +++ b/docs/input.dox @@ -889,7 +889,7 @@ timer varies depending on the operating system and hardware. You can query the frequency, in Hz, with @ref glfwGetTimerFrequency. @code -uint64_t freqency = glfwGetTimerFrequency(); +uint64_t frequency = glfwGetTimerFrequency(); @endcode diff --git a/examples/particles.c b/examples/particles.c index 248c851637..9556ccac0f 100644 --- a/examples/particles.c +++ b/examples/particles.c @@ -444,7 +444,7 @@ static void draw_particles(GLFWwindow* window, double t, float dt) } // Set up vertex arrays. We use interleaved arrays, which is easier to - // handle (in most situations) and it gives a linear memeory access + // handle (in most situations) and it gives a linear memory access // access pattern (which may give better performance in some // situations). GL_T2F_C4UB_V3F means: 2 floats for texture coords, // 4 ubytes for color and 3 floats for vertex coord (in that order). @@ -654,7 +654,7 @@ static void draw_fountain(void) //======================================================================== -// Recursive function for building variable tesselated floor +// Recursive function for building variable tessellated floor //======================================================================== static void tessellate_floor(float x1, float y1, float x2, float y2, int depth) @@ -721,7 +721,7 @@ static void draw_floor(void) glMaterialfv(GL_FRONT, GL_SPECULAR, floor_specular); glMaterialf(GL_FRONT, GL_SHININESS, floor_shininess); - // Draw floor as a bunch of triangle strips (high tesselation + // Draw floor as a bunch of triangle strips (high tessellation // improves lighting) glNormal3f(0.f, 0.f, 1.f); glBegin(GL_QUADS); diff --git a/examples/splitview.c b/examples/splitview.c index 58eb11ef95..58441dbb11 100644 --- a/examples/splitview.c +++ b/examples/splitview.c @@ -3,7 +3,7 @@ // // The program uses a "split window" view, rendering four views of the // same scene in one window (e.g. uesful for 3D modelling software). This -// demo uses scissors to separete the four different rendering areas from +// demo uses scissors to separate the four different rendering areas from // each other. // // (If the code seems a little bit strange here and there, it may be diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 343ed18847..671ba7252c 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -2041,7 +2041,7 @@ GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void); */ GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos); -/*! @brief Retrives the work area of the monitor. +/*! @brief Retrieves the work area of the monitor. * * This function returns the position, in screen coordinates, of the upper-left * corner of the work area of the specified monitor along with the work area @@ -2325,7 +2325,7 @@ GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR. * - * @remark @wayland Gamma handling is a priviledged protocol, this function + * @remark @wayland Gamma handling is a privileged protocol, this function * will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR. * * @thread_safety This function must only be called from the main thread. @@ -2349,7 +2349,7 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_PLATFORM_ERROR. * - * @remark @wayland Gamma handling is a priviledged protocol, this function + * @remark @wayland Gamma handling is a privileged protocol, this function * will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR while * returning `NULL`. * @@ -2393,7 +2393,7 @@ GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor); * * @remark @win32 The gamma ramp size must be 256. * - * @remark @wayland Gamma handling is a priviledged protocol, this function + * @remark @wayland Gamma handling is a privileged protocol, this function * will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR. * * @pointer_lifetime The specified gamma ramp is copied before this function @@ -2612,7 +2612,7 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value); * * @remark @macos When activating frame autosaving with * [GLFW_COCOA_FRAME_NAME](@ref GLFW_COCOA_FRAME_NAME_hint), the specified - * window size and position may be overriden by previously saved values. + * window size and position may be overridden by previously saved values. * * @remark @x11 Some window managers will not respect the placement of * initially hidden windows. @@ -4987,7 +4987,7 @@ GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count); */ GLFWAPI const char* glfwGetJoystickName(int jid); -/*! @brief Returns the SDL comaptible GUID of the specified joystick. +/*! @brief Returns the SDL compatible GUID of the specified joystick. * * This function returns the SDL compatible GUID, as a UTF-8 encoded * hexadecimal string, of the specified joystick. The returned string is @@ -5208,7 +5208,7 @@ GLFWAPI const char* glfwGetGamepadName(int jid); /*! @brief Retrieves the state of the specified joystick remapped as a gamepad. * - * This function retrives the state of the specified joystick remapped to + * This function retrieves the state of the specified joystick remapped to * an Xbox-like gamepad. * * If the specified joystick is not present or does not have a gamepad mapping diff --git a/src/win32_init.c b/src/win32_init.c index 216452ef7e..b2aa0a3d51 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -525,7 +525,7 @@ BOOL _glfwIsWindowsVersionOrGreaterWin32(WORD major, WORD minor, WORD sp) cond = VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL); cond = VerSetConditionMask(cond, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); // HACK: Use RtlVerifyVersionInfo instead of VerifyVersionInfoW as the - // latter lies unless the user knew to embedd a non-default manifest + // latter lies unless the user knew to embed a non-default manifest // announcing support for Windows 10 via supportedOS GUID return RtlVerifyVersionInfo(&osvi, mask, cond) == 0; } @@ -540,7 +540,7 @@ BOOL _glfwIsWindows10BuildOrGreaterWin32(WORD build) cond = VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL); cond = VerSetConditionMask(cond, VER_BUILDNUMBER, VER_GREATER_EQUAL); // HACK: Use RtlVerifyVersionInfo instead of VerifyVersionInfoW as the - // latter lies unless the user knew to embedd a non-default manifest + // latter lies unless the user knew to embed a non-default manifest // announcing support for Windows 10 via supportedOS GUID return RtlVerifyVersionInfo(&osvi, mask, cond) == 0; } diff --git a/src/wl_window.c b/src/wl_window.c index c6cbc7adc5..07fe64eb46 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -134,7 +134,7 @@ static int createTmpfileCloexec(char* tmpname) * SCM_RIGHTS methods. * * posix_fallocate() is used to guarantee that disk space is available - * for the file at the given size. If disk space is insufficent, errno + * for the file at the given size. If disk space is insufficient, errno * is set to ENOSPC. If posix_fallocate() is not supported, program may * receive SIGBUS on accessing mmap()'ed file contents instead. */ diff --git a/tests/events.c b/tests/events.c index ba7f00ab09..251e15d959 100644 --- a/tests/events.c +++ b/tests/events.c @@ -175,7 +175,7 @@ static const char* get_key_name(int key) case GLFW_KEY_KP_8: return "KEYPAD 8"; case GLFW_KEY_KP_9: return "KEYPAD 9"; case GLFW_KEY_KP_DIVIDE: return "KEYPAD DIVIDE"; - case GLFW_KEY_KP_MULTIPLY: return "KEYPAD MULTPLY"; + case GLFW_KEY_KP_MULTIPLY: return "KEYPAD MULTIPLY"; case GLFW_KEY_KP_SUBTRACT: return "KEYPAD SUBTRACT"; case GLFW_KEY_KP_ADD: return "KEYPAD ADD"; case GLFW_KEY_KP_DECIMAL: return "KEYPAD DECIMAL"; From 613b16989964e137660ad0a93ede0e7aa5f88b74 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Thu, 25 Jul 2019 16:55:19 -0500 Subject: [PATCH 067/167] Use the correct type in a for loop The `size` member in the `GLFWgammaramp` struct is of type `unsigned int`, so the `for` loop iterating over it should also use the type `unsigned int`. Closes #1541. (cherry picked from commit 243b1bc292a2e3f8c9aee8884574c1c7f4354402) --- src/cocoa_monitor.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index 112f23b0c4..28abe0d478 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -528,7 +528,7 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) CGGammaValue* values = calloc(ramp->size * 3, sizeof(CGGammaValue)); - for (int i = 0; i < ramp->size; i++) + for (unsigned int i = 0; i < ramp->size; i++) { values[i] = ramp->red[i] / 65535.f; values[i + ramp->size] = ramp->green[i] / 65535.f; From e30718e9274ca5d657526618aa861265f2dbf4da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 3 Oct 2019 19:49:25 +0200 Subject: [PATCH 068/167] Win32: Disable dynamic libgcc for MinGW DLL (cherry picked from commit 3ec8f4a7f5ae83089b5f693fb97d3eb384aa33d6) --- src/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 80ee96913f..0686730848 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -125,6 +125,10 @@ target_compile_options(glfw PRIVATE if (BUILD_SHARED_LIBS) if (WIN32) if (MINGW) + # Remove the dependency on the shared version of libgcc + # NOTE: MinGW-w64 has the correct default but MinGW needs this + target_link_options(glfw PRIVATE "-static-libgcc") + # Remove the lib prefix on the DLL (but not the import library) set_target_properties(glfw PROPERTIES PREFIX "") From 087110aa631a24fc9c8a53abb0c5dec3145b95b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 13 Sep 2019 01:16:13 +0200 Subject: [PATCH 069/167] Win32: Cleanup keyboard input flag parsing This replaces some magic numbers with the corresponding winuser.h provided macros and unifies how the MSB from Get*KeyState is tested. (cherry picked from commit 3d2540c373c53a8ddfba806fb83cdb9e39a61467) --- src/win32_window.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/win32_window.c b/src/win32_window.c index f7b9f24858..29ade44575 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -481,7 +481,7 @@ static int translateKey(WPARAM wParam, LPARAM lParam) DWORD time; // Right side keys have the extended key bit set - if (lParam & 0x01000000) + if (HIWORD(lParam) & KF_EXTENDED) return GLFW_KEY_RIGHT_CONTROL; // HACK: Alt Gr sends Left Ctrl and then Right Alt in close sequence @@ -497,7 +497,7 @@ static int translateKey(WPARAM wParam, LPARAM lParam) next.message == WM_SYSKEYUP) { if (next.wParam == VK_MENU && - (next.lParam & 0x01000000) && + (HIWORD(next.lParam) & KF_EXTENDED) && next.time == time) { // Next message is Right Alt down so discard this @@ -740,8 +740,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, case WM_SYSKEYUP: { const int key = translateKey(wParam, lParam); - const int scancode = (lParam >> 16) & 0x1ff; - const int action = ((lParam >> 31) & 1) ? GLFW_RELEASE : GLFW_PRESS; + const int scancode = (HIWORD(lParam) & 0x1ff); + const int action = (HIWORD(lParam) & KF_UP) ? GLFW_RELEASE : GLFW_PRESS; const int mods = getKeyMods(); if (key == _GLFW_KEY_INVALID) @@ -1934,8 +1934,8 @@ void _glfwPlatformPollEvents(void) window = GetPropW(handle, L"GLFW"); if (window) { - const GLFWbool lshift = (GetAsyncKeyState(VK_LSHIFT) >> 15) & 1; - const GLFWbool rshift = (GetAsyncKeyState(VK_RSHIFT) >> 15) & 1; + const GLFWbool lshift = (GetAsyncKeyState(VK_LSHIFT) & 0x8000) != 0; + const GLFWbool rshift = (GetAsyncKeyState(VK_RSHIFT) & 0x8000) != 0; if (!lshift && window->keys[GLFW_KEY_LEFT_SHIFT] == GLFW_PRESS) { From e4e9581557826bd522158ab9159859e20e10700e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 2 Oct 2019 22:41:02 +0200 Subject: [PATCH 070/167] Add VS 2010 and MinGW to AppVeyor build matrix VS 2010 and MinGW are the two trickiest Windows environments so this should hopefully catch more mistakes. This is probably not the right way to set up any of this, but it works for now. This is also a first step towards building our release binaries with CI. [skip travis] (cherry picked from commit 1bd0a55aa76ceeda0537f7483bda1163405aa571) --- .appveyor.yml | 52 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index f8aaf42d45..a21829a619 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,3 +1,6 @@ +image: + - Visual Studio 2015 + - Visual Studio 2019 branches: only: - ci @@ -5,17 +8,50 @@ branches: - 3.3-stable skip_tags: true environment: - CFLAGS: /WX matrix: - - BUILD_SHARED_LIBS: ON - - BUILD_SHARED_LIBS: OFF + - GENERATOR: MinGW Makefiles + BUILD_SHARED_LIBS: ON + CFLAGS: -Werror + - GENERATOR: MinGW Makefiles + BUILD_SHARED_LIBS: OFF + CFLAGS: -Werror + - GENERATOR: Visual Studio 10 2010 + BUILD_SHARED_LIBS: ON + CFLAGS: /WX + - GENERATOR: Visual Studio 10 2010 + BUILD_SHARED_LIBS: OFF + CFLAGS: /WX + - GENERATOR: Visual Studio 16 2019 + BUILD_SHARED_LIBS: ON + CFLAGS: /WX + - GENERATOR: Visual Studio 16 2019 + BUILD_SHARED_LIBS: OFF + CFLAGS: /WX matrix: fast_finish: true -build_script: - - mkdir build - - cd build - - cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS% .. - - cmake --build . + exclude: + - image: Visual Studio 2015 + GENERATOR: Visual Studio 16 2019 + - image: Visual Studio 2019 + GENERATOR: Visual Studio 10 2010 + - image: Visual Studio 2019 + GENERATOR: MinGW Makefiles +for: +- + matrix: + except: + - GENERATOR: Visual Studio 10 2010 + build_script: + - set PATH=%PATH:C:\Program Files\Git\usr\bin=C:\MinGW\bin% + - cmake -S . -B build -G "%GENERATOR%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS% + - cmake --build build +- + matrix: + only: + - GENERATOR: Visual Studio 10 2010 + build_script: + - cmake -S . -B build -G "%GENERATOR%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS% + - cmake --build build --target glfw notifications: - provider: Email to: From 3facbd2083ebc2bce9a3eddfaffc6ab8c36ffd4c Mon Sep 17 00:00:00 2001 From: Luflosi Date: Mon, 30 Sep 2019 23:17:42 +0200 Subject: [PATCH 071/167] Use the correct type for a struct member The `name` member in the `_GLFWmonitorWayland` struct is used in two places. It is assigned the value from a variable of type `uint32_t` and is compared to another variable of type `uint32_t`, so `name` should also have the same type. Closes #1569. (cherry picked from commit d25248343e248337284dfbe5ecd1eddbd37ae66d) --- src/wl_platform.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wl_platform.h b/src/wl_platform.h index 9fef848d1b..af977d93e1 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -332,7 +332,7 @@ typedef struct _GLFWlibraryWayland typedef struct _GLFWmonitorWayland { struct wl_output* output; - int name; + uint32_t name; int currentMode; int x; From 4a62820646ded53ea9e3c39c35e3368a2f2e32ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 10 Oct 2019 18:03:28 +0200 Subject: [PATCH 072/167] Clean up monitors tool output (cherry picked from commit f71b55f83d5666c17d9a3ef057397b8f49704039) --- tests/monitors.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/monitors.c b/tests/monitors.c index 30ce408896..2b75d7b1ec 100644 --- a/tests/monitors.c +++ b/tests/monitors.c @@ -109,13 +109,13 @@ static void list_modes(GLFWmonitor* monitor) glfwGetMonitorName(monitor), glfwGetPrimaryMonitor() == monitor ? "primary" : "secondary"); printf("Current mode: %s\n", format_mode(mode)); - printf("Virtual position: %i %i\n", x, y); - printf("Content scale: %f %f\n", xscale, yscale); + printf("Virtual position: %i, %i\n", x, y); + printf("Content scale: %f x %f\n", xscale, yscale); - printf("Physical size: %i x %i mm (%0.2f dpi)\n", - width_mm, height_mm, mode->width * 25.4f / width_mm); - printf("Monitor work area: pos=(%d,%d) size=(%dx%d)\n", - workarea_x, workarea_y, workarea_width, workarea_height); + printf("Physical size: %i x %i mm (%0.2f dpi at %i x %i)\n", + width_mm, height_mm, mode->width * 25.4f / width_mm, mode->width, mode->height); + printf("Monitor work area: %i x %i starting at %i, %i\n", + workarea_width, workarea_height, workarea_x, workarea_y); printf("Modes:\n"); From 3f0390b8273af6555eb31919c5ea4f7c32537374 Mon Sep 17 00:00:00 2001 From: Guillaume Racicot Date: Thu, 5 Sep 2019 09:47:49 -0400 Subject: [PATCH 073/167] Enable C99 explicitly with CMake where available This enables compilation as C99 where supported by the compiler. A workaround with per-compiler hardcoded flags is used for CMake 3.0, which does not support the C_STANDARD target property. Fixes #1560. Closes #1576. (cherry picked from commit 8f852e0833be7fa762d70c804c7856b537da9376) --- src/CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0686730848..0af6dd052e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -100,6 +100,16 @@ set_target_properties(glfw PROPERTIES POSITION_INDEPENDENT_CODE ON FOLDER "GLFW3") +if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.1.0") + set_target_properties(glfw PROPERTIES C_STANDARD 99) +else() + # Remove this fallback when removing support for CMake version less than 3.1 + target_compile_options(glfw PRIVATE + "$<$:-std=c99>" + "$<$:-std=c99>>" + "$<$:-std=c99>>") +endif() + target_compile_definitions(glfw PRIVATE _GLFW_USE_CONFIG_H) target_include_directories(glfw PUBLIC "$" From 17f1cceb3200a886ae1d20be1986b39c86612af2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 10 Oct 2019 20:12:42 +0200 Subject: [PATCH 074/167] Add credit Related to #1576. (cherry picked from commit 545f4095921273e9c3ea562b95f331f77f2202b2) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 85a1a2d7db..0bbe526626 100644 --- a/README.md +++ b/README.md @@ -282,6 +282,7 @@ skills. - Nathan Poirier - Alexandre Pretyman - przemekmirek + - Guillaume Racicot - Philip Rideout - Eddie Ringle - Max Risuhin From 857951419a674bf12be8dcaad584ce0e256d45eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 13 Oct 2019 16:42:54 +0200 Subject: [PATCH 075/167] Use HTTPS for Discourse forum (cherry picked from commit 1e20218b3da47691ab5589592f41ce50856f7273) --- README.md | 2 +- docs/CONTRIBUTING.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0bbe526626..bb29cc1cb0 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ On [glfw.org](http://www.glfw.org/) you can find the latest version of GLFW, as well as news, documentation and other information about the project. If you have questions related to the use of GLFW, we have a -[forum](http://discourse.glfw.org/), and the `#glfw` IRC channel on +[forum](https://discourse.glfw.org/), and the `#glfw` IRC channel on [Freenode](http://freenode.net/). If you have a bug to report, a patch to submit or a feature you'd like to diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 3bee43b95e..070cff958e 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -20,14 +20,14 @@ ## Asking a question Questions about how to use GLFW should be asked either in the [support -section](http://discourse.glfw.org/c/support) of the forum, under the [Stack +section](https://discourse.glfw.org/c/support) of the forum, under the [Stack Overflow tag](https://stackoverflow.com/questions/tagged/glfw) or [Game Development tag](https://gamedev.stackexchange.com/questions/tagged/glfw) on Stack Exchange or in the IRC channel `#glfw` on [Freenode](http://freenode.net/). Questions about the design or implementation of GLFW or about future plans -should be asked in the [dev section](http://discourse.glfw.org/c/dev) of the +should be asked in the [dev section](https://discourse.glfw.org/c/dev) of the forum or in the IRC channel. Please don't open a GitHub issue to discuss design questions without first checking with a maintainer. From 8c69091c5902807d824ac383190ae67b6c2de040 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Sun, 6 Oct 2019 22:56:58 +0200 Subject: [PATCH 076/167] Use the correct type in a for loop The `monitorCount` member in the `_GLFWlibrary` struct is of type `int`, so the `for` loop iterating over it should also use the type `int`. Closes #1572. (cherry picked from commit 7749aac50dd404b53ac5c1b35b7935b660ecdad7) --- src/cocoa_monitor.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index 28abe0d478..bb526732fa 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -252,7 +252,7 @@ void _glfwPollMonitorsNS(void) CGDirectDisplayID* displays = calloc(displayCount, sizeof(CGDirectDisplayID)); CGGetOnlineDisplayList(displayCount, displays, &displayCount); - for (uint32_t i = 0; i < _glfw.monitorCount; i++) + for (int i = 0; i < _glfw.monitorCount; i++) _glfw.monitors[i]->ns.screen = nil; _GLFWmonitor** disconnected = NULL; From afcefcb5f72f13100ba44030b0f8e395b4f1ddd1 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Sun, 15 Sep 2019 08:57:34 -0400 Subject: [PATCH 077/167] Fix -Wextra-semi warnings Closes #1440. (cherry picked from commit 3a37a089982ba66f69d3b8e15ec8c769621f7f12) --- README.md | 1 + src/cocoa_joystick.h | 2 +- src/null_joystick.h | 4 ++-- src/null_platform.h | 14 +++++++------- src/win32_joystick.h | 2 +- src/wl_platform.h | 4 ++-- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index bb29cc1cb0..5c227ca781 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,7 @@ information on what to include when reporting a bug. - Bugfix: The CMake config-file package used an absolute path and was not relocatable (#1470) - Bugfix: Video modes with a duplicate screen area were discarded (#1555,#1556) + - Bugfix: Fix -Wextra-semi compilation warning (#1440) - [Win32] Bugfix: `GLFW_INCLUDE_VULKAN` plus `VK_USE_PLATFORM_WIN32_KHR` caused symbol redefinition (#1524) - [Win32] Bugfix: The cursor position event was emitted before its cursor enter diff --git a/src/cocoa_joystick.h b/src/cocoa_joystick.h index 0ab81377b7..b444877818 100644 --- a/src/cocoa_joystick.h +++ b/src/cocoa_joystick.h @@ -30,7 +30,7 @@ #include #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickNS ns -#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE +#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyJoystick; } #define _GLFW_PLATFORM_MAPPING_NAME "Mac OS X" diff --git a/src/null_joystick.h b/src/null_joystick.h index 5a5c558416..9307ae88e4 100644 --- a/src/null_joystick.h +++ b/src/null_joystick.h @@ -24,8 +24,8 @@ // //======================================================================== -#define _GLFW_PLATFORM_JOYSTICK_STATE int nulljs -#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE int nulljs +#define _GLFW_PLATFORM_JOYSTICK_STATE struct { int dummyJoystick; } +#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; } #define _GLFW_PLATFORM_MAPPING_NAME "" diff --git a/src/null_platform.h b/src/null_platform.h index 7871683ed9..708975d1d7 100644 --- a/src/null_platform.h +++ b/src/null_platform.h @@ -29,13 +29,13 @@ #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNull null -#define _GLFW_PLATFORM_CONTEXT_STATE -#define _GLFW_PLATFORM_MONITOR_STATE -#define _GLFW_PLATFORM_CURSOR_STATE -#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE -#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE -#define _GLFW_EGL_CONTEXT_STATE -#define _GLFW_EGL_LIBRARY_CONTEXT_STATE +#define _GLFW_PLATFORM_CONTEXT_STATE struct { int dummyContext; } +#define _GLFW_PLATFORM_MONITOR_STATE struct { int dummyMonitor; } +#define _GLFW_PLATFORM_CURSOR_STATE struct { int dummyCursor; } +#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE struct { int dummyLibraryWindow; } +#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; } +#define _GLFW_EGL_CONTEXT_STATE struct { int dummyEGLContext; } +#define _GLFW_EGL_LIBRARY_CONTEXT_STATE struct { int dummyEGLLibraryContext; } #include "osmesa_context.h" #include "posix_time.h" diff --git a/src/win32_joystick.h b/src/win32_joystick.h index 22bcded37f..9ba46d906a 100644 --- a/src/win32_joystick.h +++ b/src/win32_joystick.h @@ -25,7 +25,7 @@ //======================================================================== #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickWin32 win32 -#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE int dummy +#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; } #define _GLFW_PLATFORM_MAPPING_NAME "Windows" diff --git a/src/wl_platform.h b/src/wl_platform.h index af977d93e1..940e57ee38 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -75,8 +75,8 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWayland wl #define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorWayland wl -#define _GLFW_PLATFORM_CONTEXT_STATE -#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE +#define _GLFW_PLATFORM_CONTEXT_STATE struct { int dummyContext; } +#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; } struct wl_cursor_image { uint32_t width; From 3a8d97cc3d0d34cf37d8dee1913c71a917b2f2ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 16 Oct 2019 16:49:37 +0200 Subject: [PATCH 078/167] Allow AppVeyor to skip pure documentation updates (cherry picked from commit 692754a2c5e37f6384aefec327ad52c58f45216c) --- .appveyor.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.appveyor.yml b/.appveyor.yml index a21829a619..2f4532ebaf 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -7,6 +7,11 @@ branches: - master - 3.3-stable skip_tags: true +skip_commits: + files: + - README.md + - LICENSE.md + - docs/* environment: matrix: - GENERATOR: MinGW Makefiles From 161e9e1215091bb01610cf9fb79abb93307e3d08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 16 Oct 2019 17:43:29 +0200 Subject: [PATCH 079/167] Update changelog (cherry picked from commit 36c547875c3db6bea9e1e7d5ed8a633771dde774) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5c227ca781..413e4c3611 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,7 @@ information on what to include when reporting a bug. - Bugfix: The CMake config-file package used an absolute path and was not relocatable (#1470) - Bugfix: Video modes with a duplicate screen area were discarded (#1555,#1556) - - Bugfix: Fix -Wextra-semi compilation warning (#1440) + - Bugfix: Compiling with -Wextra-semi caused warnings (#1440) - [Win32] Bugfix: `GLFW_INCLUDE_VULKAN` plus `VK_USE_PLATFORM_WIN32_KHR` caused symbol redefinition (#1524) - [Win32] Bugfix: The cursor position event was emitted before its cursor enter From 411d4dd51e8759b346864969387f75a3fcab9438 Mon Sep 17 00:00:00 2001 From: Pablo Prietz Date: Thu, 24 Oct 2019 12:04:18 +0200 Subject: [PATCH 080/167] Fix CMake 3.0 - 3.6 support regression Replaces `VERSION_GREATER_EQUAL` with `VERSION_EQUAL OR VERSION_GREATER`. `VERSION_GREATER_EQUAL` was only added in CMake 3.7. Fixes #1584. Closes #1585. (cherry picked from commit 4d0ae4ffa74f71f91a807a08e9f09324862f1ffc) --- README.md | 1 + src/CMakeLists.txt | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 413e4c3611..b8af3664b6 100644 --- a/README.md +++ b/README.md @@ -337,6 +337,7 @@ skills. - Santi Zupancic - Jonas Ådahl - Lasse Öörni + - Pablo Prietz - All the unmentioned and anonymous contributors in the GLFW community, for bug reports, patches, feedback, testing and encouragement diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0af6dd052e..c7364902b1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -100,7 +100,10 @@ set_target_properties(glfw PROPERTIES POSITION_INDEPENDENT_CODE ON FOLDER "GLFW3") -if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.1.0") +if ( + ${CMAKE_VERSION} VERSION_EQUAL "3.1.0" OR + ${CMAKE_VERSION} VERSION_GREATER "3.1.0" +) set_target_properties(glfw PROPERTIES C_STANDARD 99) else() # Remove this fallback when removing support for CMake version less than 3.1 From 91c6a542ffe5dec84446b6ab69f9802178baa2bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 24 Oct 2019 16:20:43 +0200 Subject: [PATCH 081/167] Cleanup Related to #1585. (cherry picked from commit 04f7f55f077bcb61081d8249ac0515b1453eedfb) --- README.md | 2 +- src/CMakeLists.txt | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b8af3664b6..c023d30c1f 100644 --- a/README.md +++ b/README.md @@ -282,6 +282,7 @@ skills. - Konstantin Podsvirov - Nathan Poirier - Alexandre Pretyman + - Pablo Prietz - przemekmirek - Guillaume Racicot - Philip Rideout @@ -337,7 +338,6 @@ skills. - Santi Zupancic - Jonas Ådahl - Lasse Öörni - - Pablo Prietz - All the unmentioned and anonymous contributors in the GLFW community, for bug reports, patches, feedback, testing and encouragement diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c7364902b1..b78b8d37a7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -100,10 +100,9 @@ set_target_properties(glfw PROPERTIES POSITION_INDEPENDENT_CODE ON FOLDER "GLFW3") -if ( - ${CMAKE_VERSION} VERSION_EQUAL "3.1.0" OR - ${CMAKE_VERSION} VERSION_GREATER "3.1.0" -) +if (${CMAKE_VERSION} VERSION_EQUAL "3.1.0" OR + ${CMAKE_VERSION} VERSION_GREATER "3.1.0") + set_target_properties(glfw PROPERTIES C_STANDARD 99) else() # Remove this fallback when removing support for CMake version less than 3.1 From f9a9bb6747b7064a12ff02b9de318870872827d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 24 Oct 2019 16:27:26 +0200 Subject: [PATCH 082/167] Remove stray characters from hardcoded CFLAGS The additional '>' characters were appended to the compiler option. Related to #1576. (cherry picked from commit 33683ec60e96dd52e99c48b7e7c1dad664d234ec) --- src/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b78b8d37a7..6cbeed6d60 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -108,8 +108,8 @@ else() # Remove this fallback when removing support for CMake version less than 3.1 target_compile_options(glfw PRIVATE "$<$:-std=c99>" - "$<$:-std=c99>>" - "$<$:-std=c99>>") + "$<$:-std=c99>" + "$<$:-std=c99>") endif() target_compile_definitions(glfw PRIVATE _GLFW_USE_CONFIG_H) From 1bf892f603b2479666b0035eb1bc214b05364ad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 26 Sep 2019 18:29:37 +0200 Subject: [PATCH 083/167] X11: Fix decoration enabling after window creation This fixes the enabling of window decorations after creation. Instead of removing the _MOTIF_WM_HINTS property, we now set or unset the MWM_DECOR_ALL bit of the decorations field. Fixes #1566. (cherry picked from commit 5fc4c01302b0729fd9f39e8c504e28cf7347153c) --- README.md | 1 + src/x11_window.c | 43 +++++++++++++++++++------------------------ 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index c023d30c1f..1bc453872b 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,7 @@ information on what to include when reporting a bug. - [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) + - [X11] Bugfix: Decorations could not be enabled after window creation (#1566) ## Contact diff --git a/src/x11_window.c b/src/x11_window.c index 0ddbc0d488..85d548a63c 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -50,6 +50,10 @@ #define Button6 6 #define Button7 7 +// Motif WM hints flags +#define MWM_HINTS_DECORATIONS 2 +#define MWM_DECOR_ALL 1 + #define _GLFW_XDND_VERSION 5 @@ -2536,33 +2540,24 @@ void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled) void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled) { - if (enabled) - { - XDeleteProperty(_glfw.x11.display, - window->x11.handle, - _glfw.x11.MOTIF_WM_HINTS); - } - else + struct { - struct - { - unsigned long flags; - unsigned long functions; - unsigned long decorations; - long input_mode; - unsigned long status; - } hints; + unsigned long flags; + unsigned long functions; + unsigned long decorations; + long input_mode; + unsigned long status; + } hints = {0}; - hints.flags = 2; // Set decorations - hints.decorations = 0; // No decorations + hints.flags = MWM_HINTS_DECORATIONS; + hints.decorations = enabled ? MWM_DECOR_ALL : 0; - XChangeProperty(_glfw.x11.display, window->x11.handle, - _glfw.x11.MOTIF_WM_HINTS, - _glfw.x11.MOTIF_WM_HINTS, 32, - PropModeReplace, - (unsigned char*) &hints, - sizeof(hints) / sizeof(long)); - } + XChangeProperty(_glfw.x11.display, window->x11.handle, + _glfw.x11.MOTIF_WM_HINTS, + _glfw.x11.MOTIF_WM_HINTS, 32, + PropModeReplace, + (unsigned char*) &hints, + sizeof(hints) / sizeof(long)); } void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled) From 399c082033945f4f3c1a993d9d4b80b85c66172e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 28 Oct 2019 19:18:19 +0100 Subject: [PATCH 084/167] X11: Fix content scale fallback value on KDE KDE sometimes removes the Xft.dpi resource when it would be set to the X11 default value of 96, causing GLFW to fall back to a value calculated from the core display sizes in pixels and mm in a desktop environment that supports Xft.dpi. This moves to a hardcoded fallback value of 96 on the assumption that there are more people running KDE with 96 DPI than there are people running desktop environments that do not support Xft.dpi. All of this is terrible please send help. Fixes #1578. (cherry picked from commit 75294462b354d147aa5914c30e3005551cc04e4a) --- README.md | 1 + src/x11_init.c | 11 ++++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 1bc453872b..77844aafb1 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,7 @@ information on what to include when reporting a bug. - [X11] Bugfix: Key names were not updated when the keyboard layout changed (#1462,#1528) - [X11] Bugfix: Decorations could not be enabled after window creation (#1566) + - [X11] Bugfix: Content scale fallback value could be inconsistent (#1578) ## Contact diff --git a/src/x11_init.c b/src/x11_init.c index f00080d644..2f220ec508 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -793,13 +793,10 @@ static GLFWbool initExtensions(void) // static void getSystemContentScale(float* xscale, float* yscale) { - // NOTE: Fall back to the display-wide DPI instead of RandR monitor DPI if - // Xft.dpi retrieval below fails as we don't currently have an exact - // policy for which monitor a window is considered to "be on" - float xdpi = DisplayWidth(_glfw.x11.display, _glfw.x11.screen) * - 25.4f / DisplayWidthMM(_glfw.x11.display, _glfw.x11.screen); - float ydpi = DisplayHeight(_glfw.x11.display, _glfw.x11.screen) * - 25.4f / DisplayHeightMM(_glfw.x11.display, _glfw.x11.screen); + // Start by assuming the default X11 DPI + // NOTE: Some desktop environments (KDE) may remove the Xft.dpi field when it + // would be set to 96, so assume that is the case if we cannot find it + float xdpi = 96.f, ydpi = 96.f; // NOTE: Basing the scale on Xft.dpi where available should provide the most // consistent user experience (matches Qt, Gtk, etc), although not From 3484aa81871b5d92ef831818e593df0c83f3ac69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 1 Nov 2019 13:27:44 +0100 Subject: [PATCH 085/167] Fix order of words in window guide Fixes #1571. (cherry picked from commit 28d850770022afc8b73d88a871fa07e8d35766b3) --- docs/window.dox | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/window.dox b/docs/window.dox index 3a9e4a2948..d7a3563d14 100644 --- a/docs/window.dox +++ b/docs/window.dox @@ -1400,7 +1400,7 @@ glfwSwapBuffers(window); Sometimes it can be useful to select when the buffer swap will occur. With the function @ref glfwSwapInterval it is possible to select the minimum number of -monitor refreshes the driver wait should from the time @ref glfwSwapBuffers was +monitor refreshes the driver should wait from the time @ref glfwSwapBuffers was called before swapping the buffers: @code From c5a870ebd9280f72272b3d655b840fcb3a85b51f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 5 Nov 2019 18:55:42 +0100 Subject: [PATCH 086/167] Win32: Change transparent framebuffer key color This is a temporary fix while we determine if the color key workaround should be removed completely. See issue thread for discussion. Related to #1512. (cherry picked from commit c88ee1c9d3e018c199eaf0b0f5ccc3874ac1de09) --- docs/window.dox | 7 +++++++ src/win32_window.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/window.dox b/docs/window.dox index d7a3563d14..6109fbf55a 100644 --- a/docs/window.dox +++ b/docs/window.dox @@ -234,6 +234,13 @@ alpha channel will be used to combine the framebuffer with the background. This does not affect window decorations. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. +@par +@win32 GLFW sets a color key for the window to work around repainting issues +with a transparent framebuffer. The chosen color value is RGB 255,0,255 +(magenta). This will make pixels with that exact color fully transparent +regardless of their alpha values. If this is a problem, make these pixels any +other color before buffer swap. + @anchor GLFW_FOCUS_ON_SHOW_hint __GLFW_FOCUS_ON_SHOW__ specifies whether the window will be given input focus when @ref glfwShowWindow is called. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. diff --git a/src/win32_window.c b/src/win32_window.c index 29ade44575..cdb1fe8771 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -411,7 +411,7 @@ static void updateFramebufferTransparency(const _GLFWwindow* window) // issue. When set to black, something is making the hit test // not resize with the window frame. SetLayeredWindowAttributes(window->win32.handle, - RGB(0, 193, 48), 255, LWA_COLORKEY); + RGB(255, 0, 255), 255, LWA_COLORKEY); } DeleteObject(region); From 5f7e5cb92b19daa481af1438af75490711fcf734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 5 Nov 2019 20:37:08 +0100 Subject: [PATCH 087/167] Remove mappings for GUID used by different devices The SDL2 2.0.5+ controller GUID 03000000790000000600000000000000 matches many devices with different layouts and element counts but with the same chipset. This issue is still being resolved upstream. In the meantime this removes those mappings from GLFW to avoid confusion and errors. SDL upstream issue: https://bugzilla.libsdl.org/show_bug.cgi?id=4545 Related to #1583. (cherry picked from commit b69fb99031258f5fe37281ce4a6e44ce96e32a03) --- src/mappings.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mappings.h b/src/mappings.h index 94a279af43..606824a625 100644 --- a/src/mappings.h +++ b/src/mappings.h @@ -84,7 +84,6 @@ const char* _glfwDefaultMappings[] = "030000000d0f00008700000000000000,Fighting Stick mini 4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,", "030000000d0f00002700000000000000,FIGHTING STICK V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,", "78696e70757403000000000000000000,Fightstick TES,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b2,y:b3,platform:Windows,", -"03000000790000000600000000000000,G-Shark GS-GP702,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows,", "03000000260900002625000000000000,Gamecube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,lefttrigger:a4,leftx:a0,lefty:a1,righttrigger:a5,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Windows,", "030000008f0e00000d31000000000000,GAMEPAD 3 TURBO,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,", "03000000280400000140000000000000,GamePad Pro USB,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,", @@ -207,7 +206,6 @@ const char* _glfwDefaultMappings[] = "030000008305000031b0000000000000,Cideko AK08b,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,", "03000000260900008888000088020000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a5,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Mac OS X,", "03000000a306000022f6000001030000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Mac OS X,", -"03000000790000000600000000000000,G-Shark GP-702,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Mac OS X,", "03000000ad1b000001f9000000000000,Gamestop BB-070 X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,", "0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X,", "030000000d0f00005f00000000010000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,", From 11db404fa15803909b813793d04d5f6ed9cc7803 Mon Sep 17 00:00:00 2001 From: thewoz Date: Tue, 5 Nov 2019 16:27:06 +0100 Subject: [PATCH 088/167] Add canonical build directory to .gitignore Closes #1595. (cherry picked from commit c5f1ca3e410e1f719c4e02c70c7827729cb7c888) --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 544117e079..c20775d45b 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ Release MinSizeRel RelWithDebInfo *.xcodeproj +build # CMake files Makefile From 82effcb7bac2553d61fdfefa342e42adb098a9df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 26 Sep 2019 19:22:36 +0200 Subject: [PATCH 089/167] Make events test output only UTF-8 in C locale (cherry picked from commit 20e522cdf4b6b772e3609e95eb9773c29ed9fee1) --- tests/events.c | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/tests/events.c b/tests/events.c index 251e15d959..f29dfbb034 100644 --- a/tests/events.c +++ b/tests/events.c @@ -253,17 +253,32 @@ static const char* get_mods_name(int mods) return name; } -static const char* get_character_string(int codepoint) +static size_t encode_utf8(char* s, unsigned int ch) { - // This assumes UTF-8, which is stupid - static char result[6 + 1]; + size_t count = 0; - int length = wctomb(result, codepoint); - if (length == -1) - length = 0; + if (ch < 0x80) + s[count++] = (char) ch; + else if (ch < 0x800) + { + s[count++] = (ch >> 6) | 0xc0; + s[count++] = (ch & 0x3f) | 0x80; + } + else if (ch < 0x10000) + { + s[count++] = (ch >> 12) | 0xe0; + s[count++] = ((ch >> 6) & 0x3f) | 0x80; + s[count++] = (ch & 0x3f) | 0x80; + } + else if (ch < 0x110000) + { + s[count++] = (ch >> 18) | 0xf0; + s[count++] = ((ch >> 12) & 0x3f) | 0x80; + s[count++] = ((ch >> 6) & 0x3f) | 0x80; + s[count++] = (ch & 0x3f) | 0x80; + } - result[length] = '\0'; - return result; + return count; } static void error_callback(int error, const char* description) @@ -425,9 +440,11 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action, static void char_callback(GLFWwindow* window, unsigned int codepoint) { Slot* slot = glfwGetWindowUserPointer(window); + char string[5] = ""; + + encode_utf8(string, codepoint); printf("%08x to %i at %0.3f: Character 0x%08x (%s) input\n", - counter++, slot->number, glfwGetTime(), codepoint, - get_character_string(codepoint)); + counter++, slot->number, glfwGetTime(), codepoint, string); } static void drop_callback(GLFWwindow* window, int count, const char* paths[]) @@ -500,8 +517,6 @@ int main(int argc, char** argv) GLFWmonitor* monitor = NULL; int ch, i, width, height, count = 1; - setlocale(LC_ALL, ""); - glfwSetErrorCallback(error_callback); if (!glfwInit()) From 8c46a3e9f91de1ae6a60b31c0961b9109f3f6c5f Mon Sep 17 00:00:00 2001 From: Guillaume Racicot Date: Sun, 3 Nov 2019 21:12:01 -0500 Subject: [PATCH 090/167] Set C standard at 99 for all test targets Related to #1593. (cherry picked from commit bc5523e994ff79304b2a690b354b7531dbbe1246) --- tests/CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index fcc992433e..4f49c77018 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -20,6 +20,18 @@ set(GETOPT "${GLFW_SOURCE_DIR}/deps/getopt.h" set(TINYCTHREAD "${GLFW_SOURCE_DIR}/deps/tinycthread.h" "${GLFW_SOURCE_DIR}/deps/tinycthread.c") +if (${CMAKE_VERSION} VERSION_EQUAL "3.1.0" OR + ${CMAKE_VERSION} VERSION_GREATER "3.1.0") + set(CMAKE_C_STANDARD 99) +else() + # Remove this fallback when removing support for CMake version less than 3.1 + add_compile_options( + "$<$:-std=c99>" + "$<$:-std=c99>" + "$<$:-std=c99>") + +endif() + add_executable(clipboard clipboard.c ${GETOPT} ${GLAD_GL}) add_executable(events events.c ${GETOPT} ${GLAD_GL}) add_executable(msaa msaa.c ${GETOPT} ${GLAD_GL}) From 7a10e6439c8193c6fbe5f879eadf8902db797dc0 Mon Sep 17 00:00:00 2001 From: Guillaume Racicot Date: Sat, 9 Nov 2019 12:19:49 -0500 Subject: [PATCH 091/167] Set C standard at 99 for all example targets Closes #1593. (cherry picked from commit 70a3104c4977fc4ea55efb12d4c565b2581edd5c) --- examples/CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index e0a9c2d68f..b69761c309 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -23,6 +23,18 @@ elseif (APPLE) MACOSX_PACKAGE_LOCATION "Resources") endif() +if (${CMAKE_VERSION} VERSION_EQUAL "3.1.0" OR + ${CMAKE_VERSION} VERSION_GREATER "3.1.0") + set(CMAKE_C_STANDARD 99) +else() + # Remove this fallback when removing support for CMake version less than 3.1 + add_compile_options( + "$<$:-std=c99>" + "$<$:-std=c99>" + "$<$:-std=c99>") + +endif() + set(GLAD_GL "${GLFW_SOURCE_DIR}/deps/glad/gl.h" "${GLFW_SOURCE_DIR}/deps/glad_gl.c") set(GETOPT "${GLFW_SOURCE_DIR}/deps/getopt.h" From 5ea34d62bf2d6299b9aa4ea7a2ca5617b9d880c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 10 Nov 2019 15:20:29 +0100 Subject: [PATCH 092/167] Cleanup (cherry picked from commit 953a1c3f8b793dcb23879ca1032b7b62f0f27410) --- examples/CMakeLists.txt | 3 +-- tests/CMakeLists.txt | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index b69761c309..69ef0d455b 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -28,8 +28,7 @@ if (${CMAKE_VERSION} VERSION_EQUAL "3.1.0" OR set(CMAKE_C_STANDARD 99) else() # Remove this fallback when removing support for CMake version less than 3.1 - add_compile_options( - "$<$:-std=c99>" + add_compile_options("$<$:-std=c99>" "$<$:-std=c99>" "$<$:-std=c99>") diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4f49c77018..c471d8b94f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -25,8 +25,7 @@ if (${CMAKE_VERSION} VERSION_EQUAL "3.1.0" OR set(CMAKE_C_STANDARD 99) else() # Remove this fallback when removing support for CMake version less than 3.1 - add_compile_options( - "$<$:-std=c99>" + add_compile_options("$<$:-std=c99>" "$<$:-std=c99>" "$<$:-std=c99>") From 25af31528c17f4c349950fc27638dcb2412c5f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 6 Nov 2019 17:25:16 +0100 Subject: [PATCH 093/167] Cocoa: Add comments for Cocoa symbol macros (cherry picked from commit 94cb0347abdc4e8ebf8dcf133894a764d395b84c) --- src/cocoa_platform.h | 3 +++ src/nsgl_context.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 43639a3489..b29b64c8d4 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -41,6 +41,9 @@ typedef void* id; #endif +// NOTE: Many Cocoa enum values have been renamed and we need to build across +// SDK versions where one is unavailable or the other deprecated +// We use the newer names in code and these macros to handle compatibility #if MAC_OS_X_VERSION_MAX_ALLOWED < 101200 #define NSBitmapFormatAlphaNonpremultiplied NSAlphaNonpremultipliedBitmapFormat #define NSEventMaskAny NSAnyEventMask diff --git a/src/nsgl_context.h b/src/nsgl_context.h index 2485b18078..432d200e40 100644 --- a/src/nsgl_context.h +++ b/src/nsgl_context.h @@ -24,6 +24,9 @@ // //======================================================================== +// NOTE: Many Cocoa enum values have been renamed and we need to build across +// SDK versions where one is unavailable or the other deprecated +// We use the newer names in code and these macros to handle compatibility #if MAC_OS_X_VERSION_MAX_ALLOWED < 101400 #define NSOpenGLContextParameterSwapInterval NSOpenGLCPSwapInterval #define NSOpenGLContextParameterSurfaceOpacity NSOpenGLCPSurfaceOpacity From 129a5ccb197f6a3c6907f46892c4abdc41b14303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 6 Nov 2019 23:34:08 +0100 Subject: [PATCH 094/167] Cocoa: Process events after window destruction On macOS a destroyed window remained on screen until the next time events were processed. This makes the behavior more consistent with other platforms. Fixes #1412. (cherry picked from commit c819f27ce3e6639b4d4b432c0e5191e5c26a9d31) --- README.md | 2 ++ src/cocoa_window.m | 3 +++ 2 files changed, 5 insertions(+) diff --git a/README.md b/README.md index 77844aafb1..9572d585fe 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,8 @@ information on what to include when reporting a bug. - [Win32] Bugfix: The window hint `GLFW_MAXIMIZED` did not move or resize the window (#1499) - [Cocoa] Bugfix: `glfwSetWindowSize` used a bottom-left anchor point (#1553) + - [Cocoa] Bugfix: Window remained on screen after destruction until event poll + (#1412) - [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 c8af3321a4..ac22d7e359 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -962,6 +962,9 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window) [window->ns.object close]; window->ns.object = nil; + // HACK: Allow Cocoa to catch up before returning + _glfwPlatformPollEvents(); + } // autoreleasepool } From b3c2023ebc40b9003c7942eb4549358402be5d92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 6 Nov 2019 23:46:05 +0100 Subject: [PATCH 095/167] Cocoa: Fix multiple methods warning This fixes a warning due to us using bare ids and NSCollectionLayoutAnchor having a message with the same name. (cherry picked from commit bac15f94493938eded7161a7a0ab8827584e3db1) --- 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 ac22d7e359..e2f798e854 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -816,7 +816,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window, [window->ns.object setLevel:NSMainMenuWindowLevel + 1]; else { - [window->ns.object center]; + [(NSWindow*) window->ns.object center]; _glfw.ns.cascadePoint = NSPointToCGPoint([window->ns.object cascadeTopLeftFromPoint: NSPointFromCGPoint(_glfw.ns.cascadePoint)]); From e662492169bab1b3659a82061defd1546567f369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 7 Nov 2019 13:45:15 +0100 Subject: [PATCH 096/167] Cocoa: Cleanup Readability fix, does not affect generated code. (cherry picked from commit bd452016be99e10d7fa8282cd75b1c53e0d5a8cc) --- src/nsgl_context.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nsgl_context.m b/src/nsgl_context.m index 1b450b18fa..9cfa4276f9 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -339,7 +339,7 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, return GLFW_FALSE; } - NSOpenGLContext* share = NULL; + NSOpenGLContext* share = nil; if (ctxconfig->share) share = ctxconfig->share->context.nsgl.object; @@ -412,7 +412,7 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle) if (window->context.client == GLFW_NO_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); - return NULL; + return nil; } return window->context.nsgl.object; From 52b77030e426ee790ef5e7da289ce96d9132f2e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 12 Nov 2019 18:23:04 +0100 Subject: [PATCH 097/167] Cocoa: Fix full screen window iconification Iconification (miniaturization) of undecorated windows stopped working unless the window has the NSWindowStyleMaskMiniaturizable style. (cherry picked from commit 2c519709be0dacc7af2908982a7ab80b889a8126) --- src/cocoa_window.m | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index e2f798e854..61321805ba 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -35,15 +35,14 @@ // static NSUInteger getStyleMask(_GLFWwindow* window) { - NSUInteger styleMask = 0; + NSUInteger styleMask = NSWindowStyleMaskMiniaturizable; if (window->monitor || !window->decorated) styleMask |= NSWindowStyleMaskBorderless; else { styleMask |= NSWindowStyleMaskTitled | - NSWindowStyleMaskClosable | - NSWindowStyleMaskMiniaturizable; + NSWindowStyleMaskClosable; if (window->resizable) styleMask |= NSWindowStyleMaskResizable; From 7c33fb22fdd55af5417a48c8594fc495fb1f81a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 5 Nov 2019 13:09:01 +0100 Subject: [PATCH 098/167] X11: Assume 96 DPI if RandR monitor size is zero This falls back to calculating the monitor physical size from the current resolution and the default X11 DPI when the physical size returned by RandR is zero. (cherry picked from commit e96dc5d2199032d565b55c4177820ab28b1d67c9) --- src/x11_monitor.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/x11_monitor.c b/src/x11_monitor.c index cce05f98fd..412f9f409a 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -161,6 +161,16 @@ void _glfwPollMonitorsX11(void) heightMM = oi->mm_height; } + if (widthMM <= 0 || heightMM <= 0) + { + // HACK: If RandR does not provide a physical size, assume the + // X11 default 96 DPI and calcuate from the CRTC viewport + // NOTE: These members are affected by rotation, unlike the mode + // info and output info members + widthMM = (int) (ci->width * 25.4f / 96.f); + heightMM = (int) (ci->height * 25.4f / 96.f); + } + _GLFWmonitor* monitor = _glfwAllocMonitor(oi->name, widthMM, heightMM); monitor->x11.output = sr->outputs[i]; monitor->x11.crtc = oi->crtc; From b4cc6101ed66d5216f815b90b6065488f60306aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 13 Nov 2019 15:55:09 +0100 Subject: [PATCH 099/167] Add initial .mailmap file (cherry picked from commit 359758bb53400b589e311c7d4f8732a58a40a1cd) --- .mailmap | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .mailmap diff --git a/.mailmap b/.mailmap new file mode 100644 index 0000000000..96d8a9b77f --- /dev/null +++ b/.mailmap @@ -0,0 +1,10 @@ +Camilla Löwy +Camilla Löwy +Camilla Löwy + +Emmanuel Gil Peyrot + +Marcus Geelnard +Marcus Geelnard +Marcus Geelnard + From 0ecc84182c5adbad6d1debd79e923bcf1a475d82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 14 Nov 2019 14:12:43 +0100 Subject: [PATCH 100/167] Add initial GH support file (cherry picked from commit b804379463b6378e5f38803ef29ddf74adc98a9c) --- docs/SUPPORT.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 docs/SUPPORT.md diff --git a/docs/SUPPORT.md b/docs/SUPPORT.md new file mode 100644 index 0000000000..604957d066 --- /dev/null +++ b/docs/SUPPORT.md @@ -0,0 +1,14 @@ +# Support resources + +See the [latest documentation](http://www.glfw.org/docs/latest/) for tutorials, +guides and the API reference. + +If you have questions about using GLFW, we have a +[forum](https://discourse.glfw.org/), and the `#glfw` IRC channel on +[Freenode](http://freenode.net/). + +Bugs are reported to our [issue tracker](https://github.com/glfw/glfw/issues). +Please check the [contribution +guide](https://github.com/glfw/glfw/blob/master/docs/CONTRIBUTING.md) for +information on what to include when reporting a bug. + From e3c83f684fb9165bbd13e9b4365c247a6668370e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 14 Nov 2019 19:02:29 +0100 Subject: [PATCH 101/167] Add initial CODEOWNERS file (cherry picked from commit 50a6270e55e6d12a24031395943495120efd2d30) --- docs/CODEOWNERS | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 docs/CODEOWNERS diff --git a/docs/CODEOWNERS b/docs/CODEOWNERS new file mode 100644 index 0000000000..ec174185f1 --- /dev/null +++ b/docs/CODEOWNERS @@ -0,0 +1,10 @@ + +* @elmindreda + +src/wl_* @linkmauve + +docs/*.css @glfw/webdev +docs/*.less @glfw/webdev +docs/*.html @glfw/webdev +docs/*.xml @glfw/webdev + From 4116db14fd36b651075e8a778d03d57efcb8c74d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 14 Nov 2019 19:20:10 +0100 Subject: [PATCH 102/167] Cleanup .gitignore file somewhat (cherry picked from commit c42d8f3e5b7203a5ebb8dd7876c87b9ca282cbd4) --- .gitignore | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index c20775d45b..c4dddd12f9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ -# External junk -.DS_Store +# The canonical out-of-tree build subdirectory +build + +# Visual Studio clutter _ReSharper* -*.opensdf *.sdf *.suo *.dir @@ -15,10 +16,15 @@ Release MinSizeRel RelWithDebInfo *.xcodeproj -build +*.opensdf + +# macOS clutter +.DS_Store -# CMake files +# Makefile generator clutter Makefile + +# CMake clutter CMakeCache.txt CMakeFiles CMakeScripts From 2bac7ee8da526257d808bd026b027246c98e4f2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 14 Nov 2019 19:45:29 +0100 Subject: [PATCH 103/167] Update .gitignore file This adds missing entries for Ninja and the unavoidable clutter of the modern Doxygen CMake module. (cherry picked from commit d861d7bffe391815bce26073c38f6f8075e46410) --- .gitignore | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.gitignore b/.gitignore index c4dddd12f9..cd1d9213a8 100644 --- a/.gitignore +++ b/.gitignore @@ -24,10 +24,18 @@ RelWithDebInfo # Makefile generator clutter Makefile +# Ninja generator clutter +build.ninja +rules.ninja +.ninja_deps +.ninja_log + # CMake clutter CMakeCache.txt CMakeFiles CMakeScripts +CMakeDoxyfile.in +CMakeDoxygenDefaults.cmake cmake_install.cmake cmake_uninstall.cmake From 3a2c0aaa27666e5bd534c91787498a002fab93ed Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Fri, 15 Nov 2019 15:30:41 +0100 Subject: [PATCH 104/167] =?UTF-8?q?Wayland:=20Don=E2=80=99t=20reload=20the?= =?UTF-8?q?=20cursor=20on=20every=20pointer=20motion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, any pointer motion in the window decorations when using the fallback implementation would obtain the wl_cursor again, and do the attach danse for no benefit. This will ultimately allow animated cursors to not reset to the first frame on motion, once these will be implemented. (cherry picked from commit a9f674e719cd663560418de2a7fa1147ce6c6c9b) --- src/wl_init.c | 6 ++++-- src/wl_platform.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index 292de1c382..748746929d 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -169,6 +169,7 @@ static void setCursor(_GLFWwindow* window, const char* name) wl_surface_damage(surface, 0, 0, image->width, image->height); wl_surface_commit(surface); + _glfw.wl.cursorPreviousName = name; } static void pointerHandleMotion(void* data, @@ -178,7 +179,7 @@ static void pointerHandleMotion(void* data, wl_fixed_t sy) { _GLFWwindow* window = _glfw.wl.pointerFocus; - const char* cursorName; + const char* cursorName = NULL; if (!window) return; @@ -227,7 +228,8 @@ static void pointerHandleMotion(void* data, default: assert(0); } - setCursor(window, cursorName); + if (_glfw.wl.cursorPreviousName != cursorName) + setCursor(window, cursorName); } static void pointerHandleButton(void* data, diff --git a/src/wl_platform.h b/src/wl_platform.h index 940e57ee38..41a7fdfa7a 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -249,6 +249,7 @@ typedef struct _GLFWlibraryWayland struct wl_cursor_theme* cursorTheme; struct wl_cursor_theme* cursorThemeHiDPI; struct wl_surface* cursorSurface; + const char* cursorPreviousName; int cursorTimerfd; uint32_t serial; From 50218fbf7e9808c022688881ea0f68e2d5f0101f Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Thu, 21 Nov 2019 13:46:18 +0100 Subject: [PATCH 105/167] =?UTF-8?q?Wayland:=20Don=E2=80=99t=20update=20cur?= =?UTF-8?q?sor=20position=20in=20the=20frame?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit That way the application only sees the cursor moving when it is inside of its area, it won’t go back to the top or left side when trying to resize the window or just hovering the fallback decorations. (cherry picked from commit a80788c17f3376177b45d52f983d4d98f1175af2) --- src/wl_init.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index 748746929d..d64e2e353e 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -180,47 +180,45 @@ static void pointerHandleMotion(void* data, { _GLFWwindow* window = _glfw.wl.pointerFocus; const char* cursorName = NULL; + double x, y; if (!window) return; if (window->cursorMode == GLFW_CURSOR_DISABLED) return; - else - { - window->wl.cursorPosX = wl_fixed_to_double(sx); - window->wl.cursorPosY = wl_fixed_to_double(sy); - } + x = wl_fixed_to_double(sx); + y = wl_fixed_to_double(sy); switch (window->wl.decorations.focus) { case mainWindow: - _glfwInputCursorPos(window, - wl_fixed_to_double(sx), - wl_fixed_to_double(sy)); + window->wl.cursorPosX = x; + window->wl.cursorPosY = y; + _glfwInputCursorPos(window, x, y); return; case topDecoration: - if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH) + if (y < _GLFW_DECORATION_WIDTH) cursorName = "n-resize"; else cursorName = "left_ptr"; break; case leftDecoration: - if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH) + if (y < _GLFW_DECORATION_WIDTH) cursorName = "nw-resize"; else cursorName = "w-resize"; break; case rightDecoration: - if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH) + if (y < _GLFW_DECORATION_WIDTH) cursorName = "ne-resize"; else cursorName = "e-resize"; break; case bottomDecoration: - if (window->wl.cursorPosX < _GLFW_DECORATION_WIDTH) + if (x < _GLFW_DECORATION_WIDTH) cursorName = "sw-resize"; - else if (window->wl.cursorPosX > window->wl.width + _GLFW_DECORATION_WIDTH) + else if (x > window->wl.width + _GLFW_DECORATION_WIDTH) cursorName = "se-resize"; else cursorName = "s-resize"; From df4bda44fc4f453b08e8ed1a6ee72b0840e25a3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 17 May 2019 18:30:02 +0200 Subject: [PATCH 106/167] Wayland: Fix pointing hand cursor shape Related to #1432. (cherry picked from commit 80fde12fdade85a39c5c1300d0a29200691fdc23) --- README.md | 1 + src/wl_window.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9572d585fe..92c5ea2af2 100644 --- a/README.md +++ b/README.md @@ -136,6 +136,7 @@ information on what to include when reporting a bug. (#1462,#1528) - [X11] Bugfix: Decorations could not be enabled after window creation (#1566) - [X11] Bugfix: Content scale fallback value could be inconsistent (#1578) + - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) ## Contact diff --git a/src/wl_window.c b/src/wl_window.c index 07fe64eb46..a90257189c 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -904,7 +904,7 @@ static char *translateCursorShape(int shape) case GLFW_CROSSHAIR_CURSOR: return "crosshair"; case GLFW_HAND_CURSOR: - return "grabbing"; + return "hand2"; case GLFW_HRESIZE_CURSOR: return "sb_h_double_arrow"; case GLFW_VRESIZE_CURSOR: From 9db0bd45e68d573f463895945224f636bd8bae95 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Thu, 28 Nov 2019 15:47:09 +0100 Subject: [PATCH 107/167] Wayland: Unset the cursor name on border exit It would previously conserve the last name it had before leaving the border, sometimes desynchronising with what it should have been. (cherry picked from commit ef6189f348d7f911afe640e6b817e2e945dc86a1) --- src/wl_init.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wl_init.c b/src/wl_init.c index d64e2e353e..97b53673f1 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -125,6 +125,7 @@ static void pointerHandleLeave(void* data, _glfw.wl.serial = serial; _glfw.wl.pointerFocus = NULL; _glfwInputCursorEnter(window, GLFW_FALSE); + _glfw.wl.cursorPreviousName = NULL; } static void setCursor(_GLFWwindow* window, const char* name) @@ -196,6 +197,7 @@ static void pointerHandleMotion(void* data, window->wl.cursorPosX = x; window->wl.cursorPosY = y; _glfwInputCursorPos(window, x, y); + _glfw.wl.cursorPreviousName = NULL; return; case topDecoration: if (y < _GLFW_DECORATION_WIDTH) From 58c16214811dedc245cd2911ed05b8ee16a05c60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 14 Nov 2019 21:07:29 +0100 Subject: [PATCH 108/167] Add Xcode section to .gitignore file (cherry picked from commit 382943f2b006badfdfdc549187aa470bf4b54bf7) --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index cd1d9213a8..3b989ac986 100644 --- a/.gitignore +++ b/.gitignore @@ -15,9 +15,12 @@ Debug Release MinSizeRel RelWithDebInfo -*.xcodeproj *.opensdf +# Xcode clutter +GLFW.build +GLFW.xcodeproj + # macOS clutter .DS_Store From 17d727cd35e7a61ee52d7b2fa2a03d061a35182b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 28 Nov 2019 00:37:30 +0100 Subject: [PATCH 109/167] Cocoa: Update outdated comment (cherry picked from commit b3544ca43e2fd328aa084f118789c7eeda5869a8) --- src/cocoa_init.m | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/cocoa_init.m b/src/cocoa_init.m index 62a3cfabc3..fd077e15bb 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -431,9 +431,8 @@ - (void)applicationWillFinishLaunching:(NSNotification *)notification // In case we are unbundled, make us a proper UI application [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; - // Menu bar setup must go between sharedApplication above and - // finishLaunching below, in order to properly emulate the behavior - // of NSApplicationMain + // Menu bar setup must go between sharedApplication and finishLaunching + // in order to properly emulate the behavior of NSApplicationMain if ([[NSBundle mainBundle] pathForResource:@"MainMenu" ofType:@"nib"]) { From 2da4adce40d6852667d8bbc5b9eb8cc4de41605e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 27 Nov 2019 23:21:13 +0100 Subject: [PATCH 110/167] Cocoa: Fix pre-window-creation event processing Polling the event queue before NSApp had been allowed to finish launching, in our case by starting our self-terminating run loop, triggered an assertion inside NSApplication. This fix, which makes all event processing functions capable of starting it, makes that assertion less likely. A more Cocoa-friendly fix would be to finish launching NSApp during glfwInit and let people annoyed by the menu bar disabled it with GLFW_COCOA_MENUBAR. That may not be suitable for 3.3-stable, though. Fixes #1543. (cherry picked from commit 6e6805000ac7ddf39c8c5f6be3e877770cba5083) --- README.md | 1 + src/cocoa_init.m | 4 ++-- src/cocoa_window.m | 15 ++++++++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 92c5ea2af2..b846d66dac 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,7 @@ information on what to include when reporting a bug. - [Cocoa] Bugfix: `glfwSetWindowSize` used a bottom-left anchor point (#1553) - [Cocoa] Bugfix: Window remained on screen after destruction until event poll (#1412) + - [Cocoa] Bugfix: Event processing before window creation would assert (#1543) - [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_init.m b/src/cocoa_init.m index fd077e15bb..6dfb6f5695 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -447,9 +447,9 @@ - (void)applicationWillFinishLaunching:(NSNotification *)notification - (void)applicationDidFinishLaunching:(NSNotification *)notification { - [NSApp stop:nil]; - + _glfw.ns.finishedLaunching = GLFW_TRUE; _glfwPlatformPostEmptyEvent(); + [NSApp stop:nil]; } - (void)applicationDidHide:(NSNotification *)notification diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 61321805ba..5046d58cbe 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -891,10 +891,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, @autoreleasepool { if (!_glfw.ns.finishedLaunching) - { [NSApp run]; - _glfw.ns.finishedLaunching = GLFW_TRUE; - } if (!createNativeWindow(window, wndconfig, fbconfig)) return GLFW_FALSE; @@ -1385,6 +1382,9 @@ void _glfwPlatformPollEvents(void) { @autoreleasepool { + if (!_glfw.ns.finishedLaunching) + [NSApp run]; + for (;;) { NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny @@ -1404,6 +1404,9 @@ void _glfwPlatformWaitEvents(void) { @autoreleasepool { + if (!_glfw.ns.finishedLaunching) + [NSApp run]; + // I wanted to pass NO to dequeue:, and rely on PollEvents to // dequeue and send. For reasons not at all clear to me, passing // NO to dequeue: causes this method never to return. @@ -1422,6 +1425,9 @@ void _glfwPlatformWaitEventsTimeout(double timeout) { @autoreleasepool { + if (!_glfw.ns.finishedLaunching) + [NSApp run]; + NSDate* date = [NSDate dateWithTimeIntervalSinceNow:timeout]; NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:date @@ -1439,6 +1445,9 @@ void _glfwPlatformPostEmptyEvent(void) { @autoreleasepool { + if (!_glfw.ns.finishedLaunching) + [NSApp run]; + NSEvent* event = [NSEvent otherEventWithType:NSEventTypeApplicationDefined location:NSMakePoint(0, 0) modifierFlags:0 From e135210cb3bd9299e1fbfce045d3880b52e3be3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 9 Dec 2019 18:53:29 +0100 Subject: [PATCH 111/167] NSGL: Fix disabling of Retina resolution It appears the default is now YES. Fixes #1442. (cherry picked from commit fa602692455d87e11c9ff5a5fb0681ca6403772a) --- README.md | 2 ++ src/nsgl_context.m | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b846d66dac..9b925a73f0 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,8 @@ information on what to include when reporting a bug. - [X11] Bugfix: Decorations could not be enabled after window creation (#1566) - [X11] Bugfix: Content scale fallback value could be inconsistent (#1578) - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) + - [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer + macOS versions (#1442) ## Contact diff --git a/src/nsgl_context.m b/src/nsgl_context.m index 9cfa4276f9..df1e490cb7 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -361,8 +361,7 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, forParameter:NSOpenGLContextParameterSurfaceOpacity]; } - if (window->ns.retina) - [window->ns.view setWantsBestResolutionOpenGLSurface:YES]; + [window->ns.view setWantsBestResolutionOpenGLSurface:window->ns.retina]; GLint interval = 0; [window->context.nsgl.object setValues:&interval From b05d88796859e001908e4136b0602667e51cdc9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 5 Dec 2019 17:33:11 +0100 Subject: [PATCH 112/167] Fix .gitignore entries for VS with CMake (cherry picked from commit 7dd14a4b2086944e8c936cea14906db4b410f933) --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3b989ac986..9a9305f432 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,8 @@ _ReSharper* *.dir *.vcxproj* *.sln -.vs/ +.vs +CMakeSettings.json Win32 x64 Debug From 5a1512aaa08dbb99d2b37cc3acdc6e75c43bcbb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 25 Nov 2019 19:39:06 +0100 Subject: [PATCH 113/167] Rename CMake variable for GUI-only programs Hopefully this is less ambiguous. (cherry picked from commit 92c70b2a83f8902a018cc53915eecd3f423bc931) --- examples/CMakeLists.txt | 9 +++++---- tests/CMakeLists.txt | 10 +++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 69ef0d455b..e1fbe54448 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -56,15 +56,16 @@ if (RT_LIBRARY) target_link_libraries(particles "${RT_LIBRARY}") endif() -set(WINDOWS_BINARIES boing gears heightmap particles sharing simple splitview wave) +set(GUI_ONLY_BINARIES boing gears heightmap particles sharing simple splitview + wave) set(CONSOLE_BINARIES offscreen) -set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES +set_target_properties(${GUI_ONLY_BINARIES} ${CONSOLE_BINARIES} PROPERTIES FOLDER "GLFW3/Examples") if (MSVC) # Tell MSVC to use main instead of WinMain for Windows subsystem executables - set_target_properties(${WINDOWS_BINARIES} PROPERTIES + set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES LINK_FLAGS "/ENTRY:mainCRTStartup") endif() @@ -78,7 +79,7 @@ if (APPLE) set_target_properties(splitview PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "SplitView") set_target_properties(wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave") - set_target_properties(${WINDOWS_BINARIES} PROPERTIES + set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES RESOURCE glfw.icns MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION} MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c471d8b94f..675592c4ad 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -60,17 +60,17 @@ if (RT_LIBRARY) target_link_libraries(threads "${RT_LIBRARY}") endif() -set(WINDOWS_BINARIES empty gamma icon inputlag joysticks opacity tearing - threads timeout title triangle-vulkan windows) +set(GUI_ONLY_BINARIES empty gamma icon inputlag joysticks opacity tearing + threads timeout title triangle-vulkan windows) set(CONSOLE_BINARIES clipboard events msaa glfwinfo iconify monitors reopen cursor) -set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES +set_target_properties(${GUI_ONLY_BINARIES} ${CONSOLE_BINARIES} PROPERTIES FOLDER "GLFW3/Tests") if (MSVC) # Tell MSVC to use main instead of WinMain for Windows subsystem executables - set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES + set_target_properties(${GUI_ONLY_BINARIES} ${CONSOLE_BINARIES} PROPERTIES LINK_FLAGS "/ENTRY:mainCRTStartup") endif() @@ -87,7 +87,7 @@ if (APPLE) set_target_properties(triangle-vulkan PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Vulkan Triangle") set_target_properties(windows PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Windows") - set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES + set_target_properties(${GUI_ONLY_BINARIES} ${CONSOLE_BINARIES} PROPERTIES MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION} MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION} MACOSX_BUNDLE_INFO_PLIST "${GLFW_SOURCE_DIR}/CMake/MacOSXBundleInfo.plist.in") From 8c1b59f8858cdf02239394e7894dcd5f929b48b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 25 Nov 2019 19:52:02 +0100 Subject: [PATCH 114/167] Remove dependency on platform header paths The tests and examples should not need these paths. (cherry picked from commit d74c18117d73968dc58ac514e416df83ce398617) --- examples/CMakeLists.txt | 2 +- tests/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index e1fbe54448..a3b0589ac1 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,7 +1,7 @@ link_libraries(glfw) -include_directories(${glfw_INCLUDE_DIRS} "${GLFW_SOURCE_DIR}/deps") +include_directories("${GLFW_SOURCE_DIR}/deps") if (MATH_LIBRARY) link_libraries("${MATH_LIBRARY}") diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 675592c4ad..e10d58e3ce 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,7 +1,7 @@ link_libraries(glfw) -include_directories(${glfw_INCLUDE_DIRS} "${GLFW_SOURCE_DIR}/deps") +include_directories("${GLFW_SOURCE_DIR}/deps") if (MATH_LIBRARY) link_libraries("${MATH_LIBRARY}") From f650a898f28b4fc53af79ff5b300369047a3067e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 26 Nov 2019 18:14:21 +0100 Subject: [PATCH 115/167] Trust CMake to do the right thing for static libs CMake understands what private library dependencies for a static library means and handles it correctly. (cherry picked from commit f6d44cedfdf5d61ce5acd461da5a9eadd01e6898) --- src/CMakeLists.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6cbeed6d60..fc5ba016c0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -120,6 +120,7 @@ target_include_directories(glfw PRIVATE "${GLFW_SOURCE_DIR}/src" "${GLFW_BINARY_DIR}/src" ${glfw_INCLUDE_DIRS}) +target_link_libraries(glfw PRIVATE ${glfw_LIBRARIES}) # HACK: When building on MinGW, WINVER and UNICODE need to be defined before # the inclusion of stddef.h (by glfw3.h), which is itself included before @@ -164,10 +165,6 @@ if (BUILD_SHARED_LIBS) # Hide symbols not explicitly tagged for export from the shared library target_compile_options(glfw PRIVATE "-fvisibility=hidden") endif() - - target_link_libraries(glfw PRIVATE ${glfw_LIBRARIES}) -else() - target_link_libraries(glfw INTERFACE ${glfw_LIBRARIES}) endif() if (MSVC) From bcd232e2ae28b26f0705a4c8a5ea0ab86bd94ffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 26 Nov 2019 18:18:40 +0100 Subject: [PATCH 116/167] Remove tab character (cherry picked from commit bc7b19cbd1e4d52660743965a31b2349c74962af) --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fc5ba016c0..8530909ec8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -152,7 +152,7 @@ if (BUILD_SHARED_LIBS) set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.lib") endif() - target_compile_definitions(glfw INTERFACE GLFW_DLL) + target_compile_definitions(glfw INTERFACE GLFW_DLL) elseif (APPLE) # Add -fno-common to work around a bug in Apple's GCC target_compile_options(glfw PRIVATE "-fno-common") From 82bd22ec2968ceeea716a706f5f41359d3bce32f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 27 Nov 2019 17:58:05 +0100 Subject: [PATCH 117/167] Fix source list for -Wdeclaration-after-statement The context creation files were not included on platforms other than Win32. (cherry picked from commit 9486ec0c0223dc4e5f51a44fdc9c7d28b5a1d059) --- src/CMakeLists.txt | 13 ++++++------- src/egl_context.c | 29 +++++++++++++++-------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8530909ec8..306e47ff6b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -83,13 +83,12 @@ if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang") - if (WIN32) - set(windows_SOURCES ${glfw_SOURCES}) - else() - set(windows_SOURCES ${common_SOURCES}) - endif() - set_source_files_properties(${windows_SOURCES} PROPERTIES - COMPILE_FLAGS -Wdeclaration-after-statement) + set_source_files_properties(context.c init.c input.c monitor.c vulkan.c + window.c win32_init.c win32_joystick.c + win32_monitor.c win32_time.c win32_thread.c + win32_window.c wgl_context.c egl_context.c + osmesa_context.c PROPERTIES + COMPILE_FLAGS -Wdeclaration-after-statement) endif() add_library(glfw ${glfw_SOURCES} ${glfw_HEADERS}) diff --git a/src/egl_context.c b/src/egl_context.c index 0b93e72d26..e458bfb87e 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -123,23 +123,24 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig, continue; #if defined(_GLFW_X11) - XVisualInfo vi = {0}; + { + XVisualInfo vi = {0}; - // Only consider EGLConfigs with associated Visuals - vi.visualid = getEGLConfigAttrib(n, EGL_NATIVE_VISUAL_ID); - if (!vi.visualid) - continue; + // Only consider EGLConfigs with associated Visuals + vi.visualid = getEGLConfigAttrib(n, EGL_NATIVE_VISUAL_ID); + if (!vi.visualid) + continue; - if (desired->transparent) - { - int count; - XVisualInfo* vis = XGetVisualInfo(_glfw.x11.display, - VisualIDMask, &vi, - &count); - if (vis) + if (desired->transparent) { - u->transparent = _glfwIsVisualTransparentX11(vis[0].visual); - XFree(vis); + int count; + XVisualInfo* vis = + XGetVisualInfo(_glfw.x11.display, VisualIDMask, &vi, &count); + if (vis) + { + u->transparent = _glfwIsVisualTransparentX11(vis[0].visual); + XFree(vis); + } } } #endif // _GLFW_X11 From db2ff13d4173ab00df90e28d8ecabc18c4972d30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 3 Dec 2019 23:08:17 +0100 Subject: [PATCH 118/167] Fix source list for Objective-C fix (cherry picked from commit 197193ac0b37979a1b8fa95f568a4e5fb7bc8bac) --- src/CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 306e47ff6b..4c59196c0c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -73,8 +73,10 @@ if (_GLFW_X11 OR _GLFW_WAYLAND) endif() if (APPLE) - # For some reason, CMake doesn't know about .m - set_source_files_properties(${glfw_SOURCES} PROPERTIES LANGUAGE C) + # For some reason CMake didn't know about .m until version 3.16 + set_source_files_properties(cocoa_init.m cocoa_joystick.m cocoa_monitor.m + cocoa_window.m nsgl_context.m PROPERTIES + LANGUAGE C) endif() # Make GCC and Clang warn about declarations that VS 2010 and 2012 won't accept From f318ab74673d5d7e2ac52e9d741e0807e12fa3d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 20 Nov 2019 22:20:37 +0100 Subject: [PATCH 119/167] Remove unneccessary example target property Bundle icon file copying is performed by MACOSX_PACKAGE_LOCATION. (cherry picked from commit c81def70be066e650ca46e67ce7b42bbc970e146) --- examples/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index a3b0589ac1..7f203e4389 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -80,7 +80,6 @@ if (APPLE) set_target_properties(wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave") set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES - RESOURCE glfw.icns MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION} MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION} MACOSX_BUNDLE_ICON_FILE glfw.icns From cd70e1bbc45f033265d92fcc54f7c56e52c9c5a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sat, 7 Dec 2019 21:03:14 +0100 Subject: [PATCH 120/167] Merge GCC/Clang specific CMake blocks (cherry picked from commit 9dc365f192a8c32ba8aa50a59aa169e2cea03002) --- src/CMakeLists.txt | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4c59196c0c..ae2f0eaba6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -79,20 +79,6 @@ if (APPLE) LANGUAGE C) endif() -# Make GCC and Clang warn about declarations that VS 2010 and 2012 won't accept -# for all source files that VS will build -if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR - "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR - "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang") - - set_source_files_properties(context.c init.c input.c monitor.c vulkan.c - window.c win32_init.c win32_joystick.c - win32_monitor.c win32_time.c win32_thread.c - win32_window.c wgl_context.c egl_context.c - osmesa_context.c PROPERTIES - COMPILE_FLAGS -Wdeclaration-after-statement) -endif() - add_library(glfw ${glfw_SOURCES} ${glfw_HEADERS}) set_target_properties(glfw PROPERTIES OUTPUT_NAME ${GLFW_LIB_NAME} @@ -123,6 +109,23 @@ target_include_directories(glfw PRIVATE ${glfw_INCLUDE_DIRS}) target_link_libraries(glfw PRIVATE ${glfw_LIBRARIES}) +if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR + "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR + "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang") + + # Make GCC and Clang warn about declarations that VS 2010 and 2012 won't + # accept for all source files that VS will build + set_source_files_properties(context.c init.c input.c monitor.c vulkan.c + window.c win32_init.c win32_joystick.c + win32_monitor.c win32_time.c win32_thread.c + win32_window.c wgl_context.c egl_context.c + osmesa_context.c PROPERTIES + COMPILE_FLAGS -Wdeclaration-after-statement) + + # Enable a reasonable set of warnings (no, -Wextra is not reasonable) + target_compile_options(glfw PRIVATE "-Wall") +endif() + # HACK: When building on MinGW, WINVER and UNICODE need to be defined before # the inclusion of stddef.h (by glfw3.h), which is itself included before # win32_platform.h. We define them here until a saner solution can be found @@ -130,12 +133,6 @@ target_link_libraries(glfw PRIVATE ${glfw_LIBRARIES}) target_compile_definitions(glfw PRIVATE "$<$:UNICODE;WINVER=0x0501>") -# Enable a reasonable set of warnings (no, -Wextra is not reasonable) -target_compile_options(glfw PRIVATE - "$<$:-Wall>" - "$<$:-Wall>" - "$<$:-Wall>") - if (BUILD_SHARED_LIBS) if (WIN32) if (MINGW) From 03f2cde34e9e3189f852ced0fef86341484514f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sat, 7 Dec 2019 21:05:56 +0100 Subject: [PATCH 121/167] Replace CMake generator expression with variable Generator expressions are amazing but best used in moderation. (cherry picked from commit c194193797d454f46ccdf08f2ce7b7bff33f637f) --- src/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ae2f0eaba6..cf82f0f6c8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -130,8 +130,9 @@ endif() # the inclusion of stddef.h (by glfw3.h), which is itself included before # win32_platform.h. We define them here until a saner solution can be found # NOTE: MinGW-w64 and Visual C++ do /not/ need this hack. -target_compile_definitions(glfw PRIVATE - "$<$:UNICODE;WINVER=0x0501>") +if (MINGW) + target_compile_definitions(glfw PRIVATE UNICODE WINVER=0x0501) +endif() if (BUILD_SHARED_LIBS) if (WIN32) From b5bccd1425f6bd29774d093b43337b5cab1badbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 9 Dec 2019 17:04:34 +0100 Subject: [PATCH 122/167] Make target-specific define target-specific (cherry picked from commit db76abb63c257a45a04cbfa9810c3b1692990510) --- examples/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 7f203e4389..aa453d7192 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -11,10 +11,6 @@ if (MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS) endif() -if (GLFW_USE_OSMESA) - add_definitions(-DUSE_NATIVE_OSMESA) -endif() - if (WIN32) set(ICON glfw.rc) elseif (APPLE) @@ -63,6 +59,10 @@ set(CONSOLE_BINARIES offscreen) set_target_properties(${GUI_ONLY_BINARIES} ${CONSOLE_BINARIES} PROPERTIES FOLDER "GLFW3/Examples") +if (GLFW_USE_OSMESA) + target_compile_definitions(offscreen PRIVATE USE_NATIVE_OSMESA) +endif() + if (MSVC) # Tell MSVC to use main instead of WinMain for Windows subsystem executables set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES From f25202fbfa8c9c3bf11ff7b23b2dc1e713409e99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 9 Dec 2019 21:26:02 +0100 Subject: [PATCH 123/167] Remove non-GUI binaries from GUI-only setup (cherry picked from commit c016b26852075e1eba87b29a9e22c127a97a5825) --- tests/CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e10d58e3ce..6c6cd55a8a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -70,7 +70,7 @@ set_target_properties(${GUI_ONLY_BINARIES} ${CONSOLE_BINARIES} PROPERTIES if (MSVC) # Tell MSVC to use main instead of WinMain for Windows subsystem executables - set_target_properties(${GUI_ONLY_BINARIES} ${CONSOLE_BINARIES} PROPERTIES + set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES LINK_FLAGS "/ENTRY:mainCRTStartup") endif() @@ -84,10 +84,9 @@ if (APPLE) set_target_properties(threads PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Threads") set_target_properties(timeout PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Timeout") set_target_properties(title PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Title") - set_target_properties(triangle-vulkan PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Vulkan Triangle") set_target_properties(windows PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Windows") - set_target_properties(${GUI_ONLY_BINARIES} ${CONSOLE_BINARIES} PROPERTIES + set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION} MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION} MACOSX_BUNDLE_INFO_PLIST "${GLFW_SOURCE_DIR}/CMake/MacOSXBundleInfo.plist.in") From bf9c5fcfc28d1685212d5d4ab94f4e6080972147 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 9 Dec 2019 21:59:21 +0100 Subject: [PATCH 124/167] Gather all macOS specific CMake properties (cherry picked from commit 5f4a6f689adc739a8aa5fc961dfdf3de54b40edb) --- examples/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index aa453d7192..a884e6bc1d 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -15,8 +15,6 @@ if (WIN32) set(ICON glfw.rc) elseif (APPLE) set(ICON glfw.icns) - set_source_files_properties(glfw.icns PROPERTIES - MACOSX_PACKAGE_LOCATION "Resources") endif() if (${CMAKE_VERSION} VERSION_EQUAL "3.1.0" OR @@ -79,6 +77,8 @@ if (APPLE) set_target_properties(splitview PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "SplitView") set_target_properties(wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave") + set_source_files_properties(glfw.icns PROPERTIES + MACOSX_PACKAGE_LOCATION "Resources") set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION} MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION} From d8648876dad95811af7431d6e5526af25c6afac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 9 Dec 2019 22:01:29 +0100 Subject: [PATCH 125/167] Remove reference to non-existent CMake variable (cherry picked from commit 8a1f4940fcccacdd8fb51578d75a9fdf37ad71df) --- tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6c6cd55a8a..5232720f2a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -50,7 +50,7 @@ add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c ${GLAD_GL}) add_executable(threads WIN32 MACOSX_BUNDLE threads.c ${TINYCTHREAD} ${GLAD_GL}) add_executable(timeout WIN32 MACOSX_BUNDLE timeout.c ${GLAD_GL}) add_executable(title WIN32 MACOSX_BUNDLE title.c ${GLAD_GL}) -add_executable(triangle-vulkan WIN32 triangle-vulkan.c ${ICON} ${GLAD_VULKAN}) +add_executable(triangle-vulkan WIN32 triangle-vulkan.c ${GLAD_VULKAN}) add_executable(windows WIN32 MACOSX_BUNDLE windows.c ${GETOPT} ${GLAD_GL}) target_link_libraries(empty "${CMAKE_THREAD_LIBS_INIT}") From 365321a9af4dc0db7c40236406d4d8ac148f18a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 10 Dec 2019 10:40:48 +0100 Subject: [PATCH 126/167] Add dependency name hints to CMake error messages Fixes #1605. (cherry picked from commit a43f54567773c38ee9dda4ab6b6a65fd58a67080) --- CMakeLists.txt | 12 ++++++------ README.md | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a07c964551..96e9e041c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,7 +71,7 @@ if (MSVC) include(CheckIncludeFile) check_include_file(dinput.h DINPUT_H_FOUND) if (NOT DINPUT_H_FOUND) - message(FATAL_ERROR "DirectX 9 SDK not found") + message(FATAL_ERROR "DirectX 9 headers not found; install DirectX 9 SDK") endif() # Workaround for VS 2008 not shipping with stdint.h list(APPEND glfw_INCLUDE_DIRS "${GLFW_SOURCE_DIR}/deps/vs2008") @@ -203,27 +203,27 @@ if (_GLFW_X11) # Check for XRandR (modern resolution switching and gamma control) if (NOT X11_Xrandr_INCLUDE_PATH) - message(FATAL_ERROR "The RandR headers were not found") + message(FATAL_ERROR "RandR headers not found; install libxrandr development package") endif() # Check for Xinerama (legacy multi-monitor support) if (NOT X11_Xinerama_INCLUDE_PATH) - message(FATAL_ERROR "The Xinerama headers were not found") + message(FATAL_ERROR "Xinerama headers not found; install libxinerama development package") endif() # Check for Xkb (X keyboard extension) if (NOT X11_Xkb_INCLUDE_PATH) - message(FATAL_ERROR "The X keyboard extension headers were not found") + message(FATAL_ERROR "XKB headers not found; install X11 development package") endif() # Check for Xcursor (cursor creation from RGBA images) if (NOT X11_Xcursor_INCLUDE_PATH) - message(FATAL_ERROR "The Xcursor headers were not found") + message(FATAL_ERROR "Xcursor headers not found; install libxcursor development package") endif() # Check for XInput (modern HID input) if (NOT X11_Xi_INCLUDE_PATH) - message(FATAL_ERROR "The XInput headers were not found") + message(FATAL_ERROR "XInput headers not found; install libxi development package") endif() list(APPEND glfw_INCLUDE_DIRS "${X11_Xrandr_INCLUDE_PATH}" diff --git a/README.md b/README.md index 9b925a73f0..26c0ec8a37 100644 --- a/README.md +++ b/README.md @@ -292,6 +292,7 @@ skills. - Alexandre Pretyman - Pablo Prietz - przemekmirek + - pthom - Guillaume Racicot - Philip Rideout - Eddie Ringle From 39c5e90d94f217ecfa214b3d8de4e2cd43c925b4 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Wed, 28 Aug 2019 21:28:23 +0200 Subject: [PATCH 127/167] Fix typo Fixes #1601. (cherry picked from commit ac30ef3e0c6cac8bbd54b142eadfedd8dd3fe91b) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 26c0ec8a37..81f31bdf85 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ application development. It provides a simple, platform-independent API for creating windows, contexts and surfaces, reading input, handling events, etc. GLFW natively supports Windows, macOS and Linux and other Unix-like systems. On -Linux both X11 and Wayland is supported. +Linux both X11 and Wayland are supported. GLFW is licensed under the [zlib/libpng license](http://www.glfw.org/license.html). From 2b1e2d2e4957461a47ad6dac3256b1e3f42c0e79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 10 Dec 2019 20:10:12 +0100 Subject: [PATCH 128/167] Fix typo (cherry picked from commit 7e03bce1387696918bef4a7022cb5cc3db39e2ea) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 81f31bdf85..2bd0a9b848 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ in the documentation for more information. GLFW itself depends only on the headers and libraries for your window system. The (experimental) Wayland backend also depends on the `extra-cmake-modules` -package, which is used to generated Wayland protocol headers. +package, which is used to generate Wayland protocol headers. The examples and test programs depend on a number of tiny libraries. These are located in the `deps/` directory. From 8c3d2f769fc83e4a079d642381cf04453e7b44aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 10 Dec 2019 13:47:19 +0100 Subject: [PATCH 129/167] Cocoa: Fix duplicate conversion of title string (cherry picked from commit a875a536b76233d7f3024cf9aec17086aa6bc795) --- src/cocoa_window.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 5046d58cbe..3cf8dd3e79 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -967,10 +967,11 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window) void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char *title) { @autoreleasepool { - [window->ns.object setTitle:@(title)]; + NSString* string = @(title); + [window->ns.object setTitle:string]; // HACK: Set the miniwindow title explicitly as setTitle: doesn't update it // if the window lacks NSWindowStyleMaskTitled - [window->ns.object setMiniwindowTitle:@(title)]; + [window->ns.object setMiniwindowTitle:string]; } // autoreleasepool } From 9724f330387848416320fe2d8b4d9df5b7c8ed03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 11 Dec 2019 22:10:00 +0100 Subject: [PATCH 130/167] Formatting (cherry picked from commit 506a6aafdee2bb043da5cef6e28377466dda2f09) --- 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 3cf8dd3e79..00cecd5a21 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -964,7 +964,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window) } // autoreleasepool } -void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char *title) +void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) { @autoreleasepool { NSString* string = @(title); From e8dab396252a77cad1604afae212ed59ed18ac53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 15 Dec 2019 09:03:22 +0100 Subject: [PATCH 131/167] Fix use of CMake 3.13 command target_link_options (cherry picked from commit a5ed740d9d97580e162e07cbd36648969c61688b) --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cf82f0f6c8..d25bcadb75 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -139,7 +139,7 @@ if (BUILD_SHARED_LIBS) if (MINGW) # Remove the dependency on the shared version of libgcc # NOTE: MinGW-w64 has the correct default but MinGW needs this - target_link_options(glfw PRIVATE "-static-libgcc") + target_link_libraries(glfw PRIVATE "-static-libgcc") # Remove the lib prefix on the DLL (but not the import library) set_target_properties(glfw PROPERTIES PREFIX "") From dd00c6dea161194a56621c7bdfc68017ba7bb184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 15 Dec 2019 16:33:18 +0100 Subject: [PATCH 132/167] Win32: Enable Unicode mode for all compilers (cherry picked from commit fb0028c766c6404acabc2c8e582b0129fc966c3b) --- src/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d25bcadb75..891302edad 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -126,6 +126,10 @@ if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR target_compile_options(glfw PRIVATE "-Wall") endif() +if (WIN32) + target_compile_definitions(glfw PRIVATE _UNICODE) +endif() + # HACK: When building on MinGW, WINVER and UNICODE need to be defined before # the inclusion of stddef.h (by glfw3.h), which is itself included before # win32_platform.h. We define them here until a saner solution can be found From 640e3205a94ab8f1705c688a6e2a8e351f1e2edd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 15 Dec 2019 17:36:55 +0100 Subject: [PATCH 133/167] Win32: Add missing include for wcscmp (cherry picked from commit da3f20d860deb39b0e5db497bbaaaef8ad01bec6) --- src/win32_monitor.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/win32_monitor.c b/src/win32_monitor.c index 03496411ac..4f5af36a4c 100644 --- a/src/win32_monitor.c +++ b/src/win32_monitor.c @@ -33,6 +33,7 @@ #include #include #include +#include // Callback for EnumDisplayMonitors in createMonitor From 8dd40f1c48161df33cce9d9a6d1cdc05ca52dd3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 16 Dec 2019 14:53:06 +0100 Subject: [PATCH 134/167] X11: Fix maximization of hidden windows This fixes glfwMaximizeWindow having no effect on hidden windows by manually appending the maximization states to the EWMH state property. (cherry picked from commit 4837b78ffe48aa9fab7a9657347b77cba104979a) --- README.md | 1 + src/x11_window.c | 67 +++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 59 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 2bd0a9b848..e6629bdcb0 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,7 @@ information on what to include when reporting a bug. (#1462,#1528) - [X11] Bugfix: Decorations could not be enabled after window creation (#1566) - [X11] Bugfix: Content scale fallback value could be inconsistent (#1578) + - [X11] Bugfix: `glfwMaximizeWindow` had no effect on hidden windows - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer macOS versions (#1442) diff --git a/src/x11_window.c b/src/x11_window.c index 85d548a63c..dfd66098d8 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2340,18 +2340,67 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window) void _glfwPlatformMaximizeWindow(_GLFWwindow* window) { - if (_glfw.x11.NET_WM_STATE && - _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT && - _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ) + if (!_glfw.x11.NET_WM_STATE || + !_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT || + !_glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ) + { + return; + } + + if (_glfwPlatformWindowVisible(window)) { sendEventToWM(window, - _glfw.x11.NET_WM_STATE, - _NET_WM_STATE_ADD, - _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT, - _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ, - 1, 0); - XFlush(_glfw.x11.display); + _glfw.x11.NET_WM_STATE, + _NET_WM_STATE_ADD, + _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT, + _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ, + 1, 0); } + else + { + Atom* states = NULL; + unsigned long count = + _glfwGetWindowPropertyX11(window->x11.handle, + _glfw.x11.NET_WM_STATE, + XA_ATOM, + (unsigned char**) &states); + + // NOTE: We don't check for failure as this property may not exist yet + // and that's fine (and we'll create it implicitly with append) + + Atom missing[2] = + { + _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT, + _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ + }; + unsigned long missingCount = 2; + + for (unsigned long i = 0; i < count; i++) + { + for (unsigned long j = 0; j < missingCount; j++) + { + if (states[i] == missing[j]) + { + missing[j] = missing[missingCount - 1]; + missingCount--; + } + } + } + + if (states) + XFree(states); + + if (!missingCount) + return; + + XChangeProperty(_glfw.x11.display, window->x11.handle, + _glfw.x11.NET_WM_STATE, XA_ATOM, 32, + PropModeAppend, + (unsigned char*) missing, + missingCount); + } + + XFlush(_glfw.x11.display); } void _glfwPlatformShowWindow(_GLFWwindow* window) From 5615c16439ece2da9af283d7af52459a84635cd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 16 Dec 2019 15:08:54 +0100 Subject: [PATCH 135/167] X11: Fix missing checks for EWMH attention atoms (cherry picked from commit 9b6d68ec70da775c4e2bf6481f86117cf9d9f551) --- src/x11_window.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/x11_window.c b/src/x11_window.c index dfd66098d8..48e68dae17 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2420,6 +2420,9 @@ void _glfwPlatformHideWindow(_GLFWwindow* window) void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) { + if (!_glfw.x11.NET_WM_STATE || !_glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION) + return; + sendEventToWM(window, _glfw.x11.NET_WM_STATE, _NET_WM_STATE_ADD, From 85a27e9f747c5b00b2a62981a93e43a037a434a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 17 Dec 2019 01:43:08 +0100 Subject: [PATCH 136/167] X11: Fix invalid read when clearing GLFW_FLOATING (cherry picked from commit 0b652a44d2afe593d6eca8a0d586c20555a0497c) --- README.md | 1 + src/x11_window.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e6629bdcb0..55698e8df4 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,7 @@ information on what to include when reporting a bug. - [X11] Bugfix: Decorations could not be enabled after window creation (#1566) - [X11] Bugfix: Content scale fallback value could be inconsistent (#1578) - [X11] Bugfix: `glfwMaximizeWindow` had no effect on hidden windows + - [X11] Bugfix: Clearing `GLFW_FLOATING` on a hidden window caused invalid read - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer macOS versions (#1442) diff --git a/src/x11_window.c b/src/x11_window.c index 48e68dae17..8f3844af8c 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2668,7 +2668,7 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled) XChangeProperty(_glfw.x11.display, window->x11.handle, _glfw.x11.NET_WM_STATE, XA_ATOM, 32, - PropModeReplace, (unsigned char*) &states, count); + PropModeReplace, (unsigned char*) states, count); } XFree(states); From 94bb2a138e200308ce8fc908dc74f74c2f071ccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 16 Dec 2019 16:09:52 +0100 Subject: [PATCH 137/167] X11: Fix updating GLFW_FLOATING on a hidden window (cherry picked from commit 9db156421f038e5a269a63d59e509f4fb1e2392b) --- README.md | 1 + src/x11_window.c | 39 ++++++++++++++++++++++----------------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 55698e8df4..e0b33979db 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,7 @@ information on what to include when reporting a bug. - [X11] Bugfix: Content scale fallback value could be inconsistent (#1578) - [X11] Bugfix: `glfwMaximizeWindow` had no effect on hidden windows - [X11] Bugfix: Clearing `GLFW_FLOATING` on a hidden window caused invalid read + - [X11] Bugfix: Changing `GLFW_FLOATING` on a hidden window could silently fail - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer macOS versions (#1442) diff --git a/src/x11_window.c b/src/x11_window.c index 8f3844af8c..6c586c9c56 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2628,15 +2628,16 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled) } else { - Atom* states; + Atom* states = NULL; unsigned long i, count; count = _glfwGetWindowPropertyX11(window->x11.handle, _glfw.x11.NET_WM_STATE, XA_ATOM, (unsigned char**) &states); - if (!states) - return; + + // NOTE: We don't check for failure as this property may not exist yet + // and that's fine (and we'll create it implicitly with append) if (enabled) { @@ -2646,32 +2647,36 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled) break; } - if (i == count) - { - XChangeProperty(_glfw.x11.display, window->x11.handle, - _glfw.x11.NET_WM_STATE, XA_ATOM, 32, - PropModeAppend, - (unsigned char*) &_glfw.x11.NET_WM_STATE_ABOVE, - 1); - } + if (i < count) + return; + + XChangeProperty(_glfw.x11.display, window->x11.handle, + _glfw.x11.NET_WM_STATE, XA_ATOM, 32, + PropModeAppend, + (unsigned char*) &_glfw.x11.NET_WM_STATE_ABOVE, + 1); } - else + else if (states) { for (i = 0; i < count; i++) { if (states[i] == _glfw.x11.NET_WM_STATE_ABOVE) - { - states[i] = states[count - 1]; - count--; - } + break; } + if (i == count) + return; + + states[i] = states[count - 1]; + count--; + XChangeProperty(_glfw.x11.display, window->x11.handle, _glfw.x11.NET_WM_STATE, XA_ATOM, 32, PropModeReplace, (unsigned char*) states, count); } - XFree(states); + if (states) + XFree(states); } XFlush(_glfw.x11.display); From 4df0a2b38eaaee966ab5bf8c121d5468d3a6ec23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 16 Dec 2019 17:44:17 +0100 Subject: [PATCH 138/167] X11: Cleanup The window state action is not an atom. (cherry picked from commit 4e70c95aa3bcb666320e17f2097f33d18a7fc225) --- src/x11_window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/x11_window.c b/src/x11_window.c index 6c586c9c56..3ea50fffa5 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2619,7 +2619,7 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled) if (_glfwPlatformWindowVisible(window)) { - const Atom action = enabled ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE; + const long action = enabled ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE; sendEventToWM(window, _glfw.x11.NET_WM_STATE, action, From c3b8afc5d699df607e83164eb4b8dac069ec6e30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 17 Dec 2019 02:17:31 +0100 Subject: [PATCH 139/167] X11: Cleanup This is technically valid but misleading and may inspire future bugs like the one fixed by 0b652a44d2afe593d6eca8a0d586c20555a0497c. (cherry picked from commit 73a8ebb691813ccdc1531c1bd916c352ac0b7574) --- src/x11_window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/x11_window.c b/src/x11_window.c index 3ea50fffa5..0ec3c16540 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -682,7 +682,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window, { XChangeProperty(_glfw.x11.display, window->x11.handle, _glfw.x11.NET_WM_STATE, XA_ATOM, 32, - PropModeReplace, (unsigned char*) &states, count); + PropModeReplace, (unsigned char*) states, count); } } From 7c9d0081e3a70f91949c3dff40fcce1bbb28ba8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 19 Dec 2019 08:43:01 +0100 Subject: [PATCH 140/167] Cocoa: Only create per-monitor display link once The display link query is not specific to any particular display mode and so only needs to be done once. The next step is to replace the display link altogether by querying IOKit directly, which is what the display link does. (cherry picked from commit b4a8eb9b197caebcec1304cd3d55cd56e3869376) --- src/cocoa_monitor.m | 53 ++++++++++++++++++++++++++------------------ src/cocoa_platform.h | 1 + 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index bb526732fa..13d463f1b7 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -144,7 +144,7 @@ static GLFWbool modeIsGood(CGDisplayModeRef mode) // Convert Core Graphics display mode to GLFW video mode // static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode, - CVDisplayLinkRef link) + double fallbackRefreshRate) { GLFWvidmode result; result.width = (int) CGDisplayModeGetWidth(mode); @@ -152,11 +152,7 @@ static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode, result.refreshRate = (int) round(CGDisplayModeGetRefreshRate(mode)); if (result.refreshRate == 0) - { - const CVTime time = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(link); - if (!(time.flags & kCVTimeIsIndefinite)) - result.refreshRate = (int) (time.timeScale / (double) time.timeValue); - } + result.refreshRate = (int) round(fallbackRefreshRate); #if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100 CFStringRef format = CGDisplayModeCopyPixelEncoding(mode); @@ -238,6 +234,29 @@ static GLFWbool refreshMonitorScreen(_GLFWmonitor* monitor) return GLFW_FALSE; } +// Returns a fallback refresh rate for when Core Graphics says it is zero +// +static double getFallbackRefreshRate(_GLFWmonitor* monitor) +{ + CGDisplayModeRef mode = CGDisplayCopyDisplayMode(monitor->ns.displayID); + double refreshRate = CGDisplayModeGetRefreshRate(mode); + CGDisplayModeRelease(mode); + + if (refreshRate == 0.0) + { + CVDisplayLinkRef link = NULL; + CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link); + + const CVTime time = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(link); + if (!(time.flags & kCVTimeIsIndefinite)) + refreshRate = (int) (time.timeScale / (double) time.timeValue); + + CVDisplayLinkRelease(link); + } + + return refreshRate; +} + ////////////////////////////////////////////////////////////////////////// ////// GLFW internal API ////// @@ -291,6 +310,7 @@ void _glfwPollMonitorsNS(void) _GLFWmonitor* monitor = _glfwAllocMonitor(name, size.width, size.height); monitor->ns.displayID = displays[i]; monitor->ns.unitNumber = unitNumber; + monitor->ns.fallbackRefreshRate = getFallbackRefreshRate(monitor); free(name); @@ -318,9 +338,6 @@ void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired) if (_glfwCompareVideoModes(¤t, best) == 0) return; - CVDisplayLinkRef link; - CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link); - CFArrayRef modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL); const CFIndex count = CFArrayGetCount(modes); CGDisplayModeRef native = NULL; @@ -331,7 +348,8 @@ void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired) if (!modeIsGood(dm)) continue; - const GLFWvidmode mode = vidmodeFromCGDisplayMode(dm, link); + const GLFWvidmode mode = + vidmodeFromCGDisplayMode(dm, monitor->ns.fallbackRefreshRate); if (_glfwCompareVideoModes(best, &mode) == 0) { native = dm; @@ -350,7 +368,6 @@ void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired) } CFRelease(modes); - CVDisplayLinkRelease(link); } // Restore the previously saved (original) video mode @@ -440,9 +457,6 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, *count = 0; - CVDisplayLinkRef link; - CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link); - CFArrayRef modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL); const CFIndex found = CFArrayGetCount(modes); GLFWvidmode* result = calloc(found, sizeof(GLFWvidmode)); @@ -453,7 +467,8 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, if (!modeIsGood(dm)) continue; - const GLFWvidmode mode = vidmodeFromCGDisplayMode(dm, link); + const GLFWvidmode mode = + vidmodeFromCGDisplayMode(dm, monitor->ns.fallbackRefreshRate); CFIndex j; for (j = 0; j < *count; j++) @@ -471,7 +486,6 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, } CFRelease(modes); - CVDisplayLinkRelease(link); return result; } // autoreleasepool @@ -481,15 +495,10 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode) { @autoreleasepool { - CVDisplayLinkRef link; - CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link); - CGDisplayModeRef native = CGDisplayCopyDisplayMode(monitor->ns.displayID); - *mode = vidmodeFromCGDisplayMode(native, link); + *mode = vidmodeFromCGDisplayMode(native, monitor->ns.fallbackRefreshRate); CGDisplayModeRelease(native); - CVDisplayLinkRelease(link); - } // autoreleasepool } diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index b29b64c8d4..2b7371a1ea 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -170,6 +170,7 @@ typedef struct _GLFWmonitorNS CGDisplayModeRef previousMode; uint32_t unitNumber; id screen; + double fallbackRefreshRate; } _GLFWmonitorNS; From ccb54c3e05e6d7d2e1e3b9bebc2a33366233b0da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 7 Nov 2019 15:13:49 +0100 Subject: [PATCH 141/167] NSGL: Remove problematic swap interval workaround Fixes #1483. (cherry picked from commit 54e8e0b0928400a9da7ebb9d27ad686ee756686e) --- README.md | 1 + src/cocoa_window.m | 6 ---- src/nsgl_context.h | 5 --- src/nsgl_context.m | 86 +++++----------------------------------------- 4 files changed, 9 insertions(+), 89 deletions(-) diff --git a/README.md b/README.md index e0b33979db..01dbcdc348 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer macOS versions (#1442) + - [NSGL] Bugfix: Workaround for swap interval on 10.14 broke on 10.12 (#1483) ## Contact diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 00cecd5a21..59eec91c4e 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -322,12 +322,6 @@ - (void)windowDidResignKey:(NSNotification *)notification _glfwInputWindowFocus(window, GLFW_FALSE); } -- (void)windowDidChangeScreen:(NSNotification *)notification -{ - if (window->context.source == GLFW_NATIVE_CONTEXT_API) - _glfwUpdateDisplayLinkDisplayNSGL(window); -} - @end diff --git a/src/nsgl_context.h b/src/nsgl_context.h index 432d200e40..a772b51117 100644 --- a/src/nsgl_context.h +++ b/src/nsgl_context.h @@ -44,10 +44,6 @@ typedef struct _GLFWcontextNSGL { id pixelFormat; id object; - CVDisplayLinkRef displayLink; - atomic_int swapInterval; - int swapIntervalsPassed; - id swapIntervalCond; } _GLFWcontextNSGL; @@ -67,5 +63,4 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig); void _glfwDestroyContextNSGL(_GLFWwindow* window); -void _glfwUpdateDisplayLinkDisplayNSGL(_GLFWwindow* window); diff --git a/src/nsgl_context.m b/src/nsgl_context.m index df1e490cb7..ba4e422fa0 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -28,30 +28,6 @@ #include "internal.h" -// Display link callback for manual swap interval implementation -// This is based on a similar workaround added to SDL2 -// -static CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, - const CVTimeStamp* now, - const CVTimeStamp* outputTime, - CVOptionFlags flagsIn, - CVOptionFlags* flagsOut, - void* userInfo) -{ - _GLFWwindow* window = (_GLFWwindow *) userInfo; - - const int interval = atomic_load(&window->context.nsgl.swapInterval); - if (interval > 0) - { - [window->context.nsgl.swapIntervalCond lock]; - window->context.nsgl.swapIntervalsPassed++; - [window->context.nsgl.swapIntervalCond signal]; - [window->context.nsgl.swapIntervalCond unlock]; - } - - return kCVReturnSuccess; -} - static void makeContextCurrentNSGL(_GLFWwindow* window) { @autoreleasepool { @@ -69,33 +45,21 @@ static void makeContextCurrentNSGL(_GLFWwindow* window) static void swapBuffersNSGL(_GLFWwindow* window) { @autoreleasepool { - - const int interval = atomic_load(&window->context.nsgl.swapInterval); - if (interval > 0) - { - [window->context.nsgl.swapIntervalCond lock]; - do - { - [window->context.nsgl.swapIntervalCond wait]; - } while (window->context.nsgl.swapIntervalsPassed % interval != 0); - window->context.nsgl.swapIntervalsPassed = 0; - [window->context.nsgl.swapIntervalCond unlock]; - } - - // ARP appears to be unnecessary, but this is future-proof [window->context.nsgl.object flushBuffer]; - } // autoreleasepool } static void swapIntervalNSGL(int interval) { @autoreleasepool { - _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot); - atomic_store(&window->context.nsgl.swapInterval, interval); - [window->context.nsgl.swapIntervalCond lock]; - window->context.nsgl.swapIntervalsPassed = 0; - [window->context.nsgl.swapIntervalCond unlock]; + + NSOpenGLContext* context = [NSOpenGLContext currentContext]; + if (context) + { + [context setValues:&interval + forParameter:NSOpenGLContextParameterSwapInterval]; + } + } // autoreleasepool } @@ -123,17 +87,6 @@ static void destroyContextNSGL(_GLFWwindow* window) { @autoreleasepool { - if (window->context.nsgl.displayLink) - { - if (CVDisplayLinkIsRunning(window->context.nsgl.displayLink)) - CVDisplayLinkStop(window->context.nsgl.displayLink); - - CVDisplayLinkRelease(window->context.nsgl.displayLink); - } - - [window->context.nsgl.swapIntervalCond release]; - window->context.nsgl.swapIntervalCond = nil; - [window->context.nsgl.pixelFormat release]; window->context.nsgl.pixelFormat = nil; @@ -363,14 +316,8 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, [window->ns.view setWantsBestResolutionOpenGLSurface:window->ns.retina]; - GLint interval = 0; - [window->context.nsgl.object setValues:&interval - forParameter:NSOpenGLContextParameterSwapInterval]; - [window->context.nsgl.object setView:window->ns.view]; - window->context.nsgl.swapIntervalCond = [NSCondition new]; - window->context.makeCurrent = makeContextCurrentNSGL; window->context.swapBuffers = swapBuffersNSGL; window->context.swapInterval = swapIntervalNSGL; @@ -378,26 +325,9 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, window->context.getProcAddress = getProcAddressNSGL; window->context.destroy = destroyContextNSGL; - CVDisplayLinkCreateWithActiveCGDisplays(&window->context.nsgl.displayLink); - CVDisplayLinkSetOutputCallback(window->context.nsgl.displayLink, - &displayLinkCallback, - window); - CVDisplayLinkStart(window->context.nsgl.displayLink); - - _glfwUpdateDisplayLinkDisplayNSGL(window); return GLFW_TRUE; } -void _glfwUpdateDisplayLinkDisplayNSGL(_GLFWwindow* window) -{ - CGDirectDisplayID displayID = - [[[window->ns.object screen] deviceDescription][@"NSScreenNumber"] unsignedIntValue]; - if (!displayID) - return; - - CVDisplayLinkSetCurrentCGDisplay(window->context.nsgl.displayLink, displayID); -} - ////////////////////////////////////////////////////////////////////////// ////// GLFW native API ////// From bb8ed627bf93cd596b95dc83d429977bfeea80f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 10 Nov 2019 19:09:23 +0100 Subject: [PATCH 142/167] NSGL: Simulate vsync for occluded windows This only supports a swap interval of zero or one, as that is all NSGL supports. (cherry picked from commit c3ca88055f7c2c8b02b38cb90fc1989990552977) --- src/nsgl_context.m | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/nsgl_context.m b/src/nsgl_context.m index ba4e422fa0..3bcfafcc7a 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -28,6 +28,9 @@ #include "internal.h" +#include +#include + static void makeContextCurrentNSGL(_GLFWwindow* window) { @autoreleasepool { @@ -45,7 +48,31 @@ static void makeContextCurrentNSGL(_GLFWwindow* window) static void swapBuffersNSGL(_GLFWwindow* window) { @autoreleasepool { + + // HACK: Simulate vsync with usleep as NSGL swap interval does not apply to + // windows with a non-visible occlusion state + if (!([window->ns.object occlusionState] & NSWindowOcclusionStateVisible)) + { + int interval = 0; + [window->context.nsgl.object getValues:&interval + forParameter:NSOpenGLContextParameterSwapInterval]; + + if (interval > 0) + { + const double framerate = 60.0; + const uint64_t frequency = _glfwPlatformGetTimerFrequency(); + const uint64_t value = _glfwPlatformGetTimerValue(); + + const double elapsed = value / (double) frequency; + const double period = 1.0 / framerate; + const double delay = period - fmod(elapsed, period); + + usleep(floorl(delay * 1e6)); + } + } + [window->context.nsgl.object flushBuffer]; + } // autoreleasepool } @@ -53,11 +80,11 @@ static void swapIntervalNSGL(int interval) { @autoreleasepool { - NSOpenGLContext* context = [NSOpenGLContext currentContext]; - if (context) + _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot); + if (window) { - [context setValues:&interval - forParameter:NSOpenGLContextParameterSwapInterval]; + [window->context.nsgl.object setValues:&interval + forParameter:NSOpenGLContextParameterSwapInterval]; } } // autoreleasepool From 9fc5fd1375e8ad8f3195451602980fc713e8b996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 25 Dec 2019 17:09:38 +0100 Subject: [PATCH 143/167] Cocoa: Replace display link with IOKit query This removes the final dependency on CoreVideo, using a display link to get the refresh rate of monitors where Core Graphics report a refresh rate of zero. Instead we now query the I/O registry directly, similarly to what the display link does at creation. Thanks to @OneSadCookie for pointers to this solution. (cherry picked from commit 4ec7daf3e92440efab8dac7c1f4c60707d990ed0) --- CMakeLists.txt | 5 ++-- README.md | 1 + docs/build.dox | 6 ++-- src/cocoa_monitor.m | 69 +++++++++++++++++++++++++++++++++++--------- src/cocoa_platform.h | 2 -- 5 files changed, 62 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 96e9e041c5..8086d42200 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -282,11 +282,10 @@ if (_GLFW_COCOA) list(APPEND glfw_LIBRARIES "-framework Cocoa" "-framework IOKit" - "-framework CoreFoundation" - "-framework CoreVideo") + "-framework CoreFoundation") set(glfw_PKG_DEPS "") - set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation -framework CoreVideo") + set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation") endif() #-------------------------------------------------------------------- diff --git a/README.md b/README.md index 01dbcdc348..083d9c48e9 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,7 @@ information on what to include when reporting a bug. event (#1490) - [Win32] Bugfix: The window hint `GLFW_MAXIMIZED` did not move or resize the window (#1499) + - [Cocoa] Removed dependency on the CoreVideo framework - [Cocoa] Bugfix: `glfwSetWindowSize` used a bottom-left anchor point (#1553) - [Cocoa] Bugfix: Window remained on screen after destruction until event poll (#1412) diff --git a/docs/build.dox b/docs/build.dox index 65646aa2ff..f957ca9a69 100644 --- a/docs/build.dox +++ b/docs/build.dox @@ -354,8 +354,8 @@ If you are using the dynamic library version of GLFW, add it to the project dependencies. If you are using the static library version of GLFW, add it and the Cocoa, -OpenGL, IOKit and CoreVideo frameworks to the project as dependencies. They can -all be found in `/System/Library/Frameworks`. +OpenGL and IOKit frameworks to the project as dependencies. They can all be +found in `/System/Library/Frameworks`. @subsection build_link_osx With command-line on macOS @@ -369,7 +369,7 @@ the `-l` and `-framework` switches. If you are using the dynamic GLFW library, which is named `libglfw.3.dylib`, do: @code{.sh} -cc -o myprog myprog.c -lglfw -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo +cc -o myprog myprog.c -lglfw -framework Cocoa -framework OpenGL -framework IOKit @endcode If you are using the static library, named `libglfw3.a`, substitute `-lglfw3` diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index 13d463f1b7..8ef94a3b0f 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -234,26 +234,65 @@ static GLFWbool refreshMonitorScreen(_GLFWmonitor* monitor) return GLFW_FALSE; } -// Returns a fallback refresh rate for when Core Graphics says it is zero +// Returns the display refresh rate queried from the I/O registry // -static double getFallbackRefreshRate(_GLFWmonitor* monitor) +static double getFallbackRefreshRate(CGDirectDisplayID displayID) { - CGDisplayModeRef mode = CGDisplayCopyDisplayMode(monitor->ns.displayID); - double refreshRate = CGDisplayModeGetRefreshRate(mode); - CGDisplayModeRelease(mode); + double refreshRate = 60.0; - if (refreshRate == 0.0) + io_iterator_t it; + io_service_t service; + + if (IOServiceGetMatchingServices(kIOMasterPortDefault, + IOServiceMatching("IOFramebuffer"), + &it) != 0) + { + return refreshRate; + } + + while ((service = IOIteratorNext(it)) != 0) { - CVDisplayLinkRef link = NULL; - CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link); + const CFNumberRef indexRef = + IORegistryEntryCreateCFProperty(service, + CFSTR("IOFramebufferOpenGLIndex"), + kCFAllocatorDefault, + kNilOptions); + if (!indexRef) + continue; + + uint32_t index = 0; + CFNumberGetValue(indexRef, kCFNumberIntType, &index); + CFRelease(indexRef); - const CVTime time = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(link); - if (!(time.flags & kCVTimeIsIndefinite)) - refreshRate = (int) (time.timeScale / (double) time.timeValue); + if (CGOpenGLDisplayMaskToDisplayID(1 << index) != displayID) + continue; + + const CFNumberRef clockRef = + IORegistryEntryCreateCFProperty(service, + CFSTR("IOFBCurrentPixelClock"), + kCFAllocatorDefault, + kNilOptions); + const CFNumberRef countRef = + IORegistryEntryCreateCFProperty(service, + CFSTR("IOFBCurrentPixelCount"), + kCFAllocatorDefault, + kNilOptions); + if (!clockRef || !countRef) + break; - CVDisplayLinkRelease(link); + uint32_t clock = 0, count = 0; + CFNumberGetValue(clockRef, kCFNumberIntType, &clock); + CFNumberGetValue(countRef, kCFNumberIntType, &count); + CFRelease(clockRef); + CFRelease(countRef); + + if (clock > 0 && count > 0) + refreshRate = clock / (double) count; + + break; } + IOObjectRelease(it); return refreshRate; } @@ -310,10 +349,14 @@ void _glfwPollMonitorsNS(void) _GLFWmonitor* monitor = _glfwAllocMonitor(name, size.width, size.height); monitor->ns.displayID = displays[i]; monitor->ns.unitNumber = unitNumber; - monitor->ns.fallbackRefreshRate = getFallbackRefreshRate(monitor); free(name); + CGDisplayModeRef mode = CGDisplayCopyDisplayMode(displays[i]); + if (CGDisplayModeGetRefreshRate(mode) == 0.0) + monitor->ns.fallbackRefreshRate = getFallbackRefreshRate(displays[i]); + CGDisplayModeRelease(mode); + _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST); } diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 2b7371a1ea..fbe71bf2a9 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -28,8 +28,6 @@ #include #include -#include -#include // NOTE: All of NSGL was deprecated in the 10.14 SDK // This disables the pointless warnings for every symbol we use From cb49e1821be5ce3d68043afd125920144a33245a Mon Sep 17 00:00:00 2001 From: Luflosi Date: Sun, 6 Oct 2019 22:53:42 +0200 Subject: [PATCH 144/167] Use the correct type in a for loop The `sizeof()` operator has the type `size_t`, so the `for` loop iterating over it should use the same type. Closes #1614. (cherry picked from commit 74a46dfa0cca79e871b24dbbb9e595b4fe65e0f6) --- src/cocoa_joystick.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cocoa_joystick.m b/src/cocoa_joystick.m index a8121e8553..2c8d82d94c 100644 --- a/src/cocoa_joystick.m +++ b/src/cocoa_joystick.m @@ -331,7 +331,7 @@ void _glfwInitJoysticksNS(void) return; } - for (int i = 0; i < sizeof(usages) / sizeof(long); i++) + for (size_t i = 0; i < sizeof(usages) / sizeof(long); i++) { const long page = kHIDPage_GenericDesktop; From 7f775302ae57d35d82e693d6885f5bbbf8e42dfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 22 Dec 2019 09:12:59 +0100 Subject: [PATCH 145/167] X11: Cleanup We can use C99 now and also we will need the event mask below. (cherry picked from commit 8149a5fc00e63ff1e94228f338f1a27de374c68b) --- src/x11_window.c | 70 ++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 38 deletions(-) diff --git a/src/x11_window.c b/src/x11_window.c index 0ec3c16540..2d32884568 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -613,46 +613,40 @@ static GLFWbool createNativeWindow(_GLFWwindow* window, window->x11.transparent = _glfwIsVisualTransparentX11(visual); - // Create the actual window - { - XSetWindowAttributes wa; - const unsigned long wamask = CWBorderPixel | CWColormap | CWEventMask; - - wa.colormap = window->x11.colormap; - wa.border_pixel = 0; - wa.event_mask = StructureNotifyMask | KeyPressMask | KeyReleaseMask | - PointerMotionMask | ButtonPressMask | ButtonReleaseMask | - ExposureMask | FocusChangeMask | VisibilityChangeMask | - EnterWindowMask | LeaveWindowMask | PropertyChangeMask; - - _glfwGrabErrorHandlerX11(); - - window->x11.handle = XCreateWindow(_glfw.x11.display, - _glfw.x11.root, - 0, 0, - width, height, - 0, // Border width - depth, // Color depth - InputOutput, - visual, - wamask, - &wa); - - _glfwReleaseErrorHandlerX11(); - - if (!window->x11.handle) - { - _glfwInputErrorX11(GLFW_PLATFORM_ERROR, - "X11: Failed to create window"); - return GLFW_FALSE; - } - - XSaveContext(_glfw.x11.display, - window->x11.handle, - _glfw.x11.context, - (XPointer) window); + XSetWindowAttributes wa = { 0 }; + wa.colormap = window->x11.colormap; + wa.event_mask = StructureNotifyMask | KeyPressMask | KeyReleaseMask | + PointerMotionMask | ButtonPressMask | ButtonReleaseMask | + ExposureMask | FocusChangeMask | VisibilityChangeMask | + EnterWindowMask | LeaveWindowMask | PropertyChangeMask; + + _glfwGrabErrorHandlerX11(); + + window->x11.handle = XCreateWindow(_glfw.x11.display, + _glfw.x11.root, + 0, 0, // Position + width, height, + 0, // Border width + depth, // Color depth + InputOutput, + visual, + CWBorderPixel | CWColormap | CWEventMask, + &wa); + + _glfwReleaseErrorHandlerX11(); + + if (!window->x11.handle) + { + _glfwInputErrorX11(GLFW_PLATFORM_ERROR, + "X11: Failed to create window"); + return GLFW_FALSE; } + XSaveContext(_glfw.x11.display, + window->x11.handle, + _glfw.x11.context, + (XPointer) window); + if (!wndconfig->decorated) _glfwPlatformSetWindowDecorated(window, GLFW_FALSE); From e8d4cc327d616568dbbc6fc284a221743d15b2af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 22 Dec 2019 09:23:22 +0100 Subject: [PATCH 146/167] X11: Fix IC event mask not being added to our window (cherry picked from commit a3d28ef52cec2fb69941bbce8a7ed7a2a22a8c41) --- src/x11_window.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/x11_window.c b/src/x11_window.c index 2d32884568..42baf5f4a8 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -781,6 +781,13 @@ static GLFWbool createNativeWindow(_GLFWwindow* window, NULL); } + if (window->x11.ic) + { + unsigned long filter = 0; + if (XGetICValues(window->x11.ic, XNFilterEvents, &filter, NULL) == NULL) + XSelectInput(_glfw.x11.display, window->x11.handle, wa.event_mask | filter); + } + _glfwPlatformGetWindowPos(window, &window->x11.xpos, &window->x11.ypos); _glfwPlatformGetWindowSize(window, &window->x11.width, &window->x11.height); From 821873974a292be666268731dea4a73bf726af2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 25 Dec 2019 22:54:23 +0100 Subject: [PATCH 147/167] Set macOS deployment target in Travis CI build (cherry picked from commit 5dd207048cc957bcf680e6c7f80eff8faf92ccb7) --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 9b37ebfd33..5f3b739360 100644 --- a/.travis.yml +++ b/.travis.yml @@ -75,12 +75,14 @@ matrix: env: - BUILD_SHARED_LIBS=ON - CFLAGS=-Werror + - MACOSX_DEPLOYMENT_TARGET=10.8 - os: osx sudo: false name: "Cocoa static library" env: - BUILD_SHARED_LIBS=OFF - CFLAGS=-Werror + - MACOSX_DEPLOYMENT_TARGET=10.8 script: - if grep -Inr '\s$' src include docs tests examples CMake *.md .gitattributes .gitignore; then echo Trailing whitespace found, aborting; From 359f0e103c169791c8620da6fbf7c17ea784c45c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 1 Jan 2020 01:42:25 +0100 Subject: [PATCH 148/167] Update changelog and add credit (cherry picked from commit bf292f0083df14e0c8e0bf10c599681d460c9179) --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 083d9c48e9..9c6b3dc73f 100644 --- a/README.md +++ b/README.md @@ -122,17 +122,20 @@ information on what to include when reporting a bug. relocatable (#1470) - Bugfix: Video modes with a duplicate screen area were discarded (#1555,#1556) - Bugfix: Compiling with -Wextra-semi caused warnings (#1440) + - Bugfix: Built-in mappings failed because some OEMs re-used VID/PID (#1583) - [Win32] Bugfix: `GLFW_INCLUDE_VULKAN` plus `VK_USE_PLATFORM_WIN32_KHR` caused symbol redefinition (#1524) - [Win32] Bugfix: The cursor position event was emitted before its cursor enter event (#1490) - [Win32] Bugfix: The window hint `GLFW_MAXIMIZED` did not move or resize the window (#1499) + - [Win32] Bugfix: Disabled cursor mode interfered with some non-client actions - [Cocoa] Removed dependency on the CoreVideo framework - [Cocoa] Bugfix: `glfwSetWindowSize` used a bottom-left anchor point (#1553) - [Cocoa] Bugfix: Window remained on screen after destruction until event poll (#1412) - [Cocoa] Bugfix: Event processing before window creation would assert (#1543) + - [Cocoa] Bugfix: Undecorated windows could not be iconified on recent macOS - [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) @@ -141,6 +144,8 @@ information on what to include when reporting a bug. - [X11] Bugfix: `glfwMaximizeWindow` had no effect on hidden windows - [X11] Bugfix: Clearing `GLFW_FLOATING` on a hidden window caused invalid read - [X11] Bugfix: Changing `GLFW_FLOATING` on a hidden window could silently fail + - [X11] Bugfix: Disabled cursor mode was interrupted by indicator windows + - [X11] Bugfix: Monitor physical dimensions could be reported as zero mm - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer macOS versions (#1442) @@ -217,6 +222,7 @@ skills. - GeO4d - Marcus Geelnard - Charles Giessen + - Ryan C. Gordon - Stephen Gowen - Kovid Goyal - Eloi Marín Gratacós From ecda86fa4f89ecdd364e5a1a22645030fe0ced6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 1 Jan 2020 16:56:32 +0100 Subject: [PATCH 149/167] X11: Fix no window position events during resize A window resize action that also resulting in the window being moved did not emit any window positions events, as the position of real ConfigureNotify events was ignored. The real events use parent coordinates instead of root coordinates so this adds parent tracking and conditional translation. Fixes #1613. (cherry picked from commit fe57e3c2921a1901390534e1e51053df70b5644b) --- README.md | 1 + src/x11_platform.h | 1 + src/x11_window.c | 42 ++++++++++++++++++++++++++++++++---------- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 9c6b3dc73f..0a0cb660b6 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ information on what to include when reporting a bug. - [X11] Bugfix: Changing `GLFW_FLOATING` on a hidden window could silently fail - [X11] Bugfix: Disabled cursor mode was interrupted by indicator windows - [X11] Bugfix: Monitor physical dimensions could be reported as zero mm + - [X11] Bugfix: Window position events were not emitted during resizing (#1613) - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer macOS versions (#1442) diff --git a/src/x11_platform.h b/src/x11_platform.h index d34bc5871b..7377b2c082 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -180,6 +180,7 @@ typedef struct _GLFWwindowX11 { Colormap colormap; Window handle; + Window parent; XIC ic; GLFWbool overrideRedirect; diff --git a/src/x11_window.c b/src/x11_window.c index 42baf5f4a8..522c293c00 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -1258,6 +1258,18 @@ static void processEvent(XEvent *event) switch (event->type) { + case CreateNotify: + { + window->x11.parent = event->xcreatewindow.parent; + return; + } + + case ReparentNotify: + { + window->x11.parent = event->xreparent.parent; + return; + } + case KeyPress: { const int key = translateKey(keycode); @@ -1542,18 +1554,28 @@ static void processEvent(XEvent *event) window->x11.height = event->xconfigure.height; } - if (event->xconfigure.x != window->x11.xpos || - event->xconfigure.y != window->x11.ypos) + int xpos = event->xconfigure.x; + int ypos = event->xconfigure.y; + + // NOTE: ConfigureNotify events from the server are in local + // coordinates, so if we are reparented we need to translate + // the position into root (screen) coordinates + if (!event->xany.send_event && window->x11.parent != _glfw.x11.root) { - if (window->x11.overrideRedirect || event->xany.send_event) - { - _glfwInputWindowPos(window, - event->xconfigure.x, - event->xconfigure.y); + Window dummy; + XTranslateCoordinates(_glfw.x11.display, + window->x11.parent, + _glfw.x11.root, + xpos, ypos, + &xpos, &ypos, + &dummy); + } - window->x11.xpos = event->xconfigure.x; - window->x11.ypos = event->xconfigure.y; - } + if (xpos != window->x11.xpos || ypos != window->x11.ypos) + { + _glfwInputWindowPos(window, xpos, ypos); + window->x11.xpos = xpos; + window->x11.ypos = ypos; } return; From 09384626161b67dbd70c4a6221263842fe18a838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 5 Jan 2020 14:50:14 +0100 Subject: [PATCH 150/167] Start 3.3.2 --- CMakeLists.txt | 2 +- README.md | 34 +--------------------------------- include/GLFW/glfw3.h | 2 +- 3 files changed, 3 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8086d42200..e98886249f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.0) -project(GLFW VERSION 3.3.1 LANGUAGES C) +project(GLFW VERSION 3.3.2 LANGUAGES C) set(CMAKE_LEGACY_CYGWIN_WIN32 OFF) diff --git a/README.md b/README.md index 0a0cb660b6..339b70e7bf 100644 --- a/README.md +++ b/README.md @@ -118,39 +118,7 @@ information on what to include when reporting a bug. ## Changelog - - Bugfix: The CMake config-file package used an absolute path and was not - relocatable (#1470) - - Bugfix: Video modes with a duplicate screen area were discarded (#1555,#1556) - - Bugfix: Compiling with -Wextra-semi caused warnings (#1440) - - Bugfix: Built-in mappings failed because some OEMs re-used VID/PID (#1583) - - [Win32] Bugfix: `GLFW_INCLUDE_VULKAN` plus `VK_USE_PLATFORM_WIN32_KHR` caused - symbol redefinition (#1524) - - [Win32] Bugfix: The cursor position event was emitted before its cursor enter - event (#1490) - - [Win32] Bugfix: The window hint `GLFW_MAXIMIZED` did not move or resize the - window (#1499) - - [Win32] Bugfix: Disabled cursor mode interfered with some non-client actions - - [Cocoa] Removed dependency on the CoreVideo framework - - [Cocoa] Bugfix: `glfwSetWindowSize` used a bottom-left anchor point (#1553) - - [Cocoa] Bugfix: Window remained on screen after destruction until event poll - (#1412) - - [Cocoa] Bugfix: Event processing before window creation would assert (#1543) - - [Cocoa] Bugfix: Undecorated windows could not be iconified on recent macOS - - [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) - - [X11] Bugfix: Decorations could not be enabled after window creation (#1566) - - [X11] Bugfix: Content scale fallback value could be inconsistent (#1578) - - [X11] Bugfix: `glfwMaximizeWindow` had no effect on hidden windows - - [X11] Bugfix: Clearing `GLFW_FLOATING` on a hidden window caused invalid read - - [X11] Bugfix: Changing `GLFW_FLOATING` on a hidden window could silently fail - - [X11] Bugfix: Disabled cursor mode was interrupted by indicator windows - - [X11] Bugfix: Monitor physical dimensions could be reported as zero mm - - [X11] Bugfix: Window position events were not emitted during resizing (#1613) - - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - - [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer - macOS versions (#1442) - - [NSGL] Bugfix: Workaround for swap interval on 10.14 broke on 10.12 (#1483) +There is nothing here yet. ## Contact diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 671ba7252c..d561e5029b 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -270,7 +270,7 @@ extern "C" { * API changes. * @ingroup init */ -#define GLFW_VERSION_REVISION 1 +#define GLFW_VERSION_REVISION 2 /*! @} */ /*! @brief One. From 487e0419a7dc8becf3577e5ae9c79896eca7259d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 5 Jan 2020 14:34:39 +0100 Subject: [PATCH 151/167] X11: Fix BadMatch focusing a window on non-EWMH WM When the WM does not support EWMH or there is no WM running, GLFW falls back to XSetInputFocus, which will emit BadMatch if the window is not viewable, which will terminate the program. Bug spotted on IRC. (cherry picked from commit aa5e31356178de43d42f43f48914a62c25033f4b) --- README.md | 2 +- src/x11_window.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 339b70e7bf..64924b7a61 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ information on what to include when reporting a bug. ## Changelog -There is nothing here yet. + - [X11] Bugfix: `glfwFocusWindow` could terminate on older WMs or without a WM ## Contact diff --git a/src/x11_window.c b/src/x11_window.c index 522c293c00..ed4e25130b 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2457,7 +2457,7 @@ void _glfwPlatformFocusWindow(_GLFWwindow* window) { if (_glfw.x11.NET_ACTIVE_WINDOW) sendEventToWM(window, _glfw.x11.NET_ACTIVE_WINDOW, 1, 0, 0, 0, 0); - else + else if (_glfwPlatformWindowVisible(window)) { XRaiseWindow(_glfw.x11.display, window->x11.handle); XSetInputFocus(_glfw.x11.display, window->x11.handle, From fbe8ae993c3dfbee5a21d265b351474b284be816 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 12 Jan 2020 17:18:21 +0100 Subject: [PATCH 152/167] X11: Fix parent window handle initialization This should have been initialized to the screen root, not None. This issue was introduced by fe57e3c2921a1901390534e1e51053df70b5644b. Fixes #1620. (cherry picked from commit 9372ba95faabd1bb45280d201d6ccdae77bf872e) --- src/x11_window.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/x11_window.c b/src/x11_window.c index ed4e25130b..75986442ca 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -622,6 +622,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window, _glfwGrabErrorHandlerX11(); + window->x11.parent = _glfw.x11.root; window->x11.handle = XCreateWindow(_glfw.x11.display, _glfw.x11.root, 0, 0, // Position @@ -1258,12 +1259,6 @@ static void processEvent(XEvent *event) switch (event->type) { - case CreateNotify: - { - window->x11.parent = event->xcreatewindow.parent; - return; - } - case ReparentNotify: { window->x11.parent = event->xreparent.parent; From 977e2b51b0822e354c48166d97927e1a81c5bf82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 12 Jan 2020 17:57:14 +0100 Subject: [PATCH 153/167] Update changelog This is a fix relative to 3.3.1 but not 3.3. Related to #1620. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 64924b7a61..8b35fbca41 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,7 @@ information on what to include when reporting a bug. ## Changelog - [X11] Bugfix: `glfwFocusWindow` could terminate on older WMs or without a WM + - [X11] Bugfix: Creating an undecorated window could fail with BadMatch (#1620) ## Contact From 50f3979dfd195581d7e06ad43226dff5ed2c4c6e Mon Sep 17 00:00:00 2001 From: ByunghoonKim <44054076+ByunghoonKim@users.noreply.github.com> Date: Mon, 6 Jan 2020 00:46:42 +0900 Subject: [PATCH 154/167] Cocoa: Add support for VK_EXT_metal_surface This adds optional support for the VK_EXT_metal_surface instance extension. Closes #1619. (cherry picked from commit c5cb4a253a9c304b136cac01a378567dc46e0320) --- CMakeLists.txt | 2 ++ docs/compat.dox | 8 ++++---- include/GLFW/glfw3.h | 5 +++-- src/cocoa_platform.h | 18 ++++++++++++++++++ src/cocoa_window.m | 36 +++++++++++++++++++++++++++++++++++- src/glfw_config.h.in | 1 + src/internal.h | 5 +++++ src/vulkan.c | 5 +++++ 8 files changed, 73 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e98886249f..09ec4bc550 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,6 +145,8 @@ elseif (WIN32) elseif (APPLE) set(_GLFW_COCOA 1) message(STATUS "Using Cocoa for window creation") + set(VK_USE_PLATFORM_METAL_EXT 1) + message(STATUS "Using VK_EXT_metal_surface") elseif (UNIX) set(_GLFW_X11 1) message(STATUS "Using X11 for window creation") diff --git a/docs/compat.dox b/docs/compat.dox index 615264b4e9..fea7ab180b 100644 --- a/docs/compat.dox +++ b/docs/compat.dox @@ -266,10 +266,10 @@ surfaces on Microsoft Windows. If any of these extensions are not available, @ref glfwGetRequiredInstanceExtensions will return an empty list and window surface creation will fail. -GLFW uses the `VK_KHR_surface` and `VK_MVK_macos_surface` extensions to create -surfaces on macOS. If any of these extensions are not available, @ref -glfwGetRequiredInstanceExtensions will return an empty list and window surface -creation will fail. +GLFW uses the `VK_KHR_surface` and either the `VK_MVK_macos_surface` or +`VK_EXT_metal_surface` extensions to create surfaces on macOS. If any of these +extensions are not available, @ref glfwGetRequiredInstanceExtensions will +return an empty list and window surface creation will fail. GLFW uses the `VK_KHR_surface` and either the `VK_KHR_xlib_surface` or `VK_KHR_xcb_surface` extensions to create surfaces on X11. If `VK_KHR_surface` diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index d561e5029b..66dff64905 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -5677,8 +5677,9 @@ GLFWAPI int glfwVulkanSupported(void); * returned array, as it is an error to specify an extension more than once in * the `VkInstanceCreateInfo` struct. * - * @remark @macos This function currently only supports the - * `VK_MVK_macos_surface` extension from MoltenVK. + * @remark @macos This function currently supports either the + * `VK_MVK_macos_surface` extension from MoltenVK or `VK_EXT_metal_surface` + * extension. * * @pointer_lifetime The returned array is allocated and freed by GLFW. You * should not free it yourself. It is guaranteed to be valid only until the diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index fbe71bf2a9..e160bb17ee 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -60,6 +60,7 @@ typedef void* id; #define NSWindowStyleMaskTitled NSTitledWindowMask #endif +#if defined(VK_USE_PLATFORM_MACOS_MVK) typedef VkFlags VkMacOSSurfaceCreateFlagsMVK; typedef struct VkMacOSSurfaceCreateInfoMVK @@ -72,6 +73,23 @@ typedef struct VkMacOSSurfaceCreateInfoMVK typedef VkResult (APIENTRY *PFN_vkCreateMacOSSurfaceMVK)(VkInstance,const VkMacOSSurfaceCreateInfoMVK*,const VkAllocationCallbacks*,VkSurfaceKHR*); +#elif defined(VK_USE_PLATFORM_METAL_EXT) +#define VK_EXT_metal_surface 1 +typedef void CAMetalLayer; + +#define VK_EXT_METAL_SURFACE_SPEC_VERSION 1 +#define VK_EXT_METAL_SURFACE_EXTENSION_NAME "VK_EXT_metal_surface" +typedef VkFlags VkMetalSurfaceCreateFlagsEXT; +typedef struct VkMetalSurfaceCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkMetalSurfaceCreateFlagsEXT flags; + const CAMetalLayer* pLayer; +} VkMetalSurfaceCreateInfoEXT; + +typedef VkResult (APIENTRY *PFN_vkCreateMetalSurfaceEXT)(VkInstance, const VkMetalSurfaceCreateInfoEXT*, const VkAllocationCallbacks*, VkSurfaceKHR*); +#endif + #include "posix_thread.h" #include "cocoa_joystick.h" #include "nsgl_context.h" diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 59eec91c4e..88ed9c4fd6 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1689,11 +1689,19 @@ void _glfwPlatformSetClipboardString(const char* string) void _glfwPlatformGetRequiredInstanceExtensions(char** extensions) { +#if defined(VK_USE_PLATFORM_MACOS_MVK) if (!_glfw.vk.KHR_surface || !_glfw.vk.MVK_macos_surface) return; extensions[0] = "VK_KHR_surface"; extensions[1] = "VK_MVK_macos_surface"; + +#elif defined(VK_USE_PLATFORM_METAL_EXT) + if (!_glfw.vk.KHR_surface || !_glfw.vk.EXT_metal_surface) + return; + extensions[0] = "VK_KHR_surface"; + extensions[1] = "VK_EXT_metal_surface"; +#endif } int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, @@ -1712,9 +1720,11 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101100 VkResult err; + +#if defined(VK_USE_PLATFORM_MACOS_MVK) VkMacOSSurfaceCreateInfoMVK sci; - PFN_vkCreateMacOSSurfaceMVK vkCreateMacOSSurfaceMVK; + PFN_vkCreateMacOSSurfaceMVK vkCreateMacOSSurfaceMVK; vkCreateMacOSSurfaceMVK = (PFN_vkCreateMacOSSurfaceMVK) vkGetInstanceProcAddr(instance, "vkCreateMacOSSurfaceMVK"); if (!vkCreateMacOSSurfaceMVK) @@ -1724,6 +1734,20 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, return VK_ERROR_EXTENSION_NOT_PRESENT; } +#elif defined(VK_USE_PLATFORM_METAL_EXT) + VkMetalSurfaceCreateInfoEXT sci; + + PFN_vkCreateMetalSurfaceEXT vkCreateMetalSurfaceEXT; + vkCreateMetalSurfaceEXT = (PFN_vkCreateMetalSurfaceEXT) + vkGetInstanceProcAddr(instance, "vkCreateMetalSurfaceEXT"); + if (!vkCreateMetalSurfaceEXT) + { + _glfwInputError(GLFW_API_UNAVAILABLE, + "Cocoa: Vulkan instance missing VK_EXT_metal_surface extension"); + return VK_ERROR_EXTENSION_NOT_PRESENT; + } +#endif + // HACK: Dynamically load Core Animation to avoid adding an extra // dependency for the majority who don't use MoltenVK NSBundle* bundle = [NSBundle bundleWithPath:@"/System/Library/Frameworks/QuartzCore.framework"]; @@ -1750,10 +1774,20 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, [window->ns.view setWantsLayer:YES]; memset(&sci, 0, sizeof(sci)); +#if defined(VK_USE_PLATFORM_MACOS_MVK) sci.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK; sci.pView = window->ns.view; err = vkCreateMacOSSurfaceMVK(instance, &sci, allocator, surface); + +#elif defined(VK_USE_PLATFORM_METAL_EXT) + sci.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT; + sci.pNext = NULL; + sci.flags = 0; + sci.pLayer = window->ns.layer; + + err = vkCreateMetalSurfaceEXT(instance, &sci, allocator, surface); +#endif if (err) { _glfwInputError(GLFW_PLATFORM_ERROR, diff --git a/src/glfw_config.h.in b/src/glfw_config.h.in index f418c99507..cf297abe87 100644 --- a/src/glfw_config.h.in +++ b/src/glfw_config.h.in @@ -40,6 +40,7 @@ #cmakedefine _GLFW_WIN32 // Define this to 1 if building GLFW for Cocoa #cmakedefine _GLFW_COCOA +#cmakedefine VK_USE_PLATFORM_METAL_EXT // Define this to 1 if building GLFW for Wayland #cmakedefine _GLFW_WAYLAND // Define this to 1 if building GLFW for OSMesa diff --git a/src/internal.h b/src/internal.h index 81f12dc1c9..1b4d96674e 100644 --- a/src/internal.h +++ b/src/internal.h @@ -128,6 +128,7 @@ typedef enum VkStructureType VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR = 1000006000, VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR = 1000009000, VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK = 1000123000, + VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT = 1000217000, VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF } VkStructureType; @@ -555,7 +556,11 @@ struct _GLFWlibrary #if defined(_GLFW_WIN32) GLFWbool KHR_win32_surface; #elif defined(_GLFW_COCOA) + #if defined(VK_USE_PLATFORM_MACOS_MVK) GLFWbool MVK_macos_surface; + #elif defined(VK_USE_PLATFORM_METAL_EXT) + GLFWbool EXT_metal_surface; + #endif #elif defined(_GLFW_X11) GLFWbool KHR_xlib_surface; GLFWbool KHR_xcb_surface; diff --git a/src/vulkan.c b/src/vulkan.c index 7f9ed86260..7f8a0abfd4 100644 --- a/src/vulkan.c +++ b/src/vulkan.c @@ -128,8 +128,13 @@ GLFWbool _glfwInitVulkan(int mode) else if (strcmp(ep[i].extensionName, "VK_KHR_win32_surface") == 0) _glfw.vk.KHR_win32_surface = GLFW_TRUE; #elif defined(_GLFW_COCOA) + #if defined(VK_USE_PLATFORM_MACOS_MVK) else if (strcmp(ep[i].extensionName, "VK_MVK_macos_surface") == 0) _glfw.vk.MVK_macos_surface = GLFW_TRUE; + #elif defined(VK_USE_PLATFORM_METAL_EXT) + else if (strcmp(ep[i].extensionName, "VK_EXT_metal_surface") == 0) + _glfw.vk.EXT_metal_surface = GLFW_TRUE; + #endif #elif defined(_GLFW_X11) else if (strcmp(ep[i].extensionName, "VK_KHR_xlib_surface") == 0) _glfw.vk.KHR_xlib_surface = GLFW_TRUE; From d33084447d58d9e3dd877fe6ba80e7288c5b281b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 16 Jan 2020 01:52:50 +0100 Subject: [PATCH 155/167] Cocoa: Select Vulkan surface extension at runtime This mostly just follows the pattern established by X11. Related to #1619. (cherry picked from commit 15d91801b7ac3d52779ec7330f2a1c0128fb57df) --- CMakeLists.txt | 2 - README.md | 2 + src/cocoa_platform.h | 20 +++------ src/cocoa_window.m | 104 +++++++++++++++++++++---------------------- src/glfw_config.h.in | 1 - src/internal.h | 3 -- src/vulkan.c | 3 -- 7 files changed, 58 insertions(+), 77 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 09ec4bc550..e98886249f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,8 +145,6 @@ elseif (WIN32) elseif (APPLE) set(_GLFW_COCOA 1) message(STATUS "Using Cocoa for window creation") - set(VK_USE_PLATFORM_METAL_EXT 1) - message(STATUS "Using VK_EXT_metal_surface") elseif (UNIX) set(_GLFW_X11 1) message(STATUS "Using X11 for window creation") diff --git a/README.md b/README.md index 8b35fbca41..4e49646b19 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,7 @@ information on what to include when reporting a bug. ## Changelog + - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) - [X11] Bugfix: `glfwFocusWindow` could terminate on older WMs or without a WM - [X11] Bugfix: Creating an undecorated window could fail with BadMatch (#1620) @@ -213,6 +214,7 @@ skills. - Cem Karan - Osman Keskin - Josh Kilmer + - Byunghoon Kim - Cameron King - Peter Knut - Christoph Kubisch diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index e160bb17ee..66c4767b39 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -60,8 +60,8 @@ typedef void* id; #define NSWindowStyleMaskTitled NSTitledWindowMask #endif -#if defined(VK_USE_PLATFORM_MACOS_MVK) typedef VkFlags VkMacOSSurfaceCreateFlagsMVK; +typedef VkFlags VkMetalSurfaceCreateFlagsEXT; typedef struct VkMacOSSurfaceCreateInfoMVK { @@ -71,24 +71,16 @@ typedef struct VkMacOSSurfaceCreateInfoMVK const void* pView; } VkMacOSSurfaceCreateInfoMVK; -typedef VkResult (APIENTRY *PFN_vkCreateMacOSSurfaceMVK)(VkInstance,const VkMacOSSurfaceCreateInfoMVK*,const VkAllocationCallbacks*,VkSurfaceKHR*); - -#elif defined(VK_USE_PLATFORM_METAL_EXT) -#define VK_EXT_metal_surface 1 -typedef void CAMetalLayer; - -#define VK_EXT_METAL_SURFACE_SPEC_VERSION 1 -#define VK_EXT_METAL_SURFACE_EXTENSION_NAME "VK_EXT_metal_surface" -typedef VkFlags VkMetalSurfaceCreateFlagsEXT; -typedef struct VkMetalSurfaceCreateInfoEXT { +typedef struct VkMetalSurfaceCreateInfoEXT +{ VkStructureType sType; const void* pNext; VkMetalSurfaceCreateFlagsEXT flags; - const CAMetalLayer* pLayer; + const void* pLayer; } VkMetalSurfaceCreateInfoEXT; -typedef VkResult (APIENTRY *PFN_vkCreateMetalSurfaceEXT)(VkInstance, const VkMetalSurfaceCreateInfoEXT*, const VkAllocationCallbacks*, VkSurfaceKHR*); -#endif +typedef VkResult (APIENTRY *PFN_vkCreateMacOSSurfaceMVK)(VkInstance,const VkMacOSSurfaceCreateInfoMVK*,const VkAllocationCallbacks*,VkSurfaceKHR*); +typedef VkResult (APIENTRY *PFN_vkCreateMetalSurfaceEXT)(VkInstance,const VkMetalSurfaceCreateInfoEXT*,const VkAllocationCallbacks*,VkSurfaceKHR*); #include "posix_thread.h" #include "cocoa_joystick.h" diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 88ed9c4fd6..30d8c1fc1b 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1689,19 +1689,16 @@ void _glfwPlatformSetClipboardString(const char* string) void _glfwPlatformGetRequiredInstanceExtensions(char** extensions) { -#if defined(VK_USE_PLATFORM_MACOS_MVK) - if (!_glfw.vk.KHR_surface || !_glfw.vk.MVK_macos_surface) - return; - - extensions[0] = "VK_KHR_surface"; - extensions[1] = "VK_MVK_macos_surface"; - -#elif defined(VK_USE_PLATFORM_METAL_EXT) - if (!_glfw.vk.KHR_surface || !_glfw.vk.EXT_metal_surface) - return; - extensions[0] = "VK_KHR_surface"; - extensions[1] = "VK_EXT_metal_surface"; -#endif + if (_glfw.vk.KHR_surface && _glfw.vk.EXT_metal_surface) + { + extensions[0] = "VK_KHR_surface"; + extensions[1] = "VK_EXT_metal_surface"; + } + else if (_glfw.vk.KHR_surface && _glfw.vk.MVK_macos_surface) + { + extensions[0] = "VK_KHR_surface"; + extensions[1] = "VK_MVK_macos_surface"; + } } int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, @@ -1719,35 +1716,6 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, @autoreleasepool { #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101100 - VkResult err; - -#if defined(VK_USE_PLATFORM_MACOS_MVK) - VkMacOSSurfaceCreateInfoMVK sci; - - PFN_vkCreateMacOSSurfaceMVK vkCreateMacOSSurfaceMVK; - vkCreateMacOSSurfaceMVK = (PFN_vkCreateMacOSSurfaceMVK) - vkGetInstanceProcAddr(instance, "vkCreateMacOSSurfaceMVK"); - if (!vkCreateMacOSSurfaceMVK) - { - _glfwInputError(GLFW_API_UNAVAILABLE, - "Cocoa: Vulkan instance missing VK_MVK_macos_surface extension"); - return VK_ERROR_EXTENSION_NOT_PRESENT; - } - -#elif defined(VK_USE_PLATFORM_METAL_EXT) - VkMetalSurfaceCreateInfoEXT sci; - - PFN_vkCreateMetalSurfaceEXT vkCreateMetalSurfaceEXT; - vkCreateMetalSurfaceEXT = (PFN_vkCreateMetalSurfaceEXT) - vkGetInstanceProcAddr(instance, "vkCreateMetalSurfaceEXT"); - if (!vkCreateMetalSurfaceEXT) - { - _glfwInputError(GLFW_API_UNAVAILABLE, - "Cocoa: Vulkan instance missing VK_EXT_metal_surface extension"); - return VK_ERROR_EXTENSION_NOT_PRESENT; - } -#endif - // HACK: Dynamically load Core Animation to avoid adding an extra // dependency for the majority who don't use MoltenVK NSBundle* bundle = [NSBundle bundleWithPath:@"/System/Library/Frameworks/QuartzCore.framework"]; @@ -1773,21 +1741,49 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, [window->ns.view setLayer:window->ns.layer]; [window->ns.view setWantsLayer:YES]; - memset(&sci, 0, sizeof(sci)); -#if defined(VK_USE_PLATFORM_MACOS_MVK) - sci.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK; - sci.pView = window->ns.view; + VkResult err; + + if (_glfw.vk.EXT_metal_surface) + { + VkMetalSurfaceCreateInfoEXT sci; - err = vkCreateMacOSSurfaceMVK(instance, &sci, allocator, surface); + PFN_vkCreateMetalSurfaceEXT vkCreateMetalSurfaceEXT; + vkCreateMetalSurfaceEXT = (PFN_vkCreateMetalSurfaceEXT) + vkGetInstanceProcAddr(instance, "vkCreateMetalSurfaceEXT"); + if (!vkCreateMetalSurfaceEXT) + { + _glfwInputError(GLFW_API_UNAVAILABLE, + "Cocoa: Vulkan instance missing VK_EXT_metal_surface extension"); + return VK_ERROR_EXTENSION_NOT_PRESENT; + } -#elif defined(VK_USE_PLATFORM_METAL_EXT) - sci.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT; - sci.pNext = NULL; - sci.flags = 0; - sci.pLayer = window->ns.layer; + memset(&sci, 0, sizeof(sci)); + sci.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT; + sci.pLayer = window->ns.layer; + + err = vkCreateMetalSurfaceEXT(instance, &sci, allocator, surface); + } + else + { + VkMacOSSurfaceCreateInfoMVK sci; + + PFN_vkCreateMacOSSurfaceMVK vkCreateMacOSSurfaceMVK; + vkCreateMacOSSurfaceMVK = (PFN_vkCreateMacOSSurfaceMVK) + vkGetInstanceProcAddr(instance, "vkCreateMacOSSurfaceMVK"); + if (!vkCreateMacOSSurfaceMVK) + { + _glfwInputError(GLFW_API_UNAVAILABLE, + "Cocoa: Vulkan instance missing VK_MVK_macos_surface extension"); + return VK_ERROR_EXTENSION_NOT_PRESENT; + } + + memset(&sci, 0, sizeof(sci)); + sci.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK; + sci.pView = window->ns.view; + + err = vkCreateMacOSSurfaceMVK(instance, &sci, allocator, surface); + } - err = vkCreateMetalSurfaceEXT(instance, &sci, allocator, surface); -#endif if (err) { _glfwInputError(GLFW_PLATFORM_ERROR, diff --git a/src/glfw_config.h.in b/src/glfw_config.h.in index cf297abe87..f418c99507 100644 --- a/src/glfw_config.h.in +++ b/src/glfw_config.h.in @@ -40,7 +40,6 @@ #cmakedefine _GLFW_WIN32 // Define this to 1 if building GLFW for Cocoa #cmakedefine _GLFW_COCOA -#cmakedefine VK_USE_PLATFORM_METAL_EXT // Define this to 1 if building GLFW for Wayland #cmakedefine _GLFW_WAYLAND // Define this to 1 if building GLFW for OSMesa diff --git a/src/internal.h b/src/internal.h index 1b4d96674e..92b9497abb 100644 --- a/src/internal.h +++ b/src/internal.h @@ -556,11 +556,8 @@ struct _GLFWlibrary #if defined(_GLFW_WIN32) GLFWbool KHR_win32_surface; #elif defined(_GLFW_COCOA) - #if defined(VK_USE_PLATFORM_MACOS_MVK) GLFWbool MVK_macos_surface; - #elif defined(VK_USE_PLATFORM_METAL_EXT) GLFWbool EXT_metal_surface; - #endif #elif defined(_GLFW_X11) GLFWbool KHR_xlib_surface; GLFWbool KHR_xcb_surface; diff --git a/src/vulkan.c b/src/vulkan.c index 7f8a0abfd4..61b40ea3a3 100644 --- a/src/vulkan.c +++ b/src/vulkan.c @@ -128,13 +128,10 @@ GLFWbool _glfwInitVulkan(int mode) else if (strcmp(ep[i].extensionName, "VK_KHR_win32_surface") == 0) _glfw.vk.KHR_win32_surface = GLFW_TRUE; #elif defined(_GLFW_COCOA) - #if defined(VK_USE_PLATFORM_MACOS_MVK) else if (strcmp(ep[i].extensionName, "VK_MVK_macos_surface") == 0) _glfw.vk.MVK_macos_surface = GLFW_TRUE; - #elif defined(VK_USE_PLATFORM_METAL_EXT) else if (strcmp(ep[i].extensionName, "VK_EXT_metal_surface") == 0) _glfw.vk.EXT_metal_surface = GLFW_TRUE; - #endif #elif defined(_GLFW_X11) else if (strcmp(ep[i].extensionName, "VK_KHR_xlib_surface") == 0) _glfw.vk.KHR_xlib_surface = GLFW_TRUE; From 85172703dbcc851e159d69c91392a952ec17fa7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 16 Jan 2020 05:09:19 +0100 Subject: [PATCH 156/167] Cocoa: Add fully dynamic loading of Vulkan loader If the application is not linked against the Vulkan loader and relies on a third-party loader library or glfwGetInstanceProcAddress, then our call to dlopen will fail without a custom dyld environment variable. This adds a fallback of looking in the directory of the main executable, which matches the bundle structure recommended by the Vulkan SDK, making that finally work out of the box for fully dynamic loading. (cherry picked from commit 7da87aaae7039cbdc132f8f563a2603c5e3c73a1) --- README.md | 1 + src/cocoa_init.m | 26 ++++++++++++++++++++++++++ src/cocoa_platform.h | 2 ++ src/vulkan.c | 2 ++ 4 files changed, 31 insertions(+) diff --git a/README.md b/README.md index 4e49646b19..e69bc4bf23 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,7 @@ information on what to include when reporting a bug. ## Changelog - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) + - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - [X11] Bugfix: `glfwFocusWindow` could terminate on older WMs or without a WM - [X11] Bugfix: Creating an undecorated window could fail with BadMatch (#1620) diff --git a/src/cocoa_init.m b/src/cocoa_init.m index 6dfb6f5695..579b6e6ce4 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -463,6 +463,32 @@ - (void)applicationDidHide:(NSNotification *)notification @end // GLFWApplicationDelegate +////////////////////////////////////////////////////////////////////////// +////// GLFW internal API ////// +////////////////////////////////////////////////////////////////////////// + +void* _glfwLoadLocalVulkanLoaderNS(void) +{ + CFBundleRef bundle = CFBundleGetMainBundle(); + if (!bundle) + return NULL; + + CFURLRef url = + CFBundleCopyAuxiliaryExecutableURL(bundle, CFSTR("libvulkan.1.dylib")); + if (!url) + return NULL; + + char path[PATH_MAX]; + void* handle = NULL; + + if (CFURLGetFileSystemRepresentation(url, true, (UInt8*) path, sizeof(path) - 1)) + handle = _glfw_dlopen(path); + + CFRelease(url); + return handle; +} + + ////////////////////////////////////////////////////////////////////////// ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 66c4767b39..15c2169619 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -207,3 +207,5 @@ void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor); float _glfwTransformYNS(float y); +void* _glfwLoadLocalVulkanLoaderNS(void); + diff --git a/src/vulkan.c b/src/vulkan.c index 61b40ea3a3..22c54e4adc 100644 --- a/src/vulkan.c +++ b/src/vulkan.c @@ -57,6 +57,8 @@ GLFWbool _glfwInitVulkan(int mode) _glfw.vk.handle = _glfw_dlopen("vulkan-1.dll"); #elif defined(_GLFW_COCOA) _glfw.vk.handle = _glfw_dlopen("libvulkan.1.dylib"); + if (!_glfw.vk.handle) + _glfw.vk.handle = _glfwLoadLocalVulkanLoaderNS(); #else _glfw.vk.handle = _glfw_dlopen("libvulkan.so.1"); #endif From 8552152f808feb0ac01fed8b5861051526757d0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 15 Jan 2020 16:19:56 +0100 Subject: [PATCH 157/167] Win32: Fix no Super key release event after Win+V The Win+V hotkey brings up a clipboard history IME that consumes the key release. This adds left and right Super to the modifier keys manually polled for undetected release during event processing. Fixes #1622. (cherry picked from commit 562c17d131bd99d92f1166e2a8a42d7af023d122) --- README.md | 1 + src/win32_window.c | 41 +++++++++++++++++++++++++---------------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index e69bc4bf23..726046141b 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,7 @@ information on what to include when reporting a bug. ## Changelog + - [Win32] Bugfix: Super key was not released after Win+V hotkey (#1622) - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - [X11] Bugfix: `glfwFocusWindow` could terminate on older WMs or without a WM diff --git a/src/win32_window.c b/src/win32_window.c index cdb1fe8771..2d701bb60a 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1924,30 +1924,39 @@ void _glfwPlatformPollEvents(void) } } + // HACK: Release modifier keys that the system did not emit KEYUP for + // NOTE: Shift keys on Windows tend to "stick" when both are pressed as + // no key up message is generated by the first key release + // NOTE: Windows key is not reported as released by the Win+V hotkey + // Other Win hotkeys are handled implicitly by _glfwInputWindowFocus + // because they change the input focus handle = GetActiveWindow(); if (handle) { - // NOTE: Shift keys on Windows tend to "stick" when both are pressed as - // no key up message is generated by the first key release - // The other half of this is in the handling of WM_KEYUP - // HACK: Query actual key state and synthesize release events as needed window = GetPropW(handle, L"GLFW"); if (window) { - const GLFWbool lshift = (GetAsyncKeyState(VK_LSHIFT) & 0x8000) != 0; - const GLFWbool rshift = (GetAsyncKeyState(VK_RSHIFT) & 0x8000) != 0; - - if (!lshift && window->keys[GLFW_KEY_LEFT_SHIFT] == GLFW_PRESS) + int i; + const int keys[4][2] = { - const int mods = getAsyncKeyMods(); - const int scancode = _glfw.win32.scancodes[GLFW_KEY_LEFT_SHIFT]; - _glfwInputKey(window, GLFW_KEY_LEFT_SHIFT, scancode, GLFW_RELEASE, mods); - } - else if (!rshift && window->keys[GLFW_KEY_RIGHT_SHIFT] == GLFW_PRESS) + { VK_LSHIFT, GLFW_KEY_LEFT_SHIFT }, + { VK_RSHIFT, GLFW_KEY_RIGHT_SHIFT }, + { VK_LWIN, GLFW_KEY_LEFT_SUPER }, + { VK_RWIN, GLFW_KEY_RIGHT_SUPER } + }; + + for (i = 0; i < 4; i++) { - const int mods = getAsyncKeyMods(); - const int scancode = _glfw.win32.scancodes[GLFW_KEY_RIGHT_SHIFT]; - _glfwInputKey(window, GLFW_KEY_RIGHT_SHIFT, scancode, GLFW_RELEASE, mods); + const int vk = keys[i][0]; + const int key = keys[i][1]; + const int scancode = _glfw.win32.scancodes[key]; + + if ((GetAsyncKeyState(vk) & 0x8000)) + continue; + if (window->keys[key] != GLFW_PRESS) + continue; + + _glfwInputKey(window, key, scancode, GLFW_RELEASE, getAsyncKeyMods()); } } } From 0af3bf3b36c68cacc60ad45653dde3b7848375b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 15 Jan 2020 16:26:29 +0100 Subject: [PATCH 158/167] Win32: Use non-async key state for modifier hack The synchronous key state seems to make more sense in context. (cherry picked from commit a491b0698cc520fb7e77d66e3d335310814cbb86) --- src/win32_window.c | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/src/win32_window.c b/src/win32_window.c index 2d701bb60a..38c12e0a40 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -448,28 +448,6 @@ static int getKeyMods(void) return mods; } -// Retrieves and translates modifier keys -// -static int getAsyncKeyMods(void) -{ - int mods = 0; - - if (GetAsyncKeyState(VK_SHIFT) & 0x8000) - mods |= GLFW_MOD_SHIFT; - if (GetAsyncKeyState(VK_CONTROL) & 0x8000) - mods |= GLFW_MOD_CONTROL; - if (GetAsyncKeyState(VK_MENU) & 0x8000) - mods |= GLFW_MOD_ALT; - if ((GetAsyncKeyState(VK_LWIN) | GetAsyncKeyState(VK_RWIN)) & 0x8000) - mods |= GLFW_MOD_SUPER; - if (GetAsyncKeyState(VK_CAPITAL) & 1) - mods |= GLFW_MOD_CAPS_LOCK; - if (GetAsyncKeyState(VK_NUMLOCK) & 1) - mods |= GLFW_MOD_NUM_LOCK; - - return mods; -} - // Translates a Windows key to the corresponding GLFW key // static int translateKey(WPARAM wParam, LPARAM lParam) @@ -1951,12 +1929,12 @@ void _glfwPlatformPollEvents(void) const int key = keys[i][1]; const int scancode = _glfw.win32.scancodes[key]; - if ((GetAsyncKeyState(vk) & 0x8000)) + if ((GetKeyState(vk) & 0x8000)) continue; if (window->keys[key] != GLFW_PRESS) continue; - _glfwInputKey(window, key, scancode, GLFW_RELEASE, getAsyncKeyMods()); + _glfwInputKey(window, key, scancode, GLFW_RELEASE, getKeyMods()); } } } From ec286969942dbebfb9d0c041410ca61ebb7a08d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 15 Jan 2020 16:34:58 +0100 Subject: [PATCH 159/167] Check scancode before use in glfwGetKeyName (cherry picked from commit 5f1631cb0e6f3544e9d13e7deb60ff3473a8a3f3) --- README.md | 2 ++ src/cocoa_window.m | 7 +++++++ src/win32_window.c | 7 +++++++ src/x11_window.c | 7 +++++++ 4 files changed, 23 insertions(+) diff --git a/README.md b/README.md index 726046141b..801582c04a 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,8 @@ information on what to include when reporting a bug. ## Changelog - [Win32] Bugfix: Super key was not released after Win+V hotkey (#1622) + - [Win32] Bugfix: `glfwGetKeyName` could access out of bounds and return an + invalid pointer - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - [X11] Bugfix: `glfwFocusWindow` could terminate on older WMs or without a WM diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 30d8c1fc1b..129e975e55 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1516,6 +1516,13 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) { @autoreleasepool { + if (scancode < 0 || scancode > 0xff || + _glfw.ns.keycodes[scancode] == GLFW_KEY_UNKNOWN) + { + _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode"); + return NULL; + } + const int key = _glfw.ns.keycodes[scancode]; UInt32 deadKeyState = 0; diff --git a/src/win32_window.c b/src/win32_window.c index 38c12e0a40..14dc51a987 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -2016,6 +2016,13 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) const char* _glfwPlatformGetScancodeName(int scancode) { + if (scancode < 0 || scancode > (KF_EXTENDED | 0xff) || + _glfw.win32.keycodes[scancode] == GLFW_KEY_UNKNOWN) + { + _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode"); + return NULL; + } + return _glfw.win32.keynames[_glfw.win32.keycodes[scancode]]; } diff --git a/src/x11_window.c b/src/x11_window.c index 75986442ca..271e108094 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2862,6 +2862,13 @@ const char* _glfwPlatformGetScancodeName(int scancode) if (!_glfw.x11.xkb.available) return NULL; + if (scancode < 0 || scancode > 0xff || + _glfw.x11.keycodes[scancode] == GLFW_KEY_UNKNOWN) + { + _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode"); + return NULL; + } + const int key = _glfw.x11.keycodes[scancode]; const KeySym keysym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, _glfw.x11.xkb.group, 0); From e53538010a8f3695943f8f48bc83405c1a9692f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 15 Jan 2020 18:54:42 +0100 Subject: [PATCH 160/167] Win32: Fix scancode when key message only had VK Some synthetic key messages come with a scancode of zero, causing them to be translate to GLFW_KEY_UNKNOWN. This fills in the missing scancode by translating the provided virtual key. Rather than further complicate a single-use function, its body is merged into the key message handler. Fixes #1623. (cherry picked from commit 789a2bcb3985a882944f3ae8dc6aa8aa22a23494) --- README.md | 2 + src/win32_window.c | 108 ++++++++++++++++++++++----------------------- 2 files changed, 56 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index 801582c04a..031fb0e7d6 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,8 @@ information on what to include when reporting a bug. - [Win32] Bugfix: Super key was not released after Win+V hotkey (#1622) - [Win32] Bugfix: `glfwGetKeyName` could access out of bounds and return an invalid pointer + - [Win32] Bugfix: Some synthetic key events were reported as `GLFW_KEY_UNKNOWN` + (#1623) - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - [X11] Bugfix: `glfwFocusWindow` could terminate on older WMs or without a WM diff --git a/src/win32_window.c b/src/win32_window.c index 14dc51a987..c04d1a74e6 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -36,8 +36,6 @@ #include #include -#define _GLFW_KEY_INVALID -2 - // Returns the window style for the specified window // static DWORD getWindowStyle(const _GLFWwindow* window) @@ -448,55 +446,6 @@ static int getKeyMods(void) return mods; } -// Translates a Windows key to the corresponding GLFW key -// -static int translateKey(WPARAM wParam, LPARAM lParam) -{ - // The Ctrl keys require special handling - if (wParam == VK_CONTROL) - { - MSG next; - DWORD time; - - // Right side keys have the extended key bit set - if (HIWORD(lParam) & KF_EXTENDED) - return GLFW_KEY_RIGHT_CONTROL; - - // HACK: Alt Gr sends Left Ctrl and then Right Alt in close sequence - // We only want the Right Alt message, so if the next message is - // Right Alt we ignore this (synthetic) Left Ctrl message - time = GetMessageTime(); - - if (PeekMessageW(&next, NULL, 0, 0, PM_NOREMOVE)) - { - if (next.message == WM_KEYDOWN || - next.message == WM_SYSKEYDOWN || - next.message == WM_KEYUP || - next.message == WM_SYSKEYUP) - { - if (next.wParam == VK_MENU && - (HIWORD(next.lParam) & KF_EXTENDED) && - next.time == time) - { - // Next message is Right Alt down so discard this - return _GLFW_KEY_INVALID; - } - } - } - - return GLFW_KEY_LEFT_CONTROL; - } - - if (wParam == VK_PROCESSKEY) - { - // IME notifies that keys have been filtered by setting the virtual - // key-code to VK_PROCESSKEY - return _GLFW_KEY_INVALID; - } - - return _glfw.win32.keycodes[HIWORD(lParam) & 0x1FF]; -} - static void fitToMonitor(_GLFWwindow* window) { MONITORINFO mi = { sizeof(mi) }; @@ -717,13 +666,64 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, case WM_KEYUP: case WM_SYSKEYUP: { - const int key = translateKey(wParam, lParam); - const int scancode = (HIWORD(lParam) & 0x1ff); + int key, scancode; const int action = (HIWORD(lParam) & KF_UP) ? GLFW_RELEASE : GLFW_PRESS; const int mods = getKeyMods(); - if (key == _GLFW_KEY_INVALID) + scancode = (HIWORD(lParam) & (KF_EXTENDED | 0xff)); + if (!scancode) + { + // NOTE: Some synthetic key messages have a scancode of zero + // HACK: Map the virtual key back to a usable scancode + scancode = MapVirtualKeyW((UINT) wParam, MAPVK_VK_TO_VSC); + } + + key = _glfw.win32.keycodes[scancode]; + + // The Ctrl keys require special handling + if (wParam == VK_CONTROL) + { + if (HIWORD(lParam) & KF_EXTENDED) + { + // Right side keys have the extended key bit set + key = GLFW_KEY_RIGHT_CONTROL; + } + else + { + // NOTE: Alt Gr sends Left Ctrl followed by Right Alt + // HACK: We only want one event for Alt Gr, so if we detect + // this sequence we discard this Left Ctrl message now + // and later report Right Alt normally + MSG next; + const DWORD time = GetMessageTime(); + + if (PeekMessageW(&next, NULL, 0, 0, PM_NOREMOVE)) + { + if (next.message == WM_KEYDOWN || + next.message == WM_SYSKEYDOWN || + next.message == WM_KEYUP || + next.message == WM_SYSKEYUP) + { + if (next.wParam == VK_MENU && + (HIWORD(next.lParam) & KF_EXTENDED) && + next.time == time) + { + // Next message is Right Alt down so discard this + break; + } + } + } + + // This is a regular Left Ctrl message + key = GLFW_KEY_LEFT_CONTROL; + } + } + else if (wParam == VK_PROCESSKEY) + { + // IME notifies that keys have been filtered by setting the + // virtual key-code to VK_PROCESSKEY break; + } if (action == GLFW_RELEASE && wParam == VK_SHIFT) { From 6a9fd2e13f21a6a890745b20205beb1b095e4ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 15 Jan 2020 22:19:19 +0100 Subject: [PATCH 161/167] Win32: Add matching comment (cherry picked from commit 190673e77965b043bbb76020e5557d53c9d80cda) --- src/win32_window.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/win32_window.c b/src/win32_window.c index c04d1a74e6..0ce22ee7ad 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1908,6 +1908,7 @@ void _glfwPlatformPollEvents(void) // NOTE: Windows key is not reported as released by the Win+V hotkey // Other Win hotkeys are handled implicitly by _glfwInputWindowFocus // because they change the input focus + // NOTE: The other half of this is in the WM_*KEY* handler in windowProc handle = GetActiveWindow(); if (handle) { From 835dc3d32725a677ddd95dd22e7c3d9ac060ff69 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 21 Aug 2018 13:04:52 +0530 Subject: [PATCH 162/167] X11: Fix queries crashing if monitor disconnected Merged from downstream kovidgoyal/glfw. First of many. Related to #1602. (cherry picked from commit a5e5b782c7c7eaa71a1d60e71934724240ae2ab6) --- src/x11_monitor.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/x11_monitor.c b/src/x11_monitor.c index 412f9f409a..1f804aeb40 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -322,12 +322,16 @@ void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root); XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc); - if (xpos) - *xpos = ci->x; - if (ypos) - *ypos = ci->y; + if (ci) + { + if (xpos) + *xpos = ci->x; + if (ypos) + *ypos = ci->y; + + XRRFreeCrtcInfo(ci); + } - XRRFreeCrtcInfo(ci); XRRFreeScreenResources(sr); } } @@ -493,9 +497,15 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root); XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc); - *mode = vidmodeFromModeInfo(getModeInfo(sr, ci->mode), ci); + if (ci) + { + const XRRModeInfo* mi = getModeInfo(sr, ci->mode); + if (mi) // mi can be NULL if the monitor has been disconnected + *mode = vidmodeFromModeInfo(mi, ci); + + XRRFreeCrtcInfo(ci); + } - XRRFreeCrtcInfo(ci); XRRFreeScreenResources(sr); } else From ad12b97acdebe7cec54d25086f7f32367f0a5554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 16 Jan 2020 21:12:37 +0100 Subject: [PATCH 163/167] Update changelog and add credit Related to #1602. (cherry picked from commit 13479ed27dd94e4196205b173c6a2ab104ed21f5) --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 031fb0e7d6..3ff274955f 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,7 @@ information on what to include when reporting a bug. - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - [X11] Bugfix: `glfwFocusWindow` could terminate on older WMs or without a WM - [X11] Bugfix: Creating an undecorated window could fail with BadMatch (#1620) + - [X11] Bugfix: Querying a disconnected monitor could segfault (#1602) ## Contact @@ -228,6 +229,7 @@ skills. - Rokas Kupstys - Konstantin Käfer - Eric Larson + - Francis Lecavalier - Robin Leffmann - Glenn Lewis - Shane Liesegang From b1d4b6a5955806c49755ab1a607f93995bfed25b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 16 Jan 2020 23:29:38 +0100 Subject: [PATCH 164/167] Remove AppVeyor skip commits setting (cherry picked from commit 46c7c1cdffbc1753eea127b6252d0c5e018b82b1) --- .appveyor.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 2f4532ebaf..a21829a619 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -7,11 +7,6 @@ branches: - master - 3.3-stable skip_tags: true -skip_commits: - files: - - README.md - - LICENSE.md - - docs/* environment: matrix: - GENERATOR: MinGW Makefiles From 0a49ef0a00baa3ab520ddc452f0e3b1e099c5589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 19 Jan 2020 20:08:11 +0100 Subject: [PATCH 165/167] Update OpenGL bits of build documentation slightly This removes most references to GLU, replaces the legacy CMake cache variables for OpenGL with the modern namespaced target and switches to $() for command substitution. Fixes #1580. (cherry picked from commit d973acc123826666ecc9e6fd475682e3d84c54a6) --- README.md | 1 + docs/build.dox | 124 ++++++++++++++++--------------------------------- 2 files changed, 41 insertions(+), 84 deletions(-) diff --git a/README.md b/README.md index 3ff274955f..76c7a96b59 100644 --- a/README.md +++ b/README.md @@ -238,6 +238,7 @@ skills. - Eyal Lotem - Aaron Loucks - Luflosi + - lukect - Tristam MacDonald - Hans Mackowiak - Дмитри Малышев diff --git a/docs/build.dox b/docs/build.dox index f957ca9a69..5aeb136abc 100644 --- a/docs/build.dox +++ b/docs/build.dox @@ -78,6 +78,11 @@ compiler that the GLFW functions are defined in a DLL. The following macros control which OpenGL or OpenGL ES API header is included. Only one of these may be defined at a time. +@note GLFW does not provide any of the API headers mentioned below. They are +provided by your development environment or your OpenGL, OpenGL ES or Vulkan +SDK, and most of them can be downloaded from the +[Khronos Registry](https://www.khronos.org/registry/). + @anchor GLFW_INCLUDE_GLCOREARB __GLFW_INCLUDE_GLCOREARB__ makes the GLFW header include the modern `GL/glcorearb.h` header (`OpenGL/gl3.h` on macOS) instead of the regular OpenGL @@ -129,10 +134,6 @@ header selected above. This should only be used with the standard OpenGL header and only for compatibility with legacy code. GLU has been deprecated and should not be used in new code. -@note GLFW does not provide any of the API headers mentioned above. They must -be provided by your development environment or your OpenGL, OpenGL ES or Vulkan -SDK. - @note None of these macros may be defined during the compilation of GLFW itself. If your build includes GLFW and you define any these in your build files, make sure they are not applied to the GLFW sources. @@ -166,16 +167,11 @@ must also explicitly link with `gdi32`. Other toolchains including MinGW-w64 include it in the set of default libraries along with other dependencies like `user32` and `kernel32`. -If you are using GLU, you must also link with `glu32`. - The link library for the GLFW DLL is named `glfw3dll`. When compiling an application that uses the DLL version of GLFW, you need to define the @ref GLFW_DLL macro _before_ any inclusion of the GLFW header. This can be done either with a compiler switch or by defining it in your source code. -An application using the GLFW DLL does not need to link against any of its -dependencies, but you still have to link against `glu32` if it uses GLU. - @subsection build_link_cmake_source With CMake and GLFW source @@ -196,52 +192,39 @@ set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE) set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) @endcode -Then add the root directory of the GLFW source tree to your project. This -will add the `glfw` target and the necessary cache variables to your project. +Add the root directory of the GLFW source tree to your project. This will add +the `glfw` target to your project. @code{.cmake} add_subdirectory(path/to/glfw) @endcode -Once GLFW has been added to the project, link against it with the `glfw` target. -This adds all link-time dependencies of GLFW as it is currently configured, -the include directory for the GLFW header and, when applicable, the @ref -GLFW_DLL macro. +Once GLFW has been added, link your application against the `glfw` target. +This adds the GLFW library and its link-time dependencies as it is currently +configured, the include directory for the GLFW header and, when applicable, the +@ref GLFW_DLL macro. @code{.cmake} target_link_libraries(myapp glfw) @endcode -Note that the dependencies do not include OpenGL or GLU, as GLFW loads any -OpenGL, OpenGL ES or Vulkan libraries it needs at runtime and does not use GLU. -If your application calls OpenGL directly, instead of using a modern -[extension loader library](@ref context_glext_auto) you can find it by requiring -the OpenGL package. +Note that the `glfw` target does not depend on OpenGL, as GLFW loads any OpenGL, +OpenGL ES or Vulkan libraries it needs at runtime. If your application calls +OpenGL directly, instead of using a modern +[extension loader library](@ref context_glext_auto), use the OpenGL CMake +package. @code{.cmake} find_package(OpenGL REQUIRED) @endcode -If OpenGL is found, the `OPENGL_FOUND` variable is true and the -`OPENGL_INCLUDE_DIR` and `OPENGL_gl_LIBRARY` cache variables can be used. +If OpenGL is found, the `OpenGL::GL` target is added to your project, containing +library and include directory paths. Link against this like above. @code{.cmake} -target_include_directories(myapp PUBLIC ${OPENGL_INCLUDE_DIR}) -target_link_libraries(myapp ${OPENGL_gl_LIBRARY}) +target_link_libraries(myapp OpenGL::GL) @endcode -The OpenGL CMake package also looks for GLU. If GLU is found, the -`OPENGL_GLU_FOUND` variable is true and the `OPENGL_INCLUDE_DIR` and -`OPENGL_glu_LIBRARY` cache variables can be used. - -@code{.cmake} -target_link_libraries(myapp ${OPENGL_glu_LIBRARY}) -@endcode - -@note GLU has been deprecated and should not be used in new code, but some -legacy code requires it. See the [section on GLU](@ref moving_glu) in the -transition guide for suggested replacements. - @subsection build_link_cmake_package With CMake and installed GLFW binaries @@ -257,44 +240,30 @@ find_package(glfw3 3.3 REQUIRED) @endcode Once GLFW has been added to the project, link against it with the `glfw` target. -This adds all link-time dependencies of GLFW as it is currently configured, -the include directory for the GLFW header and, when applicable, the @ref -GLFW_DLL macro. +This adds the GLFW library and its link-time dependencies, the include directory +for the GLFW header and, when applicable, the @ref GLFW_DLL macro. @code{.cmake} target_link_libraries(myapp glfw) @endcode -Note that the dependencies do not include OpenGL or GLU, as GLFW loads any -OpenGL, OpenGL ES or Vulkan libraries it needs at runtime and does not use GLU. -If your application calls OpenGL directly, instead of using a modern -[extension loader library](@ref context_glext_auto) you can find it by requiring -the OpenGL package. +Note that the `glfw` target does not depend on OpenGL, as GLFW loads any OpenGL, +OpenGL ES or Vulkan libraries it needs at runtime. If your application calls +OpenGL directly, instead of using a modern +[extension loader library](@ref context_glext_auto), use the OpenGL CMake +package. @code{.cmake} find_package(OpenGL REQUIRED) @endcode -If OpenGL is found, the `OPENGL_FOUND` variable is true and the -`OPENGL_INCLUDE_DIR` and `OPENGL_gl_LIBRARY` cache variables can be used. +If OpenGL is found, the `OpenGL::GL` target is added to your project, containing +library and include directory paths. Link against this like above. @code{.cmake} -target_include_directories(myapp PUBLIC ${OPENGL_INCLUDE_DIR}) -target_link_libraries(myapp ${OPENGL_gl_LIBRARY}) +target_link_libraries(myapp OpenGL::GL) @endcode -The OpenGL CMake package also looks for GLU. If GLU is found, the -`OPENGL_GLU_FOUND` variable is true and the `OPENGL_INCLUDE_DIR` and -`OPENGL_glu_LIBRARY` cache variables can be used. - -@code{.cmake} -target_link_libraries(myapp ${OPENGL_glu_LIBRARY}) -@endcode - -@note GLU has been deprecated and should not be used in new code, but some -legacy code requires it. See the [section on GLU](@ref moving_glu) in the -transition guide for suggested replacements. - @subsection build_link_pkgconfig With makefiles and pkg-config on Unix @@ -309,42 +278,31 @@ A typical compile and link command-line when using the static version of the GLFW library may look like this: @code{.sh} -cc `pkg-config --cflags glfw3` -o myprog myprog.c `pkg-config --static --libs glfw3` +cc $(pkg-config --cflags glfw3) -o myprog myprog.c $(pkg-config --static --libs glfw3) @endcode If you are using the shared version of the GLFW library, omit the `--static` flag. @code{.sh} -cc `pkg-config --cflags glfw3` -o myprog myprog.c `pkg-config --libs glfw3` +cc $(pkg-config --cflags glfw3) -o myprog myprog.c $(pkg-config --libs glfw3) @endcode You can also use the `glfw3.pc` file without installing it first, by using the `PKG_CONFIG_PATH` environment variable. @code{.sh} -env PKG_CONFIG_PATH=path/to/glfw/src cc `pkg-config --cflags glfw3` -o myprog myprog.c `pkg-config --libs glfw3` +env PKG_CONFIG_PATH=path/to/glfw/src cc $(pkg-config --cflags glfw3) -o myprog myprog.c $(pkg-config --libs glfw3) @endcode -The dependencies do not include OpenGL or GLU, as GLFW loads any OpenGL, OpenGL -ES or Vulkan libraries it needs at runtime and does not use GLU. On macOS, GLU -is built into the OpenGL framework, so if you need GLU you don't need to do -anything extra. If you need GLU and are using Linux or BSD, you should add the -`glu` pkg-config package. - -@code{.sh} -cc `pkg-config --cflags glfw3 glu` -o myprog myprog.c `pkg-config --libs glfw3 glu` -@endcode - -@note GLU has been deprecated and should not be used in new code, but some -legacy code requires it. See the [section on GLU](@ref moving_glu) in the -transition guide for suggested replacements. - -If you are using the static version of the GLFW library, make sure you don't -link statically against GLU. +The dependencies do not include OpenGL, as GLFW loads any OpenGL, OpenGL ES or +Vulkan libraries it needs at runtime. If your application calls OpenGL +directly, instead of using a modern +[extension loader library](@ref context_glext_auto), you should add the `gl` +pkg-config package. @code{.sh} -cc `pkg-config --cflags glfw3 glu` -o myprog myprog.c `pkg-config --static --libs glfw3` `pkg-config --libs glu` +cc $(pkg-config --cflags glfw3 gl) -o myprog myprog.c $(pkg-config --libs glfw3 gl) @endcode @@ -378,9 +336,7 @@ for `-lglfw`. Note that you do not add the `.framework` extension to a framework when linking against it from the command-line. -The OpenGL framework contains both the OpenGL and GLU APIs, so there is nothing -special to do when using GLU. Also note that even though your machine may have -`libGL`-style OpenGL libraries, they are for use with the X Window System and -will _not_ work with the macOS native version of GLFW. +@note Your machine may have `libGL.*.dylib` style OpenGL library, but that is +for the X Window System and will not work with the macOS native version of GLFW. */ From 8bc966bbae4967a008252f1ac9b625e4dc77ad64 Mon Sep 17 00:00:00 2001 From: Yuanming Hu Date: Fri, 8 May 2020 20:51:28 -0400 Subject: [PATCH 166/167] remove dependency on glibc 2.27 --- src/monitor.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/monitor.c b/src/monitor.c index c6bcfd395a..348e97c1fa 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -36,6 +36,9 @@ #include #include +#if defined(__linux__) +__asm__(".symver powf,powf@GLIBC_2.2.5"); +#endif // Lexically compare video modes, used by qsort // From eba790a3dc088a5f8d51004399990863f7abf8ea Mon Sep 17 00:00:00 2001 From: jetbot Date: Fri, 26 Jun 2020 18:41:51 +0200 Subject: [PATCH 167/167] dependency on glibc 2.27 removed only on Linux x86/x64 architecture (needed for ARM). --- src/monitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/monitor.c b/src/monitor.c index 348e97c1fa..32ded56d63 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -36,7 +36,7 @@ #include #include -#if defined(__linux__) +#if defined(__linux__) && defined(__x86_64__) __asm__(".symver powf,powf@GLIBC_2.2.5"); #endif